Added selected state images to list items.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 17 Aug 2010 07:01:32 +0000 (10:01 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 17 Aug 2010 07:01:32 +0000 (10:01 +0300)
images.qrc
res/images/list_item_bottom_selected.png [new file with mode: 0644]
res/images/list_item_middle_selected.png [new file with mode: 0644]
res/images/list_item_top_selected.png [new file with mode: 0644]
src/ui/listitemdelegate.cpp
src/ui/listitemdelegate.h

index 2ea4c0b..bf3e802 100644 (file)
@@ -46,5 +46,8 @@
         <file>res/images/arrow_turn_start.png</file>
         <file>res/images/arrow_turn_u_turn.png</file>
         <file>res/images/ruler.png</file>
+        <file>res/images/list_item_bottom_selected.png</file>
+        <file>res/images/list_item_middle_selected.png</file>
+        <file>res/images/list_item_top_selected.png</file>
     </qresource>
 </RCC>
diff --git a/res/images/list_item_bottom_selected.png b/res/images/list_item_bottom_selected.png
new file mode 100644 (file)
index 0000000..236cb58
Binary files /dev/null and b/res/images/list_item_bottom_selected.png differ
diff --git a/res/images/list_item_middle_selected.png b/res/images/list_item_middle_selected.png
new file mode 100644 (file)
index 0000000..2840e6c
Binary files /dev/null and b/res/images/list_item_middle_selected.png differ
diff --git a/res/images/list_item_top_selected.png b/res/images/list_item_top_selected.png
new file mode 100644 (file)
index 0000000..9fb5bb9
Binary files /dev/null and b/res/images/list_item_top_selected.png differ
index c6ed37d..1001b39 100644 (file)
@@ -41,6 +41,9 @@ ListItemDelegate::ListItemDelegate(QWidget *parent) :
     m_backgroundTopImage.load(":/res/images/list_item_top.png");
     m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
     m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
+    m_backgroundTopSelectedImage.load(":/res/images/list_item_top_selected.png");
+    m_backgroundMiddleSelectedImage.load(":/res/images/list_item_middle_selected.png");
+    m_backgroundBottomSelectedImage.load(":/res/images/list_item_bottom_selected.png");
 }
 
 void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
@@ -51,6 +54,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
     QPixmap image = QPixmap(qvariant_cast<QPixmap>(index.data(AVATAR_IMAGE_INDEX)));
     QString name = index.data(TITLE_DISPLAY_INDEX).toString();
     QSize size = index.data(ITEM_SIZE_HINT_INDEX).toSize();
+    bool selected = index.data(ITEM_EXPANDED_INDEX).toBool();
 
     QRect itemRect = option.rect;
 
@@ -62,9 +66,15 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
     QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), ITEM_WIDTH,
                              BACKGROUND_BOTTOM_HEIGHT);
 
-    painter->drawPixmap(topRect, m_backgroundTopImage);
-    painter->drawPixmap(middleRect, m_backgroundMiddleImage);
-    painter->drawPixmap(bottomRect, m_backgroundBottomImage);
+    if (selected) {
+        painter->drawPixmap(topRect, m_backgroundTopSelectedImage);
+        painter->drawPixmap(middleRect, m_backgroundMiddleSelectedImage);
+        painter->drawPixmap(bottomRect, m_backgroundBottomSelectedImage);
+    } else {
+        painter->drawPixmap(topRect, m_backgroundTopImage);
+        painter->drawPixmap(middleRect, m_backgroundMiddleImage);
+        painter->drawPixmap(bottomRect, m_backgroundBottomImage);
+    }
 
     painter->setPen(Qt::white);
     painter->setFont(NOKIA_FONT_NORMAL);
index b10118b..90c99a2 100644 (file)
@@ -73,6 +73,9 @@ private:
     QPixmap m_backgroundBottomImage;   ///< Bottom background image
     QPixmap m_backgroundMiddleImage;   ///< Middle background image
     QPixmap m_backgroundTopImage;      ///< Top background image
+    QPixmap m_backgroundBottomSelectedImage;   ///< Bottom background image
+    QPixmap m_backgroundMiddleSelectedImage;   ///< Middle background image
+    QPixmap m_backgroundTopSelectedImage;      ///< Top background image
 };
 
 #endif // LISTITEMDELEGATE_H