]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/DialogView.h
Fix the tab ordering of GuiDocument components.
[lyx.git] / src / frontends / qt4 / DialogView.h
index d34b83dff28f375f41060e88402a3ce4cd6545c9..d3125c6f8e94298e00e78d9898fada42b4a76114 100644 (file)
 #include "Dialog.h"
 #include "GuiView.h"
 
+#include <QCloseEvent>
 #include <QDialog>
 
 namespace lyx {
 namespace frontend {
 
-/** \c Dialog collects the different parts of a Model-Controller-View
- *  split of a generic dialog together.
- */
 class DialogView : public QDialog, public Dialog
 {
 public:
@@ -38,12 +36,29 @@ public:
        virtual QWidget const * asQWidget() const { return this; }
 
 protected:
-       /// Dialog inherited methods
+       /// \name Dialog inherited methods
        //@{
        void applyView() {}
        bool initialiseParams(std::string const & /*data*/) { return true; }
        void clearParams() {}
+       bool needBufferOpen() const { return isBufferDependent(); }
        //@}
+       /// Any dialog that overrides this method should make sure to call it.
+       void closeEvent(QCloseEvent * ev)
+       {
+               clearParams();
+               Dialog::disconnect();
+               ev->accept();
+       }
+       /// Any dialog that overrides this method should make sure to call it.
+       void hideEvent(QHideEvent * ev)
+       {
+               if (!ev->spontaneous()) {
+                       clearParams();
+                       Dialog::disconnect();
+                       ev->accept();
+               }
+       }
 };
 
 } // namespace frontend