58
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
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".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: stub VideoProxyModelGeneric implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "videoproxymodelgeneric.h"
|
|
19 |
#include "videoproxymodeldata.h"
|
|
20 |
#include "videocollectioncommon.h"
|
|
21 |
#include "videolistdatamodel.h"
|
|
22 |
|
|
23 |
using namespace VideoCollectionCommon;
|
|
24 |
|
|
25 |
int VideoProxyModelData::mSortRole = -1;
|
|
26 |
Qt::SortOrder VideoProxyModelData::mSortOrder = Qt::AscendingOrder;
|
|
27 |
bool VideoProxyModelData::mSortAsync = false;
|
|
28 |
bool VideoProxyModelData::mDeleteItemsFails = false;
|
|
29 |
bool VideoProxyModelData::mRemoveAlbumsFails = false;
|
|
30 |
int VideoProxyModelData::mDoSortingCallCount = 0;
|
|
31 |
bool VideoProxyModelData::mOpenFails = false;
|
|
32 |
QList<TMPXItemId> VideoProxyModelData::mItemIds = QList<TMPXItemId>();
|
|
33 |
QModelIndex VideoProxyModelData::mLastIndex = QModelIndex();
|
|
34 |
TMPXItemId VideoProxyModelData::mLastItemId = TMPXItemId::InvalidId();
|
|
35 |
TMPXItemId VideoProxyModelData::mOpenedItemId = TMPXItemId::InvalidId();
|
|
36 |
int VideoProxyModelData::mDetailsReturnValue = 0;
|
|
37 |
int VideoProxyModelData::mAddItemsInAlbumReturnValue = 0;
|
|
38 |
int VideoProxyModelData::mRemoveItemsFromAlbumReturnValue = 0;
|
|
39 |
TMPXItemId VideoProxyModelData::mGenericFilterId = TMPXItemId::InvalidId();
|
|
40 |
bool VideoProxyModelData::mGenericFilterValue = false;
|
|
41 |
TMPXItemId VideoProxyModelData::mNewAlbumId = TMPXItemId::InvalidId();
|
|
42 |
QString VideoProxyModelData::mLastItemNameInRename = "";
|
|
43 |
int VideoProxyModelData::mRenameItemReturnValue = 0;
|
|
44 |
QString VideoProxyModelData::mLastAddedAlbumName = "";
|
|
45 |
|
|
46 |
const TMPXItemId INVALID_ID = TMPXItemId::InvalidId();
|
|
47 |
|
|
48 |
VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent):
|
|
49 |
QSortFilterProxyModel(parent),
|
|
50 |
mModel(0),
|
|
51 |
mCollectionClient(0),
|
|
52 |
mLevel(VideoCollectionCommon::ELevelInvalid),
|
|
53 |
mIdleSortTimer(0),
|
|
54 |
mWantedSortRole(VideoCollectionCommon::KeyDateTime),
|
|
55 |
mDefaultSortRole(VideoCollectionCommon::KeyTitle)
|
|
56 |
{
|
|
57 |
|
|
58 |
}
|
|
59 |
|
|
60 |
VideoProxyModelGeneric::~VideoProxyModelGeneric()
|
|
61 |
{
|
|
62 |
VideoProxyModelData::reset();
|
|
63 |
}
|
|
64 |
|
|
65 |
int VideoProxyModelGeneric::initialize(VideoListDataModel *sourceModel)
|
|
66 |
{
|
|
67 |
mModel = sourceModel;
|
|
68 |
setSourceModel(mModel);
|
|
69 |
return 0;
|
|
70 |
}
|
|
71 |
|
|
72 |
bool VideoProxyModelGeneric::connectSignals()
|
|
73 |
{
|
|
74 |
// not stubbed
|
|
75 |
return true;
|
|
76 |
}
|
|
77 |
|
|
78 |
void VideoProxyModelGeneric::disconnectSignals()
|
|
79 |
{
|
|
80 |
// not stubbed
|
|
81 |
}
|
|
82 |
|
|
83 |
int VideoProxyModelGeneric::open(VideoCollectionCommon::TCollectionLevels level)
|
|
84 |
{
|
|
85 |
int err = 0;
|
|
86 |
|
|
87 |
mLevel = level;
|
|
88 |
if (VideoProxyModelData::mOpenFails)
|
|
89 |
{
|
|
90 |
err = -1;
|
|
91 |
}
|
|
92 |
|
|
93 |
return err;
|
|
94 |
}
|
|
95 |
|
|
96 |
void VideoProxyModelGeneric::doSorting(int sortingRole,
|
|
97 |
Qt::SortOrder order,
|
|
98 |
bool async)
|
|
99 |
{
|
|
100 |
VideoProxyModelData::mDoSortingCallCount++;
|
|
101 |
VideoProxyModelData::mSortRole = sortingRole;
|
|
102 |
VideoProxyModelData::mSortOrder = order;
|
|
103 |
VideoProxyModelData::mSortAsync = async;
|
|
104 |
setSortRole(sortingRole);
|
|
105 |
sort(0, order);
|
|
106 |
}
|
|
107 |
|
|
108 |
void VideoProxyModelGeneric::getSorting(int &sortingRole,
|
|
109 |
Qt::SortOrder &order)
|
|
110 |
{
|
|
111 |
sortingRole = VideoProxyModelData::mSortRole;
|
|
112 |
order = VideoProxyModelData::mSortOrder;
|
|
113 |
}
|
|
114 |
|
|
115 |
int VideoProxyModelGeneric::deleteItems(const QModelIndexList &indexList)
|
|
116 |
{
|
|
117 |
|
|
118 |
int err = 0;
|
|
119 |
if (VideoProxyModelData::mDeleteItemsFails)
|
|
120 |
{
|
|
121 |
err = -1;
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
if (indexList.count() > 0)
|
|
126 |
{
|
|
127 |
VideoProxyModelData::mLastIndex = indexList.at(0);
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
return err;
|
|
132 |
}
|
|
133 |
|
|
134 |
int VideoProxyModelGeneric::openItem(TMPXItemId mediaId)
|
|
135 |
{
|
|
136 |
VideoProxyModelData::mLastItemId = mediaId;
|
|
137 |
|
|
138 |
return 0;
|
|
139 |
}
|
|
140 |
|
|
141 |
int VideoProxyModelGeneric::back()
|
|
142 |
{
|
|
143 |
// not stubbed
|
|
144 |
return 0;
|
|
145 |
}
|
|
146 |
|
|
147 |
int VideoProxyModelGeneric::fetchItemDetails(const QModelIndex &index)
|
|
148 |
{
|
|
149 |
VideoProxyModelData::mLastIndex = index;
|
|
150 |
|
|
151 |
return VideoProxyModelData::mDetailsReturnValue;
|
|
152 |
}
|
|
153 |
|
|
154 |
void VideoProxyModelGeneric::processSorting()
|
|
155 |
{
|
|
156 |
// not stubbed
|
|
157 |
}
|
|
158 |
|
|
159 |
void VideoProxyModelGeneric::processSortingSlot()
|
|
160 |
{
|
|
161 |
// not stubbed
|
|
162 |
}
|
|
163 |
|
|
164 |
bool VideoProxyModelGeneric::lessThan(const QModelIndex &left,
|
|
165 |
const QModelIndex &right) const
|
|
166 |
{
|
|
167 |
Q_UNUSED(left);
|
|
168 |
Q_UNUSED(right);
|
|
169 |
// not stubbed
|
|
170 |
return true;
|
|
171 |
}
|
|
172 |
|
|
173 |
bool VideoProxyModelGeneric::filterAcceptsRow (int source_row,
|
|
174 |
const QModelIndex &source_parent) const
|
|
175 |
{
|
|
176 |
Q_UNUSED(source_row);
|
|
177 |
Q_UNUSED(source_parent);
|
|
178 |
// not stubbed
|
|
179 |
return true;
|
|
180 |
}
|
|
181 |
|
|
182 |
const TMPXItemId& VideoProxyModelGeneric::getMediaIdAtIndex(
|
|
183 |
const QModelIndex &index) const
|
|
184 |
{
|
|
185 |
if (index.row() >= 0 &&
|
|
186 |
index.row() < VideoProxyModelData::mItemIds.count())
|
|
187 |
{
|
|
188 |
return VideoProxyModelData::mItemIds[index.row()];
|
|
189 |
}
|
|
190 |
return INVALID_ID;
|
|
191 |
}
|
|
192 |
|
|
193 |
QModelIndex VideoProxyModelGeneric::indexOfId(const TMPXItemId &id)
|
|
194 |
{
|
|
195 |
//VideoListDataModel *sourceModel = qobject_cast<VideoListDataModel*>(sourceModel());
|
|
196 |
|
|
197 |
for(int i = 0; i < VideoProxyModelData::mItemIds.count(); i++)
|
|
198 |
{
|
|
199 |
if(VideoProxyModelData::mItemIds.at(i) == id)
|
|
200 |
{
|
|
201 |
//return sourceModel->index(i, 0);
|
|
202 |
return index(i, 0);
|
|
203 |
}
|
|
204 |
}
|
|
205 |
return QModelIndex();
|
|
206 |
}
|
|
207 |
|
|
208 |
QString VideoProxyModelGeneric::getMediaFilePathForId(const TMPXItemId &mediaId)
|
|
209 |
{
|
|
210 |
Q_UNUSED(mediaId);
|
|
211 |
// not stubbed
|
|
212 |
return QString();
|
|
213 |
}
|
|
214 |
|
|
215 |
TMPXItemId VideoProxyModelGeneric::addNewAlbum(const QString &title)
|
|
216 |
{
|
|
217 |
VideoProxyModelData::mLastAddedAlbumName = title;
|
|
218 |
return VideoProxyModelData::mNewAlbumId;
|
|
219 |
}
|
|
220 |
|
|
221 |
QString VideoProxyModelGeneric::resolveAlbumName(
|
|
222 |
const QString& albumName) const
|
|
223 |
{
|
|
224 |
QString name = albumName;
|
|
225 |
return name;
|
|
226 |
}
|
|
227 |
|
|
228 |
int VideoProxyModelGeneric::addItemsInAlbum(TMPXItemId &albumId, const QList<TMPXItemId> &mediaIds)
|
|
229 |
{
|
|
230 |
if(VideoProxyModelData::mAddItemsInAlbumReturnValue >= 0)
|
|
231 |
{
|
|
232 |
VideoProxyModelData::mLastItemId = albumId;
|
|
233 |
VideoProxyModelData::mItemIds.clear();
|
|
234 |
VideoProxyModelData::mItemIds = mediaIds;
|
|
235 |
}
|
|
236 |
// not stubbed
|
|
237 |
return VideoProxyModelData::mAddItemsInAlbumReturnValue;
|
|
238 |
}
|
|
239 |
|
|
240 |
int VideoProxyModelGeneric::removeAlbums(const QModelIndexList &indexList)
|
|
241 |
{
|
|
242 |
|
|
243 |
int err = 0;
|
|
244 |
if (VideoProxyModelData::mRemoveAlbumsFails)
|
|
245 |
{
|
|
246 |
err = -1;
|
|
247 |
}
|
|
248 |
else
|
|
249 |
{
|
|
250 |
if (indexList.count() > 0)
|
|
251 |
{
|
|
252 |
VideoProxyModelData::mLastIndex = indexList.at(0);
|
|
253 |
}
|
|
254 |
}
|
|
255 |
|
|
256 |
return err;
|
|
257 |
}
|
|
258 |
|
|
259 |
int VideoProxyModelGeneric::removeItemsFromAlbum(class TMPXItemId &album, QList<class TMPXItemId> const &mediaIds)
|
|
260 |
{
|
|
261 |
if(VideoProxyModelData::mRemoveItemsFromAlbumReturnValue >= 0)
|
|
262 |
{
|
|
263 |
VideoProxyModelData::mLastItemId = album;
|
|
264 |
VideoProxyModelData::mItemIds.clear();
|
|
265 |
VideoProxyModelData::mItemIds = mediaIds;
|
|
266 |
}
|
|
267 |
return VideoProxyModelData::mRemoveItemsFromAlbumReturnValue;
|
|
268 |
}
|
|
269 |
|
|
270 |
void VideoProxyModelGeneric::setAlbumInUse(const TMPXItemId &albumId)
|
|
271 |
{
|
|
272 |
VideoProxyModelData::mLastItemId = albumId;
|
|
273 |
}
|
|
274 |
|
|
275 |
int VideoProxyModelGeneric::renameItem(const TMPXItemId &itemId, const QString &newTitle)
|
|
276 |
{
|
|
277 |
if(VideoProxyModelData::mRemoveItemsFromAlbumReturnValue >= 0)
|
|
278 |
{
|
|
279 |
VideoProxyModelData::mLastItemId = itemId;
|
|
280 |
VideoProxyModelData::mLastItemNameInRename = newTitle;
|
|
281 |
|
|
282 |
}
|
|
283 |
return VideoProxyModelData::mRenameItemReturnValue;
|
|
284 |
}
|
|
285 |
|
|
286 |
TMPXItemId VideoProxyModelGeneric::getOpenItem() const
|
|
287 |
{
|
|
288 |
return VideoProxyModelData::mOpenedItemId;
|
|
289 |
}
|
|
290 |
|
|
291 |
void VideoProxyModelGeneric::setGenericIdFilter(const TMPXItemId &itemId, bool filterValue)
|
|
292 |
{
|
|
293 |
VideoProxyModelData::mGenericFilterId = itemId;
|
|
294 |
VideoProxyModelData::mGenericFilterValue = filterValue;
|
|
295 |
return;
|
|
296 |
}
|
|
297 |
|
|
298 |
// end of file
|