|
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: VideoListDataModel class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <qstringlist.h> |
|
19 |
|
20 #include "videolistdatamodel.h" |
|
21 #include "videolistdatamodeldata.h" |
|
22 |
|
23 QMap<int, QVariant> VideoListDataModelData::mData; |
|
24 QModelIndex VideoListDataModelData::mLastIndex; |
|
25 int VideoListDataModelData::mDataAccessCount = 0; |
|
26 int VideoListDataModelData::mRowCount = 0; |
|
27 int VideoListDataModelData::mRowCountDecrement = 0; |
|
28 TMPXItemId VideoListDataModelData::mItemId = TMPXItemId::InvalidId(); |
|
29 |
|
30 |
|
31 |
|
32 VideoListDataModel::VideoListDataModel(QObject *parent) : |
|
33 QAbstractItemModel(parent), |
|
34 d_ptr(0), |
|
35 mCollectionClient(0), |
|
36 mDeleteWorker(0), |
|
37 mInitialized(false) |
|
38 { |
|
39 // nop |
|
40 } |
|
41 |
|
42 VideoListDataModel::~VideoListDataModel() |
|
43 { |
|
44 VideoListDataModelData::reset(); |
|
45 } |
|
46 |
|
47 int VideoListDataModel::initialize() |
|
48 { |
|
49 if (VideoListDataModelData::mRowCount) |
|
50 { |
|
51 int newCount = VideoListDataModelData::mRowCount; |
|
52 int oldCount = VideoListDataModelData::mData.count(); |
|
53 if(newCount == oldCount) |
|
54 { |
|
55 return 0; |
|
56 } |
|
57 if (newCount < oldCount) |
|
58 { |
|
59 beginRemoveRows(QModelIndex(), newCount, oldCount); |
|
60 endRemoveRows(); |
|
61 } |
|
62 else |
|
63 { |
|
64 beginInsertRows(QModelIndex(), oldCount, newCount-1); |
|
65 endInsertRows(); |
|
66 } |
|
67 } |
|
68 else |
|
69 { |
|
70 reset(); |
|
71 } |
|
72 return 0; |
|
73 } |
|
74 |
|
75 VideoCollectionClient* VideoListDataModel::getCollectionClient() |
|
76 { |
|
77 // not stubbed |
|
78 return 0; |
|
79 } |
|
80 |
|
81 void VideoListDataModel::connectSignals() |
|
82 { |
|
83 // not stubbed |
|
84 } |
|
85 |
|
86 void VideoListDataModel::disconnectSignals() |
|
87 { |
|
88 // not stubbed |
|
89 } |
|
90 |
|
91 const TMPXItemId& VideoListDataModel::mediaIdAtIndex(const int &index) const |
|
92 { |
|
93 Q_UNUSED(index); |
|
94 // not stubbed |
|
95 return VideoListDataModelData::mItemId; |
|
96 } |
|
97 |
|
98 QString VideoListDataModel::mediaFilePathForId(const TMPXItemId &mediaId) const |
|
99 { |
|
100 Q_UNUSED(mediaId); |
|
101 // not stubbed |
|
102 return QString(); |
|
103 } |
|
104 |
|
105 int VideoListDataModel::rowCount(const QModelIndex &parent ) const |
|
106 { |
|
107 Q_UNUSED(parent); |
|
108 |
|
109 uint count = VideoListDataModelData::mRowCount - VideoListDataModelData::mRowCountDecrement; |
|
110 if(VideoListDataModelData::mRowCountDecrement > 0) |
|
111 { |
|
112 VideoListDataModelData::mRowCountDecrement--; |
|
113 } |
|
114 return count; |
|
115 } |
|
116 |
|
117 QMap<int, QVariant> VideoListDataModel::itemData(const QModelIndex &index) const |
|
118 { |
|
119 QMap<int, QVariant> itemData; |
|
120 if (index.isValid()) |
|
121 { |
|
122 // returns only basic data of the item |
|
123 itemData.insert(Qt::DisplayRole, data(index, Qt::DisplayRole)); |
|
124 itemData.insert(Qt::DecorationRole, data(index, Qt::DecorationRole)); |
|
125 itemData.insert(Qt::BackgroundRole, data(index, Qt::BackgroundRole)); |
|
126 } |
|
127 return itemData; |
|
128 } |
|
129 |
|
130 QString VideoListDataModel::prepareDetailRow(int &index) const |
|
131 { |
|
132 Q_UNUSED(index); |
|
133 |
|
134 // not stubbed |
|
135 return QString(); |
|
136 } |
|
137 |
|
138 QString VideoListDataModel::prepareSizeString(int &index) const |
|
139 { |
|
140 Q_UNUSED(index); |
|
141 |
|
142 // not stubbed |
|
143 return QString(); |
|
144 } |
|
145 |
|
146 QVariant VideoListDataModel::data(const QModelIndex &index, int role) const |
|
147 { |
|
148 QVariant returnValue = QVariant(); |
|
149 VideoListDataModelData::mLastIndex = index; |
|
150 VideoListDataModelData::mDataAccessCount++; |
|
151 if (index.isValid()) |
|
152 { |
|
153 returnValue = VideoListDataModelData::mData.value(role); |
|
154 } |
|
155 |
|
156 return returnValue; |
|
157 } |
|
158 |
|
159 int VideoListDataModel::columnCount(const QModelIndex &parent) const |
|
160 { |
|
161 Q_UNUSED(parent); |
|
162 |
|
163 return 1; |
|
164 } |
|
165 |
|
166 QModelIndex VideoListDataModel::index(int row, |
|
167 int column, |
|
168 const QModelIndex &parent) const |
|
169 { |
|
170 Q_UNUSED(parent); |
|
171 |
|
172 return createIndex(row, column); |
|
173 } |
|
174 |
|
175 QModelIndex VideoListDataModel::parent(const QModelIndex &index) const |
|
176 { |
|
177 Q_UNUSED(index); |
|
178 |
|
179 // not stubbed |
|
180 return QModelIndex(); |
|
181 } |
|
182 |
|
183 bool VideoListDataModel::removeRows(const QModelIndexList &indexList) |
|
184 { |
|
185 Q_UNUSED(indexList); |
|
186 |
|
187 // not stubbed |
|
188 return false; |
|
189 } |
|
190 |
|
191 bool VideoListDataModel::belongsToAlbum(const TMPXItemId &itemId, TMPXItemId albumId) const |
|
192 { |
|
193 Q_UNUSED(albumId); |
|
194 Q_UNUSED(itemId); |
|
195 |
|
196 // not stubbed |
|
197 return false; |
|
198 } |
|
199 |
|
200 void VideoListDataModel::setAlbumInUse(const TMPXItemId &albumId) |
|
201 { |
|
202 Q_UNUSED(albumId); |
|
203 |
|
204 // not stubbed |
|
205 } |
|
206 |
|
207 void VideoListDataModel::deleteStartingFailsSlot(QList<TMPXItemId>& ids) |
|
208 { |
|
209 Q_UNUSED(ids); |
|
210 |
|
211 // not stubbed |
|
212 } |
|
213 |
|
214 void VideoListDataModel::reportAsyncStatus(int statusCode, QVariant &additional) |
|
215 { |
|
216 Q_UNUSED(statusCode); |
|
217 Q_UNUSED(additional); |
|
218 |
|
219 // not stubbed |
|
220 } |
|
221 |
|
222 // end of file |