本文整理汇总了C++中qvariantmap::const_iterator::key方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::key方法的具体用法?C++ const_iterator::key怎么用?C++ const_iterator::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qvariantmap::const_iterator
的用法示例。
在下文中一共展示了const_iterator::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: context_scope
std::map<QString, double> ScriptMatch::getFeatures(const ConstOsmMapPtr& map) const
{
Context::Scope context_scope(_script->getContext());
HandleScope handleScope;
// removing these two lines causes a crash when checking for conflicts. WTF?
Handle<Object> global = _script->getContext()->Global();
global->Get(String::NewSymbol("plugin"));
std::map<QString, double> result;
Handle<Value> v = _callGetMatchFeatureDetails(map);
if (v.IsEmpty() || v->IsObject() == false)
{
throw IllegalArgumentException(
"Expected getMatchFeatureDetails to return an associative array.");
}
QVariantMap vm = toCpp<QVariantMap>(v);
for (QVariantMap::const_iterator it = vm.begin(); it != vm.end(); ++it)
{
if (it.value().isNull() == false)
{
double d = it.value().toDouble();
result[it.key()] = d;
if (isnan(result[it.key()]))
{
LOG_WARN("found NaN feature value for: " << it.key());
}
}
}
return result;
}
示例2: findKey
QStringList FindKeyOperation::findKey(const QVariant &in, const QString &key, const QString &prefix)
{
QStringList result;
if (in.type() == QVariant::Map) {
QVariantMap map = in.toMap();
for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) {
QString pfx = prefix;
if (!pfx.isEmpty())
pfx.append(QLatin1Char('/'));
if (i.key() == key) {
result << pfx + key;
} else {
pfx.append(i.key());
result.append(findKey(i.value(), key, pfx));
}
}
} else if (in.type() == QVariant::List) {
QVariantList list = in.toList();
for (int pos = 0; pos < list.count(); ++pos) {
QString pfx = prefix + QLatin1Char('[') + QString::number(pos) + QLatin1Char(']');
result.append(findKey(list.at(pos), key, pfx));
}
}
return result;
}
示例3: updateLocalProperties
void ExternalObjectInterface::updateLocalProperties(const QVariantMap& properties, bool callOnLocalPropertiesChanged)
{
LOG(Trace, "updateLocalProperties");
QVariantMap changedProperties;
QVariantMap::const_iterator it = properties.begin();
QVariantMap::const_iterator itend = properties.end();
for (; it != itend; ++it){
QVariantMap::const_iterator jt = m_localProperties.find(it.key());
if (jt != m_localProperties.end()){
if (jt.value() == it.value()){
// no change
}else{
m_localProperties[it.key()] = it.value();
changedProperties.insert(it.key(), it.value());
}
}else{
// key not found
m_localProperties[it.key()] = it.value();
changedProperties.insert(it.key(), it.value());
}
}
if (callOnLocalPropertiesChanged && !changedProperties.empty()){
onLocalPropertiesChanged(changedProperties);
}
}
示例4: restore
void StatusManager::restore(const QString& filename)
{
QVariant var;
// Try to Read a JSON file
bool res =
fromJsonFile(filename.toStdString().c_str(), var);
if (res)
{
const QVariantMap map = var.toMap();
for (QVariantMap::const_iterator it = map.begin();
it != map.end(); ++it)
{
Holder holder(status(it.key()));
if (holder.is_valid())
{
res = fromQVariant(holder.get_type_descriptor(),
holder, it.value());
if (res)
{
setStatus(it.key(), holder);
}
}
}
}
else
{
emit error(QString("Unable to load file '%1'").arg(filename));
}
}
示例5: toProperties
Properties VariantToMapConverter::toProperties(const QVariant &propertiesVariant,
const QVariant &propertyTypesVariant) const
{
const QVariantMap propertiesMap = propertiesVariant.toMap();
const QVariantMap propertyTypesMap = propertyTypesVariant.toMap();
Properties properties;
QVariantMap::const_iterator it = propertiesMap.constBegin();
QVariantMap::const_iterator it_end = propertiesMap.constEnd();
for (; it != it_end; ++it) {
int type = nameToType(propertyTypesMap.value(it.key()).toString());
if (type == QVariant::Invalid)
type = QVariant::String;
QVariant value = it.value();
if (type == filePathTypeId())
value = resolvePath(mMapDir, value);
value = fromExportValue(value, type);
properties[it.key()] = value;
}
return properties;
}
示例6: setupModelData
void TreeJsonModel::setupModelData(const QVariant& newdata, TreeJsonItem* parent)
{
QMetaType::Type type = (QMetaType::Type)newdata.type();
if (type == QMetaType::QVariantMap) {
QVariantMap map = newdata.toMap();
QVariantMap::const_iterator it;
for (it = map.constBegin(); it != map.constEnd(); it++) {
type = (QMetaType::Type)it.value().type();
if (type == QMetaType::QString || type == QMetaType::ULongLong) {
QList<QVariant> value;
value << it.key() << it.value();
TreeJsonItem* item = new TreeJsonItem(value,parent);
parent->appendChild(item);
} else if (type == QMetaType::QVariantMap) {
QList<QVariant> value;
value << it.key() << "{";
TreeJsonItem* item = new TreeJsonItem(value,parent);
parent->appendChild(item);
setupModelData(it.value(),item);
item->setData(1,QString("{%1}").arg(item->childCount()));
} else if (type == QMetaType::QVariantList) {
QList<QVariant> value;
value << it.key() << "[";
TreeJsonItem* item = new TreeJsonItem(value,parent);
parent->appendChild(item);
setupModelData(it.value(),item);
item->setData(1,QString("[%1]").arg(item->childCount()));
}
}
} else if (type == QMetaType::QVariantList) {
QVariantList list = newdata.toList();
int len = list.size();
for (int i=0;i<len;i++) {
type = (QMetaType::Type)list.value(i).type();
if (type == QMetaType::QString || type == QMetaType::ULongLong) {
QList<QVariant> value;
value << i << list.value(i);
TreeJsonItem* item = new TreeJsonItem(value,parent);
parent->appendChild(item);
} else if (type == QMetaType::QVariantMap) {
QList<QVariant> value;
value << i << "{";
TreeJsonItem* item = new TreeJsonItem(value,parent);
parent->appendChild(item);
setupModelData(list.value(i),item);
item->setData(1,QString("{%1}").arg(item->childCount()));
} else if (type == QMetaType::QVariantList) {
QList<QVariant> value;
value << i << "[";
TreeJsonItem* item = new TreeJsonItem(value,parent);
parent->appendChild(item);
setupModelData(list.value(i),item);
item->setData(1,QString("[%1]").arg(item->childCount()));
}
}
}
}
示例7: toFile
bool ccObject::toFile(QFile& out) const
{
assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
//class ID (dataVersion>=20)
//DGM: on 64 bits since version 34
uint64_t classID = static_cast<uint64_t>(getClassID());
if (out.write((const char*)&classID,8) < 0)
return WriteError();
//unique ID (dataVersion>=20)
//DGM: this ID will be useful to recreate dynamic links between entities!
uint32_t uniqueID = (uint32_t)m_uniqueID;
if (out.write((const char*)&uniqueID,4) < 0)
return WriteError();
//name (dataVersion>=22)
{
QDataStream outStream(&out);
outStream << m_name;
}
//flags (dataVersion>=20)
uint32_t objFlags = (uint32_t)m_flags;
if (out.write((const char*)&objFlags,4) < 0)
return WriteError();
//meta data (dataVersion>=30)
{
//check for valid pieces of meta-data
//DGM: some pieces of meta-data can't be properly streamed (the ones relying on 'Q_DECLARE_METATYPE' calls typically)
uint32_t validMetaDataCount = 0;
for (QVariantMap::const_iterator it = m_metaData.begin(); it != m_metaData.end(); ++it)
{
if (!it.key().contains(".nosave"))
{
++validMetaDataCount;
}
}
//count
if (out.write((const char*)&validMetaDataCount, 4) < 0)
return WriteError();
//"key + value" pairs
QDataStream outStream(&out);
for (QVariantMap::const_iterator it = m_metaData.begin(); it != m_metaData.end(); ++it)
{
if (!it.key().contains(".nosave"))
{
outStream << it.key();
outStream << it.value();
}
}
}
return true;
}
示例8: size
ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
{
m_parameters = parsedJson[QLatin1String("parameters")].toMap();
QVariantMap attachedShaders =
parsedJson[QLatin1String("shaders")].toMap();
QVariantMap::const_iterator itr;
for (itr = attachedShaders.constBegin(); itr != attachedShaders.constEnd();
++itr) {
QString type = itr.key();
QString source = itr.value().toString();
m_shaderSources[type] = source;
}
m_uniforms = parsedJson[QLatin1String("uniforms")].toMap();
m_buffers = parsedJson[QLatin1String("buffers")].toMap();
{
QVariantMap textures =
parsedJson[QLatin1String("textures")].toMap();
for (itr = textures.constBegin(); itr != textures.constEnd(); ++itr) {
m_textures.append(getTextureFrom(itr.value().toMap(), itr.key()));
}
}
QVariantMap fbos =
parsedJson[QLatin1String("framebuffer")].toMap();
for (itr = fbos.constBegin(); itr != fbos.constEnd(); ++itr) {
QVariantMap buffer = itr.value().toMap();
QSize size(buffer[QLatin1String("__width__")].toInt(),
buffer[QLatin1String("__height__")].toInt());
QString cls = buffer[QLatin1String("__class__")].toString();
int depth = buffer[QLatin1String("__depth__")].toInt();
QString formatName = buffer[QLatin1String("__format__")].toString();
QByteArray dataArray =
buffer[QLatin1String("__data__")].toByteArray();
QString label = itr.key();
QString userLabel =
buffer[QLatin1String("__label__")].toString();
if (!userLabel.isEmpty()) {
label += QString(", \"%1\"").arg(userLabel);
}
ApiFramebuffer fbo;
fbo.setSize(size);
fbo.setDepth(depth);
fbo.setFormatName(formatName);
fbo.setType(label);
fbo.setData(dataArray);
m_framebuffers.append(fbo);
}
}
示例9: setMetaData
void ccObject::setMetaData(const QVariantMap& dataset, bool overwrite/*=false*/)
{
for (QVariantMap::const_iterator it = dataset.begin(); it != dataset.end(); ++it)
{
if (overwrite || !m_metaData.contains(it.key()))
{
m_metaData[it.key()] = it.value();
}
}
}
示例10: expand_map
void expand_map(QStringList & keys, const QString & k, const QVariant & v){
if(v.type() == QVariant::Map){
const QVariantMap & map = asMap(v);
for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it){
expand_map(keys, k.isEmpty() ? it.key() : k +"." + it.key(), it.value());
}
}
if(!k.isEmpty()){
keys.append(k);
}
}
示例11: recognizer
void RecognitionDatabase::Private::applyParameters()
{
if (recognizerConst())
{
for (QVariantMap::const_iterator it = parameters.constBegin(); it != parameters.constEnd(); ++it)
{
if (it.key() == QString::fromLatin1("threshold") || it.key() == QString::fromLatin1("accuracy"))
{
recognizer()->setThreshold(it.value().toFloat());
}
}
}
}
示例12: DbgPrintf
bool tLibs3::UploadFile( tTransfer* pTransfer )
{
bool success = false;
if( m_Process.state() == QProcess::NotRunning )
{
QString archiveFilename = pTransfer->GetTransferGroup()->GetDirectoryToString() + QDir::separator() + pTransfer->GetArchiveFilename();
QVariantMap metaData = pTransfer->GetMetaData();
for(QVariantMap::const_iterator iter = metaData.begin(); iter != metaData.end(); ++iter)
{
DbgPrintf( QString("%1 = %2").arg(iter.key()).arg(iter.value().toString()) );
}
QString uploadName;
{
uploadName = "navicomerlintest/"; // TODO
uploadName += "support.";
uploadName += tUploadAWS::CreateFilename(metaData["brand"].toString(), metaData["model"].toString(), metaData["serialnumber"].toString(), metaData["time"].toString());
}
QStringList args;
args << "-f" << "put" << QString("%1").arg(uploadName);
args << QString("filename=%1").arg(archiveFilename);
for(QVariantMap::const_iterator iter = metaData.begin(); iter != metaData.end(); ++iter)
{
QString value;
if (iter.value().isValid() == true)
{
value = iter.value().toString();
}
if (value.isEmpty() == false)
{
// x-amz-meta-serial=123456
args << QString("x-amz-meta-%1=%2").arg(iter.key()).arg(value);
}
}
QString command = "";
#ifdef Q_WS_WIN
command = QString( "..\\..\\ThirdParty\\libs3\\s3.exe" );
#else
command = QString( "s3" );
#endif
#ifdef DATATRANSFERMANAGER_DBG
DbgPrintf(command);
foreach (QString arg, args)
{
DbgPrintf( QString(" \"%1\"").arg(arg) );
}
示例13: addQt
QVariantMap AddQtOperation::addQt(const QVariantMap &map,
const QString &id, const QString &displayName, const QString &type,
const QString &qmake, const KeyValuePairList &extra)
{
QString sdkId = extendId(id);
// Sanity check: Make sure autodetection source is not in use already:
if (exists(map, sdkId)) {
std::cerr << "Error: Id " << qPrintable(id) << " already defined as Qt versions." << std::endl;
return QVariantMap();
}
// Find position to insert:
int versionCount = 0;
for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) {
if (!i.key().startsWith(QLatin1String(PREFIX)))
continue;
QString number = i.key().mid(QString::fromLatin1(PREFIX).count());
bool ok;
int count = number.toInt(&ok);
if (ok && count >= versionCount)
versionCount = count + 1;
}
const QString qt = QString::fromLatin1(PREFIX) + QString::number(versionCount);
// Sanity check: Make sure displayName is unique.
QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME));
QStringList nameList;
foreach (const QString &nameKey, nameKeys)
nameList << GetOperation::get(map, nameKey).toString();
const QString uniqueName = makeUnique(displayName, nameList);
// Sanitize qmake path:
QString saneQmake = QDir::cleanPath(QDir::fromNativeSeparators(qmake));
// insert data:
KeyValuePairList data;
data << KeyValuePair(QStringList() << qt << QLatin1String(ID), QVariant(-1));
data << KeyValuePair(QStringList() << qt << QLatin1String(DISPLAYNAME), QVariant(uniqueName));
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTED), QVariant(true));
data << KeyValuePair(QStringList() << qt << QLatin1String(AUTODETECTION_SOURCE), QVariant(sdkId));
data << KeyValuePair(QStringList() << qt << QLatin1String(QMAKE), QVariant(saneQmake));
data << KeyValuePair(QStringList() << qt << QLatin1String(TYPE), QVariant(type));
KeyValuePairList qtExtraList;
foreach (const KeyValuePair &pair, extra)
qtExtraList << KeyValuePair(QStringList() << qt << pair.key, pair.value);
data.append(qtExtraList);
return AddKeysOperation::addKeys(map, data);
}
示例14: validate
void Feature::validate(StrictChecking strict)
{
// make sure we didn't get more fields than necessary
for (QVariantMap::const_iterator it = _values.begin(); it != _values.end(); ++it)
{
if (_definition->hasField(it.key()) == false)
{
QString error = QString("Returned a field name that isn't appropriate for this layer. %1")
.arg(it.key());
if (strict == StrictOn)
{
throw FieldDefinition::InvalidValueException(it.key(), error);
}
else if (strict == StrictWarn)
{
LOG_WARN(error);
}
}
}
for (size_t i = 0; i < _definition->getFieldCount(); ++i)
{
// is
shared_ptr<const FieldDefinition> d = _definition->getFieldDefinition(i);
if (_values.contains(d->getName()) == false)
{
if (d->hasDefaultValue() == false)
{
QString error = QString("Field has no default value and no value was specified. (%1)")
.arg(d->getName());
if (strict == StrictOn)
{
throw FieldDefinition::InvalidValueException(d->getName(), error);
}
else if (strict == StrictWarn)
{
LOG_WARN(error);
}
}
else
{
_values[d->getName()] = d->getDefaultValue();
}
}
else
{
d->validate(_values[d->getName()], strict);
}
}
}
示例15: debugDumpJson
QString debugDumpJson(QVariantMap json, QString name, QString indent) {
QString ret = "{";
QVariantMap::const_iterator it = json.constBegin();
for (; it != json.constEnd(); ++it) {
ret += "\n" + indent + " " + it.key() + ": ";
ret += debugDumpJson(it.value(), it.key(), indent);
}
ret += "\n" + indent + "}";
if (!name.isEmpty())
ret += " // end of " + name;
return ret;
}