void MapleManager::init() { //Load script extensions const QStringList availableExtensions = m_engine->availableExtensions(); //Load "Qt" extensions first for(auto it = availableExtensions.cbegin(); it!= availableExtensions.cend(); ++it) { if((*it).startsWith("qt",Qt::CaseInsensitive)) { QScriptValue imported = m_engine->importExtension(*it); if(imported.isUndefined()) { if(m_engine->hasUncaughtException()) qDebug() << m_engine->uncaughtException().toString(); } } } //Load custom "server" extensions for(auto it = availableExtensions.cbegin(); it!= availableExtensions.cend(); ++it) { if(!(*it).contains(Packets::client_tag)) { QScriptValue imported = m_engine->importExtension(*it); if(imported.isUndefined()) { if(m_engine->hasUncaughtException()) qDebug() << m_engine->uncaughtException().toString(); } } } }
void ExtScript::setFilters(const QStringList _filters) { qCDebug(LOG_LIB) << "Filters" << _filters; std::for_each(_filters.cbegin(), _filters.cend(), [this](QString filter) { return updateFilter(filter); }); }
/** * @fn childrenPids */ QList<Q_PID> QueuedProcess::childrenPids() const { QStringList allDirectories = QDir("/proc").entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); QStringList directories = allDirectories.filter(QRegExp("(\\d+)")); QList<Q_PID> pids = std::accumulate(directories.cbegin(), directories.cend(), QList<Q_PID>(), [this](QList<Q_PID> &list, const QString &dir) { QFile statFile(QString("/proc/%1/stat").arg(dir)); if (!statFile.open(QIODevice::ReadOnly | QIODevice::Text)) return list; QString output = statFile.readAll(); output.remove(QRegExp("\\d+ \\(.*\\) . ")); Q_PID ppid = output.split(' ').first().toLongLong(); if (ppid == pid()) list.append(dir.toLongLong()); statFile.close(); return list; }); return pids; }
OSMAND_CORE_UTILS_API bool OSMAND_CORE_UTILS_CALL OsmAnd::Verifier::parseCommandLineArguments( const QStringList& cmdLineArgs, Configuration& cfg, QString& error ) { cfg.action = Configuration::Action::Invalid; for(auto itArg = cmdLineArgs.cbegin(); itArg != cmdLineArgs.cend(); ++itArg) { auto arg = *itArg; if(arg.startsWith("-obfsDir=")) cfg.obfDirs.append(arg.mid(strlen("-obfsDir="))); if(arg.startsWith("-obf=")) cfg.obfFiles.append(arg.mid(strlen("-obf="))); else if(arg == "-uniqueMapObjectIds") cfg.action = Configuration::Action::UniqueMapObjectIds; } if(cfg.obfDirs.isEmpty() && cfg.obfFiles.isEmpty()) { error = "no input given"; return false; } if(cfg.action == Configuration::Action::Invalid) { error = "no command given"; return false; } return true; }
QString JsScriptingComponent::getStartedScriptFromAgrs() const { // TODO: Handle optional argument ... may be it should be one more extension QStringList args = definition()->arguments(); auto it = std::find(args.cbegin(), args.cend(), "--start-script"); if (it == args.cend()) return QString(); ++it; if (it == args.cend()) { Log.e("Wrong parameters. Usage [--start-script <scriptFilePath>]"); return QString(); } return *it; }
bool Net::DownloadManager::hasSupportedScheme(const QString &url) { const QStringList schemes = instance()->m_networkManager.supportedSchemes(); return std::any_of(schemes.cbegin(), schemes.cend(), [&url](const QString &scheme) { return url.startsWith((scheme + QLatin1Char(':')), Qt::CaseInsensitive); }); }
int Settings::enterGroup(const QString& path) { QStringList parts = path.split('.'); auto it = parts.cbegin(); while(it != parts.cend()){ m_settings->beginGroup(*it); it++; } return parts.count(); }
void CountrySelectInner::updateFilter(QString filter) { filter = textSearchKey(filter); QStringList f; if (!filter.isEmpty()) { QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts); int l = filterList.size(); f.reserve(l); for (int i = 0; i < l; ++i) { QString filterName = filterList[i].trimmed(); if (filterName.isEmpty()) continue; f.push_back(filterName); } filter = f.join(' '); } if (_filter != filter) { _filter = filter; if (_filter.isEmpty()) { countriesNow = &countriesAll; } else { QChar first = _filter[0].toLower(); CountriesIds &ids(countriesByLetter[first]); QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; countriesFiltered.clear(); for (CountriesIds::const_iterator i = ids.cbegin(), e = ids.cend(); i != e; ++i) { int index = *i; CountryNames &names(countriesNames[index]); CountryNames::const_iterator nb = names.cbegin(), ne = names.cend(), ni; for (fi = fb; fi != fe; ++fi) { QString filterName(*fi); for (ni = nb; ni != ne; ++ni) { if (ni->startsWith(*fi)) { break; } } if (ni == ne) { break; } } if (fi == fe) { countriesFiltered.push_back(countriesAll[index]); } } countriesNow = &countriesFiltered; } refresh(); _sel = countriesNow->isEmpty() ? -1 : 0; update(); } }
QStringList Kleo::makeRelativeTo(const QDir &baseDir, const QStringList &fileNames) { QStringList rv; rv.reserve(fileNames.size()); std::transform(fileNames.cbegin(), fileNames.cend(), std::back_inserter(rv), [&baseDir](const QString &file) { return baseDir.relativeFilePath(file); }); return rv; }
void MainWindow::listFiles() { QStringList fileList; listFilesDetails("cel", fileList); listFilesDetails("cl2", fileList); fileList.sort(); for (QStringList::const_iterator it = fileList.cbegin(); it != fileList.cend(); it++) { ui->listView->addItem(*it); } }
void LocalImageLoader::append(const QStringList &files, const PeerId &peer, MsgId replyTo, ToPrepareMediaType t) { { QMutexLocker lock(toPrepareMutex()); for (QStringList::const_iterator i = files.cbegin(), e = files.cend(); i != e; ++i) { toPrepare.push_back(ToPrepareMedia(*i, peer, t, false, replyTo)); } } if (!thread) { thread = new QThread(); priv = new LocalImageLoaderPrivate(MTP::authedId(), this, thread); thread->start(); } emit needToPrepare(); }
QStringList CeSdkHandler::getMsBuildToolPaths() const { QSettings msbuildEntries("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\MSBuild\\ToolsVersions", QSettings::NativeFormat); const QStringList allKeys = msbuildEntries.allKeys(); QStringList toolVersionKeys; toolVersionKeys.push_back(QStringLiteral("c:\\Program Files\\MSBuild\\")); std::remove_copy_if(allKeys.cbegin(), allKeys.cend(), std::back_inserter(toolVersionKeys), ContainsPathKey()); QStringList toolVersionValues; std::transform(toolVersionKeys.constBegin(), toolVersionKeys.constEnd(), std::back_inserter(toolVersionValues), ValueFromKey(&msbuildEntries)); return toolVersionValues; }
bool RemoveTagQuery::exec(TaffyDB *db) { Tag t(tag); QStringList files = this->getFiles(); for (auto i = files.cbegin(); i != files.cend(); i++) { File f(*i); if (!f.exists()) { QString msg("File '%1' does not exist."); msg = msg.arg(*i); postWarning(msg); } db->removeTagFromFile(t, f); } return true; }
OSMAND_CORE_UTILS_API bool OSMAND_CORE_UTILS_CALL OsmAnd::Inspector::parseCommandLineArguments( const QStringList& cmdLineArgs, Configuration& cfg, QString& error ) { for(auto itArg = cmdLineArgs.cbegin(); itArg != cmdLineArgs.cend(); ++itArg) { auto arg = *itArg; if(arg == "-vaddress") cfg.verboseAddress = true; else if(arg == "-vstreets") cfg.verboseStreets = true; else if(arg == "-vstreetgroups") cfg.verboseStreetGroups = true; else if(arg == "-vbuildings") cfg.verboseBuildings = true; else if(arg == "-vintersections") cfg.verboseIntersections = true; else if(arg == "-vmap") cfg.verboseMap = true; else if(arg == "-vmapObjects") cfg.verboseMapObjects = true; else if(arg == "-vpoi") cfg.verbosePoi = true; else if(arg == "-vamenities") cfg.verboseAmenities = true; else if(arg == "-vtransport") cfg.verboseTrasport = true; else if(arg.startsWith("-zoom=")) cfg.zoom = static_cast<ZoomLevel>(arg.mid(strlen("-zoom=")).toInt()); else if(arg.startsWith("-bbox=")) { auto values = arg.mid(strlen("-bbox=")).split(","); cfg.bbox.left = values[0].toDouble(); cfg.bbox.top = values[1].toDouble(); cfg.bbox.right = values[2].toDouble(); cfg.bbox.bottom = values[3].toDouble(); } else if(arg.startsWith("-obf=")) { cfg.fileName = arg.mid(strlen("-obf=")); } } if(cfg.fileName.isEmpty()) { error = "OBF file not defined"; return false; } return true; }
void chanCompilerModule::build(const QStringList& fileNames, const QString& dec){ //默认 gcc QStringList arg; std::for_each(fileNames.cbegin(), fileNames.cend(), [&](const QString& fileName){ arg << fileName; }); arg << "-o" << dec; m_successCount = fileNames.size(); m_errorCount = 0; m_process.start("g++",arg); }
QStringList AWDBusAdaptor::ActiveServices() const { QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call( QDBus::BlockWithGui, "ListNames"); if (listServices.arguments().isEmpty()) { qCWarning(LOG_DBUS) << "Could not find any DBus service"; return {}; } QStringList arguments = listServices.arguments().first().toStringList(); return std::accumulate(arguments.cbegin(), arguments.cend(), QStringList(), [](QStringList &source, QString service) { if (service.startsWith(AWDBUS_SERVICE)) source.append(service); return source; }); }
void PlaylistModel::openFilesAndDirs0(QVector<ImageFile*> &openfiles, const QStringList &paths, int level) { if (paths.empty()) return; for (auto iter = paths.cbegin(); iter != paths.cend(); ++iter) { const QFileInfo info(*iter); if (info.isFile()) { if (ImageFile::isReadableImageFile(*iter)) { ImageFile *imgfile = new ImageFile(*iter); openfiles.append(imgfile); } else { QVector<ImageFile*> imgfiles = ImageFile::openArchive(*iter); openfiles.append(imgfiles); imgfiles.clear(); } } else if (level > 0) { QStringList newlist; const QFileInfoList entrylist = QDir(*iter).entryInfoList(); const int clen = info.canonicalPath().length(); for (auto iter2 = entrylist.cbegin(); iter2 != entrylist.cend(); ++iter2) { if (clen < iter2->canonicalPath().length()) { newlist << iter2->filePath(); } } openFilesAndDirs0(openfiles, newlist, level-1); } } }
QString FileInProjectFinder::bestMatch(const QStringList &filePaths, const QString &filePathToFind) { if (filePaths.isEmpty()) return QString(); if (filePaths.length() == 1) { if (debug) qDebug() << "FileInProjectFinder: found" << filePaths.first() << "in project files"; return filePaths.first(); } auto it = std::max_element(filePaths.constBegin(), filePaths.constEnd(), [&filePathToFind] (const QString &a, const QString &b) -> bool { return rankFilePath(a, filePathToFind) < rankFilePath(b, filePathToFind); }); if (it != filePaths.cend()) { if (debug) qDebug() << "FileInProjectFinder: found best match" << *it << "in project files"; return *it; } return QString(); }
void MapleManager::loadSettings() { QString target = QFileDialog::getOpenFileName(this->m_widget, tr("Save"), qApp->applicationDirPath(), tr("Ini files (*.ini)")); if(!target.isEmpty()) { QSettings setting(target,QSettings::IniFormat); QStringList AllKeys = setting.allKeys(); QMap<QString,QScriptValue> args; for(auto it = AllKeys.cbegin(); it != AllKeys.cend(); ++it) { const QString s = *it; args.insert(s,QScriptValue(setting.value(s).toString())); } ScriptFunctions::callAllImportsFunction(m_engine,API::Load_func,args); } }
void AddParticipantInner::updateFilter(QString filter) { _time = unixtime(); QStringList f; if (!filter.isEmpty()) { QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts); int l = filterList.size(); f.reserve(l); for (int i = 0; i < l; ++i) { QString filterName = filterList[i].trimmed(); if (filterName.isEmpty()) continue; f.push_back(filterName); } filter = f.join(' '); } if (_filter != filter) { int32 rh = (st::profileListPhotoSize + st::profileListPadding.height() * 2); _filter = filter; if (_filter.isEmpty()) { resize(width(), _contacts->list.count * rh); if (_contacts->list.count) { _sel = _contacts->list.begin; while (_sel->next->next &&& contactData(_sel)->inchat) { _sel = _sel->next; } } } else { QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; _filtered.clear(); if (!f.isEmpty()) { DialogsList *dialogsToFilter = 0; if (_contacts->list.count) { for (fi = fb; fi != fe; ++fi) { DialogsIndexed::DialogsIndex::iterator i = _contacts->index.find(fi->at(0)); if (i == _contacts->index.cend()) { dialogsToFilter = 0; break; } if (!dialogsToFilter || dialogsToFilter->count > i.value()->count) { dialogsToFilter = i.value(); } } } if (dialogsToFilter && dialogsToFilter->count) { _filtered.reserve(dialogsToFilter->count); for (DialogRow *i = dialogsToFilter->begin, *e = dialogsToFilter->end; i != e; i = i->next) { const PeerData::Names &names(i->history->peer->names); PeerData::Names::const_iterator nb = names.cbegin(), ne = names.cend(), ni; for (fi = fb; fi != fe; ++fi) { QString filterName(*fi); for (ni = nb; ni != ne; ++ni) { if (ni->startsWith(*fi)) { break; } } if (ni == ne) { break; } } if (fi == fe) { i->attached = 0; _filtered.push_back(i); } } } } _filteredSel = _filtered.isEmpty() ? -1 : 0; while (_filteredSel < _filtered.size() - 1 && contactData(_filtered[_filteredSel])->inchat) { ++_filteredSel; } resize(width(), _filtered.size() * rh); } if (parentWidget()) parentWidget()->update(); loadProfilePhotos(0); } }
OSMAND_CORE_UTILS_API bool OSMAND_CORE_UTILS_CALL OsmAnd::EyePiece::parseCommandLineArguments( const QStringList& cmdLineArgs, Configuration& cfg, QString& error ) { bool wasObfRootSpecified = false; for(auto itArg = cmdLineArgs.cbegin(); itArg != cmdLineArgs.cend(); ++itArg) { auto arg = *itArg; if (arg == "-verbose") { cfg.verbose = true; } else if (arg == "-dumpRules") { cfg.dumpRules = true; } else if (arg == "-map") { cfg.drawMap = true; } else if (arg == "-text") { cfg.drawText = true; } else if (arg == "-icons") { cfg.drawIcons = true; } else if (arg.startsWith("-stylesPath=")) { auto path = arg.mid(strlen("-stylesPath=")); QDir dir(path); if(!dir.exists()) { error = "Style directory '" + path + "' does not exist"; return false; } Utilities::findFiles(dir, QStringList() << "*.render.xml", cfg.styleFiles); } else if (arg.startsWith("-style=")) { cfg.styleName = arg.mid(strlen("-style=")); } else if (arg.startsWith("-obfsDir=")) { QDir obfRoot(arg.mid(strlen("-obfsDir="))); if(!obfRoot.exists()) { error = "OBF directory does not exist"; return false; } cfg.obfsDir = obfRoot; wasObfRootSpecified = true; } else if(arg.startsWith("-bbox=")) { auto values = arg.mid(strlen("-bbox=")).split(","); cfg.bbox.left = values[0].toDouble(); cfg.bbox.top = values[1].toDouble(); cfg.bbox.right = values[2].toDouble(); cfg.bbox.bottom = values[3].toDouble(); } else if(arg.startsWith("-zoom=")) { cfg.zoom = static_cast<ZoomLevel>(arg.mid(strlen("-zoom=")).toInt()); } else if(arg.startsWith("-tileSide=")) { cfg.tileSide = arg.mid(strlen("-tileSide=")).toInt(); } else if(arg.startsWith("-density=")) { cfg.densityFactor = arg.mid(strlen("-density=")).toFloat(); } else if(arg == "-32bit") { cfg.is32bit = true; } else if(arg.startsWith("-output=")) { cfg.output = arg.mid(strlen("-output=")); } } if(!cfg.drawMap && !cfg.drawText && !cfg.drawIcons) { cfg.drawMap = true; cfg.drawText = true; cfg.drawIcons = true; } if(!wasObfRootSpecified) cfg.obfsDir = QDir::current(); return true; }
void ContactsInner::updateFilter(QString filter) { filter = textSearchKey(filter); QStringList f; if (!filter.isEmpty()) { QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts); int l = filterList.size(); f.reserve(l); for (int i = 0; i < l; ++i) { QString filterName = filterList[i].trimmed(); if (filterName.isEmpty()) continue; f.push_back(filterName); } filter = f.join(' '); } if (_filter != filter) { int32 rh = (st::profileListPhotoSize + st::profileListPadding.height() * 2); _filter = filter; if (_filter.isEmpty()) { if (_contacts->list.count) { if (!_addContactLnk.isHidden()) _addContactLnk.hide(); resize(width(), _contacts->list.count * rh + st::contactsClose.height); _sel = _contacts->list.begin; } else { resize(width(), st::noContactsHeight); if (cContactsReceived()) { if (_addContactLnk.isHidden()) _addContactLnk.show(); } else { if (!_addContactLnk.isHidden()) _addContactLnk.hide(); } } } else { if (!_addContactLnk.isHidden()) _addContactLnk.hide(); QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; _filtered.clear(); if (!f.isEmpty()) { DialogsList *dialogsToFilter = 0; if (_contacts->list.count) { for (fi = fb; fi != fe; ++fi) { DialogsIndexed::DialogsIndex::iterator i = _contacts->index.find(fi->at(0)); if (i == _contacts->index.cend()) { dialogsToFilter = 0; break; } if (!dialogsToFilter || dialogsToFilter->count > i.value()->count) { dialogsToFilter = i.value(); } } } if (dialogsToFilter && dialogsToFilter->count) { _filtered.reserve(dialogsToFilter->count); for (DialogRow *i = dialogsToFilter->begin, *e = dialogsToFilter->end; i != e; i = i->next) { const PeerData::Names &names(i->history->peer->names); PeerData::Names::const_iterator nb = names.cbegin(), ne = names.cend(), ni; for (fi = fb; fi != fe; ++fi) { QString filterName(*fi); for (ni = nb; ni != ne; ++ni) { if (ni->startsWith(*fi)) { break; } } if (ni == ne) { break; } } if (fi == fe) { i->attached = 0; _filtered.push_back(i); } } } } _filteredSel = _filtered.isEmpty() ? -1 : 0; if (!_filtered.isEmpty()) { resize(width(), _filtered.size() * rh + st::contactsClose.height); } else { resize(width(), st::noContactsHeight); } } if (parentWidget()) parentWidget()->update(); loadProfilePhotos(0); } }
OSMAND_CORE_UTILS_API bool OSMAND_CORE_UTILS_CALL OsmAnd::Voyager::parseCommandLineArguments( const QStringList& cmdLineArgs, Configuration& cfg, QString& error ) { bool wasObfRootSpecified = false; bool wasRouterConfigSpecified = false; for(auto itArg = cmdLineArgs.cbegin(); itArg != cmdLineArgs.cend(); ++itArg) { auto arg = *itArg; if (arg.startsWith("-config=")) { QFile configFile(arg.mid(strlen("-config="))); if(!configFile.exists()) { error = "Router configuration file does not exist"; return false; } configFile.open(QIODevice::ReadOnly | QIODevice::Text); if(!RoutingConfiguration::parseConfiguration(&configFile, *cfg.routingConfig.get())) { error = "Bad router configuration"; return false; } configFile.close(); wasRouterConfigSpecified = true; } else if (arg == "-verbose") { cfg.verbose = true; } else if (arg == "-xml") { cfg.generateXml = true; } else if (arg == "-recalc") { cfg.doRecalculate = true; } else if (arg.startsWith("-obfsDir=")) { QDir obfRoot(arg.mid(strlen("-obfsDir="))); if(!obfRoot.exists()) { error = "OBF directory does not exist"; return false; } Utilities::findFiles(obfRoot, QStringList() << "*.obf", cfg.obfs); wasObfRootSpecified = true; } else if (arg.startsWith("-vehicle=")) { cfg.vehicle = arg.mid(strlen("-vehicle=")); } else if (arg.startsWith("-memlimit=")) { bool ok; cfg.memoryLimit = arg.mid(strlen("-memlimit=")).toInt(&ok); if(!ok || cfg.memoryLimit < 0) { error = "Bad memory limit"; return false; } } else if (arg.startsWith("-start=")) { auto coords = arg.mid(strlen("-start=")).split(QChar(';')); cfg.startLatitude = coords[0].toDouble(); cfg.startLongitude = coords[1].toDouble(); } else if (arg.startsWith("-waypoint=")) { auto coords = arg.mid(strlen("-waypoint=")).split(QChar(';')); auto latitude = coords[0].toDouble(); auto longitude = coords[1].toDouble(); cfg.waypoints.push_back(std::pair<double, double>(latitude, longitude)); } else if (arg.startsWith("-end=")) { auto coords = arg.mid(strlen("-end=")).split(QChar(';')); cfg.endLatitude = coords[0].toDouble(); cfg.endLongitude = coords[1].toDouble(); } else if (arg == "-left") { cfg.leftSide = true; } else if (arg.startsWith("-gpx=")) { cfg.gpxPath = arg.mid(strlen("-gpx=")); } } if(!wasObfRootSpecified) Utilities::findFiles(QDir::current(), QStringList() << "*.obf", cfg.obfs); if(cfg.obfs.isEmpty()) { error = "No OBF files loaded"; return false; } if(!wasRouterConfigSpecified) RoutingConfiguration::loadDefault(*cfg.routingConfig); return true; }