summaryrefslogtreecommitdiff
path: root/rockwork/appstoreclient.h
diff options
context:
space:
mode:
Diffstat (limited to 'rockwork/appstoreclient.h')
-rw-r--r--rockwork/appstoreclient.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/rockwork/appstoreclient.h b/rockwork/appstoreclient.h
new file mode 100644
index 0000000..5a31d60
--- /dev/null
+++ b/rockwork/appstoreclient.h
@@ -0,0 +1,62 @@
+#ifndef APPSTORECLIENT_H
+#define APPSTORECLIENT_H
+
+#include <QObject>
+
+class QNetworkAccessManager;
+class ApplicationsModel;
+class AppItem;
+
+class AppStoreClient : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(Type)
+ Q_PROPERTY(ApplicationsModel* model READ model CONSTANT)
+ Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
+ Q_PROPERTY(QString hardwarePlatform READ hardwarePlatform WRITE setHardwarePlatform NOTIFY hardwarePlatformChanged)
+ Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
+
+public:
+ enum Type {
+ TypeWatchapp,
+ TypeWatchface
+ };
+
+ explicit AppStoreClient(QObject *parent = 0);
+
+ ApplicationsModel *model() const;
+
+ int limit() const;
+ void setLimit(int limit);
+
+ QString hardwarePlatform() const;
+ void setHardwarePlatform(const QString &hardwarePlatform);
+
+ bool busy() const;
+
+signals:
+ void limitChanged();
+ void hardwarePlatformChanged();
+ void busyChanged();
+
+public slots:
+ void fetchHome(Type type);
+ void fetchLink(const QString &link);
+
+ void fetchAppDetails(const QString &appId);
+
+ void search(const QString &searchString, Type type);
+
+private:
+ AppItem *parseAppItem(const QVariantMap &map);
+ void setBusy(bool busy);
+
+private:
+ QNetworkAccessManager *m_nam;
+ ApplicationsModel *m_model;
+ int m_limit = 20;
+ QString m_hardwarePlatform;
+ bool m_busy = false;
+};
+
+#endif // APPSTORECLIENT_H