diff options
| author | Fabian Schillinger | 2010-11-01 16:53:24 +0100 |
|---|---|---|
| committer | Fabian Schillinger | 2010-11-01 16:53:24 +0100 |
| commit | 0d97a7378ffe5f6be408201cd1f5595607ed5f87 (patch) | |
| tree | 78ccd691a67c2f63f8fa4d1032d4cabfae0e80fa /src/gui/processWidget.cpp | |
| parent | [PVSGUI] parsing cmdargs fixed (diff) | |
| download | pvs-0d97a7378ffe5f6be408201cd1f5595607ed5f87.tar.gz pvs-0d97a7378ffe5f6be408201cd1f5595607ed5f87.tar.xz pvs-0d97a7378ffe5f6be408201cd1f5595607ed5f87.zip | |
Process start/stop/view functionality
processWidget - shows a list of processes on one client, allows to start ans stop processes
processesDialog - shows every processWidget as a tab
processesStartDialog - starts process entered in messageEdit
added handling of new pvscommands
Diffstat (limited to 'src/gui/processWidget.cpp')
| -rw-r--r-- | src/gui/processWidget.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/gui/processWidget.cpp b/src/gui/processWidget.cpp new file mode 100644 index 0000000..9b59b2a --- /dev/null +++ b/src/gui/processWidget.cpp @@ -0,0 +1,98 @@ +/* +# Copyright (c) 2010 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# processWidget.cpp + Widget to start/stop processes on a client. This widget is used in + processesDialog.cpp as a tab in the QTabWidget +# ----------------------------------------------------------------------------- +*/ + +#include "processesDialog.h" +#include "processWidget.h" +#include "ui_processWidget.h" + +ProcessWidget::ProcessWidget(QWidget *parent, PVSClient *cl): + QWidget(parent), + prowui(new Ui::ProcessWidget) +{ + prowui->setupUi(this); + + client = cl; + + connect( prowui->startButton, SIGNAL( clicked()), this, SLOT( startProcess())); + connect( prowui->refreshButton, SIGNAL( clicked()), this, SLOT( refrProcessList())); + connect( prowui->stopButton, SIGNAL( clicked()), this, SLOT( stopProcess())); + connect( client, SIGNAL( processVectorReady(bool)), this, SLOT( refrProcessList())); + + sendCommand("SHOWPROCESSES", ""); +} + +void ProcessWidget::startProcess() +{ + QMessageBox::StandardButton start = QMessageBox::question(0, + tr("PVS Start Process"), tr("Do you want to start the process: ") + prowui->processLineEdit->text() + + tr(" on User '") + client->getDesktopName() + tr("' ?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + + if (start == QMessageBox::Ok) + { + sendCommand("STARTPROCESS", prowui->processLineEdit->text()); + sendCommand("SHOWPROCESSES", ""); + } + prowui->processLineEdit->clear(); +} + +void ProcessWidget::refrProcessList() +{ + for(int i=prowui->processTable->rowCount(); i == 0; i--) + { + prowui->processTable->removeRow(i); + } + prowui->processTable->setRowCount(0); + QVector<QString> processes = client->getProcessesVector(); + + for (int i=0; i<processes.size(); i++) + { + prowui->processTable->setRowCount(i+1); + QStringList processesList = processes.at(i).split(QRegExp("<#>")); + for (int j=0; j<processesList.size()&&j<3; j++) + { + prowui->processTable->setItem(i,j,new QTableWidgetItem(processesList.at(j),0)); + } + } + prowui->processTable->selectRow(0); +} + +void ProcessWidget::stopProcess() +{ + if (prowui->processTable->rowCount() > 0) + { + QMessageBox::StandardButton start = QMessageBox::question(0, + tr("PVS Start Process"), tr("Do you want to stop the process: ") + prowui->processTable->item(prowui->processTable->currentRow(),1)->text() + + tr(" on User '") + client->getDesktopName() + tr("' ?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + if (start == QMessageBox::Ok) + { + sendCommand("KILLPROCESS", prowui->processTable->item(prowui->processTable->currentRow(),0)->text()); + sendCommand("SHOWPROCESSES", ""); + } + } +} + +void ProcessWidget::sendCommand(QString ident, QString message) +{ + client->sendMessage(PVSCOMMAND, ident, message); +} + +ProcessWidget::~ProcessWidget() +{ + delete prowui; +} |
