--- a/videocollection/videocollectionview/inc/videocollectionuiloader.h Thu Apr 01 23:13:36 2010 +0300
+++ b/videocollection/videocollectionview/inc/videocollectionuiloader.h Thu Apr 01 23:22:15 2010 +0300
@@ -20,6 +20,8 @@
// System includes
#include <hbdocumentloader.h>
+#include <qhash.h>
+#include <qmap.h>
// Constants
static const char* DOCML_VIDEOCOLLECTIONVIEW_FILE = ":/layout/collectionview.docml";
@@ -27,6 +29,8 @@
// Videocollection View
static const char* DOCML_NAME_VC_HEADINGBANNER = "vc:mBanner";
+static const char* DOCML_NAME_VC_COLLECTIONWIDGET = "vc:mCollectionWidget";
+static const char* DOCML_NAME_VC_COLLECTIONCONTENTWIDGET = "vc:mCollectionContentWidget";
static const char* DOCML_NAME_VC_VIDEOLISTWIDGET = "vc:mListWidget";
static const char* DOCML_NAME_VC_VIDEOHINTWIDGET = "vc:mHintWidget";
@@ -51,25 +55,116 @@
// Videocollection hint widget
static const char* DOCML_NAME_HINT_BUTTON = "vc:mHintButton";
static const char* DOCML_NAME_HINT_LABEL = "vc:mHintTextLabel";
+static const char* DOCML_NAME_NO_VIDEOS_LABEL = "vc:mNoVideosLabel";
// video multiselection dialog
static const char* DOCML_VIDEOSELECTIONDIALOG_FILE = ":/layout/videolistselectiondialog.docml";
static const char* DOCML_NAME_DIALOG = "mMultiSelectionDialog";
static const char* DOCML_NAME_DLG_HEADINGLBL = "mHeadingLabel";
+static const char* DOCML_NAME_CHECK_CONTAINER = "mCheckBoxContainer";
static const char* DOCML_NAME_MARKALL = "mCheckMarkAll";
static const char* DOCML_NAME_LBL_SELECTION = "mSelectionCount";
static const char* DOCML_NAME_LIST_CONTAINER = "mListContainer";
+// async loading timeout
+static const int ASYNC_FIND_TIMEOUT = 50; // ms
+
+class QActionGroup;
+class HbAction;
// Class declaration
-class VideoCollectionUiLoader : public HbDocumentLoader
+class VideoCollectionUiLoader:
+ public QObject,
+ public HbDocumentLoader
{
+ Q_OBJECT
+
+private:
+ /** actions used in menus and toolbars */
+ enum ActionIds
+ {
+ EActionSortBy = 1,
+ EActionSortByDate,
+ EActionSortByName,
+ EACtionSortByItemCount,
+ EActionSortByLength,
+ EActionSortBySize,
+ EActionNewCollection,
+ EActionAddToCollection,
+ EActionDelete,
+ ETBActionAllVideos,
+ ETBActionCollections,
+ ETBActionServices,
+ ETBActionAddVideos,
+ ETBActionRemoveVideos,
+ ETBActionSortVideos
+ };
+
+ /** VideoCollectionUiLoader parameter class */
+ class Params
+ {
+ public:
+ Params(const QString& name,
+ bool isWidget = false,
+ QObject *receiver = 0,
+ const char *docml = 0,
+ const char *member = 0):
+ mName(name),
+ mIsWidget(isWidget),
+ mReceiver(receiver),
+ mDocml(docml),
+ mMember(member)
+ {
+ // nothing to do
+ }
+
+ bool isDuplicate(const Params& params) const
+ {
+ bool isSame(false);
+
+ if (mName == params.mName &&
+ mReceiver == params.mReceiver &&
+ mDocml == params.mDocml &&
+ mMember == params.mMember)
+ {
+ isSame = true;
+ }
+
+ return isSame;
+ }
+
+ public:
+ QString mName;
+ bool mIsWidget;
+ QObject *mReceiver;
+ const char *mDocml;
+ const char *mMember;
+ };
public:
-
+ /**
+ * C++ constructor.
+ */
VideoCollectionUiLoader();
-
- ~VideoCollectionUiLoader();
+
+ /**
+ * C++ destructor.
+ */
+ virtual ~VideoCollectionUiLoader();
+
+ /**
+ * Starts to load a specified UI section.
+ *
+ * @param uiSection, UI section to load.
+ * @param receiver, Receiver of a ready signal.
+ * @param widgetSlot, Slot which is called when a widget is ready.
+ * @param objectSlot, Slot which is called when an object is ready.
+ * @return None.
+ */
+ void startLoading(QSet<QString> uiSections,
+ QObject *receiver,
+ const char *widgetSlot,
+ const char *objectSlot);
/**
* Returns the requested widget casted to correct type
@@ -78,9 +173,9 @@
* @return Pointer to the widget
*/
template<class T>
- T* findWidget( QString name )
+ T* findWidget(const QString &name)
{
- return qobject_cast<T*>( HbDocumentLoader::findWidget( name ) );
+ return qobject_cast<T*>(doFindWidget(name));
}
/**
@@ -90,14 +185,112 @@
* @return Pointer to the object
*/
template<class T>
- T* findObject( QString name )
+ T* findObject(const QString &name)
{
- return qobject_cast<T*>( HbDocumentLoader::findObject( name ) );
+ return qobject_cast<T*>(doFindObject(name));
}
+
+ /**
+ * Set video services in use.
+ */
+ void setIsService(bool isService);
+signals:
+ /**
+ * Signals that widget has been loaded asynchonously.
+ *
+ * @param widget, Widget which was loaded.
+ * @param name, Name of the widget in document.
+ * @return None.
+ */
+ void widgetReady(QGraphicsWidget *widget, const QString &name);
+
+ /**
+ * Signals that object has been loaded asynchonously.
+ *
+ * @param object, Object which was loaded.
+ * @param name, Name of the object in document.
+ * @return None.
+ */
+ void objectReady(QObject *object, const QString &name);
+
+public:
+ /**
+ * Loads widget from document.
+ *
+ * @param name, Widget name.
+ * @return QGraphicsWidget*.
+ */
+ QGraphicsWidget* doFindWidget(const QString &name);
+
+ /**
+ * Loads object from document.
+ *
+ * @param name, Widget name.
+ * @return QGraphicsWidget*.
+ */
+ QObject* doFindObject(const QString &name);
+
private:
+ /**
+ * Adds a ui section to async loading queue.
+ */
+ void addToQueue(Params ¶ms);
+
+ /**
+ * Init a specific widget.
+ */
+ void initWidget(QGraphicsWidget *widget,
+ const QString &name);
+
+ /**
+ * Init a specific object.
+ */
+ void initObject(QObject *object,
+ const QString& name);
+
+private:
+ /** from QObject */
+ void timerEvent(QTimerEvent *event);
+
+ /** from HbDocumentLoader */
+ QObject *createObject(const QString& type, const QString &name);
+
+private:
+ /**
+ * Run next async find request from queue.
+ */
+ void runNext();
+
+ /**
+ * Check that set params are valid.
+ */
+ bool isValid(const Params ¶ms);
+
+private:
+ /** async queue */
+ QList<Params> mQueue;
+
+ /** timer id */
+ int mTimerId;
+
+ /** list of loaded widgets */
+ QHash<QString, QGraphicsWidget*> mWidgets;
- QObject *createObject( const QString& type, const QString &name );
+ /** list of loaded objects */
+ QHash<QString, QObject*> mObjects;
+
+ /** menu actions */
+ QMap<ActionIds, HbAction*> mMenuActions;
+
+ /** toolbar actions */
+ QMap<ActionIds, HbAction*> mToolbarActions;
+
+ /** action group for "sort by" actions */
+ QActionGroup* mSortGroup;
+
+ /** is service */
+ bool mIsService;
};
#endif // _VIDEOCOLLECTIONUILOADER_H_