Changed fetchPeopleWithSimilarInterest to send request to Situare server instead...
[situare] / src / user / user.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@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 <QVariant>
23
24 #include "user.h"
25
26 User::User(const QString &address, const GeoCoordinate &coordinates, const QString &name,
27            const QString &note, const QUrl &imageUrl, const QString &timestamp, const bool &type,
28            const QString &userId, const QString &units, const double &value)
29                : m_address(address)
30                , m_coordinates(coordinates)
31                , m_name(name)
32                , m_note(note)
33                , m_profileImageUrl(imageUrl)
34                , m_timestamp(timestamp)
35                , m_type(type)
36                , m_units(units)
37                , m_userId(userId)
38                , m_value(value)
39 {
40
41 }
42
43 User::User()
44     : m_address()
45     , m_coordinates()
46     , m_name()
47     , m_note()
48     , m_profileImageUrl()
49     , m_tags()
50     , m_timestamp()
51     , m_type()
52     , m_units()
53     , m_userId()
54     , m_value()
55 {
56
57 }
58
59 void User::setAddress(const QString &address)
60 {
61     m_address = address;
62 }
63
64 void User::setCoordinates(const GeoCoordinate &coordinates)
65 {
66     m_coordinates = coordinates;
67 }
68
69 void User::setDistance(const double &value, const QString &units)
70 {
71     m_value = value;
72     m_units = units;
73 }
74
75 void User::setName(const QString &name)
76 {
77     m_name = name;
78 }
79
80 void User::setNote(const QString &note)
81 {
82     m_note = note;
83 }
84
85 void User::setProfileImage(const QPixmap &image)
86 {
87     m_profileImage = image;
88 }
89
90 void User::setProfileImageUrl(const QUrl &imageUrl)
91 {
92     m_profileImageUrl = imageUrl;
93 }
94
95 void User::setTags(const QHash<QString, QString> &tags)
96 {
97     m_tags = tags;
98 }
99
100 void User::setTags(const QList<QVariant> &tags)
101 {
102     QHash<QString, QString> tagsStrings;
103
104     for (int i = 0; i < tags.count(); ++i)
105         tagsStrings.insert(QString::number(i), tags.at(i).toString());
106
107     m_tags = tagsStrings;
108 }
109
110 void User::setTags(const QString &tags)
111 {
112     QHash<QString, QString> tagsStrings;
113     QStringList invTags = tags.split(",");
114
115     for (int i = 0; i < invTags.count(); ++i)
116         tagsStrings.insert(QString::number(i), invTags.at(i));
117
118     m_tags = tagsStrings;
119 }
120
121 void User::setTimestamp(const QString &timestamp)
122 {
123     m_timestamp = timestamp;
124 }
125
126 void User::setUserId(const QString &userId)
127 {
128     m_userId = userId;
129 }
130
131 const QString& User::address() const
132 {
133     return m_address;
134 }
135
136 const GeoCoordinate& User::coordinates() const
137 {
138     return m_coordinates;
139 }
140
141 void User::distance(double &value, QString &units) const
142 {
143     value = m_value;
144     units = m_units;
145 }
146
147 const QString& User::name() const
148 {
149     return m_name;
150 }
151
152 const QString& User::note() const
153 {
154     return m_note;
155 }
156
157 const QPixmap& User::profileImage() const
158 {
159     return m_profileImage;
160 }
161
162 const QUrl& User::profileImageUrl() const
163 {
164     return m_profileImageUrl;
165 }
166
167 const QHash<QString, QString>& User::tags() const
168 {
169     return m_tags;
170 }
171
172 const QString& User::timestamp() const
173 {
174     return m_timestamp;
175 }
176
177 const bool& User::type() const
178 {
179     return m_type;
180 }
181
182 const QString& User::userId() const
183 {
184     return m_userId;
185 }