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 "support/gettext.h"
26 #include "support/lstrings.h"
28 #include <QPushButton>
31 using namespace lyx::support;
36 GuiBranch::GuiBranch(QWidget * parent) : InsetParamsWidget(parent)
39 connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
40 connect(invertedCB, SIGNAL(clicked()), this, SIGNAL(changed()));
44 void GuiBranch::paramsToDialog(Inset const * inset)
46 InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
47 Buffer const & buf = ib->buffer();
48 BranchList const & branchlist = buf.params().branchlist();
49 docstring const cur_branch = ib->branch();
54 for (Branch const & it : branchlist) {
55 docstring const & branch = it.branch();
56 branchCO->addItem(toqstr(branch), toqstr(branch));
57 if (cur_branch == branch)
61 // Add branches from master
62 Buffer const * masterBuf = buf.masterBuffer();
63 if (masterBuf != &buf) {
64 BranchList const & masterBranchlist = masterBuf->params().branchlist();
65 for (Branch const & it : masterBranchlist) {
66 docstring const & branch = it.branch();
67 if (!branchlist.find(branch)) {
69 toqstr(bformat(_("%1$s[[branch]] (%2$s)[[master]]"),
70 branch, _("master"))),
72 if (cur_branch == branch)
78 branchCO->setCurrentIndex(id);
79 invertedCB->setChecked(ib->params().inverted);
83 docstring GuiBranch::dialogToParams() const
85 docstring branch = qstring_to_ucs4(branchCO->itemData(branchCO->currentIndex()).toString());
86 InsetBranchParams params(branch, invertedCB->isChecked());
87 return from_utf8(InsetBranch::params2string(params));
91 bool GuiBranch::checkWidgets(bool readonly) const
93 branchCO->setEnabled(!readonly);
94 invertedCB->setEnabled(!readonly);
95 return InsetParamsWidget::checkWidgets();
99 } // namespace frontend
102 #include "moc_GuiBranch.cpp"