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