Commit 0b5d6d6e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Set different message when collection is sent folder

parent 52025100
......@@ -35,6 +35,7 @@
#include <IncidenceEditor/IncidenceDialog>
#include <IncidenceEditor/IncidenceDialogFactory>
#include <akonadi/kmime/specialmailcollections.h>
#include <KGuiItem>
#include <KStandardGuiItem>
......@@ -144,10 +145,27 @@ void TodoEdit::updateButtons(const QString &subject)
void TodoEdit::showToDoWidget()
{
const KMime::Headers::Subject *const subject = mMessage ? mMessage->subject(false) : 0;
if (subject) {
bool isSentFolder = false;
if (mCurrentCollection.isValid()) {
isSentFolder = (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::SentMail) == mCurrentCollection);
}
mNoteEdit->setText(isSentFolder ? i18n("Check I received a reply about \"%1\"", subject->asUnicodeString()) : i18n("Reply to \"%1\"", subject->asUnicodeString()));
mNoteEdit->selectAll();
mNoteEdit->setFocus();
} else {
mNoteEdit->clear();
}
mNoteEdit->setFocus();
show();
}
void TodoEdit::setCurrentCollection(const Akonadi::Collection &col)
{
mCurrentCollection = col;
}
void TodoEdit::writeConfig()
{
const Akonadi::Collection col = mCollectionCombobox->currentCollection();
......@@ -193,14 +211,6 @@ void TodoEdit::setMessage(const KMime::Message::Ptr &value)
{
if (mMessage != value) {
mMessage = value;
const KMime::Headers::Subject *const subject = mMessage ? mMessage->subject(false) : 0;
if (subject) {
mNoteEdit->setText(i18n("Reply to \"%1\"", subject->asUnicodeString()));
mNoteEdit->selectAll();
mNoteEdit->setFocus();
} else {
mNoteEdit->clear();
}
Q_EMIT messageChanged(mMessage);
}
}
......
......@@ -49,6 +49,7 @@ public:
void writeConfig();
void showToDoWidget();
void setCurrentCollection(const Akonadi::Collection &col);
public Q_SLOTS:
void slotCloseWidget();
......@@ -67,12 +68,14 @@ private:
void updateButtons(const QString &subject);
void readConfig();
Akonadi::Collection mCollection;
Akonadi::Collection mCurrentCollection;
KMime::Message::Ptr mMessage;
QLineEdit *mNoteEdit;
Akonadi::CollectionComboBox *mCollectionCombobox;
KMessageWidget *mMsgWidget;
QPushButton *mSaveButton;
QPushButton *mOpenEditorButton;
};
}
#endif // TODOEDIT_H
......@@ -111,3 +111,9 @@ TodoEdit *ViewerPluginCreateTodoInterface::widget()
}
return mTodoEdit;
}
void MessageViewer::ViewerPluginCreateTodoInterface::setCurrentCollection(const Akonadi::Collection &col)
{
widget()->setCurrentCollection(col);
}
......@@ -40,6 +40,7 @@ public:
void showWidget() override;
void setMessageItem(const Akonadi::Item &item) override;
ViewerPluginInterface::SpecificFeatureTypes featureTypes() const override;
void setCurrentCollection(const Akonadi::Collection &col) override;
private:
void slotCreateTodo(const KCalCore::Todo::Ptr &todoPtr, const Akonadi::Collection &collection);
......
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