diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-08-10 16:06:14 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-08-10 16:06:14 +0200 |
commit | 39fa663cd08bd2b7d46ed170d49ac794c531c42e (patch) | |
tree | 92131388053eadbfca4b8917ab1e1f87ffe30fdd /sowatchui/watchesmodel.cpp | |
parent | b9082fda48bb026fc4e6148efeba9aabf608373a (diff) | |
download | sowatch-39fa663cd08bd2b7d46ed170d49ac794c531c42e.tar.gz sowatch-39fa663cd08bd2b7d46ed170d49ac794c531c42e.zip |
watchlet edit UI
Diffstat (limited to 'sowatchui/watchesmodel.cpp')
-rw-r--r-- | sowatchui/watchesmodel.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/sowatchui/watchesmodel.cpp b/sowatchui/watchesmodel.cpp index 302e484..f8afcd4 100644 --- a/sowatchui/watchesmodel.cpp +++ b/sowatchui/watchesmodel.cpp @@ -81,14 +81,6 @@ QVariant WatchesModel::data(const QModelIndex &index, int role) const return QVariant(); } -bool WatchesModel::removeRows(int row, int count, const QModelIndex &parent) -{ - Q_UNUSED(row); - Q_UNUSED(count); - Q_UNUSED(parent); - return false; // TODO -} - void WatchesModel::addFoundWatch(const QVariantMap &info) { QStringList existing = _config->dirs(); @@ -109,9 +101,8 @@ void WatchesModel::addFoundWatch(const QVariantMap &info) // Set some defaults Registry *registry = Registry::registry(); - foreach (const QString& providerId, registry->allNotificationProviders()) { - qDebug() << "Would add" << providerId; - } + newkey->set("providers", registry->allNotificationProviders()); + newkey->set("watchlets", registry->allWatchlets()); // Now add to the watches list QStringList active = _watches_list->value().toStringList(); @@ -120,6 +111,33 @@ void WatchesModel::addFoundWatch(const QVariantMap &info) // Now enable newkey->set("enable", true); + + delete newkey; +} + +void WatchesModel::removeWatch(const QString &id) +{ + QString name; + + int i = id.lastIndexOf('/'); + if (i != -1) { + // Hack: QML UI might pass /apps/sowatch/id instead of id alone + name = id.mid(i + 1); + } else { + name = id; + } + + ConfigKey *subkey = _config->getSubkey(name); + + qDebug() << "Deleting watch" << name; + + // Remove from watches list + QStringList active = _watches_list->value().toStringList(); + active.removeAll(name); + _watches_list->set(active); + + subkey->recursiveUnset(); + delete subkey; } void WatchesModel::reload() |