stifui/qt/src/dlgoutput.cpp
branchRCL_3
changeset 13 822c625f7adc
parent 9 404ad6c9bc20
child 17 d40e813b23c0
equal deleted inserted replaced
11:454d022d514b 13:822c625f7adc
    18 #include <QtGui>
    18 #include <QtGui>
    19 
    19 
    20 DlgOutput::DlgOutput(IStfQtUIController* ctl, QWidget *parent) :
    20 DlgOutput::DlgOutput(IStfQtUIController* ctl, QWidget *parent) :
    21     QDialog(parent), controller(ctl)
    21     QDialog(parent), controller(ctl)
    22     {
    22     {
    23     QSize btnSize(100,30);
       
    24     QGridLayout *mainLayout = new QGridLayout(this);
    23     QGridLayout *mainLayout = new QGridLayout(this);
    25     this->setLayout(mainLayout);
    24     this->setLayout(mainLayout);
    26     this->setContextMenuPolicy(Qt::NoContextMenu);
    25     this->setContextMenuPolicy(Qt::NoContextMenu);
    27 
    26 
    28     tabMain = new QTabWidget();
    27     tabMain = new QTabWidget(this);
    29     tabMain->setContextMenuPolicy(Qt::NoContextMenu);
    28     tabMain->setContextMenuPolicy(Qt::NoContextMenu);
    30 
    29 
    31     QWidget *toolWidget = new QWidget(this);
    30     QWidget *toolWidget = new QWidget(this);
    32     toolWidget->setContextMenuPolicy(Qt::NoContextMenu);
    31     toolWidget->setContextMenuPolicy(Qt::NoContextMenu);
    33     QGridLayout *toolLayout = new QGridLayout();
    32     QGridLayout *toolLayout = new QGridLayout(this);
    34     toolWidget->setLayout(toolLayout);
    33     toolWidget->setLayout(toolLayout);
    35     btnPause = new QPushButton(tr("Pause"), toolWidget);
    34     btnPause = new QPushButton(tr("Pause"), toolWidget);
    36     btnPause->setContextMenuPolicy(Qt::NoContextMenu);
    35     btnPause->setContextMenuPolicy(Qt::NoContextMenu);
    37     btnPause->setFixedSize(btnSize);
       
    38     QObject::connect(btnPause, SIGNAL(clicked()), this,
    36     QObject::connect(btnPause, SIGNAL(clicked()), this,
    39             SLOT(on_btnPause_clicked()));
    37             SLOT(on_btnPause_clicked()));
    40     btnAbort = new QPushButton(tr("Abort"), toolWidget);
    38     btnAbort = new QPushButton(tr("Abort"), toolWidget);
    41     btnAbort->setContextMenuPolicy(Qt::NoContextMenu);
    39     btnAbort->setContextMenuPolicy(Qt::NoContextMenu);
    42     btnAbort->setFixedSize(btnSize);
       
    43     QObject::connect(btnAbort, SIGNAL(clicked()), this,
    40     QObject::connect(btnAbort, SIGNAL(clicked()), this,
    44             SLOT(on_btnAbort_clicked()));
    41             SLOT(on_btnAbort_clicked()));
       
    42     
       
    43     btnClose = new QPushButton(tr("Hide"), toolWidget);
       
    44     btnClose->setContextMenuPolicy(Qt::NoContextMenu);
       
    45     QObject::connect(btnClose, SIGNAL(clicked()), this,
       
    46             SLOT(on_btnClose_clicked()));
    45     toolLayout->addWidget(btnPause, 0, 0);
    47     toolLayout->addWidget(btnPause, 0, 0);
    46     toolLayout->addWidget(btnAbort, 0, 1);
    48     toolLayout->addWidget(btnAbort, 0, 1);
       
    49     toolLayout->addWidget(btnClose, 0, 2);
       
    50         
    47 
    51 
    48     mainLayout->addWidget(toolWidget, 0, 0);
    52     mainLayout->addWidget(toolWidget, 0, 0);
    49     mainLayout->addWidget(tabMain, 1, 0);
    53     mainLayout->addWidget(tabMain, 1, 0);
    50     controller->AddStfEventListener(this);
    54     controller->AddStfEventListener(this);
    51     }
    55     }
    64     }
    68     }
    65 
    69 
    66 void DlgOutput::CloseItem(QString index)
    70 void DlgOutput::CloseItem(QString index)
    67     {
    71     {
    68     int u = tabList.keys().indexOf(index);
    72     int u = tabList.keys().indexOf(index);
       
    73     
       
    74     delete tabList.value(index);
    69     tabList.remove(index);
    75     tabList.remove(index);
    70     tabMain->removeTab(u);
       
    71     if (tabMain->count() == 0)
    76     if (tabMain->count() == 0)
    72         {
    77         {
    73         this->close();
    78         this->close();
    74         }
    79         }
    75     }
    80     }
    77 void DlgOutput::ShowMessage(QString index, QString msg)
    82 void DlgOutput::ShowMessage(QString index, QString msg)
    78     {
    83     {
    79     if(tabList.contains(index))
    84     if(tabList.contains(index))
    80         {
    85         {
    81         tabList.value(index)->setPlainText(msg);    
    86         tabList.value(index)->setPlainText(msg);    
       
    87         }
       
    88     else
       
    89         {
       
    90 //        bool ok;
       
    91 //        CSTFCase acase = controller->GetRunningCase(index.toInt(&ok, 10));
       
    92 //        CreateItem(index, acase.Name());
       
    93 //        ShowMessage(index, msg);
    82         }
    94         }
    83     }
    95     }
    84 
    96 
    85 void DlgOutput::on_btnPause_clicked()
    97 void DlgOutput::on_btnPause_clicked()
    86     {
    98     {
    99 void DlgOutput::on_btnAbort_clicked()
   111 void DlgOutput::on_btnAbort_clicked()
   100     {
   112     {
   101     controller->AbortCase();
   113     controller->AbortCase();
   102     }
   114     }
   103 
   115 
       
   116 void DlgOutput::on_btnClose_clicked()
       
   117     {
       
   118     controller->SetShowOutput(false);
       
   119     this->close();
       
   120     }
       
   121 
   104 void DlgOutput::OnCaseOutputChanged(const IStfEventListener::CaseOutputCommand& cmd,
   122 void DlgOutput::OnCaseOutputChanged(const IStfEventListener::CaseOutputCommand& cmd,
   105         const QString& index, const QString& msg)
   123         const QString& index, const QString& msg)
   106     {
   124     {
   107     this->showMaximized();
   125     if(controller->ShowOutput() && this->isVisible() == false)
       
   126         {
       
   127         this->showMaximized();
       
   128         }
   108     switch (cmd)
   129     switch (cmd)
   109         {
   130         {
   110         case IStfEventListener::ECreate:
   131         case IStfEventListener::ECreate:
   111             CreateItem(index, msg);
   132             CreateItem(index, msg);
   112             break;
   133             break;