diff --git a/akonadi/calendar/etmcalendar.cpp b/akonadi/calendar/etmcalendar.cpp --- a/akonadi/calendar/etmcalendar.cpp +++ b/akonadi/calendar/etmcalendar.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -214,9 +215,13 @@ , mCalFilterPartStatusProxyModel(0) , mSelectionProxy(0) , mCollectionFilteringEnabled(true) + , mLoadFromModelTimer(new QTimer) , q(qq) { mListensForNewItems = true; + mLoadFromModelTimer->setInterval(0); + mLoadFromModelTimer->setSingleShot(true); + connect(mLoadFromModelTimer, SIGNAL(timeout()), SLOT(loadFromETM())); } void ETMCalendarPrivate::init() @@ -280,7 +285,8 @@ connect(mFilteredETM, SIGNAL(rowsAboutToBeRemoved(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, @@ -549,13 +555,13 @@ void ETMCalendarPrivate::onLayoutChangedInFilteredModel() { clear(); - loadFromETM(); + mLoadFromModelTimer->start(); } void ETMCalendarPrivate::onModelResetInFilteredModel() { clear(); - loadFromETM(); + mLoadFromModelTimer->start(); } void ETMCalendarPrivate::onDataChangedInFilteredModel(const QModelIndex &topLeft, diff --git a/akonadi/calendar/etmcalendar_p.h b/akonadi/calendar/etmcalendar_p.h --- a/akonadi/calendar/etmcalendar_p.h +++ b/akonadi/calendar/etmcalendar_p.h @@ -90,9 +90,9 @@ void init(); void setupFilteredETM(); - void loadFromETM(); public Q_SLOTS: + void loadFromETM(); Akonadi::Item::List itemsFromModel(const QAbstractItemModel *model, const QModelIndex &parentIndex = QModelIndex(), int start = 0, @@ -143,6 +143,7 @@ bool mCollectionFilteringEnabled; QSet mPopulatedCollectionIds; QStringList mMimeTypes; + QTimer *mLoadFromModelTimer; private: ETMCalendar *const q; };