[Kde-pim] KDE/kdepimlibs/akonadi
Stephen Kelly
steveire at gmail.com
Wed Dec 30 17:40:46 GMT 2009
SVN commit 1067822 by skelly:
Allow setting the Session used by the monitor, and use the same session in EntityTreeModel.
This is an API change for the ETM (which is @since 4.4). I'll update kdepim, the porting branch, playground and mailody.
I'm not sure of anything else that uses this.
CCMAIL: kde-pim at kde.org
M +1 -1 collectioncombobox.cpp
M +1 -1 collectiondialog.cpp
M +3 -3 contact/contactcompletionmodel.cpp
M +1 -1 contact/contactcompletionmodel_p.h
M +6 -1 entitycache.cpp
M +11 -5 entitycache_p.h
M +4 -6 entitytreemodel.cpp
M +2 -2 entitytreemodel.h
M +2 -2 entitytreemodel_p.cpp
M +1 -1 entitytreemodel_p.h
M +19 -0 monitor.cpp
M +11 -0 monitor.h
M +3 -2 monitor_p.cpp
M +2 -1 monitor_p.h
M +6 -5 tests/entitytreemodeltest.cpp
--- trunk/KDE/kdepimlibs/akonadi/collectioncombobox.cpp #1067821:1067822
@@ -51,7 +51,7 @@
mMonitor->fetchCollection( true );
mMonitor->setCollectionMonitored( Akonadi::Collection::root() );
- mModel = new EntityTreeModel( Session::defaultSession(), mMonitor, mParent );
+ mModel = new EntityTreeModel( mMonitor, mParent );
mModel->setItemPopulationStrategy( EntityTreeModel::NoItemPopulation );
KDescendantsProxyModel *proxyModel = new KDescendantsProxyModel( parent );
--- trunk/KDE/kdepimlibs/akonadi/collectiondialog.cpp #1067821:1067822
@@ -68,7 +68,7 @@
mMonitor->fetchCollection( true );
mMonitor->setCollectionMonitored( Akonadi::Collection::root() );
- mModel = new EntityTreeModel( Session::defaultSession(), mMonitor, mParent );
+ mModel = new EntityTreeModel( mMonitor, mParent );
mModel->setItemPopulationStrategy( EntityTreeModel::NoItemPopulation );
baseModel = mModel;
}
--- trunk/KDE/kdepimlibs/akonadi/contact/contactcompletionmodel.cpp #1067821:1067822
@@ -45,7 +45,7 @@
monitor->setCollectionMonitored( Akonadi::Collection::root() );
monitor->setMimeTypeMonitored( KABC::Addressee::mimeType() );
- ContactCompletionModel *model = new ContactCompletionModel( Session::defaultSession(), monitor );
+ ContactCompletionModel *model = new ContactCompletionModel( monitor );
KDescendantsProxyModel *descModel = new KDescendantsProxyModel( model );
descModel->setSourceModel( model );
@@ -60,8 +60,8 @@
return mSelf;
}
-ContactCompletionModel::ContactCompletionModel( Session *session, ChangeRecorder *monitor, QObject *parent )
- : EntityTreeModel( session, monitor, parent )
+ContactCompletionModel::ContactCompletionModel( ChangeRecorder *monitor, QObject *parent )
+ : EntityTreeModel( monitor, parent )
{
}
--- trunk/KDE/kdepimlibs/akonadi/contact/contactcompletionmodel_p.h #1067821:1067822
@@ -38,7 +38,7 @@
EmailColumn ///< The preferred email of the contact.
};
- ContactCompletionModel( Session *session, ChangeRecorder *monitor, QObject *parent = 0 );
+ ContactCompletionModel( ChangeRecorder *monitor, QObject *parent = 0 );
virtual ~ContactCompletionModel();
virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const;
--- trunk/KDE/kdepimlibs/akonadi/entitycache.cpp #1067821:1067822
@@ -21,8 +21,13 @@
using namespace Akonadi;
-EntityCacheBase::EntityCacheBase( QObject *parent ) : QObject( parent )
+EntityCacheBase::EntityCacheBase( Session *_session ) : QObject( _session ), session(_session)
{
}
+void EntityCacheBase::setSession( Session *_session )
+{
+ session = _session;
+}
+
#include "entitycache_p.moc"
--- trunk/KDE/kdepimlibs/akonadi/entitycache_p.h #1067821:1067822
@@ -26,6 +26,7 @@
#include <akonadi/collection.h>
#include <akonadi/collectionfetchjob.h>
#include <akonadi/collectionfetchscope.h>
+#include <akonadi/session.h>
#include <qobject.h>
#include <QQueue>
@@ -44,8 +45,13 @@
{
Q_OBJECT
public:
- explicit EntityCacheBase (QObject * parent = 0);
+ explicit EntityCacheBase ( Session * parent = 0 );
+ void setSession(Session *session);
+
+ protected:
+ Session *session;
+
signals:
void dataAvailable();
@@ -71,8 +77,8 @@
class EntityCache : public EntityCacheBase
{
public:
- explicit EntityCache( int maxCapacity, QObject *parent = 0 ) :
- EntityCacheBase( parent ),
+ explicit EntityCache( int maxCapacity, Session *session = 0 ) :
+ EntityCacheBase( session ),
mCapacity( maxCapacity )
{}
@@ -189,7 +195,7 @@
inline FetchJob* createFetchJob( typename T::Id id )
{
- return new FetchJob( T( id ), this );
+ return new FetchJob( T( id ), session );
}
/** Tries to reduce the cache size until at least one more object fits in. */
@@ -226,7 +232,7 @@
template<> inline CollectionFetchJob* EntityCache<Collection, CollectionFetchJob, CollectionFetchScope>::createFetchJob( Collection::Id id )
{
- return new CollectionFetchJob( Collection( id ), CollectionFetchJob::Base, this );
+ return new CollectionFetchJob( Collection( id ), CollectionFetchJob::Base, session );
}
typedef EntityCache<Collection, CollectionFetchJob, CollectionFetchScope> CollectionCache;
--- trunk/KDE/kdepimlibs/akonadi/entitytreemodel.cpp #1067821:1067822
@@ -53,25 +53,23 @@
using namespace Akonadi;
-EntityTreeModel::EntityTreeModel( Session *session,
- ChangeRecorder *monitor,
+EntityTreeModel::EntityTreeModel( ChangeRecorder *monitor,
QObject *parent
)
: QAbstractItemModel( parent ),
d_ptr( new EntityTreeModelPrivate( this ) )
{
Q_D( EntityTreeModel );
- d->init( monitor, session );
+ d->init( monitor );
}
-EntityTreeModel::EntityTreeModel( Session *session,
- ChangeRecorder *monitor,
+EntityTreeModel::EntityTreeModel( ChangeRecorder *monitor,
EntityTreeModelPrivate *d,
QObject *parent )
: QAbstractItemModel( parent ),
d_ptr( d )
{
- d->init(monitor, session);
+ d->init(monitor );
}
EntityTreeModel::~EntityTreeModel()
--- trunk/KDE/kdepimlibs/akonadi/entitytreemodel.h #1067821:1067822
@@ -363,7 +363,7 @@
* @param monitor The ChangeRecorder whose entities should be represented in the model.
* @param parent The parent object.
*/
- EntityTreeModel( Session *session, ChangeRecorder *monitor, QObject *parent = 0 );
+ explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 );
/**
* Destroys the entity tree model.
@@ -515,7 +515,7 @@
//@cond PRIVATE
Q_DECLARE_PRIVATE( EntityTreeModel )
EntityTreeModelPrivate * d_ptr;
- EntityTreeModel( Session *session, ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
+ EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
//@endcond
private:
--- trunk/KDE/kdepimlibs/akonadi/entitytreemodel_p.cpp #1067821:1067822
@@ -52,11 +52,11 @@
{
}
-void EntityTreeModelPrivate::init( ChangeRecorder *monitor, Session *session )
+void EntityTreeModelPrivate::init( ChangeRecorder *monitor )
{
Q_Q( EntityTreeModel );
m_monitor = monitor;
- m_session = session;
+ m_session = m_monitor->session();
m_monitor->setChangeRecordingEnabled( false );
--- trunk/KDE/kdepimlibs/akonadi/entitytreemodel_p.h #1067821:1067822
@@ -70,7 +70,7 @@
Recursive
};
- void init( ChangeRecorder *monitor, Session *session );
+ void init( ChangeRecorder *monitor );
void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel );
void fetchItems( const Collection &collection );
--- trunk/KDE/kdepimlibs/akonadi/monitor.cpp #1067821:1067822
@@ -166,6 +166,25 @@
return d->monitorAll;
}
+void Monitor::setSession( Akonadi::Session *session )
+{
+ if (session == d->session)
+ return;
+
+ if (!session)
+ d->session = Session::defaultSession();
+ else
+ d->session = session;
+
+ d->itemCache.setSession(d->session);
+ d->collectionCache.setSession(d->session);
+}
+
+Session* Monitor::session() const
+{
+ return d->session;
+}
+
#undef d
#include "monitor.moc"
--- trunk/KDE/kdepimlibs/akonadi/monitor.h #1067821:1067822
@@ -242,6 +242,17 @@
*/
bool isAllMonitored() const;
+ /**
+ * Sets the session used by the Monitor to communicate with the %Akonadi server.
+ * If not set, the Akonadi::Session::defaultSession is used.
+ */
+ void setSession(Akonadi::Session *session);
+
+ /**
+ * Returns the Session used by the monitor to communicate with Akonadi.
+ */
+ Session* session() const;
+
Q_SIGNALS:
/**
* This signal is emitted if a monitored item has changed, e.g. item parts have been modified.
--- trunk/KDE/kdepimlibs/akonadi/monitor_p.cpp #1067821:1067822
@@ -37,8 +37,9 @@
q_ptr( parent ),
nm( 0 ),
monitorAll( false ),
- collectionCache( 3*PipelineSize ), // needs to be at least 3x pipeline size for the collection move case
- itemCache( PipelineSize ), // needs to be at least 1x pipeline size
+ session( Session::defaultSession() ),
+ collectionCache( 3*PipelineSize, session ), // needs to be at least 3x pipeline size for the collection move case
+ itemCache( PipelineSize, session ), // needs to be at least 1x pipeline size
fetchCollection( false ),
fetchCollectionStatistics( false ),
useRefCounting( false )
--- trunk/KDE/kdepimlibs/akonadi/monitor_p.h #1067821:1067822
@@ -61,6 +61,7 @@
QList<QByteArray> sessions;
ItemFetchScope mItemFetchScope;
CollectionFetchScope mCollectionFetchScope;
+ Session *session;
CollectionCache collectionCache;
ItemCache itemCache;
QQueue<NotificationMessage> pendingNotifications;
@@ -210,7 +211,7 @@
void fetchStatistics( Collection::Id colId )
{
- CollectionStatisticsJob *job = new CollectionStatisticsJob( Collection( colId ), q_ptr );
+ CollectionStatisticsJob *job = new CollectionStatisticsJob( Collection( colId ), session );
QObject::connect( job, SIGNAL(result(KJob*)), q_ptr, SLOT(slotStatisticsChangedFinished(KJob*)) );
}
--- trunk/KDE/kdepimlibs/akonadi/tests/entitytreemodeltest.cpp #1067821:1067822
@@ -43,7 +43,7 @@
Q_OBJECT
Q_DECLARE_PRIVATE(PublicETM)
public:
- PublicETM( Session *session, ChangeRecorder *monitor, QObject *parent );
+ PublicETM( ChangeRecorder *monitor, QObject *parent );
EntityTreeModelPrivate *privateClass() const { return d_ptr; }
};
@@ -56,12 +56,12 @@
PublicETMPrivate( PublicETM *p );
};
-PublicETM::PublicETM( Session *session, ChangeRecorder *monitor, QObject *parent )
- : EntityTreeModel( session, monitor, new PublicETMPrivate( this ), parent )
+PublicETM::PublicETM( ChangeRecorder *monitor, QObject *parent )
+ : EntityTreeModel( monitor, new PublicETMPrivate( this ), parent )
{
}
-PublicETMPrivate::PublicETMPrivate(PublicETM *p)
+PublicETMPrivate::PublicETMPrivate( PublicETM *p )
: EntityTreeModelPrivate( p )
{
}
@@ -138,8 +138,9 @@
{
FakeMonitor *fakeMonitor = new FakeMonitor(this);
+ fakeMonitor->setSession( m_fakeSession );
fakeMonitor->setCollectionMonitored(Collection::root());
- m_model = new PublicETM( m_fakeSession, fakeMonitor, this );
+ m_model = new PublicETM( fakeMonitor, this );
m_model->setItemPopulationStrategy( EntityTreeModel::NoItemPopulation );
m_modelSpy = new ModelSpy(this);
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
More information about the kde-pim
mailing list