QString QAutoGenDialog::GetFileParameter(const QString & strParam, const QString & strFilename, unsigned int iVehicle) { std::map<QString, std::vector<QString> >::iterator iterFileData = m_mapFileData.find(strFilename); if (iterFileData == m_mapFileData.end()) { QFile fileData(strFilename); if (fileData.exists() && fileData.open(QIODevice::ReadOnly | QIODevice::Text)) { Q3TextStream streamData(&fileData); QString strLine; iterFileData = m_mapFileData.insert(std::pair<QString, std::vector<QString> >(strFilename, std::vector<QString>())).first; while (!(strLine = streamData.readLine()).isNull()) { strLine = strLine.stripWhiteSpace(); if (strLine.isEmpty()) continue; iterFileData->second.push_back(strLine); } fileData.close(); } } if (iterFileData == m_mapFileData.end()) return ""; else return iterFileData->second[iVehicle % iterFileData->second.size()]; }
bool KstGuiData::matrixTagNameNotUnique(const QString &tag, bool warn, void *p) { /* verify that the tag name is not empty */ if (tag.stripWhiteSpace().isEmpty()) { if (warn) { KMessageBox::sorry(static_cast<QWidget*>(p), i18n("Empty tag names are not allowed.")); } return true; } /* verify that the tag name is not used by a data object */ KST::matrixList.lock().readLock(); KST::scalarList.lock().readLock(); if (KST::matrixList.findTag(tag) != KST::matrixList.end() || KST::scalarList.findTag(tag) != KST::scalarList.end()) { KST::scalarList.lock().readUnlock(); KST::matrixList.lock().readUnlock(); if (warn) { KMessageBox::sorry(static_cast<QWidget*>(p), i18n("%1: this name is already in use. Change it to a unique name.").arg(tag)); } return true; } KST::scalarList.lock().readUnlock(); KST::matrixList.lock().readUnlock(); return false; }
void KTextBox::fitText() { int startindex, endindex, countindex, testlength, line, column; // Map the text to the width of the widget cursorPosition( &line, &column ); countindex =-1; QString testText = text().simplifyWhiteSpace() + " "; startindex = 0; testlength = testText.length(); countindex = testText.find(" ", 0); while ((endindex = testText.find(" ", countindex+1)) > -1) { QString middle; int len; len = endindex - startindex; middle = testText.mid( startindex, len ); if (textWidth( &middle ) > width()) { testText.replace( countindex, 1, "\n" ); startindex = countindex; } countindex = endindex; } setText( testText.stripWhiteSpace() ); setCursorPosition( line, column ); }
void DTD::parseDTDElement(QString line) { QString name; QString *value; line.replace("\\end", " "); name = line.mid(10); int firstSpace = name.find(' '); name.remove(firstSpace, name.length()-firstSpace); value = new QString(line.mid(10+firstSpace)); //value->remove(0, value->find("\"")+1); value->remove(value->find(">"), 10000); parseDTDReplace(&name); parseDTDReplace(value); if ( name.startsWith("(") && name.endsWith(")") ) { name.remove(0,1); name.remove(name.length()-1,1); QStringList multipleTags = QStringList::split("|", name); QStringList::Iterator it = multipleTags.begin(); while(it != multipleTags.end()) { name = *it; name = name.stripWhiteSpace(); elements.insert(name, value); tags.append(name); //kdDebug() << "Element --- Name: " << name << " --- Value: " << *value << endl; ++it; } } else { elements.insert(name, value); tags.append(name); //kdDebug() << "Element --- Name: " << name << " --- Value: " << *value << endl; } }
static QString extractAddress(DOM::Node node) { QString rc = ";;"; QMap<QString,QString> entry; DOM::NodeList nodes = node.childNodes(); unsigned int n = nodes.length(); for (unsigned int i = 0; i < n; ++i) { DOM::Node node = nodes.item(i); DOM::NamedNodeMap map = node.attributes(); for (unsigned int j = 0; j < map.length(); ++j) { if (map.item(j).nodeName().string() != "class") { continue; } QString a = map.item(j).nodeValue().string(); if (a == "street-address") { entry["street-address"] = textForNode(node); } else if (a == "locality") { entry["locality"] = textForNode(node); } else if (a == "region") { entry["region"] = textForNode(node); } else if (a == "postal-code") { entry["postal-code"] = textForNode(node); } } } rc += entry["street-address"] + ";" + entry["locality"] + ";" + entry["region"] + ";" + entry["postal-code"] + ";" + entry["country"]; return rc.stripWhiteSpace(); }
GrepListBoxItem::GrepListBoxItem(const QString &fileName, const QString &lineNumber, const QString &text, bool showFilename) : ProcessListBoxItem( QString::null, Normal), fileName(fileName), lineNumber(lineNumber), text(text.stripWhiteSpace()), show(showFilename) { this->text.replace( QChar('\t'), QString(" ") ); }
QValidator::State MapimgValidator::validate( QString & input, int & ) const { if( input.upper() == "UNDEFINED" && m_allowUndefined ) { input = "Undefined"; return Acceptable; } QRegExp empty( QString::fromLatin1(" *-?\\.? *") ); if ( m_bottom >= 0 && input.stripWhiteSpace().startsWith(QString::fromLatin1("-")) ) return Invalid; if ( empty.exactMatch(input) ) return Intermediate; bool ok = TRUE; double entered = input.toDouble( &ok ); int nume = input.contains( 'e', FALSE ); if ( !ok ) { // explicit exponent regexp QRegExp expexpexp( QString::fromLatin1("[Ee][+-]?\\d*$") ); int eeePos = expexpexp.search( input ); if ( eeePos > 0 && nume == 1 ) { QString mantissa = input.left( eeePos ); entered = mantissa.toDouble( &ok ); if ( !ok ) return Invalid; } else if ( eeePos == 0 ) { return Intermediate; } else { return Invalid; } } QString tempInput = QString::number( entered ); int tempj = tempInput.find( '.' ); int i = input.find( '.' ); if( (i >= 0 || tempj >= 0 || input.contains("e-", FALSE)) && m_decimals == 0 ) { return Invalid; } if ( i >= 0 && nume == 0 ) { // has decimal point (but no E), now count digits after that i++; int j = i; while( input[j].isDigit() ) j++; if ( j - i > m_decimals ) return Invalid; //Intermediate; } if( entered > m_top ) return Invalid; else if ( entered < m_bottom ) return Intermediate; else return Acceptable; }
void ElogConfigurationI::save() { QString strConfiguration; QString strGroup; QString strIPAddress; QString strName; QString strUserName; QString strUserPassword; QString strWritePassword; QString strEntry; KConfig cfg("kstrc", false, false); int iPortNumber; int iIndex; strConfiguration = comboBoxConfiguration->currentText( ); iIndex = strConfiguration.find( ' ' ); if( iIndex != -1 ) { strConfiguration = strConfiguration.left( iIndex ); } iIndex = strConfiguration.toInt(); strGroup.sprintf("ELOG%d", iIndex); strIPAddress = lineEditIPAddress->text(); iPortNumber = spinBoxPortNumber->value(); strName = lineEditLogbook->text(); strUserName = lineEditUserName->text(); strUserPassword = lineEditUserPassword->text(); strWritePassword = lineEditWritePassword->text(); strIPAddress.stripWhiteSpace(); strName.stripWhiteSpace(); cfg.setGroup(strGroup); cfg.writeEntry("IPAddress", strIPAddress); cfg.writeEntry("Port", iPortNumber); cfg.writeEntry("Name", strName); cfg.writeEntry("UserName", strUserName); cfg.writeEntry("UserPassword", strUserPassword); cfg.writeEntry("WritePassword", strWritePassword); cfg.sync(); if( !strIPAddress.isEmpty() ) { strEntry.sprintf( "%d [%s:%d:%s]", iIndex, strIPAddress.ascii(), iPortNumber, strName.ascii() ); } else { strEntry.sprintf( "%d", iIndex ); } comboBoxConfiguration->changeItem( strEntry, iIndex ); }
bool cddb_playlist_decode(QStrList& list, QString& str){ bool isok = true; int pos1, pos2; pos1 = 0; pos2 = 0; list.clear(); while((pos2 = str.find(",",pos1,true)) != -1){ if(pos2 > pos1){ list.append(str.mid(pos1,pos2 - pos1)); } pos1 = pos2 + 1; } if(pos1 <(int) str.length()) list.append(str.mid(pos1,str.length())); QString check; bool ok1; int num; for(uint i = 0; i < list.count(); i++){ check = list.at(i); check = check.stripWhiteSpace(); if(check.isEmpty()){ list.remove(i); i--; continue; } if(check == QString (",")){ list.remove(i); i--; continue; } num = check.toInt(&ok1); if(!ok1 || num < 1){ list.remove(i); i--; isok = false; continue; } list.remove(i); list.insert(i, check); } /* for(uint i = 0; i < list.count(); i++){ printf("playlist %d=%s\n",i,list.at(i)); }*/ return isok; }
void SpawnMonitor::loadSpawnPoints() { QString fileName; fileName = QString(LOGDIR "/") + m_zoneName + ".sp"; if (!findFile(fileName)) { printf("Can't find spawn point file %s\n", (const char*)fileName); return; } QFile spFile(fileName); if (!spFile.open(IO_ReadOnly)) { printf( "Can't open spawn point file %s\n", (const char*)fileName ); return; } QTextStream input( &spFile ); int16_t x, y, z; unsigned long diffTime; uint32_t count; QString name; while (!input.atEnd()) { input >> x; input >> y; input >> z; input >> diffTime; input >> count; name = input.readLine(); name = name.stripWhiteSpace(); EQPoint loc(x, y, z); SpawnPoint* p = new SpawnPoint( 0, loc, name, diffTime, count ); if (p) { QString key = p->key(); if (!m_points.find(key)) { m_points.insert(key, p); emit newSpawnPoint(p); } else { printf("Warning: spawn point key already in use!\n"); delete p; } } } printf("Loaded spawn points: %s\n", (const char*)fileName); m_modified = false; }
//New saveUserLog, moved from DetailDialog. //Should create a special UserLog widget that encapsulates the "default" //message in the widget when no log exists (much like we do with dmsBox now) void SkyObject::saveUserLog( const QString &newLog ) { QFile file; QString logs; //existing logs //Do nothing if new log is the "default" message //(keep going if new log is empty; we'll want to delete its current entry) if ( newLog == (i18n("Record here observation logs and/or data on %1.").arg(name())) || newLog.isEmpty() ) return; // header label QString KSLabel ="[KSLABEL:" + name() + "]"; //However, we can't accept a star name if it has a greek letter in it: if ( type() == STAR ) { StarObject *star = (StarObject*)this; if ( name() == star->gname() ) KSLabel = "[KSLABEL:" + star->gname( false ) + "]"; //"false": spell out greek letter } file.setName( locateLocal( "appdata", "userlog.dat" ) ); //determine filename in local user KDE directory tree. if ( file.open( IO_ReadOnly)) { QTextStream instream(&file); // read all data into memory logs = instream.read(); file.close(); } //Remove old log entry from the logs text if ( ! userLog.isEmpty() ) { int startIndex, endIndex; QString sub; startIndex = logs.find(KSLabel); sub = logs.mid (startIndex); endIndex = sub.find("[KSLogEnd]"); logs.remove(startIndex, endIndex + 11); } //append the new log entry to the end of the logs text, //but only if the log is not empty if ( ! newLog.stripWhiteSpace().isEmpty() ) logs.append( KSLabel + "\n" + newLog + "\n[KSLogEnd]\n" ); //Open file for writing //FIXME: change error message to "cannot write to user log file" if ( !file.open( IO_WriteOnly ) ) { kdDebug() << i18n( "user log file could not be opened." ) << endl; return; } //Write new logs text QTextStream outstream(&file); outstream << logs; //Set the log text in the object itself. userLog = newLog; file.close(); }
void shipTo::populate() { q.prepare( "SELECT cust_number, cust_name, shipto_active, shipto_default," " shipto_cust_id," " shipto_num, shipto_name, shipto_cntct_id," " shipto_shipvia, formatScrap(shipto_commission) AS commission," " shipto_comments, shipto_shipcomments," " shipto_salesrep_id, shipto_taxauth_id, shipto_shipzone_id," " shipto_shipform_id, shipto_shipchrg_id, " " shipto_ediprofile_id, shipto_addr_id " "FROM shiptoinfo LEFT OUTER JOIN cust ON (shipto_cust_id=cust_id) " "WHERE (shipto_id=:shipto_id);" ); q.bindValue(":shipto_id", _shiptoid); q.exec(); if (q.first()) { QString commission = q.value("commission").toString(); _custid = q.value("shipto_cust_id").toInt(); _custNum->setText(q.value("cust_number").toString()); _custName->setText(q.value("cust_name").toString()); _active->setChecked(q.value("shipto_active").toBool()); _default->setChecked(q.value("shipto_default").toBool()); _shipToNumber->setText(q.value("shipto_num")); _name->setText(q.value("shipto_name")); _contact->setId(q.value("shipto_cntct_id").toInt()); _comments->setText(q.value("shipto_comments").toString()); _shippingComments->setText(q.value("shipto_shipcomments").toString()); _taxauth->setId(q.value("shipto_taxauth_id").toInt()); _shipZone->setId(q.value("shipto_shipzone_id").toInt()); _shipform->setId(q.value("shipto_shipform_id").toInt()); _shipchrg->setId(q.value("shipto_shipchrg_id").toInt()); _ediProfile->setId(q.value("shipto_ediprofile_id").toInt()); _address->setId(q.value("shipto_addr_id").toInt()); // Handle the free-form Ship Via _shipVia->setCurrentItem(-1); QString shipvia = q.value("shipto_shipvia").toString(); if (shipvia.stripWhiteSpace().length() != 0) { for (int counter = 0; counter < _shipVia->count(); counter++) if (_shipVia->text(counter) == shipvia) _shipVia->setCurrentItem(counter); if (_shipVia->id() == -1) { _shipVia->insertItem(shipvia); _shipVia->setCurrentItem(_shipVia->count() - 1); } } _salesRep->setId(q.value("shipto_salesrep_id").toInt()); _commission->setText(commission); } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
/*! \internal */ void OPimContact::replace( int key, const QString & v ) { QString value = v.stripWhiteSpace(); if ( value.isEmpty() ) mMap.remove( key ); else mMap.replace( key, value ); }
void KSSLPeerInfo::setPeerHost(QString realHost) { d->peerHost = realHost.stripWhiteSpace(); while(d->peerHost.endsWith(".")) d->peerHost.truncate(d->peerHost.length() - 1); d->peerHost = QString::fromLatin1(KNetwork::KResolver::domainToAscii(d->peerHost)); }
bool KexiSimplePrintingCommand::showPrintPreview(const KexiSimplePrintingSettings& settings, const QString& aTitleText, bool reload) { m_settings = settings; if (!m_previewEngine) m_previewEngine = new KexiSimplePrintingEngine(m_settings, this); if (reload) m_printPreviewNeedsReloading = true; bool backToPage0 = true; QString titleText(aTitleText.stripWhiteSpace()); KexiDB::Connection *conn = m_mainWin->project()->dbConnection(); KexiDB::TableOrQuerySchema tableOrQuery(conn, m_objectId); if (!tableOrQuery.table() && !tableOrQuery.query()) { //! @todo item not found return false; } if (titleText.isEmpty()) titleText = tableOrQuery.captionOrName(); if (!m_previewWindow || m_printPreviewNeedsReloading) { QString errorMessage; if (!m_previewEngine->init( *conn, tableOrQuery, titleText, errorMessage)) { if (!errorMessage.isEmpty()) KMessageBox::sorry(m_mainWin, errorMessage, i18n("Print Preview")); return false; } } if (!m_previewWindow) { backToPage0 = false; m_previewWindow = new KexiSimplePrintPreviewWindow( *m_previewEngine, tableOrQuery.captionOrName(), 0, Qt::WStyle_Customize|Qt::WStyle_NormalBorder|Qt::WStyle_Title| Qt::WStyle_SysMenu|Qt::WStyle_MinMax|Qt::WStyle_ContextHelp); connect(m_previewWindow, SIGNAL(printRequested()), this, SLOT(print())); connect(m_previewWindow, SIGNAL(pageSetupRequested()), this, SLOT(slotShowPageSetupRequested())); m_previewWindow->show(); KDialog::centerOnScreen(m_previewWindow); m_printPreviewNeedsReloading = false; } if (m_printPreviewNeedsReloading) {//dirty m_previewEngine->clear(); //! @todo progress bar... m_previewEngine->setTitleText( titleText ); m_previewWindow->setFullWidth(); m_previewWindow->updatePagesCount(); m_printPreviewNeedsReloading = false; } if (backToPage0) m_previewWindow->goToPage(0); m_previewWindow->show(); m_previewWindow->raise(); // m_previewWindow->setPagesCount(INT_MAX); //will be properly set on demand return true; }
bool CMySQLQuery::execStaticQuery(const QString &qry) { #ifdef DEBUG qDebug("CMySQLQuery::execStaticQuery()"); #endif QString q = qry.stripWhiteSpace(); return execRealStaticQuery(q, q.length()); }
//==================================== // storeData... //------------------------------------ void SaXProcess::storeData (void) { // .../ //! Store data which has been written to STDOUT after //! a previous isax process call // ---- QList<QString> data = mProc->readStdout(); QListIterator<QString> in (data); for (; in.current(); ++in) { QString line (*in.current()); QString cnr; QString key; QString val; int index = 0; QStringList tokens = QStringList::split ( ":", line ); for ( QStringList::Iterator in = tokens.begin(); in != tokens.end(); ++in ) { QString item (*in); item = item.stripWhiteSpace(); switch (index) { case 0: cnr = item; break; case 1: key = item; break; case 2: val = item; break; default: bool isNumber = false; if ((key == "Screen") || (key == "Relative")) { QRegExp idExp ("^(\\d+)$"); if (idExp.search (val,0) >= 0) { isNumber=true; } } if ( (((key == "Screen") || (key == "Relative")) && (!isNumber)) || (key == "Modes")||(key == "Virtual") ) { key = key+":"+val; val = item; } else { val = val+":"+item; } break; } index++; } if (val.isEmpty()) { continue; } addID (cnr.toInt()); setItem (key,val); } }
bool SqliteResult::reset(const QString &q) { if (!driver) return false; if (!driver->isOpen() || driver->isOpenError()) return false; setActive(false); setAt(QSql::BeforeFirst); query = q.stripWhiteSpace(); if (q.find("select", 0, false) == 0) setSelect(true); else setSelect(false); query.replace("'true'", "'1'"); query.replace("'false'", "'0'"); query.replace("=;", "= NULL;"); while (query.endsWith(";")) query.truncate(query.length() - 1); if (query.upper().endsWith("NOWAIT")) query.truncate(query.length() - 6); if (query.upper().endsWith("FOR UPDATE")) query.truncate(query.length() - 10); if (!isSelect()) { if (query.find("CREATE TABLE", 0, false) == 0) { Dataset *ds = ((SqliteDriver *) driver) ->dataBase() ->CreateDataset(); if (!ds) return false; if (!ds->exec(query.latin1())) { delete ds; return false; } delete ds; } else { if (dataSet) delete dataSet; dataSet = ((SqliteDriver *) driver) ->dataBase() ->CreateDataset(); if (!dataSet->exec(query.latin1())) return false; } return true; } if (dataSet) delete dataSet; dataSet = ((SqliteDriver *) driver) ->dataBase() ->CreateDataset(); if (dataSet->query(query.latin1())) { setActive(true); return true; } else return false; }
void MainInfo::addString(QStringList &lst, QString str) { str = str.stripWhiteSpace(); if (str.length() == 0) return; QStringList::Iterator it; for (it = lst.begin(); it != lst.end(); ++it){ if ((*it) == str) return; } lst.append(str); }
//==================================== // readDict... //------------------------------------ Q3Dict<QString> SCCFile::readDict (void) { // .../ // read the contents of the file whereas the file format // has to use a KEY=VALUE description. Comments starting // with a "#" are allowed // ---- char line[MAX_LINE_LENGTH]; while ((mHandle->readLine(line,MAX_LINE_LENGTH)) != 0) { QString string_line(line); string_line.truncate(string_line.length()-1); if ((string_line[0] == '#') || (string_line.isEmpty())) { if (mHandle->atEnd()) { break; } continue; } QString key; QString* val = new QString(); QStringList tokens = QStringList::split ( "=", string_line ); key = tokens.first(); *val = tokens.last(); *val = val->stripWhiteSpace(); key = key.stripWhiteSpace(); int bslash = val->find ('\\'); if (bslash >= 0) { *val = val->replace (bslash,2,"\n"); while ( 1 ) { bslash = val->find ('\\'); if (bslash >= 0) { *val = val->replace (bslash,2,"\n"); } else { break; } } } gtx.insert (key,val); if (mHandle->atEnd()) { break; } } mHandle->close(); return (gtx); }
void PhraseBookBox::sourceChanged( const QString& source ) { if ( lv->currentItem() != 0 ) { lv->currentItem()->setText( PhraseLVI::SourceTextShown, source.stripWhiteSpace() ); lv->currentItem()->setText( PhraseLVI::SourceTextOriginal, source ); lv->sort(); lv->ensureItemVisible( lv->currentItem() ); } }
void PhraseBookBox::targetChanged( const QString& target ) { if ( lv->currentItem() != 0 ) { lv->currentItem()->setText( PhraseLVI::TargetTextShown, target.stripWhiteSpace() ); lv->currentItem()->setText( PhraseLVI::TargetTextOriginal, target ); lv->sort(); lv->ensureItemVisible( lv->currentItem() ); } }
//--------------------------------------------------------------------------- void KXSConfigDialog::slotPreviewExited(KProcess *) { if ( mKilled ) { mKilled = false; mPreviewProc->clearArguments(); QString saver; saver.sprintf( "%s -window-id 0x%lX", mFilename.latin1(), long(mPreview->winId()) ); saver += command(); kdDebug() << "Command: " << saver << endl; unsigned int i = 0; QString word; saver = saver.stripWhiteSpace(); while ( !saver[i].isSpace() ) word += saver[i++]; //work around a KStandarDirs::findExe() "feature" where it looks in $KDEDIR/bin first no matter what and sometimes finds the wrong executable QFileInfo checkExe; QString saverdir = QString("%1/%2").arg(XSCREENSAVER_HACKS_DIR).arg(word); QString path; checkExe.setFile(saverdir); if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) { path = saverdir; } if (!path.isEmpty()) { (*mPreviewProc) << path; bool inQuotes = false; while ( i < saver.length() ) { word = ""; while ( saver[i].isSpace() && i < saver.length() ) i++; while ( (!saver[i].isSpace() || inQuotes) && i < saver.length() ) { if ( saver[i] == '\"' ) { inQuotes = !inQuotes; } else { word += saver[i]; } i++; } if (!word.isEmpty()) { (*mPreviewProc) << word; } } mPreviewProc->start(); } } else { // stops us from spawning the hack really fast, but still not the best QString path = KStandardDirs::findExe(mFilename, XSCREENSAVER_HACKS_DIR); if ( QFile::exists(path) ) { mKilled = true; slotChanged(); } } }
void TypeDesc::takeData( const QString& string ) { makeDataPrivate(); m_data->m_templateParams.clear(); ParamIterator it( "<>", string ); QString name = it.prefix(); name.remove( "*" ); name.remove( "&" ); m_data->m_cleanName = name.stripWhiteSpace(); for ( ; it; ++it ) m_data->m_templateParams.append( new TypeDescShared( *it ) ); }
void TabbedWidget::renameItem(int session_id, const QString& namep) { int position = items.findIndex(session_id); if (position == -1) return; QString name = namep.stripWhiteSpace(); captions[position] = !name.isEmpty() ? name : captions[position]; refreshBuffer(); }
void TesterStopPage::loadCustomStopRule (QString &ruleName) { Config config; QString s; config.getData(Config::TestPath, s); s.append("/" + ruleName + "/customLongStop"); QFile f(s); if (! f.open(IO_ReadOnly)) return; QTextStream stream(&f); while(stream.atEnd() == 0) { s = stream.readLine(); s = s.stripWhiteSpace(); if (! s.length()) continue; customLongStopEdit->setLine(s); } f.close(); config.getData(Config::TestPath, s); s.append("/" + ruleName + "/customShortStop"); f.setName(s); if (! f.open(IO_ReadOnly)) return; while(stream.atEnd() == 0) { s = stream.readLine(); s = s.stripWhiteSpace(); if (! s.length()) continue; customShortStopEdit->setLine(s); } f.close(); }
QValidator::State KDoubleSpinBoxValidator::validate( QString& str, int& pos ) const { QString pref = spinBox->prefix(); QString suff = spinBox->suffix(); QString suffStriped = suff.stripWhiteSpace(); uint overhead = pref.length() + suff.length(); State state = Invalid; if ( overhead == 0 ) { state = KDoubleValidator::validate( str, pos ); } else { bool stripedVersion = false; if ( str.length() >= overhead && str.startsWith(pref) && (str.endsWith(suff) || (stripedVersion = str.endsWith(suffStriped))) ) { if ( stripedVersion ) overhead = pref.length() + suffStriped.length(); QString core = str.mid( pref.length(), str.length() - overhead ); int corePos = pos - pref.length(); state = KDoubleValidator::validate( core, corePos ); pos = corePos + pref.length(); str.replace( pref.length(), str.length() - overhead, core ); } else { state = KDoubleValidator::validate( str, pos ); if ( state == Invalid ) { // stripWhiteSpace(), cf. QSpinBox::interpretText() QString special = spinBox->specialValueText().stripWhiteSpace(); QString candidate = str.stripWhiteSpace(); if ( special.startsWith(candidate) ) { if ( candidate.length() == special.length() ) { state = Acceptable; } else { state = Intermediate; } } } } } return state; }
static QString textForNode(DOM::Node node) { QString rc; DOM::NodeList nl = node.childNodes(); for (unsigned int i = 0; i < nl.length(); ++i) { DOM::Node n = nl.item(i); if (n.nodeType() == DOM::Node::TEXT_NODE) { rc += n.nodeValue().string(); } } // FIXME: entries need to be escaped for vcard/vevent return rc.stripWhiteSpace(); }
// ------------------------------------------------------------------------- void SpiceDialog::slotGetNetlist() { int i; QString s; Line += QString(QucsConv->readStdout()); while((i = Line.find('\n')) >= 0) { s = Line.left(i); Line.remove(0, i+1); s = s.stripWhiteSpace(); if(s.at(0) == '.') { if(s.left(5) != ".Def:") Comp->withSim = true; continue; } switch(textStatus) { case 0: if(s == "### TOPLEVEL NODELIST BEGIN") textStatus = 1; else if(s == "### SPICE OUTPUT NODELIST BEGIN") textStatus = 2; break; case 1: if(s == "### TOPLEVEL NODELIST END") { textStatus = 0; break; } if(s.left(2) != "# ") break; s.remove(0, 2); if(s.left(4) == "_net") NodesList->insertItem(s.remove(0, 4)); break; case 2: if(s == "### SPICE OUTPUT NODELIST END") { textStatus = 0; break; } if(s.left(2) != "# ") break; s.remove(0, 2); if(s.left(4) == "_net") PortsList->insertItem(s); // prefix "_net" is removed later on break; } } }
const QString KCDDB::Genres::cddb2i18n(const QString &genre) const { QString userDefinedGenre = genre.stripWhiteSpace(); int index = m_cddb.findIndex(userDefinedGenre); if (index != -1) { return m_i18n[index]; } else { return userDefinedGenre; } }