TocWidget: Fix perf regression

4d1ad336 fixed #9754 but caused perf issues by cancelling the gains of having a
timer (introduced after #7138). This introduces in GuiToc::enableView() a
lightweight check of whether the widget should be updated. The logic is inspired
from GuiViewSource::enableView().
This commit is contained in:
Guillaume Munch 2016-04-30 00:25:46 +01:00 committed by Richard Heck
parent 0e740018ff
commit 2f9d323396
3 changed files with 15 additions and 2 deletions

View File

@ -66,9 +66,12 @@ void GuiToc::dispatchParams()
}
void GuiToc::enableView(bool /*enable*/)
void GuiToc::enableView(bool enable)
{
widget_->updateViewForce();
widget_->checkModelChanged();
if (!enable)
// In the opposite case, updateView() will be called anyway.
widget_->updateViewForce();
}

View File

@ -452,6 +452,14 @@ void TocWidget::updateViewForce()
}
void TocWidget::checkModelChanged()
{
if (!gui_view_.documentBufferView() ||
gui_view_.tocModels().model(current_type_) != tocTV->model())
updateViewForce();
}
void TocWidget::filterContents()
{
if (!tocTV->model())

View File

@ -42,6 +42,8 @@ public:
///
bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & status)
const;
// update the view when the model has changed
void checkModelChanged();
public Q_SLOTS:
/// Schedule new update of the display unless already scheduled.