/// Function name : findDocumentIndexByPath // Description : Determines the index of the specified document // // HWND hTabCtrl : [in] Documents control // CONST TCHAR* szFullPath : [in] Full path of the desired document // INT& iOutput : [out] Zero-based index if found, otherwise -1 // // Return Value : TRUE if found, otherwise FALSE // BOOL findDocumentIndexByPath(HWND hTabCtrl, CONST TCHAR* szFullPath, INT& iOutput) { DOCUMENTS_DATA* pWindowData; // Window data LIST_ITERATOR* pIterator; // List iterator DOCUMENT* pDocument; // List iterator // Prepare pWindowData = getDocumentsControlData(hTabCtrl); iOutput = -1; /// Iterate through document list for (pIterator = createListIterator(pWindowData->pDocumentList); getCurrentItem(pIterator, (LPARAM&)pDocument); moveNextItem(pIterator)) { // [CHECK] Compare paths if (utilCompareStringVariables(getDocumentPath(pDocument), szFullPath)) { /// [FOUND] Set result and abort iOutput = pIterator->iIndex; break; } } // Cleanup and return TRUE if found deleteListIterator(pIterator); return (iOutput != -1); }
/// Function name : findDocumentIndexByValue // Description : Determines the index of the specified document // // DOCUMENTS_DATA* pDocumentsData : [in] Window data // CONST DOCUMENT* pTargetDocument : [in] Document to retrieve the index for // INT& iOutput : [out] Zero-based index if found, otherwise -1 // // Return Value : TRUE if found, otherwise FALSE // BOOL findDocumentIndexByValue(DOCUMENTS_DATA* pWindowData, CONST DOCUMENT* pTargetDocument, INT& iOutput) { LIST_ITERATOR* pIterator; // List iterator DOCUMENT* pCurrentDocument; // List iterator // Prepare iOutput = -1; /// Iterate through document list for (pIterator = createListIterator(pWindowData->pDocumentList); getCurrentItem(pIterator, (LPARAM&)pCurrentDocument); moveNextItem(pIterator)) { // [CHECK] Compare current item if (pCurrentDocument == pTargetDocument) { /// [FOUND] Set result and abort iOutput = pIterator->iIndex; break; } } // Cleanup and return TRUE if found deleteListIterator(pIterator); return (iOutput != -1); }
long ComboBox::onCommand(FXObject *, FXSelector, void *a_data) { m_currentItem = getCurrentItem(); // avoid another indirect SEL_COMMAND call if (m_target) // (from ComboBox::onUpdate()) m_target->handle(this, FXSEL(SEL_COMMAND, m_selector), a_data); return 1; }
void QFFitFunctionSelectDialog::currentRowChanged(const QModelIndex & /*current*/, const QModelIndex & /*previous*/) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QString pid=getCurrentItem(); int ppid=QFPluginServices::getInstance()->getFitFunctionManager()->getPluginForID(pid); QString help=QFPluginServices::getInstance()->getFitFunctionManager()->getPluginHelp(ppid, pid); ui->txtHelp->setHtml(transformQF3HelpHTMLFile(help)); currentFunction=pid; QApplication::restoreOverrideCursor(); }
void ListJobs::actPostCommand() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; QString current = jobitem->cmd_post; bool ok; QString cmd = QInputDialog::getText(this, "Change Post Command", "Enter Command", QLineEdit::Normal, current, &ok); if( !ok) return; setParameter("command_post", afqt::qtos( cmd)); }
void ListUsers::actErrorsSameHost() { ItemUser* useritem = (ItemUser*)getCurrentItem(); if( useritem == NULL ) return; int current = useritem->errors_tasksamehost; bool ok; int value = QInputDialog::getInt(this, "Errors same host", "Enter Number of Errors", current, 0, 99, 1, &ok); if( !ok) return; setParameter("errors_task_same_host", value); }
void ListUsers::actErrorRetries() { ItemUser* useritem = (ItemUser*)getCurrentItem(); if( useritem == NULL ) return; int current = useritem->errors_retries; bool ok; int value = QInputDialog::getInt(this, "Auto retry error tasks", "Enter Number of Errors", current, 0, 99, 1, &ok); if( !ok) return; setParameter("errors_retries", value); }
void ListJobs::actMaxRunTasksPerHost() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; int current = jobitem->maxruntasksperhost; bool ok; int max = QInputDialog::getInt(this, "Change Maximum Running Tasks Per Host", "Enter Number", current, -1, 999999, 1, &ok); if( !ok) return; setParameter("max_running_tasks_per_host", max); }
void ListUsers::actMaxRunningTasks() { ItemUser* useritem = (ItemUser*)getCurrentItem(); if( useritem == NULL ) return; int current = useritem->maxrunningtasks; bool ok; int max = QInputDialog::getInt(this, "Change Maximum Running Tasks", "Enter Number", current, -1, 9999, 1, &ok); if( !ok) return; setParameter("max_running_tasks", max); }
void ListJobs::actSetUser() { ItemJob* item = (ItemJob*)getCurrentItem(); if( item == NULL ) return; QString current = item->username; bool ok; QString text = QInputDialog::getText(this, "Change Owner", "Enter New User Name", QLineEdit::Normal, current, &ok); if( !ok) return; setParameter("user_name", afqt::qtos( text)); }
void ListUsers::actHostsMaskExclude() { ItemUser* useritem = (ItemUser*)getCurrentItem(); if( useritem == NULL ) return; QString current = useritem->hostsmask_exclude; bool ok; QString mask = QInputDialog::getText(this, "Change Exclude Mask", "Enter Mask", QLineEdit::Normal, current, &ok); if( !ok) return; setParameterRE("hosts_mask_exclude", afqt::qtos( mask)); }
void ListUsers::actJobsLifeTime() { ItemUser* useritem = (ItemUser*)getCurrentItem(); if( useritem == NULL ) return; double cur = double( useritem->jobs_lifetime ) / (60.0*60.0); bool ok; double hours = QInputDialog::getDouble( this, "Jobs Life Time", "Enter number of hours (0=infinite)", cur, 0, 365*24, 3, &ok); if( !ok) return; setParameter("jobs_life_time", int( hours * 60.0 * 60.0 )); }
void ListJobs::actOpenRULES() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; QString path = jobitem->getFirstFolder(); if( path.isEmpty()) return; QString cmd = QString("rules -s \"") + path + "\""; Watch::startProcess( cmd); }
/** * this function ADDs a list of selected item names into 'names'. * it assumes the list is ready and doesn't initialize it, or clears it */ void KrView::getSelectedItems(QStringList *names, bool ignoreJustFocused) { for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) if (it->isSelected() && (it->name() != "..")) names->append(it->name()); // if all else fails, take the current item if (!ignoreJustFocused) { QString item = getCurrentItem(); if (names->empty() && !item.isEmpty() && item != "..") { names->append(item); } } }
void ListJobs::actLifeTime() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; double cur = double( jobitem->lifetime ) / (60.0*60.0); bool ok; double hours = QInputDialog::getDouble( this, "Life Time", "Enter number of hours (0=infinite)", cur, -1, 365*24, 3, &ok); if( !ok) return; int seconds = hours * 60.0 * 60.0; if( seconds < -1 ) seconds = -1; setParameter("time_life", seconds); }
void KrView::getSelectedKrViewItems(KrViewItemList *items) { for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) if (it->isSelected() && (it->name() != "..")) items->append(it); // if all else fails, take the current item QString item = getCurrentItem(); if (items->empty() && !item.isEmpty() && item != ".." && getCurrentKrViewItem() != 0) { items->append(getCurrentKrViewItem()); } }
void ListJobs::blockAction( int id_block, QString i_action) { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; std::ostringstream str; af::jsonActionStart( str, "jobs", "", getSelectedIds()); str << ",\n\"block_ids\":[" << id_block << ']'; if( jobitem->blockAction( str, id_block, i_action, this)) { af::jsonActionFinish( str); Watch::sendMsg( af::jsonMsg( str)); } }
/*========================================================================= slot newBrowserAction =========================================================================*/ void KFileBrowser::handleNewBrowserAction (void) { QString empty; QString fileName = getCurrentItem(); if (fileName != "") { if (QFileInfo(fileName).isDir()) { emit newBrowserRequested (&fileName); } else emit newBrowserRequested (&empty); } else { emit newBrowserRequested (&empty); } }
void ListJobs::actHostsMaskExclude() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; QString current = jobitem->hostsmask_exclude; bool ok; QString mask = QInputDialog::getText(this, "Change Exclude Mask", "Enter New Mask", QLineEdit::Normal, current, &ok); if( !ok) return; QRegExp rx( mask, Qt::CaseInsensitive); if( rx.isValid() == false ) { displayError( rx.errorString()); return; } setParameter("hosts_mask_exclude", afqt::qtos( mask)); }
void ListJobs::actDependMaskGlobal() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; QString current = jobitem->dependmask_global; bool ok; QString mask = QInputDialog::getText(this, "Change Depend Mask", "Enter New Mask", QLineEdit::Normal, current, &ok); if( !ok) return; QRegExp rx( mask, Qt::CaseInsensitive); if( rx.isValid() == false ) { displayError( rx.errorString()); return; } setParameter("depend_mask_global", afqt::qtos( mask)); }
void ListJobs::actNeedProperties() { ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; QString current = jobitem->need_properties; bool ok; QString mask = QInputDialog::getText(this, "Change Properties Needed", "Enter New Mask", QLineEdit::Normal, current, &ok); if( !ok) return; QRegExp rx( mask, Qt::CaseInsensitive); if( rx.isValid() == false ) { displayError( rx.errorString()); return; } setParameter("need_properties", afqt::qtos( mask)); }
void ListItems::getItemInfo( const std::string & i_mode) { Item * item = getCurrentItem(); if( item == NULL ) return; //{"get":{"type":"renders","ids":[1],"mode":"log"}} displayInfo(QString("GET: \"%1\"").arg( afqt::stoq(i_mode))); std::ostringstream str; str << "{\"get\":{"; str << "\"binary\":true"; str << ",\"type\":\"" << m_type << "\""; str << ",\"ids\":[" << item->getId() << "]"; str << ",\"mode\":\"" << i_mode << "\""; str << "}}"; Watch::sendMsg( af::jsonMsg( str)); }
long ComboBox::onUpdate(FXObject *, FXSelector, void *) /* We have to add this handler for an FXComboBox, because its current item isn't necessarily shown. Instead of copying this handler for every instance of FXComboBox, we create a derived class, hence this class. */ { FXint currentItem = getCurrentItem(); if (m_currentItem != currentItem) { setCurrentItem(currentItem); m_currentItem = currentItem; // Send a SEL_COMMAND so that the internal state of the program will match // with what is displayed FXString item = getItem(m_currentItem); // send item text for correctness if (m_target) m_target->handle(this, FXSEL(SEL_COMMAND, m_selector), (void *) item.text()); // cast const away } return 1; }
long MyIconList::onFocusInOut(FXObject*o, FXSelector sel, void*p) { long rv=FXIconList::handle(o,sel,p); switch (FXSELTYPE(sel)) { case SEL_FOCUSIN: { if (getNumItems()>0) { if (!isItemSelected(getCurrentItem())) { setCurrentItem(0); selectItem(0, true); target->handle(this,FXSEL(SEL_COMMAND,message),0); } setListStyle(ICONLIST_BROWSESELECT); } break; } case SEL_FOCUSOUT: { setListStyle(ICONLIST_SINGLESELECT); break; } } return rv; }
void ListJobs::actWaitTime() { static const QString format("yyyy.MM.dd HH:mm:ss"); ItemJob* jobitem = (ItemJob*)getCurrentItem(); if( jobitem == NULL ) return; uint32_t waittime = jobitem->time_wait; if( waittime < time( NULL)) waittime = time( NULL); QString current = QDateTime::fromTime_t( waittime).toString( format); bool ok; QString waittime_str = QInputDialog::getText(this, "Set Wait Time", format, QLineEdit::Normal, current, &ok); if( !ok) return; waittime = QDateTime::fromString( waittime_str, format).toTime_t(); //printf("waittime_str=\"%s\", waittime=%d\n", waittime_str.toUtf8().data(), waittime); if( waittime == unsigned(-1) ) { displayError( "Time format : " + format); return; } setParameter("time_wait", waittime); }
// // FUNCTION: WndProc (HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Process the message in the main window. // // WM_COMMAND - process the application menu // WM_PAINT - draw the main window // WM_DESTROY - send a message to exit and return // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int cbIndex; static scene sceneSettings = init_scene(hWnd); params parameters; PAINTSTRUCT ps; HDC hdc; HWND bufHWND; TCHAR buf[5]; switch (message) { case WM_COMMAND: { int wmId = LOWORD(wParam); switch (wmId) { case ID_BUTTON_DRAW_ELLIPSE: cbIndex = getCurrentItem(GetDlgItem(hWnd, ID_COMBO_ELLIPSE)); bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_CENTER_X); GetWindowText(bufHWND, buf, 5); parameters.centerX = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_CENTER_Y); GetWindowText(bufHWND, buf, 5); parameters.centerY = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_HEIGHT); GetWindowText(bufHWND, buf, 5); parameters.height = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_WIDTH); GetWindowText(bufHWND, buf, 5); parameters.width = _wtoi(buf); draw(ELLIPSE, parameters, cbIndex, sceneSettings); break; case ID_BUTTON_DRAW_CIRCLE: cbIndex = getCurrentItem(GetDlgItem(hWnd, ID_COMBO_CIRCLE)); bufHWND = GetDlgItem(hWnd, ID_EDIT_CIRCLE_CENTER_X); GetWindowText(bufHWND, buf, 5); parameters.centerX = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_CIRCLE_CENTER_Y); GetWindowText(bufHWND, buf, 5); parameters.centerY = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_CIRCLE_RADIUS); GetWindowText(bufHWND, buf, 5); parameters.radiusMin = _wtoi(buf); parameters.radiusMax = _wtoi(buf); draw(CIRCLE, parameters, cbIndex, sceneSettings); break; case ID_BUTTON_DRAW_SPEKTRE: cbIndex = getCurrentItem(GetDlgItem(hWnd, ID_COMBO_SPEKTRE)); bufHWND = GetDlgItem(hWnd, ID_EDIT_SPEKTRE_RADIUS_MIN); GetWindowText(bufHWND, buf, 5); parameters.radiusMin = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_SPEKTRE_RADIUS_MAX); GetWindowText(bufHWND, buf, 5); parameters.radiusMax = _wtoi(buf); bufHWND = GetDlgItem(hWnd, ID_EDIT_SPEKTRE_RADIUS_STEP); GetWindowText(bufHWND, buf, 5); parameters.radiusStep = _wtoi(buf); draw(SPEKTRE, parameters, cbIndex, sceneSettings); break; case ID_BUTTON_CLEAR: draw_scene(sceneSettings); break; case ID_BUTTON_LCOLOR: change_color(&sceneSettings, TRUE); break; case ID_BUTTON_BCOLOR: change_color(&sceneSettings, FALSE); break; case IDM_ABOUT: DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } SetFocus(hWnd); } break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); draw_scene(sceneSettings); init_colorpick(sceneSettings); init_text(sceneSettings); EndPaint(hWnd, &ps); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
int ExtraIconGroup::internalSetIcon(int id, MCONTACT hContact, void *value, bool bByName) { if (m_insideApply) { for (int i=0; i < m_items.getCount(); i++) if (m_items[i]->getID() == id) { if (bByName) return m_items[i]->setIconByName(id, hContact, (const char*)value); return m_items[i]->setIcon(id, hContact, (HANDLE)value); } return -1; } ExtraIcon *current = getCurrentItem(hContact); int currentPos = m_items.getCount(); int storePos = m_items.getCount(); for (int i=0; i < m_items.getCount(); i++) { if (m_items[i]->getID() == id) storePos = i; if (m_items[i] == current) currentPos = i; } if (storePos == m_items.getCount()) return -1; if (storePos > currentPos) { m_items[storePos]->storeIcon(hContact, value); return 0; } // Ok, we have to set the icon, but we have to assert it is a valid icon m_setValidExtraIcon = false; int ret; if (bByName) ret = m_items[storePos]->setIconByName(id, hContact, (const char*)value); else ret = m_items[storePos]->setIcon(id, hContact, (HANDLE)value); if (storePos < currentPos) { if (m_setValidExtraIcon) db_set_dw(hContact, MODULE_NAME, m_szName, m_items[storePos]->getID()); } else if (storePos == currentPos) { if (!m_setValidExtraIcon) { db_set_dw(hContact, MODULE_NAME, m_szName, 0); m_insideApply = true; for (++storePos; storePos < m_items.getCount(); ++storePos) { m_items[storePos]->applyIcon(hContact); if (m_setValidExtraIcon) break; } m_insideApply = false; if (m_setValidExtraIcon && storePos < m_items.getCount()) db_set_dw(hContact, MODULE_NAME, m_szName, m_items[storePos]->getID()); } } return ret; }
void ExtraIconGroup::onClick(MCONTACT hContact) { ExtraIcon *extra = getCurrentItem(hContact); if (extra != NULL) extra->onClick(hContact); }
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()); }
int ExtraIconGroup::setIcon(int id, HANDLE hContact, void *icon) { if (insideApply) { for (unsigned int i = 0; i < items.size(); ++i) if (items[i]->getID() == id) return items[i]->setIcon(id, hContact, icon); return -1; } ExtraIcon *current = getCurrentItem(hContact); int currentPos = (int)items.size(); int storePos = (int)items.size(); for (unsigned int i = 0; i < items.size(); ++i) { if (items[i]->getID() == id) storePos = i; if (items[i] == current) currentPos = i; } if (storePos == items.size()) { return -1; } else if (storePos > currentPos) { items[storePos]->storeIcon(hContact, icon); return 0; } // Ok, we have to set the icon, but we have to assert it is a valid icon setValidExtraIcon = false; int ret = items[storePos]->setIcon(id, hContact, icon); if (storePos < currentPos) { if (setValidExtraIcon) DBWriteContactSettingDword(hContact, MODULE_NAME, name.c_str(), items[storePos]->getID()); } else if (storePos == currentPos) { if (!setValidExtraIcon) { DBWriteContactSettingDword(hContact, MODULE_NAME, name.c_str(), 0); insideApply = true; for (++storePos; storePos < items.size(); ++storePos) { items[storePos]->applyIcon(hContact); if (setValidExtraIcon) break; } insideApply = false; if (setValidExtraIcon) DBWriteContactSettingDword(hContact, MODULE_NAME, name.c_str(), items[storePos]->getID()); } } return ret; }