]> git.lyx.org Git - features.git/commitdiff
From Ozgur Ugras BARAN: Fix bug 3529
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 15 May 2007 11:26:24 +0000 (11:26 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 15 May 2007 11:26:24 +0000 (11:26 +0000)
* src/frontends/qt4/TocWidget.{cpp,h}:
-  new member disconnectSelectionModel()
- (select): replace blockSignal() directives for tocTV selectionModel()
   with disconnect (the above new function) and reconnect relevant signal

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18338 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index 31c7e8f48feb8955cd7bc9ceed6fbb689d08926e..7046dda2f261f185035450a88196f55c5565a36f 100644 (file)
@@ -106,7 +106,8 @@ depth calculation.
 int TocWidget::getIndexDepth(QModelIndex const & index, int depth)
 {
        ++depth;
-       return (index.parent() == QModelIndex())? depth : getIndexDepth(index.parent(),depth);
+       return (index.parent() ==
+               QModelIndex())? depth : getIndexDepth(index.parent(),depth);
 }
 
 
@@ -205,12 +206,10 @@ void TocWidget::select(QModelIndex const & index)
                return;
        }
 
-       tocTV->selectionModel()->blockSignals(true);
-       tocTV->selectionModel()->clear();
-       tocTV->scrollTo(index);
-       tocTV->selectionModel()->setCurrentIndex(index,
-               QItemSelectionModel::ClearAndSelect);
-       tocTV->selectionModel()->blockSignals(false);
+       disconnectSelectionModel();
+       tocTV->setCurrentIndex(index);
+       tocTV->scrollTo(index);
+       reconnectSelectionModel();
 }
 
 
@@ -307,8 +306,21 @@ void TocWidget::setTocModel(size_t type)
 void TocWidget::reconnectSelectionModel()
 {
        connect(tocTV->selectionModel(),
-               SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
-               this, SLOT(selectionChanged(const QModelIndex &, const QModelIndex &)));
+               SIGNAL(currentChanged(const QModelIndex &,
+                      const QModelIndex &)),
+               this,
+               SLOT(selectionChanged(const QModelIndex &,
+                    const QModelIndex &)));
+}
+
+void TocWidget::disconnectSelectionModel()
+{
+       disconnect(tocTV->selectionModel(),
+                  SIGNAL(currentChanged(const QModelIndex &, 
+                         const QModelIndex &)),
+                  this,
+                  SLOT(selectionChanged(const QModelIndex &,
+                       const QModelIndex &)));
 }
 
 } // namespace frontend
index 1e474f4e517160f20c0339f3e7d8ef3cf9250c56..861d4ad768df6afb5df4e56facd07bc17426bbdc 100644 (file)
@@ -60,6 +60,9 @@ protected:
 private:
        /// Reconnects the selection model change signal when TOC changed.
        void reconnectSelectionModel();
+       /// Disconnects the selection model.
+       //This is a workaround for a problem of signals blocking.
+       void disconnectSelectionModel();
 
        QToc * form_;