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

View File

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

View File

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

View File

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

View File

@ -67,7 +67,7 @@ void QPrefs::apply()
void QPrefs::update_contents()
{
dialog_->update(controller().rc());
dialog_->updateRc(controller().rc());
}
} // 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();
for (size_t i = 0; i != end; ++i)

View File

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

View File

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