From 0d97a7378ffe5f6be408201cd1f5595607ed5f87 Mon Sep 17 00:00:00 2001 From: Fabian Schillinger Date: Mon, 1 Nov 2010 16:53:24 +0100 Subject: 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 --- src/gui/processWidget.cpp | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/gui/processWidget.cpp (limited to 'src/gui/processWidget.cpp') 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 processes = client->getProcessesVector(); + + for (int i=0; iprocessTable->setRowCount(i+1); + QStringList processesList = processes.at(i).split(QRegExp("<#>")); + for (int j=0; jprocessTable->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; +} -- cgit v1.2.3-55-g7522