]> git.lyx.org Git - lyx.git/commitdiff
Attempt to workaround movement and editation slowness.
authorPavel Sanda <sanda@lyx.org>
Sun, 19 Dec 2010 22:27:21 +0000 (22:27 +0000)
committerPavel Sanda <sanda@lyx.org>
Sun, 19 Dec 2010 22:27:21 +0000 (22:27 +0000)
If it turns out to be too annoying for other we can disable it again.
Hopefully fix #7138.

http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg164385.html

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36951 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index 84db8bd88e59974f06f1883ca3fc24eb40d9de79..f67d39119c13bc0cf11d50429ef9d2017e6a90c8 100644 (file)
 
 #include <vector>
 
+#define DELAY_UPDATE_VIEW
+
 using namespace std;
 
 namespace lyx {
 namespace frontend {
 
 TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
-       : QWidget(parent), depth_(0), persistent_(false), gui_view_(gui_view)
+       : QWidget(parent), depth_(0), persistent_(false), gui_view_(gui_view), update_delay_(0)
+
 {
        setupUi(this);
 
@@ -249,7 +252,7 @@ void TocWidget::on_updateTB_clicked()
 void TocWidget::on_sortCB_stateChanged(int state)
 {
        gui_view_.tocModels().sort(current_type_, state == Qt::Checked);
-       updateView();
+       updateViewForce();
 }
 
 
@@ -317,7 +320,7 @@ void TocWidget::on_typeCO_currentIndexChanged(int index)
        if (index == -1)
                return;
        current_type_ = typeCO->itemData(index).toString();
-       updateView();
+       updateViewForce();
        if (typeCO->hasFocus())
                gui_view_.setFocus();
 }
@@ -389,6 +392,21 @@ void TocWidget::enableControls(bool enable)
 
 void TocWidget::updateView()
 {
+// Enable if you dont want the delaying business, cf #7138.
+#ifndef DELAY_UPDATE_VIEW
+       updateViewForce();
+       return;
+#endif
+       // already scheduled?
+       if (update_delay_ == -1)
+               return;
+       QTimer::singleShot(update_delay_, this, SLOT(updateViewForce()));
+       update_delay_ = -1;
+}
+
+void TocWidget::updateViewForce()
+{
+       update_delay_ = 2000;
        if (!gui_view_.documentBufferView()) {
                tocTV->setModel(0);
                depthSL->setMaximum(0);
@@ -506,6 +524,9 @@ void TocWidget::init(QString const & str)
        typeCO->blockSignals(true);
        typeCO->setCurrentIndex(new_index);
        typeCO->blockSignals(false);
+
+       // no delay when the whole outliner is reseted.
+       update_delay_ = 0;
 }
 
 } // namespace frontend
index 6dd9fbf76a938555b1425d7c7be0a558a8f0dd63..608920a42ad3f7b7f03519895e6686c1930d9301 100644 (file)
@@ -44,8 +44,10 @@ public:
                const;
 
 public Q_SLOTS:
-       /// Update the display of the dialog whilst it is still visible.
+       /// Schedule new update of the display unless already scheduled.
        void updateView();
+       /// Update the display of the dialog whilst it is still visible.
+       void updateViewForce();
 
 protected Q_SLOTS:
        ///
@@ -99,6 +101,8 @@ private:
        bool persistent_;
        ///
        GuiView & gui_view_;
+       // next delay for outliner update in ms. -1 when already scheduled.
+       int update_delay_;
 };
 
 } // namespace frontend