This repository was archived by the owner on Sep 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuserinfo.h
More file actions
104 lines (94 loc) · 4.09 KB
/
userinfo.h
File metadata and controls
104 lines (94 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* Copyright (c) 2011, Antonie Jovanoski
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
*/
#ifndef USERINFO_H
#define USERINFO_H
#include <QObject>
#include "qtweetlib/qtweetuser.h"
class OAuthTwitter;
class QTweetStatus;
/**
* Stores, fetches twitter user information.
*/
class UserInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(QString screenName READ screenName NOTIFY userInfoChanged)
Q_PROPERTY(QString description READ description NOTIFY userInfoChanged)
Q_PROPERTY(QString url READ url NOTIFY userInfoChanged)
Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY userInfoChanged)
Q_PROPERTY(QString location READ location NOTIFY userInfoChanged)
Q_PROPERTY(QString userid READ userid NOTIFY userInfoChanged)
Q_PROPERTY(QString name READ name NOTIFY userInfoChanged)
Q_PROPERTY(int numTweets READ numTweets NOTIFY userInfoChanged)
Q_PROPERTY(int numFollowers READ numFollowers NOTIFY userInfoChanged)
Q_PROPERTY(int numFollowing READ numFollowing NOTIFY userInfoChanged)
Q_PROPERTY(int numFavorites READ numFavorites NOTIFY userInfoChanged)
Q_PROPERTY(bool isFriend READ isFriend NOTIFY isFriendChanged)
public:
explicit UserInfo(QObject *parent = 0);
/** returns user screenname */
QString screenName() const { return m_userinfo.screenName(); }
/** returns user description */
QString description() const { return m_userinfo.description(); }
/** returns user url */
QString url() const { return m_userinfo.url(); }
/** returns user avatar url */
QString avatarUrl() const { return m_userinfo.profileImageUrl(); }
/** returns user location */
QString location() const { return m_userinfo.location(); }
/** returns user id in string */
QString userid() const { return QString::number(m_userinfo.id()); }
/** returns user name */
QString name() const { return m_userinfo.name(); }
/** returns numbers of tweets for the user */
int numTweets() const { return m_userinfo.statusesCount(); }
/** returns number of followers who a following the user */
int numFollowers() const { return m_userinfo.followersCount(); }
/** returns number of users the user is following */
int numFollowing() const { return m_userinfo.friendsCount(); }
/** returns the number of favorited tweets */
int numFavorites() const { return m_userinfo.favouritesCount(); }
/** true if authenticated user is following the user */
bool isFriend() const { return m_isFriend; }
void setOAuthTwitter(OAuthTwitter* oauthTwitter) { m_oauthTwitter = oauthTwitter; }
void fetch(qint64 userid);
Q_INVOKABLE void fetch(const QString& userid);
Q_INVOKABLE void fetchByName(const QString& screenName);
Q_INVOKABLE void followUser(const QString& screenName);
Q_INVOKABLE void unfollowUser(const QString& screenName);
Q_INVOKABLE void createFavorite(const QString& id);
public slots:
void onUserStreamFriendsList(const QList<qint64> friends);
signals:
/** emited when user information is changed */
void userInfoChanged();
void isFriendChanged();
private slots:
void finishedFetch(const QTweetUser& userInfo);
void finishedFollowUser(const QTweetUser& user);
void finishedUnfollowUser(const QTweetUser& user);
void finishedCreateFavorite(const QTweetStatus& status);
private:
QTweetUser m_userinfo;
OAuthTwitter* m_oauthTwitter;
QList<qint64> m_friends;
bool m_isFriend;
};
#endif // USERINFO_H