本文整理汇总了C++中qstringlist::const_iterator::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::mid方法的具体用法?C++ const_iterator::mid怎么用?C++ const_iterator::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::const_iterator
的用法示例。
在下文中一共展示了const_iterator::mid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseQstat
void SessionListWidget::parseQstat(QString const& qstat)
{
QStringList lines = qstat.split('\n');
JobDefinition *job = NULL;
QMap<QString, QString> jobSpec, jobVars;
QRegExp rxJobId("[0-9]+\\.pbs01");
QRegExp rxKey("[A-Za-z_\\.]+");
QString key(""), value("");
for(QStringList::const_iterator line = lines.begin();
line != lines.end();
line++)
{
if(line->isEmpty()) { /* empty */ }
else if(line->startsWith("Job Id:")) {
if(job != NULL) {
job->update(jobSpec);
sessions.append(*job);
delete job;
job = NULL;
jobSpec.clear();
jobVars.clear();
}
rxJobId.indexIn(*line);
job = new JobDefinition(rxJobId.cap());
}
else if(line->startsWith(" ")) { /* keys start with 4 spaces */
if(key == "Variable_List") {
QStringList vars(jobSpec[key].split(","));
for(QStringList::const_iterator i = vars.begin();
i != vars.end();
i++)
{
int eq = i->indexOf('=');
jobVars.insert(i->left(eq), i->mid(eq + 1));
}
}
rxKey.indexIn(*line);
key = rxKey.cap(0);
value = line->mid(line->indexOf('=') + 2);
jobSpec.insert(key, value);
}
else if(line->at(0) == '\t') {
/* append to the previous key */
jobSpec[key].append(line->mid(1));
}
}
if(job) {
job->update(jobSpec);
sessions.append(*job);
}
qDebug() << sessions;
}
示例2: 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));
}
}
示例3: parseStatus
bool MercurialPlugin::parseStatus(DVcsJob *job) const
{
if (job->status() != VcsJob::JobSucceeded) {
mercurialDebug() << "Job failed: " << job->output();
return false;
}
const QString dir = job->directory().absolutePath().append(QDir::separator());
mercurialDebug() << "Job succeeded for " << dir;
const QStringList output = job->output().split('\n', QString::SkipEmptyParts);
QList<QVariant> filestatus;
QSet<QUrl> conflictedFiles;
QStringList::const_iterator it = output.constBegin();
// FIXME: Revive this functionality and add tests for it!
// conflicts first
// for (; it != output.constEnd(); it++) {
// QChar stCh = it->at(0);
// if (stCh == '%') {
// it++;
// break;
// }
//
// QUrl file = QUrl::fromLocalFile(it->mid(2).prepend(dir));
//
// VcsStatusInfo status;
// status.setUrl(file);
// // FIXME: conflicts resolved
// status.setState(VcsStatusInfo::ItemHasConflicts);
//
// conflictedFiles.insert(file);
// filestatus.append(qVariantFromValue(status));
// }
// standard statuses next
for (; it != output.constEnd(); it++) {
QChar stCh = it->at(0);
QUrl file = QUrl::fromLocalFile(it->mid(2).prepend(dir));
if (!conflictedFiles.contains(file)) {
VcsStatusInfo status;
status.setUrl(file);
status.setState(charToState(stCh.toLatin1()));
filestatus.append(qVariantFromValue(status));
}
}
job->setResults(qVariantFromValue(filestatus));
return true;
}
示例4: argumentKeyValue
/*!
Searches the arguments for the key specified by \a key. If it can find the
key, it returns the value set for it. Otherwise, it returns \a defaultValue.
Arguments are specified in the following form: \c{key=value}.
*/
QString UpdateOperation::argumentKeyValue(const QString &key, const QString &defaultValue) const
{
const QString keySeparater(key + QLatin1String("="));
const QStringList tArguments(arguments());
QStringList::const_iterator it = std::find_if(tArguments.begin(), tArguments.end(),
StartsWith(keySeparater));
if (it == tArguments.end())
return defaultValue;
const QString value = it->mid(keySeparater.size());
it = std::find_if(++it, tArguments.end(), StartsWith(keySeparater));
if (it != tArguments.end()) {
qWarning() << QString::fromLatin1("There are multiple keys in the arguments calling"
" \"%1\". Only the first found \"%2\" is used: \"%3\"").arg(name(), key, arguments().join(
QLatin1String("; ")));
}
return value;
}
示例5: slotHTMLEvents
void BackendGoogleMaps::slotHTMLEvents(const QStringList& events)
{
// for some events, we just note that they appeared and then process them later on:
bool centerProbablyChanged = false;
bool mapTypeChanged = false;
bool zoomProbablyChanged = false;
bool mapBoundsProbablyChanged = false;
QIntList movedClusters;
QList<QPersistentModelIndex> movedMarkers;
QIntList clickedClusters;
// TODO: verify that the order of the events is still okay
// or that the order does not matter
for (QStringList::const_iterator it = events.constBegin(); it != events.constEnd(); ++it)
{
const QString eventCode = it->left(2);
const QString eventParameter = it->mid(2);
const QStringList eventParameters = eventParameter.split(QLatin1Char( '/' ));
if (eventCode == QLatin1String("MT"))
{
// map type changed
mapTypeChanged = true;
d->cacheMapType = eventParameter;
}
else if (eventCode == QLatin1String("MB"))
{ // NOTE: event currently disabled in javascript part
// map bounds changed
centerProbablyChanged = true;
zoomProbablyChanged = true;
mapBoundsProbablyChanged = true;
}
else if (eventCode == QLatin1String("ZC"))
{ // NOTE: event currently disabled in javascript part
// zoom changed
zoomProbablyChanged = true;
mapBoundsProbablyChanged = true;
}
else if (eventCode == QLatin1String("id"))
{
// idle after drastic map changes
centerProbablyChanged = true;
zoomProbablyChanged = true;
mapBoundsProbablyChanged = true;
}
else if (eventCode == QLatin1String("cm"))
{
/// @todo buffer this event type!
// cluster moved
bool okay = false;
const int clusterIndex = eventParameter.toInt(&okay);
KGEOMAP_ASSERT(okay);
if (!okay)
continue;
KGEOMAP_ASSERT(clusterIndex >= 0);
KGEOMAP_ASSERT(clusterIndex<s->clusterList.size());
if ((clusterIndex<0)||(clusterIndex>s->clusterList.size()))
continue;
// re-read the marker position:
GeoCoordinates clusterCoordinates;
const bool isValid = d->htmlWidget->runScript2Coordinates(
QString::fromLatin1("kgeomapGetClusterPosition(%1);").arg(clusterIndex),
&clusterCoordinates
);
KGEOMAP_ASSERT(isValid);
if (!isValid)
continue;
/// @todo this discards the altitude!
/// @todo is this really necessary? clusters should be regenerated anyway...
s->clusterList[clusterIndex].coordinates = clusterCoordinates;
movedClusters << clusterIndex;
}
else if (eventCode == QLatin1String("cs"))
{
/// @todo buffer this event type!
// cluster snapped
bool okay = false;
const int clusterIndex = eventParameters.first().toInt(&okay);
KGEOMAP_ASSERT(okay);
if (!okay)
continue;
KGEOMAP_ASSERT(clusterIndex >= 0);
KGEOMAP_ASSERT(clusterIndex<s->clusterList.size());
if ((clusterIndex<0)||(clusterIndex>s->clusterList.size()))
continue;
// determine to which marker we snapped:
okay = false;
const int snapModelId = eventParameters.at(1).toInt(&okay);
//.........这里部分代码省略.........
示例6: init
bool CliParser::init(const QStringList &args) {
argsRaw = args;
QStringList::const_iterator currentArg;
for (currentArg = argsRaw.constBegin(); currentArg != argsRaw.constEnd(); ++currentArg) {
if(currentArg->startsWith("--")) {
// long
QString name;
if(currentArg->contains("=")) {
// option
QStringList tmp = currentArg->mid(2).split("=");
name = tmp.at(0);
QString value;
// this is needed to allow --option=""
if(tmp.at(1).isNull()) value = QString("");
else value = tmp.at(1);
if(!addLongArg(CliParserArg::CliArgOption, name, value)) return false;
}
else {
// switch
name = currentArg->mid(2);
if(!addLongArg(CliParserArg::CliArgSwitch, name)) return false;
}
}
else if(currentArg->startsWith("-")) {
// short
char name;
QStringList::const_iterator nextArg = currentArg+1;
// if next arg is a short/long option/switch the current arg is one too
if(nextArg == argsRaw.constEnd() || nextArg->startsWith("-")) {
// switch
for (int i = 0; i < currentArg->mid(1).toAscii().size(); i++) {
name = currentArg->mid(1).toAscii().at(i);
if(!addShortArg(CliParserArg::CliArgSwitch, name)) return false;
}
}
// if next arg is is no option/switch it's an argument to a shortoption
else {
// option
// short options are not freely mixable with other shortargs
if(currentArg->mid(1).toAscii().size() > 1) {
qWarning() << "Warning: Shortoptions may not be combined with other shortoptions or switches";
return false;
}
QString value;
bool skipNext = false;
if(nextArg != argsRaw.constEnd()) {
value = nextArg->toLocal8Bit();
skipNext = true;
}
else value = currentArg->toLocal8Bit();
name = currentArg->mid(1).toAscii().at(0);
// we took one argument as argument to an option so skip it next time
if(skipNext) currentArg++;
if(!addShortArg(CliParserArg::CliArgOption, name, value)) return false;
}
}
else {
// we don't support plain arguments without -/--
if(currentArg->toLatin1() != argsRaw.at(0)) return false;
}
}
return true;
}
示例7: slotHTMLEvents
void BackendOSM::slotHTMLEvents(const QStringList& events)
{
// for some events, we just note that they appeared and then process them later on:
bool centerProbablyChanged = false;
bool mapTypeChanged = false;
bool zoomProbablyChanged = false;
bool mapBoundsProbablyChanged = false;
QIntList movedClusters;
QList<QPersistentModelIndex> movedMarkers;
for (QStringList::const_iterator it = events.constBegin(); it != events.constEnd(); ++it)
{
const QString eventCode = it->left(2);
const QString eventParameter = it->mid(2);
const QStringList eventParameters = eventParameter.split(QLatin1Char( '/' ));
if (eventCode == "MB")
{ // NOTE: event currently disabled in javascript part
// map bounds changed
centerProbablyChanged = true;
zoomProbablyChanged = true;
mapBoundsProbablyChanged = true;
}
else if (eventCode == "ZC")
{ // NOTE: event currently disabled in javascript part
// zoom changed
zoomProbablyChanged = true;
mapBoundsProbablyChanged = true;
}
else if (eventCode == "id")
{
// idle after drastic map changes
centerProbablyChanged = true;
zoomProbablyChanged = true;
mapBoundsProbablyChanged = true;
}
else if (eventCode == "cm")
{
// TODO: buffer this event type!
// cluster moved
bool okay = false;
const int clusterIndex = eventParameter.toInt(&okay);
if (!okay)
continue;
if ((clusterIndex < 0) || (clusterIndex > s->clusterList.size()))
continue;
// re-read the marker position:
GeoCoordinates clusterCoordinates;
const bool isValid = d->htmlWidget->runScript2Coordinates(
QString::fromLatin1("kgeomapGetClusterPosition(%1);").arg(clusterIndex),
&clusterCoordinates);
if (!isValid)
continue;
// TODO: this discards the altitude!
s->clusterList[clusterIndex].coordinates = clusterCoordinates;
movedClusters << clusterIndex;
}
else if (eventCode == "mm")
{
// TODO: buffer this event type!
// marker moved
bool okay = false;
const int markerRow = eventParameter.toInt(&okay);
if (!okay)
continue;
if ((markerRow < 0) || (markerRow > s->specialMarkersModel->rowCount()))
continue;
// re-read the marker position:
GeoCoordinates markerCoordinates;
const bool isValid = d->htmlWidget->runScript2Coordinates(
QString::fromLatin1("kgeomapGetMarkerPosition(%1);").arg(markerRow),
&markerCoordinates
);
if (!isValid)
continue;
// TODO: this discards the altitude!
const QModelIndex markerIndex = s->specialMarkersModel->index(markerRow, 0);
s->specialMarkersModel->setData(markerIndex, QVariant::fromValue(markerCoordinates), s->specialMarkersCoordinatesRole);
movedMarkers << QPersistentModelIndex(markerIndex);
}
else if (eventCode == "do")
{
// debug output:
qCDebug(LIBKGEOMAP_LOG)<<QString::fromLatin1("javascript:%1").arg(eventParameter);
}
}
if (!movedClusters.isEmpty())
//.........这里部分代码省略.........