]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBranch.cpp
less functions
[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 Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiBranch.h"
14
15 #include "ControlBranch.h"
16
17 #include "qt_helpers.h"
18 #include "BranchList.h"
19
20 #include "insets/InsetBranch.h"
21
22 #include <QPushButton>
23 #include <QCloseEvent>
24
25
26 namespace lyx {
27 namespace frontend {
28
29 GuiBranchDialog::GuiBranchDialog(LyXView & lv)
30         : GuiDialog(lv, "branch")
31 {
32         setupUi(this);
33         setController(new ControlBranch(*this));
34         setViewTitle(_("Branch Settings"));
35
36         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
37         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
38         connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
39
40         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
41         bc().setOK(okPB);
42         bc().setCancel(closePB);
43 }
44
45
46 ControlBranch & GuiBranchDialog::controller() const
47 {
48         return static_cast<ControlBranch &>(GuiDialog::controller());
49 }
50
51
52 void GuiBranchDialog::closeEvent(QCloseEvent * e)
53 {
54         slotClose();
55         e->accept();
56 }
57
58
59 void GuiBranchDialog::change_adaptor()
60 {
61         changed();
62 }
63
64
65 void GuiBranchDialog::update_contents()
66 {
67         typedef BranchList::const_iterator const_iterator;
68
69         BranchList const & branchlist = controller().branchlist();
70         docstring const cur_branch = controller().params().branch;
71
72         branchCO->clear();
73
74         const_iterator const begin = branchlist.begin();
75         const_iterator const end = branchlist.end();
76         int id = 0;
77         int count = 0;
78         for (const_iterator it = begin; it != end; ++it, ++count) {
79                 docstring const & branch = it->getBranch();
80                 branchCO->addItem(toqstr(branch));
81
82                 if (cur_branch == branch)
83                         id = count;
84         }
85         branchCO->setCurrentIndex(id);
86 }
87
88
89 void GuiBranchDialog::applyView()
90 {
91         docstring const type = qstring_to_ucs4(branchCO->currentText());
92         controller().params().branch = type;
93 }
94
95 } // namespace frontend
96 } // namespace lyx
97
98 #include "GuiBranch_moc.cpp"