]> git.lyx.org Git - features.git/commitdiff
next one
authorAndré Pönitz <poenitz@gmx.net>
Fri, 5 Oct 2007 23:12:55 +0000 (23:12 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 5 Oct 2007 23:12:55 +0000 (23:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20766 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlBranch.cpp [deleted file]
src/frontends/controllers/ControlBranch.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiBranch.cpp
src/frontends/qt4/GuiBranch.h
src/frontends/qt4/GuiBranches.cpp

diff --git a/src/frontends/controllers/ControlBranch.cpp b/src/frontends/controllers/ControlBranch.cpp
deleted file mode 100644 (file)
index f80ece0..0000000
+++ /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 <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
diff --git a/src/frontends/controllers/ControlBranch.h b/src/frontends/controllers/ControlBranch.h
deleted file mode 100644 (file)
index 1c2fe9c..0000000
+++ /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
index 82ff1ef0e3b856adbee2b3e510100980bff03b13..f7338cc89f9a1137200cd2ff572c1e999f9c0714 100644 (file)
@@ -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 \
index 4e550ccaba5ff06fbb37a520d21f485906ffb8e8..440499f3e1ab0e8fd08c2ae4cda084962d701273 100644 (file)
@@ -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") {
index 1a85b35fff4e12b58f4a3646d99c04ea569be3b5..7832e9e05e128b78a84abce87a62b683c9f7fb44 100644 (file)
@@ -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.
 
 #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()));
@@ -43,31 +50,25 @@ GuiBranchDialog::GuiBranchDialog(LyXView & lv)
 }
 
 
-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();
 
@@ -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
 
index b0a78638c69f1c7ec767c1fb2abacfaa43f40d26..7fe05e6897b786ee73ce6bf71a370a2378ec0d10 100644 (file)
@@ -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.
 #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
index 2198506ff58f5d5331b83bd8c8be38f828128be3..46966c9fbbda5ef1b24c04f1ba79682550f0d854 100644 (file)
@@ -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