]> git.lyx.org Git - features.git/commitdiff
rework a bit the document dialog so that it works more or less fine without any open...
authorAbdelrazak Younes <younes@lyx.org>
Thu, 15 May 2008 08:41:17 +0000 (08:41 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 15 May 2008 08:41:17 +0000 (08:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24783 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h

index a36e8226f0c57dd5a0804283ae7fc10a1ee95b86..e678a8170b0554242a8f9b0cdafb3e60e9909fa1 100644 (file)
@@ -509,7 +509,7 @@ void PreambleModule::closeEvent(QCloseEvent * e)
 
 
 GuiDocument::GuiDocument(GuiView & lv)
-       : GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0)
+       : GuiDialog(lv, "document", qt_("Document Settings"))
 {
        setupUi(this);
 
@@ -1318,7 +1318,7 @@ void GuiDocument::classChanged()
                                applyView();
                }
                bp_.useClassDefaults();
-               forceUpdate();
+               paramsToDialog(bp_);
        }
 }
 
@@ -1733,13 +1733,7 @@ void GuiDocument::apply(BufferParams & params)
 }
 
 
-void GuiDocument::updateParams()
-{
-       updateParams(bp_);
-}
-
-
-void GuiDocument::updateParams(BufferParams const & params)
+void GuiDocument::paramsToDialog(BufferParams const & params)
 {
        // set the default unit
        Length::UNIT defaultUnit = Length::CM;
@@ -2081,26 +2075,8 @@ void GuiDocument::updateSelectedModules()
 
 void GuiDocument::updateContents()
 {
-       if (id() == current_id_)
-               return;
-
-       updateAvailableModules();
-       updateSelectedModules();
-       
-       //FIXME It'd be nice to make sure here that the selected
-       //modules are consistent: That required modules are actually
-       //selected, and that we don't have conflicts. If so, we could
-       //at least pop up a warning.
-       updateParams(bp_);
-       current_id_ = id();
-}
-
-
-void GuiDocument::forceUpdate()
-{
-       // reset to force dialog update
-       current_id_ = 0;
-       updateContents();
+       // Nothing to do here as the document settings is not cursor dependant.
+       return;
 }
 
 
@@ -2122,7 +2098,7 @@ void GuiDocument::useClassDefaults()
                return;
        }
        bp_.useClassDefaults();
-       forceUpdate();
+       paramsToDialog(bp_);
 }
 
 
@@ -2157,10 +2133,21 @@ char const * GuiDocument::fontfamilies_gui[5] = {
 
 bool GuiDocument::initialiseParams(string const &)
 {
-       bp_ = buffer().params();
-       // Force update on next updateContent() round.
-       current_id_ = 0;
+       BufferView * view = bufferview();
+       if (!view) {
+               bp_ = BufferParams();
+               paramsToDialog(bp_);
+               return true;
+       }
+       bp_ = view->buffer().params();
        loadModuleInfo();
+       updateAvailableModules();
+       updateSelectedModules();
+       //FIXME It'd be nice to make sure here that the selected
+       //modules are consistent: That required modules are actually
+       //selected, and that we don't have conflicts. If so, we could
+       //at least pop up a warning.
+       paramsToDialog(bp_);
        return true;
 }
 
@@ -2173,7 +2160,8 @@ void GuiDocument::clearParams()
 
 BufferId GuiDocument::id() const
 {
-       return &buffer();
+       BufferView const * const view = bufferview();
+       return view? &view->buffer() : 0;
 }
 
 
index 9cd42926a1e26d1abe2994387e0448477991a8df..5ce411e3a8dffa3b5d7f01c975776b10c947be58 100644 (file)
@@ -104,7 +104,7 @@ class GuiDocument : public GuiDialog, public Ui::DocumentUi
 public:
        GuiDocument(GuiView & lv);
 
-       void updateParams(BufferParams const & params);
+       void paramsToDialog(BufferParams const & params);
        void apply(BufferParams & params);
 
        void updateFontsize(std::string const &, std::string const &);
@@ -114,15 +114,12 @@ public:
        /// validate listings parameters and return an error message, if any
        docstring validate_listings_params();
 
-public Q_SLOTS:
+private Q_SLOTS:
        void updateNumbering();
        void change_adaptor();
        void set_listings_msg();
        void saveDefaultClicked();
        void useDefaultsClicked();
-
-private Q_SLOTS:
-       void updateParams();
        void setLSpacing(int);
        void setMargins(bool);
        void setCustomPapersize(int);
@@ -163,13 +160,11 @@ private:
        GuiIdListModel * availableModel() { return &modules_av_model_; }
        /// Selected modules
        GuiIdListModel * selectedModel() { return &modules_sel_model_; }
-private:
+
        /// Apply changes
        void applyView();
        /// update
        void updateContents();
-       /// force content update
-       void forceUpdate();
        ///
        void updateAvailableModules();
        ///