]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QBranch.C
* src/frontends/qt4/GuiSelection.C
[lyx.git] / src / frontends / qt4 / QBranch.C
1 /**
2  * \file QBranch.C
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 "QBranch.h"
14 #include "QBranchDialog.h"
15 #include "Qt2BC.h"
16 #include "qt_helpers.h"
17
18 #include "BranchList.h"
19
20 #include "controllers/ControlBranch.h"
21
22 #include "insets/insetbranch.h"
23
24 #include <QPushButton>
25
26 namespace lyx {
27 namespace frontend {
28
29 typedef QController<ControlBranch, QView<QBranchDialog> > base_class;
30
31
32 QBranch::QBranch(Dialog & parent)
33         : base_class(parent, _("Branch Settings"))
34 {}
35
36
37 void QBranch::build_dialog()
38 {
39         dialog_.reset(new QBranchDialog(this));
40
41         bcview().setOK(dialog_->okPB);
42         bcview().setCancel(dialog_->closePB);
43 }
44
45
46 void QBranch::update_contents()
47 {
48         typedef BranchList::const_iterator const_iterator;
49
50         BranchList const & branchlist = controller().branchlist();
51         docstring const cur_branch = controller().params().branch;
52
53         dialog_->branchCO->clear();
54
55         const_iterator const begin = branchlist.begin();
56         const_iterator const end = branchlist.end();
57         int id = 0;
58         int count = 0;
59         for (const_iterator it = begin; it != end; ++it, ++count) {
60                 docstring const & branch = it->getBranch();
61                 dialog_->branchCO->addItem(toqstr(branch));
62
63                 if (cur_branch == branch)
64                         id = count;
65         }
66         dialog_->branchCO->setCurrentIndex(id);
67 }
68
69
70 void QBranch::apply()
71 {
72         docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
73         controller().params().branch = type;
74 }
75
76 } // namespace frontend
77 } // namespace lyx