30
|
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 |
|
|
18 |
#ifndef _VIDEOCOLLECTIONUILOADER_H_
|
|
19 |
#define _VIDEOCOLLECTIONUILOADER_H_
|
|
20 |
|
|
21 |
// System includes
|
|
22 |
#include <hbdocumentloader.h>
|
34
|
23 |
#include <qhash.h>
|
|
24 |
#include <qmap.h>
|
36
|
25 |
#include <qset.h>
|
30
|
26 |
|
36
|
27 |
#include "videocollectionuiloaderdef.h"
|
35
|
28 |
|
|
29 |
// Forward declarations
|
34
|
30 |
class QActionGroup;
|
|
31 |
class HbAction;
|
30
|
32 |
|
|
33 |
// Class declaration
|
34
|
34 |
class VideoCollectionUiLoader:
|
|
35 |
public QObject,
|
|
36 |
public HbDocumentLoader
|
30
|
37 |
{
|
34
|
38 |
Q_OBJECT
|
|
39 |
|
36
|
40 |
public:
|
34
|
41 |
/** actions used in menus and toolbars */
|
|
42 |
enum ActionIds
|
|
43 |
{
|
|
44 |
EActionSortBy = 1,
|
|
45 |
EActionSortByDate,
|
|
46 |
EActionSortByName,
|
|
47 |
EACtionSortByItemCount,
|
|
48 |
EActionSortBySize,
|
|
49 |
EActionNewCollection,
|
|
50 |
EActionAddToCollection,
|
|
51 |
EActionDelete,
|
|
52 |
ETBActionAllVideos,
|
|
53 |
ETBActionCollections,
|
|
54 |
ETBActionServices,
|
|
55 |
ETBActionAddVideos,
|
35
|
56 |
ETBActionRemoveVideos
|
34
|
57 |
};
|
|
58 |
|
30
|
59 |
public:
|
34
|
60 |
/**
|
|
61 |
* C++ constructor.
|
|
62 |
*/
|
30
|
63 |
VideoCollectionUiLoader();
|
34
|
64 |
|
|
65 |
/**
|
|
66 |
* C++ destructor.
|
|
67 |
*/
|
|
68 |
virtual ~VideoCollectionUiLoader();
|
|
69 |
|
|
70 |
/**
|
36
|
71 |
* Adds data to ui loader loading queue.
|
34
|
72 |
*/
|
36
|
73 |
void addData(QList<VideoCollectionUiLoaderParam> params,
|
34
|
74 |
QObject *receiver,
|
36
|
75 |
const char *slot);
|
|
76 |
|
30
|
77 |
/**
|
|
78 |
* Returns the requested widget casted to correct type
|
|
79 |
*
|
|
80 |
* @param name Name of the widget
|
38
|
81 |
* @param loadIfNotFound Should the widget be loaded if not found in cache.
|
30
|
82 |
* @return Pointer to the widget
|
|
83 |
*/
|
|
84 |
template<class T>
|
38
|
85 |
T* findWidget(const QString &name, bool loadIfNotFound = true)
|
30
|
86 |
{
|
38
|
87 |
return qobject_cast<T*>(doFindWidget(name, loadIfNotFound));
|
30
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Returns the requested object casted to correct type
|
|
92 |
*
|
|
93 |
* @param name Name of the object
|
38
|
94 |
* @param loadIfNotFound Should the widget be loaded if not found in cache.
|
30
|
95 |
* @return Pointer to the object
|
|
96 |
*/
|
|
97 |
template<class T>
|
38
|
98 |
T* findObject(const QString &name, bool loadIfNotFound = true)
|
30
|
99 |
{
|
38
|
100 |
return qobject_cast<T*>(doFindObject(name, loadIfNotFound));
|
30
|
101 |
}
|
34
|
102 |
|
|
103 |
/**
|
|
104 |
* Set video services in use.
|
|
105 |
*/
|
|
106 |
void setIsService(bool isService);
|
35
|
107 |
|
|
108 |
/**
|
|
109 |
* load
|
|
110 |
*/
|
36
|
111 |
void load(const QString &fileName, bool *ok = 0);
|
35
|
112 |
|
|
113 |
/**
|
|
114 |
* load
|
|
115 |
*/
|
36
|
116 |
void load(const QString &fileName, const QString §ion , bool *ok = 0);
|
|
117 |
|
|
118 |
public slots:
|
34
|
119 |
/**
|
36
|
120 |
* Starts loading ui components belonging to the defined phase.
|
34
|
121 |
*/
|
36
|
122 |
void loadPhase(int loadPhase);
|
|
123 |
|
|
124 |
private slots:
|
|
125 |
/**
|
|
126 |
* Remove object from list since it has been already deleted.
|
|
127 |
*/
|
|
128 |
void removeOrphanFromList(QObject *object);
|
|
129 |
|
|
130 |
signals:
|
34
|
131 |
/**
|
|
132 |
* Signals that object has been loaded asynchonously.
|
|
133 |
*
|
|
134 |
* @param object, Object which was loaded.
|
|
135 |
* @param name, Name of the object in document.
|
|
136 |
* @return None.
|
|
137 |
*/
|
|
138 |
void objectReady(QObject *object, const QString &name);
|
36
|
139 |
|
|
140 |
protected:
|
34
|
141 |
|
|
142 |
/**
|
|
143 |
* Loads widget from document.
|
|
144 |
*
|
|
145 |
* @param name, Widget name.
|
38
|
146 |
* @param loadIfNotFound Should the widget be loaded if not found in cache.
|
34
|
147 |
* @return QGraphicsWidget*.
|
|
148 |
*/
|
38
|
149 |
QGraphicsWidget* doFindWidget(const QString &name, bool loadIfNotFound);
|
34
|
150 |
|
|
151 |
/**
|
|
152 |
* Loads object from document.
|
|
153 |
*
|
36
|
154 |
* @param name, Object name.
|
|
155 |
* @return QObject*.
|
34
|
156 |
*/
|
38
|
157 |
QObject* doFindObject(const QString &name, bool loadIfNotFound);
|
34
|
158 |
|
|
159 |
/**
|
|
160 |
* Adds a ui section to async loading queue.
|
|
161 |
*/
|
36
|
162 |
void addToQueue(VideoCollectionUiLoaderParam ¶m,
|
|
163 |
QObject *receiver,
|
|
164 |
const char *slot);
|
34
|
165 |
|
|
166 |
/**
|
36
|
167 |
* Finds an object or widget from docml based on the parameter.
|
34
|
168 |
*/
|
36
|
169 |
QObject* getObject(const VideoCollectionUiLoaderParam ¶m);
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Loads and prepares docml and sections if found from param.
|
|
173 |
*/
|
|
174 |
bool prepareDocmlAndSection(const char *docml, const char *section);
|
34
|
175 |
|
|
176 |
/**
|
|
177 |
* Init a specific object.
|
|
178 |
*/
|
36
|
179 |
void initObject(QObject *object, const QString& name);
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Execute ui loader request.
|
|
183 |
*/
|
|
184 |
QObject* executeRequest(const VideoCollectionUiLoaderParam ¶m);
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Gets index of the item in queue, if one found.
|
|
188 |
*/
|
|
189 |
int indexInQueue(const QString &name);
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Removes request from queue.
|
|
193 |
*/
|
|
194 |
void removeFromQueue(const QString &name);
|
34
|
195 |
|
|
196 |
private:
|
|
197 |
/** from QObject */
|
|
198 |
void timerEvent(QTimerEvent *event);
|
|
199 |
|
|
200 |
/** from HbDocumentLoader */
|
|
201 |
QObject *createObject(const QString& type, const QString &name);
|
|
202 |
|
|
203 |
private:
|
|
204 |
/**
|
|
205 |
* Run next async find request from queue.
|
|
206 |
*/
|
|
207 |
void runNext();
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Check that set params are valid.
|
|
211 |
*/
|
36
|
212 |
bool isValid(const VideoCollectionUiLoaderParam ¶m);
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Store object without a parent.
|
|
216 |
*/
|
|
217 |
void storeOrphans(const QObjectList &list);
|
34
|
218 |
|
|
219 |
private:
|
|
220 |
/** async queue */
|
36
|
221 |
QList<VideoCollectionUiLoaderParam> mQueue;
|
34
|
222 |
|
|
223 |
/** timer id */
|
|
224 |
int mTimerId;
|
|
225 |
|
36
|
226 |
/** list of initialized objects */
|
34
|
227 |
QHash<QString, QObject*> mObjects;
|
|
228 |
|
|
229 |
/** menu actions */
|
|
230 |
QMap<ActionIds, HbAction*> mMenuActions;
|
|
231 |
|
|
232 |
/** toolbar actions */
|
|
233 |
QMap<ActionIds, HbAction*> mToolbarActions;
|
|
234 |
|
36
|
235 |
/** loaded docmls */
|
|
236 |
QSet<QString> mDocmls;
|
|
237 |
|
|
238 |
/** loaded sections */
|
|
239 |
QSet<QString> mSections;
|
35
|
240 |
|
34
|
241 |
/** action group for "sort by" actions */
|
|
242 |
QActionGroup* mSortGroup;
|
|
243 |
|
|
244 |
/** is service */
|
|
245 |
bool mIsService;
|
36
|
246 |
|
|
247 |
/** load phases currently active */
|
|
248 |
QSet<int> mPhases;
|
|
249 |
|
|
250 |
/**
|
|
251 |
* objects without a parent - these needs to be deleted manually unless
|
|
252 |
* a parent is set.
|
|
253 |
*/
|
|
254 |
QObjectList mOrphans;
|
30
|
255 |
};
|
|
256 |
|
|
257 |
#endif // _VIDEOCOLLECTIONUILOADER_H_
|