本文整理汇总了C++中QVariantList类的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList类的具体用法?C++ QVariantList怎么用?C++ QVariantList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QVariantList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeOra
void Core::writeOra(const QString& oraPath, const QSize& canvasSize, const QVariantList layerList) {
QZipWriter zipWriter(oraPath);
zipWriter.setCompressionPolicy(QZipWriter::AutoCompress);
QByteArray xmlByteArray;
// mimetype file
xmlByteArray.append("image/openraster");
zipWriter.addFile("mimetype", xmlByteArray);
// stack.xml file
QXmlStreamWriter stream(&xmlByteArray);
stream.setAutoFormatting(true);
stream.writeStartDocument();
stream.writeStartElement("image");
stream.writeAttribute("w", QString::number(canvasSize.width()));
stream.writeAttribute("h",QString::number(canvasSize.height()));
stream.writeStartElement("stack");
QByteArray ba;
QBuffer buffer(&ba);
for (int i = 0; i < layerList.count(); i++) {
QMap<QString, QVariant> map = layerList.at(i).toMap();
QString name = map.value("name").toString();
QString isVisible = map.value("isVisible").toString();
QString isLock = map.value("isLock").toString();
QString isSelected = map.value("isSelected").toString();
buffer.open(QIODevice::WriteOnly);
QObject* obj = qvariant_cast<QObject*>(map.value("canvasItem"));
CanvasItem* canvasItem = qobject_cast<CanvasItem*>(obj);
QPixmap* pixmap = canvasItem->pixmap();
pixmap->save(&buffer, "PNG");
buffer.close();
QString src = "data/" + name + ".png";
zipWriter.addFile(src, ba);
// layer
stream.writeStartElement("layer");
stream.writeAttribute("name", name);
stream.writeAttribute("composite-op", "svg:src-over");
stream.writeAttribute("visibility", isVisible == "true" ? "visible" : "hidden");
stream.writeAttribute("edit-locked", isLock);
stream.writeAttribute("selected", isSelected);
stream.writeAttribute("src", src);
stream.writeAttribute("x", "0");
stream.writeAttribute("y", "0");
stream.writeAttribute("opacity", "1.0");
stream.writeEndElement(); // layer
}
stream.writeEndElement(); // stack
stream.writeEndElement(); // image
stream.writeEndDocument(); // document
zipWriter.addFile("stack.xml", xmlByteArray);
zipWriter.close();
}
示例2: getSelf
QScriptValue
REcmaSharedPointerBlock::getProperty
(QScriptContext* context, QScriptEngine* engine)
{
//REcmaHelper::functionStart("REcmaSharedPointerBlock::getProperty", context, engine);
//qDebug() << "ECMAScript WRAPPER: REcmaSharedPointerBlock::getProperty";
//QCoreApplication::processEvents();
QScriptValue result = engine->undefinedValue();
// public function: can be called from ECMA wrapper of ECMA shell:
RBlock* self =
getSelf("getProperty", context);
//Q_ASSERT(self!=NULL);
if (self==NULL) {
return REcmaHelper::throwError("self is NULL", context);
}
if( context->argumentCount() ==
1 && (
context->argument(0).isVariant() ||
context->argument(0).isQObject() ||
context->argument(0).isNull()
) /* type: RPropertyTypeId */
){
// prepare arguments:
// argument isCopyable and has default constructor and isSimpleClass
RPropertyTypeId*
ap0 =
qscriptvalue_cast<
RPropertyTypeId*
>(
context->argument(
0
)
);
if (ap0 == NULL) {
return REcmaHelper::throwError("RBlock: Argument 0 is not of type RPropertyTypeId.",
context);
}
RPropertyTypeId
a0 =
*ap0;
// end of arguments
// call C++ function:
// return type 'QPair < QVariant , RPropertyAttributes >'
QPair < QVariant , RPropertyAttributes > cppResult =
self->getProperty(a0);
// return type: QPair < QVariant , RPropertyAttributes >
// Pair of ...:
//result = REcmaHelper::pairToScriptValue(engine, cppResult);
QVariantList vl;
QVariant v;
// first type of pair is variant:
if (QString(cppResult.first.typeName())=="RLineweight::Lineweight") {
v.setValue((int)cppResult.first.value<RLineweight::Lineweight>());
}
else {
v.setValue(cppResult.first);
}
vl.append(v);
v.setValue(cppResult.second);
vl.append(v);
result = qScriptValueFromValue(engine, vl);
} else
if( context->argumentCount() ==
2 && (
context->argument(0).isVariant() ||
context->argument(0).isQObject() ||
context->argument(0).isNull()
) /* type: RPropertyTypeId */
&& (
context->argument(1).isBool()
) /* type: bool */
){
// prepare arguments:
// argument isCopyable and has default constructor and isSimpleClass
RPropertyTypeId*
ap0 =
qscriptvalue_cast<
RPropertyTypeId*
//.........这里部分代码省略.........
示例3: writeInstance
void writeInstance(QXmlStreamWriter &stream, const QVariantList &v)
{
stream.writeStartElement("instance");
writeName(stream, v[1]);
QVariant vViewRef = v[2];
if (vViewRef.type() == QVariant::List)
{
QVariantList l = vViewRef.toList();
if (l[0].toString() == "viewRef")
{
writeCellRef(stream, l[2].toList());
}
else
{
qWarning("Wrong instance cell description");
}
}
else
{
qWarning("Wrong instance description");
}
if (v.size() > 3)
{
if (v[3].type() == QVariant::List)
{
QVariantList l = v[3].toList();
if (l[0].toString() == "property")
{
QString propertyName = l[1].toString();
QVariant vValue = l[2];
if (vValue.type() == QVariant::List)
{
QVariantList l2 = vValue.toList();
QString valueType = l2[0].toString();
if (valueType == "string")
{
QString value = stripQuotes(l2[1].toString());
stream.writeStartElement("property");
stream.writeAttribute("name", propertyName);
stream.writeAttribute("value", value);
stream.writeEndElement();
}
else
{
qWarning("Unsupported value type '%s' for property", qPrintable(valueType));
}
}
}
else
{
qWarning("Wrong instance cell description");
}
}
}
stream.writeEndElement();
}
示例4: tr
Tileset *VariantToMapConverter::toTileset(const QVariant &variant)
{
const QVariantMap variantMap = variant.toMap();
const int firstGid = variantMap["firstgid"].toInt();
const QString name = variantMap["name"].toString();
const int tileWidth = variantMap["tilewidth"].toInt();
const int tileHeight = variantMap["tileheight"].toInt();
const int spacing = variantMap["spacing"].toInt();
const int margin = variantMap["margin"].toInt();
const QVariantMap tileOffset = variantMap["tileoffset"].toMap();
const int tileOffsetX = tileOffset["x"].toInt();
const int tileOffsetY = tileOffset["y"].toInt();
if (tileWidth <= 0 || tileHeight <= 0 || firstGid == 0) {
mError = tr("Invalid tileset parameters for tileset '%1'").arg(name);
return 0;
}
typedef QScopedPointer<Tileset> TilesetPtr;
TilesetPtr tileset(new Tileset(name,
tileWidth, tileHeight,
spacing, margin));
tileset->setTileOffset(QPoint(tileOffsetX, tileOffsetY));
const QString trans = variantMap["transparentcolor"].toString();
if (!trans.isEmpty() && QColor::isValidColor(trans))
tileset->setTransparentColor(QColor(trans));
QVariant imageVariant = variantMap["image"];
if (!imageVariant.isNull()) {
QString imagePath = resolvePath(mMapDir, imageVariant);
if (!tileset->loadFromImage(imagePath)) {
mError = tr("Error loading tileset image:\n'%1'").arg(imagePath);
return 0;
}
}
tileset->setProperties(toProperties(variantMap["properties"]));
// Read terrains
QVariantList terrainsVariantList = variantMap["terrains"].toList();
for (int i = 0; i < terrainsVariantList.count(); ++i) {
QVariantMap terrainMap = terrainsVariantList[i].toMap();
tileset->addTerrain(terrainMap["name"].toString(),
terrainMap["tile"].toInt());
}
// Read tile terrain and external image information
const QVariantMap tilesVariantMap = variantMap["tiles"].toMap();
QVariantMap::const_iterator it = tilesVariantMap.constBegin();
for (; it != tilesVariantMap.end(); ++it) {
bool ok;
const int tileIndex = it.key().toInt();
if (tileIndex < 0) {
mError = tr("Tileset tile index negative:\n'%1'").arg(tileIndex);
}
if (tileIndex >= tileset->tileCount()) {
// Extend the tileset to fit the tile
if (tileIndex >= tilesVariantMap.count()) {
// If tiles are defined this way, there should be an entry
// for each tile.
// Limit the index to number of entries to prevent running out
// of memory on malicious input.
mError = tr("Tileset tile index too high:\n'%1'").arg(tileIndex);
return 0;
}
for (int i = tileset->tileCount(); i <= tileIndex; i++)
tileset->addTile(QPixmap());
}
Tile *tile = tileset->tileAt(tileIndex);
if (tile) {
const QVariantMap tileVar = it.value().toMap();
QList<QVariant> terrains = tileVar["terrain"].toList();
if (terrains.count() == 4) {
for (int i = 0; i < 4; ++i) {
int terrainId = terrains.at(i).toInt(&ok);
if (ok && terrainId >= 0 && terrainId < tileset->terrainCount())
tile->setCornerTerrain(i, terrainId);
}
}
float terrainProbability = tileVar["probability"].toFloat(&ok);
if (ok)
tile->setTerrainProbability(terrainProbability);
imageVariant = tileVar["image"];
if (!imageVariant.isNull()) {
QString imagePath = resolvePath(mMapDir, imageVariant);
tileset->setTileImage(tileIndex, QPixmap(imagePath), imagePath);
}
QVariantMap objectGroupVariant = tileVar["objectgroup"].toMap();
if (!objectGroupVariant.isEmpty())
tile->setObjectGroup(toObjectGroup(objectGroupVariant));
QVariantList frameList = tileVar["animation"].toList();
if (!frameList.isEmpty()) {
QVector<Frame> frames(frameList.size());
//.........这里部分代码省略.........
示例5: foreach
bool QgsAfsProvider::getFeature( const QgsFeatureId &id, QgsFeature &f, bool fetchGeometry, const QList<int>& /*fetchAttributes*/, const QgsRectangle filterRect )
{
// If cached, return cached feature
QMap<QgsFeatureId, QgsFeature>::const_iterator it = mCache.find( id );
if ( it != mCache.end() )
{
f = it.value();
return filterRect.isNull() || f.geometry().intersects( filterRect );
}
// Determine attributes to fetch
/*QStringList fetchAttribNames;
foreach ( int idx, fetchAttributes )
fetchAttribNames.append( mFields.at( idx ).name() );
*/
// When fetching from server, fetch all attributes and geometry by default so that we can cache them
QStringList fetchAttribNames;
QList<int> fetchAttribIdx;
for ( int idx = 0, n = mFields.size(); idx < n; ++idx )
{
fetchAttribNames.append( mFields.at( idx ).name() );
fetchAttribIdx.append( idx );
}
fetchGeometry = true;
// Fetch 100 features at the time
int startId = ( id / 100 ) * 100;
int stopId = qMin( startId + 100, mObjectIds.length() );
QList<quint32> objectIds;
for ( int i = startId; i < stopId; ++i )
{
objectIds.append( mObjectIds[i] );
}
// Query
QString errorTitle, errorMessage;
QVariantMap queryData = QgsArcGisRestUtils::getObjects(
mDataSource.param( "url" ), objectIds, mDataSource.param( "crs" ), fetchGeometry,
fetchAttribNames, QgsWkbTypes::hasM( mGeometryType ), QgsWkbTypes::hasZ( mGeometryType ),
filterRect, errorTitle, errorMessage );
if ( queryData.isEmpty() )
{
const_cast<QgsAfsProvider*>( this )->pushError( errorTitle + ": " + errorMessage );
QgsDebugMsg( "Query returned empty result" );
return false;
}
QVariantList featuresData = queryData["features"].toList();
if ( featuresData.isEmpty() )
{
QgsDebugMsg( "Query returned no features" );
return false;
}
for ( int i = 0, n = featuresData.size(); i < n; ++i )
{
QVariantMap featureData = featuresData[i].toMap();
QgsFeature feature;
// Set FID
feature.setFeatureId( startId + i );
// Set attributes
if ( !fetchAttribIdx.isEmpty() )
{
QVariantMap attributesData = featureData["attributes"].toMap();
feature.setFields( mFields );
QgsAttributes attributes( mFields.size() );
foreach ( int idx, fetchAttribIdx )
{
attributes[idx] = attributesData[mFields.at( idx ).name()];
}
feature.setAttributes( attributes );
}
// Set geometry
if ( fetchGeometry )
{
QVariantMap geometryData = featureData["geometry"].toMap();
QgsAbstractGeometry* geometry = QgsArcGisRestUtils::parseEsriGeoJSON( geometryData, queryData["geometryType"].toString(),
QgsWkbTypes::hasM( mGeometryType ), QgsWkbTypes::hasZ( mGeometryType ) );
// Above might return 0, which is ok since in theory empty geometries are allowed
feature.setGeometry( QgsGeometry( geometry ) );
}
feature.setValid( true );
mCache.insert( feature.id(), feature );
}
示例6: qWarning
void ApiYandexSearch::getSuggestionsFinished(QNetworkReply *reply)
{
QByteArray content = reply->readAll();
if (m_suggestionsParameters.v == "4") {
QJsonParseError parseError;
QVariant json = QJsonDocument::fromJson(content, &parseError).toVariant();
if (Q_UNLIKELY(parseError.error)) {
qWarning() << "ApiYandexSearch::getSuggestionsFinished():"
<< tr("Can't parse JSON data:") << content
<< tr(". Parser returned an error:") << parseError.errorString();
qWarning() << "Request:" << m_currentSuggestionsRequest;
m_currentSuggestionsRequest.clear();
return;
}
QVariantList jsonList = json.toList();
if (jsonList.size() == 0) {
return;
}
QVariantList suggestions = jsonList.at(1).toList();
QList<Consts::Shared::Suggestion> suggestionsToReturn;
forc11 (QVariant var, suggestions) {
Consts::Shared::Suggestion suggestion;
// Query
if (var.type() == QVariant::String) {
suggestion.text = var.toString();
suggestion.kind = Consts::Shared::Suggestion::Kind::Query;
}
else if (var.type() == QVariant::List) {
QVariantList list = var.toList();
QString kind = list.first().toString();
// Fact
if (kind == "fact") {
suggestion.text = list.at(1).toString();
suggestion.kind = Consts::Shared::Suggestion::Kind::Fact;
suggestion.others.fact = list.at(2).toString();
}
// Navigation
else if (kind == "nav") {
suggestion.text = list.at(3).toString();
suggestion.kind = Consts::Shared::Suggestion::Kind::Navigation;
const QString nameOfGoToSite = QString::fromUtf8("перейти на сайт");
if (list.at(2).toString() != nameOfGoToSite)
suggestion.others.linkTitle = list.at(2).toString();
}
else {
continue;
}
}
else {
continue;
}
suggestionsToReturn.append(suggestion);
}
示例7: getReturnType
/*
taken from http://delta.affinix.com/2006/08/14/invokemethodwithvariants/
thanks to Justin Karneges once again :)
*/
bool MaiaXmlRpcServerConnection::invokeMethodWithVariants( QObject *obj,
const QByteArray &method,
const QVariantList &args,
QVariant *ret,
Qt::ConnectionType type )
{
// QMetaObject::invokeMethod() has a 10 argument maximum
if( args.count() > 10 ) {
return false;
}
QList<QByteArray> argTypes;
for( int n = 0; n < args.count(); ++n ) {
argTypes += args[n].typeName();
}
// get return type
int metatype = 0;
QByteArray retTypeName = getReturnType(obj->metaObject(), method, argTypes);
if( !retTypeName.isEmpty() && retTypeName != "QVariant" ) {
metatype = QMetaType::type(retTypeName.data());
if( metatype == 0 ) {
// lookup failed
return false;
}
}
QGenericArgument arg[10];
for( int n = 0; n < args.count(); ++n ) {
arg[n] = QGenericArgument(args[n].typeName(), args[n].constData());
}
QGenericReturnArgument retarg;
QVariant retval;
if( metatype != 0 && retTypeName != "void" ) {
retval = QVariant(metatype, (const void *)0);
retarg = QGenericReturnArgument(retval.typeName(), retval.data());
}
else {
/* QVariant */
retarg = QGenericReturnArgument("QVariant", &retval);
}
if( retTypeName.isEmpty() || retTypeName == "void" ) {
/* void */
if( !QMetaObject::invokeMethod(obj, method.data(), type,
arg[0], arg[1], arg[2], arg[3], arg[4],
arg[5], arg[6], arg[7], arg[8], arg[9]) ) {
return false;
}
}
else {
if( !QMetaObject::invokeMethod(obj, method.data(), type, retarg,
arg[0], arg[1], arg[2], arg[3], arg[4],
arg[5], arg[6], arg[7], arg[8], arg[9]) ) {
return false;
}
}
if( retval.isValid() && ret ) {
*ret = retval;
}
return true;
} // bool invokeMethodWithVariants( QObject *obj, const QByteArray &method, const QVariantList &args, QVariant *ret, Qt::ConnectionType type )
示例8: midnight
void CustomGroupModel::loadEvents()
{
const QDate today = QDate::currentDate();
const QTime midnight(0, 0, 0);
const QTime startday(0, 0, 1);
const QTime endday(23, 59, 59);
QDateTime searchStartTime = QDateTime(today, startday);
QDateTime searchEndTime = QDateTime(today, endday);
// Setup the search parameters with time range as specified by filter criterion
EventSearchParameters searchParameters;
searchParameters.setStart(searchStartTime);
searchParameters.setEnd(searchEndTime);
searchParameters.setDetails(DetailLevel::Weekly);
bb::pim::calendar::CalendarService* calendarService = new CalendarService();
const QList<CalendarEvent> events = calendarService->events(searchParameters);
// get list of all calendars
QList<CalendarFolder> allFolders = calendarService->folders();
CalendarFolder cf = allFolders.at(0);
QMap<std::string, uint > accountColor;
for (int i = 0; i < allFolders.size(); i++) {
std::stringstream keyStream;
keyStream << allFolders.at(i).accountId() << allFolders.at(i).id();
std::string key = keyStream.str();
accountColor.insert(key, allFolders.at(i).color());
// qDebug() << "############## folder:" << allFolders.at(i).name() << ", key:" << QString::fromStdString(key) << "=" << QString::fromStdString(value);
// accountColor.insert(as.append(fs), allFolders.at(i).color());
}
// Clear the old events information from the model
clear();
// Iterate over the list of events
QVariantList entries;
int order = 0;
foreach (const CalendarEvent &event, events) {
// Copy the data into a model entry
QVariantMap entry;
entry["myType"] = QVariant(trUtf8("today"));
entry["eventId"] = event.id();
entry["accountId"] = event.accountId();
entry["subject"] = event.subject().replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """);
entry["order"] = order++;
entry["startTime"] = event.startTime();
entry["endTime"] = event.endTime();
entry["timeString"] = "";
entry["account"] = event.accountId();
std::stringstream keyStream;
keyStream << event.accountId() << event.folderId();
std::string key = keyStream.str();
entry["color24"] = QString::number(accountColor[key], 16);
qDebug() << "FMI ######### key:" << QString::fromStdString(key) << "=" << accountColor[key];
qDebug() << "FMI ######### id:" << event.id() << " subject" << event.subject() << " startTime:" << event.startTime().toString(Qt::DefaultLocaleShortDate);
entries.append(entry);
}
示例9: ASSERT
void CWebAPI::OnRequestCompleted()
{
CHttpSocket* pRequest = (CHttpSocket*)sender();
ASSERT(pRequest->GetState() == CHttpSocket::eHandling);
QString Path = pRequest->GetPath();
TArguments Cookies = GetArguments(pRequest->GetHeader("Cookie"));
TArguments Arguments = GetArguments(pRequest->GetQuery().mid(1),'&');
switch(pRequest->GetType())
{
case CHttpSocket::eDELETE:
pRequest->RespondWithError(501);
case CHttpSocket::eHEAD:
case CHttpSocket::eOPTIONS:
pRequest->SendResponse();
return;
}
if(Path.compare("/WebAPI/") == 0)
pRequest->RespondWithError(403);
else if(Path.left(14).compare("/WebAPI/Icons/") == 0)
{
int Size;
if(Arguments["Size"] == "Small")
Size = 16;
else // if(Arguments["Size"] == "Large")
Size = 32;
QString Ext = Split2(Path.mid(14), ".").first;
QString IconPath = theCore->Cfg()->GetSettingsDir() + "/Cache/Icons/" + Ext + QString::number(Size) + ".png";
if(!QFile::exists(IconPath))
{
if(theLoader)
QMetaObject::invokeMethod(theLoader, "CreateFileIcon", Qt::BlockingQueuedConnection, Q_ARG(QString, Ext));
else
IconPath = ":/Icon" + QString::number(Size) + ".png";
}
pRequest->SetCaching(HR2S(48));
pRequest->RespondWithFile(IconPath);
}
else if(Path.left(11).compare("/WebAPI/FS/") == 0)
{
StrPair CmdExt = Split2(Path.mid(11),".");
QVariantMap Result;
if(CmdExt.first.compare("dir", Qt::CaseInsensitive) == 0)
{
QVariantList Entrys;
QString DirPath = Arguments["Path"];
QDir Dir(DirPath);
foreach (const QString& Name, Dir.entryList())
{
if (Name.compare(".") == 0 || Name.compare("..") == 0)
continue;
QVariantMap Entry;
QFileInfo Info(DirPath + "/" + Name);
Entry["Name"] = Info.fileName();
Entry["Created"] = Info.created();
Entry["Modifyed"] = Info.lastModified();
if (Info.isDir())
Entry["Size"] = "dir";
else
Entry["Size"] = Info.size();
Entrys.append(Entry);
}
Result["List"] = Entrys;
}
示例10: childCount
int FeedsViewModel::childCount(const QVariantList &indexPath) {
if (indexPath.length() == 0) {
return m_resultList.size();
}
return 0;
}
示例11: data
QVariant FeedsViewModel::data(const QVariantList &indexPath) {
return m_resultList.at(indexPath.at(0).toInt());
}
示例12: itemType
QString FeedsViewModel::itemType(const QVariantList &indexPath) {
if (indexPath.size() == 1) {
return "item";
}
return "";
}
示例13: DebugOut
{
reqlist.push_back(prop.toStdString());
}
request.properties = reqlist;
request.completed = [&cbFunction](AsyncRangePropertyReply* reply)
{
if(!reply->success)
{
DebugOut(DebugOut::Error)<<"bluemoney get history call failed"<<endl;
return;
}
if(cbFunction.isCallable())
{
QVariantList list;
for(auto val : reply->values)
{
list.append(toQVariant(val));
}
QJSValue val = cbFunction.engine()->toScriptValue<QVariantList>(list);
cbFunction.call(QJSValueList()<<val);
}
delete reply;
};
示例14: fopen
void ParticleEditor::SaveConfigFile(QString filename)
{
FILE* sFile;
sFile = fopen(filename.toLocal8Bit().data(), "wb");
if (!sFile){
addConsoleInfo("保存失败");
return;
}
QVariantMap document;
QVariantList resList;
QVariantMap particleData;
//导出资源
QStringList imageList = resourceView->getImageList();
for (int i = 0; i < imageList.size(); i++){
QVariant res = imageList.at(i);
resList.append(res);
}
//导出粒子
auto layer = dynamic_cast<C3DLayer*>(g_Layer);
auto particleSystem = layer->getParticleSystem();
particleData.insert("texture", particleSystem->getTextureFileName().c_str());
particleData.insert("count", particleSystem->getParticleCount());
particleData.insert("particle_type", particleSystem->getParticleType());
particleData.insert("blendfunc_src", particleSystem->getBlendFunc().src);
particleData.insert("blendfunc_dst", particleSystem->getBlendFunc().dst);
auto data = particleSystem->getParticleData();
particleData.insert("velocity_min_x", data.m_Velocity_Min.x);
particleData.insert("velocity_min_y", data.m_Velocity_Min.y);
particleData.insert("velocity_min_z", data.m_Velocity_Min.z);
particleData.insert("velocity_max_x", data.m_Velocity_Max.x);
particleData.insert("velocity_max_y", data.m_Velocity_Max.y);
particleData.insert("velocity_max_z", data.m_Velocity_Max.z);
particleData.insert("accleration_min_x", data.m_Acceleration_Min.x);
particleData.insert("accleration_min_y", data.m_Acceleration_Min.y);
particleData.insert("accleration_min_z", data.m_Acceleration_Min.z);
particleData.insert("accleration_max_x", data.m_Acceleration_Max.x);
particleData.insert("accleration_max_y", data.m_Acceleration_Max.y);
particleData.insert("accleration_max_z", data.m_Acceleration_Max.z);
particleData.insert("size_min_x", data.m_Size_Min.x);
particleData.insert("size_min_y", data.m_Size_Min.y);
particleData.insert("size_min_z", data.m_Size_Min.z);
particleData.insert("size_max_x", data.m_Size_Max.x);
particleData.insert("size_max_y", data.m_Size_Max.y);
particleData.insert("size_max_z", data.m_Size_Max.z);
particleData.insert("size_velocity_x", data.m_Size_Velocity.x);
particleData.insert("size_velocity_y", data.m_Size_Velocity.y);
particleData.insert("size_velocity_z", data.m_Size_Velocity.z);
particleData.insert("color_min_x", data.m_Color_Min.x);
particleData.insert("color_min_y", data.m_Color_Min.y);
particleData.insert("color_min_z", data.m_Color_Min.z);
particleData.insert("color_max_x", data.m_Color_Max.x);
particleData.insert("color_max_y", data.m_Color_Max.y);
particleData.insert("color_max_z", data.m_Color_Max.z);
particleData.insert("color_velocity_x", data.m_Color_Velocity.x);
particleData.insert("color_velocity_y", data.m_Color_Velocity.y);
particleData.insert("color_velocity_z", data.m_Color_Velocity.z);
particleData.insert("life_min", data.m_Life_Min);
particleData.insert("life_max", data.m_Life_Max);
particleData.insert("life_velocity", data.m_Life_Velocity);
particleData.insert("m_color_r", particleSystem->getColor()[0]);
particleData.insert("m_color_g", particleSystem->getColor()[1]);
particleData.insert("m_color_b", particleSystem->getColor()[2]);
particleData.insert("m_color_a", particleSystem->getColor()[3]);
document.insert("resList", resList);
document.insert("particleData", particleData);
QJsonDocument jsonDocument = QJsonDocument::fromVariant(document);
QByteArray array = jsonDocument.toJson(QJsonDocument::Compact);
unsigned int count = array.size();
const char* data__ = (const char*)array.data();
fwrite(data__, count, 1, sFile);
fclose(sFile);
}
示例15: if
/*! \fn void QSListModel::insert(int index, const QVariantList &value)
Returns the index position of the first occurrence of the byte array ba in this byte array,
*/
void QSListModel::insert(int index, const QVariantList &value)
{
if (value.count() == 0) {
return;
} else if (value.count() == 1) {
insert(index, value.at(0).toMap());
return;
}
if (m_roles.isEmpty()) {
setRoleNames(value.at(0).toMap());
}
beginInsertRows(QModelIndex(), index, index + value.count() - 1);
m_storage.reserve(m_storage.count() + value.count());
QVariantList mid = m_storage.mid(index);
for (int i = 0 ; i < value.size() ; i++) {
if (index + i < m_storage.size()) {
m_storage[index + i] = value.at(i);
} else {
m_storage.append(value.at(i));
}
}
for (int i = 0; i < mid.size(); i++) {
int idx = index + value.size() + i;
if (idx < m_storage.count()) {
m_storage[idx] = mid.at(i);
} else {
m_storage.append(mid.at(i));
}
}
endInsertRows();
emit countChanged();
}