]> git.lyx.org Git - features.git/commitdiff
Simplify Dialog::name() handling.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 23 Nov 2007 10:45:14 +0000 (10:45 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 23 Nov 2007 10:45:14 +0000 (10:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21736 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialog.cpp
src/frontends/qt4/Dialog.h
src/frontends/qt4/DialogView.h
src/frontends/qt4/DockView.h
src/frontends/qt4/GuiDialog.cpp
src/frontends/qt4/GuiDialog.h
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiView.cpp

index 7eaf6a03aed09c5b970991075951da035525eef9..cc3d3999c51cbd5528b91480aef37dadcd7aba30 100644 (file)
 #include "FuncStatus.h"
 #include "LyXFunc.h"
 
+#include <string>
 
 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_);
 }
 
 
index 94454c74d84a0fffc908bee69700691469a3c6b7..8f6cea63170d46a2c52d7d3c96c676f446ff528b 100644 (file)
@@ -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 &);
index b73814ff13af9a6ca19f37ad517430ff518bac36..e4a2ea97fd6d1190baabf70f5a010c8948ad7222 100644 (file)
@@ -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);
        }
index 7b8db928e204f8a253895fcaf410ff6e69024e4b..fe80cdf4bdd7f2812c4c5f957f2c83d2ec97aa5d 100644 (file)
@@ -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(parentname)
        {
                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
index 42d2109d7a4f2245c04ffbaa35af3d61f01e34cd..36632935ab7138e1b05ee6d4a2f430e9eba237e7 100644 (file)
@@ -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);
 }
index ee53bf22aea3422878b3b0995151b09098ca6518..977e361fa3cc27e03d5d7dcd95e1559ce36bfd86 100644 (file)
@@ -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_;
 };
 
 
index 713f5e084b71c80ed490b86b9c02025c389ffa31..30506902521e4e3a4cf65ad29454c58bdfa6097d 100644 (file)
@@ -49,7 +49,7 @@ namespace lyx {
 namespace frontend {
 
 GuiParagraph::GuiParagraph(GuiView & lv)
-       : Dialog(lv)
+       : Dialog(lv, "paragraph")
 {
        setupUi(this);
        setWindowTitle(qt_("Paragraph Settings"));
index 950631194fa08da8fcb9a5acd5dc7ee303a5ad9f..b65570d23e587ff7c08280c72b763e3eb42268a0 100644 (file)
@@ -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();
                }
        }
 }