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>
|
|
27 |
#include "videocollectioncommon.h"
|
|
28 |
|
|
29 |
// CVideoListDataModel::Data returns valid variant when used this and name exists for the row.
|
|
30 |
const int INVALID_ROLE_FOR_SORTING = VideoCollectionCommon::KeyStatus+10;
|
|
31 |
|
|
32 |
class VideoCollectionClient;
|
|
33 |
|
|
34 |
|
|
35 |
class VideoListDataModel : public QAbstractItemModel
|
|
36 |
{
|
|
37 |
|
|
38 |
Q_OBJECT
|
|
39 |
|
|
40 |
public: // Constructors and destructor
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Constructor
|
|
44 |
*
|
|
45 |
*/
|
|
46 |
VideoListDataModel(QObject *parent = NULL);
|
|
47 |
|
|
48 |
/**
|
|
49 |
* destructor
|
|
50 |
*
|
|
51 |
*/
|
|
52 |
virtual ~VideoListDataModel();
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Initializes model. Sets model cache proxy and cache's plugin to
|
|
56 |
* to be this object. Creates videolist and puts it to observe
|
|
57 |
* collection client. Calls connectSignals to connect signals into
|
|
58 |
* appropriate slots
|
|
59 |
*
|
|
60 |
* @paran collection mpx video collectionobject
|
|
61 |
*
|
|
62 |
* @return int: 0 if everything ok
|
|
63 |
*/
|
|
64 |
int initialize( VideoCollectionClient* collection);
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Method calls video list data to check if there are valid media object
|
|
68 |
* at the given index. If there is, item id is returned.
|
|
69 |
*
|
|
70 |
* @param index index of the item to be opened
|
|
71 |
* @return int item id ( > 0), < 0 if no valid item.
|
|
72 |
*/
|
|
73 |
int mediaIdAtIndex(int index) const;
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Method calls video list data to check if there are valid media object
|
|
77 |
* for the given media id. If there is, file path for is returned.
|
|
78 |
*
|
|
79 |
* @param mediaId id of the item to be opened
|
|
80 |
* @return QString file path of the media at index, empty string if not valid item.
|
|
81 |
*/
|
|
82 |
QString mediaFilePathForId(int mediaId) const;
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Called by the client when removal of videos are requested.
|
|
86 |
* Sets video status to be removed to videolistdata and
|
|
87 |
* eventually calls collection to handle the actual removing.
|
|
88 |
*
|
|
89 |
* @param indexlist list of indeces of items requested for deletion
|
|
90 |
*
|
|
91 |
* @return bool true if removal startup succeeds
|
|
92 |
*/
|
|
93 |
bool removeRows(const QModelIndexList &indexList);
|
|
94 |
|
|
95 |
public: // from QAbstractItemModel
|
|
96 |
|
|
97 |
/**
|
|
98 |
* Returns mRowCount value
|
|
99 |
*
|
|
100 |
* @param parent - not used
|
|
101 |
*
|
|
102 |
* @return int
|
|
103 |
*/
|
|
104 |
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Method does nothing in this stub
|
|
108 |
*
|
|
109 |
* @param index - not used
|
|
110 |
*
|
|
111 |
* @return QMap empty map
|
|
112 |
*/
|
|
113 |
QMap<int, QVariant> itemData(const QModelIndex &index) const;
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Returns item value based on the role defined:
|
|
117 |
* Qt::DisplayRole: from mNames -list
|
|
118 |
* VideoCollectionCommon::KeySizeValue: from mSizes -list
|
|
119 |
* VideoCollectionCommon::KeyDate: from mDates -list
|
|
120 |
*
|
|
121 |
* @param index - item index to return
|
|
122 |
* @parema role - role indicating wanted value
|
|
123 |
*
|
|
124 |
* @return QVariant
|
|
125 |
*/
|
|
126 |
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Returns 0 always.
|
|
130 |
*
|
|
131 |
* @param parent - not used
|
|
132 |
*
|
|
133 |
* @return int
|
|
134 |
*/
|
|
135 |
int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Calls QAbstractItemModel::createIndex to return appropriate QModelIndex
|
|
139 |
*
|
|
140 |
* @param row - row index
|
|
141 |
* @param column - col index
|
|
142 |
* @param parent - not used
|
|
143 |
*
|
|
144 |
* @return QModelIndex
|
|
145 |
*/
|
|
146 |
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
|
147 |
|
|
148 |
/**
|
|
149 |
* returns invalid QModelIndex
|
|
150 |
*
|
|
151 |
* @return QModelIndex
|
|
152 |
*/
|
|
153 |
QModelIndex parent(const QModelIndex & index) const;
|
|
154 |
|
|
155 |
|
|
156 |
public: // helper methods for test
|
|
157 |
|
|
158 |
/**
|
|
159 |
* sets given value tomRowCount
|
|
160 |
*
|
|
161 |
* @param count - value to set
|
|
162 |
*/
|
|
163 |
void setUsedRowCount(int count);
|
|
164 |
|
|
165 |
/**
|
|
166 |
* appends given string to mNames
|
|
167 |
*
|
|
168 |
* @param data - value to append to list
|
|
169 |
*/
|
|
170 |
void appendData(QString data);
|
|
171 |
|
|
172 |
/**
|
|
173 |
* appends given uint to mSizes
|
|
174 |
*
|
|
175 |
* @param data - value to append to list
|
|
176 |
*/
|
|
177 |
void appendData(uint data);
|
|
178 |
|
|
179 |
/**
|
|
180 |
* appends given QDate to mDates
|
|
181 |
*
|
|
182 |
* @param data - value to append to list
|
|
183 |
*/
|
|
184 |
void appendData(QDateTime data);
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Appends given status to mStatuses.
|
|
188 |
*
|
|
189 |
* @param status - value to append to list.
|
|
190 |
*/
|
|
191 |
void appendStatus(int status);
|
|
192 |
|
|
193 |
signals:
|
|
194 |
|
|
195 |
/**
|
|
196 |
* This signal is connected to video list's details ready
|
|
197 |
* -signal indicating that video details data is fetched ok
|
|
198 |
*
|
|
199 |
* @param index index of the video item
|
|
200 |
*/
|
|
201 |
void fullVideoDetailsReady(int index);
|
|
202 |
|
|
203 |
/**
|
|
204 |
* Signals that the model is ready, ie. loaded all data from
|
|
205 |
* myvideocollection.
|
|
206 |
*/
|
|
207 |
void modelReady();
|
|
208 |
|
|
209 |
public:
|
|
210 |
|
|
211 |
static bool mInitFails;
|
|
212 |
static bool mRemoveRowsFails;
|
|
213 |
static bool mGetMediaIdAtIndexFails;
|
|
214 |
static QString mMediaFilePathReturnValue;
|
|
215 |
|
|
216 |
static int mLastDeletedIndexRow;
|
|
217 |
|
|
218 |
private:
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Setted count of rows. Not necessary match the actual count.
|
|
222 |
*/
|
|
223 |
int mRowCount;
|
|
224 |
|
|
225 |
/**
|
|
226 |
* List of strings when fetching Qt::DisplayRole
|
|
227 |
*/
|
|
228 |
QList<QString> mNames;
|
|
229 |
|
|
230 |
/**
|
|
231 |
* List of uints when fetching VideoCollectionCommon::KeySizeValue
|
|
232 |
*/
|
|
233 |
QList<uint> mSizes;
|
|
234 |
|
|
235 |
/**
|
|
236 |
* List of QDates when fetching VideoCollectionCommon::KeyDate
|
|
237 |
*/
|
|
238 |
QList<QDateTime> mDates;
|
|
239 |
|
|
240 |
/**
|
|
241 |
* List of statuses when fetching VideoCollectionCommon::KeyStatus
|
|
242 |
*/
|
|
243 |
QList<int> mStatuses;
|
|
244 |
|
|
245 |
};
|
|
246 |
|
|
247 |
#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H
|
|
248 |
|
|
249 |
|