From 3dc6a5f43c4b3d8b2f6b36279f1cd2b43bdcdc38 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 15 May 2008 08:41:17 +0000 Subject: [PATCH] rework a bit the document dialog so that it works more or less fine without any open document. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24783 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiDocument.cpp | 56 ++++++++++++------------------- src/frontends/qt4/GuiDocument.h | 11 ++---- 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index a36e8226f0..e678a8170b 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -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; } diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 9cd42926a1..5ce411e3a8 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -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(); ///