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