]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBranch.cpp
math stuff
[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 #include <QCloseEvent>
29
30 using std::string;
31 using std::vector;
32
33 namespace lyx {
34 namespace frontend {
35
36 GuiBranch::GuiBranch(LyXView & lv)
37         : GuiDialog(lv, "branch"), Controller(this)
38 {
39         setupUi(this);
40         setController(this, false);
41         setViewTitle(_("Branch Settings"));
42
43         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
44         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
45         connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
46
47         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
48         bc().setOK(okPB);
49         bc().setCancel(closePB);
50 }
51
52
53 void GuiBranch::closeEvent(QCloseEvent * e)
54 {
55         slotClose();
56         e->accept();
57 }
58
59
60 void GuiBranch::change_adaptor()
61 {
62         changed();
63 }
64
65
66 void GuiBranch::updateContents()
67 {
68         typedef BranchList::const_iterator const_iterator;
69
70         BranchList const & branchlist = buffer().params().branchlist();
71         docstring const cur_branch = params_.branch;
72
73         branchCO->clear();
74
75         const_iterator const begin = branchlist.begin();
76         const_iterator const end = branchlist.end();
77         int id = 0;
78         int count = 0;
79         for (const_iterator it = begin; it != end; ++it, ++count) {
80                 docstring const & branch = it->getBranch();
81                 branchCO->addItem(toqstr(branch));
82
83                 if (cur_branch == branch)
84                         id = count;
85         }
86         branchCO->setCurrentIndex(id);
87 }
88
89
90 void GuiBranch::applyView()
91 {
92         params_.branch = qstring_to_ucs4(branchCO->currentText());
93 }
94
95
96 bool GuiBranch::initialiseParams(string const & data)
97 {
98         InsetBranchMailer::string2params(data, params_);
99         return true;
100 }
101
102
103 void GuiBranch::clearParams()
104 {
105         params_ = InsetBranchParams();
106 }
107
108
109 void GuiBranch::dispatchParams()
110 {
111         dispatch(FuncRequest(getLfun(), InsetBranchMailer::params2string(params_)));
112 }
113
114
115 Dialog * createGuiBranch(LyXView & lv) { return new GuiBranch(lv); }
116
117
118 } // namespace frontend
119 } // namespace lyx
120
121 #include "GuiBranch_moc.cpp"