Abdelrazak Younes wrote:
> On 12/17/2010 04:19 PM, Pavel Sanda wrote:
>> Vincent van Ravesteijn wrote:
>>
>>> I think we shouldn't fall back into this kind of hack before we know
>>>
>> i can offer some rc variable or small slider for the delay in outliner.
>> if its not acceptable either, well, its another local patch again :)
>>
>
> An #ifdef is fine IMHO.
sure, the patch is here.
pavel
diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp
index 84db8bd..2b621ea 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,21 @@ void TocWidget::enableControls(bool enable)
void TocWidget::updateView()
{
+// Enable if you dont want the delaying business, cf #7138.
+#ifdef 0
+ 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 +522,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