本文整理汇总了C++中QVariantList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::end方法的具体用法?C++ QVariantList::end怎么用?C++ QVariantList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTorrents
/**
* Returns all the torrents in JSON format.
*
* The return value is a JSON-formatted list of dictionaries.
* The dictionary keys are:
* - "hash": Torrent hash
* - "name": Torrent name
* - "size": Torrent size
* - "progress: Torrent progress
* - "dlspeed": Torrent download speed
* - "upspeed": Torrent upload speed
* - "priority": Torrent priority (-1 if queuing is disabled)
* - "num_seeds": Torrent seeds connected to
* - "num_complete": Torrent seeds in the swarm
* - "num_leechs": Torrent leechers connected to
* - "num_incomplete": Torrent leechers in the swarm
* - "ratio": Torrent share ratio
* - "eta": Torrent ETA
* - "state": Torrent state
* - "seq_dl": Torrent sequential download state
* - "f_l_piece_prio": Torrent first last piece priority state
* - "force_start": Torrent force start state
* - "category": Torrent category
*/
QByteArray btjson::getTorrents(QString filter, QString category,
QString sortedColumn, bool reverse, int limit, int offset)
{
QVariantList torrentList;
TorrentFilter torrentFilter(filter, TorrentFilter::AnyHash, category);
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents()) {
if (torrentFilter.match(torrent))
torrentList.append(toMap(torrent));
}
std::sort(torrentList.begin(), torrentList.end(), QTorrentCompare(sortedColumn, reverse));
int size = torrentList.size();
// normalize offset
if (offset < 0)
offset = size + offset;
if ((offset >= size) || (offset < 0))
offset = 0;
// normalize limit
if (limit <= 0)
limit = -1; // unlimited
if ((limit > 0) || (offset > 0))
return json::toJson(torrentList.mid(offset, limit));
else
return json::toJson(torrentList);
}
示例2: notesChanged
void QmlProfilerEventsModelProxy::notesChanged(int typeIndex)
{
const QmlProfilerNotesModel *notesModel = d->modelManager->notesModel();
if (typeIndex == -1) {
d->notes.clear();
for (int noteId = 0; noteId < notesModel->count(); ++noteId) {
int noteType = notesModel->typeId(noteId);
if (noteType != -1) {
QString ¬e = d->notes[noteType];
if (note.isEmpty()) {
note = notesModel->text(noteId);
} else {
note.append(QStringLiteral("\n")).append(notesModel->text(noteId));
}
}
}
} else {
d->notes.remove(typeIndex);
QVariantList changedNotes = notesModel->byTypeId(typeIndex);
if (!changedNotes.isEmpty()) {
QStringList newNotes;
for (QVariantList::ConstIterator it = changedNotes.begin(); it != changedNotes.end();
++it) {
newNotes << notesModel->text(it->toInt());
}
d->notes[typeIndex] = newNotes.join(QStringLiteral("\n"));
}
}
emit notesAvailable(typeIndex);
}
示例3: loadNetworkReplyDataIntoDataBase
void WeatherDataSource::loadNetworkReplyDataIntoDataBase(QVariantList weatherData)
{
// Iterate over all the items in the received data.
QVariantList::Iterator item = weatherData.begin();
// ValuesTable is a list of lists for adding a batch of data to the database.
QVariantList valuesTable;
// Update the data revision since we are adding new data to the data base.
int revision = incrementRevision();
while (item != weatherData.end()) {
QVariantList entryValues;
QVariantMap itemMap = (*item).toMap();
QDate itemDate = QDate::fromString(itemMap["date"].toString(), "yyyy M d");
itemMap["date"] = QVariant(itemDate.toString("yyyy-MM-dd"));
// Store the retrieved values for adding to data base.
entryValues << itemMap["city"];
entryValues << itemMap["region"];
entryValues << itemMap["templo"].toInt();
entryValues << itemMap["temphi"].toInt();
entryValues << itemMap["tempaverage"].toInt();
entryValues << itemMap["icon"].toInt();
entryValues << itemMap["date"].toString();
entryValues << revision;
valuesTable << QVariant::fromValue(entryValues);
++item;
}
// Insert the data into the data base here.
QString query = "INSERT INTO weather (city, region, templo, temphi, tempaverage, icon, date, revision_id) VALUES (:city, :region, :templo, :temphi, :tempaverage, :icon, :date, :revision_id)";
mSqlConnector->executeBatch(query, valuesTable);
}
示例4: init
void QgsRelationReferenceWidget::init()
{
if ( !mReadOnlySelector && mComboBox->count() == 0 && mReferencedLayer )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
QSet<QString> requestedAttrs;
QgsVectorLayerCache* layerCache = new QgsVectorLayerCache( mReferencedLayer, 100000, this );
if ( !mFilterFields.isEmpty() )
{
Q_FOREACH ( const QString& fieldName, mFilterFields )
{
QVariantList uniqueValues;
int idx = mReferencedLayer->fields().lookupField( fieldName );
QComboBox* cb = new QComboBox();
cb->setProperty( "Field", fieldName );
cb->setProperty( "FieldAlias", mReferencedLayer->attributeDisplayName( idx ) );
mFilterComboBoxes << cb;
mReferencedLayer->uniqueValues( idx, uniqueValues );
cb->addItem( mReferencedLayer->attributeDisplayName( idx ) );
QVariant nullValue = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->fields().at( idx ).type() ) );
qSort( uniqueValues.begin(), uniqueValues.end(), qgsVariantLessThan );
Q_FOREACH ( const QVariant& v, uniqueValues )
{
cb->addItem( v.toString(), v );
}
示例5:
QMap<QUrl,QUrl>* Fetcher::parseJson(QByteArray json)
{
QMap<QUrl,QUrl>* urls = new QMap<QUrl,QUrl>();
QJsonDocument jsonDoc = QJsonDocument::fromJson(json);
QVariantMap result = jsonDoc.toVariant().toMap();
QVariantMap responseData = (*result.find("responseData")).toMap();
QVariantList resultList = (*responseData.find("results")).toList();
QVariantMap tmp;
QVariant tbUrl,imgUrl;
QString tbUrlString,imgUrlString;
QVariantList::iterator it;
for(it = resultList.begin() ; it != resultList.end() ; ++it)
{
tmp = (*it).toMap();
tbUrl = (*tmp.find("tbUrl"));
imgUrl = (*tmp.find("unescapedUrl"));
tbUrlString = tbUrl.toString();
imgUrlString = imgUrl.toString();
urls->insert(QUrl(imgUrlString),QUrl(tbUrlString));
}
return urls;
}
示例6: getId
int RatingsProcessor::getId(QString title, QString response) {
int id;
bool flagIn = false;
bb::data::JsonDataAccess jda;
QVariant vlist = jda.loadFromBuffer(response);
QVariantList list = vlist.toList();
for (QList<QVariant>::iterator it = list.begin(); it != list.end(); it++) {
QVariantMap map = it->toMap();
QMapIterator<QString, QVariant> iw(map);
while (iw.hasNext()) {
iw.next();
QVariantMap tw = iw.value().toMap();
if (tw["title"] == title) {
flagIn = true;
id = tw["id"].toInt();
}
}
}
if (jda.hasError()) {
id = 0;
bb::data::DataAccessError error = jda.error();
qDebug() << "JSON loading error: " << error.errorType() << ": "
<< error.errorMessage();
}
if (!flagIn) {
return 0;
}
return id;
}
示例7:
QVariantList Nuria::RestfulHttpNode::deepConvertList (QVariantList list) {
for (auto it = list.begin (), end = list.end (); it != end; ++it) {
*it = serializeVariant (*it);
}
return list;
}
示例8: 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.");
}
}
示例9: loadFromMap
/**
* Load settings from the map. Existings settings will be overwritten.
*/
void SettingsManager::loadFromMap(QVariantMap &map)
{
// 1. Load version
_version = map.value("version").toString();
// 2. Load UUID encoding
int encoding = map.value("uuidEncoding").toInt();
if (encoding > 3 || encoding < 0)
encoding = 0;
_uuidEncoding = (UUIDEncoding) encoding;
// 3. Load view mode
if (map.contains("viewMode")) {
int viewMode = map.value("viewMode").toInt();
if (viewMode > 2 || encoding < 0)
viewMode = Custom; // Default View Mode
_viewMode = (ViewMode) viewMode;
} else {
_viewMode = Custom; // Default View Mode
}
_autoExpand = map.contains("autoExpand") ?
map.value("autoExpand").toBool() : true;
_lineNumbers = map.contains("lineNumbers") ?
map.value("lineNumbers").toBool() : true;
// 4. Load TimeZone
int timeZone = map.value("timeZone").toInt();
if (timeZone > 1 || timeZone < 0)
timeZone = 0;
_timeZone = (SupportedTimes) timeZone;
_loadMongoRcJs = map.value("loadMongoRcJs").toBool();
_disableConnectionShortcuts = map.value("disableConnectionShortcuts").toBool();
// Load Batch Size
_batchSize = map.value("batchSize").toInt();
if (_batchSize == 0)
_batchSize = 50;
_currentStyle = map.value("style").toString();
if (_currentStyle.isEmpty()) {
_currentStyle = AppStyle::StyleName;
}
// 5. Load connections
_connections.clear();
QVariantList list = map.value("connections").toList();
for (QVariantList::iterator it = list.begin(); it != list.end(); ++it) {
ConnectionSettings *record = new ConnectionSettings((*it).toMap());
_connections.push_back(record);
}
}
示例10: uidHex
// For QML
QVariantList
RuleConditionNFC::getUidsQml() const {
QVariantList uids;
for (QSet<QByteArray>::const_iterator i = _uids.constBegin(); i != _uids.constEnd(); ++i) {
QString uidHex(i->toHex());
uids << uidHex; // QVariant::fromValue(*i);
}
qSort(uids.begin(), uids.end(), variantQStringLessThan);
return uids;
}
示例11: addMultipleItemsToQueue
int Player::addMultipleItemsToQueue(const QVariantList& payloads)
{
if (m_player)
{
std::vector<SONOS::DigitalItemPtr> items;
for (QVariantList::const_iterator it = payloads.begin(); it != payloads.end(); ++it)
items.push_back(it->value<SONOS::DigitalItemPtr>());
return m_player->AddMultipleURIsToQueue(items);
}
return 0;
}
示例12: jpush_setTags
void jpush_setTags(QVariantList tags)
{
QString st;
for(auto it = tags.begin(); it != tags.end(); ++it){
st += (*it).toString() + ",";
}
st.remove(st.length()-1, 1);
qDebug() << "******************* st=" << st;
QAndroidJniObject jst = QAndroidJniObject::fromString(st);
QAndroidJniObject::callStaticMethod<void>("qkit/KJPush","setTags","(Ljava/lang/String;)V", jst.object<jstring>());
}
示例13: fromQVariantList
void QueueResourcesList::fromQVariantList(QVariantList const& list)
{
QVariantList::const_iterator iter;
for (iter = list.begin(); iter != list.end(); ++iter) {
QueueResources* queue(new QueueResources());
if (queue->fromQVariant(*iter)) {
append(queue);
} else {
delete queue;
}
}
}
示例14: prettyList
QString MailAddress::prettyList(const QVariantList &list, FormattingMode mode)
{
QStringList buf;
for (QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) {
Q_ASSERT(it->type() == QVariant::StringList);
QStringList item = it->toStringList();
Q_ASSERT(item.size() == 4);
MailAddress a(item[0], item[1], item[2], item[3]);
buf << a.prettyName(mode);
}
return buf.join(QLatin1String(", "));
}
示例15: load
void SimpleClient::load(const QVariant& settings)
{
const QVariantMap map = settings.toMap();
if (map.contains("dialogs"))
{
const QVariantList list = map.value("dialogs").toList();
for (QVariantList::const_iterator it = list.begin();
it != list.end(); ++it)
{
const QVariantMap map = it->toMap();
const QString operation = map["operation"].toString();
if (!operation.isEmpty() && map.contains("value"))
{
// find the index
unsigned int i = 0;
const unsigned int count =
m_objref->interface()->operation_count();
for (; i < count; i++)
{
const char * current =
m_objref->interface()->get_reflective_by_index(
i)->get_name();
if (operation == current) break;
}
// load its saved value
if (i < count)
{
getRequestDialog(i)->load(map.value("value"));
}
}
}
}
if (map.contains("filtered_log"))
{
m_filteredLog->load(map["filtered_log"]);
}
if (map.contains("operations"))
{
// ensure created
showOperationSequenceTool();
m_seqTool->load(map["operations"]);
}
}