QDomElement Reference::applyElement( const QDomElement &context ) const { kDebug() <<"Reference::applyElement()" << toString() <<"Context:" << context.tagName(); QDomElement result = context; if ( mSegments.count() == 1 && lastSegment().name() == "." ) return result; Reference::Segment::List::ConstIterator it; for( it = mSegments.constBegin(); it != mSegments.constEnd(); ++it ) { Reference::Segment segment = *it; // kDebug() <<" Segment:" << segment.toString() <<"Count:" << // segment.count(); QMap<QString, int> counts; QDomNode n; for( n = result.firstChild(); !n.isNull(); n = n.nextSibling() ) { QDomElement e = n.toElement(); // kDebug() <<" E:" << e.tagName(); int count = 1; QMap<QString, int>::ConstIterator itCount = counts.constFind( e.tagName() ); if ( itCount != counts.constEnd() ) count = itCount.value(); // kDebug() <<" COUNT:" << count; if ( e.tagName() == segment.name() && count == segment.count() ) { result = e; break; } counts.insert( e.tagName(), ++count ); } if ( n.isNull() ) { kError() <<"Reference::apply(): Unable to find element '" << segment.toString() << "'"; return QDomElement(); } } return result; }
void DsWidget::slotFindVersionsForPackageFinished(QNetworkReply* reply) { QUrl replyUrl = reply->url(); if (reply->error()) { kWarning() << "Download of " << replyUrl.toEncoded().constData() << "failed: " << qPrintable(reply->errorString()); } else { QByteArray ba = reply->readAll(); bool ok; QJson::Parser jsonParser; QVariant versionSuggestions = jsonParser.parse(ba, &ok); if (ok) { kDebug() << "Query " << replyUrl.toEncoded().constData() << "succeeded"; QMap<QString, QVariant> versions = versionSuggestions.toMap(); QMap<QString, QVariant>::const_iterator i = versions.constBegin(); while (i != versions.constEnd()) { m_versionsComboBox->addItem(i.value().toString()); ++i; } m_versionsComboBox->setEnabled(true); if( versions.size() == 1 ) { m_descriptionLineEdit->setEnabled(true); slotEnableUpload(); } } else { kDebug() << "Query " << replyUrl.toEncoded().constData() << "failed"; } } reply->deleteLater(); }
void ComplexActionDialog::addBaseActionToRuleWidget(QTreeWidgetItem *parent , QString const &name, QMap<QString, QString> const &disabledProperties , const int &repeatCountValue , const bool &isKeyActionValue , const Duration &durationValue , QTreeWidgetItem *topLevelParent ) { QTreeWidgetItem *ruleItem = nullptr; if (parent == nullptr) { ruleItem = new QTreeWidgetItem(ui->ruleTreeWidget); } else { ruleItem = new QTreeWidgetItem(parent); } if (ruleItem) { QMap<QString, QString> mapProperties; QMap<QString, QStringList> properties = mBaseUserActions.propertiesByBaseUserActionName(name); QMap<QString, QStringList>::const_iterator i = properties.constBegin(); QString ruleProperties = " — "; while (i != properties.constEnd()) { QStringList const values = i.value(); QString value = (!values.isEmpty()) ? values.at(0) : ""; if (disabledProperties.keys().contains(i.key())) { value = disabledProperties.value(i.key()); } mapProperties.insert(i.key(), value); ruleProperties += i.key() + ": " + value + "|"; ++i; } QTreeWidgetItem *topLevelParentItem = new QTreeWidgetItem(); if (topLevelParent == nullptr) { topLevelParentItem = ruleItem; } else { topLevelParentItem = topLevelParent; } mWidgetItemCustomPropertyList.append(new WidgetItemCustomProperty(topLevelParentItem, ruleItem, mapProperties , repeatCountValue, isKeyActionValue, durationValue)); mDisabledProperties.insert(ruleItem, disabledProperties); int column = 0; ruleItem->setText(column, name + ruleProperties); } }
PluginPreferences::PluginPreferences(QWidget* parent) : ConfigPage(nullptr, nullptr, parent) { QVBoxLayout* lay = new QVBoxLayout(this ); selector = new KPluginSelector( this ); lay->addWidget( selector ); QMap<QString, QList<KPluginInfo>> plugins; const QMap<QString, QString> categories = { { "Core", i18nc("@title:group", "Core") }, { "Project Management", i18nc("@title:group", "Project Management") }, { "Version Control", i18nc("@title:group", "Version Control") }, { "Utilities", i18nc("@title:group", "Utilities") }, { "Documentation", i18nc("@title:group", "Documentation") }, { "Language Support", i18nc("@title:group", "Language Support") }, { "Debugging", i18nc("@title:group", "Debugging") }, { "Testing", i18nc("@title:group", "Testing") }, { "Other", i18nc("@title:group", "Other") } }; foreach (const KPluginMetaData& info, Core::self()->pluginControllerInternal()->allPluginInfos()) { const QString loadMode = info.value(QStringLiteral("X-KDevelop-LoadMode")); if( loadMode.isEmpty() || loadMode == QLatin1String("UserSelectable") ) { QString category = info.category(); if (!categories.contains(category)) { if (!category.isEmpty()) { qWarning() << "unknown category for plugin" << info.name() << ":" << info.category(); } category = QStringLiteral("Other"); } KPluginInfo kpi(info); kpi.setPluginEnabled(Core::self()->pluginControllerInternal()->isEnabled(info)); plugins[category] << kpi; } else qDebug() << "skipping..." << info.pluginId() << info.value(QStringLiteral("X-KDevelop-Category")) << loadMode; } for (auto it = plugins.constBegin(), end = plugins.constEnd(); it != end; ++it) { selector->addPlugins(it.value(), KPluginSelector::ReadConfigFile, categories.value(it.key()), it.key(), Core::self()->activeSession()->config() ); } connect(selector, &KPluginSelector::changed, this, &PluginPreferences::changed); selector->load(); }
void Emulator_Options_Window::on_Button_Find_clicked() { if( ui.Edit_Path_to_Dir->text().isEmpty() ) { AQGraphic_Warning( tr("Error!"), tr("Path is Empty!") ); return; } QDir dir = QDir( ui.Edit_Path_to_Dir->text() ); if( ! dir.exists() ) { AQGraphic_Warning( tr("Warning"), tr("Path doesn't exist!") ); return; } // Set Type and Bin files QMap<QString, QString> list; list = System_Info::Find_QEMU_Binary_Files( ui.Edit_Path_to_Dir->text() ); // Clear old bin files ui.Table_Systems->clearContents(); while( ui.Table_Systems->rowCount() > 0 ) ui.Table_Systems->removeRow( 0 ); // Add bin files to Table_Systems QMap<QString, QString>::const_iterator iter = list.constBegin(); while( iter != list.constEnd() ) { ui.Table_Systems->insertRow( ui.Table_Systems->rowCount() ); QTableWidgetItem *newItem = new QTableWidgetItem( iter.key() ); ui.Table_Systems->setItem( ui.Table_Systems->rowCount()-1, 0, newItem ); newItem = new QTableWidgetItem( QDir::toNativeSeparators(iter.value()) ); ui.Table_Systems->setItem( ui.Table_Systems->rowCount()-1, 1, newItem ); ++iter; // next value } // Update emulator info Update_Info = true; Update_Emulator(); Update_Info = false; }
void KPlayerTrackActionList::addActions (const QMap<int, QString>& ids, int id) { QMap<int, QString>::ConstIterator iterator (ids.constBegin()), end (ids.constEnd()); while ( iterator != end ) { QString text (languageName (iterator.key(), iterator.value())); #ifdef DEBUG_KPLAYER_ACTIONLIST kdDebugTime() << " Stream " << iterator.key() << " " << iterator.value() << " " << text << "\n"; #endif KToggleAction* action = new KToggleAction (m_action_group); connect (action, SIGNAL (triggered()), SLOT (actionActivated())); action -> setText (text); updateAction (action); if ( id == iterator.key() ) action -> setChecked (true); m_actions.append (action); ++ iterator; } }
bool AppearanceGTK2::loadSettings(const QString& path) { QFile configFile(path); bool canRead = configFile.open(QIODevice::ReadOnly | QIODevice::Text); if(canRead) { // qDebug() << "The gtk2 config file exists..."; const QMap<QString, QString> foundSettings = readSettingsTuples(&configFile); m_settings = QMap<QString, QString> { {"toolbar_style", "GTK_TOOLBAR_ICONS"}, {"show_icons_buttons", "0"}, {"show_icons_menus", "0"}, {"primary_button_warps_slider", "false"} }; for(auto it = foundSettings.constBegin(), itEnd = foundSettings.constEnd(); it!=itEnd; ++it) { if (it.key() == "gtk-theme-name") m_settings["theme"] = *it; else if (it.key() == "gtk-icon-theme-name") m_settings["icon"] = *it; else if (it.key() == "gtk-fallback-icon-theme") m_settings["icon_fallback"] = *it; else if (it.key() == "gtk-cursor-theme-name") m_settings["cursor"] = *it; else if (it.key() == "gtk-font-name") m_settings["font"] = *it; else if (it.key() == "gtk-toolbar-style") m_settings["toolbar_style"] = *it; else if (it.key() == "gtk-button-images") m_settings["show_icons_buttons"] = *it; else if(it.key() == "gtk-menu-images") m_settings["show_icons_menus"] = *it; else if (it.key() == "gtk-primary-button-warps-slider") m_settings["primary_button_warps_slider"] = *it; else qWarning() << "unknown field" << it.key(); } } return canRead; }
void ItemView::loadData(QMap<quint32, Item> data) { itemTable->setRowCount(data.size()); quint32 row = 0; QMap<quint32, Item>::const_iterator i = data.constBegin(); while (i != data.constEnd()) { itemTable->setItem(row, 0, newEntry(i.value().getName())); itemTable->setItem(row, 1, newEntry(QString::number(i.value().getID()))); itemTable->setItem(row, 2, newEntry(i.value().availableText())); itemTable->setItem(row, 3, newEntry(i.value().getDateAdded().toString(Qt::SystemLocaleShortDate))); ++row; ++i; } // itemTable->resizeColumnsToContents(); }
void QgsVectorLayerSaveAsDialog::setup() { setupUi( this ); QSettings settings; restoreGeometry( settings.value( "/Windows/VectorLayerSaveAs/geometry" ).toByteArray() ); QMap<QString, QString> map = QgsVectorFileWriter::ogrDriverList(); mFormatComboBox->blockSignals( true ); for ( QMap< QString, QString>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it ) { mFormatComboBox->addItem( it.key(), it.value() ); } QString format = settings.value( "/UI/lastVectorFormat", "ESRI Shapefile" ).toString(); mFormatComboBox->setCurrentIndex( mFormatComboBox->findData( format ) ); mFormatComboBox->blockSignals( false ); mEncodingComboBox->addItems( QgsVectorDataProvider::availableEncodings() ); QString enc = settings.value( "/UI/encoding", "System" ).toString(); int idx = mEncodingComboBox->findText( enc ); if ( idx < 0 ) { mEncodingComboBox->insertItem( 0, enc ); idx = 0; } mCRSSelection->clear(); mCRSSelection->addItems( QStringList() << tr( "Layer CRS" ) << tr( "Project CRS" ) << tr( "Selected CRS" ) ); QgsCoordinateReferenceSystem srs( mCRS, QgsCoordinateReferenceSystem::InternalCrsId ); leCRS->setText( srs.description() ); mEncodingComboBox->setCurrentIndex( idx ); on_mFormatComboBox_currentIndexChanged( mFormatComboBox->currentIndex() ); //symbology export combo box mSymbologyExportComboBox->addItem( tr( "No symbology" ), QgsVectorFileWriter::NoSymbology ); mSymbologyExportComboBox->addItem( tr( "Feature symbology" ), QgsVectorFileWriter::FeatureSymbology ); mSymbologyExportComboBox->addItem( tr( "Symbol layer symbology" ), QgsVectorFileWriter::SymbolLayerSymbology ); on_mSymbologyExportComboBox_currentIndexChanged( mSymbologyExportComboBox->currentText() ); mOptionsButton->setChecked( settings.value( "/UI/vectorLayerSaveAsOptionsVisible" ).toBool() ); }
Upnp::Device::MusicTrack::MusicTrack(const QMap<QString, QString> &values, Item *p, int r) : Upnp::Device::Item(values["title"], p, r) { isBroadcast=QLatin1String(constBroadcastClass)==values["class"]; url=values["res"]; artist=values["artist"]; albumArtist=values["albumArtist"]; creator=values["creator"]; album=values["album"]; genre=values["genre"]; track=values["originalTrackNumber"].toUInt(); artUrl=values["albumArtURI"]; if (!isBroadcast && !name.isEmpty() && artist.isEmpty() && album.isEmpty() && 0==track && genre.isEmpty() && creator.isEmpty()) { isBroadcast=true; } if (artUrl.isEmpty()) { artUrl=Core::Images::self()->constDefaultImage; } if (values["date"].contains("-")) { year=values["date"].split("-").first().toUInt(); } date=values["date"]; duration=0; if (values.contains("res.duration")) { QStringList parts=values["res.duration"].split(":"); if (!parts.isEmpty()) { quint16 multiple=1; for (int i=parts.size()-1; i>=0; --i) { duration+=parts.at(i).toDouble()*multiple; multiple*=60; } } } QMap<QString, QString>::ConstIterator it=values.constBegin(); QMap<QString, QString>::ConstIterator end=values.constEnd(); QString resKey=QLatin1String("res."); for (; it!=end; ++it) { if (it.key().startsWith(resKey)) { res.insert(it.key().mid(4), it.value()); } } }
void ConnectDialog::populateSignalList() { QString selectedName; if (const QListWidgetItem *item = m_ui.signalList->currentItem()) selectedName = item->text(); m_ui.signalList->clear(); QMap<QString, QString> memberToClassName = getSignals(m_formWindow->core(), m_source, showAllSignalsSlots()); QFont font = QApplication::font(); font.setItalic(true); QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap<QString, QString>::ConstIterator itMember = memberToClassName.constBegin(); const QMap<QString, QString>::ConstIterator itMemberEnd = memberToClassName.constEnd(); while (itMember != itMemberEnd) { const QString member = itMember.key(); const bool qt3Signal = isQt3Signal(m_formWindow->core(), m_source, member); QListWidgetItem *item = new QListWidgetItem(m_ui.signalList); item->setText(member); if (!selectedName.isEmpty() && member == selectedName) curr = item; if (qt3Signal) { item->setData(Qt::FontRole, variantFont); item->setData(Qt::ForegroundRole, Qt::red); } ++itMember; } if (curr) { m_ui.signalList->setCurrentItem(curr); } else { selectedName.clear(); } populateSlotList(selectedName); if (!curr) m_ui.slotList->setEnabled(false); }
bool QgsVectorDataProvider::addAttributes( const QMap<QString, QString> &attributes ) { const QList< NativeType > &types = nativeTypes(); QList< QgsField > list; for ( QMap<QString, QString>::const_iterator it = attributes.constBegin(); it != attributes.constEnd(); it++ ) { int i; for ( i = 0; i < types.size() && types[i].mTypeName != it.value(); i++ ) ; if ( i == types.size() ) return false; list << QgsField( it.key(), types[i].mType, it.value() ); } return addAttributes( list ); }
void ConfigAppearanceWidget::setDefaultTextCharFormats(const QMap<QString, QTextCharFormat> &defaultFormatList) { for (int i = 0; i < defaultFormatList.size(); ++i) { m_itemColors << ""; m_itemFonts << ""; } QMap<QString, QTextCharFormat>::const_iterator it = defaultFormatList.constBegin(); int num; while (it != defaultFormatList.constEnd()) { num = m_typeNames.indexOf(it.key()); if (num < 0) continue; m_itemColors[num] = it.value().foreground().color().name(); m_itemFonts[num] = it.value().font().toString(); ++it; } }
QString mapiNamedTagString( int key, int tag ) { if ( MAPI_NamedTagMap.count() == 0 ) { for ( int i=0; MAPI_NamedTagStrings[ i ].str; i++ ) { MAPI_NamedTagMap[ MAPI_NamedTagStrings[ i ].tag ] = i18n( MAPI_NamedTagStrings[ i ].str ); } } QMap<int,QString>::ConstIterator it = MAPI_NamedTagMap.constFind( key ); if ( it == MAPI_NamedTagMap.constEnd() ) { if ( tag >= 0 ) { return QString().sprintf( "0x%04X [0x%04X]: ", tag, key ) + *it; } else { return QString().sprintf( "0x%04X ________:", key ) + *it; } } else { return *it; } }
void SymbolNode::convertTo(QStandardItem *item, bool recursive) const { if (!item) return; QMap<SymbolInfo, SymbolNode::Ptr> map; qDebug("---"); // convert to map - to sort it ConstChildIterator curHash = m_childList.constBegin(); ConstChildIterator endHash = m_childList.constEnd(); while (curHash != endHash) { qDebug() << curHash.key().name() << curHash.key().type(); map.insert(curHash.key(), curHash.value()); ++curHash; } // add to item QMap<SymbolInfo, SymbolNode::Ptr>::const_iterator cur = map.constBegin(); QMap<SymbolInfo, SymbolNode::Ptr>::const_iterator end = map.constEnd(); while (cur != end) { const SymbolInfo &inf = cur.key(); SymbolNode::Ptr ptr = cur.value(); QStandardItem *add = new QStandardItem(); AtlasUtils::setSymbolInformationToItem(inf, add); if (!ptr.isNull()) { // icon //add->setIcon(ptr->icon()); // locations //add->setData(AtlasUtils::locationsToRole(ptr->symbolLocations), // ClassViewConstants::SymbolLocationsRole); if (recursive) cur.value()->convertTo(add, true); } item->appendRow(add); ++cur; } }
QString FbTalker::getCallString(const QMap<QString, QString>& args) { QString concat; // NOTE: QMap iterator will sort alphabetically for (QMap<QString, QString>::const_iterator it = args.constBegin(); it != args.constEnd(); ++it) { if (!concat.isEmpty()) concat.append("&"); concat.append(it.key()); concat.append("="); concat.append(it.value()); } kDebug() << "CALL: " << concat; return concat; }
void Bubble::onActionButtonClicked(const QString &actionId) { QMap<QString, QVariant> hints = m_entity->hints(); QMap<QString, QVariant>::const_iterator i = hints.constBegin(); while (i != hints.constEnd()) { QStringList args = i.value().toString().split(","); if (!args.isEmpty()) { QString cmd = args.first(); args.removeFirst(); if (i.key() == "x-deepin-action-" + actionId) { QProcess::startDetached(cmd, args); } } ++i; } m_outTimer->stop(); Q_EMIT actionInvoked(m_entity->id().toUInt(), actionId); }
void plan::set_plans(const QMap<unsigned, QList<QString>> &plans, const QMap<unsigned, QList<QString>> &plans_details) { plans_ = plans; plans_details_ = plans_details; auto num = plans.size(); QTableWidgetItem *header_h1 = new QTableWidgetItem("Courses"); QTableWidgetItem *header_h2 = new QTableWidgetItem("Points"); QTableWidgetItem *header_h3 = new QTableWidgetItem("Period"); if (num == 0) { auto *item1 = new QTableWidgetItem("No available courses."); item1->setTextAlignment(Qt::AlignCenter); ui->plans_table->setColumnCount(1); ui->plans_table->setRowCount(1); ui->plans_table->setItem(0, 0, item1); ui->plans_table->setColumnWidth(0, this->width()); return; } ui->plans_table->setColumnCount(3); ui->plans_table->setRowCount(num); ui->plans_table->setHorizontalHeaderItem(0, header_h1); ui->plans_table->setHorizontalHeaderItem(1, header_h2); ui->plans_table->setHorizontalHeaderItem(2, header_h3); size_t row = 0; for (auto it = plans.constBegin(); it != plans.constEnd(); ++it) { size_t col = 0; auto *item1 = new QTableWidgetItem(it.value().at(0)); auto *item2 = new QTableWidgetItem(it.value().at(1)); auto *item3 = new QTableWidgetItem(it.value().at(2)); item2->setBackgroundColor(Qt::lightGray); item3->setBackgroundColor(Qt::yellow); item2->setTextAlignment(Qt::AlignCenter); item3->setTextAlignment(Qt::AlignCenter); ui->plans_table->setItem(row, col, item1); ui->plans_table->setItem(row, ++col, item2); ui->plans_table->setItem(row++, ++col, item3); } }
void html_editor::replace_local_references(const QMap<QString,QString>& map) { page()->mainFrame()->evaluateJavaScript(manitou_files_jscript); QString jscript = "var n=[];"; QMap<QString,QString>::const_iterator i = map.constBegin(); /* build a javascript snippet that maps each "source" reference (typically something like file:///home/user/foobar.gif) to each mime content id (cid:uniqueref@domain) */ while (i != map.constEnd()) { QString source = i.key(); source.replace("'", "\\'"); QString dest = i.value(); dest.replace("'", "\\'"); jscript.append(QString("n['%1']='%2';").arg(source).arg(dest)); ++i; } jscript.append("manitou_files.replace_references(n); 1"); QVariant res=page()->mainFrame()->evaluateJavaScript(jscript); }
void SugarAccount::setData(const QMap<QString, QString>& data) { d->mEmpty = false; const SugarAccount::AccessorHash accessors = SugarAccount::accessorHash(); QMap<QString, QString>::const_iterator it = data.constBegin(); for ( ; it != data.constEnd() ; ++it) { const SugarAccount::AccessorHash::const_iterator accessIt = accessors.constFind(it.key()); if (accessIt != accessors.constEnd()) { (this->*(accessIt.value().setter))(it.value()); } else { d->mCustomFields.insert(it.key(), it.value()); } } // equivalent to this, but fully automated: //d->mId = data.value("id"); //d->mName = data.value("name"); // ... }
int main(void) { QMap<QString, int> map; map["foo"] = 42; map["bar"] = 13; map["baz"] = 9; foreach(QString key, map.keys()) qDebug() << key << "=" << map[key]; QMap<QString, int>::ConstIterator ii; for ( ii = map.constBegin(); ii != map.constEnd(); ++ii) qDebug() << ii.key() << "=" << ii.value(); int sum = map["foo"] + map["ingenting"]; qDebug() << sum; qDebug() << map["ingenting"]; qDebug() << map.value("ingenting"); return 0; }
void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const { QMap<QLayoutItem *, QRect> itemToPos; int idx = 0; while (idx < layout->count()) { int r, c, rs, cs; layout->getItemPosition(idx, &r, &c, &rs, &cs); if (r > row) { itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); } else { idx++; } } const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { const QRect r = it.value(); layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); } }
float calculateRenderAccuracy(const glm::vec3& position, const AABox& bounds, float octreeSizeScale, int boundaryLevelAdjust) { float largestDimension = bounds.getLargestDimension(); const float maxScale = (float)TREE_SCALE; float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale) / OCTREE_TO_MESH_RATIO; static std::once_flag once; static QMap<float, float> shouldRenderTable; std::call_once(once, [&] { float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small float scale = maxScale; float factor = 1.0f; while (scale > SMALLEST_SCALE_IN_TABLE) { scale /= 2.0f; factor /= 2.0f; shouldRenderTable[scale] = factor; } }); float closestScale = maxScale; float visibleDistanceAtClosestScale = visibleDistanceAtMaxScale; QMap<float, float>::const_iterator lowerBound = shouldRenderTable.lowerBound(largestDimension); if (lowerBound != shouldRenderTable.constEnd()) { closestScale = lowerBound.key(); visibleDistanceAtClosestScale = visibleDistanceAtMaxScale * lowerBound.value(); } if (closestScale < largestDimension) { visibleDistanceAtClosestScale *= 2.0f; } // FIXME - for now, it's either visible or not visible. We want to adjust this to eventually return // a floating point for objects that have small angular size to indicate that they may be rendered // with lower preciscion float distanceToCamera = glm::length(bounds.calcCenter() - position); return (distanceToCamera <= visibleDistanceAtClosestScale) ? 1.0f : 0.0f; }
QDomElement Reference::apply( const QDomDocument &doc ) const { QDomElement result; Reference::Segment::List::ConstIterator it; for( it = mSegments.constBegin(); it != mSegments.constEnd(); ++it ) { Reference::Segment segment = *it; if ( result.isNull() ) { kDebug() <<"ROOT"; if ( doc.documentElement().tagName() == segment.name() ) { result = doc.documentElement(); continue; } else { kError() <<"Document element '" << doc.documentElement().tagName() << "' isn't '" << segment.name() << "'"; return QDomElement(); } } QMap<QString, int> counts; QDomNode n; for( n = result.firstChild(); !n.isNull(); n = n.nextSibling() ) { QDomElement e = n.toElement(); int count = 1; QMap<QString, int>::ConstIterator itCount = counts.constFind( e.tagName() ); if ( itCount != counts.constEnd() ) count = itCount.value(); if ( e.tagName() == segment.name() && count == segment.count() ) { result = e; break; } counts.insert( e.tagName(), ++count ); } if ( n.isNull() ) { kError() <<"Reference::apply(): Unable to find element '" << segment.toString() << "'"; return QDomElement(); } } return result; }
void ParserTreeItem::convertTo(QStandardItem *item, bool recursive) const { if (!item) return; QMap<SymbolInformation, ParserTreeItem::Ptr> map; // convert to map - to sort it QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator curHash = d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator endHash = d->symbolInformations.constEnd(); while(curHash != endHash) { map.insert(curHash.key(), curHash.value()); ++curHash; } // add to item QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator cur = map.constBegin(); QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator end = map.constEnd(); while(cur != end) { const SymbolInformation &inf = cur.key(); ParserTreeItem::Ptr ptr = cur.value(); QStandardItem *add = new QStandardItem(); Utils::setSymbolInformationToItem(inf, add); if (!ptr.isNull()) { // icon add->setIcon(ptr->icon()); // locations add->setData(Utils::locationsToRole(ptr->symbolLocations()), Constants::SymbolLocationsRole); if (recursive) cur.value()->convertTo(add, false); } item->appendRow(add); ++cur; } }
void ParserTreeItem::convertTo(QStandardItem *item) const { if (!item) return; QMap<SymbolInformation, ParserTreeItem::Ptr> map; // convert to map - to sort it CitSymbolInformations curHash = d->symbolInformations.constBegin(); CitSymbolInformations endHash = d->symbolInformations.constEnd(); while (curHash != endHash) { map.insert(curHash.key(), curHash.value()); ++curHash; } typedef QMap<SymbolInformation, ParserTreeItem::Ptr>::const_iterator MapCitSymbolInformations; // add to item MapCitSymbolInformations cur = map.constBegin(); MapCitSymbolInformations end = map.constEnd(); while (cur != end) { const SymbolInformation &inf = cur.key(); ParserTreeItem::Ptr ptr = cur.value(); QStandardItem *add = new QStandardItem(); Utils::setSymbolInformationToItem(inf, add); if (!ptr.isNull()) { // icon add->setIcon(ptr->icon()); // draggable if (!ptr->symbolLocations().isEmpty()) add->setFlags(add->flags() | Qt::ItemIsDragEnabled); // locations add->setData(Utils::locationsToRole(ptr->symbolLocations()), Constants::SymbolLocationsRole); } item->appendRow(add); ++cur; } }
void ReferencedData::addMap(const QMap<QString, QString> &idDataMap) { QMap<QString, QString>::const_iterator it = idDataMap.constBegin(); const QMap<QString, QString>::const_iterator end = idDataMap.constEnd(); if (d->mVector.isEmpty()) { d->mVector.reserve(idDataMap.count()); // The vector is currently empty -> fast path // The map is already sorted, we can just copy right away // and emit the signals only once, which is the whole point of this method. emit rowsAboutToBeInserted(0, idDataMap.count() - 1); for ( ; it != end ; ++it) { d->mVector.append(KeyValue(it.key(), it.value())); } emit rowsInserted(); } else { // Append to existing data -> slower code path for ( ; it != end ; ++it) { setReferencedData(it.key(), it.value()); } } }
void ComplexActionDialog::updateCustomProperties() { QMap<QString, QString> const customProperties = mPropertiesDialog->conProperties(); QMap<QString, QString>::const_iterator i = customProperties.constBegin(); QString ruleProperties = " — "; int column = 0; QString itemName = mOpenedRuleItem->text(column).section(" — ", 0, 0); while (i != customProperties.constEnd()) { ruleProperties += i.key() + ": " + i.value() + "|"; ++i; } if (ruleProperties == " — ") { ruleProperties = ""; } mOpenedRuleItem->setText(column, itemName + ruleProperties); mWidgetItemCustomPropertyList.replaceProperties(mOpenedRuleItem, customProperties); mWidgetItemCustomPropertyList.updateOtherProperties(mOpenedRuleItem , mPropertiesDialog->repeatCount() , mPropertiesDialog->isKeyAction() , *(mPropertiesDialog->duration())); }
QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition ) : QgsComposerTable( composition ) , mVectorLayer( 0 ) , mComposerMap( 0 ) , mMaximumNumberOfFeatures( 5 ) , mShowOnlyVisibleFeatures( true ) { //set first vector layer from layer registry as default one QMap<QString, QgsMapLayer*> layerMap = QgsMapLayerRegistry::instance()->mapLayers(); QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin(); for ( ; mapIt != layerMap.constEnd(); ++mapIt ) { QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mapIt.value() ); if ( vl ) { mVectorLayer = vl; break; } } connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); }
bool QgsRasterCalcNode::calculate( QMap<QString, QgsRasterMatrix*>& rasterData, QgsRasterMatrix& result ) const { //deprecated method //convert QgsRasterMatrix to QgsRasterBlock and call replacement method QMap<QString, QgsRasterBlock* > rasterBlockData; QMap<QString, QgsRasterMatrix*>::const_iterator it = rasterData.constBegin(); for ( ; it != rasterData.constEnd(); ++it ) { QgsRasterBlock* block = new QgsRasterBlock( QGis::Float32, it.value()->nColumns(), it.value()->nRows(), it.value()->nodataValue() ); for ( int row = 0; row < it.value()->nRows(); ++row ) { for ( int col = 0; col < it.value()->nColumns(); ++col ) { block->setValue( row, col, it.value()->data()[ row * it.value()->nColumns() + col ] ); } } rasterBlockData.insert( it.key(), block ); } return calculate( rasterBlockData, result ); }