bool SVConditionParam::checkParamValue(string &szParam, string &szParamValue) { bool bNoError = false; if(szParam.empty() || szParamValue.empty()) { showErrorMsg(sv_condition_type_error); return false; } ReturnItem rtItem; for(rtItem = m_lsReturn.begin(); rtItem != m_lsReturn.end(); rtItem ++) { if((*rtItem)->getLabel() == szParam) { szParam = (*rtItem)->getName(); if((*rtItem)->isNumeric()) { if(SV_IsNumeric(szParamValue)) bNoError = true; else showErrorMsg(sv_condition_type_error); } else bNoError = true; break; } } return bNoError; }
Canvas::Canvas(QWidget *parent): QWidget(parent){ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); createLayout(); model = new PointSet(); reader = new PointXmlReader(this); writer = new PointXmlWritter(this); connect(reader, SIGNAL(pointFound(FloatPoint)), this, SLOT(addPoint(FloatPoint))); connect(reader, SIGNAL(readingSuccessful()), this, SLOT(redraw())); connect(reader, SIGNAL(readingError(QString)), this, SLOT(showErrorMsg(QString))); connect(writer, SIGNAL(writingSuccessful()), this, SLOT(redraw())); connect(writer, SIGNAL(writingError(QString)), this, SLOT(showErrorMsg(QString))); confidence = 0; }
void KMMainView::slotUpdatePossible(bool flag) { destroyMessageWindow(); if(!flag) showErrorMsg(i18n("Unable to retrieve the printer list.")); KMTimer::self()->release(true); }
void Dialog::sendPacketToServer() { qDebug("[Dialog::sendPacketToServer]"); bool ok; int port = m_ui->portLineEdit->text().toInt(&ok); if (!ok) { showErrorMsg("Invalid port"); return; } if (m_ui->serverIpLineEdit->text().isEmpty()) { showErrorMsg("Ip is empty"); return; } // if (m_socket->peerAddress().isNull()) { // qDebug("eh?"); // return; // } // TODO trasform in HTTP GET/POST/PUT requests QString req; int comboIndex = m_ui->commandCombo->currentIndex(); if (comboIndex == 0) { // ADD qDebug("[Dialog::sendPacketToServer] ADD"); } else if (comboIndex == 1) { // BAN qDebug("[Dialog::sendPacketToServer] BAN"); } else if (comboIndex == 2) { // IS_BANNED qDebug("[Dialog::sendPacketToServer] IS BANNED"); } else if (comboIndex == 3) { // WHOIS qDebug("[Dialog::sendPacketToServer] WHOIS"); req += prepareWhoisUrl(); } else { return; } m_reply = m_netManager->get(QNetworkRequest(QUrl((req)))); connect(m_reply, SIGNAL(finished()), this, SLOT(onReplyReadyRead())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError))); // m_socket->writeDatagram(prepareMessage(), QHostAddress(m_ui->serverIpLineEdit->text()), port); }
void KMMainView::slotRemove() { if (m_current) { KMTimer::self()->hold(); bool result(false); if (KMessageBox::warningYesNo(this,i18n("Do you really want to remove %1?").arg(m_current->printerName())) == KMessageBox::Yes) if (m_current->isSpecial()) { if (!(result=m_manager->removeSpecialPrinter(m_current))) showErrorMsg(i18n("Unable to remove special printer %1.").arg(m_current->printerName())); } else if (!(result=m_manager->removePrinter(m_current))) showErrorMsg(i18n("Unable to remove printer %1.").arg(m_current->printerName())); KMTimer::self()->release(result); } }
void KMMainView::slotAdd() { KMTimer::self()->hold(); int result(0); if((result = kdeprint_management_add_printer_wizard(this)) == -1) showErrorMsg(i18n("Unable to create printer.")); KMTimer::self()->release((result == 1)); }
void KMMainView::slotHardDefault() { if(m_current) { KMTimer::self()->hold(); bool result = m_manager->setDefaultPrinter(m_current); if(!result) showErrorMsg(i18n("Unable to define printer %1 as default.").arg(m_current->printerName())); KMTimer::self()->release(result); } }
void KMMainView::slotConfigure() { if(m_current) { KMTimer::self()->hold(); bool needRefresh(false); if(m_current->isSpecial()) { KMSpecialPrinterDlg dlg(this); dlg.setPrinter(m_current); if(dlg.exec()) { KMPrinter *prt = dlg.printer(); if(prt->name() != m_current->name()) m_manager->removeSpecialPrinter(m_current); m_manager->createSpecialPrinter(prt); needRefresh = true; } } else { DrMain *driver = m_manager->loadPrinterDriver(m_current, true); if(driver) { KMDriverDialog dlg(this); dlg.setCaption(i18n("Configure %1").arg(m_current->printerName())); dlg.setDriver(driver); // disable OK button for remote printer (read-only dialog) if(m_current->isRemote()) dlg.enableButtonOK(false); if(dlg.exec()) if(!m_manager->savePrinterDriver(m_current, driver)) showErrorMsg(i18n("Unable to modify settings of printer %1.").arg(m_current->printerName())); delete driver; } else showErrorMsg(i18n("Unable to load a valid driver for printer %1.").arg(m_current->printerName())); } KMTimer::self()->release(needRefresh); } }
void KMMainView::slotServerRestart() { KMTimer::self()->hold(); bool result = m_manager->restartServer(); if(!result) { showErrorMsg(i18n("Unable to restart print server.")); KMTimer::self()->release(false); } else { reset(i18n("Restarting server..."), false, false); } }
void KMMainView::slotServerConfigure() { KMTimer::self()->hold(); bool result = m_manager->configureServer(this); if(!result) { showErrorMsg(i18n("Unable to configure print server.")); KMTimer::self()->release(false); } else { reset(i18n("Configuring server..."), false, false); } }
void KMMainView::slotTest() { if (m_current) { KMTimer::self()->hold(); if (KMessageBox::warningContinueCancel(this, i18n("You are about to print a test page on %1. Do you want to continue?").arg(m_current->printerName()), TQString::null, i18n("Print Test Page"), "printTestPage") == KMessageBox::Continue) { if (KMFactory::self()->manager()->testPrinter(m_current)) KMessageBox::information(this,i18n("Test page successfully sent to printer %1.").arg(m_current->printerName())); else showErrorMsg(i18n("Unable to test printer %1.").arg(m_current->printerName())); } KMTimer::self()->release(true); } }
bool isBackendOK() { QString id = run_back_end_with("--version-id"); if (id.isEmpty()) { showErrorMsg("failed to start command line backend sg2ps"); return false; } else { return true; } }
bool LaunchSimulationBox::onTimerClock() { updateWidget(); switch (mState) { case Wait: case Init: case Play: return true; case Error: showErrorMsg(); case Finish: case Close: return false; } return false; }
void Runner::runButtonClicked() { QFileInfo rgfFile(projectPath+"/"+projectName+".rgf"); if (!rgfFile.exists() || !rgfFile.isFile()) { showErrorMsg("the data file is not created or selected yet"); return; } emit generateSetFile(); qDebug() << "Runner invokes external exe"; QStringList args; args.append(projectName); processManager->run(projectPath, args, logFile); }
bool KManualProxyDlg::validate() { KURL filteredURL; unsigned short count = 0; if ( isValidURL( mDlg->leHttp->text(), &filteredURL ) ) { mDlg->leHttp->setText( filteredURL.url() ); count++; } else setHighLight( mDlg->lbHttp, true ); if ( !mDlg->cbSameProxy->isChecked () ) { if ( isValidURL( mDlg->leHttps->text(), &filteredURL ) ) { mDlg->leHttps->setText( filteredURL.url() ); count++; } else setHighLight( mDlg->lbHttps, true ); if ( isValidURL( mDlg->leFtp->text(), &filteredURL ) ) { mDlg->leFtp->setText( filteredURL.url() ); count++; } else setHighLight( mDlg->lbFtp, true ); } if ( count == 0 ) { showErrorMsg( i18n("Invalid Proxy Setting"), i18n("One or more of the specified proxy settings are " "invalid. The incorrect entries are highlighted.") ); } return (count > 0); }
void KMMainView::slotTimer() { kdDebug() << "KMMainView::slotTimer" << endl; QPtrList< KMPrinter > *printerlist = m_manager->printerList(); bool ok = m_manager->errorMsg().isEmpty(); m_printerview->setPrinterList(printerlist); if(m_first) { if(!ok) showErrorMsg(i18n("An error occurred while retrieving the printer list.")); else { /* try to select the most appropriate printer: * - soft default owner printer * - hard default printer * - first printer */ QPtrListIterator< KMPrinter > it(*printerlist); KMPrinter *p1 = 0, *p2 = 0, *p3 = 0; while(it.current()) { if(!it.current()->isVirtual()) { if(it.current()->ownSoftDefault()) { p1 = it.current(); break; } else if(it.current()->isHardDefault()) p2 = it.current(); else if(!p3) p3 = it.current(); } ++it; } if(p1 || p2 || p3) m_printerview->setPrinter(p1 ? p1 : (p2 ? p2 : p3)); } m_first = false; } }
void KMMainView::slotChangePrinterState() { QString opname = sender()->name(); if(m_current && opname.startsWith("printer_")) { opname = opname.mid(8); KMTimer::self()->hold(); bool result(false); if(opname == "enable") result = m_manager->enablePrinter(m_current, true); else if(opname == "disable") result = m_manager->enablePrinter(m_current, false); else if(opname == "start") result = m_manager->startPrinter(m_current, true); else if(opname == "stop") result = m_manager->startPrinter(m_current, false); if(!result) showErrorMsg(i18n("Unable to modify the state of printer %1.").arg(m_current->printerName())); KMTimer::self()->release(result); } }
void Runner::onRunFinished(bool success, const QString& errorMsg) { if (!success) { showErrorMsg(errorMsg); } showLog(); bool pointerToFolderOK = false; finalProjectFolder = dirToShow(pointerToFolderOK); // Side effect: always deletes the pointer if (pointerToFolderOK && opts().getConvertToPdf()) { converter->run(finalProjectFolder); // calls onConversionFinished in the end } else { onConcatFinished(success && pointerToFolderOK); } }
bool openPDF(const QString& fileName) { QString pdf_viewer = opts().getPdfViewer(); QString nativeFileName = QDir::toNativeSeparators( fileName ); QFile file(nativeFileName); if (!file.exists()) { showErrorMsg("file "+nativeFileName+" does not exist"); return false; } else if (pdf_viewer.isEmpty()) { return openPDFWithDefault(nativeFileName); } else { return openPDFWithUserSpecified(pdf_viewer, nativeFileName); } }
bool KManualProxyDlg::getException ( QString& result, const QString& caption, const QString& value ) { QString label; // Specify the appropriate message... if ( mDlg->cbReverseProxy->isChecked() ) label = i18n("Enter the URL or address that should use the above proxy " "settings:"); else label = i18n("Enter the address or URL that should be excluded from " "using the above proxy settings:"); QString whatsThis = i18n("<qt>Enter a valid address or url.<p>" "<b><u>NOTE:</u></b> Wildcard matching such as " "<code>*.kde.org</code> is not supported. If you want " "to match any host in the <code>.kde.org</code> domain, " "e.g. <code>printing.kde.org</code>, then simply enter " "<code>.kde.org</code></qt>"); bool ok; result = KInputDialog::text( caption, label, value, &ok, 0, 0, 0, QString::null, whatsThis ); // If the user pressed cancel, do nothing... if (!ok) return false; // If the typed URL is malformed, and the filters cannot filter it // then it must be an invalid entry, if( isValidURL(result) || (result.length() >= 3 && result.startsWith("."))) return true; showErrorMsg(); return false; }
int main3(int argc, char* argv[]) { bool exit = false; std::string input = ""; TicTacToeGame* game = new TicTacToeGame(TIC_TAC_TOE_PIECE::X); showCommandsAllowed(); std::cout << game->getCurrentBoardState(); while (!exit) { std::cout << "$ "; std::getline(std::cin, input); if ((input.substr(0,1).compare("1") == 0 || input.substr(0,1).compare("2") == 0 || input.substr(0,1).compare("3") == 0) && (input.substr(2,1).compare("1") == 0 || input.substr(2,1).compare("2") == 0 || input.substr(2,1).compare("3") == 0)) { int row = std::atoi(input.substr(0,1).c_str()) - 1; int col = std::atoi(input.substr(2,1).c_str()) - 1; if (game->isMoveAllow(row, col)) { game->playerMove(row, col); std::cout << game->getCurrentBoardState(); if (!game->getCurrentState()->isFinal()) game->aiMove(); if (game->getCurrentState() != nullptr) std::cout << game->getCurrentBoardState(); } else { showErrorMsg(); } } else if (input.compare("exit") == 0) exit = true; else if (input.compare("reset") == 0) { game->resetGame(); std::cout << game->getCurrentBoardState(); } else { showErrorMsg(); showCommandsAllowed(); } if (game->getCurrentState()->isFinal() && !exit) { std::string msg = "init"; if (game->getCurrentState()->getId()->isX_Winner()) msg = "You win!"; else if (game->getCurrentState()->getId()->isO_Winner()) msg = "You lose!"; else if (game->getCurrentState()->getId()->isFull()) msg = "Draw!"; std::cout << msg << std::endl; game->resetGame(); std::cout << game->getCurrentBoardState(); } } return 0; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 校验当前填写的条件 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// bool SVConditionParam::checkCondition(MAPNODE &alertnode) { bool bNoError = true; list<string> lstCondition; list<string> lstParam; list<string> lstOperate; if(m_pErrText) m_pErrText->hide(); string szValue = m_pConditionArea->text(); if(!szValue.empty()) { int condition,param; //unsigned int nResult = getCondition(lstCondition, szValue); // nResult = getParam(lstParam, szValue); condition=getCondition(lstCondition, szValue); param= getParam(lstParam, szValue); // if(lstCondition.size() != lstParam.size() - 1) if(condition!=param-1) { bNoError = false; showErrorMsg(sv_condition_relation_error); OutputDebugString("!!!!!!!!!!!!!!!!!!!!!!!!!!lstCondition.size lstParam.size222222222222222222222\n"); char t[200]; OutputDebugString(itoa(condition,t,10)) ; OutputDebugString("\n"); OutputDebugString(itoa(param,t,10)); OutputDebugString("\n"); return bNoError; } char szCount[4] = {0}, szKey [32] = {0}; int nCount = static_cast<int>(lstCondition.size()); int nIndex = 1; string szExpression (""); if(nCount >= 1) { while(lstCondition.size()) { string szConValue = *(lstCondition.begin()); lstCondition.pop_front(); string szParamCondition = *(lstParam.begin()); lstParam.pop_front(); string szCondition (""), szReturn (""), szParamValue (""); int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition); if(nPos > 0 && !szCondition.empty()) { szReturn = szParamCondition.substr(0, nPos - 1); szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - (nPos + szCondition.length() + 1)); if(! checkParamValue(szReturn, szParamValue)) { bNoError = false; break; } } else { showErrorMsg(sv_condition_relation_error); bNoError = false; OutputDebugString("22222222222222222222222222222222222nPosszCondition empty222222222222222222222222222222"); } nIndex ++; } } if(bNoError) { string szParamCondition = *(lstParam.begin()); lstParam.pop_front(); string szCondition (""), szReturn (""), szParamValue (""); int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition); if(nPos > 0 && !szCondition.empty()) { szReturn = szParamCondition.substr(0, nPos - 1); szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - (nPos + szCondition.length() + 1)); bNoError = checkParamValue(szReturn, szParamValue); } else { showErrorMsg(sv_condition_relation_error); OutputDebugString("2222222222222222222222222222222222222inifbNoError22222222222222222222222"); bNoError = false; } } } else { showErrorMsg(sv_condition_is_null); bNoError = false; } if(bNoError) { showHelp(m_bShowHelp); } return bNoError ; }
bool SVConditionParam::checkCondition(MAPNODE &alertnode) { bool bNoError = true; list<string> lstCondition; list<string> lstParam; list<string> lstOperate; string szValue = m_pConditionArea->text(); if(!szValue.empty()) { unsigned int nResult = getCondition(lstCondition, szValue); nResult = getParam(lstParam, szValue); if(lstCondition.size() != lstParam.size() - 1) { bNoError = false; showErrorMsg(sv_condition_relation_error); return bNoError; } char szCount[4] = {0}, szKey [32] = {0}; int nCount = static_cast<int>(lstCondition.size()); int nIndex = 1; string szExpression (""); if(nCount >= 1) { while(lstCondition.size()) { string szConValue = *(lstCondition.begin()); lstCondition.pop_front(); string szParamCondition = *(lstParam.begin()); lstParam.pop_front(); string szCondition (""), szReturn (""), szParamValue (""); int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition); if(nPos > 0 && !szCondition.empty()) { szReturn = szParamCondition.substr(0, nPos - 1); szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - (nPos + szCondition.length() + 1)); if(! checkParamValue(szReturn, szParamValue)) { bNoError = false; break; } } else { showErrorMsg(sv_condition_relation_error); bNoError = false; } nIndex ++; } } if(bNoError) { string szParamCondition = *(lstParam.begin()); lstParam.pop_front(); string szCondition (""), szReturn (""), szParamValue (""); int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition); if(nPos > 0 && !szCondition.empty()) { szReturn = szParamCondition.substr(0, nPos - 1); szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - (nPos + szCondition.length() + 1)); bNoError = checkParamValue(szReturn, szParamValue); } else { showErrorMsg(sv_condition_relation_error); bNoError = false; } } } else { showErrorMsg(sv_condition_is_null); bNoError = false; } if(bNoError) { showHelp(m_bShowHelp); } return bNoError ; }
bool SVConditionParam::SaveCondition(MAPNODE &alertnode) { bool bNoError = true; list<string> lstCondition; list<string> lstParam; list<string> lstOperate; string szValue = m_pConditionArea->text(); if(!szValue.empty()) { unsigned int nResult = getCondition(lstCondition, szValue); nResult = getParam(lstParam, szValue); if(lstCondition.size() != lstParam.size() - 1) { bNoError = false; showErrorMsg(sv_condition_relation_error); return bNoError; } char szCount[4] = {0}, szKey [32] = {0}; int nCount = static_cast<int>(lstCondition.size()); int nIndex = 1; string szExpression (""); if(nCount >= 1) { while(lstCondition.size()) { string szConValue = *(lstCondition.begin()); lstCondition.pop_front(); string szParamCondition = *(lstParam.begin()); lstParam.pop_front(); string szCondition (""), szReturn (""), szParamValue (""); int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition); if(nPos > 0) { szReturn = szParamCondition.substr(0, nPos - 1); szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - (nPos + szCondition.length() + 1)); } if(! checkParamValue(szReturn, szParamValue)) { bNoError = false; break; } sprintf(szKey, "%d", nIndex); szExpression = szExpression + szKey + "#" + szConValue + "#"; sprintf(szKey, "sv_relation%d", nIndex); if((bNoError = AddNodeAttrib(alertnode, szKey, szConValue))) { sprintf(szKey, "sv_paramname%d", nIndex); if((bNoError = AddNodeAttrib(alertnode, szKey, szReturn))) { sprintf(szKey, "sv_operate%d", nIndex); if((bNoError = AddNodeAttrib(alertnode, szKey, szCondition))) { sprintf(szKey, "sv_paramvalue%d", nIndex); bNoError = AddNodeAttrib(alertnode, szKey, szParamValue); } } } if(!bNoError) break; nIndex ++; } } if(bNoError) { string szParamCondition = *(lstParam.begin()); lstParam.pop_front(); string szCondition (""), szReturn (""), szParamValue (""); int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition); if(nPos > 0) { szReturn = szParamCondition.substr(0, nPos - 1); szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - (nPos + szCondition.length() + 1)); } if(!checkParamValue(szReturn, szParamValue)) { bNoError = false; } if(bNoError) { sprintf(szKey, "%d", nIndex); szExpression = szExpression + szKey; sprintf(szKey, "sv_paramname%d", nIndex); if((bNoError = AddNodeAttrib(alertnode, szKey, szReturn))) { sprintf(szKey, "sv_operate%d", nIndex); if((bNoError = AddNodeAttrib(alertnode, szKey, szCondition))) { sprintf(szKey, "sv_paramvalue%d", nIndex); if(bNoError = AddNodeAttrib(alertnode, szKey, szParamValue)) { if(bNoError = AddNodeAttrib(alertnode, "sv_expression", szExpression)) { sprintf(szCount, "%d", nCount + 1); bNoError = AddNodeAttrib(alertnode, "sv_conditioncount", szCount); } } } } } } } else { showErrorMsg(sv_condition_is_null); bNoError = false; } return bNoError ; }