]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/TocWidget.cpp
Fix assertion with LOF and LOT by transfering the test from TocWidget::select() to...
[lyx.git] / src / frontends / qt4 / TocWidget.cpp
index acd52790338433795f7444bdf86d5c3c340fd69d..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();
 }
 
 
@@ -252,6 +251,7 @@ void TocWidget::updateGui()
        QString current_text = typeCO->currentText();
        lyxerr << "current_text " << fromqstr(current_text) << endl;
        typeCO->blockSignals(true);
+       typeCO->clear();
        int current_type = -1;
        for (size_t i = 0; i != type_names.size(); ++i) {
                QString item = toqstr(type_names[i]);
@@ -306,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