activityfw/testapplications/nftapps/lptapp/datawidget.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 "datawidget.h"
       
    18 
       
    19 
       
    20 
       
    21 datawidget::datawidget(QObject* activityStorage, QObject* activityManager, QTextStream* stream, QGraphicsItem *parent)
       
    22     : basewidget(activityStorage, activityManager, stream, parent)
       
    23 {
       
    24     mTestCheckBox->setText("Prepare data");    
       
    25     mStartTestButton->setText("Data");
       
    26 }
       
    27 
       
    28 datawidget::~datawidget()
       
    29 {
       
    30 }
       
    31 
       
    32 
       
    33 void datawidget::timeout()
       
    34 {
       
    35     if(mAction == "predel") {
       
    36         if(mItemsCounter<mItems) {
       
    37             QString name = mActivities.at(mItemsCounter);
       
    38             bool ok = removeActivity(name);
       
    39             mItemsCounter++;
       
    40             if(!ok) {                
       
    41                 setError("remove activity");
       
    42                 return;
       
    43             }
       
    44             updateItemLabel(mItemsCounter);
       
    45         }
       
    46         else {
       
    47             mItems=Items();
       
    48             mItemsCounter = 0;
       
    49             mAction = "presave";
       
    50             updateActionLabel();
       
    51             //updateItemLabel(mItemsCounter);
       
    52             prepareSave();
       
    53         }
       
    54     }
       
    55     else if(mAction == "presave") {
       
    56         if(mItemsCounter<mItems) {
       
    57             bool ok = saveActivity(mItemsCounter);
       
    58             mItemsCounter++;
       
    59             if(!ok) {                
       
    60                 setError("save activity");
       
    61                 return;
       
    62             }
       
    63             updateItemLabel(mItemsCounter);
       
    64         }
       
    65         else {
       
    66             mItems=Items();
       
    67             mTimes=Times();
       
    68             mItemsCounter = 0;
       
    69             mAction = "data";
       
    70             updateActionLabel();
       
    71             //updateItemLabel(mItemsCounter);
       
    72             updateTimeLabel(mTimesCounter);
       
    73             clearSaveData();
       
    74             logFirst(); 
       
    75             bool ok = activities();
       
    76             if(!ok) {
       
    77                 setError("get activities list");
       
    78                 return;
       
    79             }
       
    80         }
       
    81     }
       
    82     else if(mAction == "data") {
       
    83         if(mTimesCounter==mTimes) {
       
    84             endNormally();
       
    85             return;
       
    86         }
       
    87         if(mItemsCounter<mItems) {
       
    88             QString name = mActivities.at(mItemsCounter);
       
    89             bool ok = privateData(name);
       
    90             mItemsCounter++;
       
    91             if(!ok) {                
       
    92                 setError("get data");
       
    93                 return;
       
    94             }            
       
    95             updateItemLabel(mItemsCounter);
       
    96         }
       
    97         else {
       
    98             mTimesCounter++;
       
    99             mItemsCounter = 0;
       
   100             //updateItemLabel(mItemsCounter);
       
   101             updateTimeLabel(mTimesCounter);
       
   102         }
       
   103     }
       
   104     else {
       
   105         setError("unexpected state");
       
   106     }
       
   107 }
       
   108 
       
   109 void datawidget::test()
       
   110 {
       
   111     mTimesCounter = 0;
       
   112     mStatusValueLabel->setPlainText("Pending");
       
   113     enableControls(false);
       
   114     *mStream<<tr("*Get private data*\n");
       
   115     mStream->flush();
       
   116     logSettings();
       
   117     bool ok = activities();
       
   118     if(!ok) {
       
   119         setError("get activities list");
       
   120         return;
       
   121     }
       
   122     if (TestCheckBoxChecked()) {
       
   123         mAction = "predel"; 
       
   124         mItems = mActivities.count();        
       
   125     }
       
   126     else {
       
   127         mAction = "data";
       
   128         ok = checkActNum();
       
   129          if(!ok) {
       
   130              setError("unexpected act number");
       
   131              return;
       
   132          }
       
   133          mItems=Items();
       
   134          mTimes=Times();
       
   135          mItemsCounter = 0;
       
   136          updateItemLabel(mItemsCounter);
       
   137          updateTimeLabel(mTimesCounter);
       
   138          logFirst();
       
   139          connect( mActivityManager, SIGNAL(thumbnailReady(QPixmap, void *)), this, SLOT(thumbnailReady(QPixmap, void *)) );
       
   140     }
       
   141     basewidget::test();
       
   142 }