summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-11-27 08:50:01 +0100
committerMontel Laurent <[email protected]>2017-11-27 08:50:01 +0100
commit996b6610c138dad33c9545d0170aa9f35c457484 (patch)
tree16287ad3b19877b8c54cb8f00dad4f83253b4ccb
parentcc2861aed73723f25ecd43ec5edcbc537d105937 (diff)
Avoid to show empty menu
-rw-r--r--src/pimcommon/widgets/simplestringlisteditor.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pimcommon/widgets/simplestringlisteditor.cpp b/src/pimcommon/widgets/simplestringlisteditor.cpp
index f38779f..baaf0f8 100644
--- a/src/pimcommon/widgets/simplestringlisteditor.cpp
+++ b/src/pimcommon/widgets/simplestringlisteditor.cpp
@@ -436,19 +436,20 @@ void SimpleStringListEditor::slotContextMenu(const QPoint &pos)
{
QList<QListWidgetItem *> lstSelectedItems = d->mListBox->selectedItems();
const bool hasItemsSelected = !lstSelectedItems.isEmpty();
- QMenu *menu = new QMenu(this);
+ QMenu menu(this);
if (d->mAddButton) {
- menu->addAction(d->mAddButton->text(), this, &SimpleStringListEditor::slotAdd);
+ menu.addAction(d->mAddButton->text(), this, &SimpleStringListEditor::slotAdd);
}
if (d->mModifyButton && (lstSelectedItems.count() == 1)) {
- menu->addAction(d->mModifyButton->text(), this, &SimpleStringListEditor::slotModify);
+ menu.addAction(d->mModifyButton->text(), this, &SimpleStringListEditor::slotModify);
}
if (d->mRemoveButton && hasItemsSelected) {
- menu->addSeparator();
- menu->addAction(d->mRemoveButton->text(), this, &SimpleStringListEditor::slotRemove);
+ menu.addSeparator();
+ menu.addAction(d->mRemoveButton->text(), this, &SimpleStringListEditor::slotRemove);
+ }
+ if (!menu.isEmpty()) {
+ menu.exec(d->mListBox->mapToGlobal(pos));
}
- menu->exec(d->mListBox->mapToGlobal(pos));
- delete menu;
}
QSize SimpleStringListEditor::sizeHint() const