34
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
35
|
18 |
#include <qdebug.h>
|
34
|
19 |
#include <qset.h>
|
|
20 |
#include <qstring.h>
|
|
21 |
#include <hblistview.h>
|
35
|
22 |
#include <hbmenu.h>
|
34
|
23 |
|
36
|
24 |
#include "videocollectioncommon.h"
|
34
|
25 |
#include "videocollectionuiloader.h"
|
36
|
26 |
#include "videocollectionuiloaderdef.h"
|
34
|
27 |
#include "videolistview.h"
|
|
28 |
#include "videolistwidget.h"
|
|
29 |
#include "videolistselectiondialog.h"
|
36
|
30 |
#include "videocollectionwrapper.h"
|
34
|
31 |
|
|
32 |
#include "videocollectionuiloaderdata.h"
|
|
33 |
|
|
34 |
bool VideoCollectionUiLoaderData::mFindFailure = false;
|
|
35 |
bool VideoCollectionUiLoaderData::mFailDialogLoad = false;
|
|
36 |
QStringList VideoCollectionUiLoaderData::mFindFailureNameList;
|
36
|
37 |
QMap<VideoCollectionUiLoader::ActionIds, HbAction*> VideoCollectionUiLoaderData::mMenuActions;
|
|
38 |
int VideoCollectionUiLoaderData::mLastLoadPhasedData = -1;
|
63
|
39 |
int VideoCollectionUiLoaderData::mAddDataCallCount = 0;
|
34
|
40 |
|
|
41 |
VideoCollectionUiLoader::VideoCollectionUiLoader():
|
|
42 |
HbDocumentLoader(),
|
36
|
43 |
mTimerId(0),
|
63
|
44 |
mSortGroup(0),
|
36
|
45 |
mIsService(0)
|
34
|
46 |
{
|
|
47 |
// not stubbed
|
|
48 |
}
|
|
49 |
|
|
50 |
VideoCollectionUiLoader::~VideoCollectionUiLoader()
|
|
51 |
{
|
|
52 |
VideoCollectionUiLoaderData::reset();
|
|
53 |
}
|
|
54 |
|
36
|
55 |
void VideoCollectionUiLoader::loadPhase(int loadPhase)
|
|
56 |
{
|
|
57 |
VideoCollectionUiLoaderData::mLastLoadPhasedData = loadPhase;
|
|
58 |
}
|
|
59 |
|
|
60 |
void VideoCollectionUiLoader::addData(QList<VideoCollectionUiLoaderParam> params,
|
34
|
61 |
QObject *receiver,
|
36
|
62 |
const char *slot)
|
34
|
63 |
{
|
63
|
64 |
VideoCollectionUiLoaderData::mAddDataCallCount++;
|
36
|
65 |
Q_UNUSED(params);
|
34
|
66 |
Q_UNUSED(receiver);
|
36
|
67 |
Q_UNUSED(slot);
|
|
68 |
}
|
|
69 |
|
|
70 |
void VideoCollectionUiLoader::removeOrphanFromList(QObject *object)
|
|
71 |
{
|
|
72 |
if (mOrphans.contains(object))
|
|
73 |
{
|
|
74 |
mOrphans.removeOne(object);
|
|
75 |
}
|
|
76 |
|
|
77 |
const QString &name = mObjects.key(object);
|
|
78 |
if (!name.isEmpty())
|
|
79 |
{
|
|
80 |
// found from list, remove
|
|
81 |
mObjects.remove(name);
|
|
82 |
}
|
34
|
83 |
}
|
|
84 |
|
|
85 |
void VideoCollectionUiLoader::setIsService(bool isService)
|
|
86 |
{
|
36
|
87 |
mIsService = isService;
|
|
88 |
}
|
|
89 |
|
|
90 |
void VideoCollectionUiLoader::load(const QString &fileName, bool *ok)
|
|
91 |
{
|
|
92 |
QObjectList list = HbDocumentLoader::load(fileName, ok);
|
|
93 |
storeOrphans(list);
|
|
94 |
}
|
|
95 |
|
|
96 |
void VideoCollectionUiLoader::load(const QString &fileName, const QString §ion , bool *ok)
|
|
97 |
{
|
|
98 |
QObjectList list = HbDocumentLoader::load(fileName, section, ok);
|
|
99 |
storeOrphans(list);
|
34
|
100 |
}
|
|
101 |
|
38
|
102 |
QGraphicsWidget* VideoCollectionUiLoader::doFindWidget(const QString &name, bool loadIfNotFound)
|
34
|
103 |
{
|
38
|
104 |
Q_UNUSED(loadIfNotFound);
|
34
|
105 |
QGraphicsWidget *widget = 0;
|
35
|
106 |
if(VideoCollectionUiLoaderData::mFindFailure)
|
|
107 |
{
|
|
108 |
return 0;
|
|
109 |
}
|
|
110 |
if(!VideoCollectionUiLoaderData::mFindFailureNameList.contains(name))
|
|
111 |
{
|
|
112 |
widget = HbDocumentLoader::findWidget(name);
|
|
113 |
}
|
34
|
114 |
return widget;
|
|
115 |
}
|
|
116 |
|
38
|
117 |
QObject* VideoCollectionUiLoader::doFindObject(const QString &name, bool loadIfNotFound)
|
34
|
118 |
{
|
38
|
119 |
Q_UNUSED(loadIfNotFound);
|
34
|
120 |
QObject *object = 0;
|
35
|
121 |
if(VideoCollectionUiLoaderData::mFindFailure)
|
|
122 |
{
|
|
123 |
return 0;
|
|
124 |
}
|
|
125 |
if(!VideoCollectionUiLoaderData::mFindFailureNameList.contains(name))
|
|
126 |
{
|
|
127 |
object = HbDocumentLoader::findObject(name);
|
|
128 |
}
|
34
|
129 |
return object;
|
|
130 |
}
|
|
131 |
|
|
132 |
void VideoCollectionUiLoader::initObject(QObject *object,
|
|
133 |
const QString &name)
|
|
134 |
{
|
36
|
135 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
136 |
|
|
137 |
if (name == DOCML_NAME_VC_VIDEOLISTWIDGET ||
|
|
138 |
name == DOCML_NAME_VC_COLLECTIONWIDGET ||
|
|
139 |
name == DOCML_NAME_VC_COLLECTIONCONTENTWIDGET)
|
|
140 |
{
|
58
|
141 |
VideoProxyModelGeneric *model(0);
|
|
142 |
|
36
|
143 |
if(name == DOCML_NAME_VC_COLLECTIONWIDGET) {
|
58
|
144 |
model = wrapper.getCollectionsModel();
|
36
|
145 |
} else if (name == DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) {
|
58
|
146 |
model = wrapper.getCollectionContentModel();
|
|
147 |
} else
|
|
148 |
{
|
|
149 |
model = wrapper.getAllVideosModel();
|
36
|
150 |
}
|
|
151 |
VideoListWidget *videoList = qobject_cast<VideoListWidget*>(object);
|
41
|
152 |
|
|
153 |
VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid;
|
|
154 |
if(name == DOCML_NAME_VC_VIDEOLISTWIDGET )
|
|
155 |
{
|
|
156 |
level = VideoCollectionCommon::ELevelVideos;
|
|
157 |
}
|
|
158 |
else if(name == DOCML_NAME_VC_COLLECTIONWIDGET)
|
|
159 |
{
|
|
160 |
level = VideoCollectionCommon::ELevelCategory;
|
|
161 |
}
|
|
162 |
videoList->initialize(*model, 0, level);
|
36
|
163 |
}
|
|
164 |
else if (name == DOCML_NAME_DIALOG)
|
|
165 |
{
|
|
166 |
|
|
167 |
}
|
|
168 |
else if (name == DOCML_NAME_OPTIONS_MENU)
|
|
169 |
{
|
|
170 |
|
|
171 |
}
|
|
172 |
else if (name == DOCML_NAME_SORT_MENU)
|
|
173 |
{
|
|
174 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortBy] = qobject_cast<HbAction*>(object);
|
|
175 |
}
|
|
176 |
else if(name == DOCML_NAME_ADD_TO_COLLECTION)
|
|
177 |
{
|
|
178 |
VideoCollectionUiLoaderData::mMenuActions[EActionAddToCollection] = qobject_cast<HbAction*>(object);
|
|
179 |
}
|
|
180 |
else if(name == DOCML_NAME_CREATE_COLLECTION)
|
|
181 |
{
|
|
182 |
VideoCollectionUiLoaderData::mMenuActions[EActionNewCollection] = qobject_cast<HbAction*>(object);
|
|
183 |
}
|
|
184 |
else if(name == DOCML_NAME_DELETE_MULTIPLE)
|
|
185 |
{
|
|
186 |
VideoCollectionUiLoaderData::mMenuActions[EActionDelete] = qobject_cast<HbAction*>(object);
|
|
187 |
}
|
|
188 |
else if(name == DOCML_NAME_SORT_BY_DATE)
|
|
189 |
{
|
|
190 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortByDate] = qobject_cast<HbAction*>(object);
|
63
|
191 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortByDate]->setCheckable(true);
|
36
|
192 |
}
|
|
193 |
else if(name == DOCML_NAME_SORT_BY_NAME)
|
|
194 |
{
|
|
195 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortByName] = qobject_cast<HbAction*>(object);
|
63
|
196 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortByName]->setCheckable(true);
|
36
|
197 |
}
|
|
198 |
else if(name == DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS)
|
|
199 |
{
|
|
200 |
VideoCollectionUiLoaderData::mMenuActions[EACtionSortByItemCount] = qobject_cast<HbAction*>(object);
|
63
|
201 |
VideoCollectionUiLoaderData::mMenuActions[EACtionSortByItemCount]->setCheckable(true);
|
36
|
202 |
}
|
|
203 |
else if(name == DOCML_NAME_SORT_BY_SIZE)
|
|
204 |
{
|
|
205 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortBySize] = qobject_cast<HbAction*>(object);
|
63
|
206 |
VideoCollectionUiLoaderData::mMenuActions[EActionSortBySize]->setCheckable(true);
|
36
|
207 |
}
|
34
|
208 |
}
|
|
209 |
|
|
210 |
void VideoCollectionUiLoader::timerEvent(QTimerEvent *event)
|
|
211 |
{
|
|
212 |
Q_UNUSED(event);
|
|
213 |
// not stubbed
|
|
214 |
}
|
|
215 |
|
|
216 |
QObject* VideoCollectionUiLoader::createObject(const QString& type,
|
|
217 |
const QString &name)
|
|
218 |
{
|
38
|
219 |
QObject* object = doFindObject(name, true);
|
34
|
220 |
if (!object)
|
|
221 |
{
|
35
|
222 |
if (name == DOCML_NAME_VIEW)
|
34
|
223 |
{
|
|
224 |
object = new VideoListView(this);
|
|
225 |
}
|
35
|
226 |
else if (name == DOCML_NAME_VC_COLLECTIONWIDGET ||
|
|
227 |
name == DOCML_NAME_VC_COLLECTIONCONTENTWIDGET ||
|
|
228 |
name == DOCML_NAME_VC_VIDEOLISTWIDGET)
|
34
|
229 |
{
|
|
230 |
object = new VideoListWidget(this);
|
36
|
231 |
initObject(qobject_cast<QGraphicsWidget*>(object), name);
|
34
|
232 |
}
|
35
|
233 |
else if (name == DOCML_NAME_DIALOG)
|
34
|
234 |
{
|
|
235 |
if(!VideoCollectionUiLoaderData::mFailDialogLoad)
|
|
236 |
{
|
|
237 |
object = new VideoListSelectionDialog(this);
|
|
238 |
}
|
|
239 |
else
|
|
240 |
{
|
|
241 |
return 0;
|
|
242 |
}
|
|
243 |
}
|
|
244 |
if (object)
|
|
245 |
{
|
|
246 |
object->setObjectName(name);
|
|
247 |
return object;
|
|
248 |
}
|
|
249 |
object = HbDocumentLoader::createObject(type, name);
|
36
|
250 |
initObject(object, name);
|
34
|
251 |
}
|
|
252 |
|
|
253 |
return object;
|
|
254 |
}
|
|
255 |
|
|
256 |
void VideoCollectionUiLoader::runNext()
|
|
257 |
{
|
|
258 |
// not stubbed
|
|
259 |
}
|
|
260 |
|
36
|
261 |
bool VideoCollectionUiLoader::isValid(const VideoCollectionUiLoaderParam ¶m)
|
34
|
262 |
{
|
36
|
263 |
Q_UNUSED(param);
|
34
|
264 |
// not stubbed
|
|
265 |
return true;
|
|
266 |
}
|
36
|
267 |
|
|
268 |
// ---------------------------------------------------------------------------
|
|
269 |
// storeOrphans
|
|
270 |
// ---------------------------------------------------------------------------
|
|
271 |
//
|
|
272 |
void VideoCollectionUiLoader::storeOrphans(const QObjectList &list)
|
|
273 |
{
|
|
274 |
foreach (QObject *object, list)
|
|
275 |
{
|
|
276 |
if (!mOrphans.contains(object))
|
|
277 |
{
|
|
278 |
// add to list
|
|
279 |
mOrphans.append(object);
|
|
280 |
|
|
281 |
// connect to "destroyed" signal
|
|
282 |
connect(
|
|
283 |
object, SIGNAL(destroyed(QObject*)),
|
|
284 |
this, SLOT(removeOrphanFromList(QObject*)));
|
|
285 |
}
|
|
286 |
}
|
|
287 |
}
|
|
288 |
|
|
289 |
// end of file
|