summaryrefslogtreecommitdiff
path: root/qorgwatchlet
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-04 01:24:41 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-04 01:24:41 +0200
commit8af1436e92c1a853b74bacc9ac0adf012fdbc4ca (patch)
tree55273b39332a99abd213b76d78d37bfb1c3447f7 /qorgwatchlet
parent7897ec1596a4348cd926eff7c1d4f03616ed535c (diff)
downloadsowatch-8af1436e92c1a853b74bacc9ac0adf012fdbc4ca.tar.gz
sowatch-8af1436e92c1a853b74bacc9ac0adf012fdbc4ca.zip
new calendar watchlet
Diffstat (limited to 'qorgwatchlet')
-rw-r--r--qorgwatchlet/icon.pngbin258 -> 202 bytes
-rw-r--r--qorgwatchlet/metawatch-digital.qml81
-rw-r--r--qorgwatchlet/qorgwatchlet.cpp10
-rw-r--r--qorgwatchlet/qorgwatchlet.h14
-rw-r--r--qorgwatchlet/qorgwatchlet.pro8
-rw-r--r--qorgwatchlet/qorgwatchletplugin.cpp33
-rw-r--r--qorgwatchlet/qorgwatchletplugin.h12
7 files changed, 95 insertions, 63 deletions
diff --git a/qorgwatchlet/icon.png b/qorgwatchlet/icon.png
index 005d9ee..f006a4d 100644
--- a/qorgwatchlet/icon.png
+++ b/qorgwatchlet/icon.png
Binary files differ
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