taskswitcher/server/tsrc/t_tsservicesprovider/tstestmodel.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     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 #include <QDateTime>
       
    18 #include <QStringList>
       
    19 
       
    20 #include "tstestmodel.h"
       
    21 
       
    22 const int dataIterations(3);
       
    23 
       
    24 TsTestModel::TsTestModel()
       
    25 {
       
    26     mData = data(-1);
       
    27 }
       
    28 QList<QVariantHash> TsTestModel::taskList() const
       
    29 {
       
    30     return mData;
       
    31 }
       
    32 
       
    33 QList<QVariantHash> TsTestModel::taskList(int limit) const
       
    34 {
       
    35     return data(limit);
       
    36 }
       
    37 
       
    38 bool TsTestModel::openTask(const QVariant &/*id*/)
       
    39 {
       
    40     return true;
       
    41 }
       
    42 bool TsTestModel::closeTask(const QVariant &/*id*/) 
       
    43 {
       
    44     return true;
       
    45 }
       
    46 
       
    47 QList<QVariantHash> TsTestModel::data(int limit) const
       
    48 {
       
    49     QStringList allKeys;
       
    50     allKeys << "TaskId" << "TaskName" << "TaskScreenshot" << "TaskTimestamp" << "TaskIsRunning" << "TaskCanBeClosed" << "TaskUid";
       
    51 
       
    52     int offset(0);
       
    53     QList<QVariantHash> retVal;
       
    54     for( int iter(0); iter < dataIterations; ++iter) {
       
    55     
       
    56         if(-1 != limit && ++offset >limit) {
       
    57             break;
       
    58         }
       
    59         retVal.append(data());
       
    60         
       
    61         foreach (const QString &key, allKeys) {
       
    62             if(-1 != limit && ++offset >limit) {
       
    63                 break;
       
    64             }
       
    65             QVariantHash dataSet(data());
       
    66             dataSet.remove(key);
       
    67             retVal.append(dataSet);
       
    68         }
       
    69     }
       
    70     return retVal;
       
    71 }
       
    72 
       
    73 QVariantHash TsTestModel::data()const
       
    74 {
       
    75     QVariantHash data;
       
    76     data.insert("TaskId", 0);
       
    77     data.insert("TaskName", "Fake test name");
       
    78     data.insert("TaskScreenshot", 0);
       
    79     data.insert("TaskTimestamp", QDateTime());
       
    80     data.insert("TaskIsRunning", 0);
       
    81     data.insert("TaskCanBeClosed", 0);
       
    82     data.insert("TaskUid", 0 );
       
    83     return data;
       
    84 }
       
    85