summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorSami Merilä <sami.merila@nokia.com>2009-10-20 10:31:33 (GMT)
committerSami Merilä <sami.merila@nokia.com>2009-10-20 10:31:33 (GMT)
commitda3e89e8d98a4d3322eae94aafd38ddb444f144e (patch)
treed321284a2c0a8c48dc57c0971a8fbe38e86d120f /src/gui/styles
parentccb376e04c29c4a9214f71c173c81f5877dc9502 (diff)
downloadQt-da3e89e8d98a4d3322eae94aafd38ddb444f144e.zip
Qt-da3e89e8d98a4d3322eae94aafd38ddb444f144e.tar.gz
Qt-da3e89e8d98a4d3322eae94aafd38ddb444f144e.tar.bz2
QT-693 QS60Style does not regard selection beahviors with itemviews
QS60Style disregards all selection behaviors for itemviews. This leads to error when showing a highlighted selection rect; rect is only shown for cell having focus. Fixed by setting the highlight to all 'selected' cells. Task-number: QT-693 Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 4fa1d03..6d95336 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -1313,7 +1313,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->save();
painter->setClipRect(voptAdj.rect);
- const bool isSelected = (voptAdj.state & QStyle::State_HasFocus);
+ const bool isSelected = (vopt->state & QStyle::State_Selected);
bool isVisible = false;
int scrollBarWidth = 0;
@@ -1358,7 +1358,27 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
// draw the focus rect
if (isSelected) {
- const QRect highlightRect = option->rect.adjusted(1,1,-1,-1);
+ QRect highlightRect = option->rect.adjusted(1,1,-1,-1);
+ const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
+ if (view && view->selectionBehavior() != QAbstractItemView::SelectItems) {
+ // set highlight rect so that it is continuous from cell to cell, yet sligthly
+ // smaller than cell rect
+ int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0;
+ if (view->selectionBehavior() == QAbstractItemView::SelectRows) {
+ yBeginning = 1; yEnd = -1;
+ if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning)
+ xBeginning = 1;
+ else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End)
+ xEnd = -1;
+ } else if (view->selectionBehavior() == QAbstractItemView::SelectColumns) {
+ xBeginning = 1; xEnd = -1;
+ if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning)
+ yBeginning = 1;
+ else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End)
+ yEnd = -1;
+ }
+ highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, xBeginning);
+ }
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags);
}