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