Commit 928c3fbd authored by Carl Schwan's avatar Carl Schwan 🚴 Committed by Claudio Cambra
Browse files

Removed vendored todo model

Use upstream from eventviews

Depends on eventviews!36
parent ec86a22f
Pipeline #119807 passed with stage
in 5 minutes and 9 seconds
......@@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: BSD-2-Clause
add_executable(kalendar)
target_sources(kalendar PRIVATE
about.cpp
......@@ -27,9 +26,6 @@ target_sources(kalendar PRIVATE
hourlyincidencemodel.h
incidenceoccurrencemodel.cpp
incidenceoccurrencemodel.h
incidencetreemodel.cpp
incidencetreemodel.h
incidencetreemodel_p.h
incidencewrapper.cpp
incidencewrapper.h
infinitecalendarviewmodel.cpp
......@@ -51,16 +47,12 @@ target_sources(kalendar PRIVATE
tagmanager.h
timezonelistmodel.cpp
timezonelistmodel.h
todomodel.cpp
todomodel.h
todomodel_p.h
todosortfilterproxymodel.cpp
todosortfilterproxymodel.h
resources.qrc)
ecm_qt_declare_logging_category(kalendar HEADER kalendar_debug.h IDENTIFIER KALENDAR_LOG CATEGORY_NAME org.kde.kalendar DESCRIPTION "kalendar" EXPORT KALENDAR)
target_link_libraries(kalendar
Qt5::Core
Qt5::Gui
......
......@@ -4,10 +4,11 @@
#pragma once
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <EventViews/IncidenceTreeModel>
#include <EventViews/TodoModel>
#include <KConfigWatcher>
#include <KExtraColumnsProxyModel>
#include <incidencetreemodel.h>
#include <todomodel.h>
#include <KFormat>
class ExtraTodoModel : public KExtraColumnsProxyModel
{
......
This diff is collapsed.
/*
SPDX-FileCopyrightText: 2012 Sérgio Martins <iamsergio@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Qt-Commercial-exception-1.0
*/
#pragma once
#include <QObject>
#include <akonadi_version.h>
#if AKONADI_VERSION >= QT_VERSION_CHECK(5, 18, 41)
#include <Akonadi/Item>
#else
#include <AkonadiCore/Item>
#endif
#include <QAbstractProxyModel>
#include <memory>
class IncidenceTreeModelPrivate;
class IncidenceTreeModel : public QAbstractProxyModel
{
Q_OBJECT
public:
/**
* Constructs a new IncidenceTreeModel.
*/
explicit IncidenceTreeModel(QObject *parent = nullptr);
/**
* Constructs a new IncidenceTreeModel which will only show incidences of
* type @p mimeTypes. Common use case is a to-do tree.
*
* This constructor is offered for performance reasons. The filtering has
* zero overhead, and we avoid stacking mime type filter proxy models.
*
* If you're more concerned about clean design than performance, use the default
* constructor and stack a Akonadi::EntityMimeTypeFilterModel on top of this one.
*/
explicit IncidenceTreeModel(const QStringList &mimeTypes, QObject *parent = nullptr);
~IncidenceTreeModel() override;
Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Q_REQUIRED_RESULT int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role) const override;
Q_REQUIRED_RESULT QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
Q_REQUIRED_RESULT QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
Q_REQUIRED_RESULT QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
Q_REQUIRED_RESULT QModelIndex parent(const QModelIndex &child) const override;
void setSourceModel(QAbstractItemModel *sourceModel) override;
Q_REQUIRED_RESULT bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
/**
* Returns the akonadi item containing the incidence with @p incidenceUid.
*/
Q_REQUIRED_RESULT Akonadi::Item item(const QString &incidenceUid) const;
Q_SIGNALS:
/**
* This signal is emitted whenever an index changes parent.
* The view can then expand the parent if desired.
* This is better than the view waiting for "rows moved" signals because those
* signals are also sent when the model is initially populated.
*/
void indexChangedParent(const QModelIndex &index);
/**
* Signals that we finished doing a batch of insertions.
*
* One rowsInserted() signal from the ETM, will make IncidenceTreeModel generate
* several rowsInserted(), layoutChanged() or rowsMoved() signals.
*
* A tree view can use this signal to know when to call KConfigViewStateSaver::restore()
* to restore expansion states. Listening to rowsInserted() signals would be a
* performance problem.
*/
void batchInsertionFinished();
private:
friend class IncidenceTreeModelPrivate;
std::unique_ptr<IncidenceTreeModelPrivate> const d;
};
/*
SPDX-FileCopyrightText: 2012 Sérgio Martins <iamsergio@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Qt-Commercial-exception-1.0
*/
#pragma once
#include "incidencetreemodel.h"
#include <akonadi_version.h>
#if AKONADI_VERSION >= QT_VERSION_CHECK(5, 18, 41)
#include <Akonadi/Item>
#else
#include <AkonadiCore/Item>
#endif
#include <KCalendarCore/Incidence>
#include <QHash>
#include <QModelIndex>
#include <QObject>
#include <QPersistentModelIndex>
#include <QSharedPointer>
#include <QStringList>
#include <QVector>
using Uid = QString;
using ParentUid = QString;
struct Node {
using Ptr = QSharedPointer<Node>;
using Map = QMap<Akonadi::Item::Id, Ptr>;
using List = QVector<Ptr>;
QPersistentModelIndex sourceIndex; // because ETM::modelIndexesForItem is so slow
Akonadi::Item::Id id;
Node::Ptr parentNode;
QString parentUid;
QString uid;
List directChilds;
int depth;
};
/** Just a struct to contain some data before we create the node */
struct PreNode {
using Ptr = QSharedPointer<PreNode>;
using List = QVector<Ptr>;
KCalendarCore::Incidence::Ptr incidence;
QPersistentModelIndex sourceIndex;
Akonadi::Item item;
int depth;
PreNode()
: depth(-1)
{
}
};
class IncidenceTreeModelPrivate : public QObject
{
Q_OBJECT
public:
IncidenceTreeModelPrivate(IncidenceTreeModel *qq, const QStringList &mimeTypes);
void reset(bool silent = false);
void insertNode(const PreNode::Ptr &node, bool silent = false);
void insertNode(const QModelIndex &sourceIndex, bool silent = false);
void removeNode(const Node::Ptr &node);
QModelIndex indexForNode(const Node::Ptr &node) const;
int rowForNode(const Node::Ptr &node) const;
bool indexBeingRemoved(const QModelIndex &) const; // Is it being removed?
void dumpTree();
void assert_and_dump(bool condition, const QString &message);
Node::List sorted(const Node::List &nodes) const;
PreNode::Ptr prenodeFromSourceRow(int sourceRow) const;
void setSourceModel(QAbstractItemModel *model);
public:
Node::Map m_nodeMap;
Node::List m_toplevelNodeList;
QHash<Uid, Node::Ptr> m_uidMap;
QHash<Uid, Akonadi::Item> m_itemByUid;
QMultiHash<ParentUid, Node::Ptr> m_waitingForParent;
QList<Node *> m_removedNodes;
const QStringList m_mimeTypes;
private Q_SLOTS:
void onHeaderDataChanged(Qt::Orientation orientation, int first, int last);
void onDataChanged(const QModelIndex &begin, const QModelIndex &end);
void onRowsAboutToBeInserted(const QModelIndex &parent, int begin, int end);
void onRowsInserted(const QModelIndex &parent, int begin, int end);
void onRowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
void onRowsRemoved(const QModelIndex &parent, int begin, int end);
void onRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
void onModelAboutToBeReset();
void onModelReset();
void onLayoutAboutToBeChanged();
void onLayoutChanged();
private:
IncidenceTreeModel *const q;
};
This diff is collapsed.
/*
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 LicenseRef-Qt-Commercial-exception-1.0
*/
#pragma once
#include <EventViews/Prefs>
#include <Akonadi/Calendar/ETMCalendar>
#include <Akonadi/Calendar/IncidenceChanger>
#include <akonadi_version.h>
#if AKONADI_VERSION >= QT_VERSION_CHECK(5, 18, 41)
#include <Akonadi/EntityTreeModel>
#include <Akonadi/Item>
#else
#include <EntityTreeModel>
#include <Item>
#endif
#include <KCalendarCore/Todo>
#include <QAbstractItemModel>
#include <QAbstractProxyModel>
#include <memory>
class QMimeData;
class TodoModelPrivate;
class TodoModel : public QAbstractProxyModel
{
Q_OBJECT
public:
/** This enum defines all columns this model provides */
enum {
SummaryColumn = 0,
RecurColumn,
PriorityColumn,
PercentColumn,
StartDateColumn,
DueDateColumn,
CategoriesColumn,
DescriptionColumn,
CalendarColumn,
CompletedDateColumn,
ColumnCount // Just for iteration/column count purposes. Always keep at the end of enum.
};
/** This enum defines the user defined roles of the items in this model */
enum {
TodoRole = Akonadi::EntityTreeModel::UserRole + 1,
TodoPtrRole,
IsRichTextRole,
SummaryRole,
RecurRole,
PriorityRole,
PercentRole,
StartDateRole,
DueDateRole,
CategoriesRole,
DescriptionRole,
CalendarRole,
};
explicit TodoModel(const EventViews::PrefsPtr &preferences, QObject *parent = nullptr);
~TodoModel() override;
Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Q_REQUIRED_RESULT int columnCount(const QModelIndex &parent = QModelIndex()) const override;
void setSourceModel(QAbstractItemModel *sourceModel) override;
Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role) const override;
Q_REQUIRED_RESULT bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Q_REQUIRED_RESULT QVariant headerData(int section, Qt::Orientation, int role) const override;
void setCalendar(const Akonadi::ETMCalendar::Ptr &calendar);
void setIncidenceChanger(Akonadi::IncidenceChanger *changer);
Q_REQUIRED_RESULT QMimeData *mimeData(const QModelIndexList &indexes) const override;
Q_REQUIRED_RESULT bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
Q_REQUIRED_RESULT QStringList mimeTypes() const override;
Q_REQUIRED_RESULT Qt::DropActions supportedDropActions() const override;
Q_REQUIRED_RESULT Qt::ItemFlags flags(const QModelIndex &index) const override;
Q_REQUIRED_RESULT QModelIndex parent(const QModelIndex &child) const override;
Q_REQUIRED_RESULT QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
Q_REQUIRED_RESULT QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
Q_REQUIRED_RESULT QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
Q_REQUIRED_RESULT QModelIndex buddy(const QModelIndex &index) const override;
Q_REQUIRED_RESULT QHash<int, QByteArray> roleNames() const override;
private:
friend class TodoModelPrivate;
std::unique_ptr<TodoModelPrivate> const d;
};
/*
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 LicenseRef-Qt-Commercial-exception-1.0
*/
#pragma once
#include "todomodel.h"
#include <Akonadi/Calendar/ETMCalendar>
#if AKONADI_VERSION >= QT_VERSION_CHECK(5, 18, 41)
#include <Akonadi/Item>
#else
#include <Item>
#endif
#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;
// For adjusting persistent indexes
QList<QPersistentModelIndex> m_layoutChangePersistentIndexes;
QModelIndexList m_persistentIndexes;
QList<int> m_columns;
EventViews::PrefsPtr m_preferences;
private Q_SLOTS:
void onDataChanged(const QModelIndex &begin, const QModelIndex &end);
void onHeaderDataChanged(Qt::Orientation orientation, int first, int last);
void onRowsAboutToBeInserted(const QModelIndex &parent, int begin, int end);
void onRowsInserted(const QModelIndex &parent, int begin, int end);
void onRowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
void onRowsRemoved(const QModelIndex &parent, int begin, int end);
void onRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow);
void onRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
void onModelAboutToBeReset();
void onModelReset();
void onLayoutAboutToBeChanged();
void onLayoutChanged();
private:
TodoModel *const q;
};
......@@ -8,11 +8,11 @@
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
#include <KSharedConfig>
#include <EventViews/IncidenceTreeModel>
#include <EventViews/TodoModel>
#include <QSortFilterProxyModel>
#include <QTimer>
#include <extratodomodel.h>
#include <incidencetreemodel.h>
#include <todomodel.h>
class TodoSortFilterProxyModel : public QSortFilterProxyModel
{
......
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