From: Richard Heck Date: Mon, 29 Oct 2007 16:51:07 +0000 (+0000) Subject: Make GuiRef and GuiInclude subclasses of GuiCommand. X-Git-Tag: 1.6.10~7616 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a0a04e4886fe33f06c3b1b2351d2a26eee681854;p=features.git Make GuiRef and GuiInclude subclasses of GuiCommand. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21264 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiDialog.h b/src/frontends/qt4/GuiDialog.h index 7e8aa6c322..6e3618b888 100644 --- a/src/frontends/qt4/GuiDialog.h +++ b/src/frontends/qt4/GuiDialog.h @@ -152,6 +152,7 @@ class GuiCommand : public GuiDialog { public: /// We need to know with what sort of inset we're associated. + // FIXME This should probably be an InsetCode GuiCommand(LyXView &, std::string const & name); /// bool initialiseParams(std::string const & data); diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index 019d005c1d..41c5a05a68 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -59,13 +59,8 @@ using support::getStringFromVector; using support::getVectorFromString; -/// Flags what action is taken by Kernel::dispatch() -/// Needed because we're not inheriting from GuiCommand -static std::string const lfun_include_ = "include"; - - GuiInclude::GuiInclude(LyXView & lv) - : GuiDialog(lv, "include"), params_(INCLUDE_CODE) + : GuiCommand(lv, "include") { setupUi(this); setViewTitle(_("Child Document")); @@ -329,25 +324,6 @@ bool GuiInclude::isValid() } -bool GuiInclude::initialiseParams(string const & data) -{ - InsetCommandMailer::string2params(lfun_include_, data, params_); - return true; -} - - -void GuiInclude::clearParams() -{ - params_.clear(); -} - - -void GuiInclude::dispatchParams() -{ - dispatch(FuncRequest(getLfun(), InsetCommandMailer::params2string(lfun_include_, params_))); -} - - docstring GuiInclude::browse(docstring const & in_name, Type in_type) const { docstring const title = _("Select document to include"); diff --git a/src/frontends/qt4/GuiInclude.h b/src/frontends/qt4/GuiInclude.h index 3f46796e26..5007be8ba7 100644 --- a/src/frontends/qt4/GuiInclude.h +++ b/src/frontends/qt4/GuiInclude.h @@ -25,9 +25,7 @@ namespace lyx { namespace frontend { -//FIXME This could, and therefore probably should, inherit from -//GuiCommand. -class GuiInclude : public GuiDialog, public Ui::IncludeUi +class GuiInclude : public GuiCommand, public Ui::IncludeUi { Q_OBJECT @@ -50,6 +48,18 @@ private Q_SLOTS: void set_listings_msg(); private: + /// + enum Type { + /// + INPUT, + /// + VERBATIM, + /// + INCLUDE, + /// + LISTINGS, + }; + /// void closeEvent(QCloseEvent * e); /// void updateLists(); @@ -57,41 +67,16 @@ private: docstring validate_listings_params(); /// void edit(std::string const & file); - /// bool isValid(); /// Apply changes void applyView(); /// update void updateContents(); - - /// - enum Type { - /// - INPUT, - /// - VERBATIM, - /// - INCLUDE, - /// - LISTINGS, - }; - - /// - bool initialiseParams(std::string const & data); - /// clean-up on hide. - void clearParams(); - /// clean-up on hide. - void dispatchParams(); /// bool isBufferDependent() const { return true; } - /// Browse for a file docstring browse(docstring const &, Type) const; - -private: - /// - InsetCommandParams params_; }; } // namespace frontend diff --git a/src/frontends/qt4/GuiRef.cpp b/src/frontends/qt4/GuiRef.cpp index 5dc8ced74f..364e7be739 100644 --- a/src/frontends/qt4/GuiRef.cpp +++ b/src/frontends/qt4/GuiRef.cpp @@ -42,12 +42,8 @@ namespace frontend { using support::makeAbsPath; using support::makeDisplayPath; -/// Flags what action is taken by Kernel::dispatch() -/// Needed because we're not inheriting from GuiCommand -static std::string const lfun_ref_ = "ref"; - GuiRef::GuiRef(LyXView & lv) - : GuiDialog(lv, "ref"), params_(REF_CODE) + : GuiCommand(lv, "ref") { setupUi(this); setViewTitle(_("Cross-reference")); @@ -376,28 +372,6 @@ void GuiRef::gotoBookmark() } -bool GuiRef::initialiseParams(string const & data) -{ - // The name passed with LFUN_INSET_APPLY is also the name - // used to identify the mailer. - InsetCommandMailer::string2params(lfun_ref_, data, params_); - return true; -} - - -void GuiRef::clearParams() -{ - params_.clear(); -} - - -void GuiRef::dispatchParams() -{ - string const lfun = InsetCommandMailer::params2string(lfun_ref_, params_); - dispatch(FuncRequest(getLfun(), lfun)); -} - - Dialog * createGuiRef(LyXView & lv) { return new GuiRef(lv); } diff --git a/src/frontends/qt4/GuiRef.h b/src/frontends/qt4/GuiRef.h index 96285e3640..b5b8e03b56 100644 --- a/src/frontends/qt4/GuiRef.h +++ b/src/frontends/qt4/GuiRef.h @@ -24,10 +24,7 @@ class QListWidgetItem; namespace lyx { namespace frontend { -// FIXME This could, and therefore, should inherit from -// GuiCommand. Note, e.g., that the definitions of the first -// three private functions all just replicate what's there. -class GuiRef : public GuiDialog, public Ui::RefUi +class GuiRef : public GuiCommand, public Ui::RefUi { Q_OBJECT @@ -45,15 +42,8 @@ private Q_SLOTS: void reset_dialog(); private: - /// - bool initialiseParams(std::string const & data); - /// clean-up on hide. - void clearParams(); - /// clean-up on hide. - void dispatchParams(); /// bool isBufferDependent() const { return true; } - /** disconnect from the inset when the Apply button is pressed. Allows easy insertion of multiple references. */ bool disconnectOnApply() const { return true; } @@ -61,7 +51,6 @@ private: void gotoRef(std::string const &); /// void gotoBookmark(); - /// void closeEvent(QCloseEvent * e); /// @@ -96,9 +85,6 @@ private: int restored_buffer_; /// the references std::vector refs_; - - /// - InsetCommandParams params_; }; } // namespace frontend