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)
: 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;
}

View 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();
///