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
This commit is contained in:
Abdelrazak Younes 2008-04-27 22:24:20 +00:00
parent 1458cd52b7
commit bf27334cfa
7 changed files with 37 additions and 44 deletions

View File

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

View File

@ -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();

View File

@ -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<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
map<string, DialogPtr>::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();
}

View File

@ -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.

View File

@ -1141,7 +1141,7 @@ void GuiWorkArea::setReadOnly(bool)
{
updateWindowTitle();
if (this == lyx_view_->currentWorkArea())
lyx_view_->updateBufferDependent(false);
lyx_view_->updateDialogs();
}

View File

@ -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()));
}

View File

@ -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();