diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-11 10:39:19 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-11 10:53:06 (GMT) |
commit | 820db2b2c5a0fc470fa5759d95ea49305ec98654 (patch) | |
tree | 1fc8274854a0ecb2447bbeb67a5dabf94023f567 /src | |
parent | 45fedfeb405807453e94958808c2f1d48bb846ca (diff) | |
download | Qt-820db2b2c5a0fc470fa5759d95ea49305ec98654.zip Qt-820db2b2c5a0fc470fa5759d95ea49305ec98654.tar.gz Qt-820db2b2c5a0fc470fa5759d95ea49305ec98654.tar.bz2 |
Fix incorrect drawing of the hovered row on QTreeView with some styles.
Some styles such as oxygen, or gtk, require the whole row to be
redrawn in case of mouse hover the items.
There was special code that handle that in the MouseMove event of
the QTreeView, but that did not covered all the case (such as
scrolling with the mouse wheel)
Reviewed-by: Gabriel
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 11 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 9 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index f447989..f852e67 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -146,9 +146,16 @@ void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index) if (hover == index) return; - q->update(hover); //update the old one + if (selectionBehavior != QAbstractItemView::SelectRows) { + q->update(hover); //update the old one + q->update(index); //update the new one + } else { + QRect oldHoverRect = q->visualRect(hover); + QRect newHoverRect = q->visualRect(index); + viewport->update(QRect(0, newHoverRect.y(), viewport->width(), newHoverRect.height())); + viewport->update(QRect(0, oldHoverRect.y(), viewport->width(), oldHoverRect.height())); + } hover = index; - q->update(hover); //update the new one } void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index f25d648..24b448c 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1241,15 +1241,6 @@ bool QTreeView::viewportEvent(QEvent *event) viewport()->update(newRect); } } - if (selectionBehavior() == QAbstractItemView::SelectRows) { - QModelIndex newHoverIndex = indexAt(he->pos()); - if (d->hover != newHoverIndex) { - QRect oldHoverRect = visualRect(d->hover); - QRect newHoverRect = visualRect(newHoverIndex); - viewport()->update(QRect(0, newHoverRect.y(), viewport()->width(), newHoverRect.height())); - viewport()->update(QRect(0, oldHoverRect.y(), viewport()->width(), oldHoverRect.height())); - } - } break; } default: break; |