stifui/qt/src/frmmain.cpp
branchRCL_3
changeset 15 65b472535a0d
parent 13 822c625f7adc
child 17 d40e813b23c0
equal deleted inserted replaced
13:822c625f7adc 15:65b472535a0d
    26 const QString SELECTITEMHEADER = " * ";
    26 const QString SELECTITEMHEADER = " * ";
    27 const QString UNSELECTITEMHEADER = "   ";
    27 const QString UNSELECTITEMHEADER = "   ";
    28 
    28 
    29 FrmMain::FrmMain()
    29 FrmMain::FrmMain()
    30     {
    30     {
       
    31     lastItemSelected = NULL;
    31     uiSetting = new UiSetting();
    32     uiSetting = new UiSetting();
    32     createMenus();
    33     createMenus();
    33     load();
    34     load();
    34     LoadSubMenu();
    35     LoadSubMenu();
    35     
    36     
    54     {
    55     {
    55     model->AbortCase();
    56     model->AbortCase();
    56     controller->RemoveStfEventListener(this);
    57     controller->RemoveStfEventListener(this);
    57     model->RemoveStifModelEventListener(this);
    58     model->RemoveStifModelEventListener(this);
    58     
    59     
       
    60     //lastItemSelected does not own any memory, don't need to delete.
       
    61     lastItemSelected = NULL;
    59     delete uiSetting;
    62     delete uiSetting;
    60     delete dlgOutput;
    63     delete dlgOutput;
    61     delete controller;
    64     delete controller;
    62     delete model;
    65     delete model;
    63     }
    66     }
   177 
   180 
   178     actRunCasePar = new QAction(tr("Parallel"), this);
   181     actRunCasePar = new QAction(tr("Parallel"), this);
   179     connect(actRunCasePar, SIGNAL(triggered()), this,
   182     connect(actRunCasePar, SIGNAL(triggered()), this,
   180             SLOT(on_actRunCasePar_triggered()));
   183             SLOT(on_actRunCasePar_triggered()));
   181 
   184 
       
   185     ////////////////////
       
   186     actReapeatRunSeq = new QAction(tr("Repeat run sequentially"), this);
       
   187     connect(actReapeatRunSeq, SIGNAL(triggered()), this,
       
   188             SLOT(on_actReapeatRunSeq_triggered()));
       
   189     
   182     actAddtoSet = new QAction(tr("Add cases to Set"), this);
   190     actAddtoSet = new QAction(tr("Add cases to Set"), this);
   183     connect(actAddtoSet, SIGNAL(triggered()), this,
   191     connect(actAddtoSet, SIGNAL(triggered()), this,
   184             SLOT(on_actAddtoSet_triggered()));
   192             SLOT(on_actAddtoSet_triggered()));
   185 
   193 
   186     actSelectAll = new QAction(tr("Select All"), this);
   194     actSelectAll = new QAction(tr("Select All"), this);
   503         //Cases Tab
   511         //Cases Tab
   504         menuBar()->addAction(actOpenFile);
   512         menuBar()->addAction(actOpenFile);
   505         menuBar()->addMenu(menuRunCase);
   513         menuBar()->addMenu(menuRunCase);
   506         menuRunCase->addAction(actRunCaseSeq);
   514         menuRunCase->addAction(actRunCaseSeq);
   507         menuRunCase->addAction(actRunCasePar);
   515         menuRunCase->addAction(actRunCasePar);
       
   516         menuBar()->addAction(actReapeatRunSeq);
   508         menuBar()->addSeparator();
   517         menuBar()->addSeparator();
   509         menuBar()->addAction(actAddtoSet);
   518         menuBar()->addAction(actAddtoSet);
   510         menuBar()->addSeparator();
   519         menuBar()->addSeparator();
   511         menuBar()->addAction(actSelectAll);
   520         menuBar()->addAction(actSelectAll);
   512         menuBar()->addAction(actExpandAll);
   521         menuBar()->addAction(actExpandAll);
   685     {
   694     {
   686     startRunning();
   695     startRunning();
   687     controller->RunCases(getSelectedCases(), Parallel);
   696     controller->RunCases(getSelectedCases(), Parallel);
   688     }
   697     }
   689 
   698 
       
   699 void FrmMain::on_actReapeatRunSeq_triggered()
       
   700     {
       
   701     DlgRepeatRun dlgRepeatRun(this);
       
   702     int result = dlgRepeatRun.exec();
       
   703     if(result == QDialog::Accepted)
       
   704         {
       
   705         QList<CSTFCase> selectedCases = getSelectedCases();
       
   706         if(selectedCases.count() > 0)
       
   707             {
       
   708             startRunning();
       
   709             controller->RepeatRunCases( selectedCases, 
       
   710                                         dlgRepeatRun.isRepeatInfinitely(),
       
   711                                         dlgRepeatRun.GetLoopTimes() );
       
   712             }
       
   713         
       
   714         }
       
   715     }
       
   716 
   690 void FrmMain::on_actAddtoSet_triggered()
   717 void FrmMain::on_actAddtoSet_triggered()
   691     {
   718     {
   692 
       
   693     QList<CSTFCase> list = getSelectedCases();
   719     QList<CSTFCase> list = getSelectedCases();
   694     if (list.size() == 0)
   720     if (list.size() == 0)
   695         {
   721         {
   696         QErrorMessage *errorMessageDialog = new QErrorMessage(this);
   722         QErrorMessage *errorMessageDialog = new QErrorMessage(this);
   697         errorMessageDialog->setAutoFillBackground(true);
   723         errorMessageDialog->setAutoFillBackground(true);
   910     controller->AbortCase();
   936     controller->AbortCase();
   911     }
   937     }
   912 
   938 
   913 void FrmMain::on_treeModuleList_itemClicked(QTreeWidgetItem* item, int /*column*/)
   939 void FrmMain::on_treeModuleList_itemClicked(QTreeWidgetItem* item, int /*column*/)
   914     {
   940     {
       
   941     //Check if shift key is pressed
       
   942     bool isShiftPressed = false;
       
   943     Qt::KeyboardModifiers keyMod = QApplication::keyboardModifiers();
       
   944     isShiftPressed=keyMod.testFlag(Qt::ShiftModifier);
       
   945     
       
   946     //Handle shift key.
       
   947     //Shift not pressed.
       
   948     if(!isShiftPressed)
       
   949         {
       
   950         setItemClicked(item);
       
   951         }
       
   952     //Shift pressed.
       
   953     else
       
   954         {
       
   955         enum Direction
       
   956             {
       
   957             Item_NoDirection,
       
   958             Item_Above,
       
   959             Item_Below
       
   960             };
       
   961         Direction direction = Item_NoDirection;
       
   962         QTreeWidgetItem* tempItem = item;
       
   963         //check direction of last selected item comparing current one.
       
   964         while(tempItem)
       
   965             {
       
   966             tempItem = treeModuleList->itemAbove(tempItem);
       
   967             if(tempItem == lastItemSelected)
       
   968                 {
       
   969                 direction = Item_Above;
       
   970                 break;
       
   971                 }
       
   972             }
       
   973         if (direction != Item_Above)
       
   974             {
       
   975             tempItem = item;
       
   976             while(tempItem)
       
   977                 {
       
   978                 tempItem = treeModuleList->itemBelow(tempItem);
       
   979                 if(tempItem == lastItemSelected)
       
   980                     {
       
   981                     direction = Item_Below;
       
   982                     break;
       
   983                     }
       
   984                 }
       
   985             }
       
   986         
       
   987         // Select all items between current item and last selected item.
       
   988         tempItem = item;
       
   989         if(direction != Item_NoDirection)
       
   990             {
       
   991             while(tempItem)
       
   992                 {
       
   993                 //check if this item been selected.
       
   994                 bool isItemSelected = false;
       
   995                 if ( tempItem->text(0).left(3).compare(SELECTITEMHEADER)==0 )
       
   996                     {
       
   997                     isItemSelected = true;
       
   998                     }
       
   999                 // If not selected, set to selected.
       
  1000                 if (!isItemSelected )
       
  1001                     {
       
  1002                     setItemClicked(tempItem);
       
  1003                     }
       
  1004                 
       
  1005                 //Go above/below
       
  1006                 if (direction == Item_Above)
       
  1007                     {
       
  1008                     tempItem = treeModuleList->itemAbove(tempItem);             
       
  1009                     }
       
  1010                 if (direction == Item_Below)
       
  1011                     {
       
  1012                     tempItem = treeModuleList->itemBelow(tempItem);             
       
  1013                     }
       
  1014                 
       
  1015                 if (tempItem == lastItemSelected)
       
  1016                     {
       
  1017                     break;
       
  1018                     }
       
  1019                 }
       
  1020             }
       
  1021         }
       
  1022     
       
  1023     // Set current clicked item to last selected item.
       
  1024     lastItemSelected = item;
       
  1025 
       
  1026       
       
  1027     }
       
  1028 
       
  1029 void FrmMain::setItemClicked(QTreeWidgetItem* item)
       
  1030     {
   915     QString header = UNSELECTITEMHEADER;
  1031     QString header = UNSELECTITEMHEADER;
   916     if(item->text(0).startsWith(UNSELECTITEMHEADER))
  1032     if(item->text(0).startsWith(UNSELECTITEMHEADER))
   917         {
  1033         {
   918             header = SELECTITEMHEADER;
  1034             header = SELECTITEMHEADER;
   919         }
  1035         }