Commit a4350106 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Fix duration strings



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@gmail.com>
parent 3bfb7776
Pipeline #185729 passed with stage
in 3 minutes and 18 seconds
......@@ -208,7 +208,7 @@ QVariant IncidenceOccurrenceModel::data(const QModelIndex &idx, int role) const
}
auto incidence = m_incidences.at(idx.row());
auto icalIncidence = incidence.incidence;
const auto duration = icalIncidence->duration();
const KCalendarCore::Duration duration(incidence.start, incidence.end);
switch (role) {
case Summary:
......@@ -226,9 +226,9 @@ QVariant IncidenceOccurrenceModel::data(const QModelIndex &idx, int role) const
case DurationString: {
if (duration.asSeconds() == 0) {
return QString();
} else {
return m_format.formatSpelloutDuration(duration.asSeconds() * 1000);
}
return m_format.formatSpelloutDuration(duration.asSeconds() * 1000);
}
case Recurs:
return icalIncidence->recurs();
......
......@@ -121,11 +121,15 @@ QVariant TodoSortFilterProxyModel::data(const QModelIndex &index, int role) cons
} else if (role == Roles::CollectionIdRole) {
return collectionId;
} else if (role == DurationStringRole) {
KFormat format;
if (todoPtr->allDay()) {
return format.formatSpelloutDuration(24 * 60 * 60 * 1000); // format milliseconds in 1 day
const auto duration = KCalendarCore::Duration(todoPtr->dtStart(), todoPtr->dtDue());
if (todoPtr->allDay() && !todoPtr->dtStart().isValid()) {
return m_format.formatSpelloutDuration(24 * 60 * 60 * 1000); // format milliseconds in 1 day
} else if (!todoPtr->dtStart().isValid() || duration.asSeconds() == 0) {
return QString();
}
return format.formatSpelloutDuration(todoPtr->duration().asSeconds() * 1000);
return m_format.formatSpelloutDuration(duration.asSeconds() * 1000);
} else if (role == Roles::RecursRole) {
return todoPtr->recurs();
} else if (role == Roles::IsOverdueRole) {
......
......@@ -22,6 +22,7 @@
#endif
#include <EventViews/TodoModel>
#include <KConfigWatcher>
#include <KFormat>
#include <KSharedConfig>
#include <QSortFilterProxyModel>
#include <QTimer>
......@@ -157,4 +158,5 @@ private:
int m_sortColumn = DueDateColumn;
bool m_sortAscending = false;
bool m_showCompletedSubtodosInIncomplete = true;
KFormat m_format;
};
Supports Markdown
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