1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
|
#ifndef MainWindow_h
#define MainWindow_h
/******************************************************************************
*
* Copyright (C) 2002 Hugo PEREIRA <mailto: hugo.pereira@free.fr>
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* Any WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
*******************************************************************************/
#include "BaseMainWindow.h"
#include "Counter.h"
#include "CustomToolBar.h"
#include "Debug.h"
#include "JobCommand.h"
#include "Job.h"
#include "JobRecord.h"
#include "Key.h"
#include "UserSet.h"
#include <QCloseEvent>
class TabWidget;
class JobManagerFrame;
class BaseStatusBar;
class SummaryFrame;
class SignalMenu;
class UserSelectionFrame;
class MainWindow: public BaseMainWindow, public Base::Key
{
//* Qt meta object declaration
Q_OBJECT
public:
//* constructor
MainWindow( QWidget* = nullptr );
//* user
UserSelectionFrame& userSelectionFrame( void ) const
{ return *userFrame_; }
//* toolbar
CustomToolBar& userToolBar( void )
{ return *userToolBar_; }
//* toolbar
CustomToolBar& toolBar( void )
{ return *toolbar_; }
//* active frame
bool hasActiveFrame( void ) const
{ return (bool) activeFrame_; }
//* active frame
JobManagerFrame& activeFrame( void ) const
{ return *activeFrame_; }
//* status bar
BaseStatusBar& statusBar( void ) const
{ return *statusBar_; }
//* pause state
bool isPaused( void ) const
{ return isPaused_; }
//* install frames
void installFrames( void );
//*@name actions
//@{
//* toggle summary
QAction& toggleSummaryAction( void ) const
{ return *toggleSummaryAction_; }
//* resume paused job
QAction& resumeAction( void ) const
{ return *resumeAction_; }
//* pause job
QAction& pauseAction( void ) const
{ return *pauseAction_; }
//* kill job
QAction& killAction( void ) const
{ return *killAction_; }
//* update
QAction& updateAction( void ) const
{ return *updateAction_; }
//* tree view action
QAction& treeViewAction( void ) const
{ return *treeViewAction_; }
//* lock
QAction& lockAction( void ) const
{ return *lockAction_; }
//* add frame
QAction& addFrameAction( void ) const
{ return *addFrameAction_; }
//* remove current frame
QAction& removeFrameAction( void ) const
{ return *removeFrameAction_; }
//* record
QAction& recordAction( void ) const
{ return *recordAction_; }
//* record
QAction& toggleRecordAction( void ) const
{ return *toggleRecordAction_; }
//@}
Q_SIGNALS:
//* request command
void commandRequested( JobCommand );
//* new jobs available
void newJobs( Job::Set );
public Q_SLOTS:
//* update actions visibility
void updateActions( void );
//* update users
void updateUsers(UserSet);
//* add frame
void addFrame( const QString& );
//* run top to look for job updates
void requestJobList( void );
//* process job list
void processJobList( Job::Set );
//* close record dialogs
void closeJobInformationDialogs( void );
protected Q_SLOTS:
//* update configuration
void _updateConfiguration( void );
//* save configuration
void _saveConfiguration( void );
//* update uesr
void _updateUser( QString );
//* active frame changed
void _activeFrameChanged( int );
//* toggle summary
void _toggleSummary( bool );
//* resume selected jobs
void _resume( void );
//* pause selected jobs
void _pause( void );
//* kill selected jobs
void _kill( void );
//* send signal to selected jobs
void _sendSignal( int );
//* opens recorder for selected jobs
void _record( void );
//* toggle record all jobs
void _toggleRecordAllJobs( bool );
//* tree view
void _toggleTreeView( bool );
//* pause/restart timer
void _toggleUpdate( bool );
//* add frame
void _addFrame( void );
//* remove frame
void _removeFrame( void );
//* remove frame at index
void _removeFrame( int );
//* record dialog closed
void _recordDialogClosed( JobRecord );
protected:
//* timer event
void timerEvent( QTimerEvent* );
//* close window event handler
void closeEvent( QCloseEvent* );
//* active frame
void _setActiveFrame( JobManagerFrame& frame );
//* create a new frame
JobManagerFrame& _newFrame( void );
//* update frames
void _updateFrames( const Job::Set& );
//* update job records
void _updateRecords( Job::Set );
private:
//* summary
void _installActions( void );
//* used to find records which have no matching job
/**
stores a set of jobs. For each jobRecord, loop for a matching
job in the set. If one is found, the record gets updated and the
job is erased from the set. False is returned. If none is found
true is returned. Since the set of jobs is passed as a reference,
the set of jobs is automatically updated. Remaining jobs are to be added to the list
*/
class NoJobFTor
{
public:
//* constructor
NoJobFTor( Job::Set& jobs ):
jobs_( jobs )
{}
//* predicate
/**
stores a set of jobs. For each jobRecord, loop for a matching
job in the set. If one is found, the record gets updated and the
job is erased from the set. False is returned. If none is found
true is returned.
*/
bool operator () ( JobRecord& );
private:
// reference set of jobs
Job::Set& jobs_;
};
//* toolbar
CustomToolBar* userToolBar_ = nullptr;
//* toolbar
CustomToolBar* toolbar_ = nullptr;
//* user
UserSelectionFrame* userFrame_ = nullptr;
//* status bar
BaseStatusBar* statusBar_ = nullptr;
//* tab widget
TabWidget* tabWidget_ = nullptr;
//* active frame
JobManagerFrame* activeFrame_ = nullptr;
//* signal menu
SignalMenu* signalMenu_ = nullptr;
//* true if paused
bool isPaused_ = false;
//* refresh rate
int refreshRate_ = 0;
//* timer object for scheduled update
QBasicTimer timer_;
//* local copy of jobs
Job::Set jobs_;
//* list of JobRecord associated to found jobs.
/** it is used to create histograms of a given job resources */
JobRecord::List records_;
//*@name actions
//@{
//* resume paused job
QAction* resumeAction_ = nullptr;
//* pause job
QAction* pauseAction_ = nullptr;
//* kill job
QAction* killAction_ = nullptr;
//* record
QAction* recordAction_ = nullptr;
//* record all jobs flag
QAction* toggleRecordAction_ = nullptr;
//* update
QAction* updateAction_ = nullptr;
//* tree view
QAction* treeViewAction_ = nullptr;
//* lock
QAction* lockAction_ = nullptr;
//* toggle summary frame
QAction* toggleSummaryAction_ = nullptr;
//* add frame
QAction* addFrameAction_ = nullptr;
//* remove frame
QAction* removeFrameAction_ = nullptr;
//@}
};
#endif
|