本文整理汇总了C++中qstringlist::const_iterator::startsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::startsWith方法的具体用法?C++ const_iterator::startsWith怎么用?C++ const_iterator::startsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::const_iterator
的用法示例。
在下文中一共展示了const_iterator::startsWith方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: getFilesHere
QStringList Config::getFilesHere(const QString& uncleanDir,
const QString& nameFilter,
const Location &location,
const QSet<QString> &excludedDirs,
const QSet<QString> &excludedFiles)
{
QString dir = location.isEmpty() ? QDir::cleanPath(uncleanDir) : QDir(uncleanDir).canonicalPath();
QStringList result;
if (excludedDirs.contains(dir))
return result;
QDir dirInfo(dir);
QStringList fileNames;
QStringList::const_iterator fn;
dirInfo.setNameFilters(nameFilter.split(QLatin1Char(' ')));
dirInfo.setSorting(QDir::Name);
dirInfo.setFilter(QDir::Files);
fileNames = dirInfo.entryList();
fn = fileNames.constBegin();
while (fn != fileNames.constEnd()) {
if (!fn->startsWith(QLatin1Char('~'))) {
QString s = dirInfo.filePath(*fn);
QString c = QDir::cleanPath(s);
if (!excludedFiles.contains(c)) {
result.append(c);
}
}
++fn;
}
dirInfo.setNameFilters(QStringList(QLatin1String("*")));
dirInfo.setFilter(QDir::Dirs|QDir::NoDotAndDotDot);
fileNames = dirInfo.entryList();
fn = fileNames.constBegin();
while (fn != fileNames.constEnd()) {
result += getFilesHere(dirInfo.filePath(*fn), nameFilter, location, excludedDirs, excludedFiles);
++fn;
}
return result;
}
示例4: QObject
QgsWFSData::QgsWFSData(
const QString& uri,
QgsRectangle* extent,
QMap<QgsFeatureId, QgsFeature*> &features,
QMap<QgsFeatureId, QString > &idMap,
const QString& geometryAttribute,
const QMap<QString, QPair<int, QgsField> >& thematicAttributes,
QGis::WkbType* wkbType )
: QObject(),
mUri( uri ),
mExtent( extent ),
mFeatures( features ),
mIdMap( idMap ),
mGeometryAttribute( geometryAttribute ),
mThematicAttributes( thematicAttributes ),
mWkbType( wkbType ),
mFinished( false ),
mFeatureCount( 0 )
{
//find out mTypeName from uri
QStringList arguments = uri.split( "&" );
QStringList::const_iterator it;
for ( it = arguments.constBegin(); it != arguments.constEnd(); ++it )
{
if ( it->startsWith( "TYPENAME", Qt::CaseInsensitive ) )
{
mTypeName = it->section( "=", 1, 1 );
//and strip away namespace prefix
QStringList splitList = mTypeName.split( ":" );
if ( splitList.size() > 1 )
{
mTypeName = splitList.at( 1 );
}
QgsDebugMsg( QString( "mTypeName is: %1" ).arg( mTypeName ) );
}
}
mEndian = QgsApplication::endian();
}
示例5: QObject
QgsWFSData::QgsWFSData(
const QString& uri,
QgsRectangle* extent,
QgsCoordinateReferenceSystem* srs,
QList<QgsFeature*> &features,
const QString& geometryAttribute,
const QSet<QString>& thematicAttributes,
QGis::WkbType* wkbType )
: QObject(),
mUri( uri ),
mExtent( extent ),
mSrs( srs ),
mFeatures( features ),
mGeometryAttribute( geometryAttribute ),
mThematicAttributes( thematicAttributes ),
mWkbType( wkbType ),
mFinished( false ),
mFeatureCount( 0 )
{
//qWarning("Name of the geometry attribute is:");
//qWarning(mGeometryAttribute.toLocal8Bit().data());
//find out mTypeName from uri
QStringList arguments = uri.split( "&" );
QStringList::const_iterator it;
for ( it = arguments.constBegin(); it != arguments.constEnd(); ++it )
{
if ( it->startsWith( "TYPENAME", Qt::CaseInsensitive ) )
{
mTypeName = it->section( "=", 1, 1 );
qWarning( "mTypeName is: %s", mTypeName.toLocal8Bit().constData() );
}
}
mEndian = QgsApplication::endian();
QObject::connect( &mHttp, SIGNAL( done( bool ) ), this, SLOT( setFinished( bool ) ) );
}
示例6: parseArguments
CodaClientApplication::ParseArgsResult CodaClientApplication::parseArguments(QString *errorMessage)
{
int argNumber = 1;
const QStringList args = QCoreApplication::arguments();
const QStringList::const_iterator cend = args.constEnd();
QStringList::const_iterator it = args.constBegin();
bool optionsEnd = false;
for (++it; it != cend; ++it) {
if (!optionsEnd && *it == QLatin1String("--")) {
optionsEnd = true;
continue;
}
if (!optionsEnd && it->startsWith(QLatin1Char('-')) && it->size() == 2) {
switch (it->at(1).toAscii()) {
case 'v':
m_verbose++;
break;
case 'd':
m_launchDebug = true;
break;
case 's':
m_installSilently = true;
break;
case 'c':
if (++it == cend) {
*errorMessage = QString::fromLatin1("Parameter missing for -c");
return ParseArgsError;
}
m_putChunkSize = it->toULongLong() * 1024;
if (!m_putChunkSize) {
*errorMessage = QString::fromLatin1("Invalid chunk size.");
return ParseArgsError;
}
break;
default:
*errorMessage = QString::fromLatin1("Invalid option %1").arg(*it);
return ParseArgsError;
}
} else {
if (!parseArgument(*it, argNumber++, errorMessage))
return ParseArgsError;
}
} //for loop
// Basic Check & init
switch (m_mode) {
case Invalid:
return ParseArgsError;
case Launch:
if (m_address.isEmpty() || !m_launchUID || m_launchBinary.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for launch.");
return ParseInitError;
}
break;
case Ping:
if (m_address.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for ping.");
return ParseInitError;
}
if (!isSerialPort(m_address)) {
*errorMessage = QString::fromLatin1("'ping' not supported for TCP/IP.");
return ParseInitError;
}
break;
case Install:
if (m_address.isEmpty() || m_installSisFile.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for install.");
return ParseInitError;
}
break;
case Uninstall:
if (!m_uninstallPackage) {
*errorMessage = QString::fromLatin1("Not enough parameters for uninstall.");
return ParseInitError;
}
break;
case Put: {
if (m_address.isEmpty() || m_putLocalFile.isEmpty() || m_putRemoteFile.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for put.");
return ParseInitError;
}
const QFileInfo fi(m_putLocalFile);
if (!fi.isFile() || !fi.isReadable()) {
*errorMessage = QString::fromLatin1("Local file '%1' not readable.").arg(m_putLocalFile);
return ParseInitError;
}
}
break;
default:
break;
}
return ParseArgsOk;
}
示例7: run
void VideoScannerThread::run()
{
RunProlog();
VideoMetadataListManager::metadata_list ml;
VideoMetadataListManager::loadAllFromDatabase(ml);
m_dbmetadata->setList(ml);
QList<QByteArray> image_types = QImageReader::supportedImageFormats();
QStringList imageExtensions;
for (QList<QByteArray>::const_iterator p = image_types.begin();
p != image_types.end(); ++p)
{
imageExtensions.push_back(QString(*p));
}
LOG(VB_GENERAL, LOG_INFO, QString("Beginning Video Scan."));
uint counter = 0;
FileCheckList fs_files;
if (m_HasGUI)
SendProgressEvent(counter, (uint)m_directories.size(),
tr("Searching for video files"));
for (QStringList::const_iterator iter = m_directories.begin();
iter != m_directories.end(); ++iter)
{
if (!buildFileList(*iter, imageExtensions, fs_files))
{
if (iter->startsWith("myth://"))
{
QUrl sgurl = *iter;
QString host = sgurl.host().toLower();
QString path = sgurl.path();
m_liveSGHosts.removeAll(host);
LOG(VB_GENERAL, LOG_ERR,
QString("Failed to scan :%1:").arg(*iter));
}
}
if (m_HasGUI)
SendProgressEvent(++counter);
}
PurgeList db_remove;
verifyFiles(fs_files, db_remove);
m_DBDataChanged = updateDB(fs_files, db_remove);
if (m_DBDataChanged)
{
QCoreApplication::postEvent(m_parent,
new VideoScanChanges(m_addList, m_movList,
m_delList));
QStringList slist;
QList<int>::const_iterator i;
for (i = m_addList.begin(); i != m_addList.end(); ++i)
slist << QString("added::%1").arg(*i);
for (i = m_movList.begin(); i != m_movList.end(); ++i)
slist << QString("moved::%1").arg(*i);
for (i = m_delList.begin(); i != m_delList.end(); ++i)
slist << QString("deleted::%1").arg(*i);
MythEvent me("VIDEO_LIST_CHANGE", slist);
gCoreContext->SendEvent(me);
}
else
gCoreContext->SendMessage("VIDEO_LIST_NO_CHANGE");
RunEpilog();
}
示例8: parse
bool MatchParser::parse()
{
QStringList::const_iterator it;
for (it = m_args.constBegin(); it != m_args.constEnd(); ++it)
{
if (!m_validOptions.contains(*it))
{
qWarning("Unknown option: \"%s\"", qPrintable(*it));
return false;
}
QString name = *it;
PrivateOption& option = m_validOptions[name];
QStringList list;
while (++it != m_args.constEnd())
{
if (it->size() > 1 && it->startsWith('-'))
{
bool ok = false;
it->toDouble(&ok);
if (!ok)
break;
}
list << *it;
}
--it;
if (!option.duplicates && contains(name))
{
qWarning("Multiple instances of option \"%s\"",
qPrintable(name));
return false;
}
if (list.size() < option.minArgs)
{
if (option.maxArgs == option.minArgs)
qWarning("Option \"%s\" needs %d argument(s)",
qPrintable(name), option.minArgs);
else
qWarning("Option \"%s\" needs at least %d argument(s)",
qPrintable(name), option.minArgs);
return false;
}
if (option.maxArgs != -1 && list.size() > option.maxArgs)
{
qWarning("Too many arguments for option \"%s\"",
qPrintable(name));
return false;
}
// Boolean option
if (list.isEmpty())
{
Option tmp = { name, QVariant(true) };
m_options.insert(option.priority, tmp);
continue;
}
QVariant value;
if (option.type == QVariant::StringList)
value.setValue(list);
else
value.setValue(list.join(" "));
if (!value.convert(option.type))
{
qWarning("Invalid value for option \"%s\": \"%s\"",
qPrintable(name),
qPrintable(list.join(" ")));
return false;
}
Option tmp = { name, value };
m_options.insert(option.priority, tmp);
}
return true;
}
示例9: 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;
}
示例10: main
int main(int argc, char* argv[])
{
#ifdef Q_OS_MAC
// call some Objective-C++
removeMacSpecificMenuItems();
// Native Mac applications do not have icons in the menus
QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
QCoreApplication::setOrganizationName("OpenChemistry");
QCoreApplication::setOrganizationDomain("openchemistry.org");
QCoreApplication::setApplicationName("Avogadro");
#ifdef Q_OS_WIN
// We need to ensure desktop OpenGL is loaded for our rendering.
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
QApplication app(argc, argv);
// Check for valid OpenGL support.
auto offscreen = new QOffscreenSurface;
offscreen->create();
auto context = new QOpenGLContext;
context->create();
context->makeCurrent(offscreen);
bool contextIsValid = context->isValid();
delete context;
delete offscreen;
if (!contextIsValid) {
QMessageBox::information(0, "Avogadro",
"This system does not support OpenGL!");
return 1;
}
// Use high-resolution (e.g., 2x) icons if available
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
// Set up the default format for our GL contexts.
QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
defaultFormat.setSamples(4);
// defaultFormat.setAlphaBufferSize(8);
QSurfaceFormat::setDefaultFormat(defaultFormat);
QStringList fileNames;
bool disableSettings = false;
#ifdef QTTESTING
QString testFile;
bool testExit = true;
#endif
QStringList args = QCoreApplication::arguments();
for (QStringList::const_iterator it = args.constBegin() + 1;
it != args.constEnd(); ++it) {
if (*it == "--test-file" && it + 1 != args.constEnd()) {
#ifdef QTTESTING
testFile = *(++it);
#else
qWarning("Avogadro called with --test-file but testing is disabled.");
return EXIT_FAILURE;
#endif
} else if (*it == "--test-no-exit") {
#ifdef QTTESTING
testExit = false;
#else
qWarning("Avogadro called with --test-no-exit but testing is disabled.");
return EXIT_FAILURE;
#endif
} else if (*it == "--disable-settings") {
disableSettings = true;
} else if (it->startsWith("-")) {
qWarning("Unknown command line option '%s'", qPrintable(*it));
return EXIT_FAILURE;
} else { // Assume it is a file name.
fileNames << *it;
}
}
Avogadro::MainWindow* window =
new Avogadro::MainWindow(fileNames, disableSettings);
#ifdef QTTESTING
window->playTest(testFile, testExit);
#endif
window->show();
#ifdef Avogadro_ENABLE_RPC
// create rpc listener
Avogadro::RpcListener listener;
listener.start();
#endif
return app.exec();
}
示例11: wmsLayerFromUrl
QgsRasterLayer* QgsRemoteOWSBuilder::wmsLayerFromUrl( const QString& url, const QString& layerName, QList<QgsMapLayer*>& layersToRemove, bool allowCaching ) const
{
QgsDebugMsg( "Entering" );
QgsRasterLayer* result = nullptr;
QString baseUrl, format, crs;
QStringList layerList, styleList;
if ( allowCaching )
{
result = qobject_cast<QgsRasterLayer*>( QgsMSLayerCache::instance()->searchLayer( url, layerName ) );
}
if ( result )
{
return result;
}
QStringList urlList = url.split( QStringLiteral( "?" ) );
if ( urlList.size() < 2 )
{
return nullptr;
}
baseUrl = urlList.at( 0 );
QStringList paramList = urlList.at( 1 ).split( QStringLiteral( "&" ) );
QStringList::const_iterator paramIt;
for ( paramIt = paramList.constBegin(); paramIt != paramList.constEnd(); ++paramIt )
{
if ( paramIt->startsWith( QLatin1String( "http" ), Qt::CaseInsensitive ) )
{
baseUrl = paramIt->split( QStringLiteral( "=" ) ).at( 1 );
}
else if ( paramIt->startsWith( QLatin1String( "FORMAT" ), Qt::CaseInsensitive ) )
{
format = paramIt->split( QStringLiteral( "=" ) ).at( 1 );
}
else if ( paramIt->startsWith( QLatin1String( "CRS" ), Qt::CaseInsensitive ) )
{
crs = paramIt->split( QStringLiteral( "=" ) ).at( 1 );
}
else if ( paramIt->startsWith( QLatin1String( "LAYERS" ), Qt::CaseInsensitive ) )
{
layerList = paramIt->split( QStringLiteral( "=" ) ).at( 1 ).split( QStringLiteral( "," ) );
}
else if ( paramIt->startsWith( QLatin1String( "STYLES" ), Qt::CaseInsensitive ) )
{
styleList = paramIt->split( QStringLiteral( "=" ) ).at( 1 ).split( QStringLiteral( "," ) );
}
}
QgsDebugMsg( "baseUrl: " + baseUrl );
QgsDebugMsg( "format: " + format );
QgsDebugMsg( "crs: " + crs );
QgsDebugMsg( "layerList first item: " + layerList.at( 0 ) );
QgsDebugMsg( "styleList first item: " + styleList.at( 0 ) );
QgsDataSourceUri uri;
uri.setParam( QStringLiteral( "url" ), baseUrl );
uri.setParam( QStringLiteral( "format" ), format );
uri.setParam( QStringLiteral( "crs" ), crs );
uri.setParam( QStringLiteral( "layers" ), layerList );
uri.setParam( QStringLiteral( "styles" ), styleList );
result = new QgsRasterLayer( uri.encodedUri(), QLatin1String( "" ), QStringLiteral( "wms" ) );
if ( !result->isValid() )
{
return nullptr;
}
//insert into cache
if ( allowCaching )
{
QgsMSLayerCache::instance()->insertLayer( url, layerName, result );
}
else
{
layersToRemove.push_back( result );
}
return result;
}