Commit 7f0fa860 authored by Volker Krause's avatar Volker Krause
Browse files

Simplify TodoModelPrivate

This doesn't need to be a QObject anymore after rebasing this on
KExtraColumnsProxyModel.
parent 5a3ebb42
Pipeline #175366 passed with stage
in 2 minutes and 13 seconds
......@@ -68,7 +68,6 @@ target_sources(KF5EventViews PRIVATE
todo/todomodel.h
todo/todoviewquicksearch.h
todo/tododelegates.h
todo/todomodel_p.h
todo/todoview.h
todo/todoviewquickaddline.h
multiagenda/multiagendaview.h
......
......@@ -5,7 +5,7 @@
SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
*/
#include "todomodel_p.h"
#include "todomodel.h"
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
......@@ -27,14 +27,30 @@
#include <QIcon>
#include <QMimeData>
class TodoModelPrivate
{
public:
TodoModelPrivate(const EventViews::PrefsPtr &preferences, TodoModel *qq);
// TODO: O(N) complexity, see if the profiler complains about this
Akonadi::Item findItemByUid(const QString &uid, const QModelIndex &parent) const;
Akonadi::ETMCalendar::Ptr m_calendar;
Akonadi::IncidenceChanger *m_changer = nullptr;
EventViews::PrefsPtr m_preferences;
void onDataChanged(const QModelIndex &begin, const QModelIndex &end);
TodoModel *const q;
};
static bool isDueToday(const KCalendarCore::Todo::Ptr &todo)
{
return !todo->isCompleted() && todo->dtDue().date() == QDate::currentDate();
}
TodoModelPrivate::TodoModelPrivate(const EventViews::PrefsPtr &preferences, TodoModel *qq)
: QObject()
, m_preferences(preferences)
: m_preferences(preferences)
, q(qq)
{
}
......@@ -416,13 +432,15 @@ void TodoModel::setSourceModel(QAbstractItemModel *model)
beginResetModel();
if (sourceModel()) {
disconnect(sourceModel(), &QAbstractItemModel::dataChanged, d.get(), &TodoModelPrivate::onDataChanged);
disconnect(sourceModel(), &QAbstractItemModel::dataChanged, this, nullptr);
}
KExtraColumnsProxyModel::setSourceModel(model);
if (sourceModel()) {
connect(sourceModel(), &QAbstractItemModel::dataChanged, d.get(), &TodoModelPrivate::onDataChanged);
connect(sourceModel(), &QAbstractItemModel::dataChanged, this, [this](const auto &begin, const auto &end) {
d->onDataChanged(begin, end);
});
}
endResetModel();
......
/*
SPDX-FileCopyrightText: 2008 Thomas Thrainer <tom_t@gmx.at>
SPDX-FileCopyrightText: 2012 Sérgio Martins <iamsergio@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
*/
#pragma once
#include "todomodel.h"
#include <Akonadi/ETMCalendar>
#include <Akonadi/Item>
#include <QModelIndex>
#include <QString>
namespace Akonadi
{
class IncidenceChanger;
}
class TodoModelPrivate : public QObject
{
Q_OBJECT
public:
TodoModelPrivate(const EventViews::PrefsPtr &preferences, TodoModel *qq);
// TODO: O(N) complexity, see if the profiler complains about this
Akonadi::Item findItemByUid(const QString &uid, const QModelIndex &parent) const;
public:
Akonadi::ETMCalendar::Ptr m_calendar;
Akonadi::IncidenceChanger *m_changer = nullptr;
EventViews::PrefsPtr m_preferences;
public Q_SLOTS:
void onDataChanged(const QModelIndex &begin, const QModelIndex &end);
private:
TodoModel *const q;
};
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