From 24b95a387c659c4725dee7a5816f3a8fb16ba1b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sun, 7 Oct 2007 14:59:01 +0000 Subject: [PATCH] some refactoring git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20821 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/Dialogs.cpp | 4 ++-- src/frontends/qt4/GuiCitation.cpp | 27 +++++++++++++-------------- src/frontends/qt4/GuiCitation.h | 13 +------------ src/frontends/qt4/GuiIndex.cpp | 25 +++++++++++-------------- src/frontends/qt4/GuiIndex.h | 13 +++++-------- 5 files changed, 32 insertions(+), 50 deletions(-) diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 310d62ed44..4cc878c1b7 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -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") diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 588a7843a3..c39c1dd212 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -25,6 +25,8 @@ #include "support/lstrings.h" #include "support/docstring.h" +#include "insets/InsetCommand.h" + #include #include @@ -75,11 +77,10 @@ static vector 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 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(); } diff --git a/src/frontends/qt4/GuiCitation.h b/src/frontends/qt4/GuiCitation.h index 72d13f932f..9d392e5086 100644 --- a/src/frontends/qt4/GuiCitation.h +++ b/src/frontends/qt4/GuiCitation.h @@ -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(); diff --git a/src/frontends/qt4/GuiIndex.cpp b/src/frontends/qt4/GuiIndex.cpp index 21583078a5..4dbba0e45b 100644 --- a/src/frontends/qt4/GuiIndex.cpp +++ b/src/frontends/qt4/GuiIndex.cpp @@ -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(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 diff --git a/src/frontends/qt4/GuiIndex.h b/src/frontends/qt4/GuiIndex.h index 3db4df32de..f354ac2c85 100644 --- a/src/frontends/qt4/GuiIndex.h +++ b/src/frontends/qt4/GuiIndex.h @@ -14,13 +14,12 @@ #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); }; -- 2.39.2