| 84 | } |
| 85 | |
| 86 | void 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 | |
| 121 | void ProjectFilterProvider::updateProjectFilters(IProject* project) |
| 122 | { |
nothing calls this directly
no test coverage detected