Commit 920531e6 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Re-enable etm_usage, port from CR to Monitor

Strictly speaking this change is not even necessary, the build could've
been easilly fixed simply by forward-declaring or including CR header
in our headers (and not relaying on ETM header to do it). But since
all client apps should only use Monitors and not CRs, let's port the
examples, so they are closer to what we want.
parent 9aeade1f
......@@ -65,7 +65,7 @@ set(EVENTVIEW_LIB_VERSION "5.3.40")
set(LIBKDEPIM_LIB_VERSION "5.3.40")
set(KDEPIM_APPS_LIB_VERSION "5.3.40")
set(LIBKLEO_LIB_VERSION "5.3.40")
set(AKONADI_LIB_VERSION "5.3.40")
set(AKONADI_LIB_VERSION "5.3.45")
set(INCIDENCEEDITOR_LIB_VERSION "5.3.40")
set(KTNEF_LIB_VERSION "5.3.40")
set(MESSAGELIB_LIB_VERSION "5.3.52")
......
# add_subdirectory(etm_usage)
add_subdirectory(etm_usage)
add_subdirectory(kabc)
add_subdirectory(mailreader)
add_subdirectory(coisceim)
......
......@@ -31,7 +31,7 @@
#include <KConfig>
#include <KSharedConfigPtr>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/Monitor>
#include <KSharedConfig>
#include "createfoldercontentswidget.h"
......@@ -40,7 +40,7 @@
using namespace Akonadi;
CreateTripWidget::CreateTripWidget(Trip *trip, Akonadi::ChangeRecorder *monitor, QWidget *parent, Qt::WindowFlags f)
CreateTripWidget::CreateTripWidget(Trip *trip, Akonadi::Monitor *monitor, QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f), m_trip(trip), m_monitor(monitor)
{
QVBoxLayout *layout = new QVBoxLayout(this);
......
......@@ -28,7 +28,7 @@
namespace Akonadi
{
class ChangeRecorder;
class Monitor;
}
class CreateFolderContentsWidget;
......@@ -39,7 +39,7 @@ class CreateTripWidget : public QWidget
{
Q_OBJECT
public:
explicit CreateTripWidget(Trip *trip, Akonadi::ChangeRecorder *monitor, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = 0);
explicit CreateTripWidget(Trip *trip, Akonadi::Monitor *monitor, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = 0);
private Q_SLOTS:
void tripSelected(const Akonadi::Item &item);
......@@ -49,7 +49,7 @@ private:
CreateFolderContentsWidget *createView(const QString &type, int role);
Trip *m_trip;
Akonadi::ChangeRecorder *m_monitor;
Akonadi::Monitor *m_monitor;
Akonadi::Item m_tripItem;
CreateFolderContentsWidget *m_mailWidget;
CreateFolderContentsWidget *m_todoWidget;
......
......@@ -28,7 +28,7 @@
namespace Akonadi
{
class ChangeRecorder;
class Monitor;
}
class MixedTreeModel : public Akonadi::EntityTreeModel
......
......@@ -23,7 +23,7 @@
#include <QSortFilterProxyModel>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/Monitor>
#include <KCalCore/Incidence>
......@@ -36,8 +36,8 @@
using namespace Akonadi;
Trip::Trip(const QPersistentModelIndex &index, Akonadi::ChangeRecorder *changeRecorder, TripComponentFactory *factory, QObject *parent)
: QObject(parent), m_index(index), m_changeRecorder(changeRecorder)
Trip::Trip(const QPersistentModelIndex &index, Akonadi::Monitor *monitor, TripComponentFactory *factory, QObject *parent)
: QObject(parent), m_index(index), m_monitor(monitor)
{
QAbstractItemModel *model = const_cast<QAbstractItemModel *>(m_index.model());
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(dataChanged(QModelIndex,QModelIndex)));
......@@ -45,13 +45,13 @@ Trip::Trip(const QPersistentModelIndex &index, Akonadi::ChangeRecorder *changeRe
connect(model, &QAbstractItemModel::layoutChanged, this, &Trip::layoutChanged);
connect(model, &QAbstractItemModel::rowsRemoved, this, &Trip::rowsRemoved);
m_mailChangeRecorder = factory->createMailChangeRecorder(this);
m_todoChangeRecorder = factory->createTodoChangeRecorder(this);
m_notesChangeRecorder = factory->createNotesChangeRecorder(this);
m_mailMonitor = factory->createMailMonitor(this);
m_todoMonitor = factory->createTodoMonitor(this);
m_notesMonitor = factory->createNotesMonitor(this);
m_mailChangeRecorder->setSession(m_changeRecorder->session());
m_todoChangeRecorder->setSession(m_changeRecorder->session());
m_notesChangeRecorder->setSession(m_changeRecorder->session());
m_mailMonitor->setSession(m_monitor->session());
m_todoMonitor->setSession(m_monitor->session());
m_notesMonitor->setSession(m_monitor->session());
m_mailModel = new QSortFilterProxyModel(this);
m_mailModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
......@@ -60,9 +60,9 @@ Trip::Trip(const QPersistentModelIndex &index, Akonadi::ChangeRecorder *changeRe
m_notesModel = new QSortFilterProxyModel(this);
m_notesModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_mailModel->setSourceModel(factory->createMailModel(m_mailChangeRecorder));
m_todoModel->setSourceModel(factory->createTodoModel(m_todoChangeRecorder));
m_notesModel->setSourceModel(factory->createNotesModel(m_notesChangeRecorder));
m_mailModel->setSourceModel(factory->createMailModel(m_mailMonitor));
m_todoModel->setSourceModel(factory->createTodoModel(m_todoMonitor));
m_notesModel->setSourceModel(factory->createNotesModel(m_notesMonitor));
QItemSelectionModel *mailItemSelection = new QItemSelectionModel(m_mailModel, this);
QItemSelectionModel *todoItemSelection = new QItemSelectionModel(m_todoModel, this);
......@@ -132,18 +132,18 @@ void Trip::updateEvent()
setEventName(incidence->summary());
}
static void updateCollection(Akonadi::ChangeRecorder *cr, const Collection &collection)
static void updateCollection(Akonadi::Monitor *mon, const Collection &collection)
{
foreach (const Collection &existingCollection, cr->collectionsMonitored()) {
cr->setCollectionMonitored(existingCollection, false);
foreach (const Collection &existingCollection, mon->collectionsMonitored()) {
mon->setCollectionMonitored(existingCollection, false);
}
foreach (const QString &mimeType, cr->mimeTypesMonitored()) {
cr->setMimeTypeMonitored(mimeType, false);
foreach (const QString &mimeType, mon->mimeTypesMonitored()) {
mon->setMimeTypeMonitored(mimeType, false);
}
if (collection.isValid()) {
cr->setCollectionMonitored(collection, true);
mon->setCollectionMonitored(collection, true);
}
}
......@@ -151,23 +151,23 @@ void Trip::setCollection(int role, const Akonadi::Collection &collection)
{
switch (role) {
case MailCollectionRole:
updateCollection(m_mailChangeRecorder, collection);
updateCollection(m_mailMonitor, collection);
Q_EMIT monitoredCollectionsChanged();
return;
case TodoCollectionRole:
updateCollection(m_todoChangeRecorder, collection);
updateCollection(m_todoMonitor, collection);
Q_EMIT monitoredCollectionsChanged();
return;
case NotesCollectionRole:
updateCollection(m_notesChangeRecorder, collection);
updateCollection(m_notesMonitor, collection);
Q_EMIT monitoredCollectionsChanged();
return;
}
}
static Akonadi::Collection monitoredCollection(Akonadi::ChangeRecorder *cr)
static Akonadi::Collection monitoredCollection(Akonadi::Monitor *monitor)
{
Akonadi::Collection::List list = cr->collectionsMonitored();
Akonadi::Collection::List list = monitor->collectionsMonitored();
if (list.isEmpty()) {
return Akonadi::Collection(-1);
}
......@@ -178,11 +178,11 @@ Akonadi::Collection Trip::collection(int role)
{
switch (role) {
case MailCollectionRole:
return monitoredCollection(m_mailChangeRecorder);
return monitoredCollection(m_mailMonitor);
case TodoCollectionRole:
return monitoredCollection(m_todoChangeRecorder);
return monitoredCollection(m_todoMonitor);
case NotesCollectionRole:
return monitoredCollection(m_notesChangeRecorder);
return monitoredCollection(m_notesMonitor);
}
return Akonadi::Collection();
}
......
......@@ -33,7 +33,7 @@ class TripComponentFactory;
namespace Akonadi
{
class ChangeRecorder;
class Monitor;
}
class Trip : public QObject
......@@ -56,7 +56,7 @@ public:
TodoCollectionRole,
NotesCollectionRole
};
Trip(const QPersistentModelIndex &index, Akonadi::ChangeRecorder *changeRecorder, TripComponentFactory *factory, QObject *parent = Q_NULLPTR);
Trip(const QPersistentModelIndex &index, Akonadi::Monitor *monitor, TripComponentFactory *factory, QObject *parent = Q_NULLPTR);
QString eventName() const;
QString eventDescription() const;
......@@ -100,11 +100,11 @@ private:
private:
const QPersistentModelIndex m_index;
Akonadi::ChangeRecorder *m_changeRecorder;
Akonadi::Monitor *m_monitor;
Akonadi::ChangeRecorder *m_mailChangeRecorder;
Akonadi::ChangeRecorder *m_todoChangeRecorder;
Akonadi::ChangeRecorder *m_notesChangeRecorder;
Akonadi::Monitor *m_mailMonitor;
Akonadi::Monitor *m_todoMonitor;
Akonadi::Monitor *m_notesMonitor;
QSortFilterProxyModel *m_mailModel;
QSortFilterProxyModel *m_todoModel;
QSortFilterProxyModel *m_notesModel;
......
......@@ -22,7 +22,7 @@
#include "tripcomponentfactory.h"
#include <AkonadiCore/EntityTreeModel>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/Monitor>
#include <AkonadiCore/ItemFetchScope>
#include <AkonadiCore/EntityMimeTypeFilterModel>
......@@ -34,50 +34,50 @@
#include "todocheckableproxymodel.h"
#include "mixedtreemodel.h"
Akonadi::ChangeRecorder *TripComponentFactory::createMailChangeRecorder(QObject *parent)
Akonadi::Monitor *TripComponentFactory::createMailMonitor(QObject *parent)
{
Akonadi::ChangeRecorder *chRec = new Akonadi::ChangeRecorder(parent);
chRec->setMimeTypeMonitored(KMime::Message::mimeType());
chRec->itemFetchScope().fetchFullPayload(true);
return chRec;
Akonadi::Monitor *chMon = new Akonadi::Monitor(parent);
chMon->setMimeTypeMonitored(KMime::Message::mimeType());
chMon->itemFetchScope().fetchFullPayload(true);
return chMon;
}
Akonadi::ChangeRecorder *TripComponentFactory::createNotesChangeRecorder(QObject *parent)
Akonadi::Monitor *TripComponentFactory::createNotesMonitor(QObject *parent)
{
Akonadi::ChangeRecorder *chRec = new Akonadi::ChangeRecorder(parent);
chRec->setMimeTypeMonitored(Akonotes::Note::mimeType());
chRec->itemFetchScope().fetchFullPayload(true);
return chRec;
Akonadi::Monitor *chMon = new Akonadi::Monitor(parent);
chMon->setMimeTypeMonitored(Akonotes::Note::mimeType());
chMon->itemFetchScope().fetchFullPayload(true);
return chMon;
}
Akonadi::ChangeRecorder *TripComponentFactory::createTodoChangeRecorder(QObject *parent)
Akonadi::Monitor *TripComponentFactory::createTodoMonitor(QObject *parent)
{
Akonadi::ChangeRecorder *chRec = new Akonadi::ChangeRecorder(parent);
chRec->setMimeTypeMonitored(KCalCore::Todo::todoMimeType());
chRec->itemFetchScope().fetchFullPayload(true);
return chRec;
Akonadi::Monitor *chMon = new Akonadi::Monitor(parent);
chMon->setMimeTypeMonitored(KCalCore::Todo::todoMimeType());
chMon->itemFetchScope().fetchFullPayload(true);
return chMon;
}
QAbstractItemModel *TripComponentFactory::createMailModel(Akonadi::ChangeRecorder *changeRecorder)
QAbstractItemModel *TripComponentFactory::createMailModel(Akonadi::Monitor *monitor)
{
MixedTreeModel *model = new MixedTreeModel(changeRecorder);
MixedTreeModel *model = new MixedTreeModel(monitor);
model->setCollectionFetchStrategy(MixedTreeModel::FetchNoCollections);
return model;
}
QAbstractItemModel *TripComponentFactory::createNotesModel(Akonadi::ChangeRecorder *changeRecorder)
QAbstractItemModel *TripComponentFactory::createNotesModel(Akonadi::Monitor *monitor)
{
MixedTreeModel *model = new MixedTreeModel(changeRecorder);
MixedTreeModel *model = new MixedTreeModel(monitor);
model->setCollectionFetchStrategy(MixedTreeModel::FetchNoCollections);
return model;
}
QAbstractItemModel *TripComponentFactory::createTodoModel(Akonadi::ChangeRecorder *changeRecorder)
QAbstractItemModel *TripComponentFactory::createTodoModel(Akonadi::Monitor *monitor)
{
MixedTreeModel *model = new MixedTreeModel(changeRecorder);
MixedTreeModel *model = new MixedTreeModel(monitor);
model->setCollectionFetchStrategy(MixedTreeModel::FetchNoCollections);
Akonadi::EntityMimeTypeFilterModel *filterModel = new Akonadi::EntityMimeTypeFilterModel(changeRecorder);
Akonadi::EntityMimeTypeFilterModel *filterModel = new Akonadi::EntityMimeTypeFilterModel(monitor);
filterModel->addMimeTypeInclusionFilter(KCalCore::Todo::todoMimeType());
filterModel->setHeaderGroup(MixedTreeModel::ItemListHeaders);
filterModel->setSourceModel(model);
......
......@@ -27,20 +27,20 @@ class QAbstractItemModel;
namespace Akonadi
{
class ChangeRecorder;
class Monitor;
}
class TripComponentFactory
{
public:
Akonadi::ChangeRecorder *createMailChangeRecorder(QObject *parent);
Akonadi::ChangeRecorder *createTodoChangeRecorder(QObject *parent);
Akonadi::ChangeRecorder *createNotesChangeRecorder(QObject *parent);
Akonadi::Monitor *createMailMonitor(QObject *parent);
Akonadi::Monitor *createTodoMonitor(QObject *parent);
Akonadi::Monitor *createNotesMonitor(QObject *parent);
QAbstractItemModel *createMailModel(Akonadi::ChangeRecorder *changeRecorder);
QAbstractItemModel *createTodoModel(Akonadi::ChangeRecorder *changeRecorder);
QAbstractItemModel *createNotesModel(Akonadi::ChangeRecorder *changeRecorder);
QAbstractItemModel *createMailModel(Akonadi::Monitor *monitor);
QAbstractItemModel *createTodoModel(Akonadi::Monitor *monitor);
QAbstractItemModel *createNotesModel(Akonadi::Monitor *monitor);
};
......
......@@ -28,7 +28,7 @@
#include <KConfig>
#include <AkonadiCore/Item>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/Monitor>
#include <KSharedConfig>
#include "trip.h"
......@@ -38,7 +38,7 @@
using namespace Akonadi;
TripModel::TripModel(Akonadi::ChangeRecorder *monitor, QObject *parent)
TripModel::TripModel(Akonadi::Monitor *monitor, QObject *parent)
: MixedTreeModel(monitor, parent), m_monitor(monitor)
{
setCollectionFetchStrategy(MixedTreeModel::FetchNoCollections);
......
......@@ -38,7 +38,7 @@ public:
TripRole = MixedTreeModel::UserRole + 1,
WidgetRole
};
explicit TripModel(Akonadi::ChangeRecorder *monitor, QObject *parent = Q_NULLPTR);
explicit TripModel(Akonadi::Monitor *monitor, QObject *parent = Q_NULLPTR);
bool removeRows(int, int, const QModelIndex & = QModelIndex()) Q_DECL_OVERRIDE;
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
......@@ -63,7 +63,7 @@ private:
mutable QHash<Akonadi::Item::Id, Trip *> m_trips;
mutable QHash<Akonadi::Item::Id, TripWidget *> m_tripWidgets;
CreateTripWidget *m_createWidget;
Akonadi::ChangeRecorder *m_monitor;
Akonadi::Monitor *m_monitor;
};
#endif
......@@ -38,7 +38,7 @@ Q_SIGNALS:
void modelCreated(Akonadi::EntityTreeModel *model);
protected:
Akonadi::EntityTreeModel* getModel(Akonadi::Monitor* monitor, QObject* parent);
virtual Akonadi::EntityTreeModel* getModel(Akonadi::Monitor *monitor, QObject* parent);
private Q_SLOTS:
void collectionsFetched(const Akonadi::Collection::List &list);
......
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