本文整理汇总了C++中qstringlist::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: score_words
static int score_words(const QStringList &al, const QStringList &bl)
{
QStringList::const_iterator ait = al.begin();
QStringList::const_iterator bit = bl.begin();
int score = 0;
for (; (ait != al.end()) && (bit != bl.end()); ++ait)
{
QStringList::const_iterator bit2 = bit;
int dist = 0;
int bscore = 0;
for (; bit2 != bl.end(); ++bit2)
{
if (*ait == *bit)
{
bscore = max(1000, 2000 - (dist * 500));
// lower score for short words
if (ait->length() < 5)
bscore /= 5 - ait->length();
break;
}
dist++;
}
if (bscore && dist < 3)
{
for (int i = 0; (i < dist) && bit != bl.end(); i++)
++bit;
}
score += bscore;
}
return score / al.size();
}
示例2: pointsFromCoordinateString
int QgsWFSData::pointsFromCoordinateString( std::list<QgsPoint>& points, const QString& coordString ) const
{
//tuples are separated by space, x/y by ','
QStringList tuples = coordString.split( mTupleSeparator, QString::SkipEmptyParts );
QStringList tuples_coordinates;
double x, y;
bool conversionSuccess;
QStringList::const_iterator tupleIterator;
for ( tupleIterator = tuples.constBegin(); tupleIterator != tuples.constEnd(); ++tupleIterator )
{
tuples_coordinates = tupleIterator->split( mCoordinateSeparator, QString::SkipEmptyParts );
if ( tuples_coordinates.size() < 2 )
{
continue;
}
x = tuples_coordinates.at( 0 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
continue;
}
y = tuples_coordinates.at( 1 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
{
continue;
}
points.push_back( QgsPoint( x, y ) );
}
return 0;
}
示例3: SetHosts
void VideoScannerThread::SetHosts(const QStringList &hosts)
{
m_liveSGHosts.clear();
QStringList::const_iterator iter = hosts.begin();
for (; iter != hosts.end(); ++iter)
m_liveSGHosts << iter->toLower();
}
示例4: parseURL
static KUrl parseURL( int mRealArgType, const QString& str )
{
if ( mRealArgType == 33 ) { // LDAP server
// The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
QStringList items = str.split( ':' );
if ( items.count() == 5 ) {
QStringList::const_iterator it = items.constBegin();
KUrl url;
url.setProtocol( "ldap" );
url.setHost( urlpart_decode( *it++ ) );
bool ok;
const int port = (*it++).toInt( &ok );
if ( ok )
url.setPort( port );
else if ( !it->isEmpty() )
kWarning(5150) <<"parseURL: malformed LDAP server port, ignoring: \"" << *it << "\"";
url.setPath( "/" ); // workaround KUrl parsing bug
url.setUser( urlpart_decode( *it++ ) );
url.setPass( urlpart_decode( *it++ ) );
url.setQuery( urlpart_decode( *it ) );
return url;
} else
kWarning(5150) <<"parseURL: malformed LDAP server:" << str;
}
// other URLs : assume wellformed URL syntax.
return KUrl( str );
}
示例5: getFilesHere
QStringList Config::getFilesHere(const QString& dir,
const QString& nameFilter,
const QSet<QString> &excludedDirs)
{
QStringList result;
if (excludedDirs.contains(dir))
return result;
QDir dirInfo(dir);
QStringList fileNames;
QStringList::const_iterator fn;
dirInfo.setNameFilters(nameFilter.split(' '));
dirInfo.setSorting(QDir::Name);
dirInfo.setFilter(QDir::Files);
fileNames = dirInfo.entryList();
fn = fileNames.constBegin();
while (fn != fileNames.constEnd()) {
if (!fn->startsWith(QLatin1Char('~')))
result.append(dirInfo.filePath(*fn));
++fn;
}
dirInfo.setNameFilters(QStringList("*"));
dirInfo.setFilter(QDir::Dirs|QDir::NoDotAndDotDot);
fileNames = dirInfo.entryList();
fn = fileNames.constBegin();
while (fn != fileNames.constEnd()) {
result += getFilesHere(dirInfo.filePath(*fn), nameFilter, excludedDirs);
++fn;
}
return result;
}
示例6: createTables
bool SQLiteDatabaseConnection::createTables()
{
bool retVal = true;
//Liste von auszuführenden Statements erstellen
QStringList statements;
statements << "PRAGMA page_size = 4096;";
statements << "PRAGMA max_page_count = 2147483646;";
statements << "PRAGMA cache_size=50000;";
statements << "PRAGMA synchronous=OFF;";
statements << "PRAGMA journal_mode=MEMORY;";
statements << "PRAGMA temp_store = MEMORY;";
statements << "CREATE TABLE IF NOT EXISTS EDGES(ID INTEGER PRIMARY KEY, STARTNODE INTEGER NOT NULL, ENDNODE INTEGER NOT NULL, PROPERTIES INTEGER NOT NULL);";
statements << "CREATE TABLE IF NOT EXISTS NODES(ID INTEGER PRIMARY KEY, LAT, LON, BUCKETID);";
//TODO: Müssen noch Indicies erstellt werden? Laut Doku sollte es so schon schnell sein.
statements << "CREATE TABLE EDGES_STREETNAME(ID INTEGER PRIMARY KEY, STREETNAME VARCHAR);";
//Alle Statements der Liste ausführen in einer Transaktion
//retVal = this->beginTransaction();
QStringList::const_iterator it;
for (it = statements.constBegin(); it != statements.constEnd(); it++)
{
retVal &= execCreateTableStatement(it->toStdString());
}
//retVal &= this->endTransaction();
return retVal;
}
示例7: DataVariant
const DataVariant& DynamicObjectImp::getAttributeByPath(QStringList pathComponents) const
{
static DataVariant sEmptyVariant;
QString finalName = pathComponents.back();
pathComponents.pop_back();
string loopType = "DynamicObject";
const DynamicObject* pCurrentObj = dynamic_cast<const DynamicObject*>(this);
for (QStringList::const_iterator iter = pathComponents.begin();
iter != pathComponents.end(); ++iter)
{
if ( (pCurrentObj == NULL) || loopType != "DynamicObject")
{
sEmptyVariant = DataVariant();
return sEmptyVariant;
}
const DataVariant& attrValue = pCurrentObj->getAttribute(iter->toStdString());
loopType = attrValue.getTypeName();
pCurrentObj = attrValue.getPointerToValue<DynamicObject>();
}
if (pCurrentObj == NULL)
{
sEmptyVariant = DataVariant();
return sEmptyVariant;
}
return pCurrentObj->getAttribute(finalName.toStdString());
}
示例8: if
/** @short Find a message body part through its slash-separated string path */
Imap::Mailbox::TreeItemPart *MsgPartNetAccessManager::pathToPart(const QModelIndex &message, const QString &path)
{
QStringList items = path.split('/', QString::SkipEmptyParts);
const Mailbox::Model *model = 0;
Imap::Mailbox::TreeItem *target = Mailbox::Model::realTreeItem(message, &model);
Q_ASSERT(model);
Q_ASSERT(target);
bool ok = ! items.isEmpty(); // if it's empty, it's a bogous URL
for (QStringList::const_iterator it = items.constBegin(); it != items.constEnd(); ++it) {
uint offset = it->toUInt(&ok);
if (!ok) {
// special case, we have to dive into that funny, irregular special parts now
if (*it == QLatin1String("HEADER"))
target = target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_HEADER);
else if (*it == QLatin1String("TEXT"))
target = target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_TEXT);
else if (*it == QLatin1String("MIME"))
target = target->specialColumnPtr(0, Imap::Mailbox::TreeItem::OFFSET_MIME);
else
return 0;
continue;
}
if (offset >= target->childrenCount(const_cast<Mailbox::Model *>(model))) {
return 0;
}
target = target->child(offset, const_cast<Mailbox::Model *>(model));
}
return dynamic_cast<Imap::Mailbox::TreeItemPart *>(target);
}
示例9: parseString
void Chatbox::parseString(QString str) {
if (str[0] != '!') {
emit message(str);
return;
}
str[0] = ' ';
str = str.trimmed().toLower();
QStringList list = str.split(QRegExp("\\s+"));
QStringList::const_iterator it = list.begin();
if (it->contains(rgxPos)) {
emit playStone(Position(*it));
} else if (*it == "pass" || *it == "p") {
emit pass();
} else if (*it == "undo" || *it == "u") {
emit undo();
} else if (*it == "kill" || *it == "k") {
if (++it == list.end() || !it->contains(rgxPos))
display("Expected position as second argument.");
else
emit kill(Position(*it));
} else if (*it == "exit" || *it == "e") {
emit exit();
} else if (*it == "connect" || *it == "c") {
if (++it != list.end()) {
emit setHost(*it);
if (++it != list.end()) {
emit setPort(it->toInt());
}
}
emit cl_connect();
} else if (*it == "disconnect" || *it == "dc") {
emit cl_disconnect();
} else if (*it == "yes" || *it == "y") {
emit confirm(true);
} else if (*it == "no" || *it == "n") {
emit confirm(false);
} else if (*it == "save" || *it == "s") {
if (++it == list.end())
display("Expected filename as second argument.");
else
emit writeLogToDisk(*it);
} else if (*it == "help" || *it == "h" ) {
display("4DGo -- A four-dimensional goban for online play.");
display("All commands start with a '!'. Any input that does not is treated as a chat message. All comands are case-insensitive.");
display(" Commands:");
display("!connect [hostname] [port]: connect to the game server. By default, localhost:15493 will be used.");
display("!disconnect: break connection to server and clear the goban.");
display("!A4d4: on slice A4 (top-left), on intersection d4 (top-right).");
display("!pass: end your turn without playing a stone.");
display("!undo: request that your last move be undone.");
display("!yes: allow the action your opponent requested (usually an undo or kill).");
display("!yes: refuse to allow the action your opponent requested (usually an undo or kill).");
display("!kill: request a certain group to be immediately taken off the board. Useful in endgame, to not need to play out all captures.");
display("!save filename: save the current history to file filename.");
display("!exit: disconnect and close the window.");
} else {
tbCBox_->append(QString("Unknown command: ")+*it);
}
}
示例10: list
std::vector<std::string> const MergeGeometriesDialog::getSelectedGeometries() const
{
std::vector<std::string> indexList;
QStringList const& list (_selGeo->stringList());
for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
indexList.push_back(it->toStdString());
return indexList;
}
示例11: setEnvironment
void MakefileFactory::setEnvironment(const QStringList &env)
{
for (QStringList::const_iterator it = env.begin(); it != env.end(); ++it) {
int idx = it->indexOf(QLatin1Char('='));
if (idx >= 0)
m_environment.insert(it->left(idx), it->mid(idx + 1));
}
}
示例12: if
void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset )
{
//data defined properties
double scaledWidth = 0;
if ( mStrokeWidthExpression )
{
scaledWidth = mStrokeWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble()
* QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}
else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
{
scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}
//color
if ( mStrokeColorExpression )
{
pen.setColor( QgsSymbolLayerV2Utils::decodeColor( mStrokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}
//offset
offset = mOffset;
if ( mLineOffsetExpression )
{
offset = mLineOffsetExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}
//dash dot vector
if ( mDashPatternExpression )
{
QVector<qreal> dashVector;
QStringList dashList = mDashPatternExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString().split( ";" );
QStringList::const_iterator dashIt = dashList.constBegin();
for ( ; dashIt != dashList.constEnd(); ++dashIt )
{
dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / mPen.widthF() );
}
pen.setDashPattern( dashVector );
}
//join style
if ( mJoinStyleExpression )
{
QString joinStyleString = mJoinStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
pen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( joinStyleString ) );
}
//cap style
if ( mCapStyleExpression )
{
QString capStyleString = mCapStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
pen.setCapStyle( QgsSymbolLayerV2Utils::decodePenCapStyle( capStyleString ) );
}
}
示例13: getParameterValuesByWords
QStringList CMDLineRegistryUtils::getParameterValuesByWords( const QString & paramName, int startWith ) {
QStringList words;
QStringList res = getParameterValues( paramName, startWith );
QStringList::const_iterator it = res.constBegin();
while( it != res.constEnd() ) {
words << it->split( QRegExp("\\s"), QString::SkipEmptyParts );
++it;
}
return words;
}
示例14: readSelectedFeatures
DataSetPtr readSelectedFeatures(char *filename, FeatureMappingPtr featureMapping)
{
SelectedFeatures selectedFeatures;
OverlappingFeatures overlappingFeatures;
QFile featureFile(filename);
if (!featureFile.open(QFile::ReadOnly))
{
qCritical() << "Could not open" << filename << "for reading!";
return QSharedPointer<DataSet>(new DataSet(selectedFeatures, overlappingFeatures));
}
QTextStream featureStream(&featureFile);
while(!featureStream.atEnd())
{
QString featureLine(featureStream.readLine());
QStringList lineParts = featureLine.split("\t");
size_t featureNr = lineParts[0].toULong();
QString featureName = (*featureMapping)[featureNr];
SelectedFeature feature(featureName, lineParts[1].toDouble(),
lineParts[2].toDouble());
selectedFeatures.push_back(feature);
QString overlapLine(featureStream.readLine());
QStringList overlapParts = overlapLine.split("\t", QString::SkipEmptyParts);
QVector<OverlappingFeature> overlaps;
double normOverlapSum = 0.0;
double normActivationSum = 0.0;
for (QStringList::const_iterator iter = overlapParts.begin();
iter != overlapParts.end(); ++iter)
{
QStringList overlap = iter->split('#');
double normOverlap = overlap[0].toDouble();
if (normOverlap > 0.0)
normOverlapSum += normOverlap;
else if (normOverlap < 0.0)
normActivationSum += fabs(normOverlap);
OverlappingFeature overlappingFeature(
(*featureMapping)[overlap[1].toUInt()],
normOverlap);
overlaps.push_back(overlappingFeature);
}
overlappingFeatures[featureName] = Overlap(normOverlapSum, normActivationSum,
overlaps);
}
return QSharedPointer<DataSet>(new DataSet(selectedFeatures, overlappingFeatures));
}
示例15: parseCommandLineArgs
bool QDesigner::parseCommandLineArgs(QStringList &fileNames, QString &resourceDir)
{
const QStringList args = arguments();
const QStringList::const_iterator acend = args.constEnd();
QStringList::const_iterator it = args.constBegin();
for (++it; it != acend; ++it) {
const QString &argument = *it;
do {
// Arguments
if (!argument.startsWith(QLatin1Char('-'))) {
if (!fileNames.contains(argument))
fileNames.append(argument);
break;
}
// Options
if (argument == QStringLiteral("-server")) {
m_server = new QDesignerServer();
printf("%d\n", m_server->serverPort());
fflush(stdout);
break;
}
if (argument == QStringLiteral("-client")) {
bool ok = true;
if (++it == acend) {
qWarning("** WARNING The option -client requires an argument");
return false;
}
const quint16 port = it->toUShort(&ok);
if (ok) {
m_client = new QDesignerClient(port, this);
} else {
qWarning("** WARNING Non-numeric argument specified for -client");
return false;
}
break;
}
if (argument == QStringLiteral("-resourcedir")) {
if (++it == acend) {
qWarning("** WARNING The option -resourcedir requires an argument");
return false;
}
resourceDir = QFile::decodeName(it->toLocal8Bit());
break;
}
if (argument == QStringLiteral("-enableinternaldynamicproperties")) {
QDesignerPropertySheet::setInternalDynamicPropertiesEnabled(true);
break;
}
const QString msg = QString::fromUtf8("** WARNING Unknown option %1").arg(argument);
qWarning("%s", qPrintable(msg));
} while (false);
}
return true;
}