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

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • followupreminder
followupremindercreatejob.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "followupremindercreatejob.h"
19 #include "agents/followupreminderagent/followupreminderutil.h"
20 #include <KCalCore/Todo>
21 #include <KLocalizedString>
22 #include <akonadi/itemcreatejob.h>
23 
24 //KF5 move to messagecomposer
25 
26 FollowupReminderCreateJob::FollowupReminderCreateJob(QObject *parent)
27  : KJob(parent),
28  mInfo(new FollowUpReminder::FollowUpReminderInfo)
29 {
30 
31 }
32 
33 FollowupReminderCreateJob::~FollowupReminderCreateJob()
34 {
35  delete mInfo;
36 }
37 
38 void FollowupReminderCreateJob::setFollowUpReminderDate(const QDate &date)
39 {
40  mInfo->setFollowUpReminderDate(date);
41 }
42 
43 void FollowupReminderCreateJob::setOriginalMessageItemId(Akonadi::Entity::Id value)
44 {
45  mInfo->setOriginalMessageItemId(value);
46 }
47 
48 void FollowupReminderCreateJob::setMessageId(const QString &messageId)
49 {
50  mInfo->setMessageId(messageId);
51 }
52 
53 void FollowupReminderCreateJob::setTo(const QString &to)
54 {
55  mInfo->setTo(to);
56 }
57 
58 void FollowupReminderCreateJob::setSubject(const QString &subject)
59 {
60  mInfo->setSubject(subject);
61 }
62 
63 void FollowupReminderCreateJob::setCollectionToDo(const Akonadi::Collection &collection)
64 {
65  mCollection = collection;
66 }
67 
68 void FollowupReminderCreateJob::start()
69 {
70  if (mInfo->isValid()) {
71  if (mCollection.isValid()) {
72  KCalCore::Todo::Ptr todo( new KCalCore::Todo );
73  todo->setSummary(i18n("Wait answer from \"%1\" send to \"%2\"").arg(mInfo->subject()).arg(mInfo->to()));
74  Akonadi::Item newTodoItem;
75  newTodoItem.setMimeType( KCalCore::Todo::todoMimeType() );
76  newTodoItem.setPayload<KCalCore::Todo::Ptr>( todo );
77 
78  Akonadi::ItemCreateJob *createJob = new Akonadi::ItemCreateJob(newTodoItem, mCollection);
79  connect(createJob, SIGNAL(result(KJob*)), this, SLOT(slotCreateNewTodo(KJob*)));
80  } else {
81  writeFollowupReminderInfo();
82  }
83  } else {
84  qDebug()<<"FollowupReminderCreateJob info not valid ";
85  Q_EMIT emitResult();
86  return;
87  }
88 }
89 
90 void FollowupReminderCreateJob::slotCreateNewTodo(KJob *job)
91 {
92  if ( job->error() ) {
93  qDebug() << "Error during create new Todo "<<job->errorString();
94  } else {
95  Akonadi::ItemCreateJob *createJob = qobject_cast<Akonadi::ItemCreateJob *>(job);
96  mInfo->setTodoId(createJob->item().id());
97  }
98  writeFollowupReminderInfo();
99 }
100 
101 void FollowupReminderCreateJob::writeFollowupReminderInfo()
102 {
103  FollowUpReminder::FollowUpReminderUtil::writeFollowupReminderInfo(FollowUpReminder::FollowUpReminderUtil::defaultConfig(), mInfo, true);
104  Q_EMIT emitResult();
105 }
FollowupReminderCreateJob::setOriginalMessageItemId
void setOriginalMessageItemId(Akonadi::Item::Id value)
Definition: followupremindercreatejob.cpp:43
followupremindercreatejob.h
FollowupReminderCreateJob::FollowupReminderCreateJob
FollowupReminderCreateJob(QObject *parent=0)
Definition: followupremindercreatejob.cpp:26
date
time_t date() const
FollowupReminderCreateJob::setSubject
void setSubject(const QString &subject)
Definition: followupremindercreatejob.cpp:58
messageId
QString messageId() const
FollowupReminderCreateJob::~FollowupReminderCreateJob
~FollowupReminderCreateJob()
Definition: followupremindercreatejob.cpp:33
QObject
FollowupReminderCreateJob::setFollowUpReminderDate
void setFollowUpReminderDate(const QDate &date)
Definition: followupremindercreatejob.cpp:38
to
QString to() const
subject
QString subject() const
QDate
QString
FollowupReminderCreateJob::start
void start()
Definition: followupremindercreatejob.cpp:68
FollowupReminderCreateJob::setMessageId
void setMessageId(const QString &messageId)
Definition: followupremindercreatejob.cpp:48
FollowupReminderCreateJob::setCollectionToDo
void setCollectionToDo(const Akonadi::Collection &collection)
Definition: followupremindercreatejob.cpp:63
KJob
FollowupReminderCreateJob::setTo
void setTo(const QString &to)
Definition: followupremindercreatejob.cpp:53
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

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