summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Montel <[email protected]>2017-12-25 18:22:06 +0100
committerLaurent Montel <[email protected]>2017-12-25 18:22:06 +0100
commitcfb1d16e3e5bc32153d1a60507b8ccd6a9085ce0 (patch)
tree0dfd0dceb0ca5601291d4a99d3b30be40e6041d2
parentbe67b309c98628206749b43d8e40ab69efd03376 (diff)
Move to stack
-rw-r--r--messagecomposer/src/attachment/attachmentcontrollerbase.cpp33
-rw-r--r--messageviewer/src/viewer/urlhandlermanager.cpp9
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp23
3 files changed, 31 insertions, 34 deletions
diff --git a/messagecomposer/src/attachment/attachmentcontrollerbase.cpp b/messagecomposer/src/attachment/attachmentcontrollerbase.cpp
index 31ae9bb..2b09d87 100644
--- a/messagecomposer/src/attachment/attachmentcontrollerbase.cpp
+++ b/messagecomposer/src/attachment/attachmentcontrollerbase.cpp
@@ -580,7 +580,7 @@ void AttachmentControllerBase::showContextMenu()
Q_EMIT refreshSelection();
const int numberOfParts(d->selectedParts.count());
- QMenu *menu = new QMenu;
+ QMenu menu;
const bool enableEditAction = (numberOfParts == 1)
&& (!d->selectedParts.first()->isMessageOrMessageCollection());
@@ -601,40 +601,39 @@ void AttachmentControllerBase::showContextMenu()
|| parentMimeType.contains(QStringLiteral("image/png"))
|| parentMimeType.contains(QStringLiteral("image/jpeg"))
) {
- menu->addAction(d->viewContextAction);
+ menu.addAction(d->viewContextAction);
}
- d->createOpenWithMenu(menu, d->selectedParts.first());
+ d->createOpenWithMenu(&menu, d->selectedParts.first());
}
- menu->addAction(d->openContextAction);
+ menu.addAction(d->openContextAction);
}
if (enableEditAction) {
- menu->addAction(d->editWithContextAction);
- menu->addAction(d->editContextAction);
+ menu.addAction(d->editWithContextAction);
+ menu.addAction(d->editContextAction);
}
if (numberOfParts > 0) {
- menu->addAction(d->removeContextAction);
+ menu.addAction(d->removeContextAction);
}
if (numberOfParts == 1) {
if (!d->selectedParts.first()->url().isEmpty()) {
- menu->addAction(d->reloadAttachmentAction);
+ menu.addAction(d->reloadAttachmentAction);
}
- menu->addAction(d->saveAsContextAction);
- menu->addSeparator();
- menu->addAction(d->propertiesContextAction);
+ menu.addAction(d->saveAsContextAction);
+ menu.addSeparator();
+ menu.addAction(d->propertiesContextAction);
}
const int nbAttachment = d->model->rowCount();
if (nbAttachment != numberOfParts) {
- menu->addSeparator();
- menu->addAction(d->selectAllAction);
+ menu.addSeparator();
+ menu.addAction(d->selectAllAction);
}
if (numberOfParts == 0) {
- menu->addSeparator();
- menu->addAction(d->addContextAction);
+ menu.addSeparator();
+ menu.addAction(d->addContextAction);
}
- menu->exec(QCursor::pos());
- delete menu;
+ menu.exec(QCursor::pos());
}
void AttachmentControllerBase::slotOpenWithDialog()
diff --git a/messageviewer/src/viewer/urlhandlermanager.cpp b/messageviewer/src/viewer/urlhandlermanager.cpp
index e7ac0d2..6ec4f72 100644
--- a/messageviewer/src/viewer/urlhandlermanager.cpp
+++ b/messageviewer/src/viewer/urlhandlermanager.cpp
@@ -642,17 +642,17 @@ bool ContactUidURLHandler::handleContextMenuRequest(const QUrl &url, const QPoin
return false;
}
- QMenu *menu = new QMenu();
+ QMenu menu;
QAction *open
- = menu->addAction(QIcon::fromTheme(QStringLiteral("view-pim-contacts")),
+ = menu.addAction(QIcon::fromTheme(QStringLiteral("view-pim-contacts")),
i18n("&Open in Address Book"));
#ifndef QT_NO_CLIPBOARD
QAction *copy
- = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-copy")),
+ = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")),
i18n("&Copy Email Address"));
#endif
- QAction *a = menu->exec(p);
+ QAction *a = menu.exec(p);
if (a == open) {
runKAddressBook(url);
#ifndef QT_NO_CLIPBOARD
@@ -666,7 +666,6 @@ bool ContactUidURLHandler::handleContextMenuRequest(const QUrl &url, const QPoin
}
#endif
}
- delete menu;
return true;
}
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index 7aa5f6a..74a6422 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -594,7 +594,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
{
Q_UNUSED(name);
prepareHandleAttachment(node);
- QMenu *menu = new QMenu();
+ QMenu menu;
bool deletedAttachment = false;
if (node->contentType(false)) {
deletedAttachment = (node->contentType()->mimeType() == "text/x-moz-deleted");
@@ -602,14 +602,14 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
const QString contentTypeStr = QLatin1String(node->contentType()->mimeType());
QAction *action
- = menu->addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("to open",
+ = menu.addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("to open",
"Open"));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Open);
});
if (!deletedAttachment) {
- createOpenWithMenu(menu, contentTypeStr, true);
+ createOpenWithMenu(&menu, contentTypeStr, true);
}
QMimeDatabase mimeDb;
@@ -623,7 +623,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
|| parentMimeType.contains(QStringLiteral("image/png"))
|| parentMimeType.contains(QStringLiteral("image/jpeg"))
) {
- action = menu->addAction(i18nc("to view something", "View"));
+ action = menu.addAction(i18nc("to view something", "View"));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::View);
@@ -642,14 +642,14 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
}
#endif
- action = menu->addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n(
+ action = menu.addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n(
"Save As..."));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Save);
});
- action = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy"));
+ action = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy"));
action->setEnabled(!deletedAttachment);
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Copy);
@@ -663,7 +663,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
if (MessageViewer::MessageViewerSettings::self()->allowAttachmentEditing()) {
action
- = menu->addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n(
+ = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n(
"Edit Attachment"));
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Edit);
@@ -672,7 +672,7 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
action->setEnabled(canChange);
}
action
- = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")),
+ = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")),
i18n("Delete Attachment"));
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Delete);
@@ -697,13 +697,12 @@ void ViewerPrivate::showAttachmentPopup(KMime::Content *node, const QString &nam
slotHandleAttachment(Viewer::ReplyMessageToAll);
});
#endif
- menu->addSeparator();
- action = menu->addAction(i18n("Properties"));
+ menu.addSeparator();
+ action = menu.addAction(i18n("Properties"));
connect(action, &QAction::triggered, this, [this]() {
slotHandleAttachment(Viewer::Properties);
});
- menu->exec(globalPos);
- delete menu;
+ menu.exec(globalPos);
}
void ViewerPrivate::prepareHandleAttachment(KMime::Content *node)