• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • Akonadi
  • TransactionSequence
Public Member Functions | Protected Slots | Protected Member Functions | List of all members
Akonadi::TransactionSequence Class Reference

#include <transactionsequence.h>

Inheritance diagram for Akonadi::TransactionSequence:
Inheritance graph
[legend]

Public Member Functions

 TransactionSequence (QObject *parent=0)
 
 ~TransactionSequence ()
 
void commit ()
 
void rollback ()
 
void setAutomaticCommittingEnabled (bool enable)
 
void setIgnoreJobFailure (KJob *job)
 
- Public Member Functions inherited from Akonadi::Job
 Job (QObject *parent=0)
 
virtual ~Job ()
 
virtual QString errorString () const
 
void start ()
 

Protected Slots

void slotResult (KJob *job)
 
- Protected Slots inherited from Akonadi::Job
virtual void slotResult (KJob *job)
 

Protected Member Functions

bool addSubjob (KJob *job)
 
void doStart ()
 
- Protected Member Functions inherited from Akonadi::Job
virtual void doHandleResponse (const QByteArray &tag, const QByteArray &data)
 
virtual bool doKill ()
 
void emitWriteFinished ()
 
virtual bool removeSubjob (KJob *job)
 

Additional Inherited Members

- Public Types inherited from Akonadi::Job
enum  Error {
  ConnectionFailed = UserDefinedError, ProtocolVersionMismatch, UserCanceled, Unknown,
  UserError = UserDefinedError + 42
}
 
typedef QList< Job * > List
 
- Signals inherited from Akonadi::Job
void aboutToStart (Akonadi::Job *job)
 
void writeFinished (Akonadi::Job *job)
 

Detailed Description

Base class for jobs that need to run a sequence of sub-jobs in a transaction.

As soon as the first subjob is added, the transaction is started. As soon as the last subjob has successfully finished, the transaction is committed. If any subjob fails, the transaction is rolled back.

Alternatively, a TransactionSequence object can be used as a parent object for a set of jobs to achieve the same behaviour without subclassing.

Example:

// Delete a couple of items inside a transaction
Akonadi::TransactionSequence *transaction = new Akonadi::TransactionSequence;
connect( transaction, SIGNAL( result( KJob* ) ), SLOT( transactionFinished( KJob* ) ) );
const Akonadi::Item::List items = ...
foreach ( const Akonadi::Item &item, items ) {
new Akonadi::ItemDeleteJob( item, transaction );
}
...
MyClass::transactionFinished( KJob *job )
{
if ( job->error() )
qDebug() << "Error occurred";
else
qDebug() << "Items deleted successfully";
}
Author
Volker Krause vkrau.nosp@m.se@k.nosp@m.de.or.nosp@m.g

Definition at line 69 of file transactionsequence.h.

Constructor & Destructor Documentation

TransactionSequence::TransactionSequence ( QObject *  parent = 0)
explicit

Creates a new transaction sequence.

Parameters
parentThe parent object.

Definition at line 75 of file transactionsequence.cpp.

TransactionSequence::~TransactionSequence ( )

Destroys the transaction sequence.

Definition at line 80 of file transactionsequence.cpp.

Member Function Documentation

bool TransactionSequence::addSubjob ( KJob *  job)
protectedvirtual

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.

Parameters
jobThe new subjob.

Reimplemented from Akonadi::Job.

Definition at line 84 of file transactionsequence.cpp.

void TransactionSequence::commit ( )

Commits the transaction as soon as all pending sub-jobs finished successfully.

Definition at line 144 of file transactionsequence.cpp.

void TransactionSequence::doStart ( )
protectedvirtual

This method must be reimplemented in the concrete jobs.

It will be called after the job has been started and a connection to the Akonadi backend has been established.

Implements Akonadi::Job.

Definition at line 185 of file transactionsequence.cpp.

void TransactionSequence::rollback ( )

Rolls back the current transaction as soon as possible.

You only need to call this method when you want to roll back due to external reasons (e.g. user cancellation), the transaction is automatically rolled back if one of its subjobs fails.

Since
4.5

Definition at line 203 of file transactionsequence.cpp.

void TransactionSequence::setAutomaticCommittingEnabled ( bool  enable)

Disable automatic committing.

Use this when you want to add jobs to this sequence after execution has been started, usually that is outside of the constructor or the method that creates this transaction sequence.

Note
Calling this method after execution of this job has been started has no effect.
Parameters
enabletrue to enable autocommitting (default), false to disable it
Since
4.5

Definition at line 197 of file transactionsequence.cpp.

void TransactionSequence::setIgnoreJobFailure ( KJob *  job)

Sets which job of the sequence might fail without rolling back the complete transaction.

Parameters
joba job to ignore errors from
Since
4.5

Definition at line 175 of file transactionsequence.cpp.


The documentation for this class was generated from the following files:
  • transactionsequence.h
  • transactionsequence.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:29 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal