stif/QtUI/StifQtUI/stfqtuimodel.cpp
branchRCL_3
changeset 9 8a14024f954a
equal deleted inserted replaced
8:ecff51f1e7fb 9:8a14024f954a
       
     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: QT C++ based Class.
       
    15  *              application model implementation.
       
    16  *
       
    17  */
       
    18 #include "stfqtuimodel.h"
       
    19 #include <UIEngineContainer.h>
       
    20 
       
    21 StfQtUIModel::StfQtUIModel()
       
    22     {
       
    23     //nothing to do.
       
    24     }
       
    25 
       
    26 StfQtUIModel::~StfQtUIModel()
       
    27     {
       
    28     //nothing to do.
       
    29     }
       
    30 
       
    31 void StfQtUIModel::PauseCase()
       
    32     {
       
    33     foreach(const CStartedTestCase* startedCase, runningCaseList.keys())
       
    34             {
       
    35             startedCase->UIEngineContainer().PauseTest();
       
    36             }
       
    37     }
       
    38 
       
    39 void StfQtUIModel::ResumeCase()
       
    40     {
       
    41     foreach(const CStartedTestCase* startedCase, runningCaseList.keys())
       
    42             {
       
    43             startedCase->UIEngineContainer().ResumeTest();
       
    44             }
       
    45     }
       
    46 
       
    47 void StfQtUIModel::AbortCase()
       
    48     {
       
    49     foreach(const CStartedTestCase* startedCase, runningCaseList.keys())
       
    50             {
       
    51             startedCase->UIEngineContainer().CancelTest();
       
    52             }
       
    53     }
       
    54 
       
    55 void StfQtUIModel::AddRunningCase(const CStartedTestCase* startedCase,
       
    56         const CSTFCase& stfCase)
       
    57     {
       
    58     runningCaseList.insert(startedCase, stfCase);
       
    59     FireOnRunningCaseChangedEvent();
       
    60     }
       
    61 
       
    62 void StfQtUIModel::RemoveRunningCase(const CStartedTestCase* startedCase)
       
    63     {
       
    64     runningCaseList.remove(startedCase);
       
    65     FireOnRunningCaseChangedEvent();
       
    66     }
       
    67 
       
    68 void StfQtUIModel::AddCaseByStatus(const TSTFCaseStatusType& type, const CSTFCase& aCase)
       
    69     {
       
    70     switch (type)
       
    71         {
       
    72         case EStatusRunning:
       
    73             break;
       
    74         case EStatusExecuted:
       
    75             executedCaseList.append(aCase);
       
    76             break;
       
    77         case EStatusPassed:
       
    78             passedCaseList.append(aCase);
       
    79             break;
       
    80         case EStatusFailed:
       
    81             failedCaseList.append(aCase);
       
    82             break;
       
    83         case EStatusAborted:
       
    84             abortCaseList.append(aCase);
       
    85             break;
       
    86         case EStatusCrashed:
       
    87             crashedCaseList.append(aCase);
       
    88             break;
       
    89         }
       
    90     FireOnCaseStatisticChangedEvent();
       
    91     }
       
    92 
       
    93 QList<CSTFCase> StfQtUIModel::GetCasesByStatus(const TSTFCaseStatusType& type)
       
    94     {
       
    95     switch (type)
       
    96         {
       
    97         case EStatusRunning:
       
    98             return runningCaseList.values();
       
    99         case EStatusExecuted:
       
   100             return executedCaseList;
       
   101         case EStatusPassed:
       
   102             return passedCaseList;
       
   103         case EStatusFailed:
       
   104             return failedCaseList;
       
   105         case EStatusAborted:
       
   106             return abortCaseList;
       
   107         case EStatusCrashed:
       
   108             return crashedCaseList;
       
   109         }
       
   110     QList<CSTFCase> list;
       
   111     return list;
       
   112     }
       
   113 
       
   114 void StfQtUIModel::AddStifModelEventListener(
       
   115         IStifModelEventListener* listener)
       
   116     {
       
   117     if (!listenerList.contains(listener))
       
   118         {
       
   119         listenerList.append(listener);
       
   120         }
       
   121     }
       
   122 
       
   123 void StfQtUIModel::RemoveStifModelEventListener(
       
   124         IStifModelEventListener* listener)
       
   125     {
       
   126     if (!listenerList.contains(listener))
       
   127         {
       
   128         listenerList.removeOne(listener);
       
   129         }
       
   130     }
       
   131 
       
   132 void StfQtUIModel::FireOnCaseStatisticChangedEvent()
       
   133     {
       
   134     foreach(IStifModelEventListener* listener, listenerList)
       
   135             {
       
   136             listener->OnCaseStatisticChanged();
       
   137             }
       
   138     }
       
   139 
       
   140 void StfQtUIModel::FireOnRunningCaseChangedEvent()
       
   141     {
       
   142     foreach(IStifModelEventListener* listener, listenerList)
       
   143             {
       
   144             listener->OnRunningCaseChanged();
       
   145             }
       
   146     }
       
   147 
       
   148 void StfQtUIModel::ClearCasesStatus()
       
   149     {
       
   150     executedCaseList.clear();
       
   151     passedCaseList.clear();
       
   152     failedCaseList.clear();
       
   153     abortCaseList.clear();
       
   154     crashedCaseList.clear();
       
   155     FireOnCaseStatisticChangedEvent();
       
   156     }