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

Function populateMenuWithGroup

kdevplatform/interfaces/contextmenuextension.cpp:88–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88static
89void populateMenuWithGroup(
90 QMenu* menu,
91 const QList<ContextMenuExtension>& extensions,
92 const QString& groupName,
93 const QString& groupDisplayName = QString(),
94 const QString& groupIconName = QString(),
95 bool forceAddMenu = false,
96 bool addSeparator = true)
97{
98 QList<QAction*> groupActions;
99 for (const ContextMenuExtension& extension : extensions) {
100 groupActions += extension.actions(groupName);
101 }
102 // remove NULL QActions, if any. Those can end up in groupActions if plugins
103 // like the debugger plugins are not loaded.
104 groupActions.removeAll(nullptr);
105
106 if (groupActions.isEmpty()) {
107 return;
108 }
109
110 QMenu* groupMenu = menu;
111 if ((groupActions.count() > 1 && !groupDisplayName.isEmpty()) ||
112 (!groupDisplayName.isEmpty() && forceAddMenu)) {
113 groupMenu = menu->addMenu(groupDisplayName);
114 if (!groupIconName.isEmpty()) {
115 groupMenu->setIcon(QIcon::fromTheme(groupIconName));
116 }
117 }
118
119 for (QAction* action : std::as_const(groupActions)) {
120 groupMenu->addAction(action);
121 }
122
123 if (addSeparator) {
124 menu->addSeparator();
125 }
126}
127
128void ContextMenuExtension::populateMenu(QMenu* menu, const QList<ContextMenuExtension>& extensions)
129{

Callers 1

populateMenuMethod · 0.85

Calls 6

setIconMethod · 0.80
QStringClass · 0.70
actionsMethod · 0.45
isEmptyMethod · 0.45
countMethod · 0.45
addActionMethod · 0.45

Tested by

no test coverage detected