30
|
1 |
|
|
2 |
/**
|
|
3 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Initial Contributors:
|
|
11 |
* Nokia Corporation - initial contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description: Stub collection client to be used when unit testing videocollectionsortfilterproxy
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#ifndef __STUB_VIDEOLISTDATAMODELFORPROXY_H
|
|
20 |
#define __STUB_VIDEOLISTDATAMODELFORPROXY_H
|
|
21 |
|
|
22 |
#include <QObject>
|
|
23 |
#include <QList>
|
|
24 |
#include <QString>
|
|
25 |
#include <qabstractitemmodel.h>
|
|
26 |
#include <qdatetime.h>
|
34
|
27 |
#include <mpxitemid.h>
|
30
|
28 |
#include "videocollectioncommon.h"
|
|
29 |
|
|
30 |
// CVideoListDataModel::Data returns valid variant when used this and name exists for the row.
|
|
31 |
const int INVALID_ROLE_FOR_SORTING = VideoCollectionCommon::KeyStatus+10;
|
|
32 |
|
|
33 |
class VideoCollectionClient;
|
|
34 |
|
|
35 |
|
|
36 |
class VideoListDataModel : public QAbstractItemModel
|
|
37 |
{
|
|
38 |
|
|
39 |
Q_OBJECT
|
|
40 |
|
|
41 |
public: // Constructors and destructor
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Constructor
|
|
45 |
*
|
|
46 |
*/
|
|
47 |
VideoListDataModel(QObject *parent = NULL);
|
|
48 |
|
|
49 |
/**
|
|
50 |
* destructor
|
|
51 |
*
|
|
52 |
*/
|
|
53 |
virtual ~VideoListDataModel();
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Initializes model. Sets model cache proxy and cache's plugin to
|
|
57 |
* to be this object. Creates videolist and puts it to observe
|
|
58 |
* collection client. Calls connectSignals to connect signals into
|
|
59 |
* appropriate slots
|
|
60 |
*
|
|
61 |
* @paran collection mpx video collectionobject
|
|
62 |
*
|
|
63 |
* @return int: 0 if everything ok
|
|
64 |
*/
|
34
|
65 |
int initialize();
|
30
|
66 |
|
|
67 |
/**
|
|
68 |
* Method calls video list data to check if there are valid media object
|
|
69 |
* at the given index. If there is, item id is returned.
|
|
70 |
*
|
|
71 |
* @param index index of the item to be opened
|
34
|
72 |
* @return TMPXItemId item id ( > 0), < 0 if no valid item.
|
30
|
73 |
*/
|
34
|
74 |
TMPXItemId mediaIdAtIndex(int index) const;
|
30
|
75 |
|
|
76 |
/**
|
|
77 |
* Method calls video list data to check if there are valid media object
|
|
78 |
* for the given media id. If there is, file path for is returned.
|
|
79 |
*
|
|
80 |
* @param mediaId id of the item to be opened
|
|
81 |
* @return QString file path of the media at index, empty string if not valid item.
|
|
82 |
*/
|
|
83 |
QString mediaFilePathForId(int mediaId) const;
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Called by the client when removal of videos are requested.
|
|
87 |
* Sets video status to be removed to videolistdata and
|
|
88 |
* eventually calls collection to handle the actual removing.
|
|
89 |
*
|
|
90 |
* @param indexlist list of indeces of items requested for deletion
|
|
91 |
*
|
|
92 |
* @return bool true if removal startup succeeds
|
|
93 |
*/
|
|
94 |
bool removeRows(const QModelIndexList &indexList);
|
34
|
95 |
|
|
96 |
/**
|
|
97 |
* sets mAlbumInUse
|
|
98 |
*/
|
|
99 |
void setAlbumInUse(TMPXItemId itemId);
|
|
100 |
|
|
101 |
/**
|
|
102 |
* returns mAlbumInUse
|
|
103 |
*/
|
|
104 |
TMPXItemId albumInUse();
|
|
105 |
|
|
106 |
/**
|
|
107 |
* returns mBelongsToAlbum
|
|
108 |
*/
|
|
109 |
bool belongsToAlbum(TMPXItemId itemId, TMPXItemId albumId = TMPXItemId::InvalidId());
|
|
110 |
|
|
111 |
/**
|
35
|
112 |
* returns mRemoveFrAlbumReturn
|
|
113 |
*/
|
|
114 |
int removeItemsFromAlbum(TMPXItemId &albumId, const QList<TMPXItemId> &items);
|
|
115 |
|
|
116 |
/**
|
34
|
117 |
* returns index of first occurence of provided id
|
|
118 |
*/
|
|
119 |
QModelIndex indexOfId(TMPXItemId id);
|
|
120 |
|
|
121 |
/**
|
|
122 |
* returns collection client
|
|
123 |
*/
|
|
124 |
VideoCollectionClient* getCollectionClient();
|
30
|
125 |
|
|
126 |
public: // from QAbstractItemModel
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Returns mRowCount value
|
|
130 |
*
|
|
131 |
* @param parent - not used
|
|
132 |
*
|
|
133 |
* @return int
|
|
134 |
*/
|
|
135 |
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Method does nothing in this stub
|
|
139 |
*
|
|
140 |
* @param index - not used
|
|
141 |
*
|
|
142 |
* @return QMap empty map
|
|
143 |
*/
|
|
144 |
QMap<int, QVariant> itemData(const QModelIndex &index) const;
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Returns item value based on the role defined:
|
|
148 |
* Qt::DisplayRole: from mNames -list
|
|
149 |
* VideoCollectionCommon::KeySizeValue: from mSizes -list
|
|
150 |
* VideoCollectionCommon::KeyDate: from mDates -list
|
|
151 |
*
|
|
152 |
* @param index - item index to return
|
|
153 |
* @parema role - role indicating wanted value
|
|
154 |
*
|
|
155 |
* @return QVariant
|
|
156 |
*/
|
|
157 |
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Returns 0 always.
|
|
161 |
*
|
|
162 |
* @param parent - not used
|
|
163 |
*
|
|
164 |
* @return int
|
|
165 |
*/
|
|
166 |
int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Calls QAbstractItemModel::createIndex to return appropriate QModelIndex
|
|
170 |
*
|
|
171 |
* @param row - row index
|
|
172 |
* @param column - col index
|
|
173 |
* @param parent - not used
|
|
174 |
*
|
|
175 |
* @return QModelIndex
|
|
176 |
*/
|
|
177 |
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
|
178 |
|
|
179 |
/**
|
|
180 |
* returns invalid QModelIndex
|
|
181 |
*
|
|
182 |
* @return QModelIndex
|
|
183 |
*/
|
|
184 |
QModelIndex parent(const QModelIndex & index) const;
|
|
185 |
|
|
186 |
|
|
187 |
public: // helper methods for test
|
34
|
188 |
|
|
189 |
/**
|
|
190 |
* emit album changed signal
|
|
191 |
*/
|
|
192 |
void emitAlbumChanged();
|
30
|
193 |
|
|
194 |
/**
|
34
|
195 |
* clears mData
|
30
|
196 |
*/
|
34
|
197 |
void removeAll();
|
|
198 |
|
30
|
199 |
|
|
200 |
/**
|
34
|
201 |
* adds provided id to mData
|
|
202 |
*/
|
|
203 |
void appendData(TMPXItemId data);
|
|
204 |
|
|
205 |
/**
|
|
206 |
* appends given string to mData
|
30
|
207 |
*
|
|
208 |
* @param data - value to append to list
|
|
209 |
*/
|
|
210 |
void appendData(QString data);
|
|
211 |
|
|
212 |
/**
|
34
|
213 |
* appends given uint to mData
|
30
|
214 |
*
|
|
215 |
* @param data - value to append to list
|
|
216 |
*/
|
|
217 |
void appendData(uint data);
|
|
218 |
|
|
219 |
/**
|
34
|
220 |
* appends given QDate to mData
|
30
|
221 |
*
|
|
222 |
* @param data - value to append to list
|
|
223 |
*/
|
|
224 |
void appendData(QDateTime data);
|
|
225 |
|
|
226 |
/**
|
34
|
227 |
* Appends given status to mData.
|
30
|
228 |
*
|
|
229 |
* @param status - value to append to list.
|
|
230 |
*/
|
|
231 |
void appendStatus(int status);
|
|
232 |
|
|
233 |
signals:
|
|
234 |
|
|
235 |
/**
|
|
236 |
* This signal is connected to video list's details ready
|
|
237 |
* -signal indicating that video details data is fetched ok
|
|
238 |
*
|
34
|
239 |
* @param id of the item
|
30
|
240 |
*/
|
34
|
241 |
void fullVideoDetailsReady(TMPXItemId);
|
30
|
242 |
|
|
243 |
/**
|
|
244 |
* Signals that the model is ready, ie. loaded all data from
|
|
245 |
* myvideocollection.
|
|
246 |
*/
|
|
247 |
void modelReady();
|
34
|
248 |
|
|
249 |
/**
|
|
250 |
* signals when model's internal data has changed
|
|
251 |
*/
|
|
252 |
void modelChanged();
|
|
253 |
|
|
254 |
/**
|
|
255 |
* signals when album data has changed
|
|
256 |
*/
|
|
257 |
void albumChanged();
|
36
|
258 |
|
|
259 |
/**
|
|
260 |
* signals when item has been modified
|
|
261 |
*/
|
|
262 |
void itemModified(const TMPXItemId &itemId);
|
30
|
263 |
|
|
264 |
public:
|
|
265 |
|
|
266 |
static bool mInitFails;
|
34
|
267 |
|
30
|
268 |
static bool mRemoveRowsFails;
|
34
|
269 |
|
|
270 |
static bool mGetMediaIdAtIndexFails;
|
|
271 |
|
|
272 |
static bool mBelongsToAlbum;
|
|
273 |
|
|
274 |
static bool mReturnInvalid;
|
|
275 |
|
35
|
276 |
static int mRemoveFrAlbumReturn;
|
|
277 |
|
30
|
278 |
static QString mMediaFilePathReturnValue;
|
|
279 |
|
|
280 |
static int mLastDeletedIndexRow;
|
|
281 |
|
34
|
282 |
TMPXItemId mAlbumInUse;
|
|
283 |
|
30
|
284 |
private:
|
34
|
285 |
|
|
286 |
class DummyData
|
|
287 |
{
|
|
288 |
public:
|
|
289 |
DummyData() :
|
|
290 |
mId(TMPXItemId::InvalidId()),
|
|
291 |
mName(""),
|
|
292 |
mSize(666),
|
|
293 |
mDate(QDateTime()),
|
|
294 |
mStatus(-1)
|
|
295 |
{}
|
|
296 |
TMPXItemId mId;
|
|
297 |
QString mName;
|
|
298 |
uint mSize;
|
|
299 |
QDateTime mDate;
|
|
300 |
int mStatus;
|
|
301 |
};
|
30
|
302 |
|
|
303 |
/**
|
|
304 |
* List of strings when fetching Qt::DisplayRole
|
|
305 |
*/
|
34
|
306 |
QList<DummyData*> mData;
|
|
307 |
|
30
|
308 |
/**
|
34
|
309 |
* colleciton client object, owned
|
|
310 |
*/
|
|
311 |
VideoCollectionClient *mCollectionClient;
|
30
|
312 |
};
|
|
313 |
|
|
314 |
#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H
|
|
315 |
|
|
316 |
|