2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #ifndef MCLFITEMLISTMODEL_H
20 #define MCLFITEMLISTMODEL_H
23 #include <CLFContentListing.hrh>
28 * Content Listing Framework list model refresh type.
30 enum TCLFRefreshTypeFlags
32 /// Post filter is refreshed
33 ECLFRefreshPostFilter = 0x1,
34 /// Grouping is refreshed
35 ECLFRefreshGrouping = 0x2,
36 /// Sorting is refreshed
37 ECLFRefreshSorting = 0x4,
38 /// All filters are used
39 ECLFRefreshAll = 0xFFFFFFFF
42 // FORWARD DECLARATIONS
43 class MCLFItemListModelExt;
46 class MCLFCustomGrouper;
48 class MCLFSortingStyle;
49 class MCLFCustomSorter;
50 class TResourceReader;
55 * List Model for Content Listing Framework.
56 * This model is used to list Content Listing items. These items provide
57 * infomation of media files on the device and one item represents one media
58 * file. The model can be manipulated by sorters, post filters and groupers.
59 * List Model is created by using Content Listing Engine.<br><br>
62 * // Create a new List Model instance
63 * MCLFItemListModel* listModel = iEngine->CreateListModelLC( *myObserver );
65 * // Append music-type to wanted types array to exclude
66 * // all other files than music files from the list model
67 * RArray<TCLFMediaType> myMediaTypes;
68 * CleanupClosePushL( myMediaTypes );
69 * myMediaTypes.AppendL( ECLFMediaTypeMusic );
71 * // Set wanted types with SetWantedMimeTypesL or/and SetWantedMediaTypesL.
72 * // You can add both if you want.
73 * listModel->SetWantedMediaTypesL( myMediaTypes.Array() );
74 * CleanupStack::PopAndDestroy( &myMediaTypes );
76 * // Set sorting style (if you want to sort items)
77 * listModel->SetSortingStyle( mySortingStyle );
79 * // You can also add post filter, custom sorter and custom grouper to model.
81 * // Refresh the List Model.
82 * // The model will fetch items from server and use post filter to filter items,
83 * // grouping style or custom grouper to group items and finally sort items
84 * // with sorting style or custom sorter.
85 * listModel->RefreshL();
87 * // You can also refresh the post filter and sorting only. This call does not
88 * // fetch items from the server. The model is only filtered and sorted.
89 * listModel->RefreshL( ECLFRefreshPostFilter | ECLFRefreshSorting );
92 * @lib ContentListingFramework.lib
95 class MCLFItemListModel
97 public: // Constructors and destructor
102 virtual ~MCLFItemListModel() {}
104 public: // New functions
107 * Get Content Listing Framework item from the List Model.
109 * @pre aIndex >= 0 && aIndex < ItemCount()
110 * @param aIndex Index of the item
111 * @return Content Listing Framework item
113 virtual const MCLFItem& Item( TInt aIndex ) const = 0;
116 * Get number of items that are in the model.
118 * @return Count of items
120 virtual TInt ItemCount() const = 0;
123 * Activate or remove Sorting style.
124 * Setting a new sorting style will remove all old secondary sorters.
125 * Removing the sorting will also remove all secondary sorters too.
127 * @param aSortingStyle Sorting style to activate,
128 * if the pointer is NULL then sorting styles are removed
130 virtual void SetSortingStyle( MCLFSortingStyle* aSortingStyle ) = 0;
133 * Append a secondary sorting style to the list model.
134 * If an item doesn't have the field defined by primary or
135 * any previous secondary sorting style, the items are sorted using
136 * the next secondary sorting style. When a sorting style is
137 * appended using this method, it becomes the least significant
138 * sorting style until a new one is added after it.
139 * Items with undefined fields are placed before or after items
140 * with defined fields, depending on the undefined field position
141 * setting in MCLFSortingStyle.
143 * @param aSortingStyle Secondary sorting style to add.
145 virtual void AppendSecondarySortingStyleL(
146 MCLFSortingStyle& aSortingStyle ) = 0;
149 * Activate or remove custom sorter.
150 * Custom sorter will overwrite sorting style (if there is a sorting
151 * style activated). See MCLFCustomSorter for an example implementation
152 * of a custom sorter.
154 * @param aCustomSorter Custom sorter to activate.
155 * If the pointer is NULL, sorting style is used (if there is one
158 virtual void SetCustomSorter( MCLFCustomSorter* aCustomSorter ) = 0;
161 * Activate a grouping style for the List Model. Use ECLFNoGrouping as
162 * the grouping style if you want to remove grouping.
163 * Default grouping style is ECLFNoGrouping.
165 * @param aGrouping Grouping style to activate
167 virtual void SetGroupingStyle( TCLFGrouping aGrouping ) = 0;
170 * Activate or remove custom grouper. See MCLFCustomGrouper for an example
171 * implementation of a custom grouper.
172 * Custom grouper will overwrite grouping style.
174 * @param aCustomGrouper Custom grouper to activate,
175 * if pointer is NULL then then grouping style is used
177 virtual void SetCustomGrouper( MCLFCustomGrouper* aCustomGrouper ) = 0;
180 * Activate or remove post filter. Post filter removes items from the
181 * List Model. See MCLFPostFilter for an example implementation of a
184 * @param aPostFilter Post filter to activate,
185 * if pointer is NULL then active post filter will be removed.
187 virtual void SetPostFilter( MCLFPostFilter* aPostFilter ) = 0;
190 * Wanted mime types of media files that will be requested to the model.
191 * Overwrites old mime types if they were set.
193 * @param aMimeTypes List of wanted mime types. Mime types can contain
194 * wildcard characters "*" and "?", where "*" matches
195 * zero or more consecutive occurrences of any character
196 * and "?" matches a single occurrence of any character
198 virtual void SetWantedMimeTypesL( const MDesCArray& aMimeTypes ) = 0;
201 * Wanted mime types of media files that will be requested to the model.
202 * Overwrites old mime types if they were set.
204 * @param aResource Resource reader to mime type list resource.
205 * Use resource struct CLF_MIME_TYPE_ARRAY.
207 virtual void SetWantedMimeTypesL( TResourceReader& aResource ) = 0;
210 * Wanted media types of media files that will be requested to the model.
211 * Overwrites old media types if they were set.
213 * @param aMediaTypes List of wanted media types
215 virtual void SetWantedMediaTypesL(
216 const TArray<TInt>& aMediaTypes ) = 0;
220 * Wanted media types of media files that will be requested to the model.
221 * Overwrites old media types if they were set.
223 * @param aResource Resource reader to media type list resource.
224 * Use resource struct CLF_MEDIA_TYPE_ARRAY
226 virtual void SetWantedMediaTypesL( TResourceReader& aResource ) = 0;
229 * Refresh the model. This function is asynchronous (non-blocking) and
230 * MCLFOperationObserver is called when the refresh operation is
233 * Operations in refresh are executed in the following order:<br>
234 * 1. Model gets wanted items from server.
235 * Use SetWantedMediaTypesL and/or SetWantedMimeTypesL to define
237 * 2. Model uses post filter to filter items.<br>
238 * 3. Model groups items if grouping is selected.<br>
239 * 4. Model sorting items.<br>
242 virtual void RefreshL() = 0;
245 * Refresh the model. This function is synchronous (blocking). Use
246 * parameter(s) to define the type of refresh. See TCLFRefreshTypeFlags
249 * @param aRefreshType Flag(s) to use for refreshing.
251 virtual void RefreshL( TInt32 aRefreshType ) = 0;
254 * Cancel asynchronous refresh operation.
257 virtual void CancelRefresh() = 0;
259 private: // Extension interface
262 * This member is internal and not intended for use.
264 virtual MCLFItemListModelExt* Extension() { return NULL; }
268 #endif // MCLFITEMLISTMODEL_H