Commit fe52d9cb authored by Laurent Montel's avatar Laurent Montel 😁

create followupreminder on existing message

parent d142a19c
......@@ -16,7 +16,7 @@
*/
#include "createfollowupreminderonexistingmessagejob.h"
#include "../followupreminder/followupremindercreatejob.h"
#include <akonadi/itemfetchjob.h>
#include <Akonadi/ItemFetchScope>
#include <KMime/Message>
......@@ -65,10 +65,48 @@ void CreateFollowupReminderOnExistingMessageJob::itemFetchJobDone(KJob* job)
return;
}
KMime::Message::Ptr msg = mMessageItem.payload<KMime::Message::Ptr>();
//TODO create followupreminderjob
if (msg) {
FollowupReminderCreateJob *reminderJob = new FollowupReminderCreateJob(this);
KMime::Headers::MessageID *messageID = msg->messageID(false);
if (messageID) {
const QString messageIdStr = messageID->asUnicodeString();
reminderJob->setMessageId(messageIdStr);
} else {
qDebug()<<" missing messageId";
delete reminderJob;
deleteLater();
return;
}
reminderJob->setFollowUpReminderDate(mDate);
reminderJob->setCollectionToDo(mCollection);
reminderJob->setOriginalMessageItemId(mMessageItem.id());
KMime::Headers::To *to = msg->to(false);
if (to) {
reminderJob->setTo(to->asUnicodeString());
}
KMime::Headers::Subject *subject = msg->subject(false);
if (subject) {
reminderJob->setSubject(subject->asUnicodeString());
}
connect(reminderJob,SIGNAL(result(KJob*)), this, SLOT(slotReminderDone(KJob*)));
reminderJob->start();
} else {
qDebug()<<" no message found";
deleteLater();
}
}
void CreateFollowupReminderOnExistingMessageJob::slotReminderDone(KJob* job)
{
if ( job->error() ) {
qDebug()<<"CreateFollowupReminderOnExistingMessageJob::slotReminderDone :"<<job->errorString();
}
deleteLater();
}
Akonadi::Collection CreateFollowupReminderOnExistingMessageJob::collection() const
{
return mCollection;
......
......@@ -44,8 +44,8 @@ public:
bool canStart() const;
private Q_SLOTS:
void itemFetchJobDone(KJob *job);
void itemFetchJobDone(KJob *job);
void slotReminderDone(KJob *job);
private:
void doStart();
Akonadi::Collection mCollection;
......
......@@ -2911,6 +2911,7 @@ void KMMainWidget::showMessagePopup(const Akonadi::Item&msg ,const KUrl&url,cons
menu->addSeparator();
menu->addAction( mMsgView->openBlockableItems());
}
menu->addAction( mMsgActions->addFollowupReminderAction() );
if (kmkernel->allowToDebugBalooSupport()) {
menu->addSeparator();
menu->addAction( mMsgActions->debugBalooAction() );
......
......@@ -590,6 +590,7 @@ void KMReaderMainWin::showMessagePopup(const Akonadi::Item&msg ,const KUrl&url,c
menu->addSeparator();
menu->addAction( mReaderWin->openBlockableItems());
}
menu->addAction( mMsgActions->addFollowupReminderAction() );
if (kmkernel->allowToDebugBalooSupport()) {
menu->addSeparator();
menu->addAction( mMsgActions->debugBalooAction() );
......
......@@ -36,6 +36,9 @@
#include "pimcommon/baloodebug/baloodebugdialog.h"
#include "followupreminder/followupreminderselectdatedialog.h"
#include "job/createfollowupreminderonexistingmessagejob.h"
#include <akonadi/itemfetchjob.h>
#include <akonadi/kmime/messageparts.h>
#include <Akonadi/ChangeRecorder>
......@@ -69,6 +72,7 @@ MessageActions::MessageActions( KActionCollection *ac, QWidget *parent )
mRedirectAction( 0 ),
mPrintPreviewAction( 0 ),
mCustomTemplatesMenu( 0 ),
mAddFollowupReminderAction( 0 ),
mDebugBalooAction(0)
{
mReplyActionMenu = new KActionMenu( KIcon(QLatin1String("mail-reply-sender")), i18nc("Message->","&Reply"), this );
......@@ -210,6 +214,9 @@ MessageActions::MessageActions( KActionCollection *ac, QWidget *parent )
mDebugBalooAction = new QAction(QLatin1String("Debug Baloo..."), this);
connect( mDebugBalooAction, SIGNAL(triggered(bool)), this, SLOT(slotDebugBaloo()) );
mAddFollowupReminderAction = new KAction(i18n("Add Followup Reminder..."), this );
ac->addAction( QLatin1String("message_followup_reminder"), mAddFollowupReminderAction );
connect( mAddFollowupReminderAction, SIGNAL(triggered(bool)),this, SLOT(slotAddFollowupReminder()) );
updateActions();
}
......@@ -674,3 +681,20 @@ void MessageActions::slotDebugBaloo()
dlg->doSearch();
dlg->show();
}
void MessageActions::slotAddFollowupReminder()
{
if (!mCurrentItem.isValid() )
return;
QPointer<FollowUpReminderSelectDateDialog> dlg = new FollowUpReminderSelectDateDialog;
if (dlg->exec()) {
const QDate date = dlg->selectedDate();
CreateFollowupReminderOnExistingMessageJob *job = new CreateFollowupReminderOnExistingMessageJob(this);
job->setDate(date);
job->setCollection(dlg->collection());
job->setMessageItem(mCurrentItem);
job->start();
}
delete dlg;
}
......@@ -84,6 +84,7 @@ public:
KAction* printAction() const { return mPrintAction; }
KAction* printPreviewAction() const { return mPrintPreviewAction; }
KAction* listFilterAction() const { return mListFilterAction; }
KAction* addFollowupReminderAction() const { return mAddFollowupReminderAction; }
KActionMenu* mailingListActionMenu() const { return mMailingListActionMenu; }
TemplateParser::CustomTemplatesMenu* customTemplatesMenu() const;
......@@ -132,6 +133,7 @@ private slots:
void slotConfigureWebShortcuts();
void slotDebugBaloo();
void slotAddFollowupReminder();
private:
QList<KAction*> mMailListActionList;
QWidget *mParent;
......@@ -150,6 +152,7 @@ private:
KAction *mEditAction, *mAnnotateAction, *mPrintAction, *mPrintPreviewAction;
TemplateParser::CustomTemplatesMenu *mCustomTemplatesMenu;
KAction *mListFilterAction;
KAction *mAddFollowupReminderAction;
QAction *mDebugBalooAction;
};
......
......@@ -33,7 +33,7 @@ kde4_add_unit_test( statusbarlabeltoggledstatetest ${kmail_statusbarlabeltoggled
target_link_libraries( statusbarlabeltoggledstatetest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS})
set( kmail_createfollowupreminderonexistingmessagejobtest_source createfollowupreminderonexistingmessagejobtest.cpp ../job/createfollowupreminderonexistingmessagejob.cpp )
set( kmail_createfollowupreminderonexistingmessagejobtest_source createfollowupreminderonexistingmessagejobtest.cpp ../job/createfollowupreminderonexistingmessagejob.cpp ../followupreminder/followupremindercreatejob.cpp)
kde4_add_unit_test( createfollowupreminderonexistingmessagejobtest ${kmail_createfollowupreminderonexistingmessagejobtest_source})
target_link_libraries( createfollowupreminderonexistingmessagejobtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_AKONADI_LIBS})
target_link_libraries( createfollowupreminderonexistingmessagejobtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_KCALCORE_LIBS} followupreminder)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment