Abdelrazak Younes wrote:
> Provided that it doesn't introduce regression, it looks good. But I would 
> rather put a shorter timing here in order to avoid inconcistencies and 
> crashes

i did already testing before sending the patch and the updateView routine
is pretty robust even when you change the background buffer meanwhile.

> (ex: if the user is fast enough to use the outine one second after 
> typing a char). I am sure you won't feel the difference if you set it to 
> 0.5s.

tried 0.5 and no. writing bit tensed but ok, works. however moving with
cursor makes me still frustrated.

but i understand your concerns about possible inconsistencies. after
chewing my pencil for some time i have patch, which still lets 2000 for
simple writing and moving, but for occassions when tocmodel gets reseted
due to buffer structural changes, switching entire buffer or type of
outliner information, the update is immediate.

unless there are some objections i will commit it. once in we'll see whether
the new behaviour does not irritate the second half of people which has no
performance problems...

pavel
diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp
index 84db8bd..2776f08 100644
--- a/src/frontends/qt4/TocWidget.cpp
+++ b/src/frontends/qt4/TocWidget.cpp
@@ -45,7 +45,8 @@ 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 +250,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 +318,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 +390,16 @@ void TocWidget::enableControls(bool enable)
 
 void TocWidget::updateView()
 {
+       // 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 +517,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 6dd9fbf..608920a 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

Reply via email to