ListUsers::ListUsers( QWidget* parent): ListNodes( parent, "users") { m_ctrl_sf = new CtrlSortFilter( this, &ms_SortType1, &ms_SortAscending1, &ms_SortType2, &ms_SortAscending2, &ms_FilterType, &ms_FilterInclude, &ms_FilterMatch, &ms_FilterString); m_ctrl_sf->addSortType( CtrlSortFilter::TNONE); m_ctrl_sf->addSortType( CtrlSortFilter::TPRIORITY); m_ctrl_sf->addSortType( CtrlSortFilter::TNAME); m_ctrl_sf->addSortType( CtrlSortFilter::THOSTNAME); m_ctrl_sf->addSortType( CtrlSortFilter::TNUMJOBS); m_ctrl_sf->addSortType( CtrlSortFilter::TNUMRUNNINGTASKS); m_ctrl_sf->addSortType( CtrlSortFilter::TTIMEREGISTERED); m_ctrl_sf->addSortType( CtrlSortFilter::TTIMEACTIVITY); m_ctrl_sf->addFilterType( CtrlSortFilter::TNONE); m_ctrl_sf->addFilterType( CtrlSortFilter::TNAME); m_ctrl_sf->addFilterType( CtrlSortFilter::THOSTNAME); initSortFilterCtrl(); // Add left panel buttons: ButtonPanel * bp; bp = addButtonPanel("LOG","users_log","Show user log."); connect( bp, SIGNAL( sigClicked()), this, SLOT( actRequestLog())); bp = addButtonPanel("PRI","users_priority","Set user priority."); connect( bp, SIGNAL( sigClicked()), this, SLOT( actPriority())); bp = addButtonPanel("FOR","users_errors_forgive_time","Set user errors forgive time."); connect( bp, SIGNAL( sigClicked()), this, SLOT( actErrorsForgiveTime())); bp = addButtonPanel("LIFE","users_jobs_life_time","Set jobs life time."); connect( bp, SIGNAL( sigClicked()), this, SLOT( actJobsLifeTime())); bp = addButtonPanel("ORD","users_solve_ordered","Solve jobs by order."); connect( bp, SIGNAL( sigClicked()), this, SLOT( actSolveJobsByOrder())); bp = addButtonPanel("PAR","users_solve_parallel","Solve jobs parallel."); connect( bp, SIGNAL( sigClicked()), this, SLOT( actSolveJobsParallel())); m_parentWindow->setWindowTitle("Users"); init(); if( false == af::Environment::VISOR()) setAllowSelection( false); connect( (ModelNodes*)m_model, SIGNAL( nodeAdded( ItemNode *, const QModelIndex &)), this, SLOT( userAdded( ItemNode *, const QModelIndex &))); }
void ListUsers::contextMenuEvent(QContextMenuEvent *event) { ItemUser* useritem = (ItemUser*)getCurrentItem(); if( useritem == NULL ) return; bool me = false; if( useritem->getId() == MonitorHost::getUid()) me = true; QMenu menu(this); QMenu * submenu; QAction *action; action = new QAction( "Show Log", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRequestLog() )); menu.addAction( action); if( me || af::Environment::VISOR() ) { menu.addSeparator(); action = new QAction( "Annonate", this); connect( action, SIGNAL( triggered() ), this, SLOT( actAnnotate() )); menu.addAction( action); menu.addSeparator(); action = new QAction( "Set Max Running Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMaxRunningTasks() )); menu.addAction( action); action = new QAction( "Set Hosts Mask", this); connect( action, SIGNAL( triggered() ), this, SLOT( actHostsMask() )); menu.addAction( action); action = new QAction( "Set Exclude Hosts Mask", this); connect( action, SIGNAL( triggered() ), this, SLOT( actHostsMaskExclude() )); menu.addAction( action); if(( af::Environment::VISOR()) || ( af::Environment::getPermUserModHisPriority())) { action = new QAction( "Set Prority", this); connect( action, SIGNAL( triggered() ), this, SLOT( actPriority() )); menu.addAction( action); } menu.addSeparator(); action = new QAction( "Set Job Avoid Errors", this); connect( action, SIGNAL( triggered() ), this, SLOT( actErrorsAvoidHost() )); menu.addAction( action); action = new QAction( "Set Task Avoid Errors", this); connect( action, SIGNAL( triggered() ), this, SLOT( actErrorsSameHost() )); menu.addAction( action); action = new QAction( "Set Task Error Retries", this); connect( action, SIGNAL( triggered() ), this, SLOT( actErrorRetries() )); menu.addAction( action); action = new QAction( "Set Errors Forgive Time", this); connect( action, SIGNAL( triggered() ), this, SLOT( actErrorsForgiveTime() )); menu.addAction( action); menu.addSeparator(); action = new QAction( "Set Jobs Life Time", this); connect( action, SIGNAL( triggered() ), this, SLOT( actJobsLifeTime() )); menu.addAction( action); menu.addSeparator(); submenu = new QMenu("Jobs Solving Method", this); action = new QAction("By Order", this); connect( action, SIGNAL( triggered() ), this, SLOT( actSolveJobsByOrder() )); submenu->addAction( action); action = new QAction("Parallel", this); connect( action, SIGNAL( triggered() ), this, SLOT( actSolveJobsParallel() )); submenu->addAction( action); menu.addMenu( submenu); menu.addSeparator(); action = new QAction( "Custom Data", this); connect( action, SIGNAL( triggered() ), this, SLOT( actCustomData() )); menu.addAction( action); menu.addSeparator(); action = new QAction( "Delete", this); action->setEnabled( useritem->numjobs == 0 ); connect( action, SIGNAL( triggered() ), this, SLOT( actDelete() )); menu.addAction( action); } menu.exec( event->globalPos()); }
/* void ListJobs::v_connectionLost() { if( m_parentWindow != (QWidget*)Watch::getDialog()) m_parentWindow->close(); } */ void ListJobs::contextMenuEvent( QContextMenuEvent *event) { QMenu menu(this); QMenu * submenu; QAction *action; ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; int selectedItemsCount = getSelectedItemsCount(); if( jobitem->folders.size()) { if( af::Environment::hasRULES()) { action = new QAction("Open RULES", this); connect( action, SIGNAL( triggered() ), this, SLOT( actOpenRULES() )); menu.addAction( action); menu.addSeparator(); } submenu = new QMenu("Folders", this); QMapIterator<QString,QString> it( jobitem->folders); while( it.hasNext()) { it.next(); action = new QAction( QString("\"") + it.key() + "\":", this); action->setEnabled( false); submenu->addAction( action); ActionString * action_str = new ActionString( it.value(), it.value(), this); connect( action_str, SIGNAL( triggeredString(QString) ), this, SLOT( actBrowseFolder(QString) )); submenu->addAction( action_str); } menu.addMenu( submenu); menu.addSeparator(); } action = new QAction( "Show Log", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRequestLog() )); menu.addAction( action); action = new QAction( "Show Error Hosts", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRequestErrorHostsList() )); menu.addAction( action); action = new QAction( "Reset Error Hosts", this); connect( action, SIGNAL( triggered() ), this, SLOT( actResetErrorHosts() )); menu.addAction( action); action = new QAction( "Restart Error Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRestartErrors() )); if( selectedItemsCount == 1) action->setEnabled( jobitem->state & AFJOB::STATE_ERROR_MASK); menu.addAction( action); menu.addSeparator(); submenu = new QMenu("Start/Stop/Restart", this); menu.addMenu( submenu); action = new QAction( "Restart Running Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRestartRunning() )); if( selectedItemsCount == 1) action->setEnabled( jobitem->state & AFJOB::STATE_RUNNING_MASK); submenu->addAction( action); action = new QAction( "Restart Skipped Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRestartSkipped() )); if( selectedItemsCount == 1) action->setEnabled( jobitem->state & AFJOB::STATE_SKIPPED_MASK); submenu->addAction( action); action = new QAction( "Restart Done Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRestartDone() )); submenu->addAction( action); menu.addSeparator(); action = new QAction("Start Job", this); connect( action, SIGNAL( triggered() ), this, SLOT( actStart() )); if( selectedItemsCount == 1) action->setEnabled( jobitem->state & AFJOB::STATE_OFFLINE_MASK); submenu->addAction( action); action = new QAction("Pause Job", this); connect( action, SIGNAL( triggered() ), this, SLOT( actPause() )); if( selectedItemsCount == 1) action->setEnabled( false == (jobitem->state & AFJOB::STATE_OFFLINE_MASK)); submenu->addAction( action); action = new QAction("Stop Job", this); connect( action, SIGNAL( triggered() ), this, SLOT( actStop() )); if( selectedItemsCount == 1) action->setEnabled( jobitem->state & AFJOB::STATE_RUNNING_MASK); submenu->addAction( action); action = new QAction("Restart Job", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRestart() )); if( selectedItemsCount == 1) action->setEnabled(( jobitem->time_started != 0 ) || ( jobitem->state & AFJOB::STATE_SKIPPED_MASK )); submenu->addAction( action); action = new QAction("Restart&&Pause", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRestartPause() )); if( selectedItemsCount == 1) action->setEnabled(( jobitem->time_started != 0 ) || ( jobitem->state & AFJOB::STATE_SKIPPED_MASK )); submenu->addAction( action); menu.addSeparator(); if( af::Environment::VISOR() == false) { action = new QAction( "Move Up", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMoveUp() )); menu.addAction( action); action = new QAction( "Move Down", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMoveDown() )); menu.addAction( action); action = new QAction( "Move Top", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMoveTop() )); menu.addAction( action); action = new QAction( "Move Bottom", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMoveBottom() )); menu.addAction( action); } else { action = new QAction("Change Owner", this); connect( action, SIGNAL( triggered() ), this, SLOT( actSetUser() )); menu.addAction( action); } menu.addSeparator(); submenu = new QMenu( "Set Parameter", this); action = new QAction( "Max Running Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMaxRunningTasks() )); submenu->addAction( action); action = new QAction( "Max Run Tasks Per Host", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMaxRunTasksPerHost() )); submenu->addAction( action); action = new QAction( "Hosts Mask", this); connect( action, SIGNAL( triggered() ), this, SLOT( actHostsMask() )); submenu->addAction( action); action = new QAction( "Hosts Exclude Mask", this); connect( action, SIGNAL( triggered() ), this, SLOT( actHostsMaskExclude() )); submenu->addAction( action); if(( af::Environment::VISOR()) || ( af::Environment::getPermUserModJobPriority())) { action = new QAction( "Priority", this); connect( action, SIGNAL( triggered() ), this, SLOT( actPriority() )); submenu->addAction( action); } action = new QAction( "Depend Mask", this); connect( action, SIGNAL( triggered() ), this, SLOT( actDependMask() )); submenu->addAction( action); action = new QAction( "Global Depend Mask", this); connect( action, SIGNAL( triggered() ), this, SLOT( actDependMaskGlobal() )); submenu->addAction( action); action = new QAction( "Wait Time", this); connect( action, SIGNAL( triggered() ), this, SLOT( actWaitTime() )); submenu->addAction( action); action = new QAction( "Preview Approval", this); connect( action, SIGNAL( triggered() ), this, SLOT( actPreviewApproval() )); submenu->addAction( action); action = new QAction( "No Preview Approval", this); connect( action, SIGNAL( triggered() ), this, SLOT( actNoPreviewApproval() )); submenu->addAction( action); action = new QAction( "OS Needed", this); connect( action, SIGNAL( triggered() ), this, SLOT( actNeedOS() )); submenu->addAction( action); action = new QAction( "Properties Needed", this); connect( action, SIGNAL( triggered() ), this, SLOT( actNeedProperties() )); submenu->addAction( action); action = new QAction( "Post Command", this); connect( action, SIGNAL( triggered() ), this, SLOT( actPostCommand() )); submenu->addAction( action); action = new QAction( "Life Time", this); connect( action, SIGNAL( triggered() ), this, SLOT( actLifeTime() )); submenu->addAction( action); submenu->addSeparator(); action = new QAction( "Hidden", this); connect( action, SIGNAL( triggered() ), this, SLOT( actSetHidden() )); submenu->addAction( action); action = new QAction( "Not Hidden", this); connect( action, SIGNAL( triggered() ), this, SLOT( actUnsetHidden() )); submenu->addAction( action); submenu->addSeparator(); action = new QAction( "Annotation", this); connect( action, SIGNAL( triggered() ), this, SLOT( actAnnotate() )); submenu->addAction( action); action = new QAction( "Custom Data", this); connect( action, SIGNAL( triggered() ), this, SLOT( actCustomData() )); submenu->addAction( action); menu.addMenu( submenu); menu.addSeparator(); if( selectedItemsCount == 1) { if( jobitem->getBlocksNum() > 1) { submenu = new QMenu( "Tasks Blocks", this); for( int b = -1; b < jobitem->getBlocksNum(); b++) { QMenu * subsubmenu = new QMenu( b == -1 ? QString("_to_all_") : jobitem->getBlockName(b), this); jobitem->generateMenu( b, subsubmenu , this); submenu->addMenu( subsubmenu); } } else { submenu = new QMenu( "Tasks Block", this); jobitem->generateMenu( 0, submenu, this); } } else { submenu = new QMenu( "All Selected Blocks", this); jobitem->generateMenu( -1, submenu, this); } menu.addMenu( submenu); menu.addSeparator(); action = new QAction( "Listen", this); connect( action, SIGNAL( triggered() ), this, SLOT( actListenJob() )); menu.addAction( action); menu.addSeparator(); // System job ID is 1, and can not be deleted if( jobitem->getId() != 1 ) { action = new QAction( "Delete All Done", this); connect( action, SIGNAL( triggered() ), this, SLOT( actDeleteDone())); menu.addAction( action); action = new QAction( "Delete", this); connect( action, SIGNAL( triggered() ), this, SLOT( actDelete())); menu.addAction( action); } menu.exec(event->globalPos()); }
void ListRenders::contextMenuEvent( QContextMenuEvent *event) { ItemRender* render = (ItemRender*)getCurrentItem(); if( render == NULL ) return; bool me = false; if( render->getName().contains( QString::fromUtf8( af::Environment::getComputerName().c_str())) || ( render->getUserName() == QString::fromUtf8( af::Environment::getUserName().c_str()))) me = true; int selectedItemsCount = getSelectedItemsCount(); QMenu menu(this); QAction *action; QMenu * submenu; if( selectedItemsCount <= 1 ) { action = new QAction( render->getName(), this); action->setEnabled( false); menu.addAction( action); menu.addSeparator(); } action = new QAction( "Show Log", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRequestLog() )); menu.addAction( action); action = new QAction( "Tasks Log", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRequestTasksLog() )); menu.addAction( action); action = new QAction( "Show Info", this); connect( action, SIGNAL( triggered() ), this, SLOT( actRequestInfo() )); menu.addAction( action); std::list<const af::TaskExec*> l = render->getTasks(); submenu = new QMenu( l.size() > 1 ? "Running Tasks" : "Running Task", this); submenu->setEnabled( render->hasTasks()); std::list<const af::TaskExec*>::const_iterator it; for (it = l.begin() ; it != l.end() ; ++it) { const af::TaskExec *task = *it; QString title = QString("%1[%2][%3]") .arg( QString::fromStdString(task->getJobName())) .arg( QString::fromStdString(task->getBlockName())) .arg( QString::fromStdString(task->getName())); action = new ActionIdIdId( task->getJobId(), task->getBlockNum(), task->getTaskNum(), title, this); connect( action, SIGNAL( triggeredId(int,int,int) ), this, SLOT( actRequestTaskInfo(int,int,int) )); submenu->addAction( action); } menu.addMenu( submenu); if( me || af::Environment::VISOR()) { menu.addSeparator(); action = new QAction( "Set Priority", this); connect( action, SIGNAL( triggered() ), this, SLOT( actPriority() )); menu.addAction( action); action = new QAction( "Set NIMBY", this); if( selectedItemsCount == 1) action->setEnabled(false == render->isNIMBY()); connect( action, SIGNAL( triggered() ), this, SLOT( actNIMBY() )); menu.addAction( action); action = new QAction( "Set nimby", this); if( selectedItemsCount == 1) action->setEnabled(false == render->isNimby()); connect( action, SIGNAL( triggered() ), this, SLOT( actNimby() )); menu.addAction( action); action = new QAction( "Set Free", this); if( selectedItemsCount == 1) action->setEnabled(render->isNimby() || render->isNIMBY()); connect( action, SIGNAL( triggered() ), this, SLOT( actFree() )); menu.addAction( action); action = new QAction( "Set User", this); connect( action, SIGNAL( triggered() ), this, SLOT( actUser() )); menu.addAction( action); menu.addSeparator(); action = new QAction( "Annotate", this); connect( action, SIGNAL( triggered() ), this, SLOT( actAnnotate() )); menu.addAction( action); action = new QAction( "Change Capacity", this); connect( action, SIGNAL( triggered() ), this, SLOT( actCapacity() )); menu.addAction( action); action = new QAction( "Change Max Tasks", this); connect( action, SIGNAL( triggered() ), this, SLOT( actMaxTasks() )); menu.addAction( action); action = new QAction( "Enable Service", this); connect( action, SIGNAL( triggered() ), this, SLOT( actEnableService() )); menu.addAction( action); action = new QAction( "Disable Service", this); connect( action, SIGNAL( triggered() ), this, SLOT( actDisableService() )); menu.addAction( action); action = new QAction( "Restore Defaults", this); if( selectedItemsCount == 1) action->setEnabled(render->isDirty()); connect( action, SIGNAL( triggered() ), this, SLOT( actRestoreDefaults() )); menu.addAction( action); menu.addSeparator(); submenu = new QMenu( "Eject", this); action = new QAction( "All Tasks", this); if( selectedItemsCount == 1) action->setEnabled( render->hasTasks()); connect( action, SIGNAL( triggered() ), this, SLOT( actEjectTasks() )); submenu->addAction( action); action = new QAction( "Not My Tasks", this); if( selectedItemsCount == 1) action->setEnabled( render->hasTasks()); connect( action, SIGNAL( triggered() ), this, SLOT( actEjectNotMyTasks() )); submenu->addAction( action); menu.addMenu( submenu); } QMenu * custom_submenu = NULL; int custom_cmd_index = 0; if(af::Environment::getRenderCmds().size() > 0) { menu.addSeparator(); custom_submenu = new QMenu( "Custom", this); for( std::vector<std::string>::const_iterator it = af::Environment::getRenderCmds().begin(); it != af::Environment::getRenderCmds().end(); it++, custom_cmd_index++) { ActionId * actionid = new ActionId( custom_cmd_index, QString("%1").arg( afqt::stoq(*it)), this); connect( actionid, SIGNAL( triggeredId( int ) ), this, SLOT( actCommand( int ) )); custom_submenu->addAction( actionid); } menu.addMenu( custom_submenu); }