forked from qt-creator/qt-creator
QmlProfiler: Reduce the amount of useless signals on item selection
By passing signals with identification information of varying accurary between the different views the event being selected could be changed while it was selected. By checking the current selection against the information given in the signal and not reselecting when it matches the situation is improved. Also, the selection methods are given more appropriate names. We hardly ever want to select the "next" event, but rather the "best fitting" one. Task-number: QTCREATORBUG-11945 Change-Id: I659b4929cb88f4c931a0893aa95a3bc92da5a23b Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -699,13 +699,22 @@ void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
|
||||
d->m_preventSelectBounce = false;
|
||||
}
|
||||
|
||||
void QmlProfilerEventsMainView::selectItem(const QStandardItem *item)
|
||||
{
|
||||
// If the same item is already selected, don't reselect it.
|
||||
QModelIndex index = d->m_model->indexFromItem(item);
|
||||
if (index != currentIndex()) {
|
||||
setCurrentIndex(index);
|
||||
jumpToItem(index);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerEventsMainView::selectEvent(const QString &eventHash)
|
||||
{
|
||||
for (int i=0; i<d->m_model->rowCount(); i++) {
|
||||
QStandardItem *infoItem = d->m_model->item(i, 0);
|
||||
if (infoItem->data(EventHashStrRole).toString() == eventHash) {
|
||||
setCurrentIndex(d->m_model->indexFromItem(infoItem));
|
||||
jumpToItem(currentIndex());
|
||||
selectItem(infoItem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -718,13 +727,11 @@ void QmlProfilerEventsMainView::selectEventByLocation(const QString &filename, i
|
||||
|
||||
for (int i=0; i<d->m_model->rowCount(); i++) {
|
||||
QStandardItem *infoItem = d->m_model->item(i, 0);
|
||||
if (currentIndex() != d->m_model->indexFromItem(infoItem) &&
|
||||
infoItem->data(FilenameRole).toString() == filename &&
|
||||
if (infoItem->data(FilenameRole).toString() == filename &&
|
||||
infoItem->data(LineRole).toInt() == line &&
|
||||
(column == -1 ||
|
||||
infoItem->data(ColumnRole).toInt() == column)) {
|
||||
setCurrentIndex(d->m_model->indexFromItem(infoItem));
|
||||
jumpToItem(currentIndex());
|
||||
selectItem(infoItem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user