]> git.lyx.org Git - features.git/commitdiff
Factorize general code out of GuiDialog and into the base Dialog class. This is now...
authorAbdelrazak Younes <younes@lyx.org>
Sun, 9 Dec 2007 22:35:04 +0000 (22:35 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 9 Dec 2007 22:35:04 +0000 (22:35 +0000)
* GuiDialog now inherits DialogView. GuiDialog is only there to bring the ButtonController archaeological interface; any new dialog should inherit DialogView and any new dock widget should inherit DockView.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22049 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
src/frontends/qt4/Dialog.cpp
src/frontends/qt4/Dialog.h
src/frontends/qt4/DialogView.cpp [new file with mode: 0644]
src/frontends/qt4/DialogView.h
src/frontends/qt4/DockView.h
src/frontends/qt4/GuiCitation.cpp
src/frontends/qt4/GuiCitation.h
src/frontends/qt4/GuiDialog.cpp
src/frontends/qt4/GuiDialog.h
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiParagraph.h
src/frontends/qt4/GuiSearch.cpp
src/frontends/qt4/GuiSearch.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Makefile.am
src/frontends/qt4/ui/ParagraphUi.ui

index 3ecfa94752bf8c79ec4761e97f8c145d6654aa6d..27af0d11d7da8f0ac8bdc58e94b01aae19bc4ce8 100644 (file)
 #include "FuncStatus.h"
 #include "LyXFunc.h"
 
+#include "support/Debug.h"
+
 #include <string>
 
+using namespace std;
+
 namespace lyx {
 namespace frontend {
 
@@ -122,5 +126,120 @@ Buffer const & Dialog::buffer() const
        return *lyxview_->buffer();
 }
 
+
+void Dialog::showData(string const & data)
+{
+       if (isBufferDependent() && !isBufferAvailable())
+               return;
+
+       if (!initialiseParams(data)) {
+               LYXERR0("Dialog \"" << name()
+                       << "\" failed to translate the data string passed to show()");
+               return;
+       }
+
+       showView();
+}
+
+
+void Dialog::apply()
+{
+       if (isBufferDependent()) {
+               if (!isBufferAvailable() ||
+                   (isBufferReadonly() && !canApplyToReadOnly()))
+                       return;
+       }
+
+       applyView();
+       dispatchParams();
+
+       if (disconnectOnApply() && !isClosing()) {
+               disconnect();
+               initialiseParams(string());
+               updateView();
+       }
+}
+
+
+void Dialog::updateData(string const & data)
+{
+       if (isBufferDependent() && !isBufferAvailable())
+               return;
+
+       if (!initialiseParams(data)) {
+               LYXERR0("Dialog \"" << name()
+                      << "\" could not be initialized");
+               return;
+       }
+
+       updateView();
+}
+
+
+void Dialog::showView()
+{
+       updateView();  // make sure its up-to-date
+       if (exitEarly())
+               return;
+
+       QWidget * w = asQWidget();
+       QSize const hint = w->sizeHint();
+       if (hint.height() >= 0 && hint.width() >= 0)
+               w->setMinimumSize(hint);
+
+       if (w->isVisible()) {
+               w->raise();
+               w->activateWindow();
+       } else
+               w->show();
+
+       w->setFocus();
+}
+
+
+void Dialog::hideView()
+{
+       QWidget * w = asQWidget();
+       if (!w->isVisible())
+               return;
+       clearParams();
+       disconnect();
+       w->hide();
+}
+
+
+bool Dialog::isVisibleView() const
+{
+       return asQWidget()->isVisible();
+}
+
+
+void Dialog::checkStatus()
+{
+       // buffer independant dialogs are always active.
+       // This check allows us leave canApply unimplemented for some dialogs.
+       if (!isBufferDependent())
+               return;
+
+       // deactivate the dialog if we have no buffer
+       if (!isBufferAvailable()) {
+               enableView(false);
+               return;
+       }
+
+       // check whether this dialog may be active
+       if (canApply()) {
+               bool const readonly = isBufferReadonly();
+               enableView(!readonly);
+               // refreshReadOnly() is too generous in _enabling_ widgets
+               // update dialog to disable disabled widgets again
+
+               if (!readonly || canApplyToReadOnly())
+                       updateView();
+
+       } else
+               enableView(false);
+}
+
 } // namespace frontend
 } // namespace lyx
index 2861eb02419456472ca8b332767975450231c9f3..64dd73008644fb1b63c3d2fca40d0a92ae26f2d5 100644 (file)
@@ -16,6 +16,8 @@
 
 #include <string>
 
+class QWidget;
+
 namespace lyx {
 
 class Buffer;
@@ -51,6 +53,9 @@ public:
 
        virtual ~Dialog();
 
+       virtual QWidget * asQWidget() = 0;
+       virtual QWidget const * asQWidget() const = 0;
+
        /** \name Container Access
         *  These methods are publicly accessible because they are invoked
         *  by the parent container acting on commands from the LyX kernel.
@@ -58,30 +63,21 @@ public:
        //@{
        /// \param data is a string encoding of the data to be displayed.
        /// It is passed to the Controller to be translated into a useable form.
-       virtual void showData(std::string const & /*data*/) {}
-       virtual void updateData(std::string const & /*data*/) {}
-
-       virtual void hide() {}
-
+       virtual void showData(std::string const & data);
+       virtual void updateData(std::string const & data);
        //@}
 
        /** Check whether we may apply our data.
         *
         *  The buttons are disabled if not and (re-)enabled if yes.
         */
-       virtual void checkStatus() {}
+       virtual void checkStatus();
 
        /** When applying, it's useful to know whether the dialog is about
         *  to close or not (no point refreshing the display for example).
         */
        virtual bool isClosing() const { return false; }
 
-
-       /** \c Button controller part
-        */
-       virtual void setButtonsValid(bool /*valid*/) {}
-
-
        /** \c View part
         *  of a Model-Controller-View split of a generic dialog.
         *  These few methods are all that a generic dialog needs of a
@@ -95,16 +91,20 @@ public:
        virtual void applyView() = 0;
 
        /// Hide the dialog from sight
-       virtual void hideView() = 0;
+       void hideView();
 
        /// Create the dialog if necessary, update it and display it.
-       virtual void showView() = 0;
+       void showView();
 
        /// Update the display of the dialog whilst it is still visible.
        virtual void updateView() = 0;
 
+       // Default Implementation does nothing.
+       // Each dialog has to choose what control to enable or disable.
+       virtual void enableView(bool /*enable*/) {}
+
        /// \return true if the dialog is visible.
-       virtual bool isVisibleView() const = 0;
+       virtual bool isVisibleView() const;
        //@}
 
        /// Dialog identifier.
@@ -230,7 +230,7 @@ public:
        //@}
 
 protected:
-       virtual void apply() {}
+       virtual void apply();
 
 private:
        /** The Dialog's name is the means by which a dialog identifies
diff --git a/src/frontends/qt4/DialogView.cpp b/src/frontends/qt4/DialogView.cpp
new file mode 100644 (file)
index 0000000..b193bca
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * \file Dialog.cpp
+ * 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.
+ */
+
+#include <config.h>
+
+#include "DialogView.h"
+
+#include "GuiView.h"
+#include "qt_helpers.h"
+
+#include <QCloseEvent>
+#include <QSettings>
+#include <QShowEvent>
+
+
+namespace lyx {
+namespace frontend {
+
+DialogView::DialogView(GuiView & lv, std::string const & name)
+       : QDialog(&lv), Dialog(lv, name)
+{}
+
+
+void DialogView::setViewTitle(docstring const & title)
+{
+       setWindowTitle("LyX: " + toqstr(title));
+}
+
+
+void DialogView::showEvent(QShowEvent * e)
+{
+       QSettings settings;
+       QString key = toqstr(name()) + "/geometry";
+       restoreGeometry(settings.value(key).toByteArray());
+       QDialog::showEvent(e);
+}
+
+
+void DialogView::closeEvent(QCloseEvent * e)
+{
+       QSettings settings;
+       QString key = toqstr(name()) + "/geometry";
+       settings.setValue(key, saveGeometry());
+       QDialog::closeEvent(e);
+}
+
+} // namespace frontend
+} // namespace lyx
+
+#include "DialogView_moc.cpp"
index e255b3bc86da69a6d422b95f4ee8b0583cc843fb..36f3ef2f0892e327735ee92eb82f40da7217683e 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef DIALOG_VIEW_H
-#define DIALOG_VIEW_H
+#ifndef DIALOGVIEW_H
+#define DIALOGVIEW_H
 
 #include "Dialog.h"
-#include "GuiView.h"
-#include "qt_helpers.h"
-#include "support/debug.h"
 
-#include <QCloseEvent>
 #include <QDialog>
-#include <QSettings>
-#include <QShowEvent>
-#include <QGridLayout>
 
-#include <string>
+class QCloseEvent;
+class QShowEvent;
 
 namespace lyx {
 namespace frontend {
 
-/// Window Dialog container for LyX dialogs.
-/// This template class that encapsulates a given Widget inside a
-/// QDialog and presents a Dialog interface
-template<class MyWidget>
+/** \c Dialog collects the different parts of a Model-Controller-View
+ *  split of a generic dialog together.
+ */
 class DialogView : public QDialog, public Dialog
 {
+       Q_OBJECT
+
 public:
-       DialogView(
-               GuiView & parent, ///< the main window where to dock.
-               std::string const & name, ///< dialog identifier.
-               bool modal = false, ///< Window modality.
-               Qt::WindowFlags flags = 0
-               )
-               : QDialog(&parent, flags), Dialog(parent, name)
-       {
-               setModal(modal);
-               QGridLayout * gridLayout = new QGridLayout(this);
-               gridLayout->setMargin(0);
-               widget_ = new MyWidget(*this, this);
-               gridLayout->addWidget(widget_);
-               setWindowTitle("LyX: " + widget_->windowTitle());
-       }
+       /// \param lv is the access point for the dialog to the LyX kernel.
+       /// \param name is the identifier given to the dialog by its parent
+       /// container.
+       explicit DialogView(GuiView & lv, std::string const & name);
+       virtual ~DialogView() {}
 
-       /// Dialog inherited methods
-       //@{
-       void applyView() {}
-       void hideView()
-       {
-               clearParams();
-               QDialog::hide();
-       }
-       void showData(std::string const & data)
-       {
-               initialiseParams(data);
-               showView();
-       }
-       void showView()
-       {
-               widget_->updateView();  // make sure its up-to-date
-               QDialog::show();
-               raise();
-               activateWindow();
-       }
-       bool isVisibleView() const { return QDialog::isVisible(); }
-       void checkStatus() { updateView(); }
-       void updateData(std::string const & data)
-       {
-               initialiseParams(data);
-               updateView();
-       }
-       void updateView()
-       {
-               widget_->updateView();
-       }
-       //@}
-private:
-       /// The encapsulated widget.
-       MyWidget * widget_;
+       virtual QWidget * asQWidget() { return this; }
+       virtual QWidget const * asQWidget() const { return this; }
 
-       void showEvent(QShowEvent * e)
-       {
-               QSettings settings;
-               std::string key = name() + "/geometry";
-               QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
-           QDialog::showEvent(e);
-       }
+public:
+       ///
+       void setViewTitle(docstring const & title);
 
-       void closeEvent(QCloseEvent * e)
-       {
-               QSettings settings;
-               std::string key = name() + "/geometry";
-               settings.setValue(key.c_str(), QDialog::saveGeometry());
-               QDialog::closeEvent(e);
-       }
+       ///
+       void closeEvent(QCloseEvent *);
+       ///
+       void showEvent(QShowEvent *);
 };
 
-} // frontend
-} // lyx
+} // namespace frontend
+} // namespace lyx
 
-#endif // DIALOG_VIEW_H
+#endif // DIALOGVIEW_H
index 9f2563d6874c7281e72a1a985f2e988baedc829c..3f0bd2347ab4f85ac4a05b5b0efaab2938ab862e 100644 (file)
@@ -43,27 +43,12 @@ public:
 
        virtual ~DockView() {}
 
+       virtual QWidget * asQWidget() { return this; }
+       virtual QWidget const * asQWidget() const { return this; }
+
        /// Dialog inherited methods
        //@{
        void applyView() {}
-       void hideView() { QDockWidget::hide(); }
-       void showData(std::string const & data)
-       {
-               initialiseParams(data);
-               showView();
-       }
-       void showView()
-       {
-               updateView();  // make sure its up-to-date
-               QDockWidget::show();
-       }
-       bool isVisibleView() const { return QDockWidget::isVisible(); }
-       void checkStatus() { updateView(); }
-       void updateData(std::string const & data)
-       {
-               initialiseParams(data);
-               updateView();
-       }
        bool isClosing() const { return false; }
        //@}
 };
index a1f7067e8434bb9638ae8ed61a45a4fa3a1eb9c4..7e6470b963fb75d904d8c3d9b02d9a89346aacfc 100644 (file)
@@ -30,6 +30,7 @@
 #include <string>
 
 #include <QCloseEvent>
+#include <QShowEvent>
 
 #undef KeyPress
 
@@ -138,27 +139,12 @@ void GuiCitation::applyView()
 }
 
 
-void GuiCitation::hideView()
-{
-       clearParams();
-       accept();
-}
-
-
-void GuiCitation::showView()
+void GuiCitation::showEvent(QShowEvent * e)
 {
        init();
        findLE->clear();
        availableLV->setFocus();
-       QDialog::show();
-       raise();
-       activateWindow();
-}
-
-
-bool GuiCitation::isVisibleView() const
-{
-       return QDialog::isVisible();
+       GuiDialog::showEvent(e);
 }
 
 
@@ -166,14 +152,14 @@ void GuiCitation::on_okPB_clicked()
 {
        applyView();
        clearSelection();
-       hideView();
+       hide();
 }
 
 
 void GuiCitation::on_cancelPB_clicked()
 {
        clearSelection();
-       hideView();
+       hide();
 }
 
 
index de2655a453ba85d54913f2c71a01abb612bb5bd9..9b9a867fc7189a27340c135c89b5430e6bff4d6b 100644 (file)
@@ -38,18 +38,14 @@ public:
 
        ///
        void applyView();
-       /// Hide the dialog from sight
-       void hideView();
-       /// Create the dialog if necessary, update it and display it.
-       void showView();
-       /// \return true if the dialog is visible.
-       bool isVisibleView() const;
 
 public Q_SLOTS:
        /// Update the display of the dialog whilst it is still visible.
        void updateView();
 
 private:
+       ///
+       void showEvent(QShowEvent * e);
        ///
        void closeEvent(QCloseEvent * e);
        /// prepares a call to GuiCitation::searchKeys when we
index 9b70bccf08d9229cf9b18cc06515f3fdfb977e00..f62754b2e640c40f4dc5d2d399697799623fadc5 100644 (file)
 
 #include "GuiDialog.h"
 #include "GuiView.h"
-#include "support/debug.h"
 #include "qt_helpers.h"
 
+#include "support/debug.h"
+
 #include <QCloseEvent>
 #include <QMainWindow>
 #include <QSettings>
@@ -26,21 +27,10 @@ namespace lyx {
 namespace frontend {
 
 GuiDialog::GuiDialog(GuiView & lv, std::string const & name)
-       : QDialog(&lv), Dialog(lv, name), is_closing_(false)
+       : DialogView(lv, name), is_closing_(false)
 {}
 
 
-GuiDialog::~GuiDialog()
-{
-}
-
-
-void GuiDialog::setViewTitle(docstring const & title)
-{
-       setWindowTitle("LyX: " + toqstr(title));
-}
-
-
 void GuiDialog::setButtonsValid(bool valid)
 {
        bc().setValid(valid);
@@ -49,7 +39,7 @@ void GuiDialog::setButtonsValid(bool valid)
 
 void GuiDialog::slotApply()
 {
-       apply();
+       applyView();
        bc().apply();
 }
 
@@ -57,7 +47,7 @@ void GuiDialog::slotApply()
 void GuiDialog::slotOK()
 {
        is_closing_ = true;
-       apply();
+       applyView();
        is_closing_ = false;
        QDialog::hide();
        bc().ok();
@@ -80,72 +70,20 @@ void GuiDialog::slotRestore()
        bc().restore();
 }
 
-void GuiDialog::checkStatus()
-{
-       // buffer independant dialogs are always active.
-       // This check allows us leave canApply unimplemented for some dialogs.
-       if (!isBufferDependent())
-               return;
-
-       // deactivate the dialog if we have no buffer
-       if (!isBufferAvailable()) {
-               bc().setReadOnly(true);
-               return;
-       }
-
-       // check whether this dialog may be active
-       if (canApply()) {
-               bool const readonly = isBufferReadonly();
-               bc().setReadOnly(readonly);
-               // refreshReadOnly() is too generous in _enabling_ widgets
-               // update dialog to disable disabled widgets again
-
-               if (!readonly || canApplyToReadOnly())
-                       updateView();
-
-       } else {
-               bc().setReadOnly(true);
-       }       
-}
-
-
-bool GuiDialog::isVisibleView() const
-{
-       return QDialog::isVisible();
-}
-
 
-void GuiDialog::showView()
+void GuiDialog::changed()
 {
-       QSize const hint = sizeHint();
-       if (hint.height() >= 0 && hint.width() >= 0)
-               setMinimumSize(hint);
-
-       updateView();  // make sure its up-to-date
-       if (exitEarly())
+       if (updating_)
                return;
-
-       if (QWidget::isVisible()) {
-               raise();
-               activateWindow();
-       } else {
-               QWidget::show();
-       }
-       setFocus();
-}
-
-
-void GuiDialog::hideView()
-{
-       QDialog::hide();
+       bc().setValid(isValid());
 }
 
 
-void GuiDialog::changed()
+void GuiDialog::enableView(bool enable)
 {
-       if (updating_)
-               return;
-       bc().setValid(isValid());
+       bc().setReadOnly(!enable);
+       bc().setValid(enable);
+       DialogView::enableView(enable);
 }
 
 
@@ -153,97 +91,15 @@ void GuiDialog::updateView()
 {
        setUpdatesEnabled(false);
 
+       bc().setReadOnly(isBufferReadonly());
        // protect the BC from unwarranted state transitions
        updating_ = true;
        updateContents();
        updating_ = false;
-
-       setUpdatesEnabled(true);
-       QDialog::update();
-}
-
-
-void GuiDialog::showData(string const & data)
-{
-       if (isBufferDependent() && !isBufferAvailable())
-               return;
-
-       if (!initialiseParams(data)) {
-               LYXERR0("Dialog \"" << name()
-                       << "\" failed to translate the data string passed to show()");
-               return;
-       }
-
-       bc().setReadOnly(isBufferReadonly());
-       showView();
-       // The widgets may not be valid, so refresh the button controller
-       bc().refresh();
-}
-
-
-void GuiDialog::updateData(string const & data)
-{
-       if (isBufferDependent() && !isBufferAvailable())
-               return;
-
-       if (!initialiseParams(data)) {
-               LYXERR0("Dialog \"" << name()
-                      << "\" could not be initialized");
-               return;
-       }
-
-       bc().setReadOnly(isBufferReadonly());
-       updateView();
        // The widgets may not be valid, so refresh the button controller
        bc().refresh();
-}
-
-
-void GuiDialog::hide()
-{
-       if (!isVisibleView())
-               return;
 
-       clearParams();
-       hideView();
-       Dialog::disconnect();
-}
-
-
-void GuiDialog::apply()
-{
-       if (isBufferDependent()) {
-               if (!isBufferAvailable() ||
-                   (isBufferReadonly() && !canApplyToReadOnly()))
-                       return;
-       }
-
-       applyView();
-       dispatchParams();
-
-       if (disconnectOnApply() && !is_closing_) {
-               Dialog::disconnect();
-               initialiseParams(string());
-               updateView();
-       }
-}
-
-
-void GuiDialog::showEvent(QShowEvent * e)
-{
-       QSettings settings;
-       string key = name() + "/geometry";
-       restoreGeometry(settings.value(key.c_str()).toByteArray());
-       QDialog::showEvent(e);
-}
-
-
-void GuiDialog::closeEvent(QCloseEvent * e)
-{
-       QSettings settings;
-       string key = name() + "/geometry";
-       settings.setValue(key.c_str(), saveGeometry());
-       QDialog::closeEvent(e);
+       setUpdatesEnabled(true);
 }
 
 } // namespace frontend
index 977e361fa3cc27e03d5d7dcd95e1559ce36bfd86..76889b5ccb527052edb8716a585cae3bc3bf2310 100644 (file)
 #ifndef GUIDIALOG_H
 #define GUIDIALOG_H
 
-#include "Dialog.h"
+#include "DialogView.h"
 #include "ButtonController.h"
 
 #include "insets/InsetCommandParams.h"
 
-#include <QDialog>
-#include <QObject>
-
-class QCloseEvent;
-class QShowEvent;
-
 namespace lyx {
 namespace frontend {
 
 /** \c Dialog collects the different parts of a Model-Controller-View
  *  split of a generic dialog together.
  */
-class GuiDialog : public QDialog, public Dialog
+class GuiDialog : public DialogView
 {
        Q_OBJECT
 
@@ -38,7 +32,6 @@ public:
        /// \param name is the identifier given to the dialog by its parent
        /// container.
        explicit GuiDialog(GuiView & lv, std::string const & name);
-       ~GuiDialog();
 
 public Q_SLOTS:
        /** \name Buttons
@@ -59,7 +52,6 @@ public:
         *
         *  The buttons are disabled if not and (re-)enabled if yes.
         */
-       void checkStatus();
        void setButtonsValid(bool valid);
 
        /** \name Dialog Components
@@ -70,53 +62,27 @@ public:
        ButtonController & bc() { return bc_; }
        //@}
 
-       void setViewTitle(docstring const & title);
-
-
        /// the dialog has changed contents
        virtual void changed();
 
+       virtual void enableView(bool enable);
+
        /// default: do nothing
        virtual void applyView() {}
        /// default: do nothing
        virtual void updateContents() {}
-       ///
-       void closeEvent(QCloseEvent *);
-       ///
-       void showEvent(QShowEvent *);
 
-protected:
-       /// Hide the dialog.
-       virtual void hideView();
-       /// Create the dialog if necessary, update it and display it.
-       virtual void showView();
-       ///
-       virtual bool isVisibleView() const;
+public:
        /// is the dialog currently valid ?
        virtual bool isValid() { return true; }
 
 public:
-       /** \name Container Access
-        *  These methods are publicly accessible because they are invoked
-        *  by the parent container acting on commands from the LyX kernel.
-        */
-       //@{
-       /// \param data is a string encoding of the data to be displayed.
-       /// It is passed to the Controller to be translated into a useable form.
-       void showData(std::string const & data);
-       void updateData(std::string const & data);
-
-       void hide();
-
-       //@}
 
        /** When applying, it's useful to know whether the dialog is about
         *  to close or not (no point refreshing the display for example).
         */
        bool isClosing() const { return is_closing_; }
 
-       void apply();
-
        /// Update the display of the dialog whilst it is still visible.
        virtual void updateView();
 
index d0c2faac87feebb315e80b1d7653c6be1e0a0354..7e785a54d2815eb951433074edbf986037420d85 100644 (file)
@@ -48,16 +48,11 @@ namespace lyx {
 namespace frontend {
 
 GuiParagraph::GuiParagraph(GuiView & lv)
-       : Dialog(lv, "paragraph")
+       : DialogView(lv, "paragraph")
 {
        setupUi(this);
        setWindowTitle(qt_("Paragraph Settings"));
 
-       //setModal(modal);
-       QGridLayout * gridLayout = new QGridLayout(this);
-       gridLayout->setMargin(0);
-       gridLayout->addWidget(this);
-
        connect(alignDefaultRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignJustRB, SIGNAL(clicked()), this, SLOT(changed()));
        connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(changed()));
@@ -210,6 +205,11 @@ void GuiParagraph::on_restorePB_clicked()
 }
 
 
+void GuiParagraph::enableView(bool enable)
+{
+}
+
+
 void GuiParagraph::updateView()
 {
        on_synchronizedViewCB_toggled();
index a5e8a4f0c6306fca5125ac451606ecc0e251fb54..feddbbd709f967e072e362bc4ff0fe217d6304a2 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "Layout.h"
 #include "ui_ParagraphUi.h"
-#include "Dialog.h"
+#include "DialogView.h"
 #include "ParagraphParameters.h"
 #include "GuiView.h"
 #include "qt_helpers.h"
@@ -38,7 +38,7 @@ namespace lyx {
 namespace frontend {
 
 class GuiParagraph
-       : public QDialog, public Ui::ParagraphUi, public Dialog
+       : public DialogView, public Ui::ParagraphUi
 {
        Q_OBJECT
 public:
@@ -63,51 +63,13 @@ private:
        QString const alignDefaultLabel;
 
        void applyView() {}
-       void hideView()
-       {
-               clearParams();
-               QDialog::hide();
-       }
-       void showData(std::string const & data)
-       {
-               initialiseParams(data);
-               showView();
-       }
-       void showView()
-       {
-               updateView();  // make sure its up-to-date
-               QDialog::show();
-               raise();
-               activateWindow();
-       }
-       bool isVisibleView() const { return QDialog::isVisible(); }
-       void checkStatus() { updateView(); }
-       void updateData(std::string const & data)
-       {
-               initialiseParams(data);
-               updateView();
-       }
+       void enableView(bool enable);
+
        std::string name() const { return "paragraph"; }
 
 private:
        QString name_;
 
-       void showEvent(QShowEvent * e)
-       {
-               QSettings settings;
-               QString key = name_ + "/geometry";
-               QDialog::restoreGeometry(settings.value(key).toByteArray());
-           QDialog::showEvent(e);
-       }
-
-       void closeEvent(QCloseEvent * e)
-       {
-               QSettings settings;
-               QString key = name_ + "/geometry";
-               settings.setValue(key, QDialog::saveGeometry());
-               QDialog::closeEvent(e);
-       }
-
 private Q_SLOTS:
        ///
        void changed();
index ee6bdfda72298bf84c7594e03ef0c6472c8eeaec..6039c20a5930a647fa75037c8f118517d34ecfda 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <QLineEdit>
 #include <QCloseEvent>
+#include <QShowEvent>
 
 using std::string;
 
@@ -64,10 +65,10 @@ GuiSearch::GuiSearch(GuiView & lv)
 }
 
 
-void GuiSearch::showView()
+void GuiSearch::showEvent(QShowEvent * e)
 {
        findCO->lineEdit()->selectAll();
-       GuiDialog::showView();
+       GuiDialog::showEvent(e);
 }
 
 
index 9f6f0d969a44b96787120cebced544dae59782ee..85ea64843e997a79427273b784745c460078a298 100644 (file)
@@ -33,7 +33,7 @@ private Q_SLOTS:
        void replaceallClicked();
 
 private:
-       void showView();
+       void showEvent(QShowEvent * e);
        void closeEvent(QCloseEvent * e);
        ///
        bool initialiseParams(std::string const &) { return true; }
index 5752fb8948b7f6f4e3cec89b70bc52ec577cb7b5..f2c7ced20391b7abbd35b60100cb5f64383c8a9c 100644 (file)
@@ -1668,7 +1668,7 @@ void GuiView::hideDialog(string const & name, Inset * inset)
 
        Dialog * const dialog = it->second.get();
        if (dialog->isVisibleView())
-               dialog->hide();
+               dialog->hideView();
        d.open_insets_[name] = 0;
 }
 
@@ -1699,7 +1699,7 @@ void GuiView::hideAll() const
        std::map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
 
        for(; it != end; ++it)
-               it->second->hide();
+               it->second->hideView();
 }
 
 
@@ -1711,7 +1711,7 @@ void GuiView::hideBufferDependent() const
        for(; it != end; ++it) {
                Dialog * dialog = it->second.get();
                if (dialog->isBufferDependent())
-                       dialog->hide();
+                       dialog->hideView();
        }
 }
 
@@ -1729,7 +1729,7 @@ void GuiView::updateBufferDependent(bool switched) const
                        if (dialog->initialiseParams(""))
                                dialog->updateView();
                        else
-                               dialog->hide();
+                               dialog->hideView();
                } else {
                        // A bit clunky, but the dialog will request
                        // that the kernel provides it with the necessary
index 8fc0edf27109bf0e94395489637d838caf053584..965357cbebf31ce2610e0374ccd25352b334e136 100644 (file)
@@ -50,6 +50,7 @@ SOURCEFILES = \
        ButtonPolicy.h \
        Dialog.cpp \
        Dialog.h \
+       DialogView.cpp \
        Resources.cpp \
        Action.cpp \
        BulletsModule.cpp \
@@ -135,7 +136,6 @@ SOURCEFILES = \
 
 NOMOCHEADER = \
        ButtonController.h \
-       DialogView.h \
        GuiFontLoader.h \
        GuiFontMetrics.h \
        GuiImage.h \
@@ -149,6 +149,7 @@ MOCHEADER = \
        BulletsModule.h \
        ColorCache.h \
        CustomizedWidgets.h \
+       DialogView.h \
        DockView.h \
        EmptyTable.h \
        FloatPlacement.h \
index bd72e92066ea3ae599f5913fc89d3ea55f63d261..eeb03e5dd96691674875a29580cd10b1ef1d8beb 100644 (file)
@@ -1,6 +1,6 @@
 <ui version="4.0" >
  <class>ParagraphUi</class>
- <widget class="QWidget" name="ParagraphUi" >
+ <widget class="QDialog" name="ParagraphUi" >
   <property name="geometry" >
    <rect>
     <x>0</x>