Commit 5ab9e701 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Fix check for root of content node tree

showContextMenu() is only called for content nodes from the mime part
tree, but the mime part tree has a separate copy of the node tree.
Therefore, isRoot was always false. Check content->isTopLevel() instead
of comparing pointers.
parent 0b53b367
Pipeline #59419 canceled with stage
in 17 minutes and 3 seconds
...@@ -1681,12 +1681,11 @@ void ViewerPrivate::showContextMenu(KMime::Content *content, const QPoint &pos) ...@@ -1681,12 +1681,11 @@ void ViewerPrivate::showContextMenu(KMime::Content *content, const QPoint &pos)
} }
const bool isAttachment = !content->contentType()->isMultipart() && !content->isTopLevel(); const bool isAttachment = !content->contentType()->isMultipart() && !content->isTopLevel();
const bool isExtraContent = !mMessage->content(content->index()); const bool isExtraContent = !mMessage->content(content->index());
const bool isRoot = (content == mMessage.data());
const auto hasAttachments = KMime::hasAttachment(mMessage.data()); const auto hasAttachments = KMime::hasAttachment(mMessage.data());
QMenu popup; QMenu popup;
if (!isRoot) { if (!content->isTopLevel()) {
popup.addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n("Save &As..."), this, &ViewerPrivate::slotAttachmentSaveAs); popup.addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n("Save &As..."), this, &ViewerPrivate::slotAttachmentSaveAs);
if (isAttachment) { if (isAttachment) {
...@@ -1705,20 +1704,18 @@ void ViewerPrivate::showContextMenu(KMime::Content *content, const QPoint &pos) ...@@ -1705,20 +1704,18 @@ void ViewerPrivate::showContextMenu(KMime::Content *content, const QPoint &pos)
popup.addAction(i18n("Save All Attachments..."), this, &ViewerPrivate::slotAttachmentSaveAll); popup.addAction(i18n("Save All Attachments..."), this, &ViewerPrivate::slotAttachmentSaveAll);
} }
if (!isRoot) { if (!content->isTopLevel()) {
if (isAttachment) { if (isAttachment) {
popup.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy"), this, &ViewerPrivate::slotAttachmentCopy); popup.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy"), this, &ViewerPrivate::slotAttachmentCopy);
} }
if (!content->isTopLevel()) { auto deleteAction =
auto deleteAction = popup.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete Attachment"), this, &ViewerPrivate::slotAttachmentDelete);
popup.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete Attachment"), this, &ViewerPrivate::slotAttachmentDelete); // body parts can only be deleted one at a time, and extra content cannot be delete
// body parts can only be deleted one at a time, and extra content cannot be delete deleteAction->setEnabled(selectedContents().size() == 1 && !isExtraContent);
deleteAction->setEnabled(selectedContents().size() == 1 && !isExtraContent);
popup.addSeparator(); popup.addSeparator();
popup.addAction(i18n("Properties"), this, &ViewerPrivate::slotAttachmentProperties); popup.addAction(i18n("Properties"), this, &ViewerPrivate::slotAttachmentProperties);
}
} }
popup.exec(mMimePartTree->viewport()->mapToGlobal(pos)); popup.exec(mMimePartTree->viewport()->mapToGlobal(pos));
} }
......
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