Added user class and related unit-tests, implemented user data fetching, re-factored...
[situare] / src / user / user.h
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 #ifndef USER_H
23 #define USER_H
24
25 #include <QPointF>
26 #include <QString>
27 #include <QUrl>
28
29 /**
30 * @brief Class to store user information (applies to friends also)
31 *
32 * @author Henri Lampela
33 * @class User user.h "user/user.h"
34 */
35 class User
36 {
37 public:
38
39     /**
40     * @brief Default constructor, initializes member data
41     *
42     */
43     User(const QString address, const QPointF coordinates, const QString name, const QString note,
44          const QUrl imageUrl, const QString timestamp, const bool type, const QString userId,
45          const QString units = 0, const double value = 0);
46
47     /**
48     * @brief Set address
49     *
50     * @param address street address
51     */
52     void setAddress(const QString &address);
53
54     /**
55     * @brief Set coordinates ( x = lon, y = lat )
56     *
57     * @param coordinates coordinates
58     */
59     void setCoordinates(const QPointF &coordinates);
60
61     /**
62     * @brief Set distance
63     *
64     * @param value distance
65     * @param units unit type
66     */
67     void setDistance(const double &value, const QString &units);
68
69     /**
70     * @brief Set note
71     *
72     * @param note note/status message
73     */
74     void setNote(const QString &note);
75
76     /**
77     * @brief Set download address for profile image
78     *
79     * @param imageUrl image url
80     */
81     void setProfileImageUrl(const QUrl &imageUrl);
82
83     /**
84     * @brief Set timestamp for last status update, timestamp is in literal mode
85     *
86     * @param timestamp timestamp
87     */
88     void setTimestamp(const QString &timestamp);
89
90     /**
91     * @brief Get address
92     *
93     * @return QString address
94     */
95     QString address() const;
96
97     /**
98     * @brief Get coordinates
99     *
100     * @return QPointF coordinates
101     */
102     QPointF coordinates() const;
103
104     /**
105     * @brief Get distance and units
106     *
107     * @param value distance
108     * @param units unit type
109     */
110     void distance(double &value, QString &units) const;
111
112     /**
113     * @brief Get name
114     *
115     * @return QString profile name
116     */
117     QString name() const;
118
119     /**
120     * @brief Get note/status message
121     *
122     * @return QString note
123     */
124     QString note() const;
125
126     /**
127     * @brief Get download address for profile image
128     *
129     * @return QString url
130     */
131     QUrl profileImageUrl() const;
132
133     /**
134     * @brief Get timestamp of last status update
135     *
136     * @return QString timestamp
137     */
138     QString timestamp() const;
139
140     /**
141     * @brief Get user type
142     *
143     * @return bool user type (true = user, false = friend)
144     */
145     bool type() const;
146
147     /**
148     * @brief Get userId
149     *
150     * @return QString userId
151     */
152     QString userId() const;
153
154 private:
155     QString m_address; ///< placeholder for address information
156     QPointF m_coordinates; ///< placeholder for coordinates
157     QString m_name; ///< placeholder for name
158     QString m_note; ///< placeholder for note
159     QUrl m_profileImageUrl; ///< placeholder for image url
160     QString m_timestamp; ///< placeholer for timestamp
161     bool m_type; ///< placeholder for user type
162     QString m_units; ///< placeholder for distance unit type
163     QString m_userId; ///< placeholder for userId
164     double m_value; ///< placeholder for distance value
165 };
166
167
168 #endif // USER_H