24 #include <akonadi/kmime/messagestatus.h>
25 #include <KLocalizedString>
27 #include <Akonadi/ItemFetchJob>
28 #include <Akonadi/ItemFetchScope>
29 #include <Akonadi/ItemModifyJob>
46 if (mListItem.isEmpty()) {
53 void CreateTaskJob::fetchItems()
55 Akonadi::ItemFetchJob *job =
new Akonadi::ItemFetchJob( mListItem,
this );
56 job->fetchScope().fetchFullPayload(
true );
57 job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
59 connect( job, SIGNAL(result(
KJob*)), SLOT(itemFetchJobDone(
KJob*)) );
62 void CreateTaskJob::itemFetchJobDone(
KJob *job)
65 qDebug() << job->errorString();
69 Akonadi::ItemFetchJob *fetchjob = qobject_cast<Akonadi::ItemFetchJob *>(job);
70 const Akonadi::Item::List lst = fetchjob->items();
76 bool parentStatus =
false;
79 const Akonadi::Item first = lst.at(0);
80 Akonadi::MessageStatus pStatus;
81 pStatus.setStatusFromFlags( first.flags() );
82 if ( pStatus & Akonadi::MessageStatus::statusToAct() )
87 Akonadi::Item::List itemsToModify;
88 foreach(
const Akonadi::Item &it, lst ) {
92 Akonadi::MessageStatus itemStatus;
93 itemStatus.setStatusFromFlags( it.flags() );
94 if ( itemStatus & Akonadi::MessageStatus::statusToAct() )
98 if ( myStatus != parentStatus )
101 Akonadi::Item item( it );
102 const Akonadi::Item::Flag flag = *(Akonadi::MessageStatus::statusToAct().statusFlags().begin());
103 if ( item.hasFlag( flag ) ) {
104 item.clearFlag( flag );
105 itemsToModify.push_back( item );
111 item.setFlag( flag );
112 itemsToModify.push_back( item );
117 if ( itemsToModify.isEmpty() ) {
118 slotModifyItemDone( 0 );
120 Akonadi::ItemModifyJob *modifyJob =
new Akonadi::ItemModifyJob( itemsToModify,
this );
121 modifyJob->disableRevisionCheck();
122 modifyJob->setIgnorePayload(
true );
123 connect( modifyJob, SIGNAL(result(
KJob*)),
this, SLOT(slotModifyItemDone(
KJob*)) );
127 void CreateTaskJob::slotModifyItemDone(
KJob *job)
130 if (job && job->error()) {
131 qDebug()<<
" error "<<job->errorString();
CreateTaskJob(const Akonadi::Item::List &items, QObject *parent=0)