]> git.lyx.org Git - features.git/commitdiff
next ones
authorAndré Pönitz <poenitz@gmx.net>
Sun, 7 Oct 2007 14:41:49 +0000 (14:41 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 7 Oct 2007 14:41:49 +0000 (14:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20819 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiDialog.cpp
src/frontends/qt4/GuiDialog.h
src/frontends/qt4/GuiNomencl.cpp
src/frontends/qt4/GuiNomencl.h
src/frontends/qt4/GuiURL.cpp
src/frontends/qt4/GuiURL.h

index 6520da14e70dc2ff759a4e2f4bc0b8bfa2405420..310d62ed443c0128b87dd959f65d640d48b498c3 100644 (file)
@@ -19,7 +19,6 @@
 #include "GuiDelimiter.h"
 #include "GuiIndex.h"
 #include "GuiMathMatrix.h"
-#include "GuiNomencl.h"
 #include "GuiView.h"
 
 // Uncomment this if you prefer dock widget
@@ -92,7 +91,7 @@ Dialog * createGuiLabel(LyXView & lv);
 Dialog * createGuiListings(LyXView & lv);
 Dialog * createGuiLog(LyXView & lv);
 Dialog * createGuiMath(LyXView & lv);
-Dialog * createGuiNomencl(LyXView & lv);
+Dialog * createGuiNomenclature(LyXView & lv);
 Dialog * createGuiNote(LyXView & lv);
 Dialog * createGuiParagraph(LyXView & lv);
 Dialog * createGuiPreferences(LyXView & lv);
@@ -163,7 +162,7 @@ Dialog * Dialogs::build(string const & name)
        if (name == "index")
                return new GuiIndexDialog(lyxview_);
        if (name == "nomenclature")
-               return new GuiNomenclDialog(lyxview_);
+               return createGuiNomenclature(lyxview_);
        if (name == "label")
                return new GuiLabelDialog(lyxview_);
        if (name == "log")
index d93482538f884b2502df9105283f7b3fb6fe6673..fce86af55173ea37dd4b510ea3ea970d84a9f3c4 100644 (file)
@@ -267,4 +267,49 @@ void GuiDialog::closeEvent(QCloseEvent * e)
 } // namespace frontend
 } // namespace lyx
 
+
+/////////////////////////////////////////////////////////////////////
+//
+// Command based dialogs
+//
+/////////////////////////////////////////////////////////////////////
+
+#include "FuncRequest.h"
+#include "insets/InsetCommand.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+GuiCommand::GuiCommand(LyXView & lv, string const & name)
+       : GuiDialog(lv, name), Controller(this), params_(name), lfun_name_(name)
+{
+       setController(this, false);
+}
+
+
+bool GuiCommand::initialiseParams(string const & data)
+{
+       // The name passed with LFUN_INSET_APPLY is also the name
+       // used to identify the mailer.
+       InsetCommandMailer::string2params(lfun_name_, data, params_);
+       return true;
+}
+
+
+void GuiCommand::dispatchParams()
+{
+       if (lfun_name_.empty())
+               return;
+
+       string const lfun = 
+               InsetCommandMailer::params2string(lfun_name_, params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
+
 #include "GuiDialog_moc.cpp"
index 768b50a815f2d0c2972bf777043c63c7f85c47ad..33d3b285773e77bb5b2a2ca0ad1778f1b1aafcfd 100644 (file)
@@ -15,6 +15,8 @@
 #include "Dialog.h"
 #include "ButtonController.h"
 
+#include "insets/InsetCommandParams.h"
+
 #include <QDialog>
 #include <QObject>
 
@@ -164,6 +166,31 @@ private:
        LyXView * lyxview_; // FIXME: replace by moving to constructor
 };
 
+
+class GuiCommand : public GuiDialog, public Controller
+{
+public:
+       /// We need to know with what sort of inset we're associated.
+       GuiCommand(LyXView &, std::string const & name);
+       ///
+       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
 
index 1208faeb89e076e045d6b8bed90852031120b49a..02b06ec0bed05c67b6e13f06b8897546017346ef 100644 (file)
@@ -14,7 +14,6 @@
 #include "GuiNomencl.h"
 
 #include "debug.h"
-#include "ControlCommand.h"
 #include "qt_helpers.h"
 
 #include <QLabel>
@@ -29,15 +28,14 @@ using std::string;
 namespace lyx {
 namespace frontend {
 
-GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
-       : GuiDialog(lv, "nomenclature")
+GuiNomenclature::GuiNomenclature(LyXView & lv)
+       : GuiCommand(lv, "nomenclature")
 {
        setupUi(this);
-       setController(new ControlCommand(*this, "nomenclature"));
 
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-       connect(symbolED, SIGNAL(textChanged(const QString&)),
+       connect(symbolED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
        connect(descriptionTE, SIGNAL(textChanged()),
                this, SLOT(change_adaptor()));
@@ -53,36 +51,30 @@ GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
 }
 
 
-ControlCommand & GuiNomenclDialog::controller()
-{
-       return static_cast<ControlCommand &>(GuiDialog::controller());
-}
-
-
-void GuiNomenclDialog::change_adaptor()
+void GuiNomenclature::change_adaptor()
 {
        changed();
 }
 
 
-void GuiNomenclDialog::reject()
+void GuiNomenclature::reject()
 {
        slotClose();
 }
 
 
-void GuiNomenclDialog::closeEvent(QCloseEvent * e)
+void GuiNomenclature::closeEvent(QCloseEvent * e)
 {
        slotClose();
        e->accept();
 }
 
 
-void GuiNomenclDialog::updateContents()
+void GuiNomenclature::updateContents()
 {
-       prefixED->setText(toqstr(controller().params()["prefix"]));
-       symbolED->setText(toqstr(controller().params()["symbol"]));
-       QString description = toqstr(controller().params()["description"]);
+       prefixED->setText(toqstr(params_["prefix"]));
+       symbolED->setText(toqstr(params_["symbol"]));
+       QString description = toqstr(params_["description"]);
        description.replace("\\\\","\n");
        descriptionTE->setPlainText(description);
 
@@ -90,22 +82,29 @@ void GuiNomenclDialog::updateContents()
 }
 
 
-void GuiNomenclDialog::applyView()
+void GuiNomenclature::applyView()
 {
-       controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
-       controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
+       params_["prefix"] = qstring_to_ucs4(prefixED->text());
+       params_["symbol"] = qstring_to_ucs4(symbolED->text());
        QString description = descriptionTE->toPlainText();
        description.replace('\n',"\\\\");
-       controller().params()["description"] = qstring_to_ucs4(description);
+       params_["description"] = qstring_to_ucs4(description);
 }
 
 
-bool GuiNomenclDialog::isValid()
+bool GuiNomenclature::isValid()
 {
        QString const description = descriptionTE->toPlainText();
        return !symbolED->text().isEmpty() && !description.isEmpty();
 }
 
+
+Dialog * createGuiNomenclature(LyXView & lv)
+{
+       return new GuiNomenclature(lv);
+}
+
+
 } // namespace frontend
 } // namespace lyx
 
index f42f1f2b7f1003440d88c5b9abf1a8254eb7ea69..c8735f57754f3b00e70ef3a8afc6fd5a0457c90f 100644 (file)
 #define GUINOMENCL_H
 
 #include "GuiDialog.h"
-#include "ControlCommand.h"
 #include "ui_NomenclUi.h"
 
 namespace lyx {
 namespace frontend {
 
-class GuiNomenclDialog : public GuiDialog, public Ui::NomenclUi
+class GuiNomenclature : public GuiCommand, public Ui::NomenclUi
 {
        Q_OBJECT
 
 public:
-       GuiNomenclDialog(LyXView & lv);
+       GuiNomenclature(LyXView & lv);
 
 private Q_SLOTS:
        void change_adaptor();
@@ -35,8 +34,6 @@ private Q_SLOTS:
 private:
        ///
        void closeEvent(QCloseEvent * e);
-       /// parent controller
-       ControlCommand & controller();
        ///
        bool isValid();
        /// Apply changes
index ed5f11f9ab66470aa6603dd246b08c6872e154a9..a8ac7a77e2bff3175bd26034d2bfead530d5e86c 100644 (file)
@@ -28,11 +28,10 @@ namespace lyx {
 namespace frontend {
 
 GuiURL::GuiURL(LyXView & lv)
-       : GuiDialog(lv, "url"), Controller(this), params_("url")
+       : GuiCommand(lv, "url")
 {
        setupUi(this);
        setViewTitle( _("URL"));
-       setController(this, false);
 
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@@ -99,23 +98,6 @@ bool GuiURL::isValid()
 }
 
 
-bool GuiURL::initialiseParams(std::string const & data)
-{
-       // The name passed with LFUN_INSET_APPLY is also the name
-       // used to identify the mailer.
-       InsetCommandMailer::string2params("name", data, params_);
-       return true;
-}
-
-
-void GuiURL::dispatchParams()
-{
-       std::string const lfun = 
-               InsetCommandMailer::params2string("url", params_);
-       dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
 Dialog * createGuiURL(LyXView & lv) { return new GuiURL(lv); }
 
 
index 51dc2cf11dfd3a5383501ffc6c9ad75e41f1f7a1..66856f129eacf3f0ecbe5f14d3f8e1fc2bd4ca8c 100644 (file)
 #define GUIURL_H
 
 #include "GuiDialog.h"
-#include "ControlCommand.h"
 #include "ui_URLUi.h"
 #include "insets/InsetCommandParams.h"
 
 namespace lyx {
 namespace frontend {
 
-class GuiURL : public GuiDialog, public Ui::URLUi, public Controller
+class GuiURL : public GuiCommand, public Ui::URLUi
 {
        Q_OBJECT
 
@@ -33,26 +32,12 @@ public Q_SLOTS:
 
 private:
        void closeEvent(QCloseEvent *);
-       /// parent controller
-       Controller & controller() { return *this; }
        ///
        bool isValid();
        /// apply dialog
        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