]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QBranch.C
Minipage is no more (long live the box inset)
[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 "debug.h"
14 #include "qt_helpers.h"
15 #include "ControlBranch.h"
16 #include "insets/insetbranch.h"
17 #include "support/lstrings.h"
18
19 #include <qcombobox.h>
20 #include <qpushbutton.h>
21
22 #include "QBranchDialog.h"
23 #include "QBranch.h"
24 #include "Qt2BC.h"
25
26 using lyx::support::getVectorFromString;
27
28 using std::string;
29 using std::vector;
30
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         string all_branches(controller().params().branchlist.allBranches());
43
44         dialog_.reset(new QBranchDialog(this));
45
46         std::vector<string> all = getVectorFromString(all_branches, "|");
47         for (unsigned i = 0; i < all.size(); ++i) {
48                 QString const bname = toqstr(all[i].c_str());
49                 dialog_->branchCO->insertItem(bname);
50                 }
51
52         bcview().setOK(dialog_->okPB);
53         bcview().setCancel(dialog_->closePB);
54 }
55
56
57 void QBranch::update_contents()
58 {
59         // re-read branch list
60         dialog_->branchCO->clear();
61         string all_branches(controller().params().branchlist.allBranches());
62         string cur_branch(controller().params().branch);
63         unsigned int cur_item = 0;
64         std::vector<string> all = getVectorFromString(all_branches, "|");
65         for (unsigned i = 0; i < all.size(); ++i) {
66                 QString const bname = toqstr(all[i].c_str());
67                 dialog_->branchCO->insertItem(bname);
68                 if (bname == toqstr(cur_branch))
69                         cur_item = i;
70         }
71         // set to current item. A better idea anyone?
72         if (all_branches.find(cur_branch) != string::npos && cur_branch != "none")
73                 dialog_->branchCO->setCurrentItem(cur_item);
74 }
75
76
77 void QBranch::apply()
78 {
79         string const type = fromqstr(dialog_->branchCO->currentText());
80         controller().params().branch = type;
81 }