From b3db0a708a630d9f59857ab7dcbfe8f29e3e8eb9 Mon Sep 17 00:00:00 2001 From: Rafael Fernández López Date: Mon, 17 Sep 2007 06:03:40 +0000 Subject: Give feedback to user when clicking on a category and the user is not dragging from it. Beauty, come to me :) CCMAIL: peter.penz@gmx.at svn path=/trunk/KDE/kdebase/apps/; revision=713337 --- src/kcategorizedview.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/kcategorizedview.cpp') diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index 7bc0055ae..026f56c24 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -357,10 +357,23 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index, QStyleOption optionCopy = option; const QString category = proxyModel->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString(); + optionCopy.state &= ~QStyle::State_Selected; + if ((category == hoveredCategory) && !mouseButtonPressed) { optionCopy.state |= QStyle::State_MouseOver; } + else if ((category == hoveredCategory) && mouseButtonPressed) + { + QPoint initialPressPosition = listView->viewport()->mapFromGlobal(QCursor::pos()); + initialPressPosition.setY(initialPressPosition.y() + listView->verticalOffset()); + initialPressPosition.setX(initialPressPosition.x() + listView->horizontalOffset()); + + if (initialPressPosition == this->initialPressPosition) + { + optionCopy.state |= QStyle::State_Selected; + } + } categoryDrawer->drawCategory(index, sortRole, @@ -891,6 +904,8 @@ void KCategorizedView::mousePressEvent(QMouseEvent *event) } QListView::mousePressEvent(event); + + viewport()->update(d->categoryVisualRect(d->hoveredCategory)); } void KCategorizedView::mouseReleaseEvent(QMouseEvent *event) -- cgit v1.3