]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBranch.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[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 #include "BranchList.h"
19
20 #include "Buffer.h"
21 #include "BufferParams.h"
22 #include "BranchList.h"
23 #include "FuncRequest.h"
24
25 #include "insets/InsetBranch.h"
26
27 #include <QPushButton>
28
29 using namespace std;
30
31 namespace lyx {
32 namespace frontend {
33
34 GuiBranch::GuiBranch(GuiView & lv)
35         : GuiDialog(lv, "branch", qt_("Branch Settings"))
36 {
37         setupUi(this);
38
39         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
40         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
41         connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
42
43         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
44         bc().setOK(okPB);
45         bc().setCancel(closePB);
46 }
47
48
49 void GuiBranch::change_adaptor()
50 {
51         changed();
52 }
53
54
55 void GuiBranch::updateContents()
56 {
57         typedef BranchList::const_iterator const_iterator;
58
59         BranchList const & branchlist = buffer().params().branchlist();
60         docstring const cur_branch = params_.branch;
61
62         branchCO->clear();
63
64         const_iterator const begin = branchlist.begin();
65         const_iterator const end = branchlist.end();
66         int id = 0;
67         int count = 0;
68         for (const_iterator it = begin; it != end; ++it, ++count) {
69                 docstring const & branch = it->getBranch();
70                 branchCO->addItem(toqstr(branch));
71
72                 if (cur_branch == branch)
73                         id = count;
74         }
75         branchCO->setCurrentIndex(id);
76 }
77
78
79 void GuiBranch::applyView()
80 {
81         params_.branch = qstring_to_ucs4(branchCO->currentText());
82 }
83
84
85 bool GuiBranch::initialiseParams(string const & data)
86 {
87         InsetBranch::string2params(data, params_);
88         return true;
89 }
90
91
92 void GuiBranch::clearParams()
93 {
94         params_ = InsetBranchParams();
95 }
96
97
98 void GuiBranch::dispatchParams()
99 {
100         dispatch(FuncRequest(getLfun(), InsetBranch::params2string(params_)));
101 }
102
103
104 Dialog * createGuiBranch(GuiView & lv) { return new GuiBranch(lv); }
105
106
107 } // namespace frontend
108 } // namespace lyx
109
110 #include "GuiBranch_moc.cpp"