X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffrontends%2Fqt2%2FQt2Base.h;h=272c504ac2a9e7b86af420f1c5927f1364503b44;hb=82a83d7ae6eee25e1182c713a726b17037844ffb;hp=d697dd89331fa63f9e9891c5c8e7bfa39a514799;hpb=8999098e942c66a013b052190617ef48de916dbe;p=lyx.git diff --git a/src/frontends/qt2/Qt2Base.h b/src/frontends/qt2/Qt2Base.h index d697dd8933..272c504ac2 100644 --- a/src/frontends/qt2/Qt2Base.h +++ b/src/frontends/qt2/Qt2Base.h @@ -2,9 +2,9 @@ /* This file is part of * ====================================================== * - * LyX, The Document Processor + * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000 The LyX Team. * * ====================================================== * @@ -14,12 +14,12 @@ #ifndef QT2BASE_H #define QT2BASE_H -class QDialog; - +#include + #include +#include #include - -#include +#include #ifdef __GNUG__ #pragma interface @@ -27,52 +27,63 @@ class QDialog; #include "ViewBase.h" #include "LString.h" +#include "debug.h" #include "ButtonPolicies.h" #include "ControlButtons.h" -class qt2BC; +#include + +class Qt2BC; /** This class is an Qt2 GUI base class. */ -class Qt2Base : public QObject, public ViewBC +class Qt2Base : public QObject, public ViewBC { - Q_OBJECT + Q_OBJECT public: /// - Qt2Base(ControlButtons &, const QString &); + Qt2Base(ControlButtons &, QString const &); /// virtual ~Qt2Base() {} protected: - /// Build the dialog - virtual void build() = 0; + /// build the actual dialog + virtual void build_dialog() = 0; /// Hide the dialog. - void hide(); + virtual void hide(); /// Create the dialog if necessary, update it and display it. - void show(); + virtual void show(); + /// update the dialog's contents + virtual void update_contents() = 0; -protected slots: - // dialog closed from WM - void slotWMHide(); + /// the dialog has changed contents + virtual void changed(); + + /// is the dialog currently valid ? + virtual bool isValid(); - // Apply button clicked - void slotApply(); + /// are we updating ? + bool updating_; + +protected slots: + // dialog closed from WM + void slotWMHide(); - // OK button clicked - void slotOK(); + // Restore button clicked + void slotRestore(); + + // OK button clicked + void slotOK(); - // Cancel button clicked - void slotCancel(); + // Apply button clicked + void slotApply(); - // Restore button clicked - void slotRestore(); + // Close button clicked + void slotClose(); private: /// Pointer to the actual instantiation of xform's form - virtual QDialog* form() const = 0; - /** Filter the inputs on callback from xforms - Return true if inputs are valid. */ - virtual ButtonPolicy::SMInput input(QWidget*, long); + virtual QDialog * form() const = 0; private: /// dialog title, displayed by WM. @@ -84,41 +95,85 @@ template class Qt2DB: public Qt2Base { protected: - /// - Qt2DB(ControlButtons &, const QString&); + Qt2DB(ControlButtons &, QString const &); + + /// update the dialog + virtual void update(); + + /// Build the dialog + virtual void build(); + /// Pointer to the actual instantiation of the Qt dialog - virtual QDialog* form() const; + virtual QDialog * form() const; + /// Real GUI implementation. boost::scoped_ptr dialog_; + }; template -Qt2DB::Qt2DB(ControlButtons & c, const QString& t) +Qt2DB::Qt2DB(ControlButtons & c, QString const & t) : Qt2Base(c, t) {} template -QDialog* Qt2DB::form() const +QDialog * Qt2DB::form() const { - return dialog_.get(); + return dialog_.get(); } +template +void Qt2DB::update() +{ + form()->setUpdatesEnabled(false); + + // protect the BC from unwarranted state transitions + + qApp->processEvents(); + updating_ = true; + update_contents(); + qApp->processEvents(); + updating_ = false; + + form()->setUpdatesEnabled(true); + form()->update(); +} + + +template +void Qt2DB::build() +{ + // protect the BC from unwarranted state transitions + + qApp->processEvents(); + updating_ = true; + build_dialog(); + qApp->processEvents(); + updating_ = false; +} + + template class Qt2CB: public Base { +public: + bool readOnly() const { + return controller().isReadonly(); + } + protected: /// - Qt2CB(ControlButtons &, const QString&); + Qt2CB(ControlButtons &, QString const &); /// The parent controller Controller & controller() const; }; template -Qt2CB::Qt2CB(ControlButtons & c, const QString& t) +Qt2CB::Qt2CB(ControlButtons & c, QString const & t) : Base(c, t) {}