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

Method popupContextMenu

plugins/vcschangesview/vcschangesview.cpp:64–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void VcsChangesView::popupContextMenu( const QPoint &pos )
65{
66 QList<QUrl> urls;
67 QList<IProject*> projects;
68 const QModelIndexList selectionIdxs = selectedIndexes();
69 if(selectionIdxs.isEmpty())
70 return;
71
72 for (const QModelIndex& idx : selectionIdxs) {
73 if(idx.column()==0) {
74 if(idx.parent().isValid())
75 urls += idx.data(KDevelop::VcsFileChangesModel::VcsStatusInfoRole).value<VcsStatusInfo>().url();
76 else {
77 IProject* project = ICore::self()->projectController()->findProjectByName(idx.data(ProjectChangesModel::ProjectNameRole).toString());
78 if (project) {
79 projects += project;
80 } else {
81 qWarning() << "Couldn't find a project for project: " << idx.data(ProjectChangesModel::ProjectNameRole).toString();
82 }
83 }
84 }
85 }
86
87 QPointer<QMenu> menu = new QMenu(this);
88 QAction* refreshAction = menu->addAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18nc("@action:inmenu", "Refresh"));
89 QList<ContextMenuExtension> extensions;
90 if(!urls.isEmpty()) {
91 KDevelop::FileContext context(urls);
92 extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions(&context, menu);
93 } else {
94 QList<ProjectBaseItem*> items;
95 items.reserve(projects.size());
96 for (IProject* p : std::as_const(projects)) {
97 items += p->projectItem();
98 }
99
100 KDevelop::ProjectItemContextImpl context(items);
101 extensions = ICore::self()->pluginController()->queryPluginsForContextMenuExtensions(&context, menu);
102
103 }
104
105 QList<QAction*> buildActions;
106 QList<QAction*> vcsActions;
107 QList<QAction*> extActions;
108 QList<QAction*> projectActions;
109 QList<QAction*> fileActions;
110 QList<QAction*> runActions;
111 for (const ContextMenuExtension& ext : std::as_const(extensions)) {
112 buildActions += ext.actions(ContextMenuExtension::BuildGroup);
113 fileActions += ext.actions(ContextMenuExtension::FileGroup);
114 projectActions += ext.actions(ContextMenuExtension::ProjectGroup);
115 vcsActions += ext.actions(ContextMenuExtension::VcsGroup);
116 extActions += ext.actions(ContextMenuExtension::ExtensionGroup);
117 runActions += ext.actions(ContextMenuExtension::RunGroup);
118 }
119
120 appendActions(menu, buildActions);
121 appendActions(menu, runActions );

Callers

nothing calls this directly

Calls 15

appendActionsFunction · 0.85
findProjectByNameMethod · 0.80
projectControllerMethod · 0.80
pluginControllerMethod · 0.80
execMethod · 0.80
isEmptyMethod · 0.45
columnMethod · 0.45
isValidMethod · 0.45
parentMethod · 0.45
urlMethod · 0.45
dataMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected