]> git.lyx.org Git - features.git/commitdiff
Make GuiRef and GuiInclude subclasses of GuiCommand.
authorRichard Heck <rgheck@comcast.net>
Mon, 29 Oct 2007 16:51:07 +0000 (16:51 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 29 Oct 2007 16:51:07 +0000 (16:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21264 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiDialog.h
src/frontends/qt4/GuiInclude.cpp
src/frontends/qt4/GuiInclude.h
src/frontends/qt4/GuiRef.cpp
src/frontends/qt4/GuiRef.h

index 7e8aa6c32269ae724d8628e91880e97f225310b7..6e3618b888113facfb436bcedc73a59dc78f9b95 100644 (file)
@@ -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);
index 019d005c1d1be31b5a522aef4aec1d5721f235f8..41c5a05a681c510e65148f0075e66b45c85d4516 100644 (file)
@@ -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");
index 3f46796e266862ed9c8096be5845008b1dba9e83..5007be8ba7769adfbb75e8f5cc85de39dc46cf53 100644 (file)
@@ -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
index 5dc8ced74f6979c6218f43f9d9d6ace5a685817b..364e7be739a28648cf18807e60f8da591d934da6 100644 (file)
@@ -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); }
 
 
index 96285e3640ff218bce8442253e1ebe89d7b54309..b5b8e03b56b41c5b8c9c4159ea3a0143cf2a6b95 100644 (file)
@@ -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<docstring> refs_;
-
-       ///
-       InsetCommandParams params_;
 };
 
 } // namespace frontend