From: Abdelrazak Younes Date: Fri, 23 Nov 2007 10:45:14 +0000 (+0000) Subject: Simplify Dialog::name() handling. X-Git-Tag: 1.6.10~7248 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=10cc0a8842d147462d4f26ba8353ebb163d34d9c;p=features.git Simplify Dialog::name() handling. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21736 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/Dialog.cpp b/src/frontends/qt4/Dialog.cpp index 7eaf6a03ae..cc3d3999c5 100644 --- a/src/frontends/qt4/Dialog.cpp +++ b/src/frontends/qt4/Dialog.cpp @@ -19,18 +19,29 @@ #include "FuncStatus.h" #include "LyXFunc.h" +#include namespace lyx { namespace frontend { +Dialog::Dialog(GuiView & lv, std::string const & name) + : lyxview_(&lv), name_(name.c_str()) +{} + + Dialog::~Dialog() {} +std::string Dialog::name() const +{ + return name_; +} + bool Dialog::canApply() const { - FuncRequest const fr(getLfun(), name()); + FuncRequest const fr(getLfun(), name_); FuncStatus const fs(getStatus(fr)); return fs.enabled(); } @@ -42,15 +53,15 @@ void Dialog::dispatch(FuncRequest const & fr) const } -void Dialog::updateDialog(std::string const & name) const +void Dialog::updateDialog() const { - dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name)); + dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name_)); } -void Dialog::disconnect(std::string const & name) const +void Dialog::disconnect() const { - lyxview_->disconnectDialog(name); + lyxview_->disconnectDialog(name_); } diff --git a/src/frontends/qt4/Dialog.h b/src/frontends/qt4/Dialog.h index 94454c74d8..8f6cea6317 100644 --- a/src/frontends/qt4/Dialog.h +++ b/src/frontends/qt4/Dialog.h @@ -47,7 +47,8 @@ public: /// \param lv is the access point for the dialog to the LyX kernel. /// \param name is the identifier given to the dialog by its parent /// container. - Dialog(GuiView & lv) : lyxview_(&lv) {} + Dialog(GuiView & lv, std::string const & name); + virtual ~Dialog(); /** \name Container Access @@ -107,7 +108,7 @@ public: //@} /// - virtual std::string name() const = 0; + std::string name() const; //@{ /** Enable the controller to initialise its data structures. @@ -188,7 +189,7 @@ public: * It must, therefore, ask the kernel to provide this information. * \param name is used to identify the dialog to the kernel. */ - void updateDialog(std::string const & name) const; + void updateDialog() const; /** A request from the Controller that future changes to the data * stored by the dialog are not applied to the inset currently @@ -196,7 +197,7 @@ public: * a new inset at the cursor position. * \param name is used to identify the dialog to the kernel. */ - void disconnect(std::string const & name) const; + void disconnect() const; /** \name Kernel Wrappers * Simple wrapper functions to Buffer methods. @@ -229,9 +230,13 @@ protected: virtual void apply() {} private: + /** The Dialog's name is the means by which a dialog identifies + * itself to the LyXView. + */ + char const * const name_; + /// GuiView * lyxview_; -private: /// intentionally unimplemented, therefore uncopiable Dialog(Dialog const &); void operator=(Dialog const &); diff --git a/src/frontends/qt4/DialogView.h b/src/frontends/qt4/DialogView.h index b73814ff13..e4a2ea97fd 100644 --- a/src/frontends/qt4/DialogView.h +++ b/src/frontends/qt4/DialogView.h @@ -41,7 +41,7 @@ public: bool modal = false, ///< Window modality. Qt::WindowFlags flags = 0 ) - : QDialog(&parent, flags), name_(name) + : QDialog(&parent, flags), Dialog(parent, name) { setModal(modal); QGridLayout * gridLayout = new QGridLayout(this); @@ -82,17 +82,15 @@ public: { widget_->updateView(); } - std::string name() const { return name_; } //@} private: /// The encapsulated widget. MyWidget * widget_; - std::string name_; void showEvent(QShowEvent * e) { QSettings settings; - std::string key = name_ + "/geometry"; + std::string key = name() + "/geometry"; QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray()); QDialog::showEvent(e); } @@ -100,7 +98,7 @@ private: void closeEvent(QCloseEvent * e) { QSettings settings; - std::string key = name_ + "/geometry"; + std::string key = name() + "/geometry"; settings.setValue(key.c_str(), QDialog::saveGeometry()); QDialog::closeEvent(e); } diff --git a/src/frontends/qt4/DockView.h b/src/frontends/qt4/DockView.h index 7b8db928e2..fe80cdf4bd 100644 --- a/src/frontends/qt4/DockView.h +++ b/src/frontends/qt4/DockView.h @@ -34,7 +34,7 @@ public: Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer) Qt::WindowFlags flags = 0 ) - : QDockWidget(&parent, flags), Dialog(parent), name_(name) + : QDockWidget(&parent, flags), Dialog(parent, name) { if (flags & Qt::Drawer) setFeatures(QDockWidget::NoDockWidgetFeatures); @@ -65,10 +65,7 @@ public: updateView(); } bool isClosing() const { return false; } - std::string name() const { return name_; } //@} -private: - std::string name_; }; } // frontend diff --git a/src/frontends/qt4/GuiDialog.cpp b/src/frontends/qt4/GuiDialog.cpp index 42d2109d7a..36632935ab 100644 --- a/src/frontends/qt4/GuiDialog.cpp +++ b/src/frontends/qt4/GuiDialog.cpp @@ -24,7 +24,7 @@ namespace lyx { namespace frontend { GuiDialog::GuiDialog(GuiView & lv, std::string const & name) - : Dialog(lv), is_closing_(false), name_(name) + : Dialog(lv, name), is_closing_(false) {} @@ -74,7 +74,7 @@ void GuiDialog::slotRestore() // Tell the controller that a request to refresh the dialog's contents // has been received. It's up to the controller to supply the necessary // info by calling GuiDialog::updateView(). - updateDialog(name_); + updateDialog(); bc().restore(); } @@ -167,7 +167,7 @@ void GuiDialog::showData(string const & data) return; if (!initialiseParams(data)) { - lyxerr << "Dialog \"" << name_ + lyxerr << "Dialog \"" << name() << "\" failed to translate the data " "string passed to show()" << std::endl; return; @@ -186,7 +186,7 @@ void GuiDialog::updateData(string const & data) return; if (!initialiseParams(data)) { - lyxerr << "Dialog \"" << name_ + lyxerr << "Dialog \"" << name() << "\" could not be initialized" << std::endl; return; } @@ -205,7 +205,7 @@ void GuiDialog::hide() clearParams(); hideView(); - Dialog::disconnect(name_); + Dialog::disconnect(); } @@ -221,7 +221,7 @@ void GuiDialog::apply() dispatchParams(); if (disconnectOnApply() && !is_closing_) { - Dialog::disconnect(name_); + Dialog::disconnect(); initialiseParams(string()); updateView(); } @@ -231,7 +231,7 @@ void GuiDialog::apply() void GuiDialog::showEvent(QShowEvent * e) { QSettings settings; - string key = name_ + "/geometry"; + string key = name() + "/geometry"; restoreGeometry(settings.value(key.c_str()).toByteArray()); QDialog::showEvent(e); } @@ -240,7 +240,7 @@ void GuiDialog::showEvent(QShowEvent * e) void GuiDialog::closeEvent(QCloseEvent * e) { QSettings settings; - string key = name_ + "/geometry"; + string key = name() + "/geometry"; settings.setValue(key.c_str(), saveGeometry()); QDialog::closeEvent(e); } diff --git a/src/frontends/qt4/GuiDialog.h b/src/frontends/qt4/GuiDialog.h index ee53bf22ae..977e361fa3 100644 --- a/src/frontends/qt4/GuiDialog.h +++ b/src/frontends/qt4/GuiDialog.h @@ -115,9 +115,6 @@ public: */ bool isClosing() const { return is_closing_; } - /// - std::string name() const { return name_; } - void apply(); /// Update the display of the dialog whilst it is still visible. @@ -129,10 +126,6 @@ private: bool updating_; bool is_closing_; - /** The Dialog's name is the means by which a dialog identifies - * itself to the kernel. - */ - std::string name_; }; diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 713f5e084b..3050690252 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -49,7 +49,7 @@ namespace lyx { namespace frontend { GuiParagraph::GuiParagraph(GuiView & lv) - : Dialog(lv) + : Dialog(lv, "paragraph") { setupUi(this); setWindowTitle(qt_("Paragraph Settings")); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 950631194f..b65570d23e 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1367,7 +1367,7 @@ void GuiView::updateBufferDependent(bool switched) const // A bit clunky, but the dialog will request // that the kernel provides it with the necessary // data. - dialog->updateDialog(dialog->name()); + dialog->updateDialog(); } } }