[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akonadi/libakonadi
From: Volker Krause <volker.krause () rwth-aachen ! de>
Date: 2006-09-26 13:51:41
Message-ID: 1159278701.892044.6693.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 588622 by vkrause:
No need to add jobs to a JobQueue manually anymore.
M +0 -8 collectionmodel.cpp
M +7 -3 job.h
M +9 -2 jobqueue.cpp
M +3 -5 jobqueue.h
--- trunk/KDE/kdepim/akonadi/libakonadi/collectionmodel.cpp #588621:588622
@@ -77,7 +77,6 @@
// start a list job
CollectionListJob *job = new CollectionListJob( Collection::prefix(), true, \
d->queue ); connect( job, SIGNAL(done(PIM::Job*)), SLOT(listDone(PIM::Job*)) );
- d->queue->addJob( job );
// monitor collection changes
d->monitor = new Monitor();
@@ -224,7 +223,6 @@
// update
CollectionStatusJob *job = new CollectionStatusJob( path, d->queue );
connect( job, SIGNAL(done(PIM::Job*)), SLOT(updateDone(PIM::Job*)) );
- d->queue->addJob( job );
} else {
// new collection
int index = path.lastIndexOf( Collection::delimiter() );
@@ -237,11 +235,9 @@
// re-list parent non-recursively
CollectionListJob *job = new CollectionListJob( parent, false, d->queue );
connect( job, SIGNAL(done(PIM::Job*)), SLOT(listDone(PIM::Job*)) );
- d->queue->addJob( job );
// list the new collection recursively
job = new CollectionListJob( path, true, d->queue );
connect( job, SIGNAL(done(PIM::Job*)), SLOT(listDone(PIM::Job*)) );
- d->queue->addJob( job );
}
}
@@ -334,7 +330,6 @@
if ( col->type() != Collection::VirtualParent ) {
CollectionStatusJob* csjob = new CollectionStatusJob( col->path(), d->queue \
);
connect( csjob, SIGNAL(done(PIM::Job*)), SLOT(updateDone(PIM::Job*)) );
- d->queue->addJob( csjob );
}
}
@@ -359,7 +354,6 @@
newPath = d->editedCollection->parent() + Collection::delimiter() + \
d->editedCollection->name().toLatin1(); // TODO: to utf7
CollectionRenameJob *job = new CollectionRenameJob( d->editedCollection->path(), \
newPath, d->queue ); connect( job, SIGNAL(done(PIM::Job*)), \
SLOT(editDone(PIM::Job*)) );
- d->queue->addJob( job );
emit dataChanged( index, index );
return true;
}
@@ -437,7 +431,6 @@
// start creation job
CollectionCreateJob *job = new CollectionCreateJob( d->editedCollection->path(), \
d->queue ); connect( job, SIGNAL(done(PIM::Job*)), SLOT(editDone(PIM::Job*)) );
- d->queue->addJob( job );
d->currentEdit = Private::Create;
return true;
@@ -515,7 +508,6 @@
if ( !item.isEmpty() && item.at( item.size() - 1 ) == 0 )
item.resize( item.size() - 1 );
ItemAppendJob *job = new ItemAppendJob( path, item, type.toLatin1(), d->queue );
- d->queue->addJob( job );
return true;
}
--- trunk/KDE/kdepim/akonadi/libakonadi/job.h #588621:588622
@@ -256,12 +256,16 @@
*/
virtual void doHandleResponse( const QByteArray &tag, const QByteArray &data );
- private:
/**
- Adds the given job as a sub job.
+ Adds the given job as a subjob to this job. This method is automatically \
called + if you construct a job using another job as parent object.
+ The base implementation does the necessary setup to share the network \
connection + with the backend.
+ @param job The new subjob.
*/
- void addSubJob( Job* job );
+ virtual void addSubJob( Job* job );
+ private:
void handleResponse( const QByteArray &tag, const QByteArray &data );
private slots:
--- trunk/KDE/kdepim/akonadi/libakonadi/jobqueue.cpp #588621:588622
@@ -21,6 +21,7 @@
#include <QDebug>
#include <QQueue>
+#include <QTimer>
using namespace PIM;
@@ -47,8 +48,9 @@
delete d;
}
-void PIM::JobQueue::addJob( PIM::Job * job )
+void PIM::JobQueue::addSubJob( PIM::Job * job )
{
+ Job::addSubJob( job );
d->queue.enqueue( job );
startNext();
}
@@ -66,8 +68,13 @@
startNext();
}
-void PIM::JobQueue::startNext( )
+void PIM::JobQueue::startNext()
{
+ QTimer::singleShot( 0, this, SLOT(slotStartNext()) );
+}
+
+void PIM::JobQueue::slotStartNext()
+{
if ( !d->isStarted || d->jobRunning || isEmpty() )
return;
d->jobRunning = true;
--- trunk/KDE/kdepim/akonadi/libakonadi/jobqueue.h #588621:588622
@@ -47,25 +47,23 @@
virtual ~JobQueue();
/**
- Adds the given job to the queue. Added jobs will be started automatically.
- */
- void addJob( PIM::Job* job );
-
- /**
Returns true if there are no jobs in the queue.
*/
bool isEmpty() const;
protected:
virtual void doStart();
+ virtual void addSubJob( PIM::Job *job );
private:
// part of the Job API, hide it for JobQueue
virtual void start();
+ // uses a singleshot timer to start the job, makes sure its fully constructed
void startNext();
private slots:
void jobDone( PIM::Job* job );
+ void slotStartNext();
private:
JobQueuePrivate *d;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic