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,
25 #include "friendlistitemdelegate.h"
26 #include "../common.h"
27 #include "listcommon.h"
29 FriendListItemDelegate::FriendListItemDelegate()
31 qDebug() << __PRETTY_FUNCTION__;
33 m_clockImage = QPixmap(":/res/images/clock.png");
34 m_envelopeImage = QPixmap(":/res/images/envelope.png");
35 m_compassImage = QPixmap(":/res/images/compass.png");
38 void FriendListItemDelegate::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 QString statusText = index.data(STATUS_TEXT_DISPLAY_INDEX).toString();
49 QString location = index.data(LOCATION_DISPLAY_INDEX).toString();
50 QString updated = index.data(UPDATED_DISPLAY_INDEX).toString();
51 QString distance = index.data(DISTANCE_TEXT_DISPLAY_INDEX).toString();
52 QPixmap distanceIcon = QPixmap(qvariant_cast<QPixmap>(index.data(DISTANCE_IMAGE_INDEX)));
54 QRect itemRect = option.rect;
56 QPoint distanceIconPoint = QPoint(ITEM_WIDTH - ICON_WIDTH - 3*MARGIN, itemRect.top() + MARGIN);
57 QRect distanceRect = index.data(DISTANCE_SIZE_HINT_INDEX).toRect();
58 distanceRect.translate(ITEM_WIDTH - distanceRect.width() - 2*MARGIN,
59 itemRect.top() + ICON_HEIGHT + 2*MARGIN);
61 painter->drawPixmap(distanceIconPoint, distanceIcon);
62 painter->drawText(distanceRect, Qt::TextSingleLine, distance);
64 QRect envelopeRect = QRect(itemRect.left() + IMAGE_WIDTH + 3*MARGIN,
65 itemRect.top() + IMAGE_HEIGHT - 2*MARGIN, ICON_WIDTH, ICON_HEIGHT);
66 QRect statusTextRect = index.data(STATUS_TEXT_SIZE_HINT_INDEX).toRect();
67 statusTextRect.translate(envelopeRect.right() + MARGIN, envelopeRect.top());
69 painter->drawPixmap(envelopeRect, m_envelopeImage);
70 painter->drawText(statusTextRect, Qt::TextWrapAnywhere, statusText);
73 QRect compassRect = QRect(envelopeRect.left(), statusTextRect.bottom() + ICON_MARGIN,
74 ICON_WIDTH, ICON_HEIGHT);
75 QRect locationRect = index.data(LOCATION_SIZE_HINT_INDEX).toRect();
76 locationRect.translate(compassRect.right() + MARGIN, compassRect.top());
78 painter->drawPixmap(compassRect, m_compassImage);
79 painter->drawText(locationRect, Qt::TextWrapAnywhere, location);
81 QRect clockRect = QRect(envelopeRect.left(), locationRect.bottom() + ICON_MARGIN, ICON_WIDTH,
83 QRect updatedRect = index.data(UPDATED_SIZE_HINT_INDEX).toRect();
84 updatedRect.translate(clockRect.right() + MARGIN, clockRect.top());
86 painter->drawPixmap(clockRect, m_clockImage);
87 painter->drawText(updatedRect, Qt::TextWrapAnywhere, updated);
90 QSize FriendListItemDelegate::sizeHint(const QStyleOptionViewItem &option,
91 const QModelIndex &index) const
93 qDebug() << __PRETTY_FUNCTION__;
95 return ListItemDelegate::sizeHint(option, index);