Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9bb9676b authored by Volker Krause's avatar Volker Krause

Port TimelineItem from KDateTime to QDateTime

parent ff3be446
......@@ -43,17 +43,16 @@ TimelineItem::TimelineItem(const Akonadi::ETMCalendar::Ptr &calendar, uint index
}
void TimelineItem::insertIncidence(const Akonadi::Item &aitem,
const KDateTime &_start, const KDateTime &_end)
const QDateTime &_start, const QDateTime &_end)
{
const Incidence::Ptr incidence = CalendarSupport::incidence(aitem);
KDateTime start(_start);
KDateTime end(_end);
QDateTime start(_start);
QDateTime end(_end);
if (!start.isValid()) {
start = incidence->dtStart().toTimeSpec(CalendarSupport::KCalPrefs::instance()->timeSpec());
start = incidence->dtStart().toLocalZone().dateTime();
}
if (!end.isValid()) {
end = incidence->dateTime(Incidence::RoleEnd).toTimeSpec(
CalendarSupport::KCalPrefs::instance()->timeSpec());
end = incidence->dateTime(Incidence::RoleEnd).toLocalZone().dateTime();
}
if (incidence->allDay()) {
end = end.addDays(1);
......@@ -62,17 +61,17 @@ void TimelineItem::insertIncidence(const Akonadi::Item &aitem,
typedef QList<QStandardItem *> ItemList;
ItemList list = mItemMap.value(aitem.id());
for (ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) {
if (KDateTime(static_cast<TimelineSubItem *>(*it)->startTime()) == start &&
KDateTime(static_cast<TimelineSubItem *>(*it)->endTime()) == end) {
if (static_cast<TimelineSubItem *>(*it)->startTime() == start &&
static_cast<TimelineSubItem *>(*it)->endTime() == end) {
return;
}
}
TimelineSubItem *item = new TimelineSubItem(mCalendar, aitem, this);
item->setStartTime(start.dateTime());
item->setStartTime(start);
item->setOriginalStart(start);
item->setEndTime(end.dateTime());
item->setEndTime(end);
item->setData(mColor, Qt::DecorationRole);
list = mModel->takeRow(mIndex);
......@@ -96,10 +95,10 @@ void TimelineItem::moveItems(const Akonadi::Item &incidence, int delta, int dura
ItemList list = mItemMap.value(incidence.id());
const ItemList::ConstIterator end(list.constEnd());
for (ItemList::ConstIterator it = list.constBegin(); it != end; ++it) {
QDateTime start = static_cast<TimelineSubItem *>(*it)->originalStart().dateTime();
QDateTime start = static_cast<TimelineSubItem *>(*it)->originalStart();
start = start.addSecs(delta);
static_cast<TimelineSubItem *>(*it)->setStartTime(start);
static_cast<TimelineSubItem *>(*it)->setOriginalStart(KDateTime(start));
static_cast<TimelineSubItem *>(*it)->setOriginalStart(start);
static_cast<TimelineSubItem *>(*it)->setEndTime(start.addSecs(duration));
}
}
......
......@@ -26,8 +26,7 @@
#include <Akonadi/Calendar/ETMCalendar>
#include <AkonadiCore/Item>
#include <KDateTime>
#include <QDateTime>
#include <QMap>
#include <QList>
#include <QStandardItemModel>
......@@ -45,8 +44,8 @@ public:
QObject *parent);
void insertIncidence(const Akonadi::Item &incidence,
const KDateTime &start = KDateTime(),
const KDateTime &end = KDateTime());
const QDateTime &start = QDateTime(),
const QDateTime &end = QDateTime());
void removeIncidence(const Akonadi::Item &incidence);
void moveItems(const Akonadi::Item &incidence, int delta, int duration);
......@@ -73,12 +72,12 @@ public:
return mIncidence;
}
KDateTime originalStart() const
QDateTime originalStart() const
{
return mStart;
}
void setOriginalStart(const KDateTime &dt)
void setOriginalStart(const QDateTime &dt)
{
mStart = dt;
}
......@@ -99,7 +98,7 @@ public:
private:
Akonadi::ETMCalendar::Ptr mCalendar;
Akonadi::Item mIncidence;
KDateTime mStart;
QDateTime mStart;
TimelineItem *mParent = nullptr;
bool mToolTipNeedsUpdate;
};
......
......@@ -131,8 +131,7 @@ void TimelineView::Private::insertIncidence(const Akonadi::Item &aitem, const QD
const Akonadi::Item akonadiItem = q->calendar()->item(occurIter.incidence());
const KDateTime startOfOccurrence = occurIter.occurrenceStartDate();
const KDateTime endOfOccurrence = occurIter.incidence()->endDateForStart(startOfOccurrence);
const KDateTime::Spec spec = CalendarSupport::KCalPrefs::instance()->timeSpec();
item->insertIncidence(akonadiItem, startOfOccurrence.toTimeSpec(spec), endOfOccurrence.toTimeSpec(spec));
item->insertIncidence(akonadiItem, startOfOccurrence.toLocalZone().dateTime(), endOfOccurrence.toLocalZone().dateTime());
}
} else {
if (incidence->dtStart().date() == day ||
......@@ -203,9 +202,9 @@ void TimelineView::Private::itemChanged(QStandardItem *item)
const Akonadi::Item i = tlit->incidence();
const Incidence::Ptr inc = CalendarSupport::incidence(i);
KDateTime newStart(tlit->startTime());
QDateTime newStart(tlit->startTime());
if (inc->allDay()) {
newStart = KDateTime(newStart.date());
newStart = QDateTime(newStart.date());
}
int delta = tlit->originalStart().secsTo(newStart);
......
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