From: André Pönitz Date: Fri, 5 Oct 2007 23:12:55 +0000 (+0000) Subject: next one X-Git-Tag: 1.6.10~8003 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=85b05737d4fb83ec80443d79ffd409b5028c7200;p=features.git next one git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20766 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/controllers/ControlBranch.cpp b/src/frontends/controllers/ControlBranch.cpp deleted file mode 100644 index f80ece0ca0..0000000000 --- a/src/frontends/controllers/ControlBranch.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \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 - -#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 diff --git a/src/frontends/controllers/ControlBranch.h b/src/frontends/controllers/ControlBranch.h deleted file mode 100644 index 1c2fe9c144..0000000000 --- a/src/frontends/controllers/ControlBranch.h +++ /dev/null @@ -1,52 +0,0 @@ -// -*- 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 diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 82ff1ef0e3..f7338cc89f 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -11,7 +11,6 @@ SOURCEFILES = \ ButtonPolicy.cpp \ ControlBibtex.cpp \ ControlBox.cpp \ - ControlBranch.cpp \ ControlCharacter.cpp \ ControlChanges.cpp \ ControlCitation.cpp \ @@ -43,7 +42,6 @@ HEADERFILES = \ ButtonPolicy.h \ ControlBibtex.h \ ControlBox.h \ - ControlBranch.h \ ControlCharacter.h \ ControlChanges.h \ ControlCitation.h \ diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 4e550ccaba..440499f3e1 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -20,7 +20,6 @@ #include "GuiBibitem.h" #include "GuiBibtex.h" #include "GuiBox.h" -#include "GuiBranch.h" #include "GuiChanges.h" #include "GuiCharacter.h" #include "GuiCitation.h" @@ -166,7 +165,7 @@ Dialog * Dialogs::build(string const & name) } 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") { diff --git a/src/frontends/qt4/GuiBranch.cpp b/src/frontends/qt4/GuiBranch.cpp index 1a85b35fff..7832e9e05e 100644 --- a/src/frontends/qt4/GuiBranch.cpp +++ b/src/frontends/qt4/GuiBranch.cpp @@ -3,6 +3,8 @@ * 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. @@ -12,25 +14,30 @@ #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 #include +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())); @@ -43,31 +50,25 @@ GuiBranchDialog::GuiBranchDialog(LyXView & lv) } -ControlBranch & GuiBranchDialog::controller() -{ - return static_cast(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(); @@ -86,12 +87,34 @@ void GuiBranchDialog::updateContents() } -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 diff --git a/src/frontends/qt4/GuiBranch.h b/src/frontends/qt4/GuiBranch.h index b0a78638c6..7fe05e6897 100644 --- a/src/frontends/qt4/GuiBranch.h +++ b/src/frontends/qt4/GuiBranch.h @@ -4,6 +4,8 @@ * 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. @@ -13,18 +15,19 @@ #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(); @@ -33,13 +36,23 @@ private: /// 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 diff --git a/src/frontends/qt4/GuiBranches.cpp b/src/frontends/qt4/GuiBranches.cpp index 2198506ff5..46966c9fbb 100644 --- a/src/frontends/qt4/GuiBranches.cpp +++ b/src/frontends/qt4/GuiBranches.cpp @@ -13,7 +13,6 @@ #include "GuiBranches.h" -#include "ControlBranch.h" #include "ControlDocument.h" #include "GuiApplication.h" #include "Validator.h" @@ -52,6 +51,7 @@ void GuiBranches::update(BufferParams const & params) updateView(); } + void GuiBranches::updateView() { // store the selected branch @@ -65,8 +65,7 @@ void GuiBranches::updateView() 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); @@ -90,11 +89,13 @@ void GuiBranches::updateView() changed(); } + void GuiBranches::apply(BufferParams & params) const { params.branchlist() = branchlist_; } + void GuiBranches::on_addBranchPB_pressed() { QString const new_branch = newBranchLE->text(); @@ -108,8 +109,7 @@ void GuiBranches::on_addBranchPB_pressed() void GuiBranches::on_removePB_pressed() { - QTreeWidgetItem * selItem = - branchesTW->currentItem(); + QTreeWidgetItem * selItem = branchesTW->currentItem(); QString sel_branch; if (selItem != 0) sel_branch = selItem->text(0); @@ -142,13 +142,14 @@ void GuiBranches::toggleBranch(QTreeWidgetItem * item) 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(); } } @@ -165,22 +166,24 @@ void GuiBranches::toggleColor(QTreeWidgetItem * item) 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