Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemmodel.h
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Line(s) | 52 | public: | |||
---|---|---|---|---|---|
184 | struct RoleInfo | 184 | struct RoleInfo | ||
185 | { QByteArray role; | 185 | { QByteArray role; | ||
186 | QString translation; | 186 | QString translation; | ||
187 | QString group; | 187 | QString group; | ||
188 | bool requiresBaloo; | 188 | bool requiresBaloo; | ||
189 | bool requiresIndexer; | 189 | bool requiresIndexer; | ||
190 | }; | 190 | }; | ||
191 | 191 | | |||
192 | struct ItemData | ||||
193 | { | ||||
194 | KFileItem item; | ||||
195 | QHash<QByteArray, QVariant> values; | ||||
196 | ItemData* parent; | ||||
197 | }; | ||||
198 | | ||||
192 | /** | 199 | /** | ||
193 | * @return Provides static information for all available roles that | 200 | * @return Provides static information for all available roles that | ||
194 | * are supported by KFileItemModel. Some roles can only be | 201 | * are supported by KFileItemModel. Some roles can only be | ||
195 | * determined if Baloo is enabled and/or the Baloo | 202 | * determined if Baloo is enabled and/or the Baloo | ||
196 | * indexing is enabled. | 203 | * indexing is enabled. | ||
197 | */ | 204 | */ | ||
198 | static QList<RoleInfo> rolesInformation(); | 205 | static QList<RoleInfo> rolesInformation(); | ||
199 | 206 | | |||
207 | template<typename Func> | ||||
208 | void execute(Func&& executor) | ||||
209 | { | ||||
210 | std::for_each(m_itemData.cbegin(), m_itemData.cend(), std::forward<Func>(executor)); | ||||
211 | } | ||||
212 | | ||||
213 | template<typename Indexes, typename Func> | ||||
214 | void executeOnIndexes(const Indexes& indexes, Func&& executor) | ||||
215 | { | ||||
216 | std::for_each(indexes.begin(), indexes.end(), [&](int index) | ||||
217 | { | ||||
218 | std::forward<Func>(executor)(m_itemData.at(index)); | ||||
219 | }); | ||||
220 | } | ||||
221 | | ||||
200 | signals: | 222 | signals: | ||
201 | /** | 223 | /** | ||
202 | * Is emitted if the loading of a directory has been started. It is | 224 | * Is emitted if the loading of a directory has been started. It is | ||
203 | * assured that a signal directoryLoadingCompleted() will be send after | 225 | * assured that a signal directoryLoadingCompleted() will be send after | ||
204 | * the loading has been finished. For tracking the loading progress | 226 | * the loading has been finished. For tracking the loading progress | ||
205 | * the signal directoryLoadingProgress() gets emitted in between. | 227 | * the signal directoryLoadingProgress() gets emitted in between. | ||
206 | */ | 228 | */ | ||
207 | void directoryLoadingStarted(); | 229 | void directoryLoadingStarted(); | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 305 | enum RoleType { | |||
289 | WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole, | 311 | WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole, | ||
290 | BitrateRole, OriginUrlRole, | 312 | BitrateRole, OriginUrlRole, | ||
291 | // Non-visible roles: | 313 | // Non-visible roles: | ||
292 | IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole, | 314 | IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole, | ||
293 | // Mandatory last entry: | 315 | // Mandatory last entry: | ||
294 | RolesCount | 316 | RolesCount | ||
295 | }; | 317 | }; | ||
296 | 318 | | |||
297 | struct ItemData | | |||
298 | { | | |||
299 | KFileItem item; | | |||
300 | QHash<QByteArray, QVariant> values; | | |||
301 | ItemData* parent; | | |||
302 | }; | | |||
303 | | ||||
304 | enum RemoveItemsBehavior { | 319 | enum RemoveItemsBehavior { | ||
305 | KeepItemData, | 320 | KeepItemData, | ||
306 | DeleteItemData | 321 | DeleteItemData | ||
307 | }; | 322 | }; | ||
308 | 323 | | |||
309 | void insertItems(QList<ItemData*>& items); | 324 | void insertItems(QList<ItemData*>& items); | ||
310 | void removeItems(const KItemRangeList& itemRanges, RemoveItemsBehavior behavior); | 325 | void removeItems(const KItemRangeList& itemRanges, RemoveItemsBehavior behavior); | ||
311 | 326 | | |||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |