]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBranch.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiBranch.cpp
1 /**
2  * \file GuiBranch.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author Martin Vermeer
8  * \author Jürgen Spitzmüller
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiBranch.h"
16
17 #include "qt_helpers.h"
18
19 #include "Buffer.h"
20 #include "BufferParams.h"
21 #include "BranchList.h"
22 #include "FuncRequest.h"
23
24 #include "insets/InsetBranch.h"
25
26 #include <QPushButton>
27
28 using namespace std;
29
30 namespace lyx {
31 namespace frontend {
32
33 GuiBranch::GuiBranch(GuiView & lv)
34         : GuiDialog(lv, "branch", qt_("Branch Settings"))
35 {
36         setupUi(this);
37
38         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
39         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
40         connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
41
42         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
43         bc().setOK(okPB);
44         bc().setCancel(closePB);
45 }
46
47
48 void GuiBranch::change_adaptor()
49 {
50         changed();
51 }
52
53
54 void GuiBranch::updateContents()
55 {
56         typedef BranchList::const_iterator const_iterator;
57
58         BranchList const & branchlist = buffer().params().branchlist();
59         docstring const cur_branch = params_.branch;
60
61         branchCO->clear();
62
63         const_iterator const begin = branchlist.begin();
64         const_iterator const end = branchlist.end();
65         int id = 0;
66         int count = 0;
67         for (const_iterator it = begin; it != end; ++it, ++count) {
68                 docstring const & branch = it->branch();
69                 branchCO->addItem(toqstr(branch));
70
71                 if (cur_branch == branch)
72                         id = count;
73         }
74         branchCO->setCurrentIndex(id);
75 }
76
77
78 void GuiBranch::applyView()
79 {
80         params_.branch = qstring_to_ucs4(branchCO->currentText());
81 }
82
83
84 bool GuiBranch::initialiseParams(string const & data)
85 {
86         InsetBranch::string2params(data, params_);
87         return true;
88 }
89
90
91 void GuiBranch::clearParams()
92 {
93         params_ = InsetBranchParams();
94 }
95
96
97 void GuiBranch::dispatchParams()
98 {
99         dispatch(FuncRequest(getLfun(), InsetBranch::params2string(params_)));
100 }
101
102
103 Dialog * createGuiBranch(GuiView & lv) { return new GuiBranch(lv); }
104
105
106 } // namespace frontend
107 } // namespace lyx
108
109 #include "moc_GuiBranch.cpp"