QHash<Cell*, QSet<char> > Grid::broadenDomains(Cell *unsetCell) { QQueue<Cell*> dirtyCells; QHash<Cell*, QSet<char> > diff; // initialize set of cells to check auto depCells = unsetCell->dependentCells(); for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ){ dirtyCells.enqueue(*dep); } diff.insert(unsetCell, QSet<char>()); while( !dirtyCells.empty() ) { Cell* dirty = dirtyCells.dequeue(); // broaden domain and re-restrict to check for changes const QSet<char> oldDomain = dirty->domain(); dirty->broadenDomain(); dirty->restrictDomain(); // if there are changes, enqueue dirty cell's dependents if( dirty->domain() != oldDomain ){ diff.insert(dirty, QSet<char>()); auto depCells = dirty->dependentCells(); for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ){ dirtyCells.enqueue(*dep); } } } unsetCell->restrictDomain(); return diff; }
/* Returns the time to wait for the next timer, or null if no timers are waiting. */ bool QTimerInfoList::timerWait(timeval &tm) { timeval currentTime = updateCurrentTime(); repairTimersIfNeeded(); // Find first waiting timer not already active QTimerInfo *t = 0; for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) { if (!(*it)->inTimerEvent) { t = *it; break; } } if (!t) return false; if (currentTime < t->timeout) { // time to wait tm = t->timeout - currentTime; } else { // no time to wait tm.tv_sec = 0; tm.tv_usec = 0; } return true; }
void ItemEncryptedScriptable::decryptItems() { const auto dataValueList = call("selectedItemsData").toList(); QVariantList dataList; for (const auto &itemDataValue : dataValueList) { auto itemData = itemDataValue.toMap(); const auto encryptedBytes = itemData.value(mimeEncryptedData).toByteArray(); if ( !encryptedBytes.isEmpty() ) { itemData.remove(mimeEncryptedData); const auto decryptedBytes = decrypt(encryptedBytes); if (decryptedBytes.isEmpty()) return; const auto decryptedItemData = call("unpack", QVariantList() << decryptedBytes).toMap(); for (auto it = decryptedItemData.constBegin(); it != decryptedItemData.constEnd(); ++it) itemData.insert(it.key(), it.value()); } dataList.append(itemData); } call( "setSelectedItemsData", QVariantList() << QVariant(dataList) ); }
AccessControlPage::AccessControlPage() : ConfigurationPage(), ui(new Ui::AccessControlPage), m_accessControlRulesModel( this ), m_accessControlRulesTestDialog( this ) { ui->setupUi(this); if( VeyonCore::accessControlDataBackendManager().configuredBackend() == nullptr ) { QMessageBox::critical( this, tr( "Missing access control data backend" ), tr( "No default access control backend plugin was found. " "Please check your installation!" ) ); qFatal( "AccessControlPage: missing default access control data backend" ); } const auto backends = VeyonCore::accessControlDataBackendManager().availableBackends(); for( auto it = backends.constBegin(), end = backends.constEnd(); it != end; ++it ) { ui->accessControlDataBackend->addItem( it.value(), it.key() ); } ui->accessControlRulesView->setModel( &m_accessControlRulesModel ); updateAccessGroupsLists(); updateAccessControlRules(); }
bool KEntryMap::revertEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags) { Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0); Iterator entry = findEntry(group, key, flags); if (entry != end()) { //qDebug() << "reverting" << entry.key() << " = " << entry->mValue; if (entry->bReverted) { // already done before return false; } KEntryKey defaultKey(entry.key()); defaultKey.bDefault = true; //qDebug() << "looking up default entry with key=" << defaultKey; const ConstIterator defaultEntry = constFind(defaultKey); if (defaultEntry != constEnd()) { Q_ASSERT(defaultEntry.key().bDefault); //qDebug() << "found, update entry"; *entry = *defaultEntry; // copy default value, for subsequent lookups } else { entry->mValue = QByteArray(); } entry->bDirty = true; entry->bReverted = true; // skip it when writing out to disk //qDebug() << "Here's what we have now:" << *this; return true; } return false; }
/*! * \brief MainWindow::DisplayResults */ void MainWindow::displayResults() { // ui->qwtPlot->detachItems( QwtPlotItem::Rtti_PlotCurve, false ); // ui->qwtPlot->replot(); // const auto errorVector = Facade::getInstance().getErrors(); // QVector < QPointF > points( errorVector.size() ); // quint32 counter = 0; // auto pointsIt = points.begin(); // // Create a // for ( auto errorIt = errorVector.constBegin(); errorIt != errorVector.constEnd(); ++ errorIt, ++ pointsIt, ++ counter ) { // (*pointsIt) = QPointF( counter, (*errorIt) ); // } // QwtPointSeriesData * data = new QwtPointSeriesData(points); // curve.setData(data); // curve.attach( ui->qwtPlot ); // ui->qwtPlot->replot(); ui->qwtPlot->detachItems( QwtPlotItem::Rtti_PlotCurve, false ); ui->qwtPlot->replot(); const auto errorVector = Facade::getInstance().getErrors(); QVector < QPointF > points( errorVector.size() ); quint32 counter = 0; auto pointsIt = points.begin(); // Create a for ( auto errorIt = errorVector.constBegin(); errorIt != errorVector.constEnd(); ++ errorIt, ++ pointsIt, ++ counter ) { (*pointsIt) = QPointF( counter, (*errorIt) ); } QwtPointSeriesData * data = new QwtPointSeriesData(points); curve.setData(data); // curve.setSamples( QPolygonF ( points ) ); curve.attach( ui->qwtPlot ); ui->qwtPlot->replot(); }
void LoanAssumption::SetAliases(const QString& val) { ClearAliases(); auto TempAl = val.split("$,$"); for (auto i = TempAl.constBegin(); i != TempAl.constEnd();++i) { AddAlias(*i); } }
void SpecialConfigRequest::dnsFinished() { if (!_dnsReply) { return; } auto result = _dnsReply->readAll(); _dnsReply.release()->deleteLater(); // Read and store to "entries" map all the data bytes from this response: // { .., "Answer": [ { .., "data": "bytes1", .. }, { .., "data": "bytes2", .. } ], .. } auto entries = QMap<int, QString>(); auto error = QJsonParseError { 0, QJsonParseError::NoError }; auto document = QJsonDocument::fromJson(result, &error); if (error.error != QJsonParseError::NoError) { LOG(("Config Error: Failed to parse dns response JSON, error: %1").arg(error.errorString())); } else if (!document.isObject()) { LOG(("Config Error: Not an object received in dns response JSON.")); } else { auto response = document.object(); auto answerIt = response.find(qsl("Answer")); if (answerIt == response.constEnd()) { LOG(("Config Error: Could not find Answer in dns response JSON.")); } else if (!(*answerIt).isArray()) { LOG(("Config Error: Not an array received in Answer in dns response JSON.")); } else { for (auto elem : (*answerIt).toArray()) { if (!elem.isObject()) { LOG(("Config Error: Not an object found in Answer array in dns response JSON.")); } else { auto object = elem.toObject(); auto dataIt = object.find(qsl("data")); if (dataIt == object.constEnd()) { LOG(("Config Error: Could not find data in Answer array entry in dns response JSON.")); } else if (!(*dataIt).isString()) { LOG(("Config Error: Not a string data found in Answer array entry in dns response JSON.")); } else { auto data = (*dataIt).toString(); entries.insertMulti(INT_MAX - data.size(), data); } } } } } auto text = QStringList(entries.values()).join(QString()); handleResponse(text.toLatin1()); }
void IngredientPropertyList::filter( int ingredientID, IngredientPropertyList *filteredList ) { filteredList->clear(); IngredientPropertyList::const_iterator prop_it; for ( prop_it = constBegin(); prop_it != constEnd(); ++prop_it ) { if ( (*prop_it).ingredientID == ingredientID ) filteredList->append( *prop_it ); } }
void EventList::removeAllEventsForObject(QObject *widget) { EventList::ConstIterator endIt = constEnd(); for (EventList::ConstIterator it = constBegin(); it != endIt; ++it) { if (((*it)->sender() == widget) || ((*it)->receiver() == widget)) removeEvent(*it); } }
Element ElementList::element( const QName &qualifiedName ) const { const_iterator it = constBegin(); for ( ; it != constEnd(); ++it ) if ((*it).qualifiedName() == qualifiedName) return *it; //qDebug() << "Simple type" << qualifiedName << "not found"; return Element(); }
QHash<Cell*, QSet<char> > Grid::fixArcConsistency(Cell* dirtyCell) { QHash<Cell*, QSet<char> > changes; QQueue<Cell*> dirtyCells; // initialize the set of cells to check // if no dirty cell specified, assume all are dirty if( dirtyCell != nullptr ){ auto depCells = dirtyCell->dependentCells(); for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ) { dirtyCells.enqueue(*dep); } } else { for( int i=0; i<cells.count(); i++ ){ dirtyCells.enqueue( cells.at(i) ); } } // loop until there are no more dirty cells while( !dirtyCells.empty() ) { // update domain of dirty cell Cell* cell = dirtyCells.dequeue(); QSet<char> cellChanges = cell->restrictDomain(); // if the domain changes if( !cellChanges.empty() ) { // add changes to the running diff changes[cell] += cellChanges; // add dependents to queue auto depCells = cell->dependentCells(); for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ) { dirtyCells.enqueue(*dep); } } // else nothing to be done } return changes; }
inline optional<QVariant> objectMember(const QVariant& value, const char* key) { auto map = value.toMap(); auto iter = map.constFind(key); if (iter != map.constEnd()) { return iter.value(); } else { return {}; } }
TriggersResults::TrigRes TriggersResults::GetResult(quint32 TrigType, const QDate& RefDate)const { Q_D(const TriggersResults); const auto Tempmap = d->m_Results.value(TrigType, nullptr); if (Tempmap) { auto MapIter = Tempmap->constFind(RefDate); if (MapIter == Tempmap->constEnd()) return TrigRes::trNA; return (MapIter.value() ? TrigRes::trTrue : TrigRes::trFalse); } return TrigRes::trNA; }
int IngredientPropertyList::findByName( const QString &name ) { IngredientPropertyList::const_iterator prop_it; for ( prop_it = constBegin(); prop_it != constEnd(); ++prop_it ) { if ( (*prop_it).name == name ) return (*prop_it).id; } return -1; }
/******************************************************************************* NTcpServerAuthSessionHash *******************************************************************************/ const QString NTcpServerAuthSessionHash::sessionId(const QString & address, const QString & login) const { QHash<QString, NTcpServerAuthSession>::const_iterator i = constBegin(); while (i != constEnd()) { if (i.value().address() == address && i.value().login() == login) return i.key(); ++i; } return ""; }
QVariantMap AbstractListModel::get(int row) { auto roles = roleNames(); QVariantMap map; auto index = createIndex(row, 0); for (auto it = roles.constBegin(); it != roles.constEnd(); it++) { auto value = data(index, it.key()); map.insert(it.value(), value); } return map; }
KExiv2::AltLangMap CaptionsMap::toAltLangMap() const { KExiv2::AltLangMap map; for (CaptionsMap::const_iterator it = constBegin(); it != constEnd(); ++it) { map.insert(it.key(), (*it).caption); } return map; }
KExiv2::AltLangMap CaptionsMap::datesList() const { KExiv2::AltLangMap map; for (CaptionsMap::const_iterator it = constBegin(); it != constEnd(); ++it) { map.insert(it.key(), (*it).date.toString(Qt::ISODate)); } return map; }
MetaEngine::AltLangMap CaptionsMap::authorsList() const { MetaEngine::AltLangMap map; for (CaptionsMap::const_iterator it = constBegin(); it != constEnd(); ++it) { map.insert(it.key(), (*it).author); } return map; }
void QgsOgrDataCollectionItem::deleteCollection( const QString &path, QPointer<QgsDataItem> parent ) { const bool isFolder = QFileInfo( path ).isDir(); const QString type = isFolder ? tr( "folder" ) : tr( "file" ); const QString typeCaps = isFolder ? tr( "Folder" ) : tr( "File" ); const QString title = QObject::tr( "Delete %1" ).arg( type ); // Check if the layer is in the project const QgsMapLayer *projectLayer = nullptr; const auto mapLayers = QgsProject::instance()->mapLayers(); for ( auto it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it ) { const QVariantMap parts = QgsProviderRegistry::instance()->decodeUri( it.value()->dataProvider()->name(), it.value()->source() ); if ( parts.value( QStringLiteral( "path" ) ).toString() == path ) { projectLayer = it.value(); } } if ( ! projectLayer ) { const QString confirmMessage = QObject::tr( "Are you sure you want to delete '%1'?" ).arg( path ); if ( QMessageBox::question( nullptr, title, confirmMessage, QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; bool res = false; if ( isFolder ) { // e.g. the abomination which is gdb QDir dir( path ); res = dir.removeRecursively(); } else { res = QFile::remove( path ); } if ( !res ) { QMessageBox::warning( nullptr, title, tr( "Could not delete %1." ).arg( type ) ); } else { QMessageBox::information( nullptr, title, tr( "%1 deleted successfully." ).arg( typeCaps ) ); if ( parent ) parent->refresh(); } } else { QMessageBox::warning( nullptr, title, QObject::tr( "The %1 '%2' cannot be deleted because it is in the current project as '%3'," " remove it from the project and retry." ).arg( type, path, projectLayer->name() ) ); } }
void Group::debug() { qDebug(QString("Count: %1 - Liberties: %2").arg(count()).arg(liberties)); const_iterator i; for (i = constBegin(); i != constEnd(); i++) { Stone *s = *i; qDebug(" (%d, %d) %s", s->posX(), s->posY(), s->getColor() == stoneBlack ? "B" : "W"); } }
void NTcpServerAuthSessionHash::removeExpired() { QStringList toRemove; QHash<QString, NTcpServerAuthSession>::const_iterator i = constBegin(); while (i != constEnd()) { if (i.value().isExpired()) toRemove.append(i.key()); ++i; } while (toRemove.count() > 0) remove(toRemove.takeFirst()); }
void MtgCalculator::BeeReturned(int Ident, const MtgCashFlow& a) { Q_D(MtgCalculator); RETURN_WHEN_RUNNING(false, ) d->m_AggregatedRes += a; Q_ASSERT(d->m_Loans.contains(Ident)); { auto tempLoan = std::get<1>(d->m_Loans.value<Mortgage>(Ident)); tempLoan.SetCashFlows(a); SetLoan(tempLoan, Ident); } TemplAsyncCalculator<MtgCalculatorThread, MtgCashFlow>::BeeReturned(Ident, a); if (!ContinueCalculation()) return; MtgCalculatorThread* CurrentThread; const auto loansKeys = d->m_Loans.keys(); for (auto SingleLoan = loansKeys.constBegin(); SingleLoan != loansKeys.constEnd(); ++SingleLoan) { if (d->BeesSent.contains(*SingleLoan)) continue; CurrentThread = AddThread(*SingleLoan); CurrentThread->SetLoan(std::get<1>(d->m_Loans.value<Mortgage>(*SingleLoan))); if (d->TempProperties.contains(*SingleLoan)) { const auto CurrProps = d->TempProperties.value(*SingleLoan); for (auto j = CurrProps->constBegin(); j != CurrProps->constEnd(); ++j) { CurrentThread->SetLoanProperty(j.key(), j.value()); } } CurrentThread->SetCPR(d->m_CPRass); CurrentThread->SetCDR(d->m_CDRass); CurrentThread->SetLS(d->m_LSass); CurrentThread->SetRecoveryLag(d->m_RecoveryLag); CurrentThread->SetDelinquency(d->m_Delinquency); CurrentThread->SetDelinquencyLag(d->m_DelinquencyLag); CurrentThread->SetOverrideAssumptions(d->m_OverrideAssumptions); CurrentThread->SetStartDate(d->StartDate); CurrentThread->SetDownloadScenario(d->m_DownloadScenario); CurrentThread->start(); return; } }
bool StackSegmentList::isValid() const { bool result = true; for (auto iter = constBegin(); iter != constEnd(); ++iter) { if (!iter->isValid()) { result = false; break; } } return result; }
bool KEntryMap::hasEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags) const { const ConstIterator it = findEntry(group, key, flags); if (it == constEnd()) return false; if (it->bDeleted) return false; if (key.isNull()) { // looking for group marker return it->mValue.isNull(); } // if it->bReverted, we'll just return true; the real answer depends on lookup up with SearchDefaults, though. return true; }
void ItemEncryptedScriptable::decryptItem() { const auto encryptedBytes = call("data", QVariantList() << mimeEncryptedData).toByteArray(); const auto itemData = decrypt(encryptedBytes); if (itemData.isEmpty()) return; const auto dataMap = call("unpack", QVariantList() << itemData).toMap(); for (auto it = dataMap.constBegin(); it != dataMap.constEnd(); ++it) { const auto &format = it.key(); call("setData", QVariantList() << format << dataMap[format]); } }
EventList* EventList::allEventsForObject(QObject *widget) { if (!widget) return 0; EventList *l = new EventList(); EventList::ConstIterator endIt = constEnd(); for (EventList::ConstIterator it = constBegin(); it != endIt; ++it) { if (((*it)->sender() == widget) || ((*it)->receiver() == widget)) l->addEvent(*it); } return l; }
void DesignerSettings::toSettings(QSettings *settings) const { settings->beginGroup(QLatin1String(DesignerSettingsGroupKey::QML_SETTINGS_GROUP)); settings->beginGroup(QLatin1String(DesignerSettingsGroupKey::QML_DESIGNER_SETTINGS_GROUP)); QHash<QByteArray, QVariant>::const_iterator i = constBegin(); while (i != constEnd()) { storeValue(settings, i.key(), i.value()); ++i; } settings->endGroup(); settings->endGroup(); }
double UnitRatioList::getRatio(int uid1, int uid2) { if (uid1 == uid2) return (1.0); for (UnitRatioList::const_iterator ur_it = constBegin(); ur_it != constEnd(); ++ur_it) { if (ur_it->unitId1() == uid1 && ur_it->unitId2() == uid2) return ur_it->ratio(); if (ur_it->unitId1() == uid2 && ur_it->unitId2() == uid1) return ur_it->inverseRatio(); } return (-1.0); }