+ buildGroupContextMenu(&menu, index);
+
+ QAction* action = menu.exec(pos.toPoint());
+ if (action) {
+ if (action == emptyTrashAction) {
+ Trash::empty(this);
+ } 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());
+ if (!m_model->hiddenCount()) {
+ showHiddenEntries(false);
+ }
+ } 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 == mountAction) {
+ m_model->requestStorageSetup(index);
+ } else if (action == teardownAction) {
+ m_model->requestTearDown(index);
+ } else if (action == ejectAction) {
+ m_model->requestEject(index);
+ } else if (action == propertiesAction) {
+ KPropertiesDialog* dialog = new KPropertiesDialog(item->url(), this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ dialog->show();
+ }