void FSTableView::contextMenuEvent(QContextMenuEvent * event) { QModelIndex index = indexAt(event->pos()); QMenu * menu = 0; if (index.isValid()) { if (selectionModel()->selectedRows().count() > 1) menu = createSelectionMenu(); else menu = createItemMenu(); } else menu = createMenu(); menu->move(event->globalPos()); menu->exec(); delete menu; }
/*! Shows user the item specific menu. The menu is triggered by long pressing the access point item. @param[in] position Preferred position for the item specific menu. */ void CpIapItem::showItemMenu(QPointF position) { OstTraceFunctionEntry0(CPIAPITEM_SHOWITEMMENU_ENTRY); if (isCmManagerAvailable()) { bool settingsReadSuccessful = true; bool cmConnected = false; try { CmConnectionMethodShim *cm = mCmm->connectionMethod(mIapId); cmConnected = cm->getBoolAttribute(CMManagerShim::CmConnected); delete cm; } catch (const std::exception&) { OstTrace0(TRACE_NORMAL, CPIAPITEM_SHOWITEMMENU, "CpIapItem::showItemMenu: Exception caught"); settingsReadSuccessful = false; } if (settingsReadSuccessful) { // Settings could be read from commsdat: show menu. createItemMenu(cmConnected, position)->show(); } } OstTraceFunctionExit0(CPIAPITEM_SHOWITEMMENU_EXIT); }