From 8874db5f2287ccbe1e3c31a8c4f59bb53c0eb01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 17 Apr 2007 10:27:53 +0000 Subject: [PATCH] Fix loop when opening TOC widget in an empty document, basically by Richard Heck. * src/frontends/qt4/TocWidget.[Ch]: - rename enableButtons to enableControls and include slider enabling/disabling - only set slider if there is some content git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17835 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/TocWidget.C | 43 +++++++++++++++++++---------------- src/frontends/qt4/TocWidget.h | 2 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/frontends/qt4/TocWidget.C b/src/frontends/qt4/TocWidget.C index 0ff2763766..b1cde0eb52 100644 --- a/src/frontends/qt4/TocWidget.C +++ b/src/frontends/qt4/TocWidget.C @@ -129,39 +129,39 @@ void TocWidget::on_typeCO_activated(int value) void TocWidget::on_moveUpPB_clicked() { - enableButtons(false); + enableControls(false); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); if (!list.isEmpty()) { - enableButtons(false); + enableControls(false); form_->goTo(typeCO->currentIndex(), list[0]); form_->outlineUp(); - enableButtons(true); + enableControls(true); } } void TocWidget::on_moveDownPB_clicked() { - enableButtons(false); + enableControls(false); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); if (!list.isEmpty()) { - enableButtons(false); + enableControls(false); form_->goTo(typeCO->currentIndex(), list[0]); form_->outlineDown(); - enableButtons(true); + enableControls(true); } } void TocWidget::on_moveInPB_clicked() { - enableButtons(false); + enableControls(false); QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); if (!list.isEmpty()) { - enableButtons(false); + enableControls(false); form_->goTo(typeCO->currentIndex(), list[0]); form_->outlineIn(); - enableButtons(true); + enableControls(true); } } @@ -170,10 +170,10 @@ void TocWidget::on_moveOutPB_clicked() { QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes(); if (!list.isEmpty()) { - enableButtons(false); + enableControls(false); form_->goTo(typeCO->currentIndex(), list[0]); form_->outlineOut(); - enableButtons(true); + enableControls(true); } } @@ -194,7 +194,7 @@ void TocWidget::select(QModelIndex const & index) } -void TocWidget::enableButtons(bool enable) +void TocWidget::enableControls(bool enable) { updatePB->setEnabled(enable); @@ -205,6 +205,8 @@ void TocWidget::enableButtons(bool enable) moveDownPB->setEnabled(enable); moveInPB->setEnabled(enable); moveOutPB->setEnabled(enable); + + depthSL->setEnabled(enable); } @@ -220,11 +222,10 @@ void TocWidget::updateGui() { QStringListModel * type_model = form_->typeModel(); if (type_model->stringList().isEmpty()) { - enableButtons(false); + enableControls(false); typeCO->setModel(type_model); tocTV->setModel(new QStandardItemModel); tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers); - depthSL->setEnabled(false); return; } @@ -242,20 +243,22 @@ void TocWidget::updateGui() void TocWidget::setTocModel(size_t type) { - bool buttons_enabled = false; + bool controls_enabled = false; QStandardItemModel * toc_model = form_->tocModel(type); if (toc_model) { - buttons_enabled = toc_model->rowCount() > 0; + controls_enabled = toc_model->rowCount() > 0; tocTV->setModel(toc_model); tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers); } - enableButtons(buttons_enabled); + enableControls(controls_enabled); reconnectSelectionModel(); - depthSL->setEnabled(true); - depthSL->setMaximum(form_->getTocDepth(type)); - depthSL->setValue(depth_); + + if (controls_enabled) { + depthSL->setMaximum(form_->getTocDepth(type)); + depthSL->setValue(depth_); + } LYXERR(Debug::GUI) << "In TocWidget::updateGui()" << endl; diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index c04989fd04..14897cfaaf 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -51,7 +51,7 @@ protected Q_SLOTS: protected: /// - void enableButtons(bool enable = true); + void enableControls(bool enable = true); /// int getIndexDepth(QModelIndex const & index, int depth = -1); ///