Changeset View
Changeset View
Standalone View
Standalone View
akonadi/calendar/etmcalendar.cpp
Show All 37 Lines | |||||
#include <akonadi/collectionfetchjob.h> | #include <akonadi/collectionfetchjob.h> | ||||
#include <akonadi/collectionfetchscope.h> | #include <akonadi/collectionfetchscope.h> | ||||
#include <akonadi/collectionidentificationattribute.h> | #include <akonadi/collectionidentificationattribute.h> | ||||
#include <KSelectionProxyModel> | #include <KSelectionProxyModel> | ||||
#include <KDescendantsProxyModel> | #include <KDescendantsProxyModel> | ||||
#include <QItemSelectionModel> | #include <QItemSelectionModel> | ||||
#include <QTreeView> | #include <QTreeView> | ||||
#include <QTimer> | |||||
#include <recursivecollectionfilterproxymodel.h> | #include <recursivecollectionfilterproxymodel.h> | ||||
#include <mimetypechecker.h> | #include <mimetypechecker.h> | ||||
using namespace Akonadi; | using namespace Akonadi; | ||||
using namespace KCalCore; | using namespace KCalCore; | ||||
CalendarNamespaceProxyModel::CalendarNamespaceProxyModel(QObject *parent) | CalendarNamespaceProxyModel::CalendarNamespaceProxyModel(QObject *parent) | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | ETMCalendarPrivate::ETMCalendarPrivate(ETMCalendar *qq) : CalendarBasePrivate(qq) | ||||
, mETM(0) | , mETM(0) | ||||
, mFilteredETM(0) | , mFilteredETM(0) | ||||
, mCheckableProxyModel(0) | , mCheckableProxyModel(0) | ||||
, mCollectionProxyModel(0) | , mCollectionProxyModel(0) | ||||
, mCalFilterProxyModel(0) | , mCalFilterProxyModel(0) | ||||
, mCalFilterPartStatusProxyModel(0) | , mCalFilterPartStatusProxyModel(0) | ||||
, mSelectionProxy(0) | , mSelectionProxy(0) | ||||
, mCollectionFilteringEnabled(true) | , mCollectionFilteringEnabled(true) | ||||
, mLoadFromModelTimer(new QTimer) | |||||
, q(qq) | , q(qq) | ||||
{ | { | ||||
mListensForNewItems = true; | mListensForNewItems = true; | ||||
mLoadFromModelTimer->setInterval(0); | |||||
mLoadFromModelTimer->setSingleShot(true); | |||||
connect(mLoadFromModelTimer, SIGNAL(timeout()), SLOT(loadFromETM())); | |||||
} | } | ||||
void ETMCalendarPrivate::init() | void ETMCalendarPrivate::init() | ||||
{ | { | ||||
if (!mETM) { | if (!mETM) { | ||||
Akonadi::Session *session = new Akonadi::Session("ETMCalendar", q); | Akonadi::Session *session = new Akonadi::Session("ETMCalendar", q); | ||||
Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder(q); | Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder(q); | ||||
connect(monitor, SIGNAL(collectionChanged(Akonadi::Collection,QSet<QByteArray>)), | connect(monitor, SIGNAL(collectionChanged(Akonadi::Collection,QSet<QByteArray>)), | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | connect(mFilteredETM, SIGNAL(layoutChanged()), | ||||
SLOT(onLayoutChangedInFilteredModel())); | SLOT(onLayoutChangedInFilteredModel())); | ||||
connect(mFilteredETM, SIGNAL(modelReset()), | connect(mFilteredETM, SIGNAL(modelReset()), | ||||
SLOT(onModelResetInFilteredModel())); | SLOT(onModelResetInFilteredModel())); | ||||
connect(mFilteredETM, SIGNAL(rowsInserted(QModelIndex,int,int)), | connect(mFilteredETM, SIGNAL(rowsInserted(QModelIndex,int,int)), | ||||
SLOT(onRowsInsertedInFilteredModel(QModelIndex,int,int))); | SLOT(onRowsInsertedInFilteredModel(QModelIndex,int,int))); | ||||
connect(mFilteredETM, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), | connect(mFilteredETM, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), | ||||
SLOT(onRowsAboutToBeRemovedInFilteredModel(QModelIndex,int,int))); | SLOT(onRowsAboutToBeRemovedInFilteredModel(QModelIndex,int,int))); | ||||
loadFromETM(); | //Give the caller a chance to call setCollectionFilteringEnabled before loading data | ||||
mLoadFromModelTimer->start(); | |||||
} | } | ||||
void ETMCalendarPrivate::onCollectionChanged(const Akonadi::Collection &collection, | void ETMCalendarPrivate::onCollectionChanged(const Akonadi::Collection &collection, | ||||
const QSet<QByteArray> &attributeNames) | const QSet<QByteArray> &attributeNames) | ||||
{ | { | ||||
Q_ASSERT(collection.isValid()); | Q_ASSERT(collection.isValid()); | ||||
// Is the collection changed to read-only, we update all Incidences | // Is the collection changed to read-only, we update all Incidences | ||||
if (attributeNames.contains("AccessRights")) { | if (attributeNames.contains("AccessRights")) { | ||||
▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | void ETMCalendarPrivate::onRowsMoved(const QModelIndex &sourceParent, | ||||
Q_UNUSED(sourceEnd); | Q_UNUSED(sourceEnd); | ||||
Q_UNUSED(destinationParent); | Q_UNUSED(destinationParent); | ||||
Q_UNUSED(destinationRow); | Q_UNUSED(destinationRow); | ||||
} | } | ||||
void ETMCalendarPrivate::onLayoutChangedInFilteredModel() | void ETMCalendarPrivate::onLayoutChangedInFilteredModel() | ||||
{ | { | ||||
clear(); | clear(); | ||||
loadFromETM(); | mLoadFromModelTimer->start(); | ||||
} | } | ||||
void ETMCalendarPrivate::onModelResetInFilteredModel() | void ETMCalendarPrivate::onModelResetInFilteredModel() | ||||
{ | { | ||||
clear(); | clear(); | ||||
loadFromETM(); | mLoadFromModelTimer->start(); | ||||
} | } | ||||
void ETMCalendarPrivate::onDataChangedInFilteredModel(const QModelIndex &topLeft, | void ETMCalendarPrivate::onDataChangedInFilteredModel(const QModelIndex &topLeft, | ||||
const QModelIndex &bottomRight) | const QModelIndex &bottomRight) | ||||
{ | { | ||||
Q_ASSERT(topLeft.row() <= bottomRight.row()); | Q_ASSERT(topLeft.row() <= bottomRight.row()); | ||||
const int endRow = bottomRight.row(); | const int endRow = bottomRight.row(); | ||||
QModelIndex i(topLeft); | QModelIndex i(topLeft); | ||||
▲ Show 20 Lines • Show All 268 Lines • Show Last 20 Lines |