stifui/qt/src/frmmain.cpp
branchGCC_SURGE
changeset 37 c20154ccf3c0
parent 35 98924d2efce9
equal deleted inserted replaced
20:ba8a586c45f1 37:c20154ccf3c0
    19 #include "stfqtuicontroller.h"
    19 #include "stfqtuicontroller.h"
    20 #include "stfqtuimodel.h"
    20 #include "stfqtuimodel.h"
    21 #include <QList>
    21 #include <QList>
    22 #include "version.h"
    22 #include "version.h"
    23 #include <QCursor>
    23 #include <QCursor>
       
    24 #include <QDesktopWidget>
    24 
    25 
    25 const QString SELECTITEMHEADER = " * ";
    26 const QString SELECTITEMHEADER = " * ";
    26 const QString UNSELECTITEMHEADER = "   ";
    27 const QString UNSELECTITEMHEADER = "   ";
    27 
    28 
    28 frmMain::frmMain()
    29 FrmMain::FrmMain()
    29     {
    30     {
       
    31     lastItemSelected = NULL;
    30     uiSetting = new UiSetting();
    32     uiSetting = new UiSetting();
    31     createMenus();
    33     createMenus();
    32     load();
    34     load();
    33     LoadSubMenu();
    35     LoadSubMenu();
       
    36     
       
    37     QFile file(uiSetting->ReadSetting(KStyleSheet));
       
    38     bool rst = file.open(QFile::ReadOnly);    
       
    39     if(rst)
       
    40         {
       
    41         QString styleSheet = QLatin1String(file.readAll());    
       
    42         qApp->setStyleSheet(styleSheet);    
       
    43         }
       
    44         
    34     model = new StfQtUIModel();
    45     model = new StfQtUIModel();
    35     model->AddStifModelEventListener(this);
    46     model->AddStifModelEventListener(this);
    36     controller = new StfQtUIController(model);
    47     controller = new StfQtUIController(model);
    37     controller->AddStfEventListener(this);
    48     controller->AddStfEventListener(this);
    38     loadContent();
    49     loadContent();
    39     dlgOutput = new DlgOutput(controller);
    50     dlgOutput = new DlgOutput(controller);
    40     setSetting();
    51     setSetting();
    41     }
    52     }
    42 
    53 
    43 frmMain::~frmMain()
    54 FrmMain::~FrmMain()
    44     {
    55     {
    45     model->AbortCase();
    56     model->AbortCase();
    46     controller->RemoveStfEventListener(this);
    57     controller->RemoveStfEventListener(this);
    47     model->RemoveStifModelEventListener(this);
    58     model->RemoveStifModelEventListener(this);
    48     
    59     
       
    60     //lastItemSelected does not own any memory, don't need to delete.
       
    61     lastItemSelected = NULL;
    49     delete uiSetting;
    62     delete uiSetting;
    50     delete dlgOutput;
    63     delete dlgOutput;
    51     delete controller;
    64     delete controller;
    52     delete model;
    65     delete model;
    53     }
    66     }
    54 
    67 
    55 void frmMain::setSetting()
    68 void FrmMain::paintEvent(QPaintEvent* event)
    56     {
    69     {
    57     controller->SetShowOutput(uiSetting->ReadSetting("showoutput") == "true");    
    70     
    58     }
    71     if(mainLayout != NULL)
    59 
    72         {
    60 void frmMain::OnGetMessage(const QString& aMessage)
    73         QDesktopWidget* desktop = QApplication::desktop();
       
    74         QRect rect = desktop->screenGeometry(0);
       
    75         bool temp = false;
       
    76         if(rect.height() > rect.width())
       
    77             {
       
    78             temp = true;
       
    79             }
       
    80         
       
    81         if(temp != layoutType)
       
    82             {
       
    83             mainLayout->removeWidget(tabWidget);
       
    84             mainLayout->removeWidget(groupBox);
       
    85             if(temp)
       
    86                 {
       
    87                 mainLayout->addWidget(tabWidget, 0, 0);
       
    88                 mainLayout->addWidget(groupBox, 1, 0, Qt::AlignBottom);
       
    89                 mainLayout->setRowStretch(0,4);
       
    90                 mainLayout->setRowStretch(1,1);
       
    91                 }
       
    92             else
       
    93                 {
       
    94                 mainLayout->addWidget(tabWidget, 0, 0);
       
    95                 mainLayout->addWidget(groupBox, 0, 1);//Qt::AlignRight
       
    96                 //groupBox->setFixedSize(60,0);
       
    97                 mainLayout->setColumnStretch(0,1);
       
    98                 mainLayout->setColumnStretch(1,1);
       
    99                 }
       
   100             layoutType = temp;
       
   101             
       
   102             }
       
   103         
       
   104         }
       
   105     event->accept();
       
   106     }
       
   107 
       
   108 void FrmMain::setSetting()
       
   109     {
       
   110     controller->SetShowOutput(uiSetting->ReadSetting(KShowOutput) == "true");    
       
   111     // Apply filter changes
       
   112     QString newFilter = uiSetting->ReadSetting(KFilter);
       
   113     QString newFilterCaseSens = uiSetting->ReadSetting(KFilterCaseSens); 
       
   114     if(currentFilter != newFilter || currentFilterCaseSens != newFilterCaseSens)
       
   115         {
       
   116         // Store new filter for further use
       
   117         currentFilter = newFilter;
       
   118         currentFilterCaseSens = newFilterCaseSens;
       
   119         
       
   120         // Create and setup regular expression for wildcard searching
       
   121         QRegExp filter;
       
   122         filter.setPattern((newFilter == "") ? ("*") : (tr("*") + newFilter + tr("*")));
       
   123         filter.setCaseSensitivity((newFilterCaseSens == "true") ? (Qt::CaseSensitive) : (Qt::CaseInsensitive));
       
   124         filter.setPatternSyntax(QRegExp::Wildcard);
       
   125 
       
   126         // Go through top level entries (modules)
       
   127         bool isAnythingHidden = false;
       
   128         for(int i = 0; i < treeModuleList->topLevelItemCount(); i++)
       
   129             {
       
   130             QTreeWidgetItem* top = treeModuleList->topLevelItem(i);
       
   131             // And through test cases for each module
       
   132             for(int j = 0; j < top->childCount(); j++)
       
   133                 {                
       
   134                 QTreeWidgetItem *child = top->child(j);
       
   135                 // Remove first three chars to get valid test case title
       
   136                 QString title = (child->text(0)).mid(3);
       
   137                 // Check if title is matching to filter and show or hide it
       
   138                 if(filter.exactMatch(title))
       
   139                     {
       
   140                     child->setHidden(false);
       
   141                     }
       
   142                 else
       
   143                     {
       
   144                     child->setHidden(true);
       
   145                     child->setText(0, child->text(0).replace(0, 3, UNSELECTITEMHEADER));
       
   146                     isAnythingHidden = true;
       
   147                     }
       
   148                 }
       
   149             }
       
   150 
       
   151         if(isAnythingHidden)
       
   152             treeModuleList->headerItem()->setText(0, tr("Module List (filtered)"));
       
   153         else
       
   154             treeModuleList->headerItem()->setText(0, tr("Module List"));
       
   155         }
       
   156     }
       
   157 
       
   158 void FrmMain::OnGetMessage(const QString& aMessage)
    61     {
   159     {
    62     txtOutput->appendPlainText(aMessage);
   160     txtOutput->appendPlainText(aMessage);
    63     }
   161     }
    64 
   162 
    65 void frmMain::OnRunningCaseChanged()
   163 void FrmMain::OnRunningCaseChanged()
    66     {
   164     {
    67     QList<CSTFCase> caseList = controller->GetCasesByStatus(EStatusRunning);
   165     QList<CSTFCase> caseList = controller->GetCasesByStatus(EStatusRunning);
    68     lstStartedCases->clear();
   166     lstStartedCases->clear();
    69     foreach(CSTFCase aCase, caseList)
   167     foreach(CSTFCase aCase, caseList)
    70             {
   168             {
    72             }
   170             }
    73     if (caseList.size() != 0)
   171     if (caseList.size() != 0)
    74         {
   172         {
    75         btnPauseCase->setEnabled(true);
   173         btnPauseCase->setEnabled(true);
    76         btnAbortCase->setEnabled(true);
   174         btnAbortCase->setEnabled(true);
       
   175         btnShowOutput->setEnabled(true);
    77         actPause->setEnabled(true);
   176         actPause->setEnabled(true);
    78         actAbort->setEnabled(true);
   177         actAbort->setEnabled(true);
       
   178         actOutput->setEnabled(true);
    79         }
   179         }
    80     else
   180     else
    81         {
   181         {
    82         btnPauseCase->setEnabled(false);
   182         btnPauseCase->setEnabled(false);
    83         btnAbortCase->setEnabled(false);
   183         btnAbortCase->setEnabled(false);
       
   184         btnShowOutput->setEnabled(false);
    84         actPause->setEnabled(false);
   185         actPause->setEnabled(false);
    85         actAbort->setEnabled(false);
   186         actAbort->setEnabled(false);
    86         }
   187         actOutput->setEnabled(false);
    87     }
   188         }
    88 
   189     }
    89 void frmMain::OnCaseOutputChanged(const IStfEventListener::CaseOutputCommand& /*cmd*/, const QString& /*index*/, const QString& /*msg*/)
   190 
       
   191 void FrmMain::OnCaseOutputChanged(const IStfEventListener::CaseOutputCommand& /*cmd*/, const QString& /*index*/, const QString& /*msg*/)
    90     {
   192     {
    91     //nothing to do.
   193     //nothing to do.
    92     }
   194     }
    93 
   195 
    94 void frmMain::OnSetListChanged()
   196 void FrmMain::OnSetListChanged()
    95     {
   197     {
    96     loadSetList();
   198     loadSetList();
    97     }
   199     }
    98 
   200 
    99 void frmMain::OnCaseStatisticChanged()
   201 void FrmMain::OnCaseStatisticChanged()
   100     {
   202     {
   101     loadStatistic();
   203     loadStatistic();
   102     }
   204     }
   103 
   205 
   104 void frmMain::createMenus()
   206 void FrmMain::createMenus()
   105     {
   207     {
   106     //operateMenu = menuBar()->addMenu(tr("&Operation"));
   208     //operateMenu = menuBar()->addMenu(tr("&Operation"));
   107     actAbout = new QAction(tr("&About"), this);
   209     actAbout = new QAction(tr("&About"), this);
   108     connect(actAbout, SIGNAL(triggered()), this,
   210     connect(actAbout, SIGNAL(triggered()), this,
   109             SLOT(on_actAbout_triggered()));
   211             SLOT(on_actAbout_triggered()));
   113 
   215 
   114     actOpenFile = new QAction(tr("&Open Ini File"), this);
   216     actOpenFile = new QAction(tr("&Open Ini File"), this);
   115     connect(actOpenFile, SIGNAL(triggered()), this,
   217     connect(actOpenFile, SIGNAL(triggered()), this,
   116             SLOT(on_actOpenFile_triggered()));
   218             SLOT(on_actOpenFile_triggered()));
   117 
   219 
   118     actRunCaseSeq = new QAction(tr("Run Case Sequentially"), this);
   220     menuRunCase = new QMenu(tr("Run Selected Case(s)"), this->menuBar());
       
   221     
       
   222     actRunCaseSeq = new QAction(tr("Sequentially"), this);
   119     connect(actRunCaseSeq, SIGNAL(triggered()), this,
   223     connect(actRunCaseSeq, SIGNAL(triggered()), this,
   120             SLOT(on_actRunCaseSeq_triggered()));
   224             SLOT(on_actRunCaseSeq_triggered()));
   121 
   225 
   122     actRunCasePar = new QAction(tr("Run Case Parallel"), this);
   226     actRunCasePar = new QAction(tr("Parallel"), this);
   123     connect(actRunCasePar, SIGNAL(triggered()), this,
   227     connect(actRunCasePar, SIGNAL(triggered()), this,
   124             SLOT(on_actRunCasePar_triggered()));
   228             SLOT(on_actRunCasePar_triggered()));
   125 
   229 
       
   230     ////////////////////
       
   231     actReapeatRunSeq = new QAction(tr("Repeat run sequentially"), this);
       
   232     connect(actReapeatRunSeq, SIGNAL(triggered()), this,
       
   233             SLOT(on_actReapeatRunSeq_triggered()));
       
   234     
   126     actAddtoSet = new QAction(tr("Add cases to Set"), this);
   235     actAddtoSet = new QAction(tr("Add cases to Set"), this);
   127     connect(actAddtoSet, SIGNAL(triggered()), this,
   236     connect(actAddtoSet, SIGNAL(triggered()), this,
   128             SLOT(on_actAddtoSet_triggered()));
   237             SLOT(on_actAddtoSet_triggered()));
   129 
   238 
   130     actSelectAll = new QAction(tr("Select All"), this);
   239     actSelectAll = new QAction(tr("Select All"), this);
   137 
   246 
   138     actCollapseAll = new QAction(tr("Collapse All"), this);
   247     actCollapseAll = new QAction(tr("Collapse All"), this);
   139     connect(actCollapseAll, SIGNAL(triggered()), this,
   248     connect(actCollapseAll, SIGNAL(triggered()), this,
   140             SLOT(on_actCollapseAll_triggered()));
   249             SLOT(on_actCollapseAll_triggered()));
   141 
   250 
   142     actSetting = new QAction(tr("Setting"), this);
   251     actSetting = new QAction(tr("Settings"), this);
   143     connect(actSetting, SIGNAL(triggered()), this,
   252     connect(actSetting, SIGNAL(triggered()), this,
   144             SLOT(on_actSetting_triggered()));
   253             SLOT(on_actSetting_triggered()));
   145 
   254 
   146     actRunSetSeq = new QAction(tr("Run Set Sequentially"), this);
   255     menuRunSet = new QMenu(tr("Run Case(s) in Selected Set"), this->menuBar());
       
   256     
       
   257     actRunSetSeq = new QAction(tr("Sequentially"), this);
   147     connect(actRunSetSeq, SIGNAL(triggered()), this,
   258     connect(actRunSetSeq, SIGNAL(triggered()), this,
   148             SLOT(on_actRunSetSeq_triggered()));
   259             SLOT(on_actRunSetSeq_triggered()));
   149 
   260 
   150     actRunSetPar = new QAction(tr("Run Set Parallel"), this);
   261     actRunSetPar = new QAction(tr("Parallel"), this);
   151     connect(actRunSetPar, SIGNAL(triggered()), this,
   262     connect(actRunSetPar, SIGNAL(triggered()), this,
   152             SLOT(on_actRunSetPar_triggered()));
   263             SLOT(on_actRunSetPar_triggered()));
   153 
   264 
   154     actNewSet = new QAction(tr("Create New Set"), this);
   265     actNewSet = new QAction(tr("Create New Set"), this);
   155     connect(actNewSet, SIGNAL(triggered()), this,
   266     connect(actNewSet, SIGNAL(triggered()), this,
   166 
   277 
   167     actAbort = new QAction(tr("Abort"), this);
   278     actAbort = new QAction(tr("Abort"), this);
   168     actAbort->setEnabled(false);
   279     actAbort->setEnabled(false);
   169     connect(actAbort, SIGNAL(triggered()), this,
   280     connect(actAbort, SIGNAL(triggered()), this,
   170             SLOT(on_actAbort_triggered()));
   281             SLOT(on_actAbort_triggered()));
       
   282     
       
   283     actOutput = new QAction(tr("Output"), this);
       
   284     actOutput->setEnabled(false);
       
   285     connect(actAbort, SIGNAL(triggered()), this,
       
   286             SLOT(on_actOutput_triggered()));
   171 
   287 
   172     actClearStatistics = new QAction(tr("Clear Statistics"), this);
   288     actClearStatistics = new QAction(tr("Clear Statistics"), this);
   173     connect(actClearStatistics, SIGNAL(triggered()), this,
   289     connect(actClearStatistics, SIGNAL(triggered()), this,
   174             SLOT(on_actClearStatistics_triggered()));
   290             SLOT(on_actClearStatistics_triggered()));
   175 
   291 
   176     }
   292     }
   177 
   293 
   178 void frmMain::load()
   294 void FrmMain::load()
   179     {
   295     {
   180     this->setContextMenuPolicy(Qt::NoContextMenu);
   296     this->setContextMenuPolicy(Qt::NoContextMenu);
   181     QSize btnSize(100,35);
   297     
   182     QGridLayout *mainLayout = new QGridLayout(this);
   298     this->setWindowTitle(QtUIName);
       
   299     centerWidget = new QWidget(this);
       
   300     this->setCentralWidget(centerWidget);
       
   301     
       
   302     mainLayout = new QGridLayout(this);
   183     mainLayout->setVerticalSpacing(2);
   303     mainLayout->setVerticalSpacing(2);
   184     mainLayout->setHorizontalSpacing(2);
   304     mainLayout->setHorizontalSpacing(2);
   185     mainLayout->setSpacing(2);
   305     mainLayout->setSpacing(2);
   186     mainLayout->setMargin(2);
   306     mainLayout->setMargin(2);
   187 
   307     
   188     MainWidget = new QWidget(this);
   308     this->centralWidget()->setContextMenuPolicy(Qt::NoContextMenu);
   189     MainWidget->setContextMenuPolicy(Qt::NoContextMenu);
   309     
   190 
       
   191     //tab control
   310     //tab control
   192     tabWidget = new QTabWidget(this);
   311     tabWidget = new QTabWidget(this);
   193     tabWidget->setContextMenuPolicy(Qt::NoContextMenu);
   312     tabWidget->setContextMenuPolicy(Qt::NoContextMenu);
   194     tabCase = new QWidget(tabWidget);
   313     tabCase = new QWidget(tabWidget);
   195     tabCase->setContextMenuPolicy(Qt::NoContextMenu);
   314     tabCase->setContextMenuPolicy(Qt::NoContextMenu);
   205     tabWidget->addTab(tabStatistic, tr("Statistics"));
   324     tabWidget->addTab(tabStatistic, tr("Statistics"));
   206     connect(tabWidget, SIGNAL(currentChanged(int)), this,
   325     connect(tabWidget, SIGNAL(currentChanged(int)), this,
   207             SLOT(onTabWidgetSelectIndexChanged()));
   326             SLOT(onTabWidgetSelectIndexChanged()));
   208 
   327 
   209     //output panel
   328     //output panel
   210     QGroupBox *groupBox = new QGroupBox(this);
   329     groupBox = new QGroupBox(this);
   211     groupBox->setFixedHeight(150);
   330     //groupBox->setFixedHeight(150);
   212     groupBox->setContextMenuPolicy(Qt::NoContextMenu);
   331     groupBox->setContextMenuPolicy(Qt::NoContextMenu);
   213     groupBox->setTitle(tr("Information"));
   332     groupBox->setTitle(tr("Information"));
   214     QFont serifFont("Times", 5, QFont::Normal);
       
   215     txtOutput = new QPlainTextEdit(groupBox);
   333     txtOutput = new QPlainTextEdit(groupBox);
   216     txtOutput->setFont(serifFont);
       
   217     txtOutput->setContextMenuPolicy(Qt::NoContextMenu);
   334     txtOutput->setContextMenuPolicy(Qt::NoContextMenu);
   218     txtOutput->setReadOnly(true);
   335     txtOutput->setReadOnly(true);
   219     txtOutput->setFocusPolicy(Qt::NoFocus);
   336     txtOutput->setFocusPolicy(Qt::NoFocus);
   220     //txtOutput->setEditFocus(false);
   337     //txtOutput->setEditFocus(false);
   221     QGridLayout *groupBoxLayout = new QGridLayout(this);
   338     QGridLayout *groupBoxLayout = new QGridLayout(this);
   224     groupBoxLayout->setSpacing(2);
   341     groupBoxLayout->setSpacing(2);
   225     groupBoxLayout->setMargin(2);   
   342     groupBoxLayout->setMargin(2);   
   226     groupBoxLayout->addWidget(txtOutput, 0, 0);
   343     groupBoxLayout->addWidget(txtOutput, 0, 0);
   227     groupBox->setLayout(groupBoxLayout);
   344     groupBox->setLayout(groupBoxLayout);
   228 
   345 
       
   346     QDesktopWidget* desktop = QApplication::desktop();
       
   347     QRect rect = desktop->screenGeometry(0);
       
   348     if(rect.height() > rect.width())
       
   349         {
       
   350         mainLayout->addWidget(tabWidget, 0, 0);
       
   351         mainLayout->addWidget(groupBox, 1, 0, Qt::AlignBottom);
       
   352         mainLayout->setRowStretch(0,4);
       
   353         mainLayout->setRowStretch(1,1); 
       
   354         layoutType = true;
       
   355         }
       
   356     else
       
   357         {
       
   358         mainLayout->addWidget(tabWidget, 0, 0);
       
   359         mainLayout->addWidget(groupBox, 0, 1);//Qt::AlignRight
       
   360         //groupBox->setFixedSize(60,0);
       
   361         mainLayout->setColumnStretch(0,1);
       
   362         mainLayout->setColumnStretch(1,1);    
       
   363         layoutType = false;
       
   364         }
       
   365     
   229     //Create MainLayout and MainWidget
   366     //Create MainLayout and MainWidget
       
   367     this->centralWidget()->setLayout(mainLayout);
   230     mainLayout->addWidget(tabWidget, 0, 0);
   368     mainLayout->addWidget(tabWidget, 0, 0);
   231     mainLayout->addWidget(groupBox, 1, 0, Qt::AlignBottom);
   369     mainLayout->addWidget(groupBox, 1, 0, Qt::AlignBottom);
   232     MainWidget->setLayout(mainLayout);
   370     mainLayout->setRowStretch(0,4);
       
   371     mainLayout->setRowStretch(1,1);
   233     
   372     
   234 
   373 
   235     //Tab page: Case
   374     //Tab page: Case
   236     QGridLayout *tabCaseLayout = new QGridLayout(this);
   375     QGridLayout *tabCaseLayout = new QGridLayout(this);
   237     tabCaseLayout->setVerticalSpacing(2);
   376     tabCaseLayout->setVerticalSpacing(2);
   247             SLOT(on_treeModuleList_itemClicked(QTreeWidgetItem* , int)));
   386             SLOT(on_treeModuleList_itemClicked(QTreeWidgetItem* , int)));
   248     
   387     
   249 
   388 
   250     QWidget *caseToolWidget = new QWidget(tabCase);
   389     QWidget *caseToolWidget = new QWidget(tabCase);
   251     caseToolWidget->setContextMenuPolicy(Qt::NoContextMenu);
   390     caseToolWidget->setContextMenuPolicy(Qt::NoContextMenu);
   252     QGridLayout *caseToolWidgetLayout = new QGridLayout;
   391     QGridLayout *caseToolWidgetLayout = new QGridLayout(this);
   253     QPushButton *btnRunCase = new QPushButton(tr("Run"), caseToolWidget);
   392     QPushButton *btnRunCase = new QPushButton(tr("Run"), caseToolWidget);
   254     btnRunCase->setContextMenuPolicy(Qt::NoContextMenu);
   393     btnRunCase->setContextMenuPolicy(Qt::NoContextMenu);
   255     btnRunCase->setFixedSize(btnSize);
       
   256     connect(btnRunCase, SIGNAL(clicked()), this,
   394     connect(btnRunCase, SIGNAL(clicked()), this,
   257             SLOT(on_actRunCaseSeq_triggered()));
   395             SLOT(on_actRunCaseSeq_triggered()));
   258     QPushButton *btnExpandAll = new QPushButton(tr("Expand"), caseToolWidget);
   396     QPushButton *btnExpandAll = new QPushButton(tr("Expand"), caseToolWidget);
   259     btnExpandAll->setContextMenuPolicy(Qt::NoContextMenu);
   397     btnExpandAll->setContextMenuPolicy(Qt::NoContextMenu);
   260     btnExpandAll->setFixedSize(btnSize);
       
   261     connect(btnExpandAll, SIGNAL(clicked()), this,
   398     connect(btnExpandAll, SIGNAL(clicked()), this,
   262             SLOT(on_actExpandAll_triggered()));
   399             SLOT(on_actExpand_triggered()));
   263     QPushButton *btnCollapseAll = new QPushButton(tr("Collapse"),
   400     QPushButton *btnCollapseAll = new QPushButton(tr("Collapse"),
   264             caseToolWidget);
   401             caseToolWidget);
   265     btnCollapseAll->setContextMenuPolicy(Qt::NoContextMenu);
   402     btnCollapseAll->setContextMenuPolicy(Qt::NoContextMenu);
   266     btnCollapseAll->setFixedSize(btnSize);
       
   267     connect(btnCollapseAll, SIGNAL(clicked()), this,
   403     connect(btnCollapseAll, SIGNAL(clicked()), this,
   268             SLOT(on_actCollapseAll_triggered()));
   404             SLOT(on_actCollapse_triggered()));
   269 
   405 
   270     caseToolWidgetLayout->addWidget(btnRunCase, 0, 0);
   406     caseToolWidgetLayout->addWidget(btnRunCase, 0, 0);
   271     caseToolWidgetLayout->addWidget(btnExpandAll, 0, 1);
   407     caseToolWidgetLayout->addWidget(btnExpandAll, 0, 1);
   272     caseToolWidgetLayout->addWidget(btnCollapseAll, 0, 2);
   408     caseToolWidgetLayout->addWidget(btnCollapseAll, 0, 2);
   273     caseToolWidget->setLayout(caseToolWidgetLayout);
   409     caseToolWidget->setLayout(caseToolWidgetLayout);
   316     setToolWidgetLayout->setHorizontalSpacing(2);
   452     setToolWidgetLayout->setHorizontalSpacing(2);
   317     setToolWidgetLayout->setSpacing(2);
   453     setToolWidgetLayout->setSpacing(2);
   318     setToolWidgetLayout->setMargin(2);     
   454     setToolWidgetLayout->setMargin(2);     
   319     QPushButton *btnRunSetCase = new QPushButton(tr("Run"), setToolWidget);
   455     QPushButton *btnRunSetCase = new QPushButton(tr("Run"), setToolWidget);
   320     btnRunSetCase->setContextMenuPolicy(Qt::NoContextMenu);
   456     btnRunSetCase->setContextMenuPolicy(Qt::NoContextMenu);
   321     btnRunSetCase->setFixedSize(btnSize);
       
   322     connect(btnRunSetCase, SIGNAL(clicked()), this,
   457     connect(btnRunSetCase, SIGNAL(clicked()), this,
   323             SLOT(on_actRunSetSeq_triggered()));
   458             SLOT(on_actRunSetSeq_triggered()));
   324     QPushButton *btnNewSet = new QPushButton(tr("New Set"), setToolWidget);
   459     QPushButton *btnNewSet = new QPushButton(tr("New Set"), setToolWidget);
   325     btnNewSet->setContextMenuPolicy(Qt::NoContextMenu);
   460     btnNewSet->setContextMenuPolicy(Qt::NoContextMenu);
   326     btnNewSet->setFixedSize(btnSize);
       
   327     connect(btnNewSet, SIGNAL(clicked()), this,
   461     connect(btnNewSet, SIGNAL(clicked()), this,
   328             SLOT(on_actNewSet_triggered()));
   462             SLOT(on_actNewSet_triggered()));
   329     QPushButton *btnDelSet = new QPushButton(tr("Delete Set"), setToolWidget);
   463     QPushButton *btnDelSet = new QPushButton(tr("Delete Set"), setToolWidget);
   330     btnDelSet->setContextMenuPolicy(Qt::NoContextMenu);
   464     btnDelSet->setContextMenuPolicy(Qt::NoContextMenu);
   331     btnDelSet->setFixedSize(btnSize);
       
   332     connect(btnDelSet, SIGNAL(clicked()), this,
   465     connect(btnDelSet, SIGNAL(clicked()), this,
   333             SLOT(on_actDelSet_triggered()));
   466             SLOT(on_actDelSet_triggered()));
   334 
   467 
   335     setToolWidgetLayout->addWidget(btnRunSetCase, 0, 0);
   468     setToolWidgetLayout->addWidget(btnRunSetCase, 0, 0);
   336     setToolWidgetLayout->addWidget(btnNewSet, 0, 1);
   469     setToolWidgetLayout->addWidget(btnNewSet, 0, 1);
   356     startedToolWidgetLayout->setHorizontalSpacing(2);
   489     startedToolWidgetLayout->setHorizontalSpacing(2);
   357     startedToolWidgetLayout->setSpacing(2);
   490     startedToolWidgetLayout->setSpacing(2);
   358     startedToolWidgetLayout->setMargin(2);
   491     startedToolWidgetLayout->setMargin(2);
   359     btnPauseCase = new QPushButton(tr("Pause"), startedToolWidget);
   492     btnPauseCase = new QPushButton(tr("Pause"), startedToolWidget);
   360     btnPauseCase->setContextMenuPolicy(Qt::NoContextMenu);
   493     btnPauseCase->setContextMenuPolicy(Qt::NoContextMenu);
   361     btnPauseCase->setFixedSize(btnSize);
       
   362     connect(btnPauseCase, SIGNAL(clicked()), this,
   494     connect(btnPauseCase, SIGNAL(clicked()), this,
   363             SLOT(on_actPause_triggered()));
   495             SLOT(on_actPause_triggered()));
   364     btnPauseCase->setEnabled(false);
   496     btnPauseCase->setEnabled(false);
   365 
   497 
   366     btnAbortCase = new QPushButton(tr("Abort"), startedToolWidget);
   498     btnAbortCase = new QPushButton(tr("Abort"), startedToolWidget);
   367     btnAbortCase->setContextMenuPolicy(Qt::NoContextMenu);
   499     btnAbortCase->setContextMenuPolicy(Qt::NoContextMenu);
   368     btnAbortCase->setFixedSize(btnSize);
       
   369     connect(btnAbortCase, SIGNAL(clicked()), this,
   500     connect(btnAbortCase, SIGNAL(clicked()), this,
   370             SLOT(on_actAbort_triggered()));
   501             SLOT(on_actAbort_triggered()));
   371     btnAbortCase->setEnabled(false);
   502     btnAbortCase->setEnabled(false);
   372     //    
   503         
   373     //    QPushButton *btnShowOutput = new QPushButton(tr("Output"), startedToolWidget);
   504     btnShowOutput = new QPushButton(tr("Output"), startedToolWidget);
   374     //    connect(btnShowOutput, SIGNAL(clicked()), this,
   505     connect(btnShowOutput, SIGNAL(clicked()), this,
   375     //                SLOT(on_btnShowOutput_clicked()));
   506                 SLOT(on_actOutput_triggered()));
       
   507     btnShowOutput->setEnabled(false);
   376 
   508 
   377 
   509 
   378     startedToolWidgetLayout->addWidget(btnPauseCase, 0, 0);
   510     startedToolWidgetLayout->addWidget(btnPauseCase, 0, 0);
   379     startedToolWidgetLayout->addWidget(btnAbortCase, 0, 1);
   511     startedToolWidgetLayout->addWidget(btnAbortCase, 0, 1);
   380     //startedToolWidgetLayout->addWidget(btnShowOutput, 0, 2);
   512     startedToolWidgetLayout->addWidget(btnShowOutput, 0, 2);
   381     startedToolWidget->setLayout(startedToolWidgetLayout);
   513     startedToolWidget->setLayout(startedToolWidgetLayout);
   382 
   514 
   383     tabStartedLayout->addWidget(lstStartedCases, 0, 0);
   515     tabStartedLayout->addWidget(lstStartedCases, 0, 0);
   384     tabStartedLayout->addWidget(startedToolWidget, 1, 0);
   516     tabStartedLayout->addWidget(startedToolWidget, 1, 0);
   385     tabStarted->setLayout(tabStartedLayout);
   517     tabStarted->setLayout(tabStartedLayout);
   406     crashedItems = new QTreeWidgetItem(treeStatistic);
   538     crashedItems = new QTreeWidgetItem(treeStatistic);
   407     crashedItems->setText(0, tr("Crashed Cases(0)"));
   539     crashedItems->setText(0, tr("Crashed Cases(0)"));
   408     abortedItems = new QTreeWidgetItem(treeStatistic);
   540     abortedItems = new QTreeWidgetItem(treeStatistic);
   409     abortedItems->setText(0, tr("Aborted Cases(0)"));
   541     abortedItems->setText(0, tr("Aborted Cases(0)"));
   410     
   542     
   411     
   543     //this->repaint();
   412     setCentralWidget(MainWidget);
   544 
   413 
   545 
   414     }
   546     }
   415 
   547 
   416 void frmMain::LoadSubMenu()
   548 
       
   549 
       
   550 void FrmMain::LoadSubMenu()
   417     {
   551     {
   418     menuBar()->clear();
   552     menuBar()->clear();
   419     menuBar()->setContextMenuPolicy(Qt::NoContextMenu);
   553     menuBar()->setContextMenuPolicy(Qt::NoContextMenu);
   420     if (tabWidget->currentIndex() == 0)
   554     if (tabWidget->currentIndex() == 0)
   421         {
   555         {
   422         //Cases Tab
   556         //Cases Tab
   423         menuBar()->addAction(actOpenFile);
   557         menuBar()->addAction(actOpenFile);
   424         menuBar()->addAction(actRunCaseSeq);
   558         menuBar()->addMenu(menuRunCase);
   425         menuBar()->addAction(actRunCasePar);
   559         menuRunCase->addAction(actRunCaseSeq);
       
   560         menuRunCase->addAction(actRunCasePar);
       
   561         menuBar()->addAction(actReapeatRunSeq);
   426         menuBar()->addSeparator();
   562         menuBar()->addSeparator();
   427         menuBar()->addAction(actAddtoSet);
   563         menuBar()->addAction(actAddtoSet);
   428         menuBar()->addSeparator();
   564         menuBar()->addSeparator();
   429         menuBar()->addAction(actSelectAll);
   565         menuBar()->addAction(actSelectAll);
   430         menuBar()->addAction(actExpandAll);
   566         menuBar()->addAction(actExpandAll);
   431         menuBar()->addAction(actCollapseAll);
   567         menuBar()->addAction(actCollapseAll);
   432         }
   568         }
   433     else if (tabWidget->currentIndex() == 1)
   569     else if (tabWidget->currentIndex() == 1)
   434         {
   570         {
   435         //Set Tab
   571         //Set Tab
   436         menuBar()->addAction(actRunSetSeq);
   572         menuBar()->addMenu(menuRunSet);
   437         menuBar()->addAction(actRunSetPar);
   573         menuRunSet->addAction(actRunSetSeq);
       
   574         menuRunSet->addAction(actRunSetPar);
   438         menuBar()->addSeparator();
   575         menuBar()->addSeparator();
   439         menuBar()->addAction(actNewSet);
   576         menuBar()->addAction(actNewSet);
   440         menuBar()->addAction(actDelSet);
   577         menuBar()->addAction(actDelSet);
   441         }
   578         }
   442     else if (tabWidget->currentIndex() == 2)
   579     else if (tabWidget->currentIndex() == 2)
   443         {
   580         {
   444         //Started Tab
   581         //Started Tab
   445         menuBar()->addAction(actPause);
   582         menuBar()->addAction(actPause);
   446         menuBar()->addAction(actAbort);
   583         menuBar()->addAction(actAbort);
       
   584         menuBar()->addAction(actOutput);
   447         
   585         
   448         }
   586         }
   449     else
   587     else
   450         {
   588         {
   451         //Staticstic tab
   589         //Staticstic tab
   456     menuBar()->addAction(actAbout);
   594     menuBar()->addAction(actAbout);
   457     menuBar()->addAction(actExit);
   595     menuBar()->addAction(actExit);
   458 
   596 
   459     }
   597     }
   460 
   598 
   461 void frmMain::onTabWidgetSelectIndexChanged()
   599 void FrmMain::onTabWidgetSelectIndexChanged()
   462     {
   600     {
   463     LoadSubMenu();
   601     LoadSubMenu();
   464     }
   602     }
   465 
   603 
   466 void frmMain::loadContent()
   604 void FrmMain::loadContent()
   467     {
   605     {
   468     //Load ModuleList
   606     //Load ModuleList
   469     loadModuleList();
   607     loadModuleList();
   470     //Load SetList
   608     //Load SetList
   471     loadSetList();
   609     loadSetList();
   472     //Load Statistic List
   610     //Load Statistic List
   473     loadStatistic();
   611     loadStatistic();
   474     }
   612     }
   475 
   613 
   476 void frmMain::loadModuleList()
   614 void FrmMain::loadModuleList()
   477     {
   615     {
   478     treeModuleList->clear();
   616     treeModuleList->clear();
   479     
   617     
   480     QList<QString> moduleList = controller->GetModuleList();
   618     QList<QString> moduleList = controller->GetModuleList();
   481     foreach(QString moduleName, moduleList)
   619     foreach(QString moduleName, moduleList)
   496         {
   634         {
   497         treeModuleList->setCurrentItem(treeModuleList->topLevelItem(0));
   635         treeModuleList->setCurrentItem(treeModuleList->topLevelItem(0));
   498         }
   636         }
   499     }
   637     }
   500 
   638 
   501 void frmMain::reloadStatisticItem(QString name, QTreeWidgetItem* item,
   639 void FrmMain::reloadStatisticItem(QString name, QTreeWidgetItem* item,
   502         TSTFCaseStatusType type)
   640         TSTFCaseStatusType type)
   503     {
   641     {
   504     QList<CSTFCase> caseList = controller->GetCasesByStatus(type);
   642     QList<CSTFCase> caseList = controller->GetCasesByStatus(type);
   505     while (item->childCount() != 0)
   643     while (item->childCount() != 0)
   506         {
   644         {
   512             QTreeWidgetItem* child = new QTreeWidgetItem(item);
   650             QTreeWidgetItem* child = new QTreeWidgetItem(item);
   513             child->setText(0, aCase.Name());
   651             child->setText(0, aCase.Name());
   514             }
   652             }
   515     }
   653     }
   516 
   654 
   517 void frmMain::loadStatistic()
   655 void FrmMain::loadStatistic()
   518     {
   656     {
   519     //executedItems;
   657     //executedItems;
   520     reloadStatisticItem("Executed Cases", executedItems, EStatusExecuted);
   658     reloadStatisticItem("Executed Cases", executedItems, EStatusExecuted);
   521 
   659 
   522     //passedItems;
   660     //passedItems;
   531     //abortedItems;
   669     //abortedItems;
   532     reloadStatisticItem("Aborted Cases", abortedItems, EStatusAborted);
   670     reloadStatisticItem("Aborted Cases", abortedItems, EStatusAborted);
   533 
   671 
   534     }
   672     }
   535 
   673 
   536 void frmMain::loadSetList()
   674 void FrmMain::loadSetList()
   537     {
   675     {
   538     cboSetList->clear();
   676     cboSetList->clear();
   539 
   677 
   540     QList<QString> setList = controller->GetSetList();
   678     QList<QString> setList = controller->GetSetList();
   541     foreach(QString setName, setList)
   679     foreach(QString setName, setList)
   547 //        //cboSetList->setCurrentIndex(0);
   685 //        //cboSetList->setCurrentIndex(0);
   548 //        on_cboSetList_currentIndexChanged(setList.at(0));
   686 //        on_cboSetList_currentIndexChanged(setList.at(0));
   549 //        }
   687 //        }
   550     }
   688     }
   551 
   689 
   552 QList<CSTFCase> frmMain::getSelectedCases()
   690 QList<CSTFCase> FrmMain::getSelectedCases()
   553     {
   691     {
   554     int index = 0;
   692     int index = 0;
   555     QTreeWidgetItem* item = treeModuleList->topLevelItem(index);
   693     QTreeWidgetItem* item = treeModuleList->topLevelItem(index);
   556     QList<CSTFCase> caseList;
   694     QList<CSTFCase> caseList;
   557     while (item != 0)
   695     while (item != 0)
   572         item = treeModuleList->topLevelItem(index);
   710         item = treeModuleList->topLevelItem(index);
   573         }
   711         }
   574     return caseList;
   712     return caseList;
   575     }
   713     }
   576 
   714 
   577 void frmMain::on_cboSetList_currentIndexChanged(QString item)
   715 void FrmMain::on_cboSetList_currentIndexChanged(QString item)
   578     {
   716     {
   579     lstSetCases->clear();
   717     lstSetCases->clear();
   580     QList<QString> list = controller->GetCaseListBySet(item);
   718     QList<QString> list = controller->GetCaseListBySet(item);
   581     foreach(QString caseName, list)
   719     foreach(QString caseName, list)
   582             {
   720             {
   583             lstSetCases->addItem(caseName);
   721             lstSetCases->addItem(caseName);
   584             }
   722             }
   585     }
   723     }
   586 
   724 
   587 void frmMain::on_actRunCaseSeq_triggered()
   725 void FrmMain::startRunning()
       
   726     {
       
   727     setSetting();
       
   728     tabWidget->setCurrentWidget(tabStarted);    
       
   729     }
       
   730 
       
   731 void FrmMain::on_actRunCaseSeq_triggered()
   588     {
   732     {
   589     //run case seq
   733     //run case seq
       
   734     startRunning();
   590     controller->RunCases(getSelectedCases(), Sequentially);
   735     controller->RunCases(getSelectedCases(), Sequentially);
   591     }
   736     }
   592 
   737 
   593 void frmMain::on_actRunCasePar_triggered()
   738 void FrmMain::on_actRunCasePar_triggered()
   594     {
   739     {
       
   740     startRunning();
   595     controller->RunCases(getSelectedCases(), Parallel);
   741     controller->RunCases(getSelectedCases(), Parallel);
   596     }
   742     }
   597 
   743 
   598 void frmMain::on_actAddtoSet_triggered()
   744 void FrmMain::on_actReapeatRunSeq_triggered()
   599     {
   745     {
   600 
   746     DlgRepeatRun dlgRepeatRun(this);
       
   747     int result = dlgRepeatRun.exec();
       
   748     if(result == QDialog::Accepted)
       
   749         {
       
   750         QList<CSTFCase> selectedCases = getSelectedCases();
       
   751         if(selectedCases.count() > 0)
       
   752             {
       
   753             startRunning();
       
   754             controller->RepeatRunCases( selectedCases, 
       
   755                                         dlgRepeatRun.isRepeatInfinitely(),
       
   756                                         dlgRepeatRun.GetLoopTimes() );
       
   757             }
       
   758         
       
   759         }
       
   760     }
       
   761 
       
   762 void FrmMain::on_actAddtoSet_triggered()
       
   763     {
   601     QList<CSTFCase> list = getSelectedCases();
   764     QList<CSTFCase> list = getSelectedCases();
   602     if (list.size() == 0)
   765     if (list.size() == 0)
   603         {
   766         {
   604         QErrorMessage *errorMessageDialog = new QErrorMessage(this);
   767         QErrorMessage *errorMessageDialog = new QErrorMessage(this);
       
   768         errorMessageDialog->setAutoFillBackground(true);
   605         errorMessageDialog->showMessage(tr(
   769         errorMessageDialog->showMessage(tr(
   606                 "Please select cases you want to added to set."));
   770                 "<font color =black>Please select cases you want to added to set.</font>"));
   607         return;
   771         return;
   608         }
   772         }
   609 
   773 
   610     QList<QString> setList = controller->GetSetList();
   774     QList<QString> setList = controller->GetSetList();
   611 
   775 
   612     /*    
   776     DlgSetSelector dlgSet(setList, this);
   613      bool ok;
   777     int result = dlgSet.exec();
   614      QString setName = QInputDialog::getItem(this, tr(
   778     QString setName;
   615      "Add select cases to Set"), tr("Sets:"), setList, 0, false, &ok);
   779     if(result == QDialog::Accepted)
   616      if (ok && !setName.isEmpty())
   780         {
   617      {
   781         setName = dlgSet.SelectName();
   618      controller->AddCaseToSet(list, setName);
   782         }
   619      }
   783     else
   620      */
   784         {
   621 
   785         return;
   622     //temp code, because UIStore()->AddCaseToSet() is not support to define a set name.
   786         }
   623     controller->AddCaseToSet(list, "");
   787     bool rst = false;
       
   788     if(setName == "")
       
   789         {
       
   790         setName = "temp.set";
       
   791         rst = controller->CreateSet(setName);
       
   792         if(!rst)
       
   793             {
       
   794             return;
       
   795             }
       
   796         }
       
   797     controller->AddCaseToSet(list, setName);
       
   798 //
       
   799 //     bool ok;
       
   800 //     QString setName = QInputDialog::getItem(this, tr(
       
   801 //     "\r\nAdd select cases to Set"), tr("\r\n\r\nSets:"), setList, 0, false, &ok, Qt::Dialog);
       
   802 //     if (ok && !setName.isEmpty())
       
   803 //     {
       
   804 //     if(setName == newSet)
       
   805 //         {
       
   806 //         ok = controller->CreateSet(setName);
       
   807 //         if(!ok)
       
   808 //             {
       
   809 //             return;
       
   810 //             }
       
   811 //         }
       
   812 //     controller->AddCaseToSet(list, setName);
       
   813 //     }
   624     tabWidget->setCurrentIndex(1);
   814     tabWidget->setCurrentIndex(1);
   625 
   815     int index = -1;
   626     }
   816     for(int i=0;i<cboSetList->count();i++)
   627 
   817         {
   628 void frmMain::on_actSelectAll_triggered()
   818         if(cboSetList->itemText(i) == setName)
       
   819             {
       
   820             index = i;
       
   821             break;
       
   822             }
       
   823         }
       
   824     if(index != -1)
       
   825         {
       
   826         cboSetList->setCurrentIndex(index);
       
   827         }
       
   828 
       
   829     
       
   830     }
       
   831 
       
   832 void FrmMain::on_actSelectAll_triggered()
   629     {
   833     {
   630     QString header = UNSELECTITEMHEADER;
   834     QString header = UNSELECTITEMHEADER;
   631     if(actSelectAll->text() == "Select All")
   835     if(actSelectAll->text() == "Select All")
   632         {
   836         {
   633         actSelectAll->setText("UnSelect All");
   837         actSelectAll->setText("UnSelect All");
   640     
   844     
   641     int index = 0;
   845     int index = 0;
   642     QTreeWidgetItem* item = treeModuleList->topLevelItem(index);
   846     QTreeWidgetItem* item = treeModuleList->topLevelItem(index);
   643     while (item != 0)
   847     while (item != 0)
   644         {
   848         {
   645         item->setText(0, item->text(0).replace(0,3, header));
   849         if(!item->isHidden())
       
   850             item->setText(0, item->text(0).replace(0,3, header));
   646         for (int i = 0; i < item->childCount(); i++)
   851         for (int i = 0; i < item->childCount(); i++)
   647             {
   852             {
   648             QTreeWidgetItem* child = item->child(i);
   853             QTreeWidgetItem* child = item->child(i);
   649             child->setText(0,child->text(0).replace(0,3,header));
   854             if(!child->isHidden())
       
   855                 child->setText(0,child->text(0).replace(0,3,header));
   650             }
   856             }
   651         index++;
   857         index++;
   652         item = treeModuleList->topLevelItem(index);
   858         item = treeModuleList->topLevelItem(index);
   653         }
   859         }
   654     }
   860     }
   655 
   861 
   656 void frmMain::on_actExpandAll_triggered()
   862 void FrmMain::on_actExpandAll_triggered()
   657     {
   863     {
       
   864     QTreeWidgetItem* item = treeModuleList->currentItem();
   658     treeModuleList->expandAll();
   865     treeModuleList->expandAll();
   659     }
   866     if(item != NULL)
   660 
   867         {
   661 void frmMain::on_actCollapseAll_triggered()
   868         treeModuleList->setCurrentItem(item);
   662     {
   869         }
       
   870         
       
   871     }
       
   872 
       
   873 void FrmMain::on_actCollapseAll_triggered()
       
   874     {
       
   875     QTreeWidgetItem* item = treeModuleList->currentItem();
       
   876     if(item != NULL)
       
   877         {
       
   878         if(item->parent() != NULL)
       
   879             {
       
   880             item = item->parent();
       
   881             }
       
   882         }
   663     treeModuleList->collapseAll();
   883     treeModuleList->collapseAll();
   664     }
   884     if(item != NULL)
   665 
   885         {
   666 void frmMain::on_actSetting_triggered()
   886         treeModuleList->setCurrentItem(item);
       
   887         }
       
   888     
       
   889     }
       
   890 
       
   891 void FrmMain::on_actSetting_triggered()
   667     {
   892     {
   668     DlgSetting dlgSet(uiSetting);
   893     DlgSetting dlgSet(uiSetting);
       
   894     currentFilter = uiSetting->ReadSetting(KFilter);
       
   895     currentFilterCaseSens = uiSetting->ReadSetting(KFilterCaseSens);
   669     int result = dlgSet.exec();
   896     int result = dlgSet.exec();
   670     if(result == QDialog::Accepted)
   897     if(result == QDialog::Accepted)
   671         {
   898         {
   672         setSetting();
   899         setSetting();
   673         }
   900         }
   674     }
   901     }
   675 
   902 
   676 void frmMain::on_actRunSetSeq_triggered()
   903 void FrmMain::on_actRunSetSeq_triggered()
   677     {
   904     {
       
   905     startRunning();
   678     QString setName = cboSetList->currentText();
   906     QString setName = cboSetList->currentText();
   679     controller->RunSets(setName, Sequentially);
   907     controller->RunSets(setName, Sequentially);
   680     }
   908     }
   681 
   909 
   682 void frmMain::on_actRunSetPar_triggered()
   910 void FrmMain::on_actRunSetPar_triggered()
   683     {
   911     {
       
   912     startRunning();
   684     QString setName = cboSetList->currentText();
   913     QString setName = cboSetList->currentText();
   685     controller->RunSets(setName, Parallel);
   914     controller->RunSets(setName, Parallel);
   686     }
   915     }
   687 
   916 
   688 void frmMain::on_actNewSet_triggered()
   917 void FrmMain::on_actNewSet_triggered()
   689     {
   918     {
   690     //not supported.
   919     QString name;
   691     QErrorMessage *errorMessageDialog = new QErrorMessage(this);
   920     bool rst = controller->CreateSet(name);
   692     errorMessageDialog->showMessage(
   921     if(rst)
   693             tr(
   922         {
   694                     "The feature is not supported in this version.\r\n    \
   923         QMessageBox::information(this, 
   695             If you want to Add test set.\r\n           \
   924                 tr("Create Set Successfully"), 
   696             Please switch to \"Case\" tab, Select case(s) and perform \"Add case to set\"."));
   925                 "Create a new test set, named: " + name);
   697     return;
   926 
   698     /*
   927         int index = -1;
   699      * These function is not supported in this version.
   928         for(int i=0;i<cboSetList->count();i++)
   700      * Unless this function has been impelemented:
   929             {
   701      * UIStore()->AddSet(setName);
   930             if(cboSetList->itemText(i) == name)
   702      * 
   931                 {
   703      bool ok;
   932                 index = i;
   704      QString text = QInputDialog::getText(this, tr("Create a new Set"), tr(
   933                 break;
   705      "Input a set name:"), QLineEdit::Normal, QDir::home().dirName(),
   934                 }
   706      &ok);
   935             }
   707      if (ok && !text.isEmpty())
   936         if(index != -1)
   708      {
   937             {
   709      controller->CreateSet(text);
   938             cboSetList->setCurrentIndex(index);
   710      }
   939             }
   711      */
   940 
   712     }
   941         
   713 
   942         }
   714 void frmMain::on_actDelSet_triggered()
   943     else
   715     {
   944         {
   716     //not supported.
   945         QMessageBox::information(this, 
   717     QErrorMessage *errorMessageDialog = new QErrorMessage(this);
   946                 tr("Create Set Failed"), 
   718     errorMessageDialog->showMessage(
   947                 tr("Please check the log for more information."));
   719             tr(
   948     
   720                     "The feature is not supported in this version.\r\n    \
   949         }
   721             If you want to remove test set.\r\n           \
   950     
   722             Please delete them under {epoc root}\\winscw\\c\\TestFramework  \
   951     }
   723             And restart Application"));
   952 
   724     return;
   953 void FrmMain::on_actDelSet_triggered()
   725     /*
   954     {
   726      * These function is not supported in this version.
   955         QString setName = cboSetList->currentText();
   727      * Unless this function has been impelemented:
   956         QMessageBox msgBox(QMessageBox::Warning, tr("Delete a Set"), tr(
   728      * UIStore()->RemoveSet(setName);
   957         "Do you really want to delete the set?"), 0, this);
   729      * 
   958         msgBox.addButton(tr("&Delete"), QMessageBox::AcceptRole);
   730      QString setName = cboSetList->currentText();
   959         msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
   731      QMessageBox msgBox(QMessageBox::Warning, tr("Delete a Set"), tr(
   960         if (msgBox.exec() == QMessageBox::AcceptRole)
   732      "Do you really want to delete the set?"), 0, this);
   961         {
   733      msgBox.addButton(tr("&Delete"), QMessageBox::AcceptRole);
   962         controller->DeleteSet(setName);
   734      msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
   963         }
   735      if (msgBox.exec() == QMessageBox::AcceptRole)
   964 
   736      {
   965     }
   737      controller->DeleteSet(setName);
   966 
   738      }
   967 void FrmMain::on_actPause_triggered()
   739      
       
   740      
       
   741      */
       
   742     }
       
   743 
       
   744 void frmMain::on_actPause_triggered()
       
   745     {
   968     {
   746     if (btnPauseCase->text() == "Pause")
   969     if (btnPauseCase->text() == "Pause")
   747         {
   970         {
   748         controller->PauseCase();
   971         controller->PauseCase();
   749         btnPauseCase->setText(tr("Resume"));
   972         btnPauseCase->setText(tr("Resume"));
   755         btnPauseCase->setText(tr("Pause"));
   978         btnPauseCase->setText(tr("Pause"));
   756         actPause->setText(tr("Pause"));
   979         actPause->setText(tr("Pause"));
   757         }
   980         }
   758     }
   981     }
   759 
   982 
   760 void frmMain::on_actAbort_triggered()
   983 void FrmMain::on_actAbort_triggered()
   761     {
   984     {
   762     controller->AbortCase();
   985     controller->AbortCase();
   763     }
   986     }
   764 
   987 
   765 void frmMain::on_treeModuleList_itemClicked(QTreeWidgetItem* item, int /*column*/)
   988 void FrmMain::on_treeModuleList_itemClicked(QTreeWidgetItem* item, int /*column*/)
       
   989     {
       
   990     //Check if shift key is pressed
       
   991     bool isShiftPressed = false;
       
   992     Qt::KeyboardModifiers keyMod = QApplication::keyboardModifiers();
       
   993     isShiftPressed=keyMod.testFlag(Qt::ShiftModifier);
       
   994     
       
   995     //Handle shift key.
       
   996     //Shift not pressed.
       
   997     if(!isShiftPressed)
       
   998         {
       
   999         setItemClicked(item);
       
  1000         }
       
  1001     //Shift pressed.
       
  1002     else
       
  1003         {
       
  1004         enum Direction
       
  1005             {
       
  1006             Item_NoDirection,
       
  1007             Item_Above,
       
  1008             Item_Below
       
  1009             };
       
  1010         Direction direction = Item_NoDirection;
       
  1011         QTreeWidgetItem* tempItem = item;
       
  1012         //check direction of last selected item comparing current one.
       
  1013         while(tempItem)
       
  1014             {
       
  1015             tempItem = treeModuleList->itemAbove(tempItem);
       
  1016             if(tempItem == lastItemSelected)
       
  1017                 {
       
  1018                 direction = Item_Above;
       
  1019                 break;
       
  1020                 }
       
  1021             }
       
  1022         if (direction != Item_Above)
       
  1023             {
       
  1024             tempItem = item;
       
  1025             while(tempItem)
       
  1026                 {
       
  1027                 tempItem = treeModuleList->itemBelow(tempItem);
       
  1028                 if(tempItem == lastItemSelected)
       
  1029                     {
       
  1030                     direction = Item_Below;
       
  1031                     break;
       
  1032                     }
       
  1033                 }
       
  1034             }
       
  1035         
       
  1036         // Select all items between current item and last selected item.
       
  1037         tempItem = item;
       
  1038         if(direction != Item_NoDirection)
       
  1039             {
       
  1040             while(tempItem)
       
  1041                 {
       
  1042                 //check if this item been selected.
       
  1043                 bool isItemSelected = false;
       
  1044                 if ( tempItem->text(0).left(3).compare(SELECTITEMHEADER)==0 )
       
  1045                     {
       
  1046                     isItemSelected = true;
       
  1047                     }
       
  1048                 // If not selected, set to selected.
       
  1049                 if (!isItemSelected )
       
  1050                     {
       
  1051                     setItemClicked(tempItem);
       
  1052                     }
       
  1053                 
       
  1054                 //Go above/below
       
  1055                 if (direction == Item_Above)
       
  1056                     {
       
  1057                     tempItem = treeModuleList->itemAbove(tempItem);             
       
  1058                     }
       
  1059                 if (direction == Item_Below)
       
  1060                     {
       
  1061                     tempItem = treeModuleList->itemBelow(tempItem);             
       
  1062                     }
       
  1063                 
       
  1064                 if (tempItem == lastItemSelected)
       
  1065                     {
       
  1066                     break;
       
  1067                     }
       
  1068                 }
       
  1069             }
       
  1070         }
       
  1071     
       
  1072     // Set current clicked item to last selected item.
       
  1073     lastItemSelected = item;
       
  1074 
       
  1075       
       
  1076     }
       
  1077 
       
  1078 void FrmMain::setItemClicked(QTreeWidgetItem* item)
   766     {
  1079     {
   767     QString header = UNSELECTITEMHEADER;
  1080     QString header = UNSELECTITEMHEADER;
   768     if(item->text(0).startsWith(UNSELECTITEMHEADER))
  1081     if(item->text(0).startsWith(UNSELECTITEMHEADER))
   769         {
  1082         {
   770             header = SELECTITEMHEADER;
  1083             header = SELECTITEMHEADER;
   774         {
  1087         {
   775             item->child(i)->setText(0, item->child(i)->text(0).replace(0, 3, header));
  1088             item->child(i)->setText(0, item->child(i)->text(0).replace(0, 3, header));
   776         }
  1089         }
   777     }
  1090     }
   778 
  1091 
   779 void frmMain::on_actAbout_triggered()
  1092 void FrmMain::on_actAbout_triggered()
   780     {
  1093     {
   781     QString str = QtUIVersion;
  1094     QString str = QtUIName + "<&nbsp;>" + QtUIVersion;
   782     str.append("\r\n").append("STF version:");
  1095     str.append("<br>").append("engine version:");
   783     
  1096     
   784     str.append(QString::number(STIF_MAJOR_VERSION, 10)).append(".");
  1097     str.append(QString::number(STIF_MAJOR_VERSION, 10)).append(".");
   785     str.append(QString::number(STIF_MINOR_VERSION, 10)).append(".");
  1098     str.append(QString::number(STIF_MINOR_VERSION, 10)).append(".");
   786     str.append(QString::number(STIF_BUILD_VERSION, 10));
  1099     str.append(QString::number(STIF_BUILD_VERSION, 10));
   787     str.append("  --").append(STIF_REL_DATE).append("\r\n");
  1100     str.append("  --").append(STIF_REL_DATE).append("<br>");
   788     str.append("---");
  1101     str.append("---");
   789     str.append("\r\nCopyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. ");
  1102     str.append("Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. ");
   790 
  1103 
   791     QMessageBox::information(this, tr("About"), str);
  1104     QErrorMessage *errorMessageDialog = new QErrorMessage(this);
   792     }
  1105     errorMessageDialog->showMessage("<font color =black size=12px><b>" + str + "</b></font>");
   793 
  1106     
   794 void frmMain::on_actOpenFile_triggered()
  1107     }
       
  1108 
       
  1109 void FrmMain::on_actOpenFile_triggered()
   795     {
  1110     {
   796     QString fileName = QFileDialog::getOpenFileName(this, tr(
  1111     QString fileName = QFileDialog::getOpenFileName(this, tr(
   797             "Select ini file"), tr("c:\\"), tr(
  1112             "Select ini file"), tr("c:\\"), tr(
   798             "Ini Files (*.ini);;All Files (*)"));
  1113             "Ini Files (*.ini);;All Files (*)"));
   799     if (!fileName.isEmpty())
  1114     if (!fileName.isEmpty())
   800         {
  1115         {
   801         controller->OpenEngineIniFile(fileName);
  1116         bool result = controller->OpenEngineIniFile(fileName);
   802         this->loadModuleList();
  1117         if(result)
   803         }
  1118             {
   804     }
  1119             this->loadModuleList();   
   805 
  1120             QMessageBox::information(this, tr("Open INI File"), "Load Engine INI file successfully!");
   806 void frmMain::on_actClearStatistics_triggered()
  1121             }
       
  1122         else
       
  1123             {
       
  1124             QMessageBox::warning(this, tr("Open INI File"),"Failed to Load Engine INI file. Please check the file format and its path.");
       
  1125             }
       
  1126         
       
  1127         }
       
  1128     }
       
  1129 
       
  1130 void FrmMain::on_actClearStatistics_triggered()
   807     {
  1131     {
   808     model->ClearCasesStatus();
  1132     model->ClearCasesStatus();
   809     }
  1133     }
       
  1134 
       
  1135 
       
  1136 void FrmMain::on_actExpand_triggered()
       
  1137     {
       
  1138     QTreeWidgetItem* item = treeModuleList->currentItem();
       
  1139     if(item != NULL)
       
  1140         {
       
  1141         item->setExpanded(true);
       
  1142         }
       
  1143     }
       
  1144 
       
  1145 void FrmMain::on_actCollapse_triggered()
       
  1146     {
       
  1147 
       
  1148     QTreeWidgetItem* item = treeModuleList->currentItem();
       
  1149     if(item != NULL)
       
  1150         {
       
  1151         item->setExpanded(false);
       
  1152         }
       
  1153     }
       
  1154 
       
  1155 void FrmMain::on_actOutput_triggered()
       
  1156     {
       
  1157     controller->SetShowOutput(true);
       
  1158     }
       
  1159 
       
  1160 // End of File