* 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
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);
}
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")) {
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();
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();
}
QTimer::singleShot(0, this, SLOT(close()));
}
}
+#else
+ structureChanged();
+ updateDialogs();
#endif
}
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"));
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))
}
-void GuiView::updateToc()
-{
- updateDialog("toc", "");
-}
-
-
void GuiView::autoSave()
{
LYXERR(Debug::INFO, "Running autoSave()");
}
-void GuiView::updateBufferDependent(bool switched) const
+void GuiView::updateDialogs()
{
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
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
dialog->updateDialog();
}
}
+ updateToolbars();
+ updateLayoutList();
+ updateStatusBar();
}
///@{
void resetAutosaveTimers();
void errors(std::string const &);
- void structureChanged() { updateToc(); }
+ void structureChanged() { updateDialog("toc", ""); }
///@}
/// called on timeout
/// disconnect from signals in the given buffer
void disconnectBuffer();
///
- void updateToc();
- ///
void dragEnterEvent(QDragEnterEvent * ev);
///
void dropEvent(QDropEvent * ev);
/// 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.
{
updateWindowTitle();
if (this == lyx_view_->currentWorkArea())
- lyx_view_->updateBufferDependent(false);
+ lyx_view_->updateDialogs();
}
void TocWidget::updateView()
{
LYXERR(Debug::GUI, "In TocWidget::updateView()");
+ setTreeDepth();
select(form_.currentIndex(typeCO->currentIndex()));
}
// 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()));
}
public:
TocWidget(GuiToc & form, QWidget * parent = 0);
+public Q_SLOTS:
/// Update the display of the dialog whilst it is still visible.
void updateView();