From: Abdelrazak Younes Date: Sun, 27 Apr 2008 22:24:20 +0000 (+0000) Subject: Some dialog consistency work: X-Git-Tag: 1.6.10~4972 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=bf27334cfac53c3f536e0e08dbd77f1ab104f81f;p=features.git Some dialog consistency work: * Dialog::updateData(): try to reset the dialog even if there's no Buffer. * GuiView::updateBufferDependent(): - renamed to updateDialogs() - don't hide when there's no current work area, try to disable instead. - now also take care of toolbars and other elements. * TocWidget: delay item selection to avoid unwanted node collapsing after setting a new model. Expect crash and/or assertions for dialogs that are not ready for this non-hiding change. I will fix them iteratively. There are still too many dialogs updates going on... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24529 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/Dialog.cpp b/src/frontends/qt4/Dialog.cpp index 32c47c6129..c372107246 100644 --- a/src/frontends/qt4/Dialog.cpp +++ b/src/frontends/qt4/Dialog.cpp @@ -165,16 +165,16 @@ void Dialog::apply() void Dialog::updateData(string const & data) { - if (isBufferDependent() && !isBufferAvailable()) - return; - if (!initialiseParams(data)) { LYXERR0("Dialog \"" << fromqstr(name()) << "\" could not be initialized"); return; } - updateView(); + if (lyxview_->buffer()) + updateView(); + else + enableView(false); } diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index a2ebac0575..9f51e3d7f7 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -137,6 +137,13 @@ TocList const & GuiToc::tocs() const bool GuiToc::initialiseParams(string const & data) { LYXERR(Debug::GUI, data); + types_.clear(); + type_names_.clear(); + clearTocModels(); + if (!bufferview()) + // Nothing to show here. + return true; + QString str = toqstr(data); QString new_type; if (str.contains("tableofcontents")) { @@ -155,9 +162,6 @@ bool GuiToc::initialiseParams(string const & data) new_type = "tableofcontents"; } - types_.clear(); - type_names_.clear(); - clearTocModels(); TocList const & tocs = buffer().masterBuffer()->tocBackend().tocs(); TocList::const_iterator it = tocs.begin(); TocList::const_iterator end = tocs.end(); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 215cdeb160..533b8c8e21 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -538,14 +538,13 @@ void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa) this, SLOT(updateWindowTitle(GuiWorkArea *))); updateWindowTitle(wa); - updateToc(); - // Buffer-dependent dialogs should be updated or - // hidden. This should go here because some dialogs (eg ToC) - // require bv_->text. - updateBufferDependent(true); - updateToolbars(); - updateLayoutList(); - updateStatusBar(); + // Navigator needs more than a simple update in this case. It needs to be + // rebuilt. + structureChanged(); + + // Buffer-dependent dialogs must be updated. This is done here because + // some dialogs require buffer()->text. + updateDialogs(); } @@ -561,6 +560,9 @@ void GuiView::on_lastWorkAreaRemoved() QTimer::singleShot(0, this, SLOT(close())); } } +#else + structureChanged(); + updateDialogs(); #endif } @@ -613,10 +615,8 @@ bool GuiView::event(QEvent * e) connectBuffer(bv.buffer()); // The document structure, name and dialogs might have // changed in another view. - updateBufferDependent(true); - updateToolbars(); - updateLayoutList(); - updateStatusBar(); + structureChanged(); + updateDialogs(); } else { setWindowTitle(qt_("LyX")); setWindowIconText(qt_("LyX")); @@ -765,11 +765,6 @@ GuiWorkArea const * GuiView::currentWorkArea() const void GuiView::setCurrentWorkArea(GuiWorkArea * wa) { LASSERT(wa, /**/); - - // Changing work area can result from opening a file so - // update the toc in any case. - updateToc(); - d.current_work_area_ = wa; for (int i = 0; i != d.splitter_->count(); ++i) { if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) @@ -942,12 +937,6 @@ BufferView * GuiView::view() } -void GuiView::updateToc() -{ - updateDialog("toc", ""); -} - - void GuiView::autoSave() { LYXERR(Debug::INFO, "Running autoSave()"); @@ -2147,7 +2136,7 @@ void GuiView::hideAll() const } -void GuiView::updateBufferDependent(bool switched) const +void GuiView::updateDialogs() { map::const_iterator it = d.dialogs_.begin(); map::const_iterator end = d.dialogs_.end(); @@ -2156,11 +2145,11 @@ void GuiView::updateBufferDependent(bool switched) const Dialog * dialog = it->second.get(); if (!dialog->isVisibleView()) continue; - if (switched && dialog->isBufferDependent()) { - if (dialog->initialiseParams("")) + if (dialog->isBufferDependent()) { + if (buffer()) dialog->updateView(); else - dialog->hideView(); + dialog->enableView(false); } else { // A bit clunky, but the dialog will request // that the kernel provides it with the necessary @@ -2168,6 +2157,9 @@ void GuiView::updateBufferDependent(bool switched) const dialog->updateDialog(); } } + updateToolbars(); + updateLayoutList(); + updateStatusBar(); } diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 7367af68db..c7387ac08d 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -104,7 +104,7 @@ public: ///@{ void resetAutosaveTimers(); void errors(std::string const &); - void structureChanged() { updateToc(); } + void structureChanged() { updateDialog("toc", ""); } ///@} /// called on timeout @@ -170,8 +170,6 @@ private: /// disconnect from signals in the given buffer void disconnectBuffer(); /// - void updateToc(); - /// void dragEnterEvent(QDragEnterEvent * ev); /// void dropEvent(QDropEvent * ev); @@ -208,11 +206,8 @@ public: /// Hide all visible dialogs void hideAll() const; - /** Update visible, buffer-dependent dialogs - If the bool is true then a buffer change has occurred - else it is still the same buffer. - */ - void updateBufferDependent(bool) const; + // Update all visible dialogs. + void updateDialogs(); /** \param name == "bibtex", "citation" etc; an identifier used to launch a particular dialog. diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index f040777e3c..04f853fe8e 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1141,7 +1141,7 @@ void GuiWorkArea::setReadOnly(bool) { updateWindowTitle(); if (this == lyx_view_->currentWorkArea()) - lyx_view_->updateBufferDependent(false); + lyx_view_->updateDialogs(); } diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 46985c2fcf..6912c8795b 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -207,6 +207,7 @@ void TocWidget::enableControls(bool enable) void TocWidget::updateView() { LYXERR(Debug::GUI, "In TocWidget::updateView()"); + setTreeDepth(); select(form_.currentIndex(typeCO->currentIndex())); } @@ -241,7 +242,7 @@ void TocWidget::updateGui(int selected_type) // setTocModel produce QTreeView reset and setting depth again // is needed. That must be done after all Qt updates are processed. - QTimer::singleShot(0, this, SLOT(setTreeDepth())); + QTimer::singleShot(0, this, SLOT(updateView())); } diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index 5a51e0f8ad..e3d3bf0710 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -29,6 +29,7 @@ class TocWidget : public QWidget, public Ui::TocUi public: TocWidget(GuiToc & form, QWidget * parent = 0); +public Q_SLOTS: /// Update the display of the dialog whilst it is still visible. void updateView();