本文整理汇总了C++中QVariantMap::constBegin方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::constBegin方法的具体用法?C++ QVariantMap::constBegin怎么用?C++ QVariantMap::constBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::constBegin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareSetFieldsUpdateQuery
void DatabaseUtilities::prepareSetFieldsUpdateQuery(QSqlQuery& query, QString const& queryString, QVariantMap const& fieldsAndValues) {
if (fieldsAndValues.size() > 0) {
QString setString;
setString.reserve(512);
auto it = fieldsAndValues.constBegin();
auto const end = fieldsAndValues.constEnd();
int keyIndex = 1;
for (; it != end; ++it) {
if (!setString.isEmpty()) {
setString.append(QStringLiteral(", "));
}
setString.append(QStringLiteral("`%1` = :value%2").arg(it.key()).arg(keyIndex, 4, 10, QChar('0')));
++keyIndex;
}
query.prepare(queryString.arg(setString));
it = fieldsAndValues.constBegin();
keyIndex = 1;
for (; it != end; ++it) {
query.bindValue(QStringLiteral(":value%1").arg(keyIndex, 4, 10, QChar('0')), it.value());
++keyIndex;
}
} else {
throw openmittsu::exceptions::InternalErrorException() << "Can not build setFields update query part with empty field/value map, this should never happen!";
}
}
示例2: countQuery
int DatabaseUtilities::countQuery(InternalDatabaseInterface const* database, QString const& tableName, QVariantMap const& whereQueryPart) {
QSqlQuery query(database->getQueryObject());
QString whereString;
whereString.reserve(512);
auto it = whereQueryPart.constBegin();
auto const end = whereQueryPart.constEnd();
int keyIndex = 1;
for (; it != end; ++it) {
if (whereString.isEmpty()) {
whereString = QStringLiteral(" WHERE ");
} else {
whereString.append(QStringLiteral(" AND "));
}
whereString.append(QStringLiteral("`%1` = :value%2").arg(it.key()).arg(keyIndex, 4, 10, QChar('0')));
++keyIndex;
}
query.prepare(QStringLiteral("SELECT Count(*) AS `count` FROM `%1`%2").arg(tableName).arg(whereString));
it = whereQueryPart.constBegin();
keyIndex = 1;
for (; it != end; ++it) {
query.bindValue(QStringLiteral(":value%1").arg(keyIndex, 4, 10, QChar('0')), it.value());
++keyIndex;
}
if (query.exec() && query.isSelect() && query.next()) {
return query.value(QStringLiteral("count")).toInt();
} else {
throw openmittsu::exceptions::InternalErrorException() << "Could not execute count query for table '" << tableName.toStdString() << "'. Query error: " << query.lastError().text().toStdString();
}
}
示例3: 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);
}
}
示例4: testSetting
void VlanSettingTest::testSetting()
{
QFETCH(QString, interfaceName);
QFETCH(QString, parent);
QFETCH(quint32, id);
QFETCH(quint32, flags);
QFETCH(QStringList, ingressPriorityMap);
QFETCH(QStringList, egressPriorityMap);
QVariantMap map;
#if NM_CHECK_VERSION(1, 0, 0)
map.insert(QLatin1String("interface-name"), interfaceName);
#else
map.insert(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME), interfaceName);
#endif
map.insert(QLatin1String(NM_SETTING_VLAN_PARENT), parent);
map.insert(QLatin1String(NM_SETTING_VLAN_ID), id);
map.insert(QLatin1String(NM_SETTING_VLAN_FLAGS), flags);
map.insert(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), ingressPriorityMap);
map.insert(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), egressPriorityMap);
NetworkManager::VlanSetting setting;
setting.fromMap(map);
QVariantMap map1 = setting.toMap();
QVariantMap::const_iterator it = map.constBegin();
while (it != map.constEnd()) {
QCOMPARE(it.value(), map1.value(it.key()));
++it;
}
}
示例5: addProfile
void QbsManager::addProfile(const QString &name, const QVariantMap &data)
{
qbs::Profile profile(name, settings());
const QVariantMap::ConstIterator cend = data.constEnd();
for (QVariantMap::ConstIterator it = data.constBegin(); it != cend; ++it)
profile.setValue(it.key(), it.value());
}
示例6: addProfile
void QbsManager::addProfile(const QString &name, const QVariantMap &data)
{
const QString base = QLatin1String(PROFILES_PREFIX) + name;
const QVariantMap::ConstIterator cend = data.constEnd();
for (QVariantMap::ConstIterator it = data.constBegin(); it != cend; ++it)
m_settings->setValue(base + it.key(), it.value());
}
示例7: dumpVariantMap
static inline QString dumpVariantMap( const QVariantMap &variantMap, const QString &title = QString() )
{
QString result;
if ( !title.isEmpty() )
{
result += QStringLiteral( "<tr><td class=\"highlight\">%1</td><td>" ).arg( title );
}
else
{
result += QStringLiteral( "<tr><td>" );
}
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
{
QVariantMap childMap = it.value().toMap();
if ( childMap.isEmpty() )
{
result += QStringLiteral( "%1:%2</td></tr>" ).arg( it.key(), it.value().toString() );
}
else
{
result += QStringLiteral( "%1:<table>%2</table></td></tr>" ).arg( it.key(), dumpVariantMap( childMap ) );
}
}
return result;
}
示例8: connectOfono
void QOfonoMessageWaiting::connectOfono()
{
bool wasReady = isReady();
// FIXME: Clearing properties here results in false *Changed signal
// emissions. Ideally ready() should not be derived from
// properties.isEmpty(). Also compare with QOfonoSimManager.
if (d_ptr->messageWaiting) {
delete d_ptr->messageWaiting;
d_ptr->messageWaiting = 0;
d_ptr->properties.clear();
}
d_ptr->messageWaiting = new OfonoMessageWaiting("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(),this);
if (d_ptr->messageWaiting->isValid()) {
connect(d_ptr->messageWaiting,SIGNAL(PropertyChanged(QString,QDBusVariant)),
this,SLOT(propertyChanged(QString,QDBusVariant)));
QDBusPendingReply<QVariantMap> reply;
reply = d_ptr->messageWaiting->GetProperties();
reply.waitForFinished();
if (reply.isError()) {
Q_EMIT getPropertiesFailed();
} else {
QVariantMap properties = reply.value();
for (QVariantMap::ConstIterator it = properties.constBegin();
it != properties.constEnd(); ++it) {
updateProperty(it.key(), it.value());
}
}
}
if (wasReady != isReady())
Q_EMIT readyChanged();
}
示例9: load
void CameraItem::load(QVariantMap &d, int countId)
{
QMap<QString, QVariant>::const_iterator i = d.constBegin();
while (i != d.constEnd())
{
cameraData[i.key()] = i.value();
++i;
}
update_cameraId(cameraData["id"].toString());
if (cameraData.contains("url_lowres"))
{
update_cameraId(QString::number(countId));
isV1 = true; //when url_lowres is present, assume we are talking to a V1 calaos-os
update_v1Url(cameraData["url_lowres"].toString());
}
update_name(cameraData["name"].toString());
update_url_single(QString("image://camera/%1/%2").arg(get_cameraId()).arg(qrand()));
currentImage = QImage(":/img/camera_nocam.png");
qDebug() << "New camera loaded: " << get_name();
QTimer::singleShot(100, this, [=]()
{
connection->getCameraPicture(get_cameraId(), get_v1Url());
});
}
示例10: testSetting
void BridgeSettingTest::testSetting()
{
QFETCH(QString, interfaceName);
QFETCH(bool, stp);
QFETCH(quint16, priority);
QFETCH(quint16, forwardDelay);
QFETCH(quint16, helloTime);
QFETCH(quint16, maxAge);
QFETCH(quint32, ageintTime);
QVariantMap map;
#if NM_CHECK_VERSION(1, 0, 0)
map.insert(QLatin1String("interface-name"), interfaceName);
#else
map.insert(QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME), interfaceName);
#endif
map.insert(QLatin1String(NM_SETTING_BRIDGE_STP), stp);
map.insert(QLatin1String(NM_SETTING_BRIDGE_PRIORITY), priority);
map.insert(QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY), forwardDelay);
map.insert(QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME), helloTime);
map.insert(QLatin1String(NM_SETTING_BRIDGE_MAX_AGE), maxAge);
map.insert(QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME), ageintTime);
NetworkManager::BridgeSetting setting;
setting.fromMap(map);
QVariantMap map1 = setting.toMap();
QVariantMap::const_iterator it = map.constBegin();
while (it != map.constEnd()) {
QCOMPARE(it.value(), map1.value(it.key()));
++it;
}
}
示例11: filterModel
void ODataListModel::filterModel(const QString& resourcePath, const QVariantMap& filters) {
if (!mService) {
qDebug() << "Data service isn't set";
return;
}
QUrl url = mService->getSource() + "/" + resourcePath;
for (QVariantMap::const_iterator i = filters.constBegin(); i != filters.constEnd(); i++) {
if (i.key() == "filter")
url.addQueryItem("$filter", i.value().toString());
else if (i.key() == "orderby")
url.addQueryItem("$orderby", i.value().toString());
else if (i.key() == "count")
url.addQueryItem("$count", i.value().toString());
else if (i.key() == "skip")
url.addQueryItem("$skip", QString::number(i.value().toInt()));
else if (i.key() == "top")
url.addQueryItem("$top", QString::number(i.value().toInt()));
else if (i.key() == "search")
url.addQueryItem("$search", i.value().toString());
}
mDataList.clear();
emit itemsChanged(bb::cascades::DataModelChangeType::Init);
if (mNetworkManager)
mNetworkManager->read(url.toString());
}
示例12: setModemPath
void QOfonoRadioSettings::setModemPath(const QString &path)
{
if (path == d_ptr->modemPath ||
path.isEmpty())
return;
QStringList removedProperties = d_ptr->properties.keys();
delete d_ptr->radioSettings;
d_ptr->radioSettings = new OfonoRadioSettings("org.ofono", path, QDBusConnection::systemBus(),this);
if (d_ptr->radioSettings->isValid()) {
d_ptr->modemPath = path;
connect(d_ptr->radioSettings,SIGNAL(PropertyChanged(QString,QDBusVariant)),
this,SLOT(propertyChanged(QString,QDBusVariant)));
QVariantMap properties = d_ptr->radioSettings->GetProperties().value();
for (QVariantMap::ConstIterator it = properties.constBegin();
it != properties.constEnd(); ++it) {
updateProperty(it.key(), it.value());
removedProperties.removeOne(it.key());
}
Q_EMIT modemPathChanged(path);
}
foreach (const QString &p, removedProperties)
updateProperty(p, QVariant());
}
示例13: fromQVariant
Var Var::fromQVariant(QVariant qvar)
{
Var var;
if(qvar.type()==QVariant::List)
{
QVariantList qlist = qvar.toList();
var.setType("list");
for(int i=0;i<qlist.size();i++)
var.append(fromQVariant(qlist[i]));
}
if(qvar.type()==QVariant::Map)
{
QVariantMap qmap = qvar.toMap();
var.setType("map");
for(QVariantMap::const_iterator i = qmap.constBegin();i != qmap.constEnd();i++)
var.insert(i.key(),fromQVariant(i.value()));
}
if(qvar.type()==QVariant::String)
{
var.setType("string");
var.setString(qvar.toString());
}
if(qvar.type()==QVariant::Int)
{
var.setType("string");
var.setString(QString::number(qvar.toInt()));
}
if(qvar.type()==QVariant::Double)
{
var.setType("string");
var.setString(QString::number(qvar.toDouble()));
}
return var;
}
示例14: 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;
}
示例15:
static void
interpretInstances( const YAML::Node& node, Settings::InstanceDescriptionList& customInstances )
{
// Parse the custom instances section
if ( node )
{
QVariant instancesV = CalamaresUtils::yamlToVariant( node ).toList();
if ( instancesV.type() == QVariant::List )
{
const auto instances = instancesV.toList();
for ( const QVariant& instancesVListItem : instances )
{
if ( instancesVListItem.type() != QVariant::Map )
continue;
QVariantMap instancesVListItemMap =
instancesVListItem.toMap();
Settings::InstanceDescription instanceMap;
for ( auto it = instancesVListItemMap.constBegin();
it != instancesVListItemMap.constEnd(); ++it )
{
if ( it.value().type() != QVariant::String )
continue;
instanceMap.insert( it.key(), it.value().toString() );
}
customInstances.append( instanceMap );
}
}
}
}