diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index cfc696664a..bf18a131bd 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -17,10 +17,12 @@ #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); } diff --git a/src/frontends/qt4/GuiBibtex.h b/src/frontends/qt4/GuiBibtex.h index 1234703183..e9b6a16ee3 100644 --- a/src/frontends/qt4/GuiBibtex.h +++ b/src/frontends/qt4/GuiBibtex.h @@ -13,11 +13,13 @@ #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_; /// diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 7ba1dcc4d6..0163779498 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -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 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 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); } diff --git a/src/frontends/qt4/GuiCitation.h b/src/frontends/qt4/GuiCitation.h index bdafad9ecf..f91bcec672 100644 --- a/src/frontends/qt4/GuiCitation.h +++ b/src/frontends/qt4/GuiCitation.h @@ -15,18 +15,20 @@ #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 #include 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 index 6e7edaeaf3..0000000000 --- a/src/frontends/qt4/GuiCommand.h +++ /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 diff --git a/src/frontends/qt4/GuiDialog.cpp b/src/frontends/qt4/GuiDialog.cpp index aa7ae171d7..74c992bb49 100644 --- a/src/frontends/qt4/GuiDialog.cpp +++ b/src/frontends/qt4/GuiDialog.cpp @@ -11,14 +11,11 @@ #include #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 @@ -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 diff --git a/src/frontends/qt4/GuiHyperlink.cpp b/src/frontends/qt4/GuiHyperlink.cpp index 95ae76a64a..e195ef378d 100644 --- a/src/frontends/qt4/GuiHyperlink.cpp +++ b/src/frontends/qt4/GuiHyperlink.cpp @@ -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)); } diff --git a/src/frontends/qt4/GuiHyperlink.h b/src/frontends/qt4/GuiHyperlink.h index e55a677d3a..3b28c1aac3 100644 --- a/src/frontends/qt4/GuiHyperlink.h +++ b/src/frontends/qt4/GuiHyperlink.h @@ -13,13 +13,15 @@ #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 diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index 08da8668bf..7caf50fb18 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -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); } diff --git a/src/frontends/qt4/GuiInclude.h b/src/frontends/qt4/GuiInclude.h index c34143d77e..f066a2ab05 100644 --- a/src/frontends/qt4/GuiInclude.h +++ b/src/frontends/qt4/GuiInclude.h @@ -15,14 +15,15 @@ #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 diff --git a/src/frontends/qt4/GuiLabel.cpp b/src/frontends/qt4/GuiLabel.cpp index b90723e958..47564a1f05 100644 --- a/src/frontends/qt4/GuiLabel.cpp +++ b/src/frontends/qt4/GuiLabel.cpp @@ -12,9 +12,11 @@ #include "GuiLabel.h" +#include "FuncRequest.h" #include "qt_helpers.h" #include "support/debug.h" +#include "insets/InsetCommand.h" #include #include @@ -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); } diff --git a/src/frontends/qt4/GuiLabel.h b/src/frontends/qt4/GuiLabel.h index bdca993f1a..ef59bfd530 100644 --- a/src/frontends/qt4/GuiLabel.h +++ b/src/frontends/qt4/GuiLabel.h @@ -13,13 +13,15 @@ #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 diff --git a/src/frontends/qt4/GuiNomencl.cpp b/src/frontends/qt4/GuiNomencl.cpp index b34ba798cd..b7357194e6 100644 --- a/src/frontends/qt4/GuiNomencl.cpp +++ b/src/frontends/qt4/GuiNomencl.cpp @@ -14,14 +14,14 @@ #include "GuiNomencl.h" #include "qt_helpers.h" +#include "FuncRequest.h" + +#include "insets/InsetCommand.h" #include "support/debug.h" #include #include -#include -#include -#include 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); diff --git a/src/frontends/qt4/GuiNomencl.h b/src/frontends/qt4/GuiNomencl.h index 0029f448d3..7f3084f8e0 100644 --- a/src/frontends/qt4/GuiNomencl.h +++ b/src/frontends/qt4/GuiNomencl.h @@ -14,13 +14,15 @@ #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 diff --git a/src/frontends/qt4/GuiRef.cpp b/src/frontends/qt4/GuiRef.cpp index 759b668d01..f29403e67b 100644 --- a/src/frontends/qt4/GuiRef.cpp +++ b/src/frontends/qt4/GuiRef.cpp @@ -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 #include @@ -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 buffers = theBufferList().getFileNames(); for (vector::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); } diff --git a/src/frontends/qt4/GuiRef.h b/src/frontends/qt4/GuiRef.h index e6ff95857a..ed355a590f 100644 --- a/src/frontends/qt4/GuiRef.h +++ b/src/frontends/qt4/GuiRef.h @@ -12,9 +12,11 @@ #ifndef GUIREF_H #define GUIREF_H -#include "GuiCommand.h" +#include "GuiDialog.h" #include "ui_RefUi.h" +#include "insets/InsetCommandParams.h" + #include 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_; diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 7d5b42dd8b..eba02e902a 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -140,7 +140,6 @@ NOMOCHEADER = \ DialogView.h \ DockView.h \ FileDialog.h \ - GuiCommand.h \ GuiFontExample.h \ GuiFontLoader.h \ GuiFontMetrics.h \