本文整理汇总了C++中QVariantMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::find方法的具体用法?C++ QVariantMap::find怎么用?C++ QVariantMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: capabilities
void ModemManager::ModemLocationInterface::propertiesChanged(const QString & interface, const QVariantMap & properties)
{
mmDebug() << interface << properties.keys();
if (interface == QString("org.freedesktop.ModemManager.Modem.Location")) {
QLatin1String capabilities("Capabilities");
QLatin1String enabled("Enabled");
QLatin1String signalsLocation("SignalsLocation");
QLatin1String location("Location");
QVariantMap::const_iterator it = properties.find(capabilities);
if ( it != properties.end()) {
emit capabilitiesChanged((ModemManager::ModemLocationInterface::Capability)it->toUInt());
}
it = properties.find(enabled);
if ( it != properties.end()) {
emit enabledChanged(it->toBool());
}
it = properties.find(signalsLocation);
if ( it != properties.end()) {
emit signalsLocationChanged(it->toBool());
}
it = properties.find(location);
if ( it != properties.end()) {
QVariant v = it.value();
LocationInformationMap map;
if (v.canConvert<LocationInformationMap>()) {
map = v.value<LocationInformationMap>();
} else {
mmDebug() << "Error converting LocationInformationMap property";
}
emit locationChanged(map);
}
}
}
示例2: onRequestFinished
void YandexNarodAuthorizator::onRequestFinished(QNetworkReply *reply)
{
reply->deleteLater();
if (reply != m_reply.data())
return;
QVariantMap data = Json::parse(reply->readAll()).toMap();
QVariantMap::Iterator error = data.find(QLatin1String("error"));
if (error != data.end() || reply->error() != QNetworkReply::NoError) {
QString errorStr = error.value().toString();
m_stage = Need;
if (errorStr == QLatin1String("unsupported_grant_type"))
emit result(Error, tr("Unsupported grant type. Inform developers."));
else if (errorStr == QLatin1String("invalid_request"))
emit result(Error, tr("Invalid request. Inform developers."));
else
emit result(Error, tr("Invalid login or/and password"));
return;
}
QString accessToken = data.value(QLatin1String("access_token")).toString();
QDateTime expiresAt;
QVariantMap::Iterator expiresIn = data.find(QLatin1String("expires_in"));
if (expiresIn != data.end()) {
expiresAt = QDateTime::currentDateTime();
expiresAt.addSecs(expiresIn.value().toInt());
}
debug() << accessToken << data;
m_token = accessToken;
m_stage = Already;
emit result(Success);
emit needSaveCookies();
}
示例3:
QMap<QUrl,QUrl>* Fetcher::parseJson(QByteArray json)
{
QMap<QUrl,QUrl>* urls = new QMap<QUrl,QUrl>();
QJsonDocument jsonDoc = QJsonDocument::fromJson(json);
QVariantMap result = jsonDoc.toVariant().toMap();
QVariantMap responseData = (*result.find("responseData")).toMap();
QVariantList resultList = (*responseData.find("results")).toList();
QVariantMap tmp;
QVariant tbUrl,imgUrl;
QString tbUrlString,imgUrlString;
QVariantList::iterator it;
for(it = resultList.begin() ; it != resultList.end() ; ++it)
{
tmp = (*it).toMap();
tbUrl = (*tmp.find("tbUrl"));
imgUrl = (*tmp.find("unescapedUrl"));
tbUrlString = tbUrl.toString();
imgUrlString = imgUrl.toString();
urls->insert(QUrl(imgUrlString),QUrl(tbUrlString));
}
return urls;
}
示例4: SetRange
void SetRange(QCustomPlot& plot, int index, QVariantMap range, QCPAxis::AxisType type)
{
auto g = plot.graph(index);
auto it = range.find("lo");
if (it != range.end())
{
switch (type)
{
case QCPAxis::atLeft:
g->valueAxis()->setRangeLower(it->toReal());
break;
case QCPAxis::atBottom:
g->keyAxis()->setRangeLower(it->toReal());
break;
}
}
it = range.find("up");
if (it != range.end())
{
switch (type)
{
case QCPAxis::atLeft:
g->valueAxis()->setRangeUpper(it->toReal());
break;
case QCPAxis::atBottom:
g->keyAxis()->setRangeUpper(it->toReal());
break;
}
}
}
示例5: dateToString
void Globalization::dateToString(int scId, int ecId, const QVariantMap &options) {
time_t time = options.find("time_t")->toLongLong() / 1000;
Globalization::Format formatLength = static_cast<Globalization::Format>(options.find("formatLength")->toInt());
Globalization::Selector selector = static_cast<Globalization::Selector>(options.find("selector")->toInt());
QLocale::FormatType format = translateFormat(formatLength);
if (time < 0) {
this->callback(ecId, QString("new GlobalizationError(%1, 'unsupported operation');").arg(Globalization::FORMATTING_ERROR));
return;
}
QLocale locale;
QString res;
QDateTime dateTime = QDateTime::fromTime_t((uint)time);
switch (selector) {
case SELECTOR_ALL:
res = locale.toString(dateTime,format);
break;
case SELECTOR_TIME:
res = locale.toString(dateTime.time(), format);
break;
case SELECTOR_DATE:
res = locale.toString(dateTime.date(), format);
break;
}
QVariantMap obj;
obj.insert("value", res);
this->cb(scId, obj);
}
示例6: propertiesChanged
void RemoteActivatable::propertiesChanged(const QVariantMap &changedProperties)
{
Q_D(RemoteActivatable);
QStringList propKeys = changedProperties.keys();
QLatin1String deviceUniKey("deviceUni"),
activatableTypeKey("activatableType"),
sharedKey("shared");
QVariantMap::const_iterator it = changedProperties.find(deviceUniKey);
if (it != changedProperties.end())
{
d->deviceUni = it->toString();
propKeys.removeOne(deviceUniKey);
}
it = changedProperties.find(activatableTypeKey);
if (it != changedProperties.end())
{
d->activatableType = (Knm::Activatable::ActivatableType)it->toUInt();
propKeys.removeOne(activatableTypeKey);
}
it = changedProperties.find(sharedKey);
if (it != changedProperties.end())
{
d->shared = it->toBool();
propKeys.removeOne(sharedKey);
}
/*if (propKeys.count()) {
qDebug() << "Unhandled properties: " << propKeys;
}*/
}
示例7: stringToDate
void Globalization::stringToDate(int scId, int ecId, const QVariantMap &options) {
QString dateString = options.find("dateString")->toString();
Globalization::Format formatLength = static_cast<Globalization::Format>(options.find("formatLength")->toInt());
Globalization::Selector selector = static_cast<Globalization::Selector>(options.find("selector")->toInt());
QLocale::FormatType format = translateFormat(formatLength);
QLocale locale;
bool valid(true);
int year(0), month(0), day(0), hour(0), minute(0), second(0), millisecond(0);
switch (selector) {
case SELECTOR_ALL:
{
QDateTime dateTime = locale.toDateTime(dateString, format);
valid = dateTime.isValid();
QTime time = dateTime.time();
hour = time.hour(); minute = time.minute(); second = time.second(); millisecond = time.msec();
QDate date = dateTime.date();
year = date.year(); month = date.month(); day = date.day();
}
break;
case SELECTOR_TIME:
{
QTime time = locale.toTime(dateString, format);
valid = time.isValid();
hour = time.hour(); minute = time.minute(); second = time.second(); millisecond = time.msec();
}
break;
case SELECTOR_DATE:
{
QDate date = locale.toDate(dateString, format);
valid = date.isValid();
year = date.year(); month = date.month(); day = date.day();
}
break;
}
if ((format == QLocale::NarrowFormat || format == QLocale::ShortFormat) && year < 2000 && year > 1900) {
year += 100;
}
if (!valid) {
this->callback(ecId, QString("new GlobalizationError(%1, 'parsing error')").arg(Globalization::PARSING_ERROR));
} else {
QVariantMap obj;
obj.insert("year", year);
obj.insert("month", month - 1);
obj.insert("day", day);
obj.insert("hour", hour);
obj.insert("minute", minute);
obj.insert("second", second);
obj.insert("millisecond", millisecond);
this->cb(scId, obj);
}
}
示例8: updateMainSectionSettings
void KonvergoWindow::updateMainSectionSettings(const QVariantMap& values)
{
// update mouse visibility if needed
if (values.find("disablemouse") != values.end())
{
SystemComponent::Get().setCursorVisibility(!SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "disablemouse").toBool());
}
if (values.find("fullscreen") == values.end())
return;
updateFullscreenState();
}
示例9: findTheme
void DecorationBridge::findTheme(const QVariantMap &map)
{
auto it = map.find(QStringLiteral("themes"));
if (it == map.end()) {
return;
}
if (!it.value().toBool()) {
return;
}
it = map.find(QStringLiteral("defaultTheme"));
m_defaultTheme = it != map.end() ? it.value().toString() : QString();
m_theme = readTheme();
}
示例10: checkErrors
void QCouch::checkErrors(QVariant var){
QVariantMap map = var.toMap();
if ( map.find("error") != map.end() ) {
throw CouchException(map["reason"].toString());
}
}
示例11: if
QVariant & value_unsafe(const QStringList & keys, QVariantMap & context){
QVariantMap* map = &context;
int i = 0;
while(i < keys.size()) {
const QString & key = keys.at(i++);
QVariantMap::iterator it = map->find(key);
if(it == map->constEnd())
return nullVariant;
QVariant & value = *it;
if(i >= keys.size())
return value;
if(value.type() == QVariant::Map)
map = &asMap(value);
else if(i == keys.size() -1 && value.type() == QVariant::List) {
const QString & idxStr = keys.at(i);
bool ok;
int idx = idxStr.toInt(&ok);
if(ok) {
QVariantList & lst = asList(value);
if(idx < lst.size())
return lst[idx];
}
}
else
return nullVariant;
}
return nullVariant;
}
示例12: onPropertiesChanged
void MprisPlayer::onPropertiesChanged(const QDBusMessage &msg)
{
QDBusArgument arg = msg.arguments().at(1).value<QDBusArgument>();
QVariantMap map = qdbus_cast<QVariantMap>(arg);
QVariantMap::const_iterator it = map.find(QLatin1String("Metadata"));
if (it != map.end()) {
arg = it.value().value<QDBusArgument>();
onTrackChanged(qdbus_cast<QVariantMap>(arg));
}
it = map.find(QLatin1String("PlaybackStatus"));
if (it != map.end()) {
DBusMprisPlayerStatus status;
status.Play = it.value().toString() == QLatin1String("Playing") ? 0 : 1;
onStatusChanged(status);
}
}
示例13: testFlashValidatorsDriver
static void testFlashValidatorsDriver(const QVariantMap ¶ms, const QVariantMap &validators, Context::Errors &errors)
{
QVariantMap::const_iterator ii, endii;
QVariantMap::const_iterator vv;
endii = params.end();
for (ii = params.begin(); ii != endii; ++ii) {
// check if there is a validator for this param
vv = validators.find(ii.key());
if (vv == validators.end())
continue;
// if its a map, we recurse
if (vv->type() == QVariant::Map)
testFlashValidatorsDriver(asVariantMap(*ii), asVariantMap(*vv), errors);
else {
// its not a map, execute the validator
ValidationExpr validexpr = ValidationExpr::fromVariant(*vv);
QStringList errorslist;
validexpr.test(*ii, &errorslist);
if (!errorslist.isEmpty())
errors[ii.key()] = errorslist;
}
}
}
示例14: themeListKeyword
static QString themeListKeyword(const QVariantMap &decoSettingsMap)
{
auto it = decoSettingsMap.find(QStringLiteral("themeListKeyword"));
if (it == decoSettingsMap.end()) {
return QString();
}
return it.value().toString();
}
示例15: isConfigureable
static bool isConfigureable(const QVariantMap &decoSettingsMap)
{
auto it = decoSettingsMap.find(QStringLiteral("kcmodule"));
if (it == decoSettingsMap.end()) {
return false;
}
return it.value().toBool();
}