stifui/qt/src/stfqtuimodel.cpp
changeset 0 39ab869ed429
equal deleted inserted replaced
-1:000000000000 0:39ab869ed429
       
     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 CSTFCase StfQtUIModel::GetRunningCase(const CStartedTestCase* startedCase)
       
    69     {
       
    70     return runningCaseList.value(startedCase);
       
    71     }
       
    72 
       
    73 void StfQtUIModel::AddCaseByStatus(const TSTFCaseStatusType& type, const CSTFCase& aCase)
       
    74     {
       
    75     switch (type)
       
    76         {
       
    77         case EStatusRunning:
       
    78             break;
       
    79         case EStatusExecuted:
       
    80             executedCaseList.append(aCase);
       
    81             break;
       
    82         case EStatusPassed:
       
    83             passedCaseList.append(aCase);
       
    84             break;
       
    85         case EStatusFailed:
       
    86             failedCaseList.append(aCase);
       
    87             break;
       
    88         case EStatusAborted:
       
    89             abortCaseList.append(aCase);
       
    90             break;
       
    91         case EStatusCrashed:
       
    92             crashedCaseList.append(aCase);
       
    93             break;
       
    94         default:
       
    95             break;            
       
    96         }
       
    97     FireOnCaseStatisticChangedEvent();
       
    98     }
       
    99 
       
   100 QList<CSTFCase> StfQtUIModel::GetCasesByStatus(const TSTFCaseStatusType& type)
       
   101     {
       
   102     switch (type)
       
   103         {
       
   104         case EStatusRunning:
       
   105             return runningCaseList.values();
       
   106         case EStatusExecuted:
       
   107             return executedCaseList;
       
   108         case EStatusPassed:
       
   109             return passedCaseList;
       
   110         case EStatusFailed:
       
   111             return failedCaseList;
       
   112         case EStatusAborted:
       
   113             return abortCaseList;
       
   114         case EStatusCrashed:
       
   115             return crashedCaseList;
       
   116         default:
       
   117             break;
       
   118         }
       
   119     QList<CSTFCase> list;
       
   120     return list;
       
   121     }
       
   122 
       
   123 void StfQtUIModel::AddStifModelEventListener(
       
   124         IStifModelEventListener* listener)
       
   125     {
       
   126     if (!listenerList.contains(listener))
       
   127         {
       
   128         listenerList.append(listener);
       
   129         }
       
   130     }
       
   131 
       
   132 void StfQtUIModel::RemoveStifModelEventListener(
       
   133         IStifModelEventListener* listener)
       
   134     {
       
   135     if (!listenerList.contains(listener))
       
   136         {
       
   137         listenerList.removeOne(listener);
       
   138         }
       
   139     }
       
   140 
       
   141 void StfQtUIModel::FireOnCaseStatisticChangedEvent()
       
   142     {
       
   143     foreach(IStifModelEventListener* listener, listenerList)
       
   144             {
       
   145             listener->OnCaseStatisticChanged();
       
   146             }
       
   147     }
       
   148 
       
   149 void StfQtUIModel::FireOnRunningCaseChangedEvent()
       
   150     {
       
   151     foreach(IStifModelEventListener* listener, listenerList)
       
   152             {
       
   153             listener->OnRunningCaseChanged();
       
   154             }
       
   155     }
       
   156 
       
   157 void StfQtUIModel::ClearCasesStatus()
       
   158     {
       
   159     executedCaseList.clear();
       
   160     passedCaseList.clear();
       
   161     failedCaseList.clear();
       
   162     abortCaseList.clear();
       
   163     crashedCaseList.clear();
       
   164     FireOnCaseStatisticChangedEvent();
       
   165     }
       
   166 
       
   167 // End of File