]> git.lyx.org Git - features.git/commitdiff
merge GuiCommand into its users.
authorAndré Pönitz <poenitz@gmx.net>
Sun, 20 Apr 2008 09:24:14 +0000 (09:24 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 20 Apr 2008 09:24:14 +0000 (09:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24376 a592a061-630c-0410-9148-cb99ea01b6c8

17 files changed:
src/frontends/qt4/GuiBibtex.cpp
src/frontends/qt4/GuiBibtex.h
src/frontends/qt4/GuiCitation.cpp
src/frontends/qt4/GuiCitation.h
src/frontends/qt4/GuiCommand.h [deleted file]
src/frontends/qt4/GuiDialog.cpp
src/frontends/qt4/GuiHyperlink.cpp
src/frontends/qt4/GuiHyperlink.h
src/frontends/qt4/GuiInclude.cpp
src/frontends/qt4/GuiInclude.h
src/frontends/qt4/GuiLabel.cpp
src/frontends/qt4/GuiLabel.h
src/frontends/qt4/GuiNomencl.cpp
src/frontends/qt4/GuiNomencl.h
src/frontends/qt4/GuiRef.cpp
src/frontends/qt4/GuiRef.h
src/frontends/qt4/Makefile.am

index cfc696664ad77fb9e4a1d73976bb58aef662b6eb..bf18a131bdfb08141a2a4da9b2320a43623671b8 100644 (file)
 
 #include "Buffer.h"
 #include "BufferParams.h"
-#include "ui_BibtexAddUi.h"
+#include "FuncRequest.h"
+#include "LyXRC.h"
 #include "qt_helpers.h"
 #include "Validator.h"
-#include "LyXRC.h"
+
+#include "ui_BibtexAddUi.h"
 
 #include "ButtonPolicy.h"
 
@@ -49,7 +51,8 @@ namespace frontend {
 
 
 GuiBibtex::GuiBibtex(GuiView & lv)
-       : GuiCommand(lv, "bibtex", qt_("BibTeX Bibliography"))
+       : GuiDialog(lv, "bibtex", qt_("BibTeX Bibliography")),
+         params_(insetCode("bibtex"))
 {
        setupUi(this);
 
@@ -532,6 +535,21 @@ QString GuiBibtex::styleFile() const
 }
 
 
+bool GuiBibtex::initialiseParams(std::string const & data)
+{
+       InsetCommand::string2params("bibtex", data, params_);
+       return true;
+}
+
+
+void GuiBibtex::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("bibtex", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+
 Dialog * createGuiBibtex(GuiView & lv) { return new GuiBibtex(lv); }
 
 
index 1234703183cf5ba033167c74df73b65afa08d4a3..e9b6a16ee37eb6a3546f04226cfc3292c4d7b52f 100644 (file)
 #ifndef GUIBIBTEX_H
 #define GUIBIBTEX_H
 
-#include "GuiCommand.h"
+#include "GuiDialog.h"
 #include "ButtonController.h"
 #include "ui_BibtexUi.h"
 #include "ui_BibtexAddUi.h"
 
+#include "insets/InsetCommandParams.h"
+
 
 namespace lyx {
 namespace frontend {
@@ -33,7 +35,7 @@ public:
 };
 
 
-class GuiBibtex : public GuiCommand, public Ui::BibtexUi
+class GuiBibtex : public GuiDialog, public Ui::BibtexUi
 {
        Q_OBJECT
 
@@ -79,6 +81,18 @@ private:
        /// which stylefile do we use?
        QString styleFile() const;
 
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams() { params_.clear(); }
+       /// clean-up on hide.
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+
+private:
+       ///
+       InsetCommandParams params_;
        ///
        GuiBibtexAddDialog * add_;
        ///
index 7ba1dcc4d6fd31fb44978913e0f6392cbec3cd58..0163779498078ff8e8435404eb43a8f67532c90a 100644 (file)
@@ -18,6 +18,7 @@
 #include "qt_helpers.h"
 #include "Buffer.h"
 #include "BufferParams.h"
+#include "FuncRequest.h"
 
 #include "insets/InsetCommand.h"
 
@@ -76,7 +77,8 @@ static vector<lyx::docstring> to_docstring_vector(QStringList const & qlist)
 
 
 GuiCitation::GuiCitation(GuiView & lv)
-       : GuiCommand(lv, "citation", qt_("Citation"))
+       : GuiDialog(lv, "citation", qt_("Citation")),
+         params_(insetCode("citation"))
 {
        setupUi(this);
 
@@ -589,7 +591,7 @@ void GuiCitation::setCitedKeys()
 
 bool GuiCitation::initialiseParams(string const & data)
 {
-       InsetCommand::string2params(lfun_name_, data, params_);
+       InsetCommand::string2params("citation", data, params_);
        biblio::CiteEngine const engine = buffer().params().citeEngine();
        bibkeysInfo_.fillWithBibKeys(&buffer());
        citeStyles_ = biblio::getCiteStyles(engine);
@@ -741,6 +743,13 @@ vector<docstring> GuiCitation::searchKeys(
 }
 
 
+void GuiCitation::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("citation", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
 Dialog * createGuiCitation(GuiView & lv) { return new GuiCitation(lv); }
 
 
index bdafad9ecf2fe442c899434aa2511b7d9913d0ff..f91bcec6729154a0f3fded008621270dbae85f81 100644 (file)
 #ifndef GUICITATION_H
 #define GUICITATION_H
 
-#include "GuiCommand.h"
+#include "GuiDialog.h"
 #include "GuiSelectionManager.h"
 #include "ui_CitationUi.h"
 #include "BiblioInfo.h"
 
+#include "insets/InsetCommandParams.h"
+
 #include <QStringList>
 #include <QStringListModel>
 
 namespace lyx {
 namespace frontend {
 
-class GuiCitation : public GuiCommand, public Ui::CitationUi
+class GuiCitation : public GuiDialog, public Ui::CitationUi
 {
        Q_OBJECT
 
@@ -126,6 +128,14 @@ private:
        /// Set the Params variable for the Controller.
        void apply(int const choice, bool const full, bool const force,
                                          QString before, QString after);
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams();
+       /// clean-up on hide.
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
 
 private:
        /// available keys.
@@ -136,12 +146,8 @@ private:
        QStringList all_keys_;
        /// Cited keys.
        QStringList cited_keys_;
-
        ///
-       bool initialiseParams(std::string const & data);
-
-       /// clean-up on hide.
-       void clearParams();
+       InsetCommandParams params_;
 
        /** Disconnect from the inset when the Apply button is pressed.
         *  Allows easy insertion of multiple citations.
diff --git a/src/frontends/qt4/GuiCommand.h b/src/frontends/qt4/GuiCommand.h
deleted file mode 100644 (file)
index 6e7edae..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// -*- C++ -*-
-/**
- * \file GuiCommand.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef GUICOMMAND_H
-#define GUICOMMAND_H
-
-#include "GuiDialog.h"
-
-#include "insets/InsetCommandParams.h"
-
-
-namespace lyx {
-namespace frontend {
-
-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(GuiView &, QString const & name, QString const & title);
-       ///
-       bool initialiseParams(std::string const & data);
-       /// clean-up on hide.
-       void clearParams() { params_.clear(); }
-       /// clean-up on hide.
-       void dispatchParams();
-       ///
-       bool isBufferDependent() const { return true; }
-
-protected:
-       ///
-       InsetCommandParams params_;
-       //FIXME It should be possible to eliminate lfun_name_
-       //now and recover that information from params().insetType().
-       //But let's not do that quite yet.
-       /// Flags what action is taken by Kernel::dispatch()
-       std::string const lfun_name_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // GUIDIALOG_H
index aa7ae171d716a4f150b720f6b1819729e621a3e1..74c992bb499305452dd3c14072b44b78752516b9 100644 (file)
 #include <config.h>
 
 #include "GuiDialog.h"
-#include "GuiCommand.h"
 
 #include "GuiView.h"
 #include "qt_helpers.h"
 #include "FuncRequest.h"
 
-#include "insets/InsetCommand.h"
-
 #include "support/debug.h"
 
 #include <QCloseEvent>
@@ -29,7 +26,7 @@ namespace lyx {
 namespace frontend {
 
 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
-       :  QDialog(&lv), Dialog(lv, name, "LyX: " + title), is_closing_(false)
+       : QDialog(&lv), Dialog(lv, name, "LyX: " + title), is_closing_(false)
 {}
 
 
@@ -111,40 +108,6 @@ void GuiDialog::updateView()
        setUpdatesEnabled(true);
 }
 
-
-/////////////////////////////////////////////////////////////////////
-//
-// Command based dialogs
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiCommand::GuiCommand(GuiView & lv, QString const & name,
-       QString const & title)
-       : GuiDialog(lv, name, title), params_(insetCode(fromqstr(name))),
-               lfun_name_(fromqstr(name))
-{
-}
-
-
-bool GuiCommand::initialiseParams(string const & data)
-{
-       // The name passed with LFUN_INSET_APPLY is also the name
-       // used to identify the mailer.
-       InsetCommand::string2params(lfun_name_, data, params_);
-       return true;
-}
-
-
-void GuiCommand::dispatchParams()
-{
-       if (lfun_name_.empty())
-               return;
-
-       string const lfun = InsetCommand::params2string(lfun_name_, params_);
-       dispatch(FuncRequest(getLfun(), lfun));
-}
-
 } // namespace frontend
 } // namespace lyx
 
index 95ae76a64a09e62819d68632735f1a07e725415e..e195ef378de958ec2baa7ffeb3f5a8811afe4354 100644 (file)
@@ -26,7 +26,8 @@ namespace lyx {
 namespace frontend {
 
 GuiHyperlink::GuiHyperlink(GuiView & lv)
-       : GuiCommand(lv, "href",qt_("Hyperlink"))
+       : GuiDialog(lv, "href", qt_("Hyperlink")),
+    params_(insetCode(fromqstr("href")))
 {
        setupUi(this);
 
@@ -91,10 +92,23 @@ void GuiHyperlink::applyView()
 
 bool GuiHyperlink::isValid()
 {
-       QString const u = targetED->text();
-       QString const n = nameED->text();
+       return !targetED->text().isEmpty() || !nameED->text().isEmpty();
+}
+
 
-       return !u.isEmpty() || !n.isEmpty();
+bool GuiHyperlink::initialiseParams(std::string const & data)
+{
+       // The name passed with LFUN_INSET_APPLY is also the name
+       // used to identify the mailer.
+       InsetCommand::string2params("href", data, params_);
+       return true;
+}
+
+
+void GuiHyperlink::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("href", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
 }
 
 
index e55a677d3aa448470009bcc5734f939db07a137f..3b28c1aac3fa8a136104b0a5291723238e253a50 100644 (file)
 #ifndef GUIHYPERLINK_H
 #define GUIHYPERLINK_H
 
-#include "GuiCommand.h"
+#include "GuiDialog.h"
 #include "ui_HyperlinkUi.h"
 
+#include "insets/InsetCommandParams.h"
+
 namespace lyx {
 namespace frontend {
 
-class GuiHyperlink : public GuiCommand, public Ui::HyperlinkUi
+class GuiHyperlink : public GuiDialog, public Ui::HyperlinkUi
 {
        Q_OBJECT
 
@@ -37,6 +39,18 @@ private:
        void applyView();
        /// update dialog
        void updateContents();
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams() { params_.clear(); }
+       /// clean-up on hide.
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+
+private:
+       ///
+       InsetCommandParams params_;
 };
 
 } // namespace frontend
index 08da8668bf5d29d3c1558bba7f70b87ded202200..7caf50fb188c850f262995896abc80b60ffd1cdf 100644 (file)
@@ -47,7 +47,8 @@ namespace frontend {
 
 
 GuiInclude::GuiInclude(GuiView & lv)
-       : GuiCommand(lv, "include", qt_("Child Document"))
+       : GuiDialog(lv, "include", qt_("Child Document")),
+         params_(insetCode("include"))
 {
        setupUi(this);
 
@@ -339,6 +340,20 @@ void GuiInclude::edit(string const & file)
 }
 
 
+bool GuiInclude::initialiseParams(std::string const & data)
+{
+       InsetCommand::string2params("include", data, params_);
+       return true;
+}
+
+
+void GuiInclude::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("include", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
 Dialog * createGuiInclude(GuiView & lv) { return new GuiInclude(lv); }
 
 
index c34143d77e52534843ba34ae4fb1791ec038dcff..f066a2ab05dae0a5142ec916637612ad3140ab91 100644 (file)
 #define GUIINCLUDE_H
 
 #include "GuiDialog.h"
-#include "GuiCommand.h"
 #include "ui_IncludeUi.h"
 
+#include "insets/InsetCommandParams.h"
+
 
 namespace lyx {
 namespace frontend {
 
-class GuiInclude : public GuiCommand, public Ui::IncludeUi
+class GuiInclude : public GuiDialog, public Ui::IncludeUi
 {
        Q_OBJECT
 
@@ -45,6 +46,15 @@ private Q_SLOTS:
        void set_listings_msg();
 
 private:
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams() { params_.clear(); }
+       /// clean-up on hide.
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+
        ///
        enum Type {
                ///
@@ -68,10 +78,12 @@ private:
        void applyView();
        /// update
        void updateContents();
-       ///
-       bool isBufferDependent() const { return true; }
        /// Browse for a file
        QString browse(QString const &, Type) const;
+
+private:
+       ///
+       InsetCommandParams params_;
 };
 
 } // namespace frontend
index b90723e958f6fabda1a02a3613110c6025db84e4..47564a1f05309779d754d4da402ea624a86ebf33 100644 (file)
 
 #include "GuiLabel.h"
 
+#include "FuncRequest.h"
 #include "qt_helpers.h"
 
 #include "support/debug.h"
+#include "insets/InsetCommand.h"
 
 #include <QLabel>
 #include <QPushButton>
@@ -27,12 +29,13 @@ namespace frontend {
 
 /////////////////////////////////////////////////////////////////
 //
-// Base implementation
+// GuiLabel
 //
 /////////////////////////////////////////////////////////////////
 
 GuiLabel::GuiLabel(GuiView & lv)
-       : GuiCommand(lv, "label", qt_("Label"))
+       : GuiDialog(lv, "label", qt_("Label")),
+         params_(insetCode("label"))
 {
        setupUi(this);
 
@@ -82,6 +85,20 @@ bool GuiLabel::isValid()
 }
 
 
+bool GuiLabel::initialiseParams(std::string const & data)
+{
+       InsetCommand::string2params("label", data, params_);
+       return true;
+}
+
+
+void GuiLabel::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("label", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
 Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
 
 
index bdca993f1af6731d8b2fff97d45260d044728297..ef59bfd530c1822d144f2039d03194ef20636537 100644 (file)
 #ifndef GUILABEL_H
 #define GUILABEL_H
 
-#include "GuiCommand.h"
+#include "GuiDialog.h"
 #include "ui_LabelUi.h"
 
+#include "insets/InsetCommandParams.h"
+
 namespace lyx {
 namespace frontend {
 
-class GuiLabel : public GuiCommand, public Ui::LabelUi
+class GuiLabel : public GuiDialog, public Ui::LabelUi
 {
        Q_OBJECT
 
@@ -37,6 +39,18 @@ private:
        void applyView();
        /// update
        void updateContents();
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams() { params_.clear(); }
+       /// clean-up on hide.
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+
+private:
+       ///
+       InsetCommandParams params_;
 };
 
 } // namespace frontend
index b34ba798cd142146d63ecbfb5cdeb25f98a23cc3..b7357194e684b9478610d3e86e4c18aaaf46a9a4 100644 (file)
 #include "GuiNomencl.h"
 
 #include "qt_helpers.h"
+#include "FuncRequest.h"
+
+#include "insets/InsetCommand.h"
 
 #include "support/debug.h"
 
 #include <QLabel>
 #include <QLineEdit>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QWhatsThis>
 
 using namespace std;
 
@@ -29,7 +29,8 @@ namespace lyx {
 namespace frontend {
 
 GuiNomenclature::GuiNomenclature(GuiView & lv)
-       : GuiCommand(lv, "nomenclature", qt_("Nomenclature"))
+       : GuiDialog(lv, "nomenclature", qt_("Nomenclature")),
+         params_(insetCode("nomenclature"))
 {
        setupUi(this);
 
@@ -92,6 +93,21 @@ bool GuiNomenclature::isValid()
 }
 
 
+bool GuiNomenclature::initialiseParams(std::string const & data)
+{
+       InsetCommand::string2params("nomenclature", data, params_);
+       return true;
+}
+
+
+void GuiNomenclature::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("nomenclature", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+
 Dialog * createGuiNomenclature(GuiView & lv)
 {
        return new GuiNomenclature(lv);
index 0029f448d370bdde797cd1e7224ee819a0617718..7f3084f8e06fd56cf7f0f4cb5c2511c4b5ff9b31 100644 (file)
 #ifndef GUINOMENCLATURE_H
 #define GUINOMENCLATURE_H
 
-#include "GuiCommand.h"
+#include "GuiDialog.h"
 #include "ui_NomenclUi.h"
 
+#include "insets/InsetCommandParams.h"
+
 namespace lyx {
 namespace frontend {
 
-class GuiNomenclature : public GuiCommand, public Ui::NomenclUi
+class GuiNomenclature : public GuiDialog, public Ui::NomenclUi
 {
        Q_OBJECT
 
@@ -38,6 +40,18 @@ private:
        void applyView();
        /// update
        void updateContents();
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams() { params_.clear(); }
+       /// clean-up on hide.
+       void dispatchParams();
+       ///
+       bool isBufferDependent() const { return true; }
+
+private:
+       ///
+       InsetCommandParams params_;
 };
 
 } // namespace frontend
index 759b668d01fc695115b1b4bd202192e18b1cf831..f29403e67b1bdb4b6121da4dc1a28b5990f85105 100644 (file)
@@ -22,7 +22,7 @@
 #include "insets/InsetRef.h"
 
 #include "support/FileName.h"
-#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
+#include "support/filetools.h" // makeAbsPath, makeDisplayPath
 
 #include <QLineEdit>
 #include <QCheckBox>
@@ -39,7 +39,8 @@ namespace lyx {
 namespace frontend {
 
 GuiRef::GuiRef(GuiView & lv)
-       : GuiCommand(lv, "ref", qt_("Cross-reference"))
+       : GuiDialog(lv, "ref", qt_("Cross-reference")),
+         params_(insetCode("ref"))
 {
        setupUi(this);
 
@@ -209,7 +210,7 @@ void GuiRef::updateContents()
        vector<string> buffers = theBufferList().getFileNames();
        for (vector<string>::iterator it = buffers.begin();
             it != buffers.end(); ++it) {
-               bufferCO->addItem(toqstr(lyx::to_utf8(makeDisplayPath(*it))));
+               bufferCO->addItem(toqstr(makeDisplayPath(*it)));
        }
 
        // restore the buffer combo setting for new insets
@@ -367,6 +368,21 @@ void GuiRef::gotoBookmark()
 }
 
 
+bool GuiRef::initialiseParams(std::string const & data)
+{
+       InsetCommand::string2params("ref", data, params_);
+       return true;
+}
+
+
+void GuiRef::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("ref", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+
 Dialog * createGuiRef(GuiView & lv) { return new GuiRef(lv); }
 
 
index e6ff95857a13451379d2661dd8ba4e1141c989d4..ed355a590f12c32a17bc11965626494b1b1ccf59 100644 (file)
 #ifndef GUIREF_H
 #define GUIREF_H
 
-#include "GuiCommand.h"
+#include "GuiDialog.h"
 #include "ui_RefUi.h"
 
+#include "insets/InsetCommandParams.h"
+
 #include <vector>
 
 class QListWidgetItem;
@@ -22,7 +24,7 @@ class QListWidgetItem;
 namespace lyx {
 namespace frontend {
 
-class GuiRef : public GuiCommand, public Ui::RefUi
+class GuiRef : public GuiDialog, public Ui::RefUi
 {
        Q_OBJECT
 
@@ -72,6 +74,16 @@ private:
        void redoRefs();
        /// update references
        void updateRefs();
+       ///
+       bool initialiseParams(std::string const & data);
+       /// clean-up on hide.
+       void clearParams() { params_.clear(); }
+       /// clean-up on hide.
+       void dispatchParams();
+
+private:
+       ///
+       InsetCommandParams params_;
 
        /// sort or not persistent state
        bool sort_;
index 7d5b42dd8be9624c11b4db9cbcdaaccadb7663d7..eba02e902a354ea51921cdb940a9b0d467b0ef7e 100644 (file)
@@ -140,7 +140,6 @@ NOMOCHEADER = \
        DialogView.h \
        DockView.h \
        FileDialog.h \
-       GuiCommand.h \
        GuiFontExample.h \
        GuiFontLoader.h \
        GuiFontMetrics.h \