2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiBranch.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2007-10-05 23:12:55 +00:00
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Martin Vermeer
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiBranch.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "qt_helpers.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-05 23:12:55 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
|
|
|
#include "BranchList.h"
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetBranch.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2010-02-19 20:57:25 +00:00
|
|
|
GuiBranch::GuiBranch(QWidget * parent) : InsetParamsWidget(parent)
|
2007-04-25 08:42:22 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2010-02-19 20:57:25 +00:00
|
|
|
connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
|
2016-07-12 03:56:32 +00:00
|
|
|
connect(invertedCB, SIGNAL(clicked()), this, SIGNAL(changed()));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-19 20:57:25 +00:00
|
|
|
void GuiBranch::paramsToDialog(Inset const * inset)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2010-02-19 20:57:25 +00:00
|
|
|
InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
|
2006-03-05 17:24:44 +00:00
|
|
|
typedef BranchList::const_iterator const_iterator;
|
2010-02-19 20:57:25 +00:00
|
|
|
BranchList const & branchlist = ib->buffer().params().branchlist();
|
|
|
|
docstring const cur_branch = ib->branch();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
branchCO->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
const_iterator const begin = branchlist.begin();
|
|
|
|
const_iterator const end = branchlist.end();
|
|
|
|
int id = 0;
|
|
|
|
int count = 0;
|
|
|
|
for (const_iterator it = begin; it != end; ++it, ++count) {
|
2008-09-21 19:27:20 +00:00
|
|
|
docstring const & branch = it->branch();
|
2007-09-05 20:33:29 +00:00
|
|
|
branchCO->addItem(toqstr(branch));
|
2006-03-05 17:24:44 +00:00
|
|
|
if (cur_branch == branch)
|
|
|
|
id = count;
|
|
|
|
}
|
2007-09-05 20:33:29 +00:00
|
|
|
branchCO->setCurrentIndex(id);
|
2016-07-12 03:56:32 +00:00
|
|
|
invertedCB->setChecked(ib->params().inverted);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-19 20:57:25 +00:00
|
|
|
docstring GuiBranch::dialogToParams() const
|
2007-10-05 23:12:55 +00:00
|
|
|
{
|
2016-07-12 03:56:32 +00:00
|
|
|
InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()), invertedCB->isChecked());
|
2010-02-19 20:57:25 +00:00
|
|
|
return from_utf8(InsetBranch::params2string(params));
|
2007-10-05 23:12:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 15:03:08 +00:00
|
|
|
|
|
|
|
bool GuiBranch::checkWidgets(bool readonly) const
|
|
|
|
{
|
|
|
|
branchCO->setEnabled(!readonly);
|
2016-07-12 03:56:32 +00:00
|
|
|
invertedCB->setEnabled(!readonly);
|
2015-04-02 15:03:08 +00:00
|
|
|
return InsetParamsWidget::checkWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 08:42:22 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiBranch.cpp"
|