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