From Ozgur Ugras BARAN: Fix bug 3529

* 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
This commit is contained in:
Jürgen Spitzmüller 2007-05-15 11:26:24 +00:00
parent df90247126
commit 9e4022e235
2 changed files with 24 additions and 9 deletions

View 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

View 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_;