本文整理汇总了C++中QVariantList::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::append方法的具体用法?C++ QVariantList::append怎么用?C++ QVariantList::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseUrl
void TestParser::parseUrl(){
//"http:\/\/www.last.fm\/venue\/8926427"
QByteArray json = "[\"http:\\/\\/www.last.fm\\/venue\\/8926427\"]";
QVariantList list;
list.append (QVariant(QLatin1String("http://www.last.fm/venue/8926427")));
QVariant expected (list);
Parser parser;
bool ok;
QVariant result = parser.parse (json, &ok);
QVERIFY (ok);
QCOMPARE(result, expected);
}
示例2: parseSimpleArray
void TestParser::parseSimpleArray() {
QByteArray json = "[\"foo\",\"bar\"]";
QVariantList list;
list.append (QLatin1String("foo"));
list.append (QLatin1String("bar"));
QVariant expected (list);
Parser parser;
bool ok;
QVariant result = parser.parse (json, &ok);
QVERIFY (ok);
QCOMPARE(result, expected);
}
示例3: doc
QList<QVariantList> XlsxReader::read(const QString &xlsxFilePath)
{
QList<QVariantList> data;
QXlsx::Document doc(xlsxFilePath);
QXlsx::CellRange range = doc.dimension();
for(int row = range.firstRow(); row <= range.lastRow(); ++row)
{
QVariantList rowData;
for(int col = range.firstColumn(); col <= range.lastColumn(); ++col)
{
QXlsx::Cell *cell = doc.cellAt(row, col);
if(cell)
rowData.append(cell->value());
else
rowData.append(QVariant());
}
data.append(rowData);
}
return data;
}
示例4: sendCommandToHeadless
void App::sendCommandToHeadless(const CommandMessage &command, const User &user)
{
QVariantList invokeData;
invokeData.append(QVariant(command.toMap()));
if (!user.isEmpty()){
invokeData.append(QVariant(user.toMap()));
}
QByteArray buffer;
m_jsonDA->saveToBuffer(invokeData, &buffer);
InvokeRequest request;
request.setTarget(INVOKE_TARGET_KEY_PUSH);
request.setAction(BB_PUSH_COLLECTOR_COMMAND_ACTION);
request.setMimeType("text/plain");
request.setData(buffer);
m_invokeTargetReply = m_invokeManager->invoke(request);
// Connect to the reply finished signal.
checkConnectResult(QObject::connect(m_invokeTargetReply, SIGNAL(finished()), this, SLOT(onInvokeResult())));
}
示例5: deleteRecord
void QuotesApp::deleteRecord()
{
QVariantList indexPath = mListView->selected();
if (!indexPath.isEmpty()) {
QVariantMap map = mDataModel->data(indexPath).toMap();
// Delete the item from the database based on unique ID. If successful, remove it
// from the data model (which will remove the data from the list).
if (mQuotesDbHelper->deleteById(map["id"])) {
// Delete is the only operation where the logics for updating which item
// is selected is handled in code.
// Before the item is removed, we store how many items there are in the
// category that the item is removed from, we need this to select a new item.
QVariantList categoryIndexPath;
categoryIndexPath.append(indexPath.first());
int childrenInCategory = mDataModel->childCount(categoryIndexPath);
mDataModel->remove(map);
// After removing the selected item, we want another quote to be shown.
// So we select the next quote relative to the removed one in the list.
if (childrenInCategory > 1) {
// If the Category still has items, select within the category.
int itemInCategory = indexPath.last().toInt();
if (itemInCategory < childrenInCategory - 1) {
mListView->select(indexPath);
} else {
// The last item in the category was removed, select the previous item relative to the removed item.
indexPath.replace(1, QVariant(itemInCategory - 1));
mListView->select(indexPath);
}
} else {
// If no items left in the category, move to the next category.
// If there are no more categories below(next), select the previous category.
// If no items left at all, navigate to the list.
QVariantList lastIndexPath = mDataModel->last();
if (!lastIndexPath.isEmpty()) {
if (indexPath.first().toInt() <= lastIndexPath.first().toInt()) {
mListView->select(indexPath);
} else {
mListView->select(mDataModel->last());
}
}
} // else statment
} //if statement
} // top if statement
} // deleteRecord()
示例6: untag
void ItemTagsScriptable::untag()
{
const auto args = currentArguments();
auto tagName = args.value(0).toString();
if ( args.size() <= 1 ) {
const auto dataValueList = call("selectedItemsData").toList();
if ( tagName.isEmpty() ) {
QStringList allTags;
for (const auto &itemDataValue : dataValueList) {
const auto itemData = itemDataValue.toMap();
allTags.append( ::tags(itemData) );
}
tagName = askRemoveTagName(allTags);
if ( allTags.isEmpty() )
return;
}
QVariantList dataList;
dataList.reserve( dataValueList.size() );
for (const auto &itemDataValue : dataValueList) {
auto itemData = itemDataValue.toMap();
auto itemTags = ::tags(itemData);
if ( removeTag(tagName, &itemTags) )
itemData.insert( mimeTags, itemTags.join(",") );
dataList.append(itemData);
}
call( "setSelectedItemsData", QVariantList() << QVariant(dataList) );
} else {
const auto rows = this->rows(args, 1);
if ( tagName.isEmpty() ) {
QStringList allTags;
for (int row : rows)
allTags.append( this->tags(row) );
tagName = askRemoveTagName(allTags);
if ( allTags.isEmpty() )
return;
}
for (int row : rows) {
auto itemTags = tags(row);
if ( removeTag(tagName, &itemTags) )
setTags(row, itemTags);
}
}
}
示例7: valueToVariant
QVariant valueToVariant(const Calligra::Sheets::Value& value, Sheet* sheet)
{
//Should we use following value-format enums here?
//fmt_None, fmt_Boolean, fmt_Number, fmt_Percent, fmt_Money, fmt_DateTime, fmt_Date, fmt_Time, fmt_String
switch (value.type()) {
case Calligra::Sheets::Value::Empty:
return QVariant();
case Calligra::Sheets::Value::Boolean:
return QVariant(value.asBoolean());
case Calligra::Sheets::Value::Integer:
return static_cast<qint64>(value.asInteger());
case Calligra::Sheets::Value::Float:
return (double) numToDouble(value.asFloat());
case Calligra::Sheets::Value::Complex:
return sheet->map()->converter()->asString(value).asString();
case Calligra::Sheets::Value::String:
return value.asString();
case Calligra::Sheets::Value::Array: {
QVariantList colarray;
for (uint j = 0; j < value.rows(); j++) {
QVariantList rowarray;
for (uint i = 0; i < value.columns(); i++) {
Calligra::Sheets::Value v = value.element(i, j);
rowarray.append(valueToVariant(v, sheet));
}
colarray.append(rowarray);
}
return colarray;
}
break;
case Calligra::Sheets::Value::CellRange:
//FIXME: not yet used
return QVariant();
case Calligra::Sheets::Value::Error:
return QVariant();
}
return QVariant();
}
示例8: getJson
QByteArray LoadTagsResponseJSON::getJson() const
{
QJson::Serializer serializer;
serializer.setDoublePrecision(DOUBLE_PRECISION_RESPONSE);
QVariantMap obj, rss, jchannel;
QVariantList jchannels;
QVariantList jtags;
QVariantMap channel;
obj["errno"]= m_errno;
if (m_errno == SUCCESS){
for(int j=0; j<m_tags.size(); j++)
{
Tag tag = m_tags.at(j);
QVariantMap jtag;
jtag["title"] = tag.getLabel();
jtag["link"] = tag.getUrl();
jtag["description"] = tag.getDescription();
jtag["latitude"] = tag.getLatitude();
jtag["altitude"] = tag.getAltitude();
jtag["longitude"] = tag.getLongitude();
jtag["user"] = tag.getUser().getLogin();
jtag["pubDate"] = tag.getTime().toString("dd MM yyyy HH:mm:ss.zzz");
jtags.append(jtag);
}
channel["items"] = jtags;
// channel["name"] = m_channels.at(i).getName();
jchannels.append(channel);
jchannel["items"] = jchannels;
rss["channels"] = jchannel;
obj["rss"] = rss;
}
return serializer.serialize(obj);
}
示例9: getJson
QByteArray LoadTagsResponseJSON::getJson() const
{
QJson::Serializer serializer;
QVariantMap obj, rss, jchannel;
QList<QSharedPointer<Channel> > hashKeys = m_hashMap.uniqueKeys();
QVariantList jchannels;
for(int i=0; i<hashKeys.size(); i++)
{
QList<QSharedPointer<DataMark> > tags = m_hashMap.values(hashKeys.at(i));
QVariantList jtags;
QVariantMap channel;
for(int j=0; j<tags.size(); j++)
{
QSharedPointer<DataMark> tag = tags.at(j);
QVariantMap jtag;
jtag["title"] = tag->getLabel();
jtag["link"] = tag->getUrl();
jtag["description"] = tag->getDescription();
jtag["latitude"] = tag->getLatitude();
jtag["altitude"] = tag->getAltitude();
jtag["longitude"] = tag->getLongitude();
jtag["user"] = tag->getUser()->getLogin();
jtag["pubDate"] = tag->getTime().toString("dd MM yyyy HH:mm:ss.zzz");
jtags.append(jtag);
}
channel["items"] = jtags;
channel["name"] = hashKeys.at(i)->getName();
jchannels.append(channel);
}
jchannel["items"] = jchannels;
rss["channels"] = jchannel;
obj["rss"] = rss;
obj["errno"]= m_errno;
return serializer.serialize(obj);
}
示例10: test
void tst_QPoint::test()
{
Point point;
{
QCOMPARE(point.pointSize(),1.0);
QCOMPARE(point.vertices().toList().count(),0);
}
{
QSignalSpy spyPointSize(&point,SIGNAL(pointSizeChanged()));
point.setPointSize(5.0);
QCOMPARE(spyPointSize.size(), 1);
QCOMPARE(point.pointSize(),5.0);
point.setPointSize(5.0);
QCOMPARE(spyPointSize.size(), 1);
}
{
QSignalSpy spyVertices(&point,SIGNAL(verticesChanged()));
QVariantList vertices;
vertices.append(QVariant(1.0f));
vertices.append(QVariant(2.0f));
vertices.append(QVariant(3.0f));
point.setVertices(vertices);
QCOMPARE(spyVertices.size(), 1);
QVariantList readVertices = point.vertices().toList();
QCOMPARE(readVertices.count(),3);
QCOMPARE(readVertices.at(0).toReal(),1.0);
QCOMPARE(readVertices.at(1).toReal(),2.0);
QCOMPARE(readVertices.at(2).toReal(),3.0);
point.setVertices(vertices);
QCOMPARE(spyVertices.size(), 2);
}
}
示例11: OnRequestRecived
void CMuleKad::OnRequestRecived(const QString& Command, const QVariant& Parameters, QVariant& Result)
{
QVariantMap Request = Parameters.toMap();
QVariantMap Response;
if(Command == "GetLog")
{
QList<CLog::SLine> Log = GetLog();
int Index = -1;
if(uint64 uLast = Request["LastID"].toULongLong())
{
for(int i=0;i < Log.count(); i++)
{
if(uLast == Log.at(i).uID)
{
Index = i;
break;
}
}
}
QVariantList Entries;
for(int i=Index+1;i < Log.count(); i++)
{
QVariantMap LogEntry;
LogEntry["ID"] = Log.at(i).uID;
LogEntry["Flag"] = Log.at(i).uFlag;
LogEntry["Stamp"] = (quint64)Log.at(i).uStamp;
LogEntry["Line"] = Log.at(i).Line;
Entries.append(LogEntry);
}
Response["Lines"] = Entries;
}
else if(Command == "Shutdown")
{
QTimer::singleShot(100,this,SLOT(Shutdown()));
}
else if(Command == "GetSettings")
{
if(Request.contains("Options"))
{
QVariantMap Options;
foreach(const QString& Key, Request["Options"].toStringList())
Options[Key] = m_Settings->value(Key);
Response["Options"] = Options;
}
else
{
示例12: updateTextMirrorForDocument
void ScProcess::updateTextMirrorForDocument ( Document * doc, int position, int charsRemoved, int charsAdded )
{
QVariantList argList;
argList.append(QVariant(doc->id()));
argList.append(QVariant(position));
argList.append(QVariant(charsRemoved));
QTextCursor cursor = QTextCursor(doc->textDocument());
cursor.setPosition(position, QTextCursor::MoveAnchor);
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, charsAdded);
argList.append(QVariant(cursor.selection().toPlainText()));
try {
QDataStream stream(mIpcSocket);
stream.setVersion(QDataStream::Qt_4_6);
stream << QString("updateDocText");
stream << argList;
} catch (std::exception const & e) {
scPost(QString("Exception during ScIDE_Send: %1\n").arg(e.what()));
}
}
示例13: while
IResponse *GroupsService::getUsersGroups( IRequest *req)
{
QVariantList groups;
QSqlQuery query;
if(m_proxyConnection->session()->value("logged") !=""){
int page;
if(!(page= req->parameterValue("page").toInt())){
QVariantMap error;
error.insert("page_number","error");
return req->response(QVariant(error), IResponse::BAD_REQUEST);
}
query.prepare("SELECT * FROM groups "
"INNER JOIN group_users ON groups.id = group_users.group_id "
"WHERE group_users.status = 1 AND group_users.user_id = :user_id "
"ORDER BY groups.name ASC LIMIT :limit OFFSET :offset ");
query.bindValue(":user_id", m_proxyConnection->session()->value("logged").toString());
query.bindValue(":limit",PER_PAGE);
query.bindValue(":offset", (page-1)* PER_PAGE);
if(!query.exec())
return req->response(IResponse::INTERNAL_SERVER_ERROR);
while(query.next()){
QString user_id = m_proxyConnection->session()->value("logged").toString();
QVariantMap group;
QString group_id = query.value(query.record().indexOf("id")).toString();
group.insert("id",query.value(query.record().indexOf("id")));
group.insert("name",query.value(query.record().indexOf("name")));
group.insert("description",query.value(query.record().indexOf("description")));
group.insert("date_created", query.value(query.record().indexOf("date_created")));
if(isAdmin(user_id.toUInt(),group_id.toUInt()))
group.insert("admin","1");
else
group.insert("admin","0");
group.insert("member","1");
groups.append(group);
}
return req->response(QVariant(groups),IResponse::OK);
}
return req->response(IResponse::UNAUTHORIZED);
}
示例14: parseRetrievedAudioList
QVariantList parseRetrievedAudioList(const QByteArray &result, const QString& userId)
{
std::cout << QString(result).toStdString() << std::endl;
QVariantList list;
QScriptEngine engine;
QScriptValue response = engine.evaluate("(" + QString(result) + ")").property(RESPONSE);
QScriptValueIterator it(response);
while (it.hasNext()) {
it.next();
// Parse aid & oid
QString aid = it.value().property(AID).toString();
QString oid = it.value().property(OWNER_ID).toString();
// Parse artist
QByteArray rawText = it.value().property(ARTIST).toVariant().toByteArray();
QString artist = QString::fromUtf8(rawText, rawText.size());
rawText.clear();
// Parse title
rawText = it.value().property(TITLE).toVariant().toByteArray();
QString title = QString::fromUtf8(rawText, rawText.size());
// Parse duration
QString duration = it.value().property(DURATION).toString();
// Parse url
QString url = it.value().property(TRACK_URL).toString();
if (!aid.isEmpty() && !oid.isEmpty() && !artist.isEmpty() && !title.isEmpty() && !url.isEmpty())
{
QVariantMap track;
track.insert(AID, aid);
track.insert(OWNER_ID, oid);
track.insert(OWNED, userId.toInt() == oid.toInt());
track.insert(ARTIST, artist);
track.insert(TITLE,title);
track.insert(DURATION,duration);
track.insert(TRACK_URL,url);
list.append(track);
}
}
return list;
}
示例15: refresh
void MusicVideos::refresh()
{
QVariantMap params;
QVariantList properties;
properties.append("fanart");
properties.append("playcount");
properties.append("year");
properties.append("resume");
params.insert("properties", properties);
if (m_recentlyAdded) {
KodiConnection::sendCommand("VideoLibrary.GetMusicVideos", params, this, "listReceived");
} else {
QVariantMap sort;
sort.insert("method", "label");
sort.insert("order", "ascending");
sort.insert("ignorearticle", ignoreArticle());
params.insert("sort", sort);
KodiConnection::sendCommand("VideoLibrary.GetRecentlyAddedMusicVideos", params, this, "listReceived");
}
}