3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
7 * \author Martin Vermeer
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "GuiBranch.h"
17 #include "qt_helpers.h"
20 #include "BufferParams.h"
21 #include "BranchList.h"
23 #include "insets/InsetBranch.h"
25 #include <QPushButton>
32 GuiBranch::GuiBranch(QWidget * parent) : InsetParamsWidget(parent)
35 connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
36 connect(invertedCB, SIGNAL(clicked()), this, SIGNAL(changed()));
40 void GuiBranch::paramsToDialog(Inset const * inset)
42 InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
43 typedef BranchList::const_iterator const_iterator;
44 BranchList const & branchlist = ib->buffer().params().branchlist();
45 docstring const cur_branch = ib->branch();
48 const_iterator const begin = branchlist.begin();
49 const_iterator const end = branchlist.end();
52 for (const_iterator it = begin; it != end; ++it, ++count) {
53 docstring const & branch = it->branch();
54 branchCO->addItem(toqstr(branch));
55 if (cur_branch == branch)
58 branchCO->setCurrentIndex(id);
59 invertedCB->setChecked(ib->params().inverted);
63 docstring GuiBranch::dialogToParams() const
65 InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()), invertedCB->isChecked());
66 return from_utf8(InsetBranch::params2string(params));
70 bool GuiBranch::checkWidgets(bool readonly) const
72 branchCO->setEnabled(!readonly);
73 invertedCB->setEnabled(!readonly);
74 return InsetParamsWidget::checkWidgets();
78 } // namespace frontend
81 #include "moc_GuiBranch.cpp"