libusermetrics

UserMetrics.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of version 3 of the GNU Lesser General Public License as published
6 * by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 * details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19 #ifndef USERMETRICSOUTPUT_USERMETRICS_H_
20 #define USERMETRICSOUTPUT_USERMETRICS_H_
21
22 #include <QtCore/QString>
23 #include <QtGui/QColor>
24 #include <QtCore/QAbstractItemModel>
25
26 #include <libusermetricsoutput/ColorTheme.h>
27
35 namespace UserMetricsOutput {
36
56 class Q_DECL_EXPORT UserMetrics: public QObject {
57 Q_OBJECT
58
64 Q_PROPERTY(QString label READ label NOTIFY labelChanged FINAL)
65
66
69 Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged FINAL)
70
71
74 Q_PROPERTY(UserMetricsOutput::ColorTheme* firstColor READ firstColor NOTIFY firstColorChanged FINAL)
75
76
79 Q_PROPERTY(UserMetricsOutput::ColorTheme* secondColor READ secondColor NOTIFY secondColorChanged FINAL)
80
81
84 Q_PROPERTY(QAbstractItemModel *firstMonth READ firstMonth NOTIFY firstMonthChanged FINAL)
85
86
89 Q_PROPERTY(QAbstractItemModel *secondMonth READ secondMonth NOTIFY secondMonthChanged FINAL)
90
91
96 Q_PROPERTY(int currentDay READ currentDay NOTIFY currentDayChanged FINAL)
97
98 public:
102 static UserMetrics *getInstance();
103
107 virtual ~UserMetrics();
108
114 virtual QString label() const = 0;
115
119 virtual QString username() const = 0;
120
129 virtual void setUsername(const QString &username) = 0;
130
134 virtual ColorTheme * firstColor() const = 0;
135
139 virtual QAbstractItemModel *firstMonth() const = 0;
140
146 virtual int currentDay() const = 0;
147
151 virtual ColorTheme * secondColor() const = 0;
152
156 virtual QAbstractItemModel *secondMonth() const = 0;
157
158 Q_SIGNALS:
164 void labelChanged(const QString &label);
165
171 void usernameChanged(const QString &username);
172
178 void firstColorChanged(ColorTheme *color);
179
188 void firstMonthChanged(QAbstractItemModel *firstMonth);
189
197 void currentDayChanged(int currentDay);
198
204 void secondColorChanged(ColorTheme *color);
205
214 void secondMonthChanged(QAbstractItemModel *secondMonth);
215
219 void nextDataSource();
220
224 void readyForDataChange();
225
231 void dataAboutToAppear();
232
236 void dataAppeared();
237
243 void dataAboutToChange();
244
248 void dataChanged();
249
255 void dataAboutToDisappear();
256
260 void dataDisappeared();
261
262 public Q_SLOTS:
266 virtual void nextDataSourceSlot() = 0;
267
271 virtual void readyForDataChangeSlot() = 0;
272
273 protected:
279 explicit UserMetrics(QObject *parent = 0);
280
281 Q_DISABLE_COPY(UserMetrics)
282
283 };
284
285 }
286
289 #endif // USERMETRICSOUTPUT_USERMETRICS_H_
UserMetricsOutput::UserMetrics::currentDayChanged
void currentDayChanged(int currentDay)
The current day of the month has changed.
UserMetricsOutput::UserMetrics::secondMonth
virtual QAbstractItemModel * secondMonth() const =0
The data for the second month.
UserMetricsOutput::UserMetrics::dataAppeared
void dataAppeared()
Data has finished loading.
UserMetricsOutput::ColorTheme
ColorTheme for a particular user metric.
Definition: ColorTheme.h:37
UserMetricsOutput::UserMetrics::setUsername
virtual void setUsername(const QString &username)=0
Change the current username.
UserMetricsOutput::UserMetrics::dataAboutToAppear
void dataAboutToAppear()
Data is about to appear.
UserMetricsOutput::UserMetrics::firstColor
virtual ColorTheme * firstColor() const =0
The ColorTheme for the first month.
UserMetricsOutput::UserMetrics::label
virtual QString label() const =0
Represents a textual version of the current metric.
UserMetricsOutput::UserMetrics::dataAboutToChange
void dataAboutToChange()
Data is about to change from one set to another.
UserMetricsOutput::UserMetrics::secondColor
virtual ColorTheme * secondColor() const =0
The ColorTheme for the second month.
UserMetricsOutput::UserMetrics::dataAboutToDisappear
void dataAboutToDisappear()
About to change to a user with no data.
UserMetricsOutput::UserMetrics::firstMonth
virtual QAbstractItemModel * firstMonth() const =0
The data for the first month.
UserMetricsOutput::UserMetrics::secondMonthChanged
void secondMonthChanged(QAbstractItemModel *secondMonth)
The second month's data has changed.
UserMetricsOutput::UserMetrics::readyForDataChange
void readyForDataChange()
Inform the UserMetrics that you are ready for data change.
UserMetricsOutput
The user metrics output library namespace.
Definition: ColorTheme.h:29
UserMetricsOutput::UserMetrics::labelChanged
void labelChanged(const QString &label)
The label has changed.
UserMetricsOutput::UserMetrics::secondColorChanged
void secondColorChanged(ColorTheme *color)
The second month's ColorTheme has changed.
UserMetricsOutput::UserMetrics::getInstance
static UserMetrics * getInstance()
Get a new instance of UserMetrics.
UserMetricsOutput::UserMetrics::readyForDataChangeSlot
virtual void readyForDataChangeSlot()=0
Synchronous version of readyForDataChange.
UserMetricsOutput::UserMetrics::dataChanged
void dataChanged()
Insert documentation here.
UserMetricsOutput::UserMetrics::firstColorChanged
void firstColorChanged(ColorTheme *color)
The first month's ColorTheme has changed.
UserMetricsOutput::UserMetrics::username
virtual QString username() const =0
The current username selected.
UserMetricsOutput::UserMetrics::UserMetrics
UserMetrics(QObject *parent=0)
Unusable constructor - this class is pure-virtual.
UserMetricsOutput::UserMetrics
Presentation API for user metrics.
Definition: UserMetrics.h:56
ColorTheme.h
UserMetricsOutput::UserMetrics::dataDisappeared
void dataDisappeared()
The empty data has now been loaded.
UserMetricsOutput::UserMetrics::nextDataSource
void nextDataSource()
Request the current user's next data source.
UserMetricsOutput::UserMetrics::firstMonthChanged
void firstMonthChanged(QAbstractItemModel *firstMonth)
The first month's data has changed.
UserMetricsOutput::UserMetrics::nextDataSourceSlot
virtual void nextDataSourceSlot()=0
Synchronous version of nextDataSource.
UserMetricsOutput::UserMetrics::~UserMetrics
virtual ~UserMetrics()
Destructor.
UserMetricsOutput::UserMetrics::usernameChanged
void usernameChanged(const QString &username)
The username has changed.
UserMetricsOutput::UserMetrics::currentDay
virtual int currentDay() const =0
The current day of the calendar month.