It seems that commit 17167 was not enough to ensure that the proper hide/show/update methods are called.

* QDialogView.h:
  - QDialogView::forms() now requires a QWidget instead of a QDialog. This will allow us to use DockWidget in the future.
  - QView class code simplification: implement inline instead of repeating in the same file.
  - QView::forms() now returns the real object.
  - QController class code simplification: implement inline instead of repeating in the same file.

* QDocumentDialog::update(): renamed to updateParams() to avoid clash with QWidget::update()

* QPrefsDialog::update(): renamed to updateRc() to avoid clash with QWidget::update()

* QTexinfoDialog::update(): now public so that it can be used in QDialogView.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17195 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-02-15 10:16:35 +00:00
parent 9590a3cffe
commit 018cb4905e
8 changed files with 39 additions and 77 deletions

View File

@ -17,7 +17,7 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <QApplication> #include <QApplication>
#include <QDialog> #include <QWidget>
#include <QObject> #include <QObject>
namespace lyx { namespace lyx {
@ -80,68 +80,45 @@ public Q_SLOTS:
void slotClose(); void slotClose();
private: private:
/// Pointer to the actual instantiation of the Qt dialog /// Pointer to the actual instantiation of the Qt dialog
virtual QDialog * form() const = 0; virtual QWidget * form() const = 0;
}; };
template <class GUIDialog> template <class GUIDialog>
class QView: public QDialogView { class QView: public QDialogView {
protected: protected:
QView(Dialog &, docstring const &); QView(Dialog & p, docstring const & t): QDialogView(p, t)
{}
virtual ~QView() {}
/// update the dialog /// update the dialog
virtual void update(); virtual void update() {
dialog_->setUpdatesEnabled(false);
/// Build the dialog
virtual void build();
/// Pointer to the actual instantiation of the Qt dialog
virtual QDialog * form() const;
/// Real GUI implementation.
boost::scoped_ptr<GUIDialog> dialog_;
};
template <class GUIDialog>
QView<GUIDialog>::QView(Dialog & p, docstring const & t)
: QDialogView(p, t)
{}
template <class GUIDialog>
QDialog * QView<GUIDialog>::form() const
{
return dialog_.get();
}
template <class GUIDialog>
void QView<GUIDialog>::update()
{
form()->setUpdatesEnabled(false);
// protect the BC from unwarranted state transitions // protect the BC from unwarranted state transitions
updating_ = true; updating_ = true;
update_contents(); update_contents();
updating_ = false; updating_ = false;
form()->setUpdatesEnabled(true); dialog_->setUpdatesEnabled(true);
form()->update(); dialog_->update();
} }
/// Build the dialog
template <class GUIDialog> virtual void build() {
void QView<GUIDialog>::build()
{
// protect the BC from unwarranted state transitions // protect the BC from unwarranted state transitions
updating_ = true; updating_ = true;
build_dialog(); build_dialog();
updating_ = false; updating_ = false;
} }
/// Pointer to the actual instantiation of the Qt dialog
virtual GUIDialog * form() const { return dialog_.get(); }
/// Real GUI implementation.
boost::scoped_ptr<GUIDialog> dialog_;
};
template <class Controller, class Base> template <class Controller, class Base>
@ -149,34 +126,18 @@ class QController: public Base
{ {
protected: protected:
/// ///
QController(Dialog &, docstring const &); QController(Dialog & p, docstring const & t): Base(p, t)
{}
public: public:
/// The parent controller /// The parent controller
Controller & controller(); Controller & controller()
{ return static_cast<Controller &>(this->getController()); }
/// The parent controller /// The parent controller
Controller const & controller() const; Controller const & controller() const
{ return static_cast<Controller const &>(this->getController()); }
}; };
template <class Controller, class Base>
QController<Controller, Base>::QController(Dialog & p, docstring const & t)
: Base(p, t)
{}
template <class Controller, class Base>
Controller & QController<Controller, Base>::controller()
{
return static_cast<Controller &>(this->getController());
}
template <class Controller, class Base>
Controller const & QController<Controller, Base>::controller() const
{
return static_cast<Controller const &>(this->getController());
}
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -75,7 +75,7 @@ void QDocument::update_contents()
if (!dialog_.get()) if (!dialog_.get())
return; return;
dialog_->update(controller().params()); dialog_->updateParams(controller().params());
} }
void QDocument::saveDocDefault() void QDocument::saveDocDefault()

View File

@ -888,7 +888,7 @@ findPos(std::vector<A> const & vec, A const & val)
} // namespace anom } // namespace anom
void QDocumentDialog::update(BufferParams const & params) void QDocumentDialog::updateParams(BufferParams const & params)
{ {
// set the default unit // set the default unit
// FIXME: move to controller // FIXME: move to controller

View File

@ -58,7 +58,7 @@ public:
QDocumentDialog(QDocument *); QDocumentDialog(QDocument *);
~QDocumentDialog(); ~QDocumentDialog();
void update(BufferParams const & params); void updateParams(BufferParams const & params);
void apply(BufferParams & params); void apply(BufferParams & params);
void updateFontsize(std::string const &, std::string const &); void updateFontsize(std::string const &, std::string const &);

View File

@ -67,7 +67,7 @@ void QPrefs::apply()
void QPrefs::update_contents() void QPrefs::update_contents()
{ {
dialog_->update(controller().rc()); dialog_->updateRc(controller().rc());
} }
} // namespace frontend } // namespace frontend

View File

@ -1858,7 +1858,7 @@ void QPrefsDialog::apply(LyXRC & rc) const
} }
void QPrefsDialog::update(LyXRC const & rc) void QPrefsDialog::updateRc(LyXRC const & rc)
{ {
size_t end = modules_.size(); size_t end = modules_.size();
for (size_t i = 0; i != end; ++i) for (size_t i = 0; i != end; ++i)

View File

@ -371,7 +371,7 @@ public:
~QPrefsDialog(); ~QPrefsDialog();
void apply(LyXRC & rc) const; void apply(LyXRC & rc) const;
void update(LyXRC const & rc); void updateRc(LyXRC const & rc);
public Q_SLOTS: public Q_SLOTS:
void change_adaptor(); void change_adaptor();

View File

@ -26,11 +26,12 @@ class QTexinfoDialog : public QDialog, public Ui::QTexinfoUi {
Q_OBJECT Q_OBJECT
public: public:
QTexinfoDialog(QTexinfo * form); QTexinfoDialog(QTexinfo * form);
public Q_SLOTS:
virtual void update();
protected Q_SLOTS: protected Q_SLOTS:
virtual void change_adaptor(); virtual void change_adaptor();
virtual void rescanClicked(); virtual void rescanClicked();
virtual void viewClicked(); virtual void viewClicked();
virtual void update();
virtual void enableViewPB(); virtual void enableViewPB();
protected: protected:
virtual void closeEvent(QCloseEvent * e); virtual void closeEvent(QCloseEvent * e);