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

Method addFilterFromContextMenu

plugins/projectfilter/projectfilterprovider.cpp:86–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void ProjectFilterProvider::addFilterFromContextMenu()
87{
88 auto* action = qobject_cast<QAction*>(sender());
89 Q_ASSERT(action);
90 const QList<ProjectBaseItem*> items = action->data().value<QList<ProjectBaseItem*>>();
91 QHash<IProject*, SerializedFilters> changedProjectFilters;
92 for (ProjectBaseItem* item : items) {
93 auto filterIt = changedProjectFilters.find(item->project());
94 if (filterIt == changedProjectFilters.end()) {
95 filterIt = changedProjectFilters.insert(item->project(), readFilters(item->project()->projectConfiguration()));
96 }
97 SerializedFilters& filters = *filterIt;
98 Path path;
99 if (item->target()) {
100 path = Path(item->parent()->path(), item->text());
101 } else {
102 path = item->path();
103 }
104 filters << SerializedFilter(QLatin1Char('/') + item->project()->path().relativePath(path),
105 item->folder() ? Filter::Folders : Filter::Files);
106 }
107 QHash< IProject*, SerializedFilters >::const_iterator it = changedProjectFilters.constBegin();
108 while (it != changedProjectFilters.constEnd()) {
109 writeFilters(it.value(), it.key()->projectConfiguration());
110 m_filters[it.key()] = deserialize(it.value());
111 emit filterChanged(this, it.key());
112 ++it;
113 }
114
115 KMessageBox::information(ICore::self()->uiController()->activeMainWindow(),
116 i18np("A filter for the item was added. To undo, use the project filter settings.",
117 "A filter for the items was added. To undo, use the project filter settings.",
118 items.size()), i18nc("@title:window", "Project Filter Added"), QStringLiteral("projectfilter-addfromctxmenu"));
119}
120
121void ProjectFilterProvider::updateProjectFilters(IProject* project)
122{

Callers

nothing calls this directly

Calls 15

readFiltersFunction · 0.85
SerializedFilterClass · 0.85
writeFiltersFunction · 0.85
deserializeFunction · 0.85
relativePathMethod · 0.80
folderMethod · 0.80
constBeginMethod · 0.80
constEndMethod · 0.80
uiControllerMethod · 0.80
PathClass · 0.50
dataMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected