]> git.lyx.org Git - features.git/commitdiff
some refactoring
authorAndré Pönitz <poenitz@gmx.net>
Sun, 7 Oct 2007 14:59:01 +0000 (14:59 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 7 Oct 2007 14:59:01 +0000 (14:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20821 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiCitation.cpp
src/frontends/qt4/GuiCitation.h
src/frontends/qt4/GuiIndex.cpp
src/frontends/qt4/GuiIndex.h

index 310d62ed443c0128b87dd959f65d640d48b498c3..4cc878c1b789df324d38df8efa19d97200e15c2b 100644 (file)
@@ -160,11 +160,11 @@ Dialog * Dialogs::build(string const & name)
        if (name == "include")
                return createGuiInclude(lyxview_);
        if (name == "index")
-               return new GuiIndexDialog(lyxview_);
+               return createGuiIndex(lyxview_);
        if (name == "nomenclature")
                return createGuiNomenclature(lyxview_);
        if (name == "label")
-               return new GuiLabelDialog(lyxview_);
+               return createGuiLabel(lyxview_);
        if (name == "log")
                return createGuiLog(lyxview_);
        if (name == "view-source")
index 588a7843a36e9d63a49392e9a93ab54c2b24c024..c39c1dd212ed18edea179dee9153bcf8c063c8a8 100644 (file)
@@ -25,6 +25,8 @@
 #include "support/lstrings.h"
 #include "support/docstring.h"
 
+#include "insets/InsetCommand.h"
+
 #include <vector>
 #include <string>
 
@@ -75,11 +77,10 @@ static vector<lyx::docstring> to_docstring_vector(QStringList const & qlist)
 
 
 GuiCitation::GuiCitation(LyXView & lv)
-       : GuiDialog(lv, "citation"), ControlCommand(*this, "citation")
+       : GuiCommand(lv, "citation")
 {
        setupUi(this);
        setViewTitle(_("Citation"));
-       setController(this, false);
 
        connect(citationStyleCO, SIGNAL(activated(int)),
                this, SLOT(changed()));
@@ -246,7 +247,7 @@ void GuiCitation::updateStyle()
        citationStyleCO->setEnabled(!basic_engine && haveSelection);
        citationStyleLA->setEnabled(!basic_engine && haveSelection);
 
-       string const & command = params().getCmdName();
+       string const & command = params_.getCmdName();
 
        // Find the style of the citekeys
        vector<biblio::CiteStyle> const & styles = citeStyles_;
@@ -458,10 +459,10 @@ void GuiCitation::apply(int const choice, bool const full, bool const force,
                biblio::CitationStyle(styles[choice], full, force)
                .asLatexStr();
 
-       params().setCmdName(command);
-       params()["key"] = qstring_to_ucs4(cited_keys_.join(","));
-       params()["before"] = qstring_to_ucs4(before);
-       params()["after"] = qstring_to_ucs4(after);
+       params_.setCmdName(command);
+       params_["key"] = qstring_to_ucs4(cited_keys_.join(","));
+       params_["before"] = qstring_to_ucs4(before);
+       params_["after"] = qstring_to_ucs4(after);
        dispatchParams();
 }
 
@@ -475,13 +476,13 @@ void GuiCitation::clearSelection()
 
 QString GuiCitation::textBefore()
 {
-       return toqstr(params()["before"]);
+       return toqstr(params_["before"]);
 }
 
 
 QString GuiCitation::textAfter()
 {
-       return toqstr(params()["after"]);
+       return toqstr(params_["after"]);
 }
 
 
@@ -492,7 +493,7 @@ void GuiCitation::init()
        available_model_.setStringList(all_keys_);
 
        // Ditto for the keys cited in this inset
-       QString str = toqstr(params()["key"]);
+       QString str = toqstr(params_["key"]);
        if (str.isEmpty())
                cited_keys_.clear();
        else
@@ -586,8 +587,7 @@ void GuiCitation::setCitedKeys()
 
 bool GuiCitation::initialiseParams(string const & data)
 {
-       if (!ControlCommand::initialiseParams(data))
-               return false;
+       InsetCommandMailer::string2params(lfun_name_, data, params_);
 
        biblio::CiteEngine const engine = buffer().params().getEngine();
 
@@ -607,10 +607,9 @@ bool GuiCitation::initialiseParams(string const & data)
 }
 
 
-
 void GuiCitation::clearParams()
 {
-       ControlCommand::clearParams();
+       params_.clear();
        bibkeysInfo_.clear();
 }
 
index 72d13f932f42bf1988aa807aeafe5bdded0460d2..9d392e5086f27b2c5ef6200e3a4b74023c4dc485 100644 (file)
@@ -29,8 +29,7 @@
 namespace lyx {
 namespace frontend {
 
-class GuiCitation
-       : public GuiDialog, public Ui::CitationUi, public ControlCommand
+class GuiCitation : public GuiCommand, public Ui::CitationUi
 {
        Q_OBJECT
 
@@ -54,8 +53,6 @@ public Q_SLOTS:
        void updateView();
 
 private:
-       ///
-       ControlCommand & controller() { return *this; }
        ///
        void closeEvent(QCloseEvent * e);
        /// prepares a call to GuiCitation::searchKeys when we
@@ -101,28 +98,20 @@ private:
 
        ///
        void init();
-
        /// Available keys
        QStringListModel * available() { return &available_model_; }
-
        /// Selected keys
        QStringListModel * selected() { return &selected_model_; }
-
        /// Text before cite
        QString textBefore();
-
        /// Text after cite
        QString textAfter();
-
        /// Get key description
        QString getKeyInfo(QString const &);
-
        /// Clear selected keys
        void clearSelection();
-       
        /// Return a list of available fields 
        QStringList getFieldsAsQStringList();
-       
        /// Return a list of available fields 
        QStringList getEntriesAsQStringList();
        
index 21583078a5b459813867fc7b694681b94c32ecff..4dbba0e45b20d9fb55eed65457415fdd71f0fd54 100644 (file)
@@ -12,8 +12,6 @@
 
 #include "GuiIndex.h"
 
-#include "ControlCommand.h"
-
 #include "debug.h"
 #include "qt_helpers.h"
 
@@ -36,12 +34,11 @@ namespace frontend {
 
 GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
                docstring const & title, QString const & label, std::string const & name)
-       : GuiDialog(lv, name)
+       : GuiCommand(lv, name)
 {
        label_ = label;
        setupUi(this);
        setViewTitle(title);
-       setController(new ControlCommand(*this, name));
 
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@@ -75,12 +72,6 @@ GuiIndexDialogBase::GuiIndexDialogBase(LyXView & lv,
 }
 
 
-ControlCommand & GuiIndexDialogBase::controller()
-{
-       return static_cast<ControlCommand &>(GuiDialog::controller());
-}
-
-
 void GuiIndexDialogBase::change_adaptor()
 {
        changed();
@@ -102,7 +93,7 @@ void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
 
 void GuiIndexDialogBase::updateContents()
 {
-       docstring const contents = controller().params()["name"];
+       docstring const contents = params_["name"];
        keywordED->setText(toqstr(contents));
        bc().setValid(!contents.empty());
 }
@@ -110,7 +101,7 @@ void GuiIndexDialogBase::updateContents()
 
 void GuiIndexDialogBase::applyView()
 {
-       controller().params()["name"] = qstring_to_ucs4(keywordED->text());
+       params_["name"] = qstring_to_ucs4(keywordED->text());
 }
 
 
@@ -127,7 +118,7 @@ bool GuiIndexDialogBase::isValid()
 /////////////////////////////////////////////////////////////////
 
 
-GuiIndexDialog::GuiIndexDialog(LyXView & lv)
+GuiIndex::GuiIndex(LyXView & lv)
        : GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"), "index") 
 {
        keywordED->setWhatsThis( qt_(
@@ -148,17 +139,23 @@ GuiIndexDialog::GuiIndexDialog(LyXView & lv)
 }
 
 
+Dialog * createGuiIndex(LyXView & lv) { return new GuiIndex(lv); }
+
+
 /////////////////////////////////////////////////////////////////
 //
 // Label Dialog
 //
 /////////////////////////////////////////////////////////////////
 
-GuiLabelDialog::GuiLabelDialog(LyXView & lv)
+GuiLabel::GuiLabel(LyXView & lv)
        : GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label")
 {}
 
 
+Dialog * createGuiLabel(LyXView & lv) { return new GuiLabel(lv); }
+
+
 } // namespace frontend
 } // namespace lyx
 
index 3db4df32de4b6c242e9c8ba017bb8c61343e7708..f354ac2c85fb2151ca20887659538d7795526075 100644 (file)
 #define GUIINDEX_H
 
 #include "GuiDialog.h"
-#include "ControlCommand.h"
 #include "ui_IndexUi.h"
 
 namespace lyx {
 namespace frontend {
 
-class GuiIndexDialogBase : public GuiDialog, public Ui::IndexUi
+class GuiIndexDialogBase : public GuiCommand, public Ui::IndexUi
 {
        Q_OBJECT
 
@@ -35,8 +34,6 @@ private Q_SLOTS:
 private:
        ///
        void closeEvent(QCloseEvent * e);
-       /// parent controller
-       ControlCommand & controller();
        ///
        bool isValid();
        /// Apply changes
@@ -49,17 +46,17 @@ private:
 };
 
 
-class GuiIndexDialog : public GuiIndexDialogBase
+class GuiIndex : public GuiIndexDialogBase
 {
 public:
-       GuiIndexDialog(LyXView & lv);
+       GuiIndex(LyXView & lv);
 };
 
 
-class GuiLabelDialog : public GuiIndexDialogBase
+class GuiLabel : public GuiIndexDialogBase
 {
 public:
-       GuiLabelDialog(LyXView & lv);
+       GuiLabel(LyXView & lv);
 };