ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00151
[Branch ~agateau/plasma-indicatordisplay/trunk] Rev 72: Handle "time" property as a QDateTime now
------------------------------------------------------------
revno: 72
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: plasma-indicatordisplay
timestamp: Fri 2009-09-11 12:03:01 +0200
message:
Handle "time" property as a QDateTime now
modified:
CMakeLists.txt
src/delegate.cpp
src/listenermodel.cpp
src/listenermodel.h
tests/listenermodeltest.cpp
--
lp:plasma-indicatordisplay
https://code.launchpad.net/~agateau/plasma-indicatordisplay/trunk
Your team ayatana-commits is subscribed to branch lp:plasma-indicatordisplay.
To unsubscribe from this branch go to https://code.launchpad.net/~agateau/plasma-indicatordisplay/trunk/+edit-subscription.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2009-09-10 14:48:32 +0000
+++ CMakeLists.txt 2009-09-11 10:03:01 +0000
@@ -15,7 +15,7 @@
find_package(PkgConfig REQUIRED)
# Find libindicate-qt
-pkg_check_modules(INDICATEQT REQUIRED indicate-qt)
+pkg_check_modules(INDICATEQT REQUIRED indicate-qt>=0.2.0)
include_directories(
${KDE4_INCLUDES}
=== modified file 'src/delegate.cpp'
--- src/delegate.cpp 2009-09-11 09:46:30 +0000
+++ src/delegate.cpp 2009-09-11 10:03:01 +0000
@@ -55,9 +55,10 @@
{
if (index.parent().isValid()) {
// Indicator
- QTime time = index.data(ListenerModel::IndicatorTimeRole).toTime();
- if (time.isValid()) {
- return KGlobal::locale()->formatTime(time);
+ QDateTime dateTime = index.data(ListenerModel::IndicatorDateTimeRole).toDateTime();
+ if (dateTime.isValid()) {
+ kDebug() << "FIXME: Handle date part";
+ return KGlobal::locale()->formatTime(dateTime.time());
}
}
return QString();
=== modified file 'src/listenermodel.cpp'
--- src/listenermodel.cpp 2009-08-05 17:35:55 +0000
+++ src/listenermodel.cpp 2009-09-11 10:03:01 +0000
@@ -307,8 +307,8 @@
QPixmap pix = QPixmap::fromImage(image);
item->setData(KIcon(pix), Qt::DecorationRole);
} else if (key == "time") {
- QTime time = QIndicate::Listener::timeFromValue(value);
- item->setData(QVariant(time), IndicatorTimeRole);
+ QDateTime dateTime = QIndicate::Listener::dateTimeFromValue(value);
+ item->setData(QVariant(dateTime), IndicatorDateTimeRole);
} else {
kWarning() << "Unhandled key" << key;
}
=== modified file 'src/listenermodel.h'
--- src/listenermodel.h 2009-07-31 08:03:59 +0000
+++ src/listenermodel.h 2009-09-11 10:03:01 +0000
@@ -29,7 +29,7 @@
{
ServerTypeRole = 0x0F3B4320,
IndicatorCountRole = 0x2CFC6823,
- IndicatorTimeRole = 0x215B03CC
+ IndicatorDateTimeRole = 0x215B03CC
};
/**
=== modified file 'tests/listenermodeltest.cpp'
--- tests/listenermodeltest.cpp 2009-08-06 20:55:08 +0000
+++ tests/listenermodeltest.cpp 2009-09-11 10:03:01 +0000
@@ -210,24 +210,26 @@
QCOMPARE(indicatorProxy, expectedIndicator);
}
-static QTime indicatorTime(const QModelIndex& index)
+static QDateTime indicatorDateTime(const QModelIndex& index)
{
- QVariant value = index.data(ListenerModel::IndicatorTimeRole);
- if (!value.canConvert(QVariant::Time)) {
- return QTime();
+ QVariant value = index.data(ListenerModel::IndicatorDateTimeRole);
+ if (!value.canConvert(QVariant::DateTime)) {
+ return QDateTime();
}
- return value.toTime();
+ return value.toDateTime();
}
void ListenerModelTest::testUpdateIndicator()
{
+ QDate day = QDate(2006, 4, 1);
+
// Show server
mServer->show();
// Show an indicator
QIndicate::IndicatorMessage indicator;
indicator.setProperty("sender", "John Doe");
- indicator.setProperty("time", QTime(1, 23, 45));
+ indicator.setProperty("time", QDateTime(day, QTime(1, 23, 45)));
indicator.show();
QTest::qWait(500);
@@ -236,14 +238,14 @@
QModelIndex indicatorIndex = mModel->index(0, 0, serverIndex);
QCOMPARE(indicatorIndex.data().toString(), QString("John Doe"));
- QCOMPARE(indicatorTime(indicatorIndex), QTime(1, 23, 45));
+ QCOMPARE(indicatorDateTime(indicatorIndex), QDateTime(day, QTime(1, 23, 45)));
indicator.setProperty("sender", "Bruce Wayne");
- indicator.setProperty("time", QTime(12, 34, 56));
+ indicator.setProperty("time", QDateTime(day, QTime(12, 34, 56)));
QTest::qWait(500);
QCOMPARE(indicatorIndex.data().toString(), QString("Bruce Wayne"));
- QCOMPARE(indicatorTime(indicatorIndex), QTime(12, 34, 56));
+ QCOMPARE(indicatorDateTime(indicatorIndex), QDateTime(day, QTime(12, 34, 56)));
}
static int indicatorCount(const QModelIndex& index)