Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
processManagerWidget.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 /*
52  * processManagerWidget.hh
53  *
54  * Created on: Apr 7, 2009
55  * Author: kremer
56  */
57 
58 #ifndef PROCESSMANAGERWIDGET_HH_
59 #define PROCESSMANAGERWIDGET_HH_
60 
61 
62 #include "ui_processManagerWidget.hh"
63 
64 #if QT_VERSION >= 0x050000
65  #include <QtWidgets>
66 #else
67  #include <QtGui>
68 #endif
69 
70 // A button class that additionally stores
71 // an attached job's id.
72 class JobCancelButton : public QPushButton {
73  Q_OBJECT
74 
75 public:
76  JobCancelButton(QString _caption, QString _jobId, QWidget* _parent = 0) :
77  QPushButton(_caption, _parent),
78  jobId_(_jobId) {};
79 
80  // Set job's id
81  void setJobId(const QString& _jobId) { jobId_ = _jobId; };
82 
83  // Get job's id
84  QString jobId() { return jobId_; }
85 
86 private:
87  QString jobId_;
88 };
89 
90 class ProcessManagerWidget : public QWidget, public Ui::ProcessManagerWidget
91 {
92  Q_OBJECT
93 
94  signals:
95 
96  void cancelJobRequested(QString _jobId);
97 
98  public:
99 
100  ProcessManagerWidget(QWidget* parent = 0) : QWidget(parent) {
101 
102  setupUi(this);
103  };
104 
105  virtual ~ProcessManagerWidget() {};
106 
107  void updateStatus(QString _id, int _status);
108 
109  void setJobName(QString _id, QString _desc);
110 
111  void setJobDescription(QString _id, QString _desc);
112 
113  void addJob(QString _id, QString _description = "",
114  int _minSteps = 0, int _maxSteps = 100);
115 
116  void removeJob(QString _jobName);
117 
118  size_t getNumJobs() { return processMap_.size(); }
119 
120  private slots:
121 
122  void cancelButtonPressed();
123 
124  private:
125 
126  // A container to hold the widget items
127  struct JobContainer {
128  QTableWidgetItem* id;
129  QTableWidgetItem* description;
130  QProgressBar* progress;
131  JobCancelButton* button;
132  };
133 
134  QHash<QString, JobContainer> processMap_;
135 };
136 
137 
138 #endif /* PROCESSMANAGERWIDGET_HH_ */