summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-14 01:13:41 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-14 01:13:41 +0200
commit80c58c124caf17f670d8efc120f5ae4bfd9aa09f (patch)
treec6d036f06437e54f80afd65e1a700a018cab994b /libsowatch
parentc3392e5d539e87f4720b3d107aaefffdc9579f4d (diff)
downloadsowatch-80c58c124caf17f670d8efc120f5ae4bfd9aa09f.tar.gz
sowatch-80c58c124caf17f670d8efc120f5ae4bfd9aa09f.zip
added liveview watchlet menu (API break)
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/watchletplugininterface.h9
-rw-r--r--libsowatch/watchletsmodel.cpp15
-rw-r--r--libsowatch/watchletsmodel.h11
-rw-r--r--libsowatch/watchserver.cpp1
4 files changed, 29 insertions, 7 deletions
diff --git a/libsowatch/watchletplugininterface.h b/libsowatch/watchletplugininterface.h
index ed90467..4c135b3 100644
--- a/libsowatch/watchletplugininterface.h
+++ b/libsowatch/watchletplugininterface.h
@@ -22,17 +22,18 @@ public:
struct WatchletInfo {
QString name;
QUrl icon;
- bool hidden;
+ QUrl phoneIcon;
+ bool visible;
QUrl configQmlUrl;
- inline WatchletInfo() :
- hidden(false)
+ inline WatchletInfo() : visible(false)
{
+
}
};
virtual QStringList watchlets() = 0;
- virtual WatchletInfo describeWatchlet(const QString& id) = 0;
+ virtual WatchletInfo describeWatchlet(const QString& id, const QString& watchModel) = 0;
virtual Watchlet* getWatchlet(const QString& id, ConfigKey *settings, Watch *watch) = 0;
};
diff --git a/libsowatch/watchletsmodel.cpp b/libsowatch/watchletsmodel.cpp
index 9e06928..5989872 100644
--- a/libsowatch/watchletsmodel.cpp
+++ b/libsowatch/watchletsmodel.cpp
@@ -11,10 +11,21 @@ WatchletsModel::WatchletsModel(QObject *parent) :
{
QHash<int, QByteArray> roles = roleNames();
roles[TitleRole] = QByteArray("title");
+ roles[IconRole] = QByteArray("icon");
roles[ObjectRole] = QByteArray("object");
setRoleNames(roles);
}
+QString WatchletsModel::watchModel() const
+{
+ return _watchModel;
+}
+
+void WatchletsModel::setWatchModel(const QString &s)
+{
+ _watchModel = s;
+}
+
int WatchletsModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : _list.count();
@@ -35,6 +46,8 @@ QVariant WatchletsModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole:
return QVariant::fromValue(info.name);
+ case IconRole:
+ return QVariant::fromValue(info.icon);
case ObjectRole:
return QVariant::fromValue(const_cast<sowatch::Watchlet*>(watchlet));
}
@@ -109,7 +122,7 @@ WatchletsModel::WatchletInfo WatchletsModel::getInfoForWatchlet(const Watchlet *
QString id = w->id();
WatchletPluginInterface *plugin = Registry::registry()->getWatchletPlugin(id);
if (plugin) {
- return plugin->describeWatchlet(id);
+ return plugin->describeWatchlet(id, _watchModel);
} else {
return WatchletInfo();
}
diff --git a/libsowatch/watchletsmodel.h b/libsowatch/watchletsmodel.h
index cdb6be4..3bbabf9 100644
--- a/libsowatch/watchletsmodel.h
+++ b/libsowatch/watchletsmodel.h
@@ -12,15 +12,20 @@ namespace sowatch
class WatchletsModel : public QAbstractListModel
{
Q_OBJECT
+ Q_PROPERTY(QString watchModel READ watchModel WRITE setWatchModel NOTIFY watchModelChanged)
public:
explicit WatchletsModel(QObject *parent = 0);
enum DataRoles {
ObjectRole = Qt::UserRole,
- TitleRole = Qt::DisplayRole
+ TitleRole = Qt::DisplayRole,
+ IconRole = Qt::DecorationRole
};
+ QString watchModel() const;
+ void setWatchModel(const QString& s);
+
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
@@ -35,14 +40,16 @@ public:
void remove(int position);
signals:
+ void watchModelChanged();
void modelChanged();
protected:
typedef WatchletPluginInterface::WatchletInfo WatchletInfo;
- static WatchletInfo getInfoForWatchlet(const Watchlet *w);
+ WatchletInfo getInfoForWatchlet(const Watchlet *w);
private:
+ QString _watchModel;
QList<Watchlet*> _list;
QList<WatchletInfo> _info;
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index eaea040..da93730 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -30,6 +30,7 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) :
_syncTimeTimer->setSingleShot(true);
_syncTimeTimer->setInterval(24 * 3600 * 1000); // Once a day
+ _watchlets->setWatchModel(_watch->model());
_watch->setWatchletsModel(_watchlets);
}