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