summaryrefslogtreecommitdiff
path: root/libsowatch/notification.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-25 04:53:46 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-25 04:53:46 +0200
commitcf5d24b94d96b722c6d76c2225293a56a50d3c2b (patch)
treefece0c539fe4c40e1faae109f53c46ddc5b0d222 /libsowatch/notification.cpp
parent2b4e878938215ac743bdc36deace4c2a4cb0c7a2 (diff)
downloadsowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.tar.gz
sowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.zip
watchlets working!
Diffstat (limited to 'libsowatch/notification.cpp')
-rw-r--r--libsowatch/notification.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/libsowatch/notification.cpp b/libsowatch/notification.cpp
index b4c97b2..e321b58 100644
--- a/libsowatch/notification.cpp
+++ b/libsowatch/notification.cpp
@@ -11,6 +11,25 @@ Notification::~Notification()
{
}
+QString Notification::displayTime() const
+{
+ QDateTime dt = dateTime();
+ int secsDiff = dt.secsTo(QDateTime::currentDateTime());
+ if (secsDiff < 1) {
+ return "";
+ } else if (secsDiff < 60) {
+ return tr("%n second(s) ago", "", secsDiff);
+ } else if (secsDiff < 60*60) {
+ int n = secsDiff / 60;
+ return tr("%n minute(s) ago", "", n);
+ } else if (secsDiff < 60*60*24) {
+ int n = secsDiff / 3600;
+ return tr("%n hour(s) ago", "", n);
+ } else {
+ return dt.toString(Qt::SystemLocaleShortDate);
+ }
+}
+
QImage Notification::image() const
{
return QImage();