summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Montel <[email protected]>2018-02-22 22:59:44 +0100
committerLaurent Montel <[email protected]>2018-02-22 22:59:44 +0100
commitbfcc8c1c5d6bd9c37b4307e3d0b16f9457789cc9 (patch)
tree34b8e3fbaf6a4a1c0da359eacc1b1e0d744c1644
parent24a0231002b3f1dbb276449c4961fabfcffe9e34 (diff)
Reactivate showOpenAttachmentFolderWidget
-rw-r--r--messageviewer/src/utils/messageviewerutil.cpp31
-rw-r--r--messageviewer/src/utils/messageviewerutil.h1
-rw-r--r--messageviewer/src/viewer/urlhandlermanager.cpp1
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp13
4 files changed, 26 insertions, 20 deletions
diff --git a/messageviewer/src/utils/messageviewerutil.cpp b/messageviewer/src/utils/messageviewerutil.cpp
index 092be3a..130bd7f 100644
--- a/messageviewer/src/utils/messageviewerutil.cpp
+++ b/messageviewer/src/utils/messageviewerutil.cpp
@@ -435,7 +435,7 @@ bool Util::saveAttachments(const KMime::Content::List &contents, QWidget *parent
return Util::saveContents(parent, contents, urlList);
}
-bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages)
+bool Util::saveMessageInMboxAndGetUrl(QUrl &url, const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages)
{
QString fileName;
if (retrievedMsgs.isEmpty()) {
@@ -445,10 +445,10 @@ bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *
if (msgBase.hasPayload<KMime::Message::Ptr>()) {
fileName
- = MessageCore::StringUtil::cleanFileName(MimeTreeParser::NodeHelper::cleanSubject(
- msgBase.
- payload
- <KMime::Message::Ptr>().data()).trimmed());
+ = MessageCore::StringUtil::cleanFileName(MimeTreeParser::NodeHelper::cleanSubject(
+ msgBase.
+ payload
+ <KMime::Message::Ptr>().data()).trimmed());
fileName.remove(QLatin1Char('\"'));
} else {
fileName = i18n("message");
@@ -470,10 +470,10 @@ bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *
}
QString localFile = startUrl.toLocalFile() + QLatin1Char('/') + fileName;
QString saveFileName
- = QFileDialog::getSaveFileName(parent,
- i18np("Save Message", "Save Messages",
- retrievedMsgs.count()), localFile, filter, nullptr,
- opt);
+ = QFileDialog::getSaveFileName(parent,
+ i18np("Save Message", "Save Messages",
+ retrievedMsgs.count()), localFile, filter, nullptr,
+ opt);
if (!saveFileName.isEmpty()) {
const QString localFileName = saveFileName;
@@ -503,15 +503,22 @@ bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *
i18n("Error saving message"));
return false;
}
- QUrl url = QUrl::fromLocalFile(saveFileName);
- if (url.isLocalFile()) {
- KRecentDirs::add(fileClass, url.adjusted(
+ QUrl localUrl = QUrl::fromLocalFile(saveFileName);
+ if (localUrl.isLocalFile()) {
+ KRecentDirs::add(fileClass, localUrl.adjusted(
QUrl::RemoveFilename | QUrl::StripTrailingSlash).path());
}
+ url = localUrl;
}
return true;
}
+bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages)
+{
+ QUrl url;
+ return saveMessageInMboxAndGetUrl(url, retrievedMsgs, parent, appendMessages);
+}
+
QAction *Util::createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent)
{
QString actionName(service->name().replace(QLatin1Char('&'), QStringLiteral("&&")));
diff --git a/messageviewer/src/utils/messageviewerutil.h b/messageviewer/src/utils/messageviewerutil.h
index acc988f..651d979 100644
--- a/messageviewer/src/utils/messageviewerutil.h
+++ b/messageviewer/src/utils/messageviewerutil.h
@@ -59,6 +59,7 @@ namespace MessageViewer {
namespace Util {
// return true if we should proceed, false if we should abort
bool MESSAGEVIEWER_EXPORT checkOverwrite(const QUrl &url, QWidget *w);
+MESSAGEVIEWER_EXPORT bool saveMessageInMboxAndGetUrl(QUrl &url, const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
MESSAGEVIEWER_EXPORT bool saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
MESSAGEVIEWER_EXPORT bool saveAttachments(const KMime::Content::List &contents, QWidget *parent, QList<QUrl> &saveUrl);
diff --git a/messageviewer/src/viewer/urlhandlermanager.cpp b/messageviewer/src/viewer/urlhandlermanager.cpp
index 5079132..0ba5700 100644
--- a/messageviewer/src/viewer/urlhandlermanager.cpp
+++ b/messageviewer/src/viewer/urlhandlermanager.cpp
@@ -749,6 +749,7 @@ bool AttachmentURLHandler::handleDrag(const QUrl &url, ViewerPrivate *window) co
if (!node) {
return false;
}
+ //TODO fix me embedded
if (node->header<KMime::Headers::Subject>()) {
if (!node->contents().isEmpty()) {
node = node->contents().constLast();
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index 20cf8f3..c73f1dc 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -2754,21 +2754,18 @@ void ViewerPrivate::slotHandleAttachment(int choice)
{
const bool isEncapsulatedMessage = mCurrentContent->parent() && mCurrentContent->parent()->bodyIsMessage();
if (isEncapsulatedMessage) {
-
KMime::Message::Ptr message = KMime::Message::Ptr(new KMime::Message);
message->setContent(mCurrentContent->parent()->bodyAsMessage()->encodedContent());
message->parse();
Akonadi::Item item;
-
item.setPayload<KMime::Message::Ptr>(message);
Akonadi::MessageFlags::copyMessageFlags(*message, item);
item.setMimeType(KMime::Message::mimeType());
-
- Util::saveMessageInMbox(Akonadi::Item::List() << item, mMainWindow);
-
- //TODO reimplement openattachementfolder widget!!!!
- //showOpenAttachmentFolderWidget(urlList);
- return;
+ QUrl url;
+ if (MessageViewer::Util::saveMessageInMboxAndGetUrl(url, Akonadi::Item::List() << item, mMainWindow)) {
+ showOpenAttachmentFolderWidget(QList<QUrl>() << url);
+ }
+ return;
}
QList<QUrl> urlList;