Emit error signal when login fails
[situare] / src / ui / friendlistitemdelegate.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
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.
10
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.
15
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,
19    USA.
20 */
21
22 #include <QDebug>
23 #include <QPainter>
24
25 #include "friendlistitemdelegate.h"
26 #include "../common.h"
27 #include "listcommon.h"
28
29 FriendListItemDelegate::FriendListItemDelegate(QWidget *parent)
30     : ExtendedListItemDelegate(parent)
31 {
32     qDebug() << __PRETTY_FUNCTION__;
33 }
34
35 void FriendListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
36                                    const QModelIndex &index) const
37 {
38     qDebug() << __PRETTY_FUNCTION__;
39
40     ExtendedListItemDelegate::paint(painter, option, index);
41
42     painter->setPen(COLOR_GRAY);
43     painter->setFont(NOKIA_FONT_SMALL);
44
45     QString distance = index.data(DISTANCE_TEXT_DISPLAY_INDEX).toString();
46     QPixmap distanceIcon = QPixmap(qvariant_cast<QPixmap>(index.data(DISTANCE_IMAGE_INDEX)));
47
48     QRect itemRect = option.rect;
49
50     QPoint distanceIconPoint = QPoint(ITEM_WIDTH - ICON_WIDTH - 3 * MARGIN,
51                                       itemRect.top() + MARGIN);
52
53     QRect distanceRect = index.data(DISTANCE_SIZE_HINT_INDEX).toRect();
54     distanceRect.translate(ITEM_WIDTH - distanceRect.width() - 2 * MARGIN,
55                            itemRect.top() + ICON_HEIGHT + 3 * MARGIN);
56
57     painter->drawPixmap(distanceIconPoint, distanceIcon);
58     painter->drawText(distanceRect, Qt::TextSingleLine, distance);
59 }