From 121fdba3666b43549a2f02dc4bfef1605707a1d5 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Sun, 19 Dec 2010 22:27:21 +0000 Subject: [PATCH] Attempt to workaround movement and editation slowness. 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 | 27 ++++++++++++++++++++++++--- src/frontends/qt4/TocWidget.h | 6 +++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 84db8bd88e..f67d39119c 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -39,13 +39,16 @@ #include +#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 diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index 6dd9fbf76a..608920a42a 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -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 -- 2.39.2