Changeset View
Changeset View
Standalone View
Standalone View
src/attica/atticaprovider.cpp
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 115 | { | |||
---|---|---|---|---|---|
121 | 121 | | |||
122 | Attica::ListJob<Attica::Category> *job = static_cast<Attica::ListJob<Attica::Category>*>(listJob); | 122 | Attica::ListJob<Attica::Category> *job = static_cast<Attica::ListJob<Attica::Category>*>(listJob); | ||
123 | Category::List categoryList = job->itemList(); | 123 | Category::List categoryList = job->itemList(); | ||
124 | 124 | | |||
125 | QList<CategoryMetadata> categoryMetadataList; | 125 | QList<CategoryMetadata> categoryMetadataList; | ||
126 | foreach (const Category &category, categoryList) { | 126 | foreach (const Category &category, categoryList) { | ||
127 | if (mCategoryMap.contains(category.name())) { | 127 | if (mCategoryMap.contains(category.name())) { | ||
128 | qCDebug(KNEWSTUFFCORE) << "Adding category: " << category.name() << category.displayName(); | 128 | qCDebug(KNEWSTUFFCORE) << "Adding category: " << category.name() << category.displayName(); | ||
129 | mCategoryMap[category.name()] = category; | 129 | //If there is only the placeholder category, replace it | ||
130 | if (mCategoryMap.contains(category.name()) && !mCategoryMap.value(category.name()).isValid()) { | ||||
131 | mCategoryMap.insert(category.name(), category); | ||||
132 | } else { | ||||
133 | mCategoryMap.insertMulti(category.name(), category); | ||||
134 | } | ||||
davidedmundson: mCategoryMap is pre-populated with null categories in the constructor.
This looks like this… | |||||
130 | 135 | | |||
131 | CategoryMetadata categoryMetadata; | 136 | CategoryMetadata categoryMetadata; | ||
132 | categoryMetadata.id = category.id(); | 137 | categoryMetadata.id = category.id(); | ||
133 | categoryMetadata.name = category.name(); | 138 | categoryMetadata.name = category.name(); | ||
134 | categoryMetadata.displayName = category.displayName(); | 139 | categoryMetadata.displayName = category.displayName(); | ||
135 | categoryMetadataList << categoryMetadata; | 140 | categoryMetadataList << categoryMetadata; | ||
136 | } | 141 | } | ||
137 | } | 142 | } | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 174 | { | |||
198 | Attica::Category::List categoriesToSearch; | 203 | Attica::Category::List categoriesToSearch; | ||
199 | 204 | | |||
200 | if (request.categories.isEmpty()) { | 205 | if (request.categories.isEmpty()) { | ||
201 | // search in all categories | 206 | // search in all categories | ||
202 | categoriesToSearch = mCategoryMap.values(); | 207 | categoriesToSearch = mCategoryMap.values(); | ||
203 | } else { | 208 | } else { | ||
204 | categoriesToSearch.reserve(request.categories.size()); | 209 | categoriesToSearch.reserve(request.categories.size()); | ||
205 | foreach (const QString &categoryName, request.categories) { | 210 | foreach (const QString &categoryName, request.categories) { | ||
206 | categoriesToSearch.append(mCategoryMap.value(categoryName)); | 211 | categoriesToSearch.append(mCategoryMap.values(categoryName)); | ||
207 | } | 212 | } | ||
208 | } | 213 | } | ||
209 | 214 | | |||
210 | ListJob<Content> *job = m_provider.searchContents(categoriesToSearch, request.searchTerm, sorting, request.page, request.pageSize); | 215 | ListJob<Content> *job = m_provider.searchContents(categoriesToSearch, request.searchTerm, sorting, request.page, request.pageSize); | ||
211 | connect(job, &BaseJob::finished, this, &AtticaProvider::categoryContentsLoaded); | 216 | connect(job, &BaseJob::finished, this, &AtticaProvider::categoryContentsLoaded); | ||
212 | 217 | | |||
213 | mEntryJob = job; | 218 | mEntryJob = job; | ||
214 | job->start(); | 219 | job->start(); | ||
▲ Show 20 Lines • Show All 284 Lines • Show Last 20 Lines |
mCategoryMap is pre-populated with null categories in the constructor.
This looks like this now won't ever update them.