|
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 * |
|
16 */ |
|
17 #include "dlgoutput.h" |
|
18 #include <QtGui> |
|
19 |
|
20 DlgOutput::DlgOutput(IStfQtUIController* ctl, QWidget *parent) : |
|
21 QDialog(parent), controller(ctl) |
|
22 { |
|
23 QGridLayout *mainLayout = new QGridLayout(this); |
|
24 this->setLayout(mainLayout); |
|
25 this->setContextMenuPolicy(Qt::NoContextMenu); |
|
26 |
|
27 tabMain = new QTabWidget(this); |
|
28 tabMain->setContextMenuPolicy(Qt::NoContextMenu); |
|
29 |
|
30 QWidget *toolWidget = new QWidget(this); |
|
31 toolWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
32 QGridLayout *toolLayout = new QGridLayout(this); |
|
33 toolWidget->setLayout(toolLayout); |
|
34 btnPause = new QPushButton(tr("Pause"), toolWidget); |
|
35 btnPause->setContextMenuPolicy(Qt::NoContextMenu); |
|
36 QObject::connect(btnPause, SIGNAL(clicked()), this, |
|
37 SLOT(on_btnPause_clicked())); |
|
38 btnAbort = new QPushButton(tr("Abort"), toolWidget); |
|
39 btnAbort->setContextMenuPolicy(Qt::NoContextMenu); |
|
40 QObject::connect(btnAbort, SIGNAL(clicked()), this, |
|
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())); |
|
47 toolLayout->addWidget(btnPause, 0, 0); |
|
48 toolLayout->addWidget(btnAbort, 0, 1); |
|
49 toolLayout->addWidget(btnClose, 0, 2); |
|
50 |
|
51 |
|
52 mainLayout->addWidget(toolWidget, 0, 0); |
|
53 mainLayout->addWidget(tabMain, 1, 0); |
|
54 controller->AddStfEventListener(this); |
|
55 } |
|
56 |
|
57 DlgOutput::~DlgOutput() |
|
58 { |
|
59 controller->RemoveStfEventListener(this); |
|
60 } |
|
61 |
|
62 void DlgOutput::CreateItem(QString index, QString item) |
|
63 { |
|
64 QPlainTextEdit* edit = new QPlainTextEdit(this); |
|
65 edit->setContextMenuPolicy(Qt::NoContextMenu); |
|
66 tabMain->addTab(edit, item); |
|
67 tabList.insert(index, edit); |
|
68 } |
|
69 |
|
70 void DlgOutput::CloseItem(QString index) |
|
71 { |
|
72 delete tabList.value(index); |
|
73 tabList.remove(index); |
|
74 if (tabMain->count() == 0) |
|
75 { |
|
76 this->close(); |
|
77 } |
|
78 } |
|
79 |
|
80 void DlgOutput::ShowMessage(QString index, QString msg) |
|
81 { |
|
82 if(tabList.contains(index)) |
|
83 { |
|
84 tabList.value(index)->setPlainText(msg); |
|
85 } |
|
86 else |
|
87 { |
|
88 // bool ok; |
|
89 // CSTFCase acase = controller->GetRunningCase(index.toInt(&ok, 10)); |
|
90 // CreateItem(index, acase.Name()); |
|
91 // ShowMessage(index, msg); |
|
92 } |
|
93 } |
|
94 |
|
95 void DlgOutput::on_btnPause_clicked() |
|
96 { |
|
97 if (btnPause->text() == "Pause") |
|
98 { |
|
99 controller->PauseCase(); |
|
100 btnPause->setText(tr("Resume")); |
|
101 } |
|
102 else |
|
103 { |
|
104 controller->ResumeCase(); |
|
105 btnPause->setText(tr("Pause")); |
|
106 } |
|
107 } |
|
108 |
|
109 void DlgOutput::on_btnAbort_clicked() |
|
110 { |
|
111 controller->AbortCase(); |
|
112 } |
|
113 |
|
114 void DlgOutput::on_btnClose_clicked() |
|
115 { |
|
116 controller->SetShowOutput(false); |
|
117 this->close(); |
|
118 } |
|
119 |
|
120 void DlgOutput::OnCaseOutputChanged(const IStfEventListener::CaseOutputCommand& cmd, |
|
121 const QString& index, const QString& msg) |
|
122 { |
|
123 if(controller->ShowOutput() && this->isVisible() == false) |
|
124 { |
|
125 this->showMaximized(); |
|
126 } |
|
127 switch (cmd) |
|
128 { |
|
129 case IStfEventListener::ECreate: |
|
130 CreateItem(index, msg); |
|
131 break; |
|
132 case IStfEventListener::EClose: |
|
133 CloseItem(index); |
|
134 break; |
|
135 default: |
|
136 ShowMessage(index, msg); |
|
137 break; |
|
138 } |
|
139 |
|
140 } |
|
141 |
|
142 // End of File |