some controller simplification

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20871 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-09 19:52:34 +00:00
parent 6f3cdf8da8
commit fee6fea248
2 changed files with 9 additions and 11 deletions

View File

@ -31,8 +31,8 @@ namespace frontend {
/// Window Dialog container for LyX dialogs. /// Window Dialog container for LyX dialogs.
/// This template class that encapsulates a given Widget inside a /// This template class that encapsulates a given Widget inside a
/// QDialog and presents a Dialog interface /// QDialog and presents a Dialog interface
template<class MyController, class MyWidget> template<class MyWidget>
class DialogView : public QDialog, public Dialog class DialogView : public QDialog, public Dialog, public Controller
{ {
public: public:
DialogView( DialogView(
@ -44,10 +44,9 @@ public:
: QDialog(&parent, flags), name_(name) : QDialog(&parent, flags), name_(name)
{ {
setModal(modal); setModal(modal);
controller_ = new MyController(*this, parent);
QGridLayout * gridLayout = new QGridLayout(this); QGridLayout * gridLayout = new QGridLayout(this);
gridLayout->setMargin(0); gridLayout->setMargin(0);
widget_ = new MyWidget(*controller_, this); widget_ = new MyWidget(*this, this);
gridLayout->addWidget(widget_); gridLayout->addWidget(widget_);
setWindowTitle("LyX: " + widget_->windowTitle()); setWindowTitle("LyX: " + widget_->windowTitle());
} }
@ -57,12 +56,12 @@ public:
void applyView() {} void applyView() {}
void hideView() void hideView()
{ {
controller().clearParams(); clearParams();
QDialog::hide(); QDialog::hide();
} }
void showData(std::string const & data) void showData(std::string const & data)
{ {
controller_->initialiseParams(data); initialiseParams(data);
showView(); showView();
} }
void showView() void showView()
@ -78,7 +77,7 @@ public:
void redrawView() {} void redrawView() {}
void updateData(std::string const & data) void updateData(std::string const & data)
{ {
controller_->initialiseParams(data); initialiseParams(data);
updateView(); updateView();
} }
void updateView() void updateView()
@ -86,13 +85,12 @@ public:
widget_->updateView(); widget_->updateView();
} }
void partialUpdateView(int /*id*/) {} void partialUpdateView(int /*id*/) {}
Controller & controller() { return *controller_; } Controller & controller() { return *this; }
std::string name() const { return name_; } std::string name() const { return name_; }
//@} //@}
private: private:
/// The encapsulated widget. /// The encapsulated widget.
MyWidget * widget_; MyWidget * widget_;
Controller * controller_;
std::string name_; std::string name_;
void showEvent(QShowEvent * e) void showEvent(QShowEvent * e)
@ -112,7 +110,7 @@ private:
std::string key = name_ + "/geometry"; std::string key = name_ + "/geometry";
settings.setValue(key.c_str(), QDialog::saveGeometry()); settings.setValue(key.c_str(), QDialog::saveGeometry());
#endif #endif
QDialog::closeEvent(e); QDialog::closeEvent(e);
} }
}; };

View File

@ -138,6 +138,7 @@ SOURCEFILES = \
NOMOCHEADER = \ NOMOCHEADER = \
ButtonController.h \ ButtonController.h \
DialogView.h \
GuiFontLoader.h \ GuiFontLoader.h \
GuiFontMetrics.h \ GuiFontMetrics.h \
GuiImage.h \ GuiImage.h \
@ -150,7 +151,6 @@ MOCHEADER = \
Action.h \ Action.h \
BulletsModule.h \ BulletsModule.h \
ColorCache.h \ ColorCache.h \
DialogView.h \
DockView.h \ DockView.h \
EmptyTable.h \ EmptyTable.h \
FloatPlacement.h \ FloatPlacement.h \