Changeset View
Changeset View
Standalone View
Standalone View
kcms/baloo/filteredfoldermodel.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | |||||
157 | } | 157 | } | ||
158 | 158 | | |||
159 | int FilteredFolderModel::rowCount(const QModelIndex& parent) const | 159 | int FilteredFolderModel::rowCount(const QModelIndex& parent) const | ||
160 | { | 160 | { | ||
161 | Q_UNUSED(parent); | 161 | Q_UNUSED(parent); | ||
162 | return m_folderList.count(); | 162 | return m_folderList.count(); | ||
163 | } | 163 | } | ||
164 | 164 | | |||
165 | void FilteredFolderModel::addFolder(const QString& url) | 165 | void FilteredFolderModel::addFolder(const QString& url, const bool included = false) | ||
166 | { | 166 | { | ||
167 | QString nUrl = normalizeTrailingSlashes(QUrl(url).toLocalFile()); | 167 | QString nUrl = normalizeTrailingSlashes(QUrl(url).toLocalFile()); | ||
168 | 168 | | |||
169 | auto it = std::find_if(m_folderList.begin(), m_folderList.end(), | 169 | auto it = std::find_if(m_folderList.begin(), m_folderList.end(), | ||
170 | [nUrl](const FolderInfo& folder) { | 170 | [nUrl](const FolderInfo& folder) { | ||
171 | return folder.url == nUrl; | 171 | return folder.url == nUrl; | ||
172 | }); | 172 | }); | ||
173 | if (it != m_folderList.end() && (*it).isFromConfig) { | 173 | if (it != m_folderList.end() && (*it).isFromConfig) { | ||
174 | return; | 174 | return; | ||
175 | } | 175 | } | ||
176 | auto excluded = m_settings->excludedFolders(); | 176 | if (included) { | ||
177 | auto included = addTrailingSlashes(m_settings->folders()); | ||||
178 | included.append(nUrl); | ||||
179 | std::sort(std::begin(included), std::end(included)); | ||||
180 | m_settings->setFolders(included); | ||||
181 | } else { | ||||
182 | auto excluded = addTrailingSlashes(m_settings->excludedFolders()); | ||||
177 | excluded.append(nUrl); | 183 | excluded.append(nUrl); | ||
178 | std::sort(std::begin(excluded), std::end(excluded)); | 184 | std::sort(std::begin(excluded), std::end(excluded)); | ||
179 | m_settings->setExcludedFolders(excluded); | 185 | m_settings->setExcludedFolders(excluded); | ||
186 | } | ||||
180 | m_deletedSettings.removeAll(nUrl); | 187 | m_deletedSettings.removeAll(nUrl); | ||
181 | } | 188 | } | ||
182 | 189 | | |||
183 | void FilteredFolderModel::removeFolder(int row) | 190 | void FilteredFolderModel::removeFolder(int row) | ||
184 | { | 191 | { | ||
185 | auto entry = m_folderList.at(row); | 192 | auto entry = m_folderList.at(row); | ||
186 | if (!entry.isFromConfig) { | 193 | if (!entry.isFromConfig) { | ||
187 | return; | 194 | return; | ||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |