Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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

Reactivate showOpenAttachmentFolderWidget

parent 24a02310
......@@ -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("&&")));
......
......@@ -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);
......
......@@ -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();
......
......@@ -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;
......
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