当前位置: 首页>>代码示例>>C++>>正文


C++ QVariantMap::isEmpty方法代码示例

本文整理汇总了C++中QVariantMap::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::isEmpty方法的具体用法?C++ QVariantMap::isEmpty怎么用?C++ QVariantMap::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVariantMap的用法示例。


在下文中一共展示了QVariantMap::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fillFromForeignMap

/*
 * initialize OrderData from QVariantMap
 * Map got from JsonDataAccess or so
 * includes also transient values
 * uses foreign property names - per ex. from Server API
 * corresponding export method: toForeignMap()
 */
void Customer::fillFromForeignMap(const QVariantMap& customerMap)
{
	mId = customerMap.value(idForeignKey).toInt();
	mCompanyName = customerMap.value(companyNameForeignKey).toString();
	// mCoordinate points to GeoCoordinate*
	if (customerMap.contains(coordinateForeignKey)) {
		QVariantMap coordinateMap;
		coordinateMap = customerMap.value(coordinateForeignKey).toMap();
		if (!coordinateMap.isEmpty()) {
			mCoordinate = 0;
			mCoordinate = new GeoCoordinate();
			mCoordinate->setParent(this);
			mCoordinate->fillFromForeignMap(coordinateMap);
		}
	}
	// mGeoAddress points to GeoAddress*
	if (customerMap.contains(geoAddressForeignKey)) {
		QVariantMap geoAddressMap;
		geoAddressMap = customerMap.value(geoAddressForeignKey).toMap();
		if (!geoAddressMap.isEmpty()) {
			mGeoAddress = 0;
			mGeoAddress = new GeoAddress();
			mGeoAddress->setParent(this);
			mGeoAddress->fillFromForeignMap(geoAddressMap);
		}
	}
}
开发者ID:ekke,项目名称:ekkes_dsl_sample,代码行数:34,代码来源:Customer.cpp

示例2: fromVariantMap

void NodeModel::fromVariantMap(const QVariantMap& map){

    QVariantList pos = map["Position"].toList();
    QVariantMap netDeviceMap = map["NetDevice"].toMap();
    QVariantMap noiseSourceMap = map["NoiseSource"].toMap();

    //Migration for older versions of the dgm files.
    if(netDeviceMap.isEmpty()){
        QVariantList netDevicesList = map["NetDevices"].toList();
        if(!netDevicesList.isEmpty()){
            netDeviceMap = netDevicesList.at(0).toMap();
        }
    }

    if(noiseSourceMap.isEmpty()){
        QVariantList noiseSourcesList = map["NoiseSources"].toList();
        if(!noiseSourcesList.isEmpty()){
            noiseSourceMap = noiseSourcesList.at(0).toMap();
        }
    }

    name = map["Name"].toString();
    position = QPointF(pos.at(0).toDouble(), pos.at(1).toDouble());

    if (!netDeviceMap.isEmpty()){
        netDevice = new NetDeviceModel(netDeviceMap);
    }

    if(!noiseSourceMap.isEmpty()){
        noiseSource = new NoiseSourceModel(noiseSourceMap);
    }

    this->hasOutlet = map["HasOutlet"].toBool();
    this->outletImpedance.setValue(map["OutletImpedance"].toString());
}
开发者ID:Bakhazard,项目名称:plc-gnosis,代码行数:35,代码来源:nodemodel.cpp

示例3: failure

void
YTVideoUrlFetcher::onProcessFinished(int code, QProcess::ExitStatus status)
{
    qDebug() << "youtube-dl process finished, status:" << status
             << ", exit code:" << code;
    if (status == QProcess::NormalExit && code == 0) {
        QByteArray rawJson = _process->readAllStandardOutput();
        QJsonParseError error;
        QJsonDocument doc = QJsonDocument::fromJson(rawJson, &error);
        if (error.error != QJsonParseError::NoError) {
            qCritical() << "JSON parse error:" << error.errorString();
            emit failure();
        } else {
            Q_ASSERT(!doc.isNull());
            QVariantMap response = parseResponse(doc);
            if (!response.isEmpty()) {
                QVariantMap map = doc.toVariant().toMap();
                Q_ASSERT(!map.isEmpty() && map.contains("id"));
                _response_cache.insert(map["id"].toString(), new QVariantMap(response));
                emit success(response);
            } else {
                emit failure();
            }
        }
    } else {
        qCritical() << "YouTubeDL process did not finish cleanly:"
                    << _process->readAllStandardError();
        emit failure();
    }
    delete _process;
    _process = NULL;
}
开发者ID:mschaaf,项目名称:sailfish-ytplayer,代码行数:32,代码来源:YTVIdeoUrlFetcher.cpp

示例4: execute

int AddToolChainOperation::execute() const
{
    QVariantMap map = load(QLatin1String("toolchains"));
    if (map.isEmpty())
        map = initializeToolChains();

    QVariantMap result = addToolChain(map, m_id, m_displayName, m_path, m_targetAbi, m_supportedAbis, m_extra);
    if (result.isEmpty() || map == result)
        return 2;

    return save(result, QLatin1String("toolchains")) ? 0 : 3;
}
开发者ID:aizaimenghuangu,项目名称:QtTestor,代码行数:12,代码来源:addtoolchainoperation.cpp

示例5: connectToService

bool QgsAfsSourceSelect::connectToService( const QgsOwsConnection &connection )
{
  QString errorTitle, errorMessage;
  QVariantMap serviceInfoMap = QgsArcGisRestUtils::getServiceInfo( connection.uri().param( "url" ), errorTitle, errorMessage );
  if ( serviceInfoMap.isEmpty() )
  {
    QMessageBox::warning( this, tr( "Error" ), tr( "Failed to retrieve service capabilities:\n%1: %2" ).arg( errorTitle ).arg( errorMessage ) );
    return false;
  }

  QStringList layerErrors;
  foreach ( const QVariant& layerInfo, serviceInfoMap["layers"].toList() )
  {
    QVariantMap layerInfoMap = layerInfo.toMap();
    if ( !layerInfoMap["id"].isValid() )
    {
      continue;
    }

    // Get layer info
    QVariantMap layerData = QgsArcGisRestUtils::getLayerInfo( connection.uri().param( "url" ) + "/" + layerInfoMap["id"].toString(), errorTitle, errorMessage );
    if ( layerData.isEmpty() )
    {
      layerErrors.append( tr( "Layer %1: %2 - %3" ).arg( layerInfoMap["id"].toString() ).arg( errorTitle ).arg( errorMessage ) );
      continue;
    }
    // insert the typenames, titles and abstracts into the tree view
    QStandardItem* idItem = new QStandardItem( layerData["id"].toString() );
    QStandardItem* nameItem = new QStandardItem( layerData["name"].toString() );
    QStandardItem* abstractItem = new QStandardItem( layerData["description"].toString() );
    abstractItem->setToolTip( layerData["description"].toString() );
    QStandardItem* cachedItem = new QStandardItem();
    QStandardItem* filterItem = new QStandardItem();
    cachedItem->setCheckable( true );
    cachedItem->setCheckState( Qt::Checked );

    QgsCoordinateReferenceSystem crs = QgsArcGisRestUtils::parseSpatialReference( serviceInfoMap["spatialReference"].toMap() );
    if ( !crs.isValid() )
    {
      // If not spatial reference, just use WGS84
      crs.createFromString( "EPSG:4326" );
    }
    mAvailableCRS[layerData["name"].toString()] = QList<QString>()  << crs.authid();

    mModel->appendRow( QList<QStandardItem*>() << idItem << nameItem << abstractItem << cachedItem << filterItem );
  }
  if ( !layerErrors.isEmpty() )
  {
    QMessageBox::warning( this, tr( "Error" ), tr( "Failed to query some layers:\n%1" ).arg( layerErrors.join( "\n" ) ) );
  }
  return true;
}
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:52,代码来源:qgsafssourceselect.cpp

示例6: execute

int AddQtOperation::execute() const
{
    QVariantMap map = load(QLatin1String("qtversions"));
    if (map.isEmpty())
        map = initializeQtVersions();

    QVariantMap result = addQt(map, m_id, m_displayName, m_type, m_qmake, m_extra);

    if (result.isEmpty() || result == map)
        return 2;

    return save(result, QLatin1String("qtversions")) ? 0 : 3;
}
开发者ID:aizaimenghuangu,项目名称:QtTestor,代码行数:13,代码来源:addqtoperation.cpp

示例7: execute

int AddDebuggerOperation::execute() const
{
    QVariantMap map = load(QLatin1String("Debuggers"));
    if (map.isEmpty())
        map = initializeDebuggers();

    QVariantMap result = addDebugger(map, m_id, m_displayName, m_engine, m_binary, m_abis,
                                     m_extra);

    if (result.isEmpty() || map == result)
        return 2;

    return save(result, QLatin1String("Debuggers")) ? 0 : 3;
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:14,代码来源:adddebuggeroperation.cpp

示例8: execute

int AddKitOperation::execute() const
{
    QVariantMap map = load(QLatin1String("profiles"));
    if (map.isEmpty())
        map = initializeKits();

    map = addKit(map, m_id, m_displayName, m_icon, m_debuggerEngine, m_debugger,
                 m_deviceType.toUtf8(), m_sysRoot, m_tc, m_qt, m_mkspec, m_extra);

    if (map.isEmpty())
        return -2;

    return save(map, QLatin1String("profiles")) ? 0 : -3;
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:14,代码来源:addkitoperation.cpp

示例9: mergeMaps

static QVariantMap mergeMaps(const QVariantMap &map1,
                             const QVariantMap &map2)
{
    if (map1.isEmpty()) return map2;
    if (map2.isEmpty()) return map1;

    QVariantMap map = map1;
    //map2 values will overwrite map1 values for the same keys.
    QMapIterator<QString, QVariant> it(map2);
    while (it.hasNext()) {
        it.next();
        map.insert(it.key(), it.value());
    }
    return map;
}
开发者ID:ds9-debian-packaging-backports,项目名称:accounts-qml-module,代码行数:15,代码来源:account-service.cpp

示例10: execute

int AddKitOperation::execute() const
{
    QVariantMap map = load("Profiles");
    if (map.isEmpty())
        map = initializeKits();

    QVariantMap result = addKit(map, m_id, m_displayName, m_icon, m_debuggerId, m_debuggerEngine,
                                m_debugger, m_deviceType, m_device, m_sysRoot, m_tcs, m_qt,
                                m_mkspec, m_env, m_extra);

    if (result.isEmpty() || map == result)
        return 2;

    return save(result, "Profiles") ? 0 : 3;
}
开发者ID:qrsrjm,项目名称:qt-creator,代码行数:15,代码来源:addkitoperation.cpp

示例11: test

bool AddToolChainOperation::test() const
{
    QVariantMap map = initializeToolChains();

    // Add toolchain:
    map = addToolChain(map, QLatin1String("testId"), QLatin1String("name"), QLatin1String("/tmp/test"),
                            QLatin1String("test-abi"), QLatin1String("test-abi,test-abi2"),
                            KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue"))));
    if (map.value(QLatin1String(COUNT)).toInt() != 1
            || !map.contains(QString::fromLatin1(PREFIX) + QLatin1Char('0')))
        return false;
    QVariantMap tcData = map.value(QString::fromLatin1(PREFIX) + QLatin1Char('0')).toMap();
    if (tcData.count() != 7
            || tcData.value(QLatin1String(ID)).toString() != QLatin1String("testId")
            || tcData.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("name")
            || tcData.value(QLatin1String(AUTODETECTED)).toBool() != true
            || tcData.value(QLatin1String(PATH)).toString() != QLatin1String("/tmp/test")
            || tcData.value(QLatin1String(TARGET_ABI)).toString() != QLatin1String("test-abi")
            || tcData.value(QLatin1String(SUPPORTED_ABIS)).toList().count() != 2
            || tcData.value(QLatin1String("ExtraKey")).toString() != QLatin1String("ExtraValue"))
        return false;

    // Ignore same Id:
    QVariantMap unchanged = addToolChain(map, QLatin1String("testId"), QLatin1String("name2"), QLatin1String("/tmp/test2"),
                                              QLatin1String("test-abi2"), QLatin1String("test-abi2,test-abi3"),
                                              KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue2"))));
    if (!unchanged.isEmpty())
        return false;

    // Make sure name stays unique:
    map = addToolChain(map, QLatin1String("testId2"), QLatin1String("name"), QLatin1String("/tmp/test"),
                            QLatin1String("test-abi"), QLatin1String("test-abi,test-abi2"),
                            KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue"))));
    if (map.value(QLatin1String(COUNT)).toInt() != 2
            || !map.contains(QString::fromLatin1(PREFIX) + QLatin1Char('0'))
            || !map.contains(QString::fromLatin1(PREFIX) + QLatin1Char('1')))
        return false;
    tcData = map.value(QString::fromLatin1(PREFIX) + QLatin1Char('0')).toMap();
    if (tcData.count() != 7
            || tcData.value(QLatin1String(ID)).toString() != QLatin1String("testId")
            || tcData.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("name")
            || tcData.value(QLatin1String(AUTODETECTED)).toBool() != true
            || tcData.value(QLatin1String(PATH)).toString() != QLatin1String("/tmp/test")
            || tcData.value(QLatin1String(TARGET_ABI)).toString() != QLatin1String("test-abi")
            || tcData.value(QLatin1String(SUPPORTED_ABIS)).toList().count() != 2
            || tcData.value(QLatin1String("ExtraKey")).toString() != QLatin1String("ExtraValue"))
        return false;
    tcData = map.value(QString::fromLatin1(PREFIX) + QLatin1Char('1')).toMap();
        if (tcData.count() != 7
                || tcData.value(QLatin1String(ID)).toString() != QLatin1String("testId2")
                || tcData.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("name2")
                || tcData.value(QLatin1String(AUTODETECTED)).toBool() != true
                || tcData.value(QLatin1String(PATH)).toString() != QLatin1String("/tmp/test")
                || tcData.value(QLatin1String(TARGET_ABI)).toString() != QLatin1String("test-abi")
                || tcData.value(QLatin1String(SUPPORTED_ABIS)).toList().count() != 2
                || tcData.value(QLatin1String("ExtraKey")).toString() != QLatin1String("ExtraValue"))
            return false;

    return true;
}
开发者ID:aizaimenghuangu,项目名称:QtTestor,代码行数:60,代码来源:addtoolchainoperation.cpp

示例12: generate

bool Theme::generate(const QString &path, Theme *theme)
{
    QJsonDocument doc = QkUtils::jsonFromFile(path);

    if(doc.isNull())
        return false;

    QVariantMap themeJson = doc.object().toVariantMap();

    theme->globalStyle = themeJson["globalStyle"].toString();
    theme->editorStyle = themeJson["editorStyle"].toString();
    theme->syntax = themeJson["syntax"].toString();

    QVariantMap paletteJson = themeJson["palette"].toJsonObject().toVariantMap();
    if(!paletteJson.isEmpty())
    {
        theme->globalPalette.setColor(QPalette::Window,     QColor(paletteJson["window"].toString()));
        theme->globalPalette.setColor(QPalette::WindowText, QColor(paletteJson["windowText"].toString()));
        theme->globalPalette.setColor(QPalette::Base, QColor(paletteJson["base"].toString()));
        theme->globalPalette.setColor(QPalette::AlternateBase, QColor(paletteJson["alternateBase"].toString()));
        theme->globalPalette.setColor(QPalette::ToolTipBase, QColor(paletteJson["toolTipBase"].toString()));
        theme->globalPalette.setColor(QPalette::ToolTipText, QColor(paletteJson["toolTipText"].toString()));
        theme->globalPalette.setColor(QPalette::Text, QColor(paletteJson["text"].toString()));
        theme->globalPalette.setColor(QPalette::Button, QColor(paletteJson["button"].toString()));
        theme->globalPalette.setColor(QPalette::ButtonText, QColor(paletteJson["buttonText"].toString()));
    }

    return true;
}
开发者ID:qkthings,项目名称:qkide,代码行数:29,代码来源:theme.cpp

示例13: _q_onRequestFinished

void ResourcesModelPrivate::_q_onRequestFinished() {
    if (!request) {
        return;
    }

    Q_Q(ResourcesModel);

    if (request->status() == ResourcesRequest::Ready) {
        const QVariantMap result = request->result().toMap();
    
        if (!result.isEmpty()) {
            next = result.value("next").toString();
            previous = result.value("previous").toString();
        
            const QVariantList list = result.value("items").toList();
        
            if (!list.isEmpty()) {
                if (roles.isEmpty()) {
                    setRoleNames(list.first().toMap());
                }
                
                q->beginInsertRows(QModelIndex(), items.size(), items.size() + list.size() - 1);
                
                foreach (const QVariant &item, list) {
                    items << item.toMap();
                }
                
                q->endInsertRows();
                emit q->countChanged(q->rowCount());
            }
        }
    }
开发者ID:marxoft,项目名称:libcuteradio,代码行数:32,代码来源:resourcesmodel.cpp

示例14: icon

	foreach(QVariantMap devil, mDevilData)
	{
		if( devil.isEmpty() )
			continue;

		QVariantMap devil_info = cache->devilByID( devil.value("id").toInt() );

		QString lbl = tr("lv%2 %1").arg( devil_info.value("name").toString()
			).arg(devil.value("lvl").toInt() );

		QPixmap icon( QString("icons/devils/icon_%1.png").arg(
			devil_info.value("icon").toString() ) );

		QString tooltip = cache->devilToolTip(devil);

		mDevilLabels.at(i)->setText(lbl);
		mDevilLabels.at(i)->setToolTip(tooltip);
		mDevilIcons.at(i)->setPixmap(icon);
		mDevilIcons.at(i)->setToolTip(tooltip);
		mDevilIcons2.at(i)->setPixmap(icon);
		mDevilIcons2.at(i)->setToolTip(tooltip);

		for(int j = 0; j < max; j++)
		{
			if(j <= i)
				continue;

			if( mDevilData.at(j).isEmpty() )
				continue;

			calculateFusion(i, j);
		}

		i++;
	}
开发者ID:erikku,项目名称:frosty,代码行数:35,代码来源:FusionChart.cpp

示例15: processMessageRequest

void AppController::processMessageRequest(QList<QByteArray> return_path, QList<QByteArray> payload) {
    QVariantMap response;
    
    QString request = QString::fromUtf8(payload.at(0));
//    qDebug() << "request has" << payload.size() << "packets (expecting 2)";
//    qDebug() << "request verb:" << request;
    
    if(request == "get-devices") {
        response = doGetDevices();
    } else if(request == "get-device" && payload.size() == 2) {
        QString key = payload.at(1);
//        qDebug() << "get-device for key:" << key;
        response = doGetDevice(key);
    } else {
        qDebug() << "request payload not recognized - ignoring";
        return;
    }
    
    MessageHandler* msg_handler = dynamic_cast<MessageHandler*>(sender());
    if(!response.isEmpty() && msg_handler) {
        QList<QByteArray> data;
        data.append(variantMapToJson(response));
//        qDebug() << "sending:" << data;
        msg_handler->sendResponse(return_path, data);
    }
    
}
开发者ID:UpsilonAudio,项目名称:charger,代码行数:27,代码来源:app_controller.cpp


注:本文中的QVariantMap::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。