]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBranch.cpp
rename buffer parameter math_number_before to math_numbering_side
[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
23 #include "insets/InsetBranch.h"
24
25 #include <QPushButton>
26
27 using namespace std;
28
29 namespace lyx {
30 namespace frontend {
31
32 GuiBranch::GuiBranch(QWidget * parent) : InsetParamsWidget(parent)
33 {
34         setupUi(this);
35         connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
36         connect(invertedCB, SIGNAL(clicked()), this, SIGNAL(changed()));
37 }
38
39
40 void GuiBranch::paramsToDialog(Inset const * inset)
41 {
42         InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
43         typedef BranchList::const_iterator const_iterator;
44         BranchList const & branchlist = ib->buffer().params().branchlist();
45         docstring const cur_branch = ib->branch();
46
47         branchCO->clear();
48         const_iterator const begin = branchlist.begin();
49         const_iterator const end = branchlist.end();
50         int id = 0;
51         int count = 0;
52         for (const_iterator it = begin; it != end; ++it, ++count) {
53                 docstring const & branch = it->branch();
54                 branchCO->addItem(toqstr(branch));
55                 if (cur_branch == branch)
56                         id = count;
57         }
58         branchCO->setCurrentIndex(id);
59         invertedCB->setChecked(ib->params().inverted);
60 }
61
62
63 docstring GuiBranch::dialogToParams() const
64 {
65         InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()), invertedCB->isChecked());
66         return from_utf8(InsetBranch::params2string(params));
67 }
68
69
70 bool GuiBranch::checkWidgets(bool readonly) const
71 {
72         branchCO->setEnabled(!readonly);
73         invertedCB->setEnabled(!readonly);
74         return InsetParamsWidget::checkWidgets();
75 }
76
77
78 } // namespace frontend
79 } // namespace lyx
80
81 #include "moc_GuiBranch.cpp"