3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
14 #include "qt_helpers.h"
15 #include "ControlBranch.h"
16 #include "insets/insetbranch.h"
17 #include "support/lstrings.h"
19 #include <qcombobox.h>
20 #include <qpushbutton.h>
22 #include "QBranchDialog.h"
26 using lyx::support::getVectorFromString;
32 typedef QController<ControlBranch, QView<QBranchDialog> > base_class;
35 QBranch::QBranch(Dialog & parent)
36 : base_class(parent, _("LyX: Branch Settings"))
40 void QBranch::build_dialog()
42 string all_branches(controller().params().branchlist.allBranches());
44 dialog_.reset(new QBranchDialog(this));
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);
52 bcview().setOK(dialog_->okPB);
53 bcview().setCancel(dialog_->closePB);
57 void QBranch::update_contents()
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))
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);
79 string const type = fromqstr(dialog_->branchCO->currentText());
80 controller().params().branch = type;