|
58
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2009 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: Dummy VideoProxyModelGeneric class implementation
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
// INCLUDE FILES
|
|
|
18 |
#include "videoproxymodelgeneric.h"
|
|
|
19 |
|
|
|
20 |
// ================= MEMBER FUNCTIONS =======================
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
// -----------------------------------------------------------------------------
|
|
|
24 |
// VideoProxyModelGeneric()
|
|
|
25 |
// -----------------------------------------------------------------------------
|
|
|
26 |
//
|
|
|
27 |
VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) :
|
|
|
28 |
QAbstractItemModel(parent),
|
|
|
29 |
mStartPlaybackIndex(TMPXItemId::InvalidId()),
|
|
|
30 |
mDeleteFileIndex(-1)
|
|
|
31 |
{
|
|
|
32 |
reset();
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
// -----------------------------------------------------------------------------
|
|
|
36 |
// ~VideoProxyModelGeneric()
|
|
|
37 |
// -----------------------------------------------------------------------------
|
|
|
38 |
//
|
|
|
39 |
VideoProxyModelGeneric::~VideoProxyModelGeneric()
|
|
|
40 |
{
|
|
|
41 |
reset();
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
// -----------------------------------------------------------------------------
|
|
|
45 |
// lastIndex()
|
|
|
46 |
// -----------------------------------------------------------------------------
|
|
|
47 |
//
|
|
|
48 |
QModelIndex VideoProxyModelGeneric::lastIndex()
|
|
|
49 |
{
|
|
|
50 |
return mLastIndex;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
// -----------------------------------------------------------------------------
|
|
|
54 |
// lastIndex()
|
|
|
55 |
// -----------------------------------------------------------------------------
|
|
|
56 |
//
|
|
|
57 |
TMPXItemId VideoProxyModelGeneric::lastId()
|
|
|
58 |
{
|
|
|
59 |
return mLastId;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
// -----------------------------------------------------------------------------
|
|
|
63 |
// dataAccessCount()
|
|
|
64 |
// -----------------------------------------------------------------------------
|
|
|
65 |
//
|
|
|
66 |
int VideoProxyModelGeneric::dataAccessCount()
|
|
|
67 |
{
|
|
|
68 |
return mDataAccessCount;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
// -----------------------------------------------------------------------------
|
|
|
72 |
// reset()
|
|
|
73 |
// -----------------------------------------------------------------------------
|
|
|
74 |
//
|
|
|
75 |
void VideoProxyModelGeneric::reset()
|
|
|
76 |
{
|
|
|
77 |
mLastIndex = QModelIndex();
|
|
|
78 |
mLastId = TMPXItemId::InvalidId();
|
|
|
79 |
mDataAccessCount = 0;
|
|
|
80 |
mRowCount = 0;
|
|
|
81 |
mData.clear();
|
|
|
82 |
mStartPlaybackIndex = TMPXItemId::InvalidId();
|
|
|
83 |
mDeleteFileIndex = -1;
|
|
|
84 |
mDatareturnsInvalid = false;
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
// -----------------------------------------------------------------------------
|
|
|
88 |
// setDataReturnInvalid()
|
|
|
89 |
// -----------------------------------------------------------------------------
|
|
|
90 |
//
|
|
|
91 |
void VideoProxyModelGeneric::setDataReturnInvalid(bool setInvalid)
|
|
|
92 |
{
|
|
|
93 |
mDatareturnsInvalid = setInvalid;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
// -----------------------------------------------------------------------------
|
|
|
97 |
// setData()
|
|
|
98 |
// -----------------------------------------------------------------------------
|
|
|
99 |
//
|
|
|
100 |
void VideoProxyModelGeneric::setData(int role, QVariant data)
|
|
|
101 |
{
|
|
|
102 |
mData.insert(role, data);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
// -----------------------------------------------------------------------------
|
|
|
106 |
// setRowCount()
|
|
|
107 |
// -----------------------------------------------------------------------------
|
|
|
108 |
//
|
|
|
109 |
void VideoProxyModelGeneric::setRowCount(int count)
|
|
|
110 |
{
|
|
|
111 |
if ( count == mRowCount ) return;
|
|
|
112 |
|
|
|
113 |
if ( count > mRowCount ) {
|
|
|
114 |
beginInsertRows(QModelIndex(), mRowCount, count);
|
|
|
115 |
mRowCount = count;
|
|
|
116 |
endInsertRows();
|
|
|
117 |
} else {
|
|
|
118 |
beginRemoveRows(QModelIndex(), count, mRowCount);
|
|
|
119 |
mRowCount = count;
|
|
|
120 |
endRemoveRows();
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
// -----------------------------------------------------------------------------
|
|
|
125 |
// rowCount()
|
|
|
126 |
// -----------------------------------------------------------------------------
|
|
|
127 |
//
|
|
|
128 |
int VideoProxyModelGeneric::rowCount(const QModelIndex &parent ) const
|
|
|
129 |
{
|
|
|
130 |
// according to Qt documentation if parent is valid this should return 0 if
|
|
|
131 |
// implementing a table based implementation like this.
|
|
|
132 |
if (parent.isValid())
|
|
|
133 |
{
|
|
|
134 |
return 0;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
return mRowCount;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
// -----------------------------------------------------------------------------
|
|
|
141 |
// itemData()
|
|
|
142 |
// -----------------------------------------------------------------------------
|
|
|
143 |
//
|
|
|
144 |
QMap<int, QVariant> VideoProxyModelGeneric::itemData(const QModelIndex &index) const
|
|
|
145 |
{
|
|
|
146 |
QMap<int, QVariant> itemData;
|
|
|
147 |
if (index.isValid())
|
|
|
148 |
{
|
|
|
149 |
// returns only basic data of the item
|
|
|
150 |
itemData.insert(Qt::DisplayRole, data(index, Qt::DisplayRole));
|
|
|
151 |
itemData.insert(Qt::DecorationRole, data(index, Qt::DecorationRole));
|
|
|
152 |
itemData.insert(Qt::BackgroundRole, data(index, Qt::BackgroundRole));
|
|
|
153 |
}
|
|
|
154 |
return itemData;
|
|
|
155 |
|
|
|
156 |
}
|
|
|
157 |
// -----------------------------------------------------------------------------
|
|
|
158 |
// data()
|
|
|
159 |
// -----------------------------------------------------------------------------
|
|
|
160 |
//
|
|
|
161 |
QVariant VideoProxyModelGeneric::data(const QModelIndex & index, int role) const
|
|
|
162 |
{
|
|
|
163 |
QVariant returnValue = QVariant();
|
|
|
164 |
mLastIndex = index;
|
|
|
165 |
mDataAccessCount++;
|
|
|
166 |
if (index.isValid() && !mDatareturnsInvalid)
|
|
|
167 |
{
|
|
|
168 |
returnValue = mData.value(role);
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
return returnValue;
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
// -----------------------------------------------------------------------------
|
|
|
175 |
// columnCount()
|
|
|
176 |
// -----------------------------------------------------------------------------
|
|
|
177 |
//
|
|
|
178 |
int VideoProxyModelGeneric::columnCount(const QModelIndex & parent) const
|
|
|
179 |
{
|
|
|
180 |
// according to Qt documentation if parent is valid this should return 0 if
|
|
|
181 |
// implementing a table based implementation like this.
|
|
|
182 |
if (parent.isValid())
|
|
|
183 |
{
|
|
|
184 |
return 0;
|
|
|
185 |
}
|
|
|
186 |
else
|
|
|
187 |
{
|
|
|
188 |
return 1;
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
// -----------------------------------------------------------------------------
|
|
|
193 |
// index()
|
|
|
194 |
// -----------------------------------------------------------------------------
|
|
|
195 |
//
|
|
|
196 |
QModelIndex VideoProxyModelGeneric::index(int row, int column, const QModelIndex & /*parent*/) const
|
|
|
197 |
{
|
|
|
198 |
return createIndex(row, column);
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
// -----------------------------------------------------------------------------
|
|
|
202 |
// parent()
|
|
|
203 |
// -----------------------------------------------------------------------------
|
|
|
204 |
//
|
|
|
205 |
QModelIndex VideoProxyModelGeneric::parent(const QModelIndex & /*index*/) const
|
|
|
206 |
{
|
|
|
207 |
return QModelIndex();
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
// -----------------------------------------------------------------------------
|
|
|
211 |
// openItem()
|
|
|
212 |
// -----------------------------------------------------------------------------
|
|
|
213 |
//
|
|
|
214 |
int VideoProxyModelGeneric::openItem(const TMPXItemId &index)
|
|
|
215 |
{
|
|
|
216 |
mStartPlaybackIndex = index;
|
|
|
217 |
return 0;
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
// -----------------------------------------------------------------------------
|
|
|
221 |
// deleteItems()
|
|
|
222 |
// -----------------------------------------------------------------------------
|
|
|
223 |
//
|
|
|
224 |
int VideoProxyModelGeneric::deleteItems(const QModelIndexList &indexList)
|
|
|
225 |
{
|
|
|
226 |
if(indexList.count() > 0)
|
|
|
227 |
{
|
|
|
228 |
mDeleteFileIndex = indexList.at(0).row();
|
|
|
229 |
return 0;
|
|
|
230 |
}
|
|
|
231 |
else
|
|
|
232 |
{
|
|
|
233 |
mDeleteFileIndex = -1;
|
|
|
234 |
return -1;
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
// -----------------------------------------------------------------------------
|
|
|
240 |
// startPlaybackIndex()
|
|
|
241 |
// -----------------------------------------------------------------------------
|
|
|
242 |
//
|
|
|
243 |
TMPXItemId VideoProxyModelGeneric::startPlaybackIndex()
|
|
|
244 |
{
|
|
|
245 |
return mStartPlaybackIndex;
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
// -----------------------------------------------------------------------------
|
|
|
249 |
// deleteFileIndex()
|
|
|
250 |
// -----------------------------------------------------------------------------
|
|
|
251 |
//
|
|
|
252 |
int VideoProxyModelGeneric::deleteFileIndex()
|
|
|
253 |
{
|
|
|
254 |
return mDeleteFileIndex;
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
// -----------------------------------------------------------------------------
|
|
|
258 |
// sourceModel()
|
|
|
259 |
// -----------------------------------------------------------------------------
|
|
|
260 |
//
|
|
|
261 |
VideoProxyModelGeneric* VideoProxyModelGeneric::sourceModel()
|
|
|
262 |
{
|
|
|
263 |
return this;
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
// -----------------------------------------------------------------------------
|
|
|
267 |
// getMediaIdAtIndex()
|
|
|
268 |
// -----------------------------------------------------------------------------
|
|
|
269 |
//
|
|
|
270 |
TMPXItemId VideoProxyModelGeneric::getMediaIdAtIndex(const QModelIndex &/*index*/)
|
|
|
271 |
{
|
|
|
272 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
|
273 |
id.iId1 = mLastIndex.row();
|
|
|
274 |
id.iId2 = 0;
|
|
|
275 |
return id;
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
// -----------------------------------------------------------------------------
|
|
|
279 |
// VideoProxyModelGeneric::indexOfId()
|
|
|
280 |
// -----------------------------------------------------------------------------
|
|
|
281 |
//
|
|
|
282 |
QModelIndex VideoProxyModelGeneric::indexOfId(TMPXItemId id)
|
|
|
283 |
{
|
|
|
284 |
mLastId = id;
|
|
|
285 |
mLastIndex = createIndex(id.iId1, 0);
|
|
|
286 |
return mLastIndex; //rikki! createIndex(row, column)
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
// End of file
|