Commit 727209df authored by Volker Krause's avatar Volker Krause

Port FreeBusyGanttProxyModel away from KDateTime::Spec

parent 5e08d290
......@@ -44,24 +44,24 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
QVERIFY(ganttModel->rowCount() == 0);
const KDateTime dt1(QDate(2010, 8, 24), QTime(7, 0, 0), KDateTime::UTC);
const KDateTime dt2(QDate(2010, 8, 24), QTime(16, 0, 0), KDateTime::UTC);
const QDateTime dt1(QDate(2010, 8, 24), QTime(7, 0, 0), Qt::UTC);
const QDateTime dt2(QDate(2010, 8, 24), QTime(16, 0, 0), Qt::UTC);
KCalCore::Attendee::Ptr a1(new KCalCore::Attendee(QStringLiteral("fred"), QStringLiteral("fred@example.com")));
KCalCore::FreeBusy::Ptr fb1(new KCalCore::FreeBusy());
fb1->addPeriod(dt1, KCalCore::Duration(60 * 60));
fb1->addPeriod(dt2, KCalCore::Duration(60 * 60));
fb1->addPeriod(KDateTime(dt1), KCalCore::Duration(60 * 60));
fb1->addPeriod(KDateTime(dt2), KCalCore::Duration(60 * 60));
CalendarSupport::FreeBusyItem::Ptr item1(new CalendarSupport::FreeBusyItem(a1, nullptr));
item1->setFreeBusy(fb1);
const KDateTime dt3(QDate(2010, 8, 25), QTime(7, 0, 0), KDateTime::UTC);
const KDateTime dt4(QDate(2010, 8, 25), QTime(16, 0, 0), KDateTime::UTC);
const QDateTime dt3(QDate(2010, 8, 25), QTime(7, 0, 0), Qt::UTC);
const QDateTime dt4(QDate(2010, 8, 25), QTime(16, 0, 0), Qt::UTC);
KCalCore::Attendee::Ptr a2(new KCalCore::Attendee(QStringLiteral("joe"), QStringLiteral("joe@example.com")));
KCalCore::FreeBusy::Ptr fb2(new KCalCore::FreeBusy());
fb2->addPeriod(dt3, KCalCore::Duration(60 * 60));
fb2->addPeriod(dt4, KCalCore::Duration(60 * 60));
fb2->addPeriod(KDateTime(dt3), KCalCore::Duration(60 * 60));
fb2->addPeriod(KDateTime(dt4), KCalCore::Duration(60 * 60));
CalendarSupport::FreeBusyItem::Ptr item2(new CalendarSupport::FreeBusyItem(a2, nullptr));
item2->setFreeBusy(fb2);
......@@ -92,9 +92,9 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
QVERIFY(child0_1.isValid());
QCOMPARE(child0_0.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child0_0.data(KGantt::StartTimeRole).value<QDateTime>(), dt1.dateTime());
QCOMPARE(child0_0.data(KGantt::StartTimeRole).value<QDateTime>(), dt1);
QCOMPARE(child0_1.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child0_1.data(KGantt::StartTimeRole).value<QDateTime>(), dt2.dateTime());
QCOMPARE(child0_1.data(KGantt::StartTimeRole).value<QDateTime>(), dt2);
QModelIndex child1_0 = ganttModel->index(0, 0, parent1);
QModelIndex child1_1 = ganttModel->index(1, 0, parent1);
......@@ -102,7 +102,7 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
QVERIFY(child1_1.isValid());
QCOMPARE(child1_0.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child1_0.data(KGantt::StartTimeRole).value<QDateTime>(), dt3.dateTime());
QCOMPARE(child1_0.data(KGantt::StartTimeRole).value<QDateTime>(), dt3);
QCOMPARE(child1_1.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child1_1.data(KGantt::StartTimeRole).value<QDateTime>(), dt4.dateTime());
QCOMPARE(child1_1.data(KGantt::StartTimeRole).value<QDateTime>(), dt4);
}
......@@ -25,7 +25,6 @@
#include <KCalCore/FreeBusyPeriod>
#include <KLocalizedString>
#include <KSystemTimeZones>
#include <QLocale>
......@@ -56,7 +55,6 @@ QVariant FreeBusyGanttProxyModel::data(const QModelIndex &index, int role) const
}
// if the index is valid, then it corrsponds to a free busy period
KDateTime::Spec timeSpec = KSystemTimeZones::local();
KCalCore::FreeBusyPeriod period
= sourceModel()->data(source_index, CalendarSupport::FreeBusyItemModel::FreeBusyPeriodRole).
value<KCalCore::FreeBusyPeriod>();
......@@ -65,13 +63,13 @@ QVariant FreeBusyGanttProxyModel::data(const QModelIndex &index, int role) const
case KGantt::ItemTypeRole:
return KGantt::TypeTask;
case KGantt::StartTimeRole:
return period.start().toTimeSpec(timeSpec).dateTime();
return period.start().toLocalZone().dateTime();
case KGantt::EndTimeRole:
return period.end().toTimeSpec(timeSpec).dateTime();
return period.end().toLocalZone().dateTime();
case Qt::BackgroundRole:
return QColor(Qt::red);
case Qt::ToolTipRole:
return tooltipify(period, timeSpec);
return tooltipify(period);
case Qt::DisplayRole:
return sourceModel()->data(source_index.parent(), Qt::DisplayRole);
default:
......@@ -79,8 +77,7 @@ QVariant FreeBusyGanttProxyModel::data(const QModelIndex &index, int role) const
}
}
QString FreeBusyGanttProxyModel::tooltipify(const KCalCore::FreeBusyPeriod &period,
const KDateTime::Spec &timeSpec) const
QString FreeBusyGanttProxyModel::tooltipify(const KCalCore::FreeBusyPeriod &period) const
{
QString toolTip = QStringLiteral("<qt>");
toolTip += QStringLiteral("<b>") + i18nc("@info:tooltip", "Free/Busy Period") + QStringLiteral(
......@@ -102,15 +99,13 @@ QString FreeBusyGanttProxyModel::tooltipify(const KCalCore::FreeBusyPeriod &peri
+ i18nc("@info:tooltip period start time",
"Start:") + QStringLiteral("</i>") + QStringLiteral(
"&nbsp;");
toolTip += QLocale::system().toString(period.start().toTimeSpec(
timeSpec).dateTime(), QLocale::ShortFormat);
toolTip += QLocale().toString(period.start().toLocalZone().dateTime(), QLocale::ShortFormat);
toolTip += QStringLiteral("<br>");
toolTip += QStringLiteral("<i>")
+ i18nc("@info:tooltip period end time",
"End:") + QStringLiteral("</i>") + QStringLiteral(
"&nbsp;");
toolTip += QLocale::system().toString(period.end().toTimeSpec(
timeSpec).dateTime(), QLocale::ShortFormat);
toolTip += QLocale().toString(period.end().toLocalZone().dateTime(), QLocale::ShortFormat);
toolTip += QStringLiteral("<br>");
toolTip += QStringLiteral("</qt>");
return toolTip;
......
......@@ -23,8 +23,6 @@
#include "incidenceeditor_export.h"
#include <KDateTime>
#include <QSortFilterProxyModel>
namespace KCalCore {
......@@ -48,8 +46,7 @@ class INCIDENCEEDITOR_EXPORT FreeBusyGanttProxyModel : public QSortFilterProxyMo
public:
explicit FreeBusyGanttProxyModel(QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QString tooltipify(const KCalCore::FreeBusyPeriod &period,
const KDateTime::Spec &timeSpec) const;
QString tooltipify(const KCalCore::FreeBusyPeriod &period) const;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment