本文整理汇总了C++中QVariantMap::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::erase方法的具体用法?C++ QVariantMap::erase怎么用?C++ QVariantMap::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupCompilerPathByLanguage
static void setupCompilerPathByLanguage(Profile &profile, const QStringList &toolchainTypes,
const QString &toolchainInstallPath, const QString &toolchainPrefix)
{
QVariantMap m;
if (toolchainTypes.contains(QLatin1String("clang"))) {
m[QLatin1String("c")] = m[QLatin1String("objc")] = QLatin1String("clang");
m[QLatin1String("cpp")] = m[QLatin1String("objcpp")] = QLatin1String("clang++");
} else if (toolchainTypes.contains(QLatin1String("gcc"))) {
m[QLatin1String("c")] = m[QLatin1String("objc")] = QLatin1String("gcc");
m[QLatin1String("cpp")] = m[QLatin1String("objcpp")] = QLatin1String("g++");
} else {
qDebug("WARNING: unexpected toolchain %s", qPrintable(toJSLiteral(toolchainTypes)));
return;
}
const QString toolchainPathPrefix = toolchainInstallPath + QLatin1Char('/') + toolchainPrefix;
for (QVariantMap::iterator it = m.begin(); it != m.end();) {
const QString filePath = HostOsInfo::appendExecutableSuffix(toolchainPathPrefix
+ it.value().toString());
if (QFile::exists(filePath)) {
it.value() = filePath;
++it;
continue;
}
qDebug("WARNING: Compiler %s for file tag %s not found.",
qPrintable(QDir::toNativeSeparators(filePath)), qPrintable(it.key()));
it = m.erase(it);
}
if (!m.isEmpty())
profile.setValue(QLatin1String("cpp.compilerPathByLanguage"), m);
}
示例2: canonicalizeOpinions
QVariantMap Decision::canonicalizeOpinions(QVariantMap opinions)
{
auto itr = opinions.begin();
while (itr != opinions.end())
if (itr.value().toInt() == 0)
itr = opinions.erase(itr);
else
++itr;
return opinions;
}
示例3: updatePrefab
void PrefabSystem::updatePrefab(const QString& path, const QVariantMap& newcomponents, bool updateInstances)
{
// fetch prefab by path
Prefab* prefab;
{
auto i = _prefabs.find(path);
if(i == _prefabs.end())
{
return;
}
prefab = i.value().data();
}
for(auto k: newcomponents.keys())
{
qDebug() << "Receeived: " << k;
}
if(updateInstances)
{
// update existing components in prefab and delete components no longer in prefab
for(auto j = prefab->components().begin(); j != prefab->components().end(); ++j)
{
EntitySystem* es = entityManager()->system(j.key());
Q_ASSERT(es);
if(!es) continue;
// component is in prefab but not in components map. Delete it from prefab instances.
if(newcomponents.find(j.key()) == newcomponents.end())
{
qDebug() << "Removing from prefab instances:" << j.key();
// find all prefab instances and destroy the component
for(auto k = this->begin(); k != this->end(); ++k)
{
PrefabInstance* pi = static_cast<PrefabInstance*>(k->second);
if(pi->prefab() == prefab)
{
es->destroyComponent(k->first);
}
}
}
else
{
// component exists in component map and in prefab. Update prefab.
QVariantMap newvals = newcomponents[j.key()].toMap();
// find all prefab instances and update the components
for(auto k = this->begin(); k != this->end(); ++k)
{
PrefabInstance* pi = static_cast<PrefabInstance*>(k->second);
if(pi->prefab() == prefab)
{
QVariantMap data = es->toVariantMap(k->first);
for(auto i = newvals.begin(); i != newvals.end(); ++i)
{
data[i.key()] = i.value();
}
auto i = data.begin();
while(i != data.end())
{
if(prefab->parameters().contains(i.key()) || i.key() == "objectName")
{
i = data.erase(i);
}
else
{
++i;
}
}
es->fromVariantMap(k->first, data);
}
}
}
}
// now handle the components that did not exist in prefab yet
for(auto i = newcomponents.begin(); i != newcomponents.end(); ++i)
{
QString key = i.key();
if(prefab->components().find(key) == prefab->components().end())
{
EntitySystem* es = entityManager()->system(key);
Q_ASSERT(es);
if(!es) continue;
for(auto k = this->begin(); k != this->end(); ++k)
{
PrefabInstance* pi = static_cast<PrefabInstance*>(k->second);
if(pi->prefab() == prefab)
{
es->createComponent(k->first, i.value().toMap());
}
}
}
}
}
// finally update prefab in prefab store
//.........这里部分代码省略.........