]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QBranch.C
enable Font cache only for MacOSX and inline width() for other platform.
[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 using std::string;
27
28 namespace lyx {
29 namespace frontend {
30
31 typedef QController<ControlBranch, QView<QBranchDialog> > base_class;
32
33
34 QBranch::QBranch(Dialog & parent)
35         : base_class(parent, lyx::to_utf8(_("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 = 0;
60         int count = 0;
61         for (const_iterator it = begin; it != end; ++it, ++count) {
62                 string const & branch = it->getBranch();
63                 dialog_->branchCO->addItem(toqstr(branch));
64
65                 if (cur_branch == branch)
66                         id = count;
67         }
68         dialog_->branchCO->setCurrentIndex(id);
69 }
70
71
72 void QBranch::apply()
73 {
74         string const type = fromqstr(dialog_->branchCO->currentText());
75         controller().params().branch = type;
76 }
77
78 } // namespace frontend
79 } // namespace lyx