diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2013-05-04 01:24:41 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2013-05-04 01:24:41 +0200 |
commit | 8af1436e92c1a853b74bacc9ac0adf012fdbc4ca (patch) | |
tree | 55273b39332a99abd213b76d78d37bfb1c3447f7 | |
parent | 7897ec1596a4348cd926eff7c1d4f03616ed535c (diff) | |
download | sowatch-8af1436e92c1a853b74bacc9ac0adf012fdbc4ca.tar.gz sowatch-8af1436e92c1a853b74bacc9ac0adf012fdbc4ca.zip |
new calendar watchlet
-rw-r--r-- | libsowatch/declarativewatchlet.cpp | 1 | ||||
-rw-r--r-- | qmsgwatchlet/metawatch-digital.qml | 11 | ||||
-rw-r--r-- | qmsgwatchlet/qmsgwatchletplugin.cpp | 4 | ||||
-rw-r--r-- | qorgwatchlet/icon.png | bin | 258 -> 202 bytes | |||
-rw-r--r-- | qorgwatchlet/metawatch-digital.qml | 81 | ||||
-rw-r--r-- | qorgwatchlet/qorgwatchlet.cpp | 10 | ||||
-rw-r--r-- | qorgwatchlet/qorgwatchlet.h | 14 | ||||
-rw-r--r-- | qorgwatchlet/qorgwatchlet.pro | 8 | ||||
-rw-r--r-- | qorgwatchlet/qorgwatchletplugin.cpp | 33 | ||||
-rw-r--r-- | qorgwatchlet/qorgwatchletplugin.h | 12 | ||||
-rw-r--r-- | qtc_packaging/debian_fremantle/changelog | 7 | ||||
-rw-r--r-- | qtc_packaging/debian_harmattan/changelog | 7 | ||||
-rw-r--r-- | qtc_packaging/debian_harmattan/manifest.aegis | 2 | ||||
-rw-r--r-- | sowatch.pro | 4 |
14 files changed, 131 insertions, 63 deletions
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp index 1851e38..32ff8e8 100644 --- a/libsowatch/declarativewatchlet.cpp +++ b/libsowatch/declarativewatchlet.cpp @@ -31,6 +31,7 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id) _registered = true; } + // TODO: Share a single engine per watch server instead of this. _engine = new QDeclarativeEngine(this); #if !defined(QT_NO_DEBUG) QString qmlDir = QDir::current().absoluteFilePath(SOWATCH_QML_DIR); diff --git a/qmsgwatchlet/metawatch-digital.qml b/qmsgwatchlet/metawatch-digital.qml index e5e999f..89a5f00 100644 --- a/qmsgwatchlet/metawatch-digital.qml +++ b/qmsgwatchlet/metawatch-digital.qml @@ -20,6 +20,7 @@ MWPage { anchors.bottom: parent.bottom clip: true model: MessageModel { + id: model sortBy: MessageModel.Timestamp sortOrder: MessageModel.DescendingOrder filter: MessageIntersectionFilter { @@ -33,6 +34,16 @@ MWPage { comparator: MessageFilter.Equal value: MessageFilter.InboxFolder } + MessageFilter { + type: MessageFilter.Status + comparator: MessageFilter.Includes + value: MessageFilter.Incoming + } + MessageFilter { + type: MessageFilter.Status + comparator: MessageFilter.Excludes + value: MessageFilter.Removed + } } limit: 20 } diff --git a/qmsgwatchlet/qmsgwatchletplugin.cpp b/qmsgwatchlet/qmsgwatchletplugin.cpp index 2471d03..dfabd12 100644 --- a/qmsgwatchlet/qmsgwatchletplugin.cpp +++ b/qmsgwatchlet/qmsgwatchletplugin.cpp @@ -1,11 +1,15 @@ #include "qmsgwatchlet.h" #include "qmsgwatchletplugin.h" +#include <QtMessaging/QMessageManager> + using namespace sowatch; +QTM_USE_NAMESPACE QMsgWatchletPlugin::QMsgWatchletPlugin(QObject *parent) : QObject(parent) { + qRegisterMetaType<QMessageManager::NotificationFilterIdSet>("QMessageManager::NotificationFilterIdSet"); } QMsgWatchletPlugin::~QMsgWatchletPlugin() diff --git a/qorgwatchlet/icon.png b/qorgwatchlet/icon.png Binary files differindex 005d9ee..f006a4d 100644 --- a/qorgwatchlet/icon.png +++ b/qorgwatchlet/icon.png diff --git a/qorgwatchlet/metawatch-digital.qml b/qorgwatchlet/metawatch-digital.qml index e5e999f..e6e4758 100644 --- a/qorgwatchlet/metawatch-digital.qml +++ b/qorgwatchlet/metawatch-digital.qml @@ -1,5 +1,5 @@ import QtQuick 1.0 -import QtMobility.messaging 1.1 +import QtMobility.organizer 1.1 import com.javispedro.sowatch.metawatch 1.0 MWPage { @@ -8,7 +8,7 @@ MWPage { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - text: qsTr("Inbox") + text: qsTr("Calendar") icon.source: "icon.png" } @@ -19,48 +19,80 @@ MWPage { anchors.right: parent.right anchors.bottom: parent.bottom clip: true - model: MessageModel { - sortBy: MessageModel.Timestamp - sortOrder: MessageModel.DescendingOrder - filter: MessageIntersectionFilter { - MessageFilter { - type: MessageFilter.Type - comparator: MessageFilter.Equal - value: MessageFilter.Email - } - MessageFilter { - type: MessageFilter.StandardFolder - comparator: MessageFilter.Equal - value: MessageFilter.InboxFolder - } - } - limit: 20 + model: OrganizerModel { + id: model + manager: "qtorganizer:mkcal" } delegate: Rectangle { - id: msgDelegate + id: itemDelegate property bool selected: ListView.isCurrentItem width: parent.width height: childrenRect.height color: ListView.isCurrentItem ? "black" : "white" Column { width: parent.width + visible: typeof display !== "undefined" MWLabel { width: parent.width - text: sender + text: typeof item !== "undefined" ? _formatEventTime(item) : "" wrapMode: Text.WrapAtWordBoundaryOrAnywhere - color: msgDelegate.selected ? "white" : "black" - font.pointSize: 12 + color: itemDelegate.selected ? "white" : "black" + font.family: "MetaWatch Large caps 8pt" + font.pixelSize: 8 } MWLabel { width: parent.width - text: subject + text: typeof display !== "undefined" ? display : "" wrapMode: Text.WrapAtWordBoundaryOrAnywhere - color: msgDelegate.selected ? "white" : "black" + color: itemDelegate.selected ? "white" : "black" + font.pixelSize: 16 } } } } + function update() { + var now = new Date(); + var end = new Date(now.getFullYear(), now.getMonth() , now.getDate() + 7); + + model.startPeriod = now; + model.endPeriod = end; + model.update(); + } + + function _isSameDay(date1, date2) { + return date1.getYear() === date2.getYear() && + date1.getMonth() === date2.getMonth() && + date1.getDate() === date2.getDate(); + } + + function _daysTo(date1, date2) { + var ms_per_day = 24 * 3600 * 1000; + var ts1 = date1.getTime(); + var ts2 = date2.getTime(); + var diff = ts2 - ts1; + return Math.round(diff / ms_per_day); + } + + function _formatEventTime(item) { + var now = new Date(); + var itemStart = item.itemStartTime; + var itemEnd = item.itemEndTime; + if (_isSameDay(now, itemStart) && _isSameDay(now, itemEnd)) { + return Qt.formatTime(itemStart) + " - " + Qt.formatTime(itemEnd); + } else if (_isSameDay(itemStart, itemEnd)) { + if (_daysTo(now, itemStart) < 7) { + return Qt.formatDate(itemStart, "dddd") + "\n" + + Qt.formatTime(itemStart) + " - " + Qt.formatTime(itemEnd); + } + return Qt.formatDate(itemStart) + "\n" + + Qt.formatTime(itemStart) + " - " + Qt.formatTime(itemEnd); + } else { + return Qt.formatDateTime(itemStart) + " -\n" + + Qt.formatDateTime(itemEnd); + } + } + Connections { target: watch onButtonPressed: { @@ -75,6 +107,7 @@ MWPage { } onActiveChanged: { if (watch.active) { + update(); list.scrollTop(); } } diff --git a/qorgwatchlet/qorgwatchlet.cpp b/qorgwatchlet/qorgwatchlet.cpp index 7111c81..3d042fb 100644 --- a/qorgwatchlet/qorgwatchlet.cpp +++ b/qorgwatchlet/qorgwatchlet.cpp @@ -1,13 +1,11 @@ #include <QtCore/QDebug> -#include "qmsgwatchlet.h" +#include "qorgwatchlet.h" -QTM_USE_NAMESPACE using namespace sowatch; -QMsgWatchlet::QMsgWatchlet(WatchServer* server) : - DeclarativeWatchlet(server, "com.javispedro.sowatch.qmsg"), - _qms(new QMessageService(this)) +QOrgWatchlet::QOrgWatchlet(WatchServer* server) : + DeclarativeWatchlet(server, "com.javispedro.sowatch.qorg") { - setSource(QUrl(SOWATCH_QML_DIR "/qmsgwatchlet/" + server->watch()->model() + ".qml")); + setSource(QUrl(SOWATCH_QML_DIR "/qorgwatchlet/" + server->watch()->model() + ".qml")); } diff --git a/qorgwatchlet/qorgwatchlet.h b/qorgwatchlet/qorgwatchlet.h index 6fa331c..1c0f28e 100644 --- a/qorgwatchlet/qorgwatchlet.h +++ b/qorgwatchlet/qorgwatchlet.h @@ -1,22 +1,18 @@ -#ifndef QMSGWATCHLET_H -#define QMSGWATCHLET_H +#ifndef QORGWATCHLET_H +#define QORGWATCHLET_H -#include <QtMessaging/QMessageService> #include <sowatch.h> namespace sowatch { -class QMsgWatchlet : public DeclarativeWatchlet +class QOrgWatchlet : public DeclarativeWatchlet { Q_OBJECT public: - explicit QMsgWatchlet(WatchServer* server); - -private: - QtMobility::QMessageService *_qms; + explicit QOrgWatchlet(WatchServer* server); }; } -#endif // QMSGWATCHLET_H +#endif // QORGWATCHLET_H diff --git a/qorgwatchlet/qorgwatchlet.pro b/qorgwatchlet/qorgwatchlet.pro index 9e18e42..4affbee 100644 --- a/qorgwatchlet/qorgwatchlet.pro +++ b/qorgwatchlet/qorgwatchlet.pro @@ -1,12 +1,12 @@ -TARGET = qmsgwatchlet +TARGET = qorgwatchlet TEMPLATE = lib CONFIG += plugin CONFIG += mobility -MOBILITY += messaging +MOBILITY += organizer -SOURCES += qmsgwatchletplugin.cpp qmsgwatchlet.cpp +SOURCES += qorgwatchletplugin.cpp qorgwatchlet.cpp -HEADERS += qmsgwatchletplugin.h qmsgwatchlet.h +HEADERS += qorgwatchletplugin.h qorgwatchlet.h qml_files.files = metawatch-digital.qml icon.png diff --git a/qorgwatchlet/qorgwatchletplugin.cpp b/qorgwatchlet/qorgwatchletplugin.cpp index 2471d03..4b7bb47 100644 --- a/qorgwatchlet/qorgwatchletplugin.cpp +++ b/qorgwatchlet/qorgwatchletplugin.cpp @@ -1,38 +1,43 @@ -#include "qmsgwatchlet.h" -#include "qmsgwatchletplugin.h" +#include "qorgwatchlet.h" +#include "qorgwatchletplugin.h" + +#include <QtOrganizer/QOrganizerAbstractRequest> using namespace sowatch; +QTM_USE_NAMESPACE -QMsgWatchletPlugin::QMsgWatchletPlugin(QObject *parent) : +QOrgWatchletPlugin::QOrgWatchletPlugin(QObject *parent) : QObject(parent) { + // Workaround a weird QtOrganizer issue + qRegisterMetaType<QOrganizerAbstractRequest::State>("QOrganizerAbstractRequest::State"); } -QMsgWatchletPlugin::~QMsgWatchletPlugin() +QOrgWatchletPlugin::~QOrgWatchletPlugin() { } -QStringList QMsgWatchletPlugin::watchlets() +QStringList QOrgWatchletPlugin::watchlets() { QStringList l; - l << "com.javispedro.sowatch.qmsg"; + l << "com.javispedro.sowatch.qorg"; return l; } -WatchletPluginInterface::WatchletInfo QMsgWatchletPlugin::describeWatchlet(const QString &id) +WatchletPluginInterface::WatchletInfo QOrgWatchletPlugin::describeWatchlet(const QString &id) { WatchletInfo info; - if (id != "com.javispedro.sowatch.qmsg") return info; - info.name = "Inbox"; - info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmsgwatchlet/icon.png"); + if (id != "com.javispedro.sowatch.qorg") return info; + info.name = "Calendar"; + info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qorgwatchlet/icon.png"); return info; } -Watchlet* QMsgWatchletPlugin::getWatchlet(const QString &id, ConfigKey *config, WatchServer *server) +Watchlet* QOrgWatchletPlugin::getWatchlet(const QString &id, ConfigKey *config, WatchServer *server) { Q_UNUSED(config); - if (id != "com.javispedro.sowatch.qmsg") return 0; - return new QMsgWatchlet(server); + if (id != "com.javispedro.sowatch.qorg") return 0; + return new QOrgWatchlet(server); } -Q_EXPORT_PLUGIN2(qmsgwatchlet, QMsgWatchletPlugin) +Q_EXPORT_PLUGIN2(qmsgwatchlet, QOrgWatchletPlugin) diff --git a/qorgwatchlet/qorgwatchletplugin.h b/qorgwatchlet/qorgwatchletplugin.h index 01cb83e..dddbce2 100644 --- a/qorgwatchlet/qorgwatchletplugin.h +++ b/qorgwatchlet/qorgwatchletplugin.h @@ -1,19 +1,19 @@ -#ifndef QMSGWATCHLETPLUGIN_H -#define QMSGWATCHLETPLUGIN_H +#ifndef QORGWATCHLETPLUGIN_H +#define QORGWATCHLETPLUGIN_H #include <sowatch.h> namespace sowatch { -class QMsgWatchletPlugin : public QObject, public WatchletPluginInterface +class QOrgWatchletPlugin : public QObject, public WatchletPluginInterface { Q_OBJECT Q_INTERFACES(sowatch::WatchletPluginInterface) public: - explicit QMsgWatchletPlugin(QObject *parent = 0); - ~QMsgWatchletPlugin(); + explicit QOrgWatchletPlugin(QObject *parent = 0); + ~QOrgWatchletPlugin(); QStringList watchlets(); WatchletInfo describeWatchlet(const QString &id); @@ -22,4 +22,4 @@ public: } -#endif // QMSGWATCHLETPLUGIN_H +#endif // QORWATCHLETPLUGIN_H diff --git a/qtc_packaging/debian_fremantle/changelog b/qtc_packaging/debian_fremantle/changelog index d9f3b3f..5c97e59 100644 --- a/qtc_packaging/debian_fremantle/changelog +++ b/qtc_packaging/debian_fremantle/changelog @@ -1,3 +1,10 @@ +sowatch (0.4.6) unstable; urgency=low + + * New status bar for metawatch watchlets + * New Calendar watchlet + + -- Javier S. Pedro <maemo@javispedro.com> Sat, 04 May 2013 01:22:40 +0200 + sowatch (0.4.5) unstable; urgency=low * Change button assignments for media player watchlet. diff --git a/qtc_packaging/debian_harmattan/changelog b/qtc_packaging/debian_harmattan/changelog index d9f3b3f..5c97e59 100644 --- a/qtc_packaging/debian_harmattan/changelog +++ b/qtc_packaging/debian_harmattan/changelog @@ -1,3 +1,10 @@ +sowatch (0.4.6) unstable; urgency=low + + * New status bar for metawatch watchlets + * New Calendar watchlet + + -- Javier S. Pedro <maemo@javispedro.com> Sat, 04 May 2013 01:22:40 +0200 + sowatch (0.4.5) unstable; urgency=low * Change button assignments for media player watchlet. diff --git a/qtc_packaging/debian_harmattan/manifest.aegis b/qtc_packaging/debian_harmattan/manifest.aegis index 26754f3..5507e46 100644 --- a/qtc_packaging/debian_harmattan/manifest.aegis +++ b/qtc_packaging/debian_harmattan/manifest.aegis @@ -5,6 +5,8 @@ <credential name="GID::users" /> <!-- Request a few additional tokens for watchlets to use. --> + <credential name="GRP::calendar" /> + <credential name="GRP::metadata-users" /> <credential name="TrackerReadAccess" /> <credential name="Location" /> diff --git a/sowatch.pro b/sowatch.pro index 4c08cff..5a1e868 100644 --- a/sowatch.pro +++ b/sowatch.pro @@ -25,6 +25,10 @@ sysinfowatchlet.depends = libsowatch SUBDIRS += qmsgwatchlet qmsgwatchlet.depends = libsowatch +# This shows some calendar appointments using QtMobility +SUBDIRS += qorgwatchlet +qorgwatchlet.depends = libsowatch + # This shows a map around the current position using QtMobility Mapping features SUBDIRS += qmapwatchlet qmapwatchlet.depends = libsowatch |