本文整理汇总了C++中QVariantMap::values方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::values方法的具体用法?C++ QVariantMap::values怎么用?C++ QVariantMap::values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::values方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onLineIsOpenFinished
void NetworkBus::onLineIsOpenFinished(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
m_error = QString::fromUtf8("线路开通数据请求错误,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}else{
JsonDataAccess jda; // at are you
const QVariant qtData = jda.loadFromBuffer(reply->readAll());
// TODO if qtData has some error
const QVariantMap map = qtData.toMap();
const QString msg = map.values("msg").value(0).toString();
const QString success = map.values("success").value(0).toString();
if(success != "true" || msg != "ok"){
m_error = QString::fromUtf8("线路开通返回失败,请检查网络后重试!");
onError();
return;
}
const QVariantList data = map["data"].toList();
m_eid = data.at(0).toMap().value("eid").toString();
m_isopen = data.at(0).toMap().value("isopen").toInt();
qDebug() << "isOpen:" << m_isopen << " eid:" << m_eid << "\n";
reply->deleteLater();
this->get_online_gps();
}
}
示例2: onAlllineDataModelFinished
void NetworkBus::onAlllineDataModelFinished(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
m_error = QString::fromUtf8("所有线路数据请求错误,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}else{
JsonDataAccess jda; // at are you
const QVariant qtData = jda.loadFromBuffer(reply->readAll());
// TODO if qtData has some error
const QVariantMap map = qtData.toMap();
const QString msg = map.values("msg").value(0).toString();
const QString success = map.values("success").value(0).toString();
if(success != "true" || msg != "ok"){
m_error = QString::fromUtf8("所有线路数据返回不成功,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}
//
const QVariantList data = map["data"].toList();
if(data.isEmpty() || data.length() == 0){
m_error = QString::fromUtf8("未查询到所有公交车线路数据!");
onError();
reply->deleteLater();
return ;
}
QString result = "";
m_alllineDataModel->clear();
for(int i=0;i<data.length();i++){
const QVariantMap iMap = data.at(i).toMap();
busline *bus = new busline;
bus->setBeginTime(iMap.value("begin_time").toString());
bus->setEndTime(iMap.value("end_time").toString());
bus->setId(iMap.value("id").toString());
bus->setStartStation(iMap.value("start_station").toString());
bus->setEndStation(iMap.value("end_station").toString());
bus->setPrice(iMap.value("price").toString());
bus->setLineName(iMap.value("line_name").toString());
bus->setIsOpen(iMap.value("isopen").toInt());//1
bus->setDir(iMap.value("dir").toInt());//0/1
bus->setCityId(m_city_id);
if(bus->getIsOpen() == 1)
m_alllineDataModel->append(bus);
}
reply->deleteLater();
}
qDebug()<< "m_allline datamodel size:" << m_alllineDataModel->size();
m_error = QString::fromUtf8("查询到所有公交车线路数据!");
this->setProcess(false);
emit processChanged();
emit alllineDataModelChanged();
}
示例3: onSublineInfFinished
//! [1]
void NetworkBus::onSublineInfFinished(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
m_error = QString::fromUtf8("站点信息请求失败,请检查网络后重试!");
onError();
reply->deleteLater();
return ;
}else{
JsonDataAccess jda; // at are you
const QVariant qtData = jda.loadFromBuffer(reply->readAll());
// TODO if qtData has some error
const QVariantMap map = qtData.toMap();
const QString msg = map.values("msg").value(0).toString();
const QString success = map.values("success").value(0).toString();
if(success != "true" || msg != "ok"){
m_error = QString::fromUtf8("站点信息返回不成功,请稍后重试!");
onError();
reply->deleteLater();
return;
}
const QVariantMap data = map["data"].toMap();
const QVariantList stations = data["stations"].toList();
if(stations.isEmpty() || stations.length() == 0){
m_error = QString::fromUtf8("未查询到站点数据!");
onError();
reply->deleteLater();
return ;
}
m_dataModel->clear();
for(int i=0;i<stations.length();i++){
const QVariantMap var = stations.at(i).toMap();
station *sta = new station();
sta->setCode(var["code"].toString());
sta->setId(var["id"].toString());
sta->setLat(var["lat"].toString());
sta->setLng(var["lng"].toString());
// QString name = QString::number(i+1) ;
// name.append(var["name"].toString());
sta->setIndex(QString::number(i+1));
// qDebug() << "name string : " << name ;
sta->setName(var["name"].toString());
if(m_dir == 0)
startStation->append(sta);
else endStation->append(sta);
}
m_dataModel->append(m_dir == 0 ? *startStation : *endStation);
}
qDebug() << "\nm_dataModel size :"<<m_dataModel->size() << "\n";
emit dataModelChanged();
emit buslineChanged();
reply->deleteLater();
this->get_lineisopen();
}
示例4: nextAiredEpisode
//--------------------------------------------------------------------------------------------------
AiredEpisodeDetails SeriesProvider::nextAiredEpisode(const Serie & serie) const
{
AiredEpisodeDetails details;
_network->read(getEpisodesDetailsUrl(serie));
if (_network->contentIsReady())
{
bool parsingIsOk;
QJson::Parser parser;
QVariantMap jsonResult = parser.parse(_network->content(),
&parsingIsOk).toMap();
if (parsingIsOk)
{
QVariantMap seasons = jsonResult["root"].toMap()["seasons"].toMap();
QVariantMap episodes = seasons["0"].toMap()["episodes"].toMap();
QList<QVariant> episodeList = episodes.values();
qSort(episodeList.begin(), episodeList.end());
foreach (const QVariant & episode, episodeList)
{
const QDateTime episodeDate =
QDateTime::fromTime_t(episode.toMap()["date"].toUInt());
if (episodeDate > _currentDate)
{
return AiredEpisodeDetails(episode.toMap()["episode"].toUInt(),
episodeDate.date());
}
}
}
}
示例5: initTables
void QxtWebJsonRPCService::Private::handle(QxtWebRequestEvent *event, QVariant rid, QString action, QVariant argsE)
{
QVariantMap argsM;
QVariantList args;
if (argsE.type() == QVariant::Map) {
argsM = argsE.toMap();
args = argsM.values();
} else {
args = argsE.toList();
}
if (!invokable)
initTables(p);
if (!methods.contains(action.toUtf8() + QByteArray::number(args.count()))) {
QVariantMap res;
res.insert("result", QVariant());
res.insert("error", "no such method or incorrect number of arguments");
res.insert("id", rid);
QxtWebPageEvent *err = new QxtWebPageEvent(event->sessionID, event->requestID,
QxtJSON::stringify(res).toUtf8() + "\r\n");
p->postEvent(err);
return;
}
Method method = methods.value(action.toUtf8() + QByteArray::number(args.count()));
if (argsE.type() == QVariant::Map) {
args.clear();
foreach (const QString &pname, method.meta.parameterNames ()) {
args.append(argsM.value(pname));
}
}
示例6: downLoadDataFinished
void MusicKWBackgroundThread::downLoadDataFinished(const QByteArray &bytes)
{
QJson::Parser parser;
bool ok;
if(bytes != "NO_PIC")
{
QVariant data = parser.parse(bytes, &ok);
if(ok)
{
QVariantMap dataMap = data.toMap();
QVariantList datas = dataMap["array"].toList();
foreach(const QVariant &value, datas)
{
dataMap = value.toMap();
if(m_counter < 5 && !dataMap.isEmpty())
{
QString url = dataMap.values().first().toString();
M_LOGGER_ERROR(url);
MusicDataDownloadThread *download = new MusicDataDownloadThread(url, QString("%1%2%3%4").arg(BACKGROUND_DIR_FULL)
.arg(m_savePath).arg(m_counter++).arg(SKN_FILE),
MusicDownLoadThreadAbstract::DownloadBigBG, this);
connect(download, SIGNAL(downLoadDataChanged(QString)), SLOT(downLoadFinished()));
download->startToDownload();
}
}
}
示例7: tLog
QVariantMap
HatchetAccount::parseReply( QNetworkReply* reply, bool& okRet ) const
{
QVariantMap resp;
reply->deleteLater();
bool ok;
int statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt( &ok );
if ( reply->error() != QNetworkReply::NoError && statusCode < 400 )
{
tLog() << Q_FUNC_INFO << "Network error in command:" << reply->error() << reply->errorString();
okRet = false;
return resp;
}
QJson::Parser p;
QByteArray replyData = reply->readAll();
resp = p.parse( replyData, &ok ).toMap();
if ( !ok )
{
tLog() << Q_FUNC_INFO << "Error parsing JSON from server" << replyData;
okRet = false;
return resp;
}
if ( statusCode >= 400 )
{
tDebug() << "Error from tomahawk server response, or in parsing from json:" << resp.value( "error" ).toString() << resp;
}
tDebug() << Q_FUNC_INFO << "Got keys" << resp.keys();
tDebug() << Q_FUNC_INFO << "Got values" << resp.values();
okRet = true;
return resp;
}
示例8: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
QFile vcf, xml;
if (args.count() > 1) {
vcf.setFileName(args[1]);
if (not vcf.open(QFile::ReadOnly)) {
qWarning("Cannot open %s for reading: %s",
qPrintable(vcf.fileName()),
qPrintable(vcf.errorString()));
return 1;
}
} else {
if (not vcf.open(stdin, QFile::ReadOnly)) {
qWarning("Cannot open STDIN for reading: %s",
qPrintable(vcf.errorString()));
return 1;
}
}
QVersitReader reader(&vcf);
if (not reader.startReading() ||
not reader.waitForFinished() ||
QVersitReader::NoError != reader.error()) {
qWarning("Cannot read vcard: rc=%d", reader.error());
return 1;
}
QVersitContactImporter importer;
if (not importer.importDocuments(reader.results())) {
typedef QMap<int, QVersitContactImporter::Error> ErrorMap;
const ErrorMap errors = importer.errors();
for(ErrorMap::ConstIterator it = errors.constBegin(); it != errors.constEnd(); ++it) {
qWarning("Cannot convert contact #%d: %d", it.key(), it.value());
}
return 1;
}
if (args.count() > 2) {
xml.setFileName(args[2]);
if (not xml.open(QFile::WriteOnly)) {
qWarning("Cannot open %s for writing: %s",
qPrintable(xml.fileName()),
qPrintable(xml.errorString()));
return 1;
}
} else {
if (not xml.open(stdout, QFile::WriteOnly)) {
qWarning("Cannot open STDIN for writing: %s",
qPrintable(xml.errorString()));
return 1;
}
}
QTextStream out(&xml);
out << "<Contacts>\n";
foreach(const QContact &contact, importer.contacts()) {
out << " <Contact id=\"" << makeIri(contact) << "\">\n";
foreach(const QContactDetail &detail, contact.details()) {
QVariantMap fields = detail.variantValues();
out << " <" << detail.definitionName();
if (not detail.detailUri().isEmpty()) {
out << " id=\"" << detail.detailUri() << "\"";
}
out << ">";
if (fields.count() > 1 || fields.keys().first() != detail.definitionName()) {
QVariantMap::ConstIterator it;
for(it = fields.constBegin(); it != fields.constEnd(); ++it) {
out << "\n ";
out << "<" << it.key() << ">";
out << toString(it.value());
out << "</" << it.key() << ">";
}
out << "\n ";
} else {
out << toString(fields.values().first());
}
out << "</" << detail.definitionName() << ">\n";
}
out << " </Contact>\n";
}
//.........这里部分代码省略.........
示例9: onBusLineFinished
//! [1]
void NetworkBus::onBusLineFinished(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
m_error = QString::fromUtf8("线路数据请求错误,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}else{
JsonDataAccess jda; // at are you
const QVariant qtData = jda.loadFromBuffer(reply->readAll());
// TODO if qtData has some error
const QVariantMap map = qtData.toMap();
const QString msg = map.values("msg").value(0).toString();
const QString success = map.values("success").value(0).toString();
if(success != "true" || msg != "ok"){
m_error = QString::fromUtf8("线路数据返回不成功,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}
//
const QVariantList data = map["data"].toList();
if(data.isEmpty() || data.length() == 0){
m_error = QString::fromUtf8("未查询到该趟公交车数据!");
onError();
reply->deleteLater();
return ;
}
QString result = "";
for(int i=0;i<data.length();i++){
const QVariantMap iMap = data.at(i).toMap();
busline *bus = new busline;
bus->setBeginTime(iMap.value("begin_time").toString());
bus->setEndTime(iMap.value("end_time").toString());
bus->setId(iMap.value("id").toString());
bus->setStartStation(iMap.value("start_station").toString());
bus->setEndStation(iMap.value("end_station").toString());
bus->setPrice(iMap.value("price").toString());
bus->setLineName(iMap.value("line_name").toString());
bus->setIsOpen(iMap.value("isopen").toInt());//1
bus->setDir(iMap.value("dir").toInt());//0/1
bus->setCityId(m_city_id);
if(bus->getIsOpen() == 0){
m_error = QString::fromUtf8("本线路暂未开通手机电子站牌。敬请期待!");
break;
}
if(iMap.value("dir").toInt() == 0){
int record_id = dbService->findRecordId(m_city_id,bus->getLineName());
if(record_id != 0){
dbService->updateRecord(record_id);
}else{
dbService->createRecord(bus);
}
dbService->readRecords(m_city_id);
emit localDataModelChanged();
startLine = bus;
}
else endLine = bus;
}
reply->deleteLater();
if(m_error.length() > 0){
onError();
emit buslineChanged();
return;
}
this->get_subline_inf(startLine->getId());
}
emit buslineChanged();
}
示例10: create_window
void IconGridActivity::create_window(const QRectF &window_geometry,
const QString &window_title,
const QPointF &window_pos) {
if (d->m_activity_window_ptr) {
return;
}
d->m_auto_scale_frame = false;
d->m_activity_window_ptr = new UIKit::Window();
d->m_activity_window_ptr->set_window_title(window_title);
d->m_activity_window_ptr->setGeometry(window_geometry);
d->m_grid_view = new UIKit::ItemView(d->m_activity_window_ptr,
UIKit::ItemView::kGridModel);
d->m_grid_view->set_view_geometry(window_geometry);
d->m_grid_view->on_item_removed([](UIKit::ModelViewItem *a_item) {
if (a_item)
delete a_item;
});
on_arguments_updated([this]() {
if (has_attribute("data")) {
QVariantMap data = attributes()["data"].toMap();
foreach(const QVariant & var, data.values()) {
QVariantMap _item = var.toMap();
Action *l_action_item = new Action;
d->m_action_list.append(l_action_item);
l_action_item->onActionActivated([this](const Action *aAction) {
d->m_activity_result.clear();
d->m_activity_result["controller"] = aAction->controller_name();
d->m_activity_result["action"] = aAction->label();
d->mSelection = aAction->label();
update_action();
});
UIKit::ModelViewItem *grid_item = new UIKit::ModelViewItem();
grid_item->on_view_removed([](UIKit::ModelViewItem *a_item) {
if (a_item && a_item->view()) {
UIKit::Widget *view = a_item->view();
if (view)
delete view;
}
});
grid_item->set_view(l_action_item->createActionItem(
_item["icon"].toString(), _item["label"].toString(),
_item["controller"].toString()));
d->m_grid_view->insert(grid_item);
d->m_grid_view->updateGeometry();
QRectF _content_rect = d->m_grid_view->boundingRect();
set_geometry(_content_rect);
d->m_activity_window_ptr->setGeometry(_content_rect);
}
}
if (has_attribute("auto_scale")) {
d->m_auto_scale_frame = attributes()["auto_scale"].toBool();
}
if (d->m_auto_scale_frame) {
QRectF _content_rect = d->m_grid_view->boundingRect();
_content_rect.setHeight(_content_rect.height() + 64);
set_geometry(_content_rect);
d->m_activity_window_ptr->setGeometry(_content_rect);
}
});