本文整理汇总了C++中QVariantList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::insert方法的具体用法?C++ QVariantList::insert怎么用?C++ QVariantList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editAccount
void AccountList::editAccount(int i, QString name, int start, int stop)
{
JsonDataAccess jda;
QVariantList list = jda.load(this->file).value<QVariantList>();
QVariantMap acc;
acc["name"] = QVariant(name);
acc["start"] = QVariant(start);
acc["stop"] = QVariant(stop);
list.removeAt(i);
list.insert(i, QVariant(acc));
jda.save(QVariant(list), this->file);
loadAccounts();
}
示例2: parseBSONElt
bool Parser::parseBSONElt(QVariant &res, QString &key) {
char c, t = read<quint8>();
if (t == BSON_TOKEN_END) {
return false;
}
while ((c = read<quint8>()) != '\0') {
key.append(c);
}
switch (t) {
case BSON_TOKEN_UNDEF:
logWarn() << "Deprecated token Undefined";
case BSON_TOKEN_NULL:
res = QVariant();
break;
case BSON_TOKEN_BOOL:
res = QVariant(read<quint8>() == BSON_TOKEN_TRUE);
break;
case BSON_TOKEN_INT32:
res = QVariant(read<qint32>());
break;
case BSON_TOKEN_INT64:
res = QVariant(read<qlonglong>());
break;
case BSON_TOKEN_DOUBLE:
res = QVariant(read<double>());
break;
case BSON_TOKEN_DATETIME:
res = QVariant(QDateTime::fromMSecsSinceEpoch(read<qlonglong>()));
break;
case BSON_TOKEN_STRING:
case BSON_TOKEN_JSCODE:
{
quint32 len = read<quint32>()-1;
char buf[len];
for (quint32 i = 0; i < len; i++) {
buf[i] = read<quint8>();
}
read<quint8>();
res = QVariant(QString::fromUtf8(buf, len));
break;
}
case BSON_TOKEN_OID:
{
quint32 len = 12;
char buf[len];
for (quint32 i = 0; i < len; i++) {
buf[i] = read<quint8>();
}
res = QVariant(QByteArray(buf, len));
break;
}
case BSON_TOKEN_DATA:
{
char type = read<quint8>();
quint32 len = read<quint32>();
char buf[len];
for (quint32 i = 0; i < len; i++) {
buf[i] = read<quint8>();
}
switch (type) {
case BSON_TOKEN_OLDUUID:
case BSON_TOKEN_UUID:
res = QVariant(QUuid(QByteArray(buf, len)));
break;
case BSON_TOKEN_GENERIC:
default:
res = QVariant(QByteArray(buf, len));
}
break;
}
case BSON_TOKEN_MAP:
{
read<quint32>();
QVariantMap map;
while (true) {
QString key;
QVariant value;
if (!parseBSONElt(value, key)) break;
map[key] = value;
}
res = map;
break;
}
case BSON_TOKEN_LIST:
{
read<quint32>();
QVariantList list;
while (true) {
QString key;
QVariant value;
if (!parseBSONElt(value, key)) break;
list.insert(key.toInt(), value);
}
res = list;
break;
}
default:
throw ParserException("Unsupported token " + QString::number(t, 16));
}
return true;
//.........这里部分代码省略.........
示例3: writeEntry
void KConfigGroup::writeEntry( const char* key, const QVariant &value,
WriteConfigFlags flags )
{
Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
if ( writeEntryGui( this, key, value, flags ) )
return; // GUI type that was handled
QByteArray data;
// if a type handler is added here you must add a QVConversions definition
// to conversion_check.h, or ConversionCheck::to_QVariant will not allow
// writeEntry<T> to convert to QVariant.
switch( value.type() ) {
case QVariant::Invalid:
data = "";
break;
case QVariant::ByteArray:
data = value.toByteArray();
break;
case QVariant::String:
case QVariant::Int:
case QVariant::UInt:
case QVariant::Double:
case QMetaType::Float:
case QVariant::Bool:
case QVariant::LongLong:
case QVariant::ULongLong:
data = value.toString().toUtf8();
break;
case QVariant::List:
if (!value.canConvert(QVariant::StringList))
qWarning() << "not all types in \"" << key << "\" can convert to QString,"
" information will be lost";
case QVariant::StringList:
writeEntry( key, value.toList(), flags );
return;
case QVariant::Point: {
QVariantList list;
const QPoint rPoint = value.toPoint();
list.insert( 0, rPoint.x() );
list.insert( 1, rPoint.y() );
writeEntry( key, list, flags );
return;
}
case QVariant::PointF: {
QVariantList list;
const QPointF point = value.toPointF();
list.insert( 0, point.x() );
list.insert( 1, point.y() );
writeEntry( key, list, flags );
return;
}
case QVariant::Rect:{
QVariantList list;
const QRect rRect = value.toRect();
list.insert( 0, rRect.left() );
list.insert( 1, rRect.top() );
list.insert( 2, rRect.width() );
list.insert( 3, rRect.height() );
writeEntry( key, list, flags );
return;
}
case QVariant::RectF:{
QVariantList list;
const QRectF rRectF = value.toRectF();
list.insert(0, rRectF.left());
list.insert(1, rRectF.top());
list.insert(2, rRectF.width());
list.insert(3, rRectF.height());
writeEntry(key, list, flags);
return;
}
case QVariant::Size:{
QVariantList list;
const QSize rSize = value.toSize();
list.insert( 0, rSize.width() );
list.insert( 1, rSize.height() );
writeEntry( key, list, flags );
return;
}
case QVariant::SizeF:{
QVariantList list;
const QSizeF rSizeF = value.toSizeF();
list.insert(0, rSizeF.width());
list.insert(1, rSizeF.height());
writeEntry(key, list, flags);
return;
}
case QVariant::Date: {
QVariantList list;
const QDate date = value.toDate();
list.insert( 0, date.year() );
//.........这里部分代码省略.........
示例4: receiptTablesData
//.........这里部分代码省略.........
qfu::TreeTable tt = model.toTreeTable();
{
qf::core::sql::QueryBuilder qb;
qb.select2("courses", "length, climb")
.select("(SELECT COUNT(*) FROM coursecodes WHERE courseId=courses.id) AS controlCount")
.from("courses")
.where("courses.id=" QF_IARG(course_id));
qf::core::sql::Query q;
q.exec(qb.toString());
if(q.next()) {
QSqlRecord rec = q.record();
for (int i = 0; i < rec.count(); ++i) {
QString fld_name = rec.fieldName(i);
tt.setValue(fld_name, rec.value(i));
}
}
}
{
qf::core::sql::QueryBuilder qb;
qb.select2("config", "ckey, cvalue, ctype")
.from("config")
.where("ckey LIKE 'event.%'");
qf::core::sql::Query q;
q.exec(qb.toString());
while(q.next()) {
QVariant v = qf::core::Utils::retypeStringValue(q.value("cvalue").toString(), q.value("ctype").toString());
tt.setValue(q.value("ckey").toString(), v);
}
}
tt.setValue("stageCount", eventPlugin()->stageCount());
tt.setValue("currentStageId", eventPlugin()->currentStageId());
qfDebug() << "competitor:\n" << tt.toString();
ret["competitor"] = tt.toVariant();
}
{
qfu::TreeTable tt;
tt.appendColumn("position", QVariant::Int);
tt.appendColumn("code", QVariant::Int);
tt.appendColumn("stpTimeMs", QVariant::Int);
tt.appendColumn("lapTimeMs", QVariant::Int);
tt.appendColumn("lossMs", QVariant::Int);
QMapIterator<QString, QVariant> it(checked_card);
while(it.hasNext()) {
it.next();
if(it.key() != QLatin1String("punches"))
tt.setValue(it.key(), it.value());
}
tt.setValue("isOk", checked_card.isOk());
int position = 0;
for(auto v : checked_card.punches()) {
CardReader::CheckedPunch punch(v.toMap());
qfu::TreeTableRow ttr = tt.appendRow();
++position;
int code = punch.code();
ttr.setValue("position", position);
ttr.setValue("code", code);
ttr.setValue("stpTimeMs", punch.stpTimeMs());
int lap = punch.lapTimeMs();
ttr.setValue("lapTimeMs", lap);
int best_lap = best_laps.value(position);
if(lap > 0 && best_lap > 0) {
int loss = lap - best_lap;
ttr.setValue("lossMs", loss);
}
}
/*
{
// runlaps table contains also finish time entry, it is under FINISH_PUNCH_POS
// currently best_laps[999] contains best finish lap time for this class
int loss = 0;
int best_lap = best_laps.value(CardReader::CardReaderPlugin::FINISH_PUNCH_POS);
if(best_lap > 0)
loss = checked_card.finishLapTimeMs() - best_lap;
//qfInfo() << "control_count:" << control_count << "finishLapTimeMs:" << checked_card.finishLapTimeMs() << "- best_lap:" << best_lap << "=" << loss;
tt.setValue("finishLossMs", loss);
}
*/
{
QSet<int> correct_codes;
for (int i = 0; i < checked_card.punchCount(); ++i) {
correct_codes << checked_card.punchAt(i).code();
}
QVariantList xc;
for (int i = 0; i < read_card.punchCount(); ++i) {
int code = read_card.punchAt(i).code();
if(!correct_codes.contains(code)) {
xc.insert(xc.count(), QVariantList() << (i+1) << code);
}
}
tt.setValue("extraCodes", xc);
}
tt.setValue("currentStandings", current_standings);
tt.setValue("competitorsFinished", competitors_finished);
tt.setValue("timeMs", checked_card.timeMs());
qfDebug() << "card:\n" << tt.toString();
ret["card"] = tt.toVariant();
}
return ret;
}