]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QBranch.cpp
Whitespace cleanup
[lyx.git] / src / frontends / qt4 / QBranch.cpp
1 /**
2  * \file QBranch.cpp
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 "Qt2BC.h"
15 #include "qt_helpers.h"
16
17 #include "BranchList.h"
18
19 #include "controllers/ControlBranch.h"
20
21 #include "insets/InsetBranch.h"
22
23 #include <QPushButton>
24 #include <QCloseEvent>
25
26 namespace lyx {
27 namespace frontend {
28
29 /////////////////////////////////////////////////////////////////////
30 //
31 // QBranchDialog
32 //
33 /////////////////////////////////////////////////////////////////////
34
35 QBranchDialog::QBranchDialog(QBranch * form)
36         : form_(form)
37 {
38         setupUi(this);
39         connect(okPB, SIGNAL(clicked()),
40                 form, SLOT(slotOK()));
41         connect(closePB, SIGNAL(clicked()),
42                 form, SLOT(slotClose()));
43         connect(branchCO, SIGNAL( activated(int) ),
44                 this, SLOT( change_adaptor() ) );
45 }
46
47
48 void QBranchDialog::closeEvent(QCloseEvent * e)
49 {
50         form_->slotWMHide();
51         e->accept();
52 }
53
54
55 void QBranchDialog::change_adaptor()
56 {
57         form_->changed();
58 }
59
60
61 /////////////////////////////////////////////////////////////////////
62 //
63 // QBranch
64 //
65 /////////////////////////////////////////////////////////////////////
66
67 typedef QController<ControlBranch, QView<QBranchDialog> > branch_base_class;
68
69
70 QBranch::QBranch(Dialog & parent)
71         : branch_base_class(parent, _("Branch Settings"))
72 {}
73
74
75 void QBranch::build_dialog()
76 {
77         dialog_.reset(new QBranchDialog(this));
78
79         bcview().setOK(dialog_->okPB);
80         bcview().setCancel(dialog_->closePB);
81 }
82
83
84 void QBranch::update_contents()
85 {
86         typedef BranchList::const_iterator const_iterator;
87
88         BranchList const & branchlist = controller().branchlist();
89         docstring const cur_branch = controller().params().branch;
90
91         dialog_->branchCO->clear();
92
93         const_iterator const begin = branchlist.begin();
94         const_iterator const end = branchlist.end();
95         int id = 0;
96         int count = 0;
97         for (const_iterator it = begin; it != end; ++it, ++count) {
98                 docstring const & branch = it->getBranch();
99                 dialog_->branchCO->addItem(toqstr(branch));
100
101                 if (cur_branch == branch)
102                         id = count;
103         }
104         dialog_->branchCO->setCurrentIndex(id);
105 }
106
107
108 void QBranch::apply()
109 {
110         docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
111         controller().params().branch = type;
112 }
113
114 } // namespace frontend
115 } // namespace lyx
116
117 #include "QBranch_moc.cpp"