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
This commit is contained in:
Abdelrazak Younes 2008-05-15 08:41:17 +00:00
parent ed4ea2cb97
commit 3dc6a5f43c
2 changed files with 25 additions and 42 deletions

View File

@ -509,7 +509,7 @@ void PreambleModule::closeEvent(QCloseEvent * e)
GuiDocument::GuiDocument(GuiView & lv) GuiDocument::GuiDocument(GuiView & lv)
: GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0) : GuiDialog(lv, "document", qt_("Document Settings"))
{ {
setupUi(this); setupUi(this);
@ -1318,7 +1318,7 @@ void GuiDocument::classChanged()
applyView(); applyView();
} }
bp_.useClassDefaults(); bp_.useClassDefaults();
forceUpdate(); paramsToDialog(bp_);
} }
} }
@ -1733,13 +1733,7 @@ void GuiDocument::apply(BufferParams & params)
} }
void GuiDocument::updateParams() void GuiDocument::paramsToDialog(BufferParams const & params)
{
updateParams(bp_);
}
void GuiDocument::updateParams(BufferParams const & params)
{ {
// set the default unit // set the default unit
Length::UNIT defaultUnit = Length::CM; Length::UNIT defaultUnit = Length::CM;
@ -2081,26 +2075,8 @@ void GuiDocument::updateSelectedModules()
void GuiDocument::updateContents() void GuiDocument::updateContents()
{ {
if (id() == current_id_) // Nothing to do here as the document settings is not cursor dependant.
return; 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();
} }
@ -2122,7 +2098,7 @@ void GuiDocument::useClassDefaults()
return; return;
} }
bp_.useClassDefaults(); bp_.useClassDefaults();
forceUpdate(); paramsToDialog(bp_);
} }
@ -2157,10 +2133,21 @@ char const * GuiDocument::fontfamilies_gui[5] = {
bool GuiDocument::initialiseParams(string const &) bool GuiDocument::initialiseParams(string const &)
{ {
bp_ = buffer().params(); BufferView * view = bufferview();
// Force update on next updateContent() round. if (!view) {
current_id_ = 0; bp_ = BufferParams();
paramsToDialog(bp_);
return true;
}
bp_ = view->buffer().params();
loadModuleInfo(); 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; return true;
} }
@ -2173,7 +2160,8 @@ void GuiDocument::clearParams()
BufferId GuiDocument::id() const BufferId GuiDocument::id() const
{ {
return &buffer(); BufferView const * const view = bufferview();
return view? &view->buffer() : 0;
} }

View File

@ -104,7 +104,7 @@ class GuiDocument : public GuiDialog, public Ui::DocumentUi
public: public:
GuiDocument(GuiView & lv); GuiDocument(GuiView & lv);
void updateParams(BufferParams const & params); void paramsToDialog(BufferParams const & params);
void apply(BufferParams & params); void apply(BufferParams & params);
void updateFontsize(std::string const &, std::string const &); void updateFontsize(std::string const &, std::string const &);
@ -114,15 +114,12 @@ public:
/// validate listings parameters and return an error message, if any /// validate listings parameters and return an error message, if any
docstring validate_listings_params(); docstring validate_listings_params();
public Q_SLOTS: private Q_SLOTS:
void updateNumbering(); void updateNumbering();
void change_adaptor(); void change_adaptor();
void set_listings_msg(); void set_listings_msg();
void saveDefaultClicked(); void saveDefaultClicked();
void useDefaultsClicked(); void useDefaultsClicked();
private Q_SLOTS:
void updateParams();
void setLSpacing(int); void setLSpacing(int);
void setMargins(bool); void setMargins(bool);
void setCustomPapersize(int); void setCustomPapersize(int);
@ -163,13 +160,11 @@ private:
GuiIdListModel * availableModel() { return &modules_av_model_; } GuiIdListModel * availableModel() { return &modules_av_model_; }
/// Selected modules /// Selected modules
GuiIdListModel * selectedModel() { return &modules_sel_model_; } GuiIdListModel * selectedModel() { return &modules_sel_model_; }
private:
/// Apply changes /// Apply changes
void applyView(); void applyView();
/// update /// update
void updateContents(); void updateContents();
/// force content update
void forceUpdate();
/// ///
void updateAvailableModules(); void updateAvailableModules();
/// ///