2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #include "../common.h"
27 #include "listcommon.h"
28 #include "extendedlistitemstore.h"
30 #include "extendedlistitemdelegate.h"
32 ExtendedListItemDelegate::ExtendedListItemDelegate(QWidget *parent)
33 : ListItemDelegate(parent)
35 qDebug() << __PRETTY_FUNCTION__;
38 void ExtendedListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
39 const QModelIndex &index) const
41 qDebug() << __PRETTY_FUNCTION__;
43 ListItemDelegate::paint(painter, option, index);
45 painter->setPen(COLOR_GRAY);
46 painter->setFont(NOKIA_FONT_SMALL);
48 QRect itemRect = option.rect;
49 QList<ExtendedListItemStore *> *subItems = (QList<ExtendedListItemStore *> *)
50 (index.data(SUBITEM_STORE_INDEX).value<void *>());
51 bool expanded = index.data(ITEM_EXPANDED_INDEX).toBool();
52 bool itemHasImage = index.data(ITEM_HAS_IMAGE_INDEX).toBool();
56 int previousSubItemTextRectBottom = itemRect.top() + IMAGE_HEIGHT - 2*MARGIN;
58 for (int i = 0; i < subItems->size(); ++i) {
60 ExtendedListItemStore *itemStore = subItems->at(i);
61 QRect subItemTextRect = itemStore->textRect();
65 text = itemStore->text();
68 subItemTextRect.setHeight(ICON_HEIGHT);
69 text = itemStore->shortenedText();
72 QRect iconRect = QRect(itemRect.left() + MARGIN * 3,
73 previousSubItemTextRectBottom + ICON_MARGIN,
74 ICON_WIDTH, ICON_HEIGHT);
77 iconRect.translate(IMAGE_WIDTH, 0);
79 subItemTextRect.translate(iconRect.right() + MARGIN, iconRect.top());
81 if (!itemStore->icon().isNull())
82 painter->drawPixmap(iconRect, itemStore->icon());
84 painter->drawText(subItemTextRect, Qt::TextWrapAnywhere, text);
85 previousSubItemTextRectBottom = subItemTextRect.bottom();