videocollection/videocollectionview/src/videocollectionuiloader.cpp
author hgs
Fri, 15 Oct 2010 16:29:10 +0300
changeset 67 72c709219fcd
parent 66 adb51f74b890
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
67
hgs
parents: 66
diff changeset
    18
// Version : %version: 24.1.3 %
36
hgs
parents: 35
diff changeset
    19
hgs
parents: 35
diff changeset
    20
// INCLUDE FILES
34
hgs
parents: 30
diff changeset
    21
#include <qgraphicswidget.h>
hgs
parents: 30
diff changeset
    22
#include <qaction.h>
hgs
parents: 30
diff changeset
    23
#include <qactiongroup.h>
hgs
parents: 30
diff changeset
    24
#include <hbmenu.h>
hgs
parents: 30
diff changeset
    25
#include <hbaction.h>
hgs
parents: 30
diff changeset
    26
#include <hbgroupbox.h>
hgs
parents: 30
diff changeset
    27
#include <hbpushbutton.h>
hgs
parents: 30
diff changeset
    28
30
hgs
parents:
diff changeset
    29
#include "videocollectionuiloader.h"
hgs
parents:
diff changeset
    30
#include "videolistview.h"
hgs
parents:
diff changeset
    31
#include "videolistselectiondialog.h"
hgs
parents:
diff changeset
    32
#include "videolistwidget.h"
34
hgs
parents: 30
diff changeset
    33
#include "videocollectionwrapper.h"
58
hgs
parents: 41
diff changeset
    34
#include "videoproxymodelgeneric.h"
34
hgs
parents: 30
diff changeset
    35
#include "videocollectionviewutils.h"
36
hgs
parents: 35
diff changeset
    36
#include "videocollectiontrace.h"
34
hgs
parents: 30
diff changeset
    37
hgs
parents: 30
diff changeset
    38
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
    39
// VideoCollectionUiLoader
hgs
parents: 30
diff changeset
    40
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
    41
//
36
hgs
parents: 35
diff changeset
    42
VideoCollectionUiLoader::VideoCollectionUiLoader()
hgs
parents: 35
diff changeset
    43
    : HbDocumentLoader()
hgs
parents: 35
diff changeset
    44
    , mTimerId( 0 )
hgs
parents: 35
diff changeset
    45
    , mSortGroup( 0 )
hgs
parents: 35
diff changeset
    46
    , mIsService( false )
34
hgs
parents: 30
diff changeset
    47
{
36
hgs
parents: 35
diff changeset
    48
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
    49
}
30
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    52
// VideoCollectionUiLoader
hgs
parents:
diff changeset
    53
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    54
//
34
hgs
parents: 30
diff changeset
    55
VideoCollectionUiLoader::~VideoCollectionUiLoader()
hgs
parents: 30
diff changeset
    56
{
36
hgs
parents: 35
diff changeset
    57
	FUNC_LOG;
hgs
parents: 35
diff changeset
    58
hgs
parents: 35
diff changeset
    59
    // delete objects without a parent
hgs
parents: 35
diff changeset
    60
	while (!mOrphans.isEmpty())
hgs
parents: 35
diff changeset
    61
	{
hgs
parents: 35
diff changeset
    62
		delete mOrphans.takeFirst();
hgs
parents: 35
diff changeset
    63
	}
hgs
parents: 35
diff changeset
    64
hgs
parents: 35
diff changeset
    65
    // kill timer if running
35
hgs
parents: 34
diff changeset
    66
    if (mTimerId)
hgs
parents: 34
diff changeset
    67
    {
hgs
parents: 34
diff changeset
    68
        killTimer(mTimerId);
hgs
parents: 34
diff changeset
    69
        mTimerId = 0;
hgs
parents: 34
diff changeset
    70
    }
hgs
parents: 34
diff changeset
    71
34
hgs
parents: 30
diff changeset
    72
    // clear queue and hash tables
hgs
parents: 30
diff changeset
    73
    mQueue.clear();
35
hgs
parents: 34
diff changeset
    74
    mDocmls.clear();
36
hgs
parents: 35
diff changeset
    75
    mSections.clear();
34
hgs
parents: 30
diff changeset
    76
    mObjects.clear();
36
hgs
parents: 35
diff changeset
    77
    mPhases.clear();
34
hgs
parents: 30
diff changeset
    78
}
hgs
parents: 30
diff changeset
    79
hgs
parents: 30
diff changeset
    80
// ---------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
    81
// load
hgs
parents: 34
diff changeset
    82
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
    83
//
36
hgs
parents: 35
diff changeset
    84
void VideoCollectionUiLoader::load(const QString &fileName, bool *ok)
35
hgs
parents: 34
diff changeset
    85
{
36
hgs
parents: 35
diff changeset
    86
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
    87
	if (!mDocmls.contains(fileName))
hgs
parents: 34
diff changeset
    88
	{
36
hgs
parents: 35
diff changeset
    89
		QObjectList list = HbDocumentLoader::load(fileName, ok);
hgs
parents: 35
diff changeset
    90
		if (ok && *ok)
hgs
parents: 35
diff changeset
    91
		{
hgs
parents: 35
diff changeset
    92
	        mDocmls.insert(fileName);
hgs
parents: 35
diff changeset
    93
		}
hgs
parents: 35
diff changeset
    94
		
hgs
parents: 35
diff changeset
    95
		// add objects without a parent to orphan list
hgs
parents: 35
diff changeset
    96
		storeOrphans(list);
35
hgs
parents: 34
diff changeset
    97
	}
36
hgs
parents: 35
diff changeset
    98
	else
hgs
parents: 35
diff changeset
    99
	{
hgs
parents: 35
diff changeset
   100
	    *ok = true;
hgs
parents: 35
diff changeset
   101
	}
35
hgs
parents: 34
diff changeset
   102
}
hgs
parents: 34
diff changeset
   103
hgs
parents: 34
diff changeset
   104
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   105
// load
hgs
parents: 34
diff changeset
   106
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   107
//
36
hgs
parents: 35
diff changeset
   108
void VideoCollectionUiLoader::load(const QString &fileName,
hgs
parents: 35
diff changeset
   109
    const QString &section,
hgs
parents: 35
diff changeset
   110
    bool *ok)
35
hgs
parents: 34
diff changeset
   111
{
36
hgs
parents: 35
diff changeset
   112
	FUNC_LOG;
hgs
parents: 35
diff changeset
   113
    if (!mSections.contains(section))
hgs
parents: 35
diff changeset
   114
    {
hgs
parents: 35
diff changeset
   115
        QObjectList list = HbDocumentLoader::load(fileName, section, ok);
hgs
parents: 35
diff changeset
   116
        if (ok && *ok)
hgs
parents: 35
diff changeset
   117
        {
hgs
parents: 35
diff changeset
   118
            mSections.insert(section);
hgs
parents: 35
diff changeset
   119
        }
hgs
parents: 35
diff changeset
   120
hgs
parents: 35
diff changeset
   121
        // add objects without a parent to orphan list
hgs
parents: 35
diff changeset
   122
        storeOrphans(list);
hgs
parents: 35
diff changeset
   123
    }
hgs
parents: 35
diff changeset
   124
    else
hgs
parents: 35
diff changeset
   125
    {
hgs
parents: 35
diff changeset
   126
        *ok = true;
hgs
parents: 35
diff changeset
   127
    }
35
hgs
parents: 34
diff changeset
   128
}
hgs
parents: 34
diff changeset
   129
hgs
parents: 34
diff changeset
   130
// ---------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   131
// addData
hgs
parents: 35
diff changeset
   132
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   133
//
hgs
parents: 35
diff changeset
   134
void VideoCollectionUiLoader::addData(
hgs
parents: 35
diff changeset
   135
    QList<VideoCollectionUiLoaderParam> params,
hgs
parents: 35
diff changeset
   136
    QObject *receiver,
hgs
parents: 35
diff changeset
   137
    const char *slot)
hgs
parents: 35
diff changeset
   138
{
hgs
parents: 35
diff changeset
   139
	FUNC_LOG;
hgs
parents: 35
diff changeset
   140
    // go through all parameters and add then in to the queue
hgs
parents: 35
diff changeset
   141
    foreach (VideoCollectionUiLoaderParam param, params)
hgs
parents: 35
diff changeset
   142
    {
hgs
parents: 35
diff changeset
   143
        addToQueue(param, receiver, slot);
hgs
parents: 35
diff changeset
   144
    }
hgs
parents: 35
diff changeset
   145
}
hgs
parents: 35
diff changeset
   146
hgs
parents: 35
diff changeset
   147
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   148
// loadPhase
34
hgs
parents: 30
diff changeset
   149
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   150
//
36
hgs
parents: 35
diff changeset
   151
void VideoCollectionUiLoader::loadPhase(int loadPhase)
30
hgs
parents:
diff changeset
   152
{
36
hgs
parents: 35
diff changeset
   153
	FUNC_LOG;
hgs
parents: 35
diff changeset
   154
    if (!mPhases.contains(loadPhase))
34
hgs
parents: 30
diff changeset
   155
    {
36
hgs
parents: 35
diff changeset
   156
        mPhases.insert(loadPhase);
hgs
parents: 35
diff changeset
   157
        if (!mTimerId)
hgs
parents: 35
diff changeset
   158
        {
hgs
parents: 35
diff changeset
   159
            runNext();
hgs
parents: 35
diff changeset
   160
        }
34
hgs
parents: 30
diff changeset
   161
    }
36
hgs
parents: 35
diff changeset
   162
}
hgs
parents: 35
diff changeset
   163
hgs
parents: 35
diff changeset
   164
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   165
// removeOrphanFromList
hgs
parents: 35
diff changeset
   166
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   167
//
hgs
parents: 35
diff changeset
   168
void VideoCollectionUiLoader::removeOrphanFromList(QObject *object)
hgs
parents: 35
diff changeset
   169
{
hgs
parents: 35
diff changeset
   170
	FUNC_LOG;
hgs
parents: 35
diff changeset
   171
    // remove from orphan list
hgs
parents: 35
diff changeset
   172
    if (mOrphans.contains(object))
34
hgs
parents: 30
diff changeset
   173
    {
36
hgs
parents: 35
diff changeset
   174
        mOrphans.removeOne(object);
34
hgs
parents: 30
diff changeset
   175
    }
36
hgs
parents: 35
diff changeset
   176
    
hgs
parents: 35
diff changeset
   177
    // remove from initialized objects list
hgs
parents: 35
diff changeset
   178
    const QString &name = mObjects.key(object);
hgs
parents: 35
diff changeset
   179
    if (!name.isEmpty())
34
hgs
parents: 30
diff changeset
   180
    {
36
hgs
parents: 35
diff changeset
   181
        // found from list, remove
hgs
parents: 35
diff changeset
   182
        mObjects.remove(name);
34
hgs
parents: 30
diff changeset
   183
    }
hgs
parents: 30
diff changeset
   184
}
hgs
parents: 30
diff changeset
   185
hgs
parents: 30
diff changeset
   186
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   187
// setIsService
hgs
parents: 30
diff changeset
   188
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   189
//
hgs
parents: 30
diff changeset
   190
void VideoCollectionUiLoader::setIsService(bool isService)
hgs
parents: 30
diff changeset
   191
{
36
hgs
parents: 35
diff changeset
   192
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   193
    mIsService = isService;
hgs
parents: 30
diff changeset
   194
}
hgs
parents: 30
diff changeset
   195
hgs
parents: 30
diff changeset
   196
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   197
// doFindWidget
hgs
parents: 30
diff changeset
   198
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   199
//
38
hgs
parents: 37
diff changeset
   200
QGraphicsWidget* VideoCollectionUiLoader::doFindWidget(const QString &name, bool loadIfNotFound)
34
hgs
parents: 30
diff changeset
   201
{
36
hgs
parents: 35
diff changeset
   202
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   203
    QGraphicsWidget *widget = 0;
hgs
parents: 30
diff changeset
   204
    
hgs
parents: 30
diff changeset
   205
    // 1. check from hash
36
hgs
parents: 35
diff changeset
   206
    if (mObjects.contains(name))
34
hgs
parents: 30
diff changeset
   207
    {
36
hgs
parents: 35
diff changeset
   208
        widget = qobject_cast<QGraphicsWidget*>(mObjects.value(name));
34
hgs
parents: 30
diff changeset
   209
    }
36
hgs
parents: 35
diff changeset
   210
hgs
parents: 35
diff changeset
   211
    // 2. load from document and initialize
38
hgs
parents: 37
diff changeset
   212
    else if (loadIfNotFound)
34
hgs
parents: 30
diff changeset
   213
    {
36
hgs
parents: 35
diff changeset
   214
        // find object from queue
hgs
parents: 35
diff changeset
   215
        int index = indexInQueue(name);
hgs
parents: 35
diff changeset
   216
        if (index != -1)
35
hgs
parents: 34
diff changeset
   217
        {
36
hgs
parents: 35
diff changeset
   218
            // object found from queue, load and initialize object 
hgs
parents: 35
diff changeset
   219
            const VideoCollectionUiLoaderParam &param = mQueue.at(index);
hgs
parents: 35
diff changeset
   220
            widget = qobject_cast<QGraphicsWidget*>(executeRequest(param));
hgs
parents: 35
diff changeset
   221
            
hgs
parents: 35
diff changeset
   222
            // object in loading queue, remove it
hgs
parents: 35
diff changeset
   223
            removeFromQueue(name);
35
hgs
parents: 34
diff changeset
   224
        }
36
hgs
parents: 35
diff changeset
   225
        else
34
hgs
parents: 30
diff changeset
   226
        {
36
hgs
parents: 35
diff changeset
   227
            // assuming that docml and section has already been loaded
hgs
parents: 35
diff changeset
   228
            widget = HbDocumentLoader::findWidget(name);
34
hgs
parents: 30
diff changeset
   229
        }
hgs
parents: 30
diff changeset
   230
    }
36
hgs
parents: 35
diff changeset
   231
34
hgs
parents: 30
diff changeset
   232
    return widget;
hgs
parents: 30
diff changeset
   233
}
hgs
parents: 30
diff changeset
   234
hgs
parents: 30
diff changeset
   235
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   236
// doFindObject
hgs
parents: 30
diff changeset
   237
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   238
//
38
hgs
parents: 37
diff changeset
   239
QObject* VideoCollectionUiLoader::doFindObject(const QString &name, bool loadIfNotFound)
34
hgs
parents: 30
diff changeset
   240
{
36
hgs
parents: 35
diff changeset
   241
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   242
    QObject *object = 0;
hgs
parents: 30
diff changeset
   243
    
hgs
parents: 30
diff changeset
   244
    // 1. check from hash
hgs
parents: 30
diff changeset
   245
    if (mObjects.contains(name))
hgs
parents: 30
diff changeset
   246
    {
hgs
parents: 30
diff changeset
   247
        object = mObjects.value(name);
hgs
parents: 30
diff changeset
   248
    }
36
hgs
parents: 35
diff changeset
   249
hgs
parents: 35
diff changeset
   250
    // 2. load from document and initialize
38
hgs
parents: 37
diff changeset
   251
    else if (loadIfNotFound)
34
hgs
parents: 30
diff changeset
   252
    {
36
hgs
parents: 35
diff changeset
   253
        // find object from queue
hgs
parents: 35
diff changeset
   254
        int index = indexInQueue(name);
hgs
parents: 35
diff changeset
   255
        if (index != -1)
35
hgs
parents: 34
diff changeset
   256
        {
36
hgs
parents: 35
diff changeset
   257
            // object found from queue, load and initialize object 
hgs
parents: 35
diff changeset
   258
            const VideoCollectionUiLoaderParam &param = mQueue.at(index);
hgs
parents: 35
diff changeset
   259
            object = executeRequest(param);
hgs
parents: 35
diff changeset
   260
            
hgs
parents: 35
diff changeset
   261
            // object in loading queue, remove it
hgs
parents: 35
diff changeset
   262
            removeFromQueue(name);
35
hgs
parents: 34
diff changeset
   263
        }
36
hgs
parents: 35
diff changeset
   264
        else
34
hgs
parents: 30
diff changeset
   265
        {
36
hgs
parents: 35
diff changeset
   266
            // assuming that docml and section has already been loaded
hgs
parents: 35
diff changeset
   267
            object = HbDocumentLoader::findObject(name);
34
hgs
parents: 30
diff changeset
   268
        }
hgs
parents: 30
diff changeset
   269
    }
36
hgs
parents: 35
diff changeset
   270
34
hgs
parents: 30
diff changeset
   271
    return object;
30
hgs
parents:
diff changeset
   272
}
hgs
parents:
diff changeset
   273
hgs
parents:
diff changeset
   274
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   275
// addToQueue
hgs
parents: 30
diff changeset
   276
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   277
//
36
hgs
parents: 35
diff changeset
   278
void VideoCollectionUiLoader::addToQueue(VideoCollectionUiLoaderParam &param,
hgs
parents: 35
diff changeset
   279
    QObject *receiver,
hgs
parents: 35
diff changeset
   280
    const char *slot)
34
hgs
parents: 30
diff changeset
   281
{
36
hgs
parents: 35
diff changeset
   282
	FUNC_LOG;
hgs
parents: 35
diff changeset
   283
hgs
parents: 35
diff changeset
   284
	INFOQSTR_1("VideoCollectionUiLoader::addToQueue() name: %S", param.mName);
hgs
parents: 35
diff changeset
   285
	
hgs
parents: 35
diff changeset
   286
    // set receiver if not already set
hgs
parents: 35
diff changeset
   287
    if (!param.mReceiver)
hgs
parents: 35
diff changeset
   288
    {
hgs
parents: 35
diff changeset
   289
        param.mReceiver = receiver;
hgs
parents: 35
diff changeset
   290
    }
hgs
parents: 35
diff changeset
   291
    
hgs
parents: 35
diff changeset
   292
    // set slot if not already set
hgs
parents: 35
diff changeset
   293
    if (!param.mMember)
hgs
parents: 35
diff changeset
   294
    {
hgs
parents: 35
diff changeset
   295
        param.mMember = slot;        
hgs
parents: 35
diff changeset
   296
    }
hgs
parents: 35
diff changeset
   297
    
hgs
parents: 35
diff changeset
   298
    // check validity and hit it
hgs
parents: 35
diff changeset
   299
    if (isValid(param))
34
hgs
parents: 30
diff changeset
   300
    {
hgs
parents: 30
diff changeset
   301
        // add the params in async queue
36
hgs
parents: 35
diff changeset
   302
        mQueue.append(param);
34
hgs
parents: 30
diff changeset
   303
    }
hgs
parents: 30
diff changeset
   304
}
hgs
parents: 30
diff changeset
   305
hgs
parents: 30
diff changeset
   306
// ---------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   307
// getObject
hgs
parents: 35
diff changeset
   308
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   309
//
hgs
parents: 35
diff changeset
   310
QObject* VideoCollectionUiLoader::getObject(
hgs
parents: 35
diff changeset
   311
    const VideoCollectionUiLoaderParam &param)
hgs
parents: 35
diff changeset
   312
{
hgs
parents: 35
diff changeset
   313
	FUNC_LOG;
hgs
parents: 35
diff changeset
   314
    QObject *object = 0;
hgs
parents: 35
diff changeset
   315
    
hgs
parents: 35
diff changeset
   316
    if (param.mIsWidget)
hgs
parents: 35
diff changeset
   317
    {
hgs
parents: 35
diff changeset
   318
        object = HbDocumentLoader::findWidget(param.mName);
hgs
parents: 35
diff changeset
   319
    }
hgs
parents: 35
diff changeset
   320
    else
hgs
parents: 35
diff changeset
   321
    {
hgs
parents: 35
diff changeset
   322
        object = HbDocumentLoader::findObject(param.mName);
hgs
parents: 35
diff changeset
   323
    }
hgs
parents: 35
diff changeset
   324
    
hgs
parents: 35
diff changeset
   325
    return object;
hgs
parents: 35
diff changeset
   326
}
hgs
parents: 35
diff changeset
   327
hgs
parents: 35
diff changeset
   328
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   329
// prepareDocmlAndSection
34
hgs
parents: 30
diff changeset
   330
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   331
//
36
hgs
parents: 35
diff changeset
   332
bool VideoCollectionUiLoader::prepareDocmlAndSection(const char *docml,
hgs
parents: 35
diff changeset
   333
    const char *section)
hgs
parents: 35
diff changeset
   334
{
hgs
parents: 35
diff changeset
   335
	FUNC_LOG;
hgs
parents: 35
diff changeset
   336
    bool ok = true;
hgs
parents: 35
diff changeset
   337
hgs
parents: 35
diff changeset
   338
    // prepare docml
hgs
parents: 35
diff changeset
   339
    if (docml && !mDocmls.contains(docml))
hgs
parents: 35
diff changeset
   340
    {
hgs
parents: 35
diff changeset
   341
        load(docml, &ok);
hgs
parents: 35
diff changeset
   342
    }
hgs
parents: 35
diff changeset
   343
        
hgs
parents: 35
diff changeset
   344
    // prepare section
hgs
parents: 35
diff changeset
   345
    if (ok && section && !mSections.contains(section))
hgs
parents: 35
diff changeset
   346
    {
hgs
parents: 35
diff changeset
   347
        load(docml, section, &ok);
hgs
parents: 35
diff changeset
   348
    }
hgs
parents: 35
diff changeset
   349
    
hgs
parents: 35
diff changeset
   350
    return ok;
hgs
parents: 35
diff changeset
   351
}
hgs
parents: 35
diff changeset
   352
hgs
parents: 35
diff changeset
   353
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   354
// initObject
hgs
parents: 35
diff changeset
   355
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   356
//
hgs
parents: 35
diff changeset
   357
void VideoCollectionUiLoader::initObject(QObject *object,
34
hgs
parents: 30
diff changeset
   358
    const QString &name)
hgs
parents: 30
diff changeset
   359
{
36
hgs
parents: 35
diff changeset
   360
	FUNC_LOG;
hgs
parents: 35
diff changeset
   361
    if (object)
34
hgs
parents: 30
diff changeset
   362
    {
36
hgs
parents: 35
diff changeset
   363
        INFOQSTR_1("VideoCollectionUiLoader::initObject() name: %S", name);
34
hgs
parents: 30
diff changeset
   364
        VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
hgs
parents: 30
diff changeset
   365
        if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
hgs
parents: 30
diff changeset
   366
        {
36
hgs
parents: 35
diff changeset
   367
            VideoListWidget *videoList = qobject_cast<VideoListWidget*>(object);
34
hgs
parents: 30
diff changeset
   368
            if (videoList)
hgs
parents: 30
diff changeset
   369
            {
58
hgs
parents: 41
diff changeset
   370
                VideoProxyModelGeneric *model = wrapper.getAllVideosModel();
34
hgs
parents: 30
diff changeset
   371
                if(model)
hgs
parents: 30
diff changeset
   372
                {
38
hgs
parents: 37
diff changeset
   373
                	VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelVideos);
hgs
parents: 37
diff changeset
   374
                	
34
hgs
parents: 30
diff changeset
   375
                    // init widget
41
hgs
parents: 39
diff changeset
   376
                    videoList->initialize(*model, mIsService, VideoCollectionCommon::ELevelVideos);
34
hgs
parents: 30
diff changeset
   377
                }
hgs
parents: 30
diff changeset
   378
            }
hgs
parents: 30
diff changeset
   379
        }
hgs
parents: 30
diff changeset
   380
        else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
hgs
parents: 30
diff changeset
   381
        {
58
hgs
parents: 41
diff changeset
   382
            VideoProxyModelGeneric *model = wrapper.getCollectionsModel();
34
hgs
parents: 30
diff changeset
   383
            if (model)
hgs
parents: 30
diff changeset
   384
            {
36
hgs
parents: 35
diff changeset
   385
                VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelCategory);
38
hgs
parents: 37
diff changeset
   386
                
34
hgs
parents: 30
diff changeset
   387
                // initialize video collection widget
hgs
parents: 30
diff changeset
   388
                VideoListWidget *videoList =
36
hgs
parents: 35
diff changeset
   389
                    qobject_cast<VideoListWidget*>(object);
34
hgs
parents: 30
diff changeset
   390
                if (videoList)
hgs
parents: 30
diff changeset
   391
                {
hgs
parents: 30
diff changeset
   392
                    // init widget
41
hgs
parents: 39
diff changeset
   393
                    videoList->initialize(*model, mIsService, VideoCollectionCommon::ELevelCategory);
34
hgs
parents: 30
diff changeset
   394
                }
hgs
parents: 30
diff changeset
   395
            }
hgs
parents: 30
diff changeset
   396
        }
hgs
parents: 30
diff changeset
   397
        else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
hgs
parents: 30
diff changeset
   398
        {
58
hgs
parents: 41
diff changeset
   399
            VideoProxyModelGeneric *model = wrapper.getCollectionContentModel();
34
hgs
parents: 30
diff changeset
   400
            if (model)
hgs
parents: 30
diff changeset
   401
            {
38
hgs
parents: 37
diff changeset
   402
                // collection content contains always a list of videos so we use 
hgs
parents: 37
diff changeset
   403
                // ELevelVideos as target for sorting
hgs
parents: 37
diff changeset
   404
                VideoCollectionViewUtils::sortModel(model, false, VideoCollectionCommon::ELevelVideos);
hgs
parents: 37
diff changeset
   405
                
36
hgs
parents: 35
diff changeset
   406
                VideoListWidget *videoList = qobject_cast<VideoListWidget*>(object);
34
hgs
parents: 30
diff changeset
   407
                if (videoList)
hgs
parents: 30
diff changeset
   408
                {
hgs
parents: 30
diff changeset
   409
                    // init widget
39
hgs
parents: 38
diff changeset
   410
                    // cannot set level at this point yet: it can be either default or user defined collection
41
hgs
parents: 39
diff changeset
   411
                    videoList->initialize(*model, mIsService);
34
hgs
parents: 30
diff changeset
   412
                }
hgs
parents: 30
diff changeset
   413
            }
hgs
parents: 30
diff changeset
   414
        }
hgs
parents: 30
diff changeset
   415
        else if (name.compare(DOCML_NAME_SORT_MENU) == 0)
hgs
parents: 30
diff changeset
   416
        {
36
hgs
parents: 35
diff changeset
   417
            HbMenu *menu = qobject_cast<HbMenu*>(object);
34
hgs
parents: 30
diff changeset
   418
            if (menu)
hgs
parents: 30
diff changeset
   419
            {
hgs
parents: 30
diff changeset
   420
                // create sort by menu action
hgs
parents: 30
diff changeset
   421
                mMenuActions[EActionSortBy] = menu->menuAction();
hgs
parents: 30
diff changeset
   422
hgs
parents: 30
diff changeset
   423
                // ensure that all the actions related to sort menu are loaded
hgs
parents: 30
diff changeset
   424
                // when sort menu is loaded
hgs
parents: 30
diff changeset
   425
                findObject<HbAction>(DOCML_NAME_SORT_BY_DATE);
hgs
parents: 30
diff changeset
   426
                findObject<HbAction>(DOCML_NAME_SORT_BY_NAME);
hgs
parents: 30
diff changeset
   427
                findObject<HbAction>(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
hgs
parents: 30
diff changeset
   428
                findObject<HbAction>(DOCML_NAME_SORT_BY_SIZE);
hgs
parents: 30
diff changeset
   429
hgs
parents: 30
diff changeset
   430
                // add sub menu actions
hgs
parents: 30
diff changeset
   431
                if (!mSortGroup)
hgs
parents: 30
diff changeset
   432
                {
hgs
parents: 30
diff changeset
   433
                    mSortGroup = new QActionGroup(menu);
hgs
parents: 30
diff changeset
   434
                    mSortGroup->addAction(mMenuActions[EActionSortByDate]);
hgs
parents: 30
diff changeset
   435
                    mSortGroup->addAction(mMenuActions[EActionSortByName]);
hgs
parents: 30
diff changeset
   436
                    mSortGroup->addAction(mMenuActions[EACtionSortByItemCount]);
hgs
parents: 30
diff changeset
   437
                    mSortGroup->addAction(mMenuActions[EActionSortBySize]);
hgs
parents: 30
diff changeset
   438
                    
hgs
parents: 30
diff changeset
   439
                    // set all sub menu items checkable
hgs
parents: 30
diff changeset
   440
                    foreach (QAction *action, menu->actions()) 
hgs
parents: 30
diff changeset
   441
                    {
hgs
parents: 30
diff changeset
   442
                        action->setCheckable(true);
hgs
parents: 30
diff changeset
   443
                    }
hgs
parents: 30
diff changeset
   444
                }
hgs
parents: 30
diff changeset
   445
            }
hgs
parents: 30
diff changeset
   446
        }
hgs
parents: 30
diff changeset
   447
        else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
hgs
parents: 30
diff changeset
   448
        {
hgs
parents: 30
diff changeset
   449
            // ensure that all the actions related to options menu are loaded
hgs
parents: 30
diff changeset
   450
            // when options menu is loaded
36
hgs
parents: 35
diff changeset
   451
            // when applicaton has been launched as a service,
hgs
parents: 35
diff changeset
   452
            // do not load components which are not required
hgs
parents: 35
diff changeset
   453
            if(!mIsService)
hgs
parents: 35
diff changeset
   454
            {
hgs
parents: 35
diff changeset
   455
                findObject<HbAction>(DOCML_NAME_ADD_TO_COLLECTION);
hgs
parents: 35
diff changeset
   456
                findObject<HbAction>(DOCML_NAME_CREATE_COLLECTION);
hgs
parents: 35
diff changeset
   457
                findObject<HbAction>(DOCML_NAME_DELETE_MULTIPLE);
hgs
parents: 35
diff changeset
   458
            }
34
hgs
parents: 30
diff changeset
   459
        }
36
hgs
parents: 35
diff changeset
   460
        else if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
34
hgs
parents: 30
diff changeset
   461
        {
hgs
parents: 30
diff changeset
   462
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   463
            if (action)
hgs
parents: 30
diff changeset
   464
            {
hgs
parents: 30
diff changeset
   465
                mMenuActions[EActionAddToCollection] = action;
hgs
parents: 30
diff changeset
   466
            }
hgs
parents: 30
diff changeset
   467
        }
hgs
parents: 30
diff changeset
   468
        else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
hgs
parents: 30
diff changeset
   469
        {
hgs
parents: 30
diff changeset
   470
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   471
            if (action)
hgs
parents: 30
diff changeset
   472
            {
hgs
parents: 30
diff changeset
   473
                mMenuActions[EActionNewCollection] = action;
hgs
parents: 30
diff changeset
   474
            }
hgs
parents: 30
diff changeset
   475
        }
hgs
parents: 30
diff changeset
   476
        else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
hgs
parents: 30
diff changeset
   477
        {
hgs
parents: 30
diff changeset
   478
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   479
            if (action)
hgs
parents: 30
diff changeset
   480
            {
hgs
parents: 30
diff changeset
   481
                mMenuActions[EActionDelete] = action;
hgs
parents: 30
diff changeset
   482
            }
hgs
parents: 30
diff changeset
   483
        }
hgs
parents: 30
diff changeset
   484
        else if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
hgs
parents: 30
diff changeset
   485
        {
hgs
parents: 30
diff changeset
   486
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   487
            if (action)
hgs
parents: 30
diff changeset
   488
            {
hgs
parents: 30
diff changeset
   489
                mMenuActions[EActionSortByDate] = action;
hgs
parents: 30
diff changeset
   490
            }
hgs
parents: 30
diff changeset
   491
        }
hgs
parents: 30
diff changeset
   492
        else if (name.compare(DOCML_NAME_SORT_BY_NAME) == 0)
hgs
parents: 30
diff changeset
   493
        {
hgs
parents: 30
diff changeset
   494
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   495
            if (action)
hgs
parents: 30
diff changeset
   496
            {
hgs
parents: 30
diff changeset
   497
                mMenuActions[EActionSortByName] = action;
hgs
parents: 30
diff changeset
   498
            }
hgs
parents: 30
diff changeset
   499
        }
hgs
parents: 30
diff changeset
   500
        else if (name.compare(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS) == 0)
hgs
parents: 30
diff changeset
   501
        {
hgs
parents: 30
diff changeset
   502
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   503
            if (action)
hgs
parents: 30
diff changeset
   504
            {
hgs
parents: 30
diff changeset
   505
                mMenuActions[EACtionSortByItemCount] = action;
hgs
parents: 30
diff changeset
   506
            }
hgs
parents: 30
diff changeset
   507
        }
hgs
parents: 30
diff changeset
   508
        else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
hgs
parents: 30
diff changeset
   509
        {
hgs
parents: 30
diff changeset
   510
            HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
   511
            if (action)
hgs
parents: 30
diff changeset
   512
            {
hgs
parents: 30
diff changeset
   513
                mMenuActions[EActionSortBySize] = action;
hgs
parents: 30
diff changeset
   514
            }
hgs
parents: 30
diff changeset
   515
        }
hgs
parents: 30
diff changeset
   516
    }
hgs
parents: 30
diff changeset
   517
}
hgs
parents: 30
diff changeset
   518
hgs
parents: 30
diff changeset
   519
// ---------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   520
// executeRequest
hgs
parents: 35
diff changeset
   521
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   522
//
hgs
parents: 35
diff changeset
   523
QObject* VideoCollectionUiLoader::executeRequest(
hgs
parents: 35
diff changeset
   524
    const VideoCollectionUiLoaderParam &param)
hgs
parents: 35
diff changeset
   525
{
hgs
parents: 35
diff changeset
   526
	FUNC_LOG;
hgs
parents: 35
diff changeset
   527
    QObject *object = getObject(param);
hgs
parents: 35
diff changeset
   528
    if (!object)
hgs
parents: 35
diff changeset
   529
    {
hgs
parents: 35
diff changeset
   530
        // object was not found, try preparing docml and section
hgs
parents: 35
diff changeset
   531
        bool ok = prepareDocmlAndSection(param.mDocml, param.mSection);
hgs
parents: 35
diff changeset
   532
        if (ok)
hgs
parents: 35
diff changeset
   533
        {
hgs
parents: 35
diff changeset
   534
            // try to get the object again
hgs
parents: 35
diff changeset
   535
            object = getObject(param);
hgs
parents: 35
diff changeset
   536
        }
hgs
parents: 35
diff changeset
   537
    }
hgs
parents: 35
diff changeset
   538
    
hgs
parents: 35
diff changeset
   539
    // initialize object if it was found from docml
hgs
parents: 35
diff changeset
   540
    if (object)
hgs
parents: 35
diff changeset
   541
    {
hgs
parents: 35
diff changeset
   542
        if (!mObjects.contains(param.mName))
hgs
parents: 35
diff changeset
   543
        {
hgs
parents: 35
diff changeset
   544
            // initialize object
hgs
parents: 35
diff changeset
   545
            initObject(object, param.mName);
hgs
parents: 35
diff changeset
   546
hgs
parents: 35
diff changeset
   547
            // insert object in hash table
hgs
parents: 35
diff changeset
   548
            mObjects.insert(param.mName, object);
hgs
parents: 35
diff changeset
   549
        }
hgs
parents: 35
diff changeset
   550
        
hgs
parents: 35
diff changeset
   551
        bool ok = connect(
hgs
parents: 35
diff changeset
   552
            this, SIGNAL(objectReady(QObject*, const QString&)),
hgs
parents: 35
diff changeset
   553
            param.mReceiver, param.mMember);
hgs
parents: 35
diff changeset
   554
        if (ok)
hgs
parents: 35
diff changeset
   555
        {
hgs
parents: 35
diff changeset
   556
            // signal client and disconnect
hgs
parents: 35
diff changeset
   557
            emit objectReady(object, param.mName);        
hgs
parents: 35
diff changeset
   558
            disconnect(
hgs
parents: 35
diff changeset
   559
                this, SIGNAL(objectReady(QObject*, const QString&)),
hgs
parents: 35
diff changeset
   560
                param.mReceiver, param.mMember);
hgs
parents: 35
diff changeset
   561
        }
hgs
parents: 35
diff changeset
   562
    }    
hgs
parents: 35
diff changeset
   563
    
hgs
parents: 35
diff changeset
   564
    return object;
hgs
parents: 35
diff changeset
   565
}
hgs
parents: 35
diff changeset
   566
hgs
parents: 35
diff changeset
   567
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   568
// indexInQueue
hgs
parents: 35
diff changeset
   569
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   570
//
hgs
parents: 35
diff changeset
   571
int VideoCollectionUiLoader::indexInQueue(const QString &name)
hgs
parents: 35
diff changeset
   572
{
hgs
parents: 35
diff changeset
   573
	FUNC_LOG;
hgs
parents: 35
diff changeset
   574
    int index = -1;
hgs
parents: 35
diff changeset
   575
    
hgs
parents: 35
diff changeset
   576
    int count = mQueue.count();
hgs
parents: 35
diff changeset
   577
    for (int i = 0; i < count; i++)
hgs
parents: 35
diff changeset
   578
    {
hgs
parents: 35
diff changeset
   579
        const VideoCollectionUiLoaderParam &param = mQueue.at(i);
hgs
parents: 35
diff changeset
   580
        if (param.mName == name)
hgs
parents: 35
diff changeset
   581
        {
hgs
parents: 35
diff changeset
   582
            // found from queue
hgs
parents: 35
diff changeset
   583
            index = i;
hgs
parents: 35
diff changeset
   584
            break;
hgs
parents: 35
diff changeset
   585
        }
hgs
parents: 35
diff changeset
   586
    }
hgs
parents: 35
diff changeset
   587
    
hgs
parents: 35
diff changeset
   588
    return index;
hgs
parents: 35
diff changeset
   589
}
hgs
parents: 35
diff changeset
   590
hgs
parents: 35
diff changeset
   591
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   592
// removeFromQueue
hgs
parents: 35
diff changeset
   593
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   594
//
hgs
parents: 35
diff changeset
   595
void VideoCollectionUiLoader::removeFromQueue(const QString &name)
hgs
parents: 35
diff changeset
   596
{
hgs
parents: 35
diff changeset
   597
	FUNC_LOG;
hgs
parents: 35
diff changeset
   598
    int count = mQueue.count();
hgs
parents: 35
diff changeset
   599
    for (int i = 0; i < count; i++)
hgs
parents: 35
diff changeset
   600
    {
hgs
parents: 35
diff changeset
   601
        const VideoCollectionUiLoaderParam &param = mQueue.at(i);
hgs
parents: 35
diff changeset
   602
        if (param.mName == name)
hgs
parents: 35
diff changeset
   603
        {
hgs
parents: 35
diff changeset
   604
            mQueue.removeAt(i);
hgs
parents: 35
diff changeset
   605
            break;
hgs
parents: 35
diff changeset
   606
        }
hgs
parents: 35
diff changeset
   607
    }
hgs
parents: 35
diff changeset
   608
}
hgs
parents: 35
diff changeset
   609
hgs
parents: 35
diff changeset
   610
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   611
// timerEvent
hgs
parents: 30
diff changeset
   612
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   613
//
hgs
parents: 30
diff changeset
   614
void VideoCollectionUiLoader::timerEvent(QTimerEvent *event)
30
hgs
parents:
diff changeset
   615
{
36
hgs
parents: 35
diff changeset
   616
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   617
    if (event)
hgs
parents: 30
diff changeset
   618
    {
hgs
parents: 30
diff changeset
   619
        if (event->timerId() == mTimerId)
hgs
parents: 30
diff changeset
   620
        {
36
hgs
parents: 35
diff changeset
   621
            // get current request from queue and execute it
hgs
parents: 35
diff changeset
   622
            int count = mQueue.count();
hgs
parents: 35
diff changeset
   623
            for (int i = 0; i < count; i++)
34
hgs
parents: 30
diff changeset
   624
            {
36
hgs
parents: 35
diff changeset
   625
                const VideoCollectionUiLoaderParam &param = mQueue.at(i);
hgs
parents: 35
diff changeset
   626
                if (mPhases.contains(param.mPhase))
34
hgs
parents: 30
diff changeset
   627
                {
36
hgs
parents: 35
diff changeset
   628
                    // load and initialize
hgs
parents: 35
diff changeset
   629
                    executeRequest(param);
hgs
parents: 35
diff changeset
   630
                                
hgs
parents: 35
diff changeset
   631
                    // remove the current request from queue and run next
hgs
parents: 35
diff changeset
   632
                    removeFromQueue(param.mName);
hgs
parents: 35
diff changeset
   633
                    break;
34
hgs
parents: 30
diff changeset
   634
                }
hgs
parents: 30
diff changeset
   635
            }
36
hgs
parents: 35
diff changeset
   636
            runNext();
34
hgs
parents: 30
diff changeset
   637
        }
hgs
parents: 30
diff changeset
   638
    }
30
hgs
parents:
diff changeset
   639
}
hgs
parents:
diff changeset
   640
hgs
parents:
diff changeset
   641
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   642
// createObject
hgs
parents:
diff changeset
   643
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   644
//
hgs
parents:
diff changeset
   645
QObject* VideoCollectionUiLoader::createObject( const QString& type, const QString &name )
hgs
parents:
diff changeset
   646
{
36
hgs
parents: 35
diff changeset
   647
	FUNC_LOG;
30
hgs
parents:
diff changeset
   648
    QObject* object = 0;
hgs
parents:
diff changeset
   649
hgs
parents:
diff changeset
   650
    if ( type == VideoListView::staticMetaObject.className() )
hgs
parents:
diff changeset
   651
    {
hgs
parents:
diff changeset
   652
        object = new VideoListView(this);
hgs
parents:
diff changeset
   653
    }
hgs
parents:
diff changeset
   654
    else if ( type == VideoListSelectionDialog::staticMetaObject.className() )
hgs
parents:
diff changeset
   655
    {
67
hgs
parents: 66
diff changeset
   656
        object = new VideoListSelectionDialog();
30
hgs
parents:
diff changeset
   657
    }
hgs
parents:
diff changeset
   658
    else if ( type == VideoListWidget::staticMetaObject.className() )
hgs
parents:
diff changeset
   659
    {
34
hgs
parents: 30
diff changeset
   660
        object = new VideoListWidget(this);
30
hgs
parents:
diff changeset
   661
    }
hgs
parents:
diff changeset
   662
    if ( object )
hgs
parents:
diff changeset
   663
    {
hgs
parents:
diff changeset
   664
        object->setObjectName( name );
hgs
parents:
diff changeset
   665
        return object;
hgs
parents:
diff changeset
   666
    }
hgs
parents:
diff changeset
   667
hgs
parents:
diff changeset
   668
    return HbDocumentLoader::createObject( type, name );
hgs
parents:
diff changeset
   669
}
34
hgs
parents: 30
diff changeset
   670
hgs
parents: 30
diff changeset
   671
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   672
// runNext
hgs
parents: 30
diff changeset
   673
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   674
//
hgs
parents: 30
diff changeset
   675
void VideoCollectionUiLoader::runNext()
hgs
parents: 30
diff changeset
   676
{
36
hgs
parents: 35
diff changeset
   677
	FUNC_LOG;
hgs
parents: 35
diff changeset
   678
    bool runNext = false;
hgs
parents: 35
diff changeset
   679
    int count = mQueue.count();
hgs
parents: 35
diff changeset
   680
    for (int i = 0; i < count; i++)
hgs
parents: 35
diff changeset
   681
    {
hgs
parents: 35
diff changeset
   682
        const VideoCollectionUiLoaderParam &param = mQueue.at(i);
hgs
parents: 35
diff changeset
   683
        if (mPhases.contains(param.mPhase))
hgs
parents: 35
diff changeset
   684
        {
hgs
parents: 35
diff changeset
   685
            runNext = true;
hgs
parents: 35
diff changeset
   686
            break;
hgs
parents: 35
diff changeset
   687
        }
hgs
parents: 35
diff changeset
   688
    }
hgs
parents: 35
diff changeset
   689
    
hgs
parents: 35
diff changeset
   690
    if (runNext)
34
hgs
parents: 30
diff changeset
   691
    {
hgs
parents: 30
diff changeset
   692
        if (!mTimerId)
hgs
parents: 30
diff changeset
   693
        {
hgs
parents: 30
diff changeset
   694
            // timer not running, start it
hgs
parents: 30
diff changeset
   695
            mTimerId = startTimer(ASYNC_FIND_TIMEOUT);
hgs
parents: 30
diff changeset
   696
        }
hgs
parents: 30
diff changeset
   697
    }
hgs
parents: 30
diff changeset
   698
    else
hgs
parents: 30
diff changeset
   699
    {
hgs
parents: 30
diff changeset
   700
        // no new requests, kill timer
hgs
parents: 30
diff changeset
   701
        if (mTimerId)
hgs
parents: 30
diff changeset
   702
        {
hgs
parents: 30
diff changeset
   703
            killTimer(mTimerId);
hgs
parents: 30
diff changeset
   704
            mTimerId = 0;
hgs
parents: 30
diff changeset
   705
        }
hgs
parents: 30
diff changeset
   706
    }
hgs
parents: 30
diff changeset
   707
}
hgs
parents: 30
diff changeset
   708
hgs
parents: 30
diff changeset
   709
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   710
// isValid
hgs
parents: 30
diff changeset
   711
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   712
//
36
hgs
parents: 35
diff changeset
   713
bool VideoCollectionUiLoader::isValid(const VideoCollectionUiLoaderParam &param)
34
hgs
parents: 30
diff changeset
   714
{
hgs
parents: 30
diff changeset
   715
    bool valid = true;
hgs
parents: 30
diff changeset
   716
    
36
hgs
parents: 35
diff changeset
   717
    if (param.mName.length() &&
hgs
parents: 35
diff changeset
   718
        param.mDocml &&
hgs
parents: 35
diff changeset
   719
        param.mMember &&
hgs
parents: 35
diff changeset
   720
        param.mReceiver)
34
hgs
parents: 30
diff changeset
   721
    {
hgs
parents: 30
diff changeset
   722
        // check if the param is already in the queue
hgs
parents: 30
diff changeset
   723
        int count = mQueue.count();
hgs
parents: 30
diff changeset
   724
        for (int i = 0; i < count; i++)
hgs
parents: 30
diff changeset
   725
        {
36
hgs
parents: 35
diff changeset
   726
            if (mQueue.at(i) == param)
34
hgs
parents: 30
diff changeset
   727
            {
36
hgs
parents: 35
diff changeset
   728
                INFO("VideoCollectionUiLoader::isValid() already in queue.");
34
hgs
parents: 30
diff changeset
   729
                valid = false;
hgs
parents: 30
diff changeset
   730
                break;
hgs
parents: 30
diff changeset
   731
            }
hgs
parents: 30
diff changeset
   732
        }
hgs
parents: 30
diff changeset
   733
        
hgs
parents: 30
diff changeset
   734
        // check that the item has not already been loaded
hgs
parents: 30
diff changeset
   735
        if (valid)
hgs
parents: 30
diff changeset
   736
        {
36
hgs
parents: 35
diff changeset
   737
            valid = !mObjects.contains(param.mName);
34
hgs
parents: 30
diff changeset
   738
        }
hgs
parents: 30
diff changeset
   739
    }
hgs
parents: 30
diff changeset
   740
    else
hgs
parents: 30
diff changeset
   741
    {
36
hgs
parents: 35
diff changeset
   742
        INFO("VideoCollectionUiLoader::isValid() params missing.");
34
hgs
parents: 30
diff changeset
   743
        valid = false;
hgs
parents: 30
diff changeset
   744
    }
hgs
parents: 30
diff changeset
   745
    
hgs
parents: 30
diff changeset
   746
    return valid;
hgs
parents: 30
diff changeset
   747
}
36
hgs
parents: 35
diff changeset
   748
hgs
parents: 35
diff changeset
   749
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   750
// storeOrphans
hgs
parents: 35
diff changeset
   751
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   752
//
hgs
parents: 35
diff changeset
   753
void VideoCollectionUiLoader::storeOrphans(const QObjectList &list)
hgs
parents: 35
diff changeset
   754
{
hgs
parents: 35
diff changeset
   755
	FUNC_LOG;
hgs
parents: 35
diff changeset
   756
    foreach (QObject *object, list)
hgs
parents: 35
diff changeset
   757
    {
hgs
parents: 35
diff changeset
   758
        if (!mOrphans.contains(object))
hgs
parents: 35
diff changeset
   759
        {
hgs
parents: 35
diff changeset
   760
            // add to list
hgs
parents: 35
diff changeset
   761
            mOrphans.append(object);
hgs
parents: 35
diff changeset
   762
            
hgs
parents: 35
diff changeset
   763
            // connect to "destroyed" signal
hgs
parents: 35
diff changeset
   764
            connect(
hgs
parents: 35
diff changeset
   765
                object, SIGNAL(destroyed(QObject*)),
hgs
parents: 35
diff changeset
   766
                this, SLOT(removeOrphanFromList(QObject*)));
hgs
parents: 35
diff changeset
   767
        }
hgs
parents: 35
diff changeset
   768
    }
hgs
parents: 35
diff changeset
   769
}
hgs
parents: 35
diff changeset
   770
hgs
parents: 35
diff changeset
   771
// end of file
hgs
parents: 35
diff changeset
   772