]> git.lyx.org Git - features.git/commitdiff
Some dialog consistency work:
authorAbdelrazak Younes <younes@lyx.org>
Sun, 27 Apr 2008 22:24:20 +0000 (22:24 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 27 Apr 2008 22:24:20 +0000 (22:24 +0000)
* 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

src/frontends/qt4/Dialog.cpp
src/frontends/qt4/GuiToc.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index 32c47c61295333612b41f78a9048a7e8bff65a16..c372107246cf87e372e1a5ff3f4a392ff913fba2 100644 (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);
 }
 
 
index a2ebac0575339acc8a3011c6828af821299f506f..9f51e3d7f7165cf69fb53c0b885546503a6e078b 100644 (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();
index 215cdeb16057b5ea6f52b38dcaa8b94a2d03b8d7..533b8c8e210903ac2506cff17271ff6721a8d666 100644 (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();
 }
 
 
index 7367af68db0a1f9f2cfe41a85c81598a50145e06..c7387ac08db9c73e77255fed1c152773656baaa8 100644 (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.
index f040777e3c5aea84dec1712ebb34d9892bafbcea..04f853fe8e4559d28cf9f67a8b6f7f25d5f7e2a0 100644 (file)
@@ -1141,7 +1141,7 @@ void GuiWorkArea::setReadOnly(bool)
 {
        updateWindowTitle();
        if (this == lyx_view_->currentWorkArea())
-               lyx_view_->updateBufferDependent(false);
+               lyx_view_->updateDialogs();
 }
 
 
index 46985c2fcfa584d4701d37755ea0a27e065b5815..6912c8795b752e7f48907801f3d38ee2d030a09a 100644 (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()));
 }
 
 
index 5a51e0f8ad31aa7a0bd106ddf338003177b1ed9f..e3d3bf071056669e2c5cfec977424409a6179c80 100644 (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();