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 "../user/user.h"
27 #include "../common.h"
28 #include "listcommon.h"
30 #include "friendlistitem.h"
32 FriendListItem::FriendListItem()
34 qDebug() << __PRETTY_FUNCTION__;
36 setSubitemTextWidth(SUBITEM_TEXT_MAX_WIDTH);
39 FriendListItem::~FriendListItem()
41 qDebug() << __PRETTY_FUNCTION__;
44 GeoCoordinate FriendListItem::coordinates() const
46 qDebug() << __PRETTY_FUNCTION__;
51 void FriendListItem::setAvatarImage(const QPixmap &image)
53 qDebug() << __PRETTY_FUNCTION__;
59 void FriendListItem::setCoordinates(const GeoCoordinate &coordinates)
61 qDebug() << __PRETTY_FUNCTION__;
63 m_coordinates = coordinates;
66 void FriendListItem::setDistanceIcon(double value, const QString &unit)
68 qDebug() << __PRETTY_FUNCTION__;
70 const int AEROPLANE_DISTANCE = 5000;///< Aeroplane distance limit for distance icon
71 const int CAR_DISTANCE = 500; ///< Car distance limit for distance icon
72 const int WALK_DISTANCE = 5; ///< Walk distance limit for distance icon
74 QPixmap distanceImage;
76 if ((unit == "m") || (value < WALK_DISTANCE))
77 distanceImage.load(":/res/images/walk_icon_gray.png");
78 else if (value < CAR_DISTANCE)
79 distanceImage.load(":/res/images/car_icon_gray.png");
80 else if (value < AEROPLANE_DISTANCE)
81 distanceImage.load(":/res/images/aeroplane_icon_gray.png");
83 distanceImage.load(":/res/images/rocket_icon_gray.png");
85 setData(DISTANCE_IMAGE_INDEX, distanceImage);
88 void FriendListItem::setUserData(User *user)
90 qDebug() << __PRETTY_FUNCTION__;
94 user->distance(value, unit);
95 QString distanceText = QString::number(value) + " " + unit;
96 setData(DISTANCE_TEXT_DISPLAY_INDEX, distanceText);
97 setDistanceIcon(value, unit);
99 //Dummy value to get painter font metrics.
100 QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT);
101 QPainter painter(&p);
102 painter.setFont(NOKIA_FONT_SMALL);
103 QFontMetrics distanceTextFontMetrics = painter.fontMetrics();
104 QRect distanceRect = distanceTextFontMetrics.boundingRect(distanceText);
106 setData(DISTANCE_SIZE_HINT_INDEX, distanceRect);
107 QString nameTemp = QString("Pitka nimi pitka nimi pitka nimi");
108 setTitle(shortenText(nameTemp, NAME_TEXT_MAX_WIDTH - distanceRect.width() - MARGIN * 2,
109 ListItem::TEXT_SIZE_NORMAL));
110 setCoordinates(user->coordinates());
112 if (!user->profileImage().isNull())
113 setImage(user->profileImage());
117 QString noteTemp = QString("Joillakin lehdillä on tosi tarkat rajat painon kanssa, ja emme "
118 "menneet Playboyn pyytämiin koekuvauksiinkaan, kun he sanoivat, "
119 "että se on ainoa mahdollisuus. Jos on esim. liian ruskettunut, "
120 "niin he karsivat saman tien pois. Nain jälkikäteen ajatellen minua "
121 "on jäänyt harmittamaan, ettemme menneet koekuvaukseen kun kerran "
122 "pyydettiin! Kun Julia pääsi kyseisen lehden Grapevine-sivulle "
123 "vuonna 2003, meille molemmille jäi kytemään ajatus jatkosta. "
124 "Olemme ihmetelleet, miksi Suomen lehdistö sivuutti asian vain "
125 "nopeasti. Vaikka kyseessä ei ollutkaan monen kuvan kuvasarja "
126 "Juliasta, hän silti poseerasi varsinaisessa Playboy-lehdessä.");
127 QString noteTemp2 = QString("hei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\n"
128 "hei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei\nhei");
130 static int index = 0;
133 addSubItem(noteTemp, QPixmap(":/res/images/envelope.png"));
135 // addSubItem(noteTemp2, QPixmap(":/res/images/envelope.png"));
136 addSubItem(user->address(), QPixmap(":/res/images/compass.png"));
137 addSubItem(user->timestamp(), QPixmap(":/res/images/clock.png"));