+++ /dev/null
-/**
- * \file ControlBranch.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Martin Vermeer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlBranch.h"
-
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "BranchList.h"
-#include "FuncRequest.h"
-
-using std::string;
-using std::vector;
-
-namespace lyx {
-namespace frontend {
-
-ControlBranch::ControlBranch(Dialog & parent)
- : Controller(parent)
-{}
-
-
-bool ControlBranch::initialiseParams(string const & data)
-{
- InsetBranchMailer::string2params(data, params_);
- return true;
-}
-
-
-void ControlBranch::clearParams()
-{
- params_ = InsetBranchParams();
-}
-
-void ControlBranch::dispatchParams()
-{
- string const lfun = InsetBranchMailer::params2string(params());
- dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-BranchList const & ControlBranch::branchlist() const
-{
- return buffer().params().branchlist();
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file ControlBranch.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Martin Vermeer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef CONTROLBRANCH_H
-#define CONTROLBRANCH_H
-
-#include "Dialog.h"
-#include "insets/InsetBranch.h"
-
-namespace lyx {
-
-class BranchList;
-
-namespace frontend {
-
-class ControlBranch : public Controller
-{
-public:
- ///
- ControlBranch(Dialog &);
- ///
- virtual bool initialiseParams(std::string const & data);
- ///
- virtual void clearParams();
- ///
- virtual void dispatchParams();
- ///
- virtual bool isBufferDependent() const { return true; }
- ///
- InsetBranchParams & params() { return params_; }
- ///
- InsetBranchParams const & params() const { return params_; }
- ///
- BranchList const & branchlist() const;
-private:
- ///
- InsetBranchParams params_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLBRANCH_H
ButtonPolicy.cpp \
ControlBibtex.cpp \
ControlBox.cpp \
- ControlBranch.cpp \
ControlCharacter.cpp \
ControlChanges.cpp \
ControlCitation.cpp \
ButtonPolicy.h \
ControlBibtex.h \
ControlBox.h \
- ControlBranch.h \
ControlCharacter.h \
ControlChanges.h \
ControlCitation.h \
#include "GuiBibitem.h"
#include "GuiBibtex.h"
#include "GuiBox.h"
-#include "GuiBranch.h"
#include "GuiChanges.h"
#include "GuiCharacter.h"
#include "GuiCitation.h"
} else if (name == "box") {
dialog = new GuiBoxDialog(lyxview_);
} else if (name == "branch") {
- dialog = new GuiBranchDialog(lyxview_);
+ dialog = createGuiBranch(lyxview_);
} else if (name == "changes") {
dialog = new GuiChangesDialog(lyxview_);
} else if (name == "character") {
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
+ * \author Angus Leeming
+ * \author Martin Vermeer
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
#include "GuiBranch.h"
-#include "ControlBranch.h"
-
#include "qt_helpers.h"
#include "BranchList.h"
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "BranchList.h"
+#include "FuncRequest.h"
+
#include "insets/InsetBranch.h"
#include <QPushButton>
#include <QCloseEvent>
+using std::string;
+using std::vector;
namespace lyx {
namespace frontend {
-GuiBranchDialog::GuiBranchDialog(LyXView & lv)
- : GuiDialog(lv, "branch")
+GuiBranch::GuiBranch(LyXView & lv)
+ : GuiDialog(lv, "branch"), Controller(this)
{
setupUi(this);
- setController(new ControlBranch(*this));
+ setController(this, false);
setViewTitle(_("Branch Settings"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
}
-ControlBranch & GuiBranchDialog::controller()
-{
- return static_cast<ControlBranch &>(GuiDialog::controller());
-}
-
-
-void GuiBranchDialog::closeEvent(QCloseEvent * e)
+void GuiBranch::closeEvent(QCloseEvent * e)
{
slotClose();
e->accept();
}
-void GuiBranchDialog::change_adaptor()
+void GuiBranch::change_adaptor()
{
changed();
}
-void GuiBranchDialog::updateContents()
+void GuiBranch::updateContents()
{
typedef BranchList::const_iterator const_iterator;
- BranchList const & branchlist = controller().branchlist();
- docstring const cur_branch = controller().params().branch;
+ BranchList const & branchlist = buffer().params().branchlist();
+ docstring const cur_branch = params_.branch;
branchCO->clear();
}
-void GuiBranchDialog::applyView()
+void GuiBranch::applyView()
+{
+ params_.branch = qstring_to_ucs4(branchCO->currentText());
+}
+
+
+bool GuiBranch::initialiseParams(string const & data)
{
- docstring const type = qstring_to_ucs4(branchCO->currentText());
- controller().params().branch = type;
+ InsetBranchMailer::string2params(data, params_);
+ return true;
}
+
+void GuiBranch::clearParams()
+{
+ params_ = InsetBranchParams();
+}
+
+
+void GuiBranch::dispatchParams()
+{
+ dispatch(FuncRequest(getLfun(), InsetBranchMailer::params2string(params_)));
+}
+
+
+Dialog * createGuiBranch(LyXView & lv) { return new GuiBranch(lv); }
+
+
} // namespace frontend
} // namespace lyx
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
+ * \author Angus Leeming
+ * \author Martin Vermeer
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
#define GUIBRANCH_H
#include "GuiDialog.h"
-#include "ControlBranch.h"
#include "ui_BranchUi.h"
+#include "insets/InsetBranch.h"
+
namespace lyx {
namespace frontend {
-class GuiBranchDialog : public GuiDialog, public Ui::BranchUi
+class GuiBranch : public GuiDialog, public Ui::BranchUi, public Controller
{
Q_OBJECT
public:
- GuiBranchDialog(LyXView & lv);
+ GuiBranch(LyXView & lv);
private Q_SLOTS:
void change_adaptor();
///
void closeEvent(QCloseEvent * e);
/// parent controller
- ControlBranch & controller();
+ Controller & controller() { return *this; }
/// Apply changes
void applyView();
/// Update dialog before showing it
void updateContents();
-};
+ ///
+ bool initialiseParams(std::string const & data);
+ ///
+ void clearParams();
+ ///
+ void dispatchParams();
+ ///
+ bool isBufferDependent() const { return true; }
+ ///
+ InsetBranchParams params_;
+};
} // namespace frontend
} // namespace lyx
#include "GuiBranches.h"
-#include "ControlBranch.h"
#include "ControlDocument.h"
#include "GuiApplication.h"
#include "Validator.h"
updateView();
}
+
void GuiBranches::updateView()
{
// store the selected branch
BranchList::const_iterator it = branchlist_.begin();
BranchList::const_iterator const end = branchlist_.end();
for (; it != end; ++it) {
- QTreeWidgetItem * newItem =
- new QTreeWidgetItem(branchesTW);
+ QTreeWidgetItem * newItem = new QTreeWidgetItem(branchesTW);
QString const bname = toqstr(it->getBranch());
newItem->setText(0, bname);
changed();
}
+
void GuiBranches::apply(BufferParams & params) const
{
params.branchlist() = branchlist_;
}
+
void GuiBranches::on_addBranchPB_pressed()
{
QString const new_branch = newBranchLE->text();
void GuiBranches::on_removePB_pressed()
{
- QTreeWidgetItem * selItem =
- branchesTW->currentItem();
+ QTreeWidgetItem * selItem = branchesTW->currentItem();
QString sel_branch;
if (selItem != 0)
sel_branch = selItem->text(0);
return;
QString sel_branch = item->text(0);
- if (!sel_branch.isEmpty()) {
- bool const selected = item->text(1) == qt_("Yes");
- Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
- if (branch && branch->setSelected(!selected)) {
- newBranchLE->clear();
- updateView();
- }
+ if (sel_branch.isEmpty())
+ return;
+
+ bool const selected = (item->text(1) == qt_("Yes"));
+ Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
+ if (branch && branch->setSelected(!selected)) {
+ newBranchLE->clear();
+ updateView();
}
}
return;
QString sel_branch = item->text(0);
- if (!sel_branch.isEmpty()) {
- docstring current_branch = qstring_to_ucs4(sel_branch);
- Branch * branch =
- branchlist_.find(current_branch);
- if (!branch)
- return;
-
- QColor const initial = rgb2qcolor(branch->getColor());
- QColor ncol(QColorDialog::getColor(initial, qApp->focusWidget()));
- if (ncol.isValid()){
- // add the color to the branchlist
- branch->setColor(fromqstr(ncol.name()));
- newBranchLE->clear();
- updateView();
- }
- }
+ if (sel_branch.isEmpty())
+ return;
+
+ docstring current_branch = qstring_to_ucs4(sel_branch);
+ Branch * branch =
+ branchlist_.find(current_branch);
+ if (!branch)
+ return;
+
+ QColor const initial = rgb2qcolor(branch->getColor());
+ QColor ncol = QColorDialog::getColor(initial, qApp->focusWidget());
+ if (!ncol.isValid())
+ return;
+
+ // add the color to the branchlist
+ branch->setColor(fromqstr(ncol.name()));
+ newBranchLE->clear();
+ updateView();
}
} // namespace frontend