Commit 8642ac3c authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Eliminate ExtraTodoModel and incorporate needed parts into TodoSortFilterProxyModel

This should help eliminate some duplicate code and also eliminate bugs in the interaction between Proxy (TodoSortFilter) to Proxy (ExtraTodoModel) to the base TodoModel.

Handling of ETMCalendar pointers is also now consistent across calendar with Akonadi::ETMCalendar::Ptr
parent c5ba5a65
Pipeline #129117 passed with stage
in 6 minutes and 50 seconds
......@@ -37,7 +37,7 @@ signals:
void calendarLoaded();
private:
QScopedPointer<Akonadi::ETMCalendar> calendar;
Akonadi::ETMCalendar::Ptr calendar;
IncidenceOccurrenceModel model;
QAbstractItemModelTester modelTester = QAbstractItemModelTester(&model);
QTimer loadedCheckTimer;
......@@ -78,7 +78,7 @@ private slots:
QCOMPARE(model.start(), now.date());
model.setLength(7);
QCOMPARE(model.length(), 7);
model.setCalendar(calendar.data());
model.setCalendar(calendar);
QCOMPARE(model.calendar()->id(), calendar->id());
fetchFinished.wait(10000);
......
......@@ -21,8 +21,6 @@ set(kalendar_SRCS
models/commandbarfiltermodel.h
contactsmanager.cpp
contactsmanager.h
models/extratodomodel.cpp
models/extratodomodel.h
models/hourlyincidencemodel.cpp
models/hourlyincidencemodel.h
models/incidenceoccurrencemodel.cpp
......
......@@ -537,9 +537,9 @@ KCheckableProxyModel *CalendarManager::collectionSelectionProxyModel() const
return m_selectionProxyModel;
}
Akonadi::ETMCalendar *CalendarManager::calendar() const
Akonadi::ETMCalendar::Ptr CalendarManager::calendar() const
{
return m_calendar.get();
return m_calendar;
}
Akonadi::IncidenceChanger *CalendarManager::incidenceChanger() const
......
......@@ -40,7 +40,7 @@ class CalendarManager : public QObject
Q_PROPERTY(Akonadi::CollectionFilterProxyModel *selectableCalendars READ selectableCalendars CONSTANT)
Q_PROPERTY(Akonadi::CollectionFilterProxyModel *selectableEventCalendars READ selectableEventCalendars CONSTANT)
Q_PROPERTY(Akonadi::CollectionFilterProxyModel *selectableTodoCalendars READ selectableTodoCalendars CONSTANT)
Q_PROPERTY(Akonadi::ETMCalendar *calendar READ calendar CONSTANT)
Q_PROPERTY(Akonadi::ETMCalendar::Ptr calendar READ calendar CONSTANT)
Q_PROPERTY(Akonadi::IncidenceChanger *incidenceChanger READ incidenceChanger CONSTANT)
Q_PROPERTY(QVariantMap undoRedoData READ undoRedoData NOTIFY undoRedoDataChanged)
......@@ -59,7 +59,7 @@ public:
void refreshEnabledTodoCollections();
Q_INVOKABLE void save();
Akonadi::ETMCalendar *calendar() const;
Akonadi::ETMCalendar::Ptr calendar() const;
Akonadi::IncidenceChanger *incidenceChanger() const;
Akonadi::CollectionFilterProxyModel *allCalendars();
Akonadi::CollectionFilterProxyModel *selectableCalendars() const;
......@@ -126,3 +126,5 @@ private:
QVector<qint64> m_enabledTodoCollections;
KConfigWatcher::Ptr m_colorWatcher;
};
Q_DECLARE_METATYPE(Akonadi::ETMCalendar::Ptr);
......@@ -522,7 +522,7 @@ QSortFilterProxyModel *KalendarApplication::actionsModel()
return m_proxyModel;
}
void KalendarApplication::setCalendar(Akonadi::ETMCalendar *calendar)
void KalendarApplication::setCalendar(Akonadi::ETMCalendar::Ptr calendar)
{
m_calendar = calendar;
}
......
......@@ -36,7 +36,7 @@ public:
void setWindow(QWindow *window);
QSortFilterProxyModel *actionsModel();
void setCalendar(Akonadi::ETMCalendar *calendar);
void setCalendar(Akonadi::ETMCalendar::Ptr calendar);
Q_INVOKABLE void importCalendarFromUrl(const QUrl &url, bool merge, qint64 collectionId = -1);
QString importErrorMessage();
......@@ -91,6 +91,6 @@ private:
KalCommandBarModel *m_actionModel = nullptr;
QSortFilterProxyModel *m_proxyModel = nullptr;
KalendarConfig *m_config = nullptr;
Akonadi::ETMCalendar *m_calendar;
Akonadi::ETMCalendar::Ptr m_calendar;
QString m_importErrorMessage;
};
......@@ -140,7 +140,6 @@ int main(int argc, char *argv[])
qmlRegisterType<AttendeesModel>("org.kde.kalendar", 1, 0, "AttendeesModel");
qmlRegisterType<MultiDayIncidenceModel>("org.kde.kalendar", 1, 0, "MultiDayIncidenceModel");
qmlRegisterType<IncidenceOccurrenceModel>("org.kde.kalendar", 1, 0, "IncidenceOccurrenceModel");
qmlRegisterType<ExtraTodoModel>("org.kde.kalendar", 1, 0, "ExtraTodoModel");
qmlRegisterType<TodoSortFilterProxyModel>("org.kde.kalendar", 1, 0, "TodoSortFilterProxyModel");
qmlRegisterType<ItemTagsModel>("org.kde.kalendar", 1, 0, "ItemTagsModel");
qmlRegisterType<HourlyIncidenceModel>("org.kde.kalendar", 1, 0, "HourlyIncidenceModel");
......@@ -148,6 +147,7 @@ int main(int argc, char *argv[])
qmlRegisterType<MonthModel>("org.kde.kalendar", 1, 0, "MonthModel");
qmlRegisterType<InfiniteCalendarViewModel>("org.kde.kalendar", 1, 0, "InfiniteCalendarViewModel");
qRegisterMetaType<Akonadi::ETMCalendar::Ptr>();
qRegisterMetaType<Akonadi::AgentFilterProxyModel *>();
qRegisterMetaType<QAction *>();
......
// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <KFormat>
#include <QDateTime>
#include <models/extratodomodel.h>
ExtraTodoModel::ExtraTodoModel(QObject *parent)
: KExtraColumnsProxyModel(parent)
{
const QString todoMimeType = QStringLiteral("application/x-vnd.akonadi.calendar.todo");
m_todoTreeModel = new IncidenceTreeModel(QStringList() << todoMimeType, this);
const auto pref = EventViews::PrefsPtr();
m_baseTodoModel = new TodoModel(pref, this);
m_baseTodoModel->setSourceModel(m_todoTreeModel);
setSourceModel(m_baseTodoModel);
appendColumn(QLatin1String("StartDateTime"));
appendColumn(QLatin1String("EndDateTime"));
appendColumn(QLatin1String("PriorityInt"));
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup rColorsConfig(config, "Resources Colors");
m_colorWatcher = KConfigWatcher::create(config);
QObject::connect(m_colorWatcher.data(), &KConfigWatcher::configChanged, this, &ExtraTodoModel::loadColors);
loadColors();
}
QVariant ExtraTodoModel::extraColumnData(const QModelIndex &parent, int row, int extraColumn, int role) const
{
if (role != Qt::DisplayRole && role != Qt::EditRole) {
return {};
}
const auto todoItem = index(row, extraColumn, parent).data(TodoModel::TodoRole).value<Akonadi::Item>();
const auto todoPtr = CalendarSupport::todo(todoItem);
if (todoPtr == nullptr) {
return {};
}
switch (extraColumn) {
case StartTimeColumn:
return todoPtr->dtStart();
case EndTimeColumn:
return todoPtr->dtDue();
case PriorityIntColumn:
return todoPtr->priority();
default:
return {};
}
}
QVariant ExtraTodoModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return {};
}
auto idx = mapToSource(index);
auto todoItem = idx.data(TodoModel::TodoRole).value<Akonadi::Item>();
auto collectionId = todoItem.parentCollection().id();
auto todoPtr = CalendarSupport::todo(todoItem);
if (todoPtr == nullptr) {
return {};
}
if (role == Roles::StartTimeRole) {
return todoPtr->dtStart();
} else if (role == Roles::EndTimeRole) {
return todoPtr->dtDue();
} else if (role == Roles::LocationRole) {
return todoPtr->location();
} else if (role == Roles::AllDayRole) {
return todoPtr->allDay();
} else if (role == Roles::ColorRole) {
QColor nullcolor;
return m_colors.contains(QString::number(collectionId)) ? m_colors[QString::number(collectionId)] : nullcolor;
} else if (role == Roles::CompletedRole) {
return todoPtr->isCompleted();
} else if (role == Roles::PriorityRole) {
return todoPtr->priority();
} 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
}
return format.formatSpelloutDuration(todoPtr->duration().asSeconds() * 1000);
} else if (role == Roles::RecursRole) {
return todoPtr->recurs();
} else if (role == Roles::IsOverdueRole) {
return todoPtr->isOverdue();
} else if (role == Roles::IncidenceIdRole) {
return todoPtr->uid();
} else if (role == Roles::IncidenceTypeRole) {
return todoPtr->type();
} else if (role == Roles::IncidenceTypeStrRole) {
return todoPtr->type() == KCalendarCore::Incidence::TypeTodo ? i18n("Task") : i18n(todoPtr->typeStr());
} else if (role == Roles::IncidenceTypeIconRole) {
return todoPtr->iconName();
} else if (role == Roles::IncidencePtrRole) {
return QVariant::fromValue(CalendarSupport::incidence(todoItem));
} else if (role == Roles::TagsRole) {
return QVariant::fromValue(todoItem.tags());
} else if (role == Roles::ItemRole) {
return QVariant::fromValue(todoItem);
} else if (role == Roles::CategoriesRole) {
return todoPtr->categories();
} else if (role == Roles::CategoriesDisplayRole) {
return todoPtr->categories().join(i18nc("List separator", ", "));
} else if (role == Roles::TreeDepthRole || role == TopMostParentSummary || role == TopMostParentDueDate || role == TopMostParentPriority) {
int depth = 0;
auto idx = index;
while (idx.parent().isValid()) {
idx = idx.parent();
depth++;
}
auto todo = idx.data(TodoModel::TodoPtrRole).value<KCalendarCore::Todo::Ptr>();
switch (role) {
case Roles::TreeDepthRole:
return depth;
case TopMostParentSummary:
return todo->summary();
case TopMostParentDueDate: {
bool isOverdue = (todo->hasDueDate() && todo->dtDue().date() < QDate::currentDate() && todo->allDay())
|| (todo->hasDueDate() && todo->dtDue() < QDateTime::currentDateTime() && !todo->allDay());
return isOverdue ? i18n("Overdue") : todo->hasDueDate() ? QLocale::system().toString(todo->dtDue().date()) : i18n("No set date");
}
case TopMostParentPriority:
return todo->priority();
}
}
return KExtraColumnsProxyModel::data(index, role);
}
QHash<int, QByteArray> ExtraTodoModel::roleNames() const
{
QHash<int, QByteArray> roleNames = KExtraColumnsProxyModel::roleNames();
roleNames[TodoModel::SummaryRole] = "text";
roleNames[Roles::StartTimeRole] = "startTime";
roleNames[Roles::EndTimeRole] = "endTime";
roleNames[Roles::LocationRole] = "location";
roleNames[Roles::AllDayRole] = "allDay";
roleNames[Roles::ColorRole] = "color";
roleNames[Roles::CompletedRole] = "todoCompleted";
roleNames[Roles::PriorityRole] = "priority";
roleNames[Roles::CollectionIdRole] = "collectionId";
roleNames[Roles::DurationStringRole] = "durationString";
roleNames[Roles::RecursRole] = "recurs";
roleNames[Roles::IsOverdueRole] = "isOverdue";
roleNames[Roles::IncidenceIdRole] = "incidenceId";
roleNames[Roles::IncidenceTypeRole] = "incidenceType";
roleNames[Roles::IncidenceTypeStrRole] = "incidenceTypeStr";
roleNames[Roles::IncidenceTypeIconRole] = "incidenceTypeIcon";
roleNames[Roles::IncidencePtrRole] = "incidencePtr";
roleNames[Roles::TagsRole] = "tags";
roleNames[Roles::ItemRole] = "item";
roleNames[Roles::CategoriesRole] = "todoCategories"; // Simply 'categories' causes issues
roleNames[Roles::CategoriesDisplayRole] = "categoriesDisplay";
roleNames[Roles::TreeDepthRole] = "treeDepth";
roleNames[Roles::TopMostParentDueDate] = "topMostParentDueDate";
roleNames[Roles::TopMostParentSummary] = "topMostParentSummary";
roleNames[Roles::TopMostParentPriority] = "topMostParentPriority";
return roleNames;
}
Akonadi::ETMCalendar::Ptr ExtraTodoModel::calendar()
{
return m_calendar;
}
void ExtraTodoModel::setCalendar(Akonadi::ETMCalendar::Ptr calendar)
{
m_calendar = calendar;
m_todoTreeModel->setSourceModel(calendar->model());
m_baseTodoModel->setCalendar(calendar);
}
Akonadi::IncidenceChanger *ExtraTodoModel::incidenceChanger()
{
return m_lastSetChanger;
}
void ExtraTodoModel::setIncidenceChanger(Akonadi::IncidenceChanger *changer)
{
m_baseTodoModel->setIncidenceChanger(changer);
m_lastSetChanger = changer; // Ideally we contribute a getter func upstream.
}
QHash<QString, QColor> ExtraTodoModel::colorCache()
{
return m_colors;
}
void ExtraTodoModel::setColorCache(QHash<QString, QColor> colorCache)
{
m_colors = colorCache;
}
void ExtraTodoModel::loadColors()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup rColorsConfig(config, "Resources Colors");
const QStringList colorKeyList = rColorsConfig.keyList();
for (const QString &key : colorKeyList) {
QColor color = rColorsConfig.readEntry(key, QColor("blue"));
m_colors[key] = color;
}
Q_EMIT layoutChanged();
}
#ifndef UNITY_CMAKE_SUPPORT
Q_DECLARE_METATYPE(KCalendarCore::Incidence::Ptr)
#endif
// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <EventViews/IncidenceTreeModel>
#include <EventViews/TodoModel>
#include <KConfigWatcher>
#include <KExtraColumnsProxyModel>
#include <KFormat>
class ExtraTodoModel : public KExtraColumnsProxyModel
{
Q_OBJECT
public:
enum Columns {
StartTimeColumn = 0,
EndTimeColumn,
PriorityIntColumn,
};
Q_ENUM(Columns);
enum Roles { // Remember to update roles in todosortfilterproxymodel
StartTimeRole = TodoModel::CalendarRole + 1,
EndTimeRole,
LocationRole,
AllDayRole,
CompletedRole,
PriorityRole,
ColorRole,
CollectionIdRole,
DurationStringRole,
RecursRole,
IsOverdueRole,
IncidenceIdRole,
IncidenceTypeRole,
IncidenceTypeStrRole,
IncidenceTypeIconRole,
IncidencePtrRole,
TagsRole,
ItemRole,
CategoriesRole,
CategoriesDisplayRole,
TreeDepthRole,
TopMostParentSummary, // These three here are used to help us conserve the proper sections
TopMostParentDueDate, // in the Kirigami TreeListView, which otherwise will create new
TopMostParentPriority // sections for subtasks
};
Q_ENUM(Roles);
ExtraTodoModel(QObject *parent = nullptr);
~ExtraTodoModel() override = default;
QVariant extraColumnData(const QModelIndex &parent, int row, int extraColumn, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
Akonadi::ETMCalendar::Ptr calendar();
void setCalendar(Akonadi::ETMCalendar::Ptr calendar);
Akonadi::IncidenceChanger *incidenceChanger();
void setIncidenceChanger(Akonadi::IncidenceChanger *changer);
QHash<QString, QColor> colorCache();
void setColorCache(QHash<QString, QColor> colorCache);
void loadColors();
private:
Akonadi::ETMCalendar::Ptr m_calendar;
IncidenceTreeModel *m_todoTreeModel = nullptr;
TodoModel *m_baseTodoModel = nullptr;
Akonadi::IncidenceChanger *m_lastSetChanger = nullptr;
QHash<QString, QColor> m_colors;
KConfigWatcher::Ptr m_colorWatcher;
};
......@@ -92,7 +92,7 @@ void IncidenceOccurrenceModel::updateQuery()
QObject::connect(m_coreCalendar->model(), &QAbstractItemModel::rowsInserted, this, &IncidenceOccurrenceModel::refreshView);
QObject::connect(m_coreCalendar->model(), &QAbstractItemModel::rowsRemoved, this, &IncidenceOccurrenceModel::refreshView);
QObject::connect(m_coreCalendar->model(), &QAbstractItemModel::modelReset, this, &IncidenceOccurrenceModel::refreshView);
QObject::connect(m_coreCalendar, &Akonadi::ETMCalendar::collectionsRemoved, this, &IncidenceOccurrenceModel::refreshView);
QObject::connect(m_coreCalendar.get(), &Akonadi::ETMCalendar::collectionsRemoved, this, &IncidenceOccurrenceModel::refreshView);
refreshView();
}
......@@ -283,7 +283,7 @@ QVariant IncidenceOccurrenceModel::data(const QModelIndex &idx, int role) const
}
}
void IncidenceOccurrenceModel::setCalendar(Akonadi::ETMCalendar *calendar)
void IncidenceOccurrenceModel::setCalendar(Akonadi::ETMCalendar::Ptr calendar)
{
if (m_coreCalendar == calendar) {
return;
......@@ -293,7 +293,7 @@ void IncidenceOccurrenceModel::setCalendar(Akonadi::ETMCalendar *calendar)
Q_EMIT calendarChanged();
}
Akonadi::ETMCalendar *IncidenceOccurrenceModel::calendar() const
Akonadi::ETMCalendar::Ptr IncidenceOccurrenceModel::calendar() const
{
return m_coreCalendar;
}
......
......@@ -38,7 +38,7 @@ class IncidenceOccurrenceModel : public QAbstractListModel
Q_PROPERTY(QDate start READ start WRITE setStart NOTIFY startChanged)
Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged)
Q_PROPERTY(QVariantMap filter READ filter WRITE setFilter NOTIFY filterChanged)
Q_PROPERTY(Akonadi::ETMCalendar *calendar READ calendar WRITE setCalendar NOTIFY calendarChanged)
Q_PROPERTY(Akonadi::ETMCalendar::Ptr calendar READ calendar WRITE setCalendar NOTIFY calendarChanged)
public:
enum Roles {
......@@ -75,8 +75,8 @@ public:
QVariant data(const QModelIndex &index, int role) const override;
void updateQuery();
Akonadi::ETMCalendar *calendar() const;
void setCalendar(Akonadi::ETMCalendar *calendar);
Akonadi::ETMCalendar::Ptr calendar() const;
void setCalendar(Akonadi::ETMCalendar::Ptr calendar);
void setStart(const QDate &start);
QDate start() const;
......@@ -112,7 +112,7 @@ private:
QDate mStart;
QDate mEnd;
int mLength{0};
Akonadi::ETMCalendar *m_coreCalendar;
Akonadi::ETMCalendar::Ptr m_coreCalendar;
QTimer mRefreshTimer;
......
......@@ -536,12 +536,12 @@ void InfiniteCalendarViewModel::setScale(int scale)
endResetModel();
}
Akonadi::ETMCalendar *InfiniteCalendarViewModel::calendar()
Akonadi::ETMCalendar::Ptr InfiniteCalendarViewModel::calendar()
{
return m_calendar;
}
void InfiniteCalendarViewModel::setCalendar(Akonadi::ETMCalendar *calendar)
void InfiniteCalendarViewModel::setCalendar(Akonadi::ETMCalendar::Ptr calendar)
{
m_insertedIds.clear();
m_calendar = calendar;
......
......@@ -16,7 +16,7 @@ class InfiniteCalendarViewModel : public QAbstractListModel
Q_PROPERTY(int datesToAdd READ datesToAdd WRITE setDatesToAdd NOTIFY datesToAddChanged)
Q_PROPERTY(int scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QStringList hourlyViewLocalisedHourLabels MEMBER m_hourlyViewLocalisedHourLabels CONSTANT)
Q_PROPERTY(Akonadi::ETMCalendar *calendar READ calendar WRITE setCalendar NOTIFY calendarChanged)
Q_PROPERTY(Akonadi::ETMCalendar::Ptr calendar READ calendar WRITE setCalendar NOTIFY calendarChanged)
Q_PROPERTY(QVariantMap filter READ filter WRITE setFilter NOTIFY filterChanged)
Q_PROPERTY(int maxLiveModels READ maxLiveModels WRITE setMaxLiveModels NOTIFY maxLiveModelsChanged)
......@@ -65,8 +65,8 @@ public:
int scale();
void setScale(int scale);
Akonadi::ETMCalendar *calendar();
void setCalendar(Akonadi::ETMCalendar *calendar);
Akonadi::ETMCalendar::Ptr calendar();
void setCalendar(Akonadi::ETMCalendar::Ptr calendar);
QVariantMap filter() const;
void setFilter(const QVariantMap &filter);
......@@ -129,6 +129,6 @@ private:
mutable QQueue<QDate> m_liveDayViewMultiDayModelKeys;
int m_maxLiveModels = 10;
mutable int m_lastAccessedModelType = TypeMonth;
Akonadi::ETMCalendar *m_calendar;
Akonadi::ETMCalendar::Ptr m_calendar;
QVariantMap mFilter;
};
// SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <KFormat>
#include <models/todosortfilterproxymodel.h>
TodoSortFilterProxyModel::TodoSortFilterProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
m_extraTodoModel = new ExtraTodoModel;
setSourceModel(m_extraTodoModel);
const QString todoMimeType = QStringLiteral("application/x-vnd.akonadi.calendar.todo");
m_todoTreeModel = new IncidenceTreeModel(QStringList() << todoMimeType, this);
const auto pref = EventViews::PrefsPtr();
m_baseTodoModel = new TodoModel(pref, this);
m_baseTodoModel->setSourceModel(m_todoTreeModel);
setSourceModel(m_baseTodoModel);
setDynamicSortFilter(true);
setSortCaseSensitivity(Qt::CaseInsensitive);
setFilterCaseSensitivity(Qt::CaseInsensitive);
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup rColorsConfig(config, "Resources Colors");
m_colorWatcher = KConfigWatcher::create(config);
QObject::connect(m_colorWatcher.data(), &KConfigWatcher::configChanged, this, &TodoSortFilterProxyModel::loadColors);
loadColors();
mRefreshTimer.setSingleShot(true);
auto sortTimer = [this] {
if (!mRefreshTimer.isActive()) {
mRefreshTimer.start(250);
qDebug() << m_baseTodoModel->rowCount();
}
};
......@@ -24,11 +39,11 @@ TodoSortFilterProxyModel::TodoSortFilterProxyModel(QObject *parent)
sortTodoModel(m_sortColumn, m_sortAscending);
});
connect(m_extraTodoModel, &KExtraColumnsProxyModel::dataChanged, this, sortTimer);
connect(m_extraTodoModel, &KExtraColumnsProxyModel::rowsInserted, this, sortTimer);
connect(m_extraTodoModel, &KExtraColumnsProxyModel::rowsRemoved, this, sortTimer);
connect(m_extraTodoModel, &KExtraColumnsProxyModel::layoutChanged, this, sortTimer);
connect(m_extraTodoModel, &KExtraColumnsProxyModel::rowsMoved, this, sortTimer);
connect(m_baseTodoModel, &TodoModel::dataChanged, this, sortTimer);
connect(m_baseTodoModel, &TodoModel::rowsInserted, this, sortTimer);
connect(m_baseTodoModel, &TodoModel::rowsRemoved, this, sortTimer);
connect(m_baseTodoModel, &TodoModel::layoutChanged, this, sortTimer);
connect(m_baseTodoModel, &TodoModel::rowsMoved, this, sortTimer);
m_config = KalendarConfig::self();
QObject::connect(m_config, &KalendarConfig::showCompletedSubtodosChanged, this, [&]() {
......@@ -36,6 +51,132 @@ TodoSortFilterProxyModel::TodoSortFilterProxyModel(QObject *parent)
});
}
TodoSortFilterProxyModel::~TodoSortFilterProxyModel()
{
delete m_baseTodoModel;
delete m_todoTreeModel;
}
QHash<int, QByteArray> TodoSortFilterProxyModel::roleNames() const
{
QHash<int, QByteArray> roleNames = QSortFilterProxyModel::roleNames();
roleNames[TodoModel::SummaryRole] = "text";
roleNames[Roles::StartTimeRole] = "startTime";
roleNames[Roles::EndTimeRole] = "endTime";
roleNames[Roles::LocationRole] = "location";
roleNames[Roles::AllDayRole] = "allDay";
roleNames[Roles::ColorRole] = "color";
roleNames[Roles::CompletedRole] = "todoCompleted";
roleNames[Roles::PriorityRole] = "priority";
roleNames[Roles::CollectionIdRole] = "collectionId";
roleNames[Roles::DurationStringRole] = "durationString";
roleNames[Roles::RecursRole] = "recurs";
roleNames[Roles::IsOverdueRole] = "isOverdue";
roleNames[Roles::IncidenceIdRole] = "incidenceId";
roleNames[Roles::IncidenceTypeRole] = "incidenceType";
roleNames[Roles::IncidenceTypeStrRole] = "incidenceTypeStr";