MCPcopy Create free account
hub / github.com/KDE/kdevelop / popupContextMenu

Method popupContextMenu

plugins/git/committoolview.cpp:297–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297void CommitToolView::popupContextMenu(const QPoint& pos)
298{
299 QList<QUrl> urls;
300 const QModelIndexList selectionIdxs = m_view->selectionModel()->selectedIndexes();
301
302 // If there are no selected files just show an action to refresh the model
303 if (selectionIdxs.isEmpty()) {
304 QModelIndex idx = m_view->indexAt(pos);
305 IProject* project
306 = ICore::self()->projectController()->findProjectByName(idx.data(RepoStatusModel::NameRole).toString());
307
308 // Show the context menu & evaluate the results
309 QAction* res = m_refreshMenu->exec(m_view->viewport()->mapToGlobal(pos));
310 if (res == m_refreshModelAct) {
311 if (project)
312 m_statusmodel->reload({ project });
313 else
314 m_statusmodel->reloadAll();
315 }
316 return;
317 }
318
319 // Convert the selection into a list of urls;
320 for (const QModelIndex& idx : selectionIdxs) {
321 if (idx.column() == 0) {
322 if (idx.parent().isValid())
323 urls += idx.data(RepoStatusModel::UrlRole).value<QUrl>();
324 }
325 }
326
327 // Show the context menu & evaluate the results
328 QAction* res = m_toolviewMenu->exec(m_view->viewport()->mapToGlobal(pos));
329 if (res == m_refreshModelAct) {
330 if (!urls.isEmpty())
331 m_statusmodel->reload(urls);
332 else
333 m_statusmodel->reloadAll();
334 } else if (res == m_stageFilesAct) {
335 if (!urls.isEmpty())
336 stageSelectedFiles(urls);
337 } else if (res == m_unstageFilesAct) {
338 if (!urls.isEmpty())
339 unstageSelectedFiles(urls);
340 } else if (res == m_revertFilesAct) {
341 if (!urls.isEmpty())
342 revertSelectedFiles(urls);
343 }
344}
345
346void CommitToolView::dblClicked ( const QModelIndex& idx )
347{

Callers

nothing calls this directly

Calls 11

findProjectByNameMethod · 0.80
projectControllerMethod · 0.80
execMethod · 0.80
isEmptyMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
reloadMethod · 0.45
reloadAllMethod · 0.45
columnMethod · 0.45
isValidMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected