]> git.lyx.org Git - features.git/commitdiff
Migrate ERT dialog to InsetDialog.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 7 Feb 2010 21:41:39 +0000 (21:41 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 7 Feb 2010 21:41:39 +0000 (21:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33354 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiERT.cpp
src/frontends/qt4/GuiERT.h
src/frontends/qt4/InsetDialog.cpp

index 65a6095cee2a7ddb979fdc91ed0ca8b2769d69b6..aa8ee5fc7f6b652dc94fed6d372a3278a002d665 100644 (file)
@@ -13,6 +13,9 @@
 #include <config.h>
 
 #include "GuiERT.h"
+
+#include "insets/InsetERT.h"
+
 #include "FuncRequest.h"
 
 #include "support/gettext.h"
@@ -26,64 +29,41 @@ namespace lyx {
 namespace frontend {
 
 GuiERT::GuiERT(GuiView & lv)
-       : GuiDialog(lv, "ert", qt_("TeX Code Settings")), status_(InsetCollapsable::Collapsed)
+       : InsetDialog(lv, ERT_CODE, LFUN_INSET_INSERT, "ert", "TeX Code Settings")
 {
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-       connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-       connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-
-       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setCancel(closePB);
+       connect(collapsedRB, SIGNAL(clicked()), this, SLOT(applyView()));
+       connect(openRB, SIGNAL(clicked()), this, SLOT(applyView()));
 }
 
 
-void GuiERT::change_adaptor()
+void GuiERT::enableView(bool enable)
 {
-       changed();
+       collapsedRB->setEnabled(enable);
+       openRB->setEnabled(enable);
 }
 
 
-void GuiERT::applyView()
+docstring GuiERT::dialogToParams() const
 {
-       if (openRB->isChecked())
-               status_ = InsetCollapsable::Open;
-       else
-               status_ = InsetCollapsable::Collapsed;
+       InsetCollapsable::CollapseStatus status = openRB->isChecked()
+               ? InsetCollapsable::Open : InsetCollapsable::Collapsed;
+       return from_ascii(InsetERT::params2string(status));
 }
 
 
-void GuiERT::updateContents()
+void GuiERT::paramsToDialog(Inset const * inset)
 {
-       switch (status_) {
+       InsetERT const * ert = static_cast<InsetERT const *>(inset);
+       InsetCollapsable::CollapseStatus status = ert->status(*bufferview());
+       switch (status) {
                case InsetCollapsable::Open: openRB->setChecked(true); break;
                case InsetCollapsable::Collapsed: collapsedRB->setChecked(true); break;
        }
 }
 
 
-bool GuiERT::initialiseParams(string const & data)
-{
-       status_ = InsetERT::string2params(data);
-       return true;
-}
-
-
-void GuiERT::clearParams()
-{
-       status_ = InsetCollapsable::Collapsed;
-}
-
-
-void GuiERT::dispatchParams()
-{
-       dispatch(FuncRequest(getLfun(), InsetERT::params2string(status_)));
-}
-
-
 Dialog * createGuiERT(GuiView & lv) { return new GuiERT(lv); }
 
 
index 09debfeb182ee2746a237fa82867fbd49b865d5a..b9b7cccc033410df822c3da8b32652650b3a4b89 100644 (file)
 #ifndef GUIERT_H
 #define GUIERT_H
 
-#include "GuiDialog.h"
+#include "InsetDialog.h"
 #include "ui_ERTUi.h"
-#include "insets/InsetERT.h" // InsetERT::ERTStatus
 
 namespace lyx {
 namespace frontend {
 
-class GuiERT : public GuiDialog, public Ui::ERTUi
+class GuiERT : public InsetDialog, public Ui::ERTUi
 {
        Q_OBJECT
 
 public:
        GuiERT(GuiView & lv);
 
-private Q_SLOTS:
-       void change_adaptor();
-
-private:
-       /// Apply changes
-       void applyView();
-       /// update
-       void updateContents();
-       ///
-       InsetCollapsable::CollapseStatus status() const { return status_; }
-       ///
-       void setStatus(InsetCollapsable::CollapseStatus status) { status_ = status; }
-       ///
-       bool initialiseParams(std::string const & data);
-       /// clean-up on hide.
-       void clearParams();
-       /// clean-up on hide.
-       void dispatchParams();
-       ///
-       bool isBufferDependent() const { return true; }
 private:
-       ///
-       InsetCollapsable::CollapseStatus status_;
+       /// \name Dialog inerited methods
+       //@{
+       void enableView(bool enable);
+       //@}
+
+       /// \name InsetDialog inherited methods
+       //@{
+       void paramsToDialog(Inset const *);
+       docstring dialogToParams() const;
+       //@}
 };
 
 } // namespace frontend
index 5eee47a6341235fea788d0d6c292de5d68a4ead3..e31eed731452fa68f3b36a9d54e18ad0d7e28a87 100644 (file)
@@ -70,7 +70,10 @@ void InsetDialog::on_closePB_clicked()
 \r
 void InsetDialog::on_newPB_clicked()\r
 {\r
-       docstring const argument = dialogToParams();\r
+       docstring argument;\r
+       if (d->creation_code_ == LFUN_INSET_INSERT)\r
+               argument = from_ascii(insetName(d->inset_code_)) + " ";\r
+       argument += dialogToParams();\r
        dispatch(FuncRequest(d->creation_code_, argument));\r
 }\r
 \r