- if (isTrash) {
- emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"));
- emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full"));
- menu.addSeparator();
- }
- }
-
- QAction* openInNewWindowAction = menu.addAction(QIcon::fromTheme("window-new"), i18nc("@item:inmenu", "Open in New Window"));
- QAction* openInNewTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@item:inmenu", "Open in New Tab"));
- if (!isDevice && !isTrash) {
- menu.addSeparator();
- }
-
- if (!isDevice) {
- editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit..."));
- }
-
- QAction* removeAction = nullptr;
- if (!isDevice && !item->isSystemItem()) {
- removeAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@item:inmenu", "Remove"));
- }
-
- QAction* hideAction = menu.addAction(i18nc("@item:inmenu", "Hide"));
- hideAction->setCheckable(true);
- hideAction->setChecked(item->isHidden());
-
- buildGroupContextMenu(&menu, index);
-
- QAction* action = menu.exec(pos.toPoint());
- if (action) {
- if (action == emptyTrashAction) {
- emptyTrash();
- } else {
- // The index might have changed if devices were added/removed while
- // the context menu was open.
- index = m_model->index(item);
- if (index < 0) {
- // The item is not in the model any more, probably because it was an
- // external device that has been removed while the context menu was open.
- return;
- }
-
- if (action == editAction) {
- editEntry(index);
- } else if (action == removeAction) {
- m_model->deleteItem(index);
- } else if (action == hideAction) {
- item->setHidden(hideAction->isChecked());
- } else if (action == openInNewWindowAction) {
- Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this);
- } else if (action == openInNewTabAction) {
- // TriggerItem does set up the storage first and then it will
- // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton.
- triggerItem(index, Qt::MiddleButton);
- } else if (action == teardownAction) {
- m_model->requestTearDown(index);
- } else if (action == ejectAction) {
- m_model->requestEject(index);
- }
- }