Changeset View
Changeset View
Standalone View
Standalone View
src/staticxml/staticxmlprovider.cpp
Show All 21 Lines | |||||
22 | #include "staticxmlprovider_p.h" | 22 | #include "staticxmlprovider_p.h" | ||
23 | 23 | | |||
24 | #include "xmlloader.h" | 24 | #include "xmlloader.h" | ||
25 | 25 | | |||
26 | #include <knewstuffcore_debug.h> | 26 | #include <knewstuffcore_debug.h> | ||
27 | #include <klocalizedstring.h> | 27 | #include <klocalizedstring.h> | ||
28 | 28 | | |||
29 | #include <QTimer> | 29 | #include <QTimer> | ||
30 | #include <tagsfilterchecker.h> | ||||
30 | 31 | | |||
31 | 32 | | |||
32 | namespace KNSCore | 33 | namespace KNSCore | ||
33 | { | 34 | { | ||
34 | 35 | | |||
35 | StaticXmlProvider::StaticXmlProvider() | 36 | StaticXmlProvider::StaticXmlProvider() | ||
36 | : mInitialized(false) | 37 | : mInitialized(false) | ||
37 | { | 38 | { | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 190 | { | |||
195 | } | 196 | } | ||
196 | 197 | | |||
197 | // load all the entries from the domdocument given | 198 | // load all the entries from the domdocument given | ||
198 | EntryInternal::List entries; | 199 | EntryInternal::List entries; | ||
199 | QDomElement element; | 200 | QDomElement element; | ||
200 | const Provider::Filter filter = loader->property("filter").value<Provider::Filter>(); | 201 | const Provider::Filter filter = loader->property("filter").value<Provider::Filter>(); | ||
201 | const QString searchTerm = loader->property("searchTerm").toString(); | 202 | const QString searchTerm = loader->property("searchTerm").toString(); | ||
202 | 203 | | |||
204 | TagsFilterChecker checker(mCurrentRequest.tagFilter); | ||||
205 | TagsFilterChecker downloadschecker(mCurrentRequest.downloadTagFilter); | ||||
203 | element = doc.documentElement(); | 206 | element = doc.documentElement(); | ||
204 | QDomElement n; | 207 | QDomElement n; | ||
205 | for (n = element.firstChildElement(); !n.isNull(); n = n.nextSiblingElement()) { | 208 | for (n = element.firstChildElement(); !n.isNull(); n = n.nextSiblingElement()) { | ||
206 | EntryInternal entry; | 209 | EntryInternal entry; | ||
207 | entry.setEntryXML(n.toElement()); | 210 | entry.setEntryXML(n.toElement()); | ||
208 | entry.setStatus(KNS3::Entry::Downloadable); | 211 | entry.setStatus(KNS3::Entry::Downloadable); | ||
209 | entry.setProviderId(mId); | 212 | entry.setProviderId(mId); | ||
210 | 213 | | |||
Show All 9 Lines | 219 | if ((cacheEntry.status() == KNS3::Entry::Installed) && | |||
220 | entry.setVersion(cacheEntry.version()); | 223 | entry.setVersion(cacheEntry.version()); | ||
221 | entry.setUpdateReleaseDate(entry.releaseDate()); | 224 | entry.setUpdateReleaseDate(entry.releaseDate()); | ||
222 | entry.setReleaseDate(cacheEntry.releaseDate()); | 225 | entry.setReleaseDate(cacheEntry.releaseDate()); | ||
223 | } else { | 226 | } else { | ||
224 | entry.setStatus(cacheEntry.status()); | 227 | entry.setStatus(cacheEntry.status()); | ||
225 | } | 228 | } | ||
226 | cacheEntry = entry; | 229 | cacheEntry = entry; | ||
227 | } | 230 | } | ||
231 | | ||||
232 | if (checker.filterAccepts(entry.tags())) { | ||||
233 | bool filterAcceptsDownloads = true; | ||||
234 | if (entry.downloadCount() > 0) { | ||||
235 | for (const KNSCore::EntryInternal::DownloadLinkInformation &dli : entry.downloadLinkInformationList()) { | ||||
236 | if (downloadschecker.filterAccepts(dli.tags)) { | ||||
237 | filterAcceptsDownloads = true; | ||||
238 | break; | ||||
239 | } | ||||
240 | } | ||||
241 | } | ||||
242 | if (filterAcceptsDownloads) { | ||||
228 | mCachedEntries.append(entry); | 243 | mCachedEntries.append(entry); | ||
229 | 244 | | |||
230 | if (searchIncludesEntry(entry)) { | 245 | if (searchIncludesEntry(entry)) { | ||
231 | switch(filter) { | 246 | switch(filter) { | ||
232 | case Installed: | 247 | case Installed: | ||
233 | //This is dealth with in loadEntries separately | 248 | //This is dealth with in loadEntries separately | ||
234 | Q_UNREACHABLE(); | 249 | Q_UNREACHABLE(); | ||
235 | case Updates: | 250 | case Updates: | ||
236 | if (entry.status() == KNS3::Entry::Updateable) { | 251 | if (entry.status() == KNS3::Entry::Updateable) { | ||
237 | entries << entry; | 252 | entries << entry; | ||
238 | } | 253 | } | ||
239 | break; | 254 | break; | ||
240 | case ExactEntryId: | 255 | case ExactEntryId: | ||
241 | if (entry.uniqueId() == searchTerm) { | 256 | if (entry.uniqueId() == searchTerm) { | ||
242 | entries << entry; | 257 | entries << entry; | ||
243 | } | 258 | } | ||
244 | break; | 259 | break; | ||
245 | case None: | 260 | case None: | ||
246 | entries << entry; | 261 | entries << entry; | ||
247 | break; | 262 | break; | ||
248 | } | 263 | } | ||
249 | } | 264 | } | ||
265 | } else { | ||||
266 | qCDebug(KNEWSTUFFCORE) << "Filter has excluded" << entry.name() << "on download filter" << mCurrentRequest.downloadTagFilter; | ||||
cfeck: again | |||||
267 | } | ||||
268 | } else { | ||||
269 | qCDebug(KNEWSTUFFCORE) << "Filter has excluded" << entry.name() << "on entry filter" << mCurrentRequest.tagFilter; | ||||
270 | } | ||||
cfeck: again | |||||
250 | } | 271 | } | ||
251 | emit loadingFinished(mCurrentRequest, entries); | 272 | emit loadingFinished(mCurrentRequest, entries); | ||
252 | } | 273 | } | ||
253 | 274 | | |||
254 | void StaticXmlProvider::slotFeedFailed() | 275 | void StaticXmlProvider::slotFeedFailed() | ||
255 | { | 276 | { | ||
256 | emit loadingFailed(mCurrentRequest); | 277 | emit loadingFailed(mCurrentRequest); | ||
257 | } | 278 | } | ||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
again