Added tags to SituareService::getInterestingPeople.
[situare] / src / ui / personlistitem.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 <QPixmap>
24
25 #include "../user/user.h"
26 #include "../common.h"
27 #include "listcommon.h"
28
29 #include "personlistitem.h"
30
31 PersonListItem::PersonListItem()
32 {
33     qDebug() << __PRETTY_FUNCTION__;
34
35     setSubitemTextWidth(SUBITEM_TEXT_MAX_WIDTH);
36 }
37
38 PersonListItem::~PersonListItem()
39 {
40     qDebug() << __PRETTY_FUNCTION__;
41 }
42
43 GeoCoordinate PersonListItem::coordinates() const
44 {
45     qDebug() << __PRETTY_FUNCTION__;
46
47     return m_coordinates;
48 }
49
50 QString PersonListItem::facebookId() const
51 {
52     return m_facebookId;
53 }
54
55 void PersonListItem::setAvatarImage(const QPixmap &image)
56 {
57     qDebug() << __PRETTY_FUNCTION__;
58
59     if(!image.isNull())
60         setImage(image);
61 }
62
63 void PersonListItem::setCoordinates(const GeoCoordinate &coordinates)
64 {
65     qDebug() << __PRETTY_FUNCTION__;
66
67     m_coordinates = coordinates;
68 }
69
70 void PersonListItem::setFacebookId(const QString &facebookId)
71 {
72     qDebug() << __PRETTY_FUNCTION__;
73
74     m_facebookId = facebookId;
75 }
76
77 void PersonListItem::setPersonData(const User &user)
78 {
79     qDebug() << __PRETTY_FUNCTION__;
80
81     setFacebookId(user.userId());
82
83     setTitle(shortenText(user.name(), NAME_TEXT_MAX_WIDTH - MARGIN * 3,
84                          ListItem::TEXT_SIZE_NORMAL));
85     setCoordinates(user.coordinates());
86
87     if (!user.profileImage().isNull())
88         setImage(user.profileImage());
89
90     clearSubItems();
91
92     QString tagsText;
93
94     foreach (QString tag, user.tags())
95         tagsText.append("[" + tag + "] ");
96
97     addSubItem(tagsText, QPixmap(":/res/images/tag.png"));
98 }
99