[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [zanshin] src: fix formatting of the due date
From: Matthias Kretz <kretz () kde ! org>
Date: 2012-02-03 15:30:28
Message-ID: 20120203153028.B6FEEA60BB () git ! kde ! org
[Download RAW message or body]
Git commit 10b40a62ccabdafbb4181e877b3cde258d10ca08 by Matthias Kretz.
Committed on 01/02/2012 at 18:09.
Pushed by mkretz into branch 'master'.
fix formatting of the due date
The delegate was using QLocale to convert a QDate into a QString. We'd
rather have KLocale do this and with a little more fancyness.
BUG: 287869
M +16 -0 src/actionlistdelegate.cpp
M +1 -0 src/actionlistdelegate.h
http://commits.kde.org/zanshin/10b40a62ccabdafbb4181e877b3cde258d10ca08
diff --git a/src/actionlistdelegate.cpp b/src/actionlistdelegate.cpp
index 9925a47..985ebbb 100644
--- a/src/actionlistdelegate.cpp
+++ b/src/actionlistdelegate.cpp
@@ -36,6 +36,8 @@
#include "globaldefs.h"
#include "kdescendantsproxymodel.h"
#include "kdateedit.h"
+#include <klocale.h>
+#include <kglobal.h>
#include <kmodelindexproxymapper.h>
#include "modelstack.h"
=
@@ -67,6 +69,20 @@ QSize ActionListDelegate::sizeHint(const QStyleOptionVie=
wItem &option,
return res;
}
=
+QString ActionListDelegate::displayText(const QVariant &value, const QLoca=
le &locale) const
+{
+ switch (value.userType()) {
+ case QVariant::Date:
+ return KGlobal::locale()->formatDate(value.toDate(), KLocale::Fanc=
yLongDate);
+ case QVariant::Time:
+ return KGlobal::locale()->formatLocaleTime(value.toTime(), KLocale=
::TimeWithoutSeconds);
+ case QVariant::DateTime:
+ return KGlobal::locale()->formatDateTime(value.toDateTime());
+ default:
+ return QStyledItemDelegate::displayText(value, locale);
+ }
+}
+
void ActionListDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
diff --git a/src/actionlistdelegate.h b/src/actionlistdelegate.h
index ec90de5..166fbdd 100644
--- a/src/actionlistdelegate.h
+++ b/src/actionlistdelegate.h
@@ -41,6 +41,7 @@ public:
virtual QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
=
+ virtual QString displayText(const QVariant &value, const QLocale &loca=
le) const;
virtual void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic