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


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

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


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

示例1: fillFromJson

void dataBase::fillFromJson(const QString &path)
{
    QProgressBar bar;
    bar.show();
    QFile file(path);
    if(!file.open(QFile::ReadOnly))
    {
        throw std::runtime_error(("No file "+ path).toStdString());
    }
    bool ok = false;
    QVariantMap map = QtJson::parse(QString::fromUtf8(file.readAll().data()), ok).toMap();
    if(!ok)
    {
        throw std::runtime_error(("Cant parse "+ path).toStdString());
    }
    for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it)
    {
        QList<QVariant> list = it.value().toList();
        for(QList<QVariant>::const_iterator list_it = list.begin(); list_it != list.end(); ++list_it)
        {
            bar.setValue(bar.value() >= bar.maximum() ? 0 : bar.value()+1);
            qApp->processEvents();
            QList<QVariant> values = list_it->toList();
            QString q_text = QString("INSERT INTO %1 ( coeff, hrn  ) VALUES ( '%2', '%3' )")
                    .arg(it.key())
                    .arg(values.at(0).toString())
                    .arg(values.at(1).toString());

            query(q_text);
        }
    }
    QList<QVariant> regions = map["regions"].toList();
    for(QList<QVariant>::const_iterator it = regions.begin(); it!= regions.end(); ++it )
    {
        QList<QVariant> towns = it->toList().at(2).toList();
        for(QList<QVariant>::const_iterator town_it = towns.begin(); town_it != towns.end(); ++town_it )
        {
            bar.setValue(bar.value() >= bar.maximum() ? 0 : bar.value()+1);
            qApp->processEvents();
            QList<QVariant> town_desc = town_it->toList();
            QString q_text = QString("INSERT INTO towns VALUES ( %1, '%2', %3, %4, %5)")
                    .arg(town_desc.at(0).toInt())
                    .arg(town_desc.at(1).toString())
                    .arg(town_desc.at(2).toString())
                    .arg(town_desc.at(3).toString())
                    .arg(it->toList().at(0).toInt());
            query(q_text);
        }
    }
    bar.close();
}
开发者ID:ruslanfirefly,项目名称:CalcKaskoAsko,代码行数:51,代码来源:database.cpp

示例2: 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);
}
开发者ID:beyondyuanshu,项目名称:qt-creator,代码行数:51,代码来源:addqtoperation.cpp

示例3: BufferViewManager

CoreBufferViewManager::CoreBufferViewManager(SignalProxy *proxy, CoreSession *parent)
    : BufferViewManager(proxy, parent),
    _coreSession(parent)
{
    QVariantMap views = Core::getUserSetting(_coreSession->user(), "BufferViews").toMap();
    QVariantMap::iterator iter = views.begin();
    QVariantMap::iterator iterEnd = views.end();
    CoreBufferViewConfig *config = 0;
    while (iter != iterEnd) {
        config = new CoreBufferViewConfig(iter.key().toInt(), iter.value().toMap(), this);
        addBufferViewConfig(config);
        ++iter;
    }
}
开发者ID:Nekka-Lucifer,项目名称:quassel,代码行数:14,代码来源:corebufferviewmanager.cpp

示例4: setWidgetData

void table_widget_delegate::setWidgetData(const QModelIndex &index, QWidget *editor, const QVariant& data) const
{
	if (!editor){
		return;
	}

	column_data_ptr cd = _column_datas[index.column()];
	if (!cd){
		return;
	}

	switch (cd->type)
	{
	case WIDGET_CHECKBOX:
        {
            QCheckBox *widget = qobject_cast<QCheckBox*>(editor);
            if(widget){
                widget->setChecked(data.toBool());
            }
        }
		break;
	case  WIDGET_COMBOBOX:
		{
			QComboBox *widget = qobject_cast<QComboBox*>(editor);
			switch (cd->data.type())
			{
			case QVariant::StringList:
				widget->setCurrentText(data.toString());
				break;
			case QVariant::Map:
				{
					  QVariantMap map = cd->data.toMap();
					  QString text;
					  for (auto it = map.begin(); it != map.end(); ++it){
						  if (data == it.value()){
							  text = it.key();
						  }
					  }

					  widget->setCurrentText(text);
				}
				break;
			default:
				break;
			}
		}
	default:
		break;
	}
}
开发者ID:jadderbao,项目名称:http-post-test,代码行数:50,代码来源:table_widget_delegate.cpp

示例5: findKey

QStringList FindKeyOperation::findKey(const QVariantMap &map, const QString &key)
{
    QStringList result;
    for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) {
        if (i.key() == key) {
            result << key;
            continue;
        }
        if (i.value().type() == QVariant::Map) {
            QStringList subKeyList = findKey(i.value().toMap(), key);
            foreach (const QString &subKey, subKeyList)
                result << i.key() + QLatin1Char('/') + subKey;
        }
    }
开发者ID:gs93,项目名称:qt-creator,代码行数:14,代码来源:findkeyoperation.cpp

示例6: compare

static bool compare(const QVariantMap& one, const QVariantMap& other)
{
    if (one.size() != other.size())
        return false;

    QVariantMap::const_iterator it1 = one.begin();
    QVariantMap::const_iterator it2 = other.begin();

    while (it1 != one.end()) {
        if (it1.value().userType() != it2.value().userType())
            return false;
        if (!(it1.value() == it2.value())) {
            if (it1.value().userType() == qMetaTypeId<QDBusObjectPath>()) {
                if (!(it1.value().value<QDBusObjectPath>() == it2.value().value<QDBusObjectPath>()))
                    return false;
            }
        }
        if (qMapLessThanKey(it1.key(), it2.key()) || qMapLessThanKey(it2.key(), it1.key()))
            return false;
        ++it2;
        ++it1;
    }
    return true;
}
开发者ID:andyhelp,项目名称:pkg-mpristester,代码行数:24,代码来源:tracklistinterfacetest.cpp

示例7: setParameters

void RecognitionDatabase::setParameters(const QVariantMap& parameters)
{
    if (!d || !d->dbAvailable)
    {
        return;
    }

    QMutexLocker lock(&d->mutex);

    for (QVariantMap::const_iterator it = parameters.begin(); it != parameters.end(); ++it)
    {
        d->parameters.insert(it.key(), it.value());
    }

    d->applyParameters();
}
开发者ID:KDE,项目名称:libkface,代码行数:16,代码来源:recognitiondatabase.cpp

示例8: prettyPrint

QString
Utilities::prettyPrint(const QVariantMap & map)
{
  QString res;
  res.append("{\n");

  QVariantMap::const_iterator itr = map.begin();
  res.append(QString("%1=%2").arg(itr.key(), prettyPrint(itr.value())));

  for (++itr; itr != map.end(); ++itr) {
    res.append(QString("; %1=%2").arg(itr.key(), prettyPrint(itr.value())));
  }

  res.append("}\n");
  return res;
}
开发者ID:Entomologist,项目名称:entomologist,代码行数:16,代码来源:Utilities.cpp

示例9: serialize

void JSONSerializer::serialize(const QVariant &variant) {
	if (!variant.isValid()) { // Case of JSON null/undefined
		// TODO:find a way to differenciate null/undefined
		m_stream << JSON_NULL;
	} else if (variant.type() == QVariant::Bool) { // Case of JSON boolean
		m_stream << (variant.toBool() ? JSON_TRUE: JSON_FALSE);
	} else if (variant.type() == QVariant::Map) { // Case of JSON object
		m_stream << JSON_OBJECT_BEGIN;
		const QVariantMap elements = variant.toMap();
		auto it = elements.begin();
		if (it != elements.end()) {
			m_stream << sanitizeString(it.key()) << JSON_MEMBER_SEP;
			serialize(it.value());
			it++;
		}
		while (it != elements.end()) {
			m_stream << JSON_ELEMENT_SEP << sanitizeString(it.key()) << JSON_MEMBER_SEP;
			serialize(it.value());
			it++;
		}
		m_stream << JSON_OBJECT_END;
	} else if (variant.type() == QVariant::List) { // Case of JSON array
		m_stream << JSON_ARRAY_BEGIN;
		const QVariantList elements = variant.toList();
		auto it = elements.begin();
		if (it != elements.end()) {
			serialize(*it);
			it++;
		}
		while (it != elements.end()) {
			m_stream << JSON_MEMBER_SEP;
			serialize(*it);
			it++;
		}
		m_stream << JSON_ARRAY_END;
	} else if ((variant.type() == QVariant::String) 
		|| (variant.type() == QVariant::ByteArray)) { // Case of JSON string
		m_stream << sanitizeString(variant.toString());
	} else if ((variant.type() == QVariant::Double) || variant.canConvert<double>()) {
		m_stream << QString::number(variant.toDouble()).replace("inf", "infinity");
	} else if ((variant.type() == QVariant::String) || variant.canConvert<QString>()) {
		m_stream << variant.toString();
	} else {
		throw JSONSerializerException("Fatal: QVariant type not managed.");
	}
}
开发者ID:ProgVal,项目名称:JSONBus,代码行数:46,代码来源:jsonserializer.cpp

示例10: handleRequest

QVariantMap SetConfigHandler::handleRequest(QVariantMap request) {
	if (request["target"] != "set_config") {
		return next->handleRequest(request);
	}

	QSettings settings("config/config.ini", QSettings::IniFormat);
	settings.setIniCodec("UTF-8");
	QVariantMap items = request["items"].toMap();
	QVariantMap response;

	// 依次设置每一项,未作检测,危险
	for (auto it = items.begin(); it != items.end(); it++) {
		settings.setValue(it.key(), it.value());
	}
	response["status"] = "ok";
	return response;
}
开发者ID:shilohchi,项目名称:PacketCapture,代码行数:17,代码来源:SetConfigHandler.cpp

示例11: qvariant2qobject

void qvariant2qobject(const QVariantMap& variant, T* object)
{
    for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter )
    {
        const int propertyIndex = T::staticMetaObject.indexOfProperty(iter.key().toLatin1());
        if (propertyIndex < 0) {
            qCWarning(KDECONNECT_CORE) << "missing property" << object << iter.key();
            continue;
        }

        QMetaProperty property = T::staticMetaObject.property(propertyIndex);
        bool ret = property.writeOnGadget(object, *iter);
        if (!ret) {
            qCWarning(KDECONNECT_CORE) << "couldn't set" << object << "->" << property.name() << '=' << *iter;
        }
    }
}
开发者ID:KDE,项目名称:kdeconnect-kde,代码行数:17,代码来源:networkpackage.cpp

示例12: setConfig

void QgsValueMapConfigDlg::setConfig( const QVariantMap& config )
{
  tableWidget->clearContents();
  for ( int i = tableWidget->rowCount() - 1; i > 0; i-- )
  {
    tableWidget->removeRow( i );
  }

  int row = 0;
  QVariantMap values = config.value( QStringLiteral( "map" ) ).toMap();
  for ( QVariantMap::ConstIterator mit = values.begin(); mit != values.end(); mit++, row++ )
  {
    if ( mit.value().isNull() )
      setRow( row, mit.key(), QString() );
    else
      setRow( row, mit.value().toString(), mit.key() );
  }
}
开发者ID:wongjimsan,项目名称:QGIS,代码行数:18,代码来源:qgsvaluemapconfigdlg.cpp

示例13: fromVariant

 void ReplicaSetSettings::fromVariant(const QVariantMap &map) 
 {
     setSetName(map.value("setName").toString().toStdString());
     // Extract and set replica members
     std::vector<std::string> vec;
     auto itr = map.begin();
     int idx = 0;
     do
     {
         itr = map.find(QString::number(idx));
         if (map.end() == itr) break;
         vec.push_back(itr->toString().toStdString());
         ++idx;
     } while (map.end() != itr);
     setMembers(vec);
     // Extract and set read reference
     setReadPreference(static_cast<ReadPreference>(map.value("readPreference").toInt()));
 }
开发者ID:luketn,项目名称:robomongo,代码行数:18,代码来源:ReplicaSetSettings.cpp

示例14: toJSLiteral_impl

static QString toJSLiteral_impl(const QVariantMap &vm, int level = 0)
{
    QString indent;
    for (int i = 0; i < level; ++i)
        indent += QLatin1String("    ");
    QString str;
    for (QVariantMap::const_iterator it = vm.begin(); it != vm.end(); ++it) {
        if (it.value().type() == QVariant::Map) {
            str += indent + it.key() + QLatin1String(": {\n");
            str += toJSLiteral_impl(it.value().toMap(), level + 1);
            str += indent + QLatin1String("}\n");
        } else {
            str += indent + it.key() + QLatin1String(": ") + toJSLiteral(it.value())
                    + QLatin1Char('\n');
        }
    }
    return str;
}
开发者ID:zebbra2014,项目名称:qt-labs-qbs,代码行数:18,代码来源:propertymapinternal.cpp

示例15: undoOperation

bool LicenseOperation::undoOperation()
{
    const QVariantMap licenses = value(QLatin1String("licenses")).toMap();
    if (licenses.isEmpty()) {
        setError(UserDefinedError);
        setErrorString(tr("No license files found to delete."));
        return false;
    }

    QString targetDir = arguments().value(0);
    for (QVariantMap::const_iterator it = licenses.begin(); it != licenses.end(); ++it)
        QFile::remove(targetDir + QDir::separator() + it.key());

    QDir dir;
    dir.rmdir(targetDir);

    return true;
}
开发者ID:qtproject,项目名称:installer-framework,代码行数:18,代码来源:licenseoperation.cpp


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