bool ewsXmlEnumReader(QXmlStreamReader &reader, QVariant &val, QVector<QString> items) { QString elmName = reader.name().toString(); QString text = reader.readElementText(); if (reader.error() != QXmlStreamReader::NoError) { qCWarningNC(EWSRES_LOG) << QStringLiteral("Failed to read %1 element - invalid content.") .arg(elmName); reader.skipCurrentElement(); return false; } int i; QVector<QString>::const_iterator it; for (it = items.cbegin(); it != items.cend(); it++, i++) { if (text == *it) { val = i; break; } } if (it == items.cend()) { qCWarningNC(EWSRES_LOG) << QStringLiteral("Failed to read %1 element - unknown value %2.") .arg(elmName).arg(text); return false; } return true; }
void mtpUpdateDcOptions(const QVector<MTPDcOption> &options) { QSet<int32> already, restart; { mtpDcOptions opts; { QReadLocker lock(mtpDcOptionsMutex()); opts = cDcOptions(); } for (QVector<MTPDcOption>::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) { const MTPDdcOption &optData(i->c_dcOption()); int32 id = optData.vid.v, idWithShift = id + (optData.vflags.v * _mtp_internal::dcShift); if (already.constFind(idWithShift) == already.cend()) { already.insert(idWithShift); mtpDcOptions::const_iterator a = opts.constFind(idWithShift); if (a != opts.cend()) { if (a.value().ip != optData.vip_address.c_string().v || a.value().port != optData.vport.v) { restart.insert(id); } } opts.insert(idWithShift, mtpDcOption(id, optData.vflags.v, optData.vip_address.c_string().v, optData.vport.v)); } } { QWriteLocker lock(mtpDcOptionsMutex()); cSetDcOptions(opts); } } for (QSet<int32>::const_iterator i = restart.cbegin(), e = restart.cend(); i != e; ++i) { MTP::restart(*i); } }
void Window::showDelayedServiceMsgs() { QVector<DelayedServiceMsg> toAdd = _delayedServiceMsgs; _delayedServiceMsgs.clear(); for (QVector<DelayedServiceMsg>::const_iterator i = toAdd.cbegin(), e = toAdd.cend(); i != e; ++i) { serviceNotification(i->first.first, i->second, i->first.second, true); } }
QBitArray OsmAnd::RoutingRulesetContext::encode( const std::shared_ptr<const ObfRoutingSectionInfo>& section, const QVector<uint32_t>& roadTypes ) { QBitArray bitset(ruleset->owner->_universalRules.size()); auto itTagValueAttribIdCache = owner->_tagValueAttribIdCache.find(section); if(itTagValueAttribIdCache == owner->_tagValueAttribIdCache.cend()) itTagValueAttribIdCache = owner->_tagValueAttribIdCache.insert(section, QMap<uint32_t, uint32_t>()); for(auto itType = roadTypes.cbegin(); itType != roadTypes.cend(); ++itType) { auto type = *itType; auto itId = itTagValueAttribIdCache->find(type); if(itId == itTagValueAttribIdCache->end()) { const auto& encodingRule = section->_d->_encodingRules[type]; assert(encodingRule); auto id = ruleset->owner->registerTagValueAttribute(encodingRule->_tag, encodingRule->_value); itId = itTagValueAttribIdCache->insert(type, id); } auto id = *itId; if(bitset.size() <= id) bitset.resize(id + 1); bitset.setBit(id); } return bitset; }
QString logVectorLong(const QVector<uint64> &ids) { if (!ids.size()) return "[void list]"; QString idsStr = QString("[%1").arg(*ids.cbegin()); for (QVector<uint64>::const_iterator i = ids.cbegin() + 1, e = ids.cend(); i != e; ++i) { idsStr += QString(", %2").arg(*i); } return idsStr + "]"; }
QVector<TacheUnitaire*> ProjetManager::getTachesProgrammable() { QVector<TacheUnitaire*> res; QVector<TacheUnitaire*> taches = this->getUnitaire(); for (QVector<TacheUnitaire*>::const_iterator it = taches.cbegin(); it != taches.cend(); ++it) { TacheUnitaire* t = *it; if(t->estProgrammable()) res.push_back(t); } return res; }
QVector<FileContainer> Documents::newerFileContainers(const QVector<FileContainer> &fileContainers) const { QVector<FileContainer> newerContainers; auto documentIsNewer = [this] (const FileContainer &fileContainer) { try { return document(fileContainer).documentRevision() != fileContainer.documentRevision(); } catch (const DocumentDoesNotExistException &) { return true; } }; std::copy_if(fileContainers.cbegin(), fileContainers.cend(), std::back_inserter(newerContainers), documentIsNewer); return newerContainers; }
void mtpUpdateDcOptions(const QVector<MTPDcOption> &options) { QSet<int32> already, restart; { mtpDcOptions opts(cDcOptions()); for (QVector<MTPDcOption>::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) { const MTPDdcOption &optData(i->c_dcOption()); if (already.constFind(optData.vid.v) == already.cend()) { already.insert(optData.vid.v); mtpDcOptions::const_iterator a = opts.constFind(optData.vid.v); if (a != opts.cend()) { if (a.value().ip != optData.vip_address.c_string().v || a.value().port != optData.vport.v) { restart.insert(optData.vid.v); } } opts.insert(optData.vid.v, mtpDcOption(optData.vid.v, optData.vhostname.c_string().v, optData.vip_address.c_string().v, optData.vport.v)); } } cSetDcOptions(opts); } for (QSet<int32>::const_iterator i = restart.cbegin(), e = restart.cend(); i != e; ++i) { MTP::restart(*i); } }
bool OsmAnd::MapRasterizer_P::containsHelper(const QVector< PointI >& points, const PointI& otherPoint) { uint32_t intersections = 0; auto itPrevPoint = points.cbegin(); auto itPoint = itPrevPoint + 1; for (const auto itEnd = points.cend(); itPoint != itEnd; itPrevPoint = itPoint, ++itPoint) { const auto& point0 = *itPrevPoint; const auto& point1 = *itPoint; if (Utilities::rayIntersect(point0, point1, otherPoint)) intersections++; } // special handling, also count first and last, might not be closed, but // we want this! const auto& point0 = points.first(); const auto& point1 = points.last(); if (Utilities::rayIntersect(point0, point1, otherPoint)) intersections++; return intersections % 2 == 1; }
void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes) { // Identify the best resolutions available for the supposed XXXXp resolutions. std::map<int, VideoMode> idealModes; idealModes[120] = VideoMode(160, 120); idealModes[240] = VideoMode(430, 240); idealModes[360] = VideoMode(640, 360); idealModes[480] = VideoMode(854, 480); idealModes[720] = VideoMode(1280, 720); idealModes[1080] = VideoMode(1920, 1080); std::map<int, int> bestModeInds; for (int i = 0; i < allVideoModes.size(); ++i) { VideoMode mode = allVideoModes[i]; // PS3-Cam protection, everything above 60fps makes no sense if (mode.FPS > 60) continue; for (auto iter = idealModes.begin(); iter != idealModes.end(); ++iter) { int res = iter->first; VideoMode idealMode = iter->second; // don't take approximately correct resolutions unless they really // are close if (mode.norm(idealMode) > 300) continue; if (bestModeInds.find(res) == bestModeInds.end()) { bestModeInds[res] = i; continue; } int index = bestModeInds[res]; VideoMode best = allVideoModes[index]; if (mode.norm(idealMode) < best.norm(idealMode)) { bestModeInds[res] = i; continue; } if (mode.norm(idealMode) == best.norm(idealMode)) { // prefer higher FPS and "better" pixel formats if (mode.FPS > best.FPS) { bestModeInds[res] = i; continue; } bool better = CameraDevice::betterPixelFormat(mode.pixel_format, best.pixel_format); if (mode.FPS >= best.FPS && better) bestModeInds[res] = i; } } } QVector<VideoMode> newVideoModes; for (auto it = bestModeInds.rbegin(); it != bestModeInds.rend(); ++it) { VideoMode mode = allVideoModes[it->second]; if (newVideoModes.empty()) { newVideoModes.push_back(mode); } else { int size = getModeSize(mode); auto result = std::find_if(newVideoModes.cbegin(), newVideoModes.cend(), [size](VideoMode mode) { return getModeSize(mode) == size; }); if (result == newVideoModes.end()) newVideoModes.push_back(mode); } } allVideoModes = newVideoModes; }