]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBranch.cpp
Migrate Branch dialog to InsetParamsWidget
[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 }
37
38
39 void GuiBranch::paramsToDialog(Inset const * inset)
40 {
41         InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
42         typedef BranchList::const_iterator const_iterator;
43         BranchList const & branchlist = ib->buffer().params().branchlist();
44         docstring const cur_branch = ib->branch();
45
46         branchCO->clear();
47         const_iterator const begin = branchlist.begin();
48         const_iterator const end = branchlist.end();
49         int id = 0;
50         int count = 0;
51         for (const_iterator it = begin; it != end; ++it, ++count) {
52                 docstring const & branch = it->branch();
53                 branchCO->addItem(toqstr(branch));
54                 if (cur_branch == branch)
55                         id = count;
56         }
57         branchCO->setCurrentIndex(id);
58 }
59
60
61 docstring GuiBranch::dialogToParams() const
62 {
63         InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()));
64         return from_utf8(InsetBranch::params2string(params));
65 }
66
67 } // namespace frontend
68 } // namespace lyx
69
70 #include "moc_GuiBranch.cpp"