QMultiMap<int, QString> QFactoryLoader::keyMap() const { QMultiMap<int, QString> result; const QString metaDataKey = QStringLiteral("MetaData"); const QString keysKey = QStringLiteral("Keys"); const QList<QJsonObject> metaDataList = metaData(); for (int i = 0; i < metaDataList.size(); ++i) { const QJsonObject metaData = metaDataList.at(i).value(metaDataKey).toObject(); const QJsonArray keys = metaData.value(keysKey).toArray(); const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) result.insert(i, keys.at(k).toString()); } return result; }
QMenu* IndigoMenuBar::getMenuItemFromJson(const QJsonObject json) { // TODO: make sure that label exists QMenu *menuItem = new QMenu(json["label"].toString()); QJsonArray children = json["children"].toArray(); for (int i = 0; i < children.size(); i++) { QJsonObject child = children[i].toObject(); if (child.contains("children")) { menuItem->addMenu(this->getMenuItemFromJson(child)); } else { menuItem->addAction(this->getActionFromJson(child, menuItem)); } } return menuItem; }
QString Job::getPrediction(QString problemsJson, QString brainJson, bool & ok, Brain::Mode mode) { QJsonDocument json; QJsonArray problemsJsonArray; QVector<Problem*> problems; QString prediction; // Brain Brain brain(nullptr, 0, QJsonDocument::fromJson(brainJson.toUtf8()).object(), qrand(), mode); // Problems if(ok) { json = QJsonDocument::fromJson(problemsJson.toUtf8()); if(json.isEmpty()) { ok = false; Util::writeError("can't load problems"); } } if(ok) { problemsJsonArray = json.object()["problems"].toArray(); } if(ok) { problems.clear(); for(int i = 0 ; i < problemsJsonArray.size() ; i++) { problems.push_back(new Problem(problemsJsonArray[i].toObject(), inputCount)); } } // Compute if(ok) { prediction = "{ "; for(int i = 0 ; i < problems.size() ; i++) { if(i) { prediction += " ; "; } prediction += (brain.getPrediction(problems[i]->getInputs())); } prediction += " }"; } return prediction; }
void AccessControlPage::moveAccessControlRuleDown() { QJsonArray accessControlRules = VeyonCore::config().accessControlRules(); int row = ui->accessControlRulesView->currentIndex().row(); int newRow = row + 1; if( newRow < accessControlRules.size() ) { const QJsonValue swapValue = accessControlRules[row]; accessControlRules[row] = accessControlRules[newRow]; accessControlRules[newRow] = swapValue; modifyAccessControlRules( accessControlRules, newRow ); } }
bool Plugin14C::areDatesMergeable(const QJsonArray& dates) { QString refCurve; for(int i=0; i<dates.size(); ++i) { QJsonObject date = dates[i].toObject(); QJsonObject data = date[STATE_DATE_DATA].toObject(); QString curve = data[DATE_14C_REF_CURVE_STR].toString(); if(refCurve.isEmpty()) refCurve = curve; else if(refCurve != curve) return false; } return true; }
bool JSONModel :: getInt32Array (const char *key, std::vector<int32_t> &value) const { auto it = d->jsonObject.find(key); if (it == d->jsonObject.end()) return false; if (!(*it).isArray()) return false; QJsonArray array = (*it).toArray(); value.resize(array.size()); auto array_it = array.constBegin(); auto value_it = value.begin(); while (array_it !=array.constEnd() && value_it != value.end()) { (*value_it++) = (*array_it++).toInt(); } return true; }
void Model::add_monster(QJsonArray monster_array, char type){ QJsonObject monster_obj; for(int i=0; i<monster_array.size();i++){ monster_obj=monster_array[i].toObject(); if(type == 'g'){ Goomba* m = new Goomba(monster_obj["line"].toInt(),monster_obj["column"].toInt(),tf->tile_vector(GOOMBA),GOOMBA, 30, 2); monster_vector.push_back(m); }else if(type == 'k'){ Koopa* m = new Koopa(monster_obj["line"].toInt(),monster_obj["column"].toInt(),tf->tile_vector(KOOPA),KOOPA, 40, 2); monster_vector.push_back(m); }else if(type == 'f'){ Bad_flower* m = new Bad_flower(monster_obj["line"].toInt(),monster_obj["column"].toInt(),tf->tile_vector(BAD_FLOWER),BAD_FLOWER, 30, 2); monster_vector.push_back(m); } } }
int QFactoryLoader::indexOf(const QString &needle) const { const QString metaDataKey = QStringLiteral("MetaData"); const QString keysKey = QStringLiteral("Keys"); const QList<QJsonObject> metaDataList = metaData(); for (int i = 0; i < metaDataList.size(); ++i) { const QJsonObject metaData = metaDataList.at(i).value(metaDataKey).toObject(); const QJsonArray keys = metaData.value(keysKey).toArray(); const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) { if (!keys.at(k).toString().compare(needle, Qt::CaseInsensitive)) return i; } } return -1; }
void JsonFileReader::readGroup(Group *group, const QJsonArray &groupObj) { for (int i = 0; i < groupObj.size(); i++) { QJsonObject obj = groupObj[i].toObject(); if (obj["Type"].toString() == "Circle") { group->add(readCircle(obj)); } else if (obj["Type"].toString() == "Rectangle") { group->add(readRectangle(obj)); } else if (obj["Type"].toString() == "Line") { group->add(readLine(obj)); } else { throw std::runtime_error("Invalid visual entity!"); } } }
MCMCSettings MCMCSettings::fromJson(const QJsonObject& json) { MCMCSettings settings; settings.mNumChains = json.contains(STATE_MCMC_NUM_CHAINS) ? json[STATE_MCMC_NUM_CHAINS].toInt() : MCMC_NUM_CHAINS_DEFAULT; settings.mNumRunIter = json.contains(STATE_MCMC_NUM_RUN_ITER) ? json[STATE_MCMC_NUM_RUN_ITER].toInt() : MCMC_NUM_RUN_DEFAULT; settings.mNumBurnIter = json.contains(STATE_MCMC_NUM_BURN_ITER) ? json[STATE_MCMC_NUM_BURN_ITER].toInt() : MCMC_NUM_BURN_DEFAULT; settings.mMaxBatches = json.contains(STATE_MCMC_MAX_ADAPT_BATCHES) ? json[STATE_MCMC_MAX_ADAPT_BATCHES].toInt() : MCMC_MAX_ADAPT_BATCHES_DEFAULT; settings.mNumBatchIter = json.contains(STATE_MCMC_ITER_PER_BATCH) ? json[STATE_MCMC_ITER_PER_BATCH].toInt() : MCMC_ITER_PER_BATCH_DEFAULT; settings.mThinningInterval = json.contains(STATE_MCMC_THINNING_INTERVAL) ? json[STATE_MCMC_THINNING_INTERVAL].toInt() : MCMC_THINNING_INTERVAL_DEFAULT; settings.mMixingLevel = json.contains(STATE_MCMC_MIXING) ? json[STATE_MCMC_MIXING].toDouble() : MCMC_MIXING_DEFAULT; QJsonArray seeds = json[STATE_MCMC_SEEDS].toArray(); for(int i=0; i<seeds.size(); ++i) settings.mSeeds.append(seeds[i].toInt()); return settings; }
QJsonArray PhaseItem::getEvents() const { QString phaseId = QString::number(mData[STATE_ID].toInt()); QJsonObject state = MainWindow::getInstance()->getProject()->state(); QJsonArray allEvents = state[STATE_EVENTS].toArray(); QJsonArray events; for(int i=0; i<allEvents.size(); ++i) { QJsonObject event = allEvents[i].toObject(); QString phasesIdsStr = event[STATE_EVENT_PHASE_IDS].toString(); QStringList phasesIds = phasesIdsStr.split(","); if(phasesIds.contains(phaseId)) events.append(event); } return events; }
void JsArchitecturalMetricsConfig::loadMetricsInfo() { _ui->scriptsMetricsTable->setColumnWidth(1, 240); _ui->scriptsMetricsTable->setColumnWidth(2, 110); QFile jsonFile(_jsArchitecturalMetricsDir+"/"+ _jsonFileName); QString contentJsonFile; if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning("Couldn't open json file."); return; } contentJsonFile = jsonFile.readAll(); jsonFile.close(); QJsonDocument jsonDocument = QJsonDocument::fromJson(contentJsonFile.toUtf8()); QJsonObject jsonObject = jsonDocument.object(); QString scriptMetricDefault = jsonObject.value("MetricDefault").toString(); QJsonArray scriptsList = jsonObject.value(QString("ScriptsFile")).toArray(); for(int i = 0; i < scriptsList.size(); i++) { QString metricName; QString shortDescription; QString scriptFile; metricName = scriptsList.at(i).toObject().value("MetricName").toString(); shortDescription = scriptsList.at(i).toObject().value("ShortDescription").toString(); scriptFile = scriptsList.at(i).toObject().value("ScriptFile").toString(); _ui->scriptsMetricsTable->insertRow(0); _ui->scriptsMetricsTable->setItem(0, 0, new QTableWidgetItem(metricName)); _ui->scriptsMetricsTable->setItem(0, 1, new QTableWidgetItem(shortDescription)); _ui->scriptsMetricsTable->setItem(0, 2, new QTableWidgetItem(scriptFile)); _ui->metricDefaultComboBox->addItem(metricName,QVariant::fromValue(scriptFile)); if(scriptFile == scriptMetricDefault){ _ui->scriptsMetricsTable->selectRow(0); _ui->metricDefaultComboBox->setCurrentIndex(i); } } }
Mode7::Mode7(const Comment &comment) { Q_ASSERT(comment.mode == 7); QJsonArray data = QJsonDocument::fromJson(comment.string.toUtf8()).array(); int l; if ((l = data.size()) < 5){ return; } QSize size = ARender::instance()->getActualSize(); auto getDouble = [&data](int i){return data.at(i).toVariant().toDouble(); }; double scale = getScale(comment.mode, comment.date, size); bPos = QPointF(getDouble(0), getDouble(1)); ePos = l < 8 ? bPos : QPointF(getDouble(7), getDouble(8)); int w = size.width(), h = size.height(); if (bPos.x() < 1 && bPos.y() < 1 && ePos.x() < 1 && ePos.y() < 1){ bPos.rx() *= w; ePos.rx() *= w; bPos.ry() *= h; ePos.ry() *= h; scale = 1; } else if (scale == 0){ scale = 1; } else{ QSizeF player = getPlayer(comment.date); QPoint offset = QPoint((w - player.width()*scale) / 2, (h - player.height()*scale) / 2); bPos = bPos*scale + offset; ePos = ePos*scale + offset; } QStringList alpha = data[2].toString().split('-'); bAlpha = alpha[0].toDouble(); eAlpha = alpha[1].toDouble(); life = getDouble(3); QJsonValue v = l < 12 ? QJsonValue(true) : data[11]; int effect = (v.isString() ? v.toString() == "true" : v.toVariant().toBool()) ? Config::getValue("/Danmaku/Effect", 5) / 2 : -1; QFont font = getFont(scale ? comment.font*scale : comment.font, l < 13 ? Utils::defaultFont(true) : data[12].toString()); QString string = data[4].toString(); cache = getCache(string, comment.color, font, getSize(string, font), comment.isLocal(), effect, 100); zRotate = l < 6 ? 0 : getDouble(5); yRotate = l < 7 ? 0 : getDouble(6); wait = l < 11 ? 0 : getDouble(10) / 1000; stay = l < 10 ? 0 : life - wait - getDouble(9) / 1000; enabled = true; source = &comment; time = 0; }
ModList ModList::Load(QString filePath) { QFile modfile(filePath); modfile.open(QIODevice::ReadOnly); QByteArray filedata = modfile.readAll(); QJsonDocument modlist(QJsonDocument::fromJson(filedata)); QJsonObject object = modlist.object(); QJsonArray modArray = object["mods"].toArray(); ModList newModList; for (int idx = 0; idx < modArray.size(); ++idx) { QJsonObject mod = modArray[idx].toObject(); newModList.mods.append(Mod(mod)); } return newModList; }
void Client::setStatistics(const QJsonValue &property_str){ QJsonArray texts = property_str.toArray(); if(texts.size() != 2){ return; } QString property_name = texts.at(0).toString(); const QJsonValue &value_str = texts.at(1); StatisticsStruct *statistics = Self->getStatistics(); if(value_str.isDouble()) statistics->setStatistics(property_name, value_str.toDouble()); else statistics->setStatistics(property_name, value_str.toString()); Self->setStatistics(statistics); }
void NewWakuSettingsWindow::setPresetsFromJson(const QJsonObject& jsn) { ui->tags_list->clear(); { const QJsonObject necessary = jsn["necessary"].toObject(); ui->title->setText(necessary["title"].toString()); ui->description->setPlainText(necessary["description"].toString()); const QJsonArray community = necessary["community"].toArray(); ui->community->setCurrentIndex(ui->community->findData(community[1].toVariant())); const QJsonArray category = necessary["category"].toArray(); ui->category->setCurrentIndex(ui->category->findData(category[1].toVariant())); } { const QJsonObject other = jsn["other"].toObject(); const QJsonArray tags = other["tags"].toArray(); for (int i = 0; i < tags.size(); ++i) { QListWidgetItem* item = new QListWidgetItem(ui->tags_list); const QJsonArray jitem = tags[i].toArray(); item->setText(jitem[1].toString()); item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsUserCheckable); item->setCheckState(jitem[0].toBool()?Qt::Checked:Qt::Unchecked); } ui->tag_allLock->setChecked(other["tag_all_lock"].toBool()); ui->additional_unmask->setChecked(other["add_unmask"].toBool()); ui->additional_callMe->setChecked(other["add_call_me"].toBool()); ui->additional_cruise->setChecked(other["add_cruise"].toBool()); ui->communityOnly->setChecked(other["community_only"].toBool()); ui->timeshift->setChecked(other["timeshift"].toBool()); ui->twitter->setChecked(other["twitter"].toBool()); ui->twitterTag->setText(other["twitter_tag"].toString()); ui->advertising->setChecked(other["advertising"].toBool()); ui->ichiba->setChecked(other["ichiba"].toBool()); ui->song_csv_file->setText(other["song_csv"].toString()); } }
QPointer<TrainTimetable> DczajaApiResponseParser::parseResponse(QByteArray response){ qDebug() << response; QPointer<TrainTimetable> timetable = new TrainTimetable(); QJsonParseError err; if(err.error != QJsonParseError::NoError){ throw new NotJsonResponseException("The response from the server did not contain valid JSON. Error message: " + err.errorString()); } QJsonDocument doc = QJsonDocument::fromJson(response, &err); QJsonObject json_root = doc.object(); QJsonArray json_connections = json_root["connections"].toArray(); QString json_travel_source = json_root["start"].toString(); QString json_travel_destination = json_root["end"].toString(); for(int i=0; i< json_connections.size(); i++){ QJsonObject single_result = json_connections[i].toObject(); QPointer<TrainConnection> connection = new TrainConnection(); connection->setSource(json_travel_source); connection->setDestination(json_travel_destination); QString departure = single_result["dateStart"].toString() + " " + single_result["departure"].toString(); QString arrival = single_result["dateStart"].toString() + " " + single_result["arrival"].toString(); qDebug() << departure; connection->setJourneyStartDate(QDateTime::fromString(departure, "dd.MM.yy HH:mm")); connection->setJourneyEndDate(QDateTime::fromString(arrival, "dd.MM.yy HH:mm")); QStringList train_types; QJsonArray trains = single_result["trains"].toArray(); for(int j=0;j<trains.size();j++){ QJsonObject curr_train = trains[j].toObject(); train_types.append(curr_train["carrier"].toString()); } connection->setCarrierName(train_types.join(",")); timetable->addConnection(connection); } return timetable; }
QStringList SeleniumServerHub::getValueArrayString(QString s) { QJsonObject result = get(s); QStringList array; if(result["value"].isArray()) { QJsonArray arr = result["value"].toArray(); for(int i = 0; i < arr.size(); i++) { array << arr.at(i).toString(); } } else { qDebug()<<"Error get array string value"; } return array; }
void ParseAskUpdateData(const QJsonObject& json, QVector<AskUpdateData>& vecAskUpdateData) { QJsonArray jaSubPrice = json[szAttributeName[AN_PRICE]].toArray(); QJsonArray jaSubAmount = json[szAttributeName[AN_AMOUNT]].toArray(); QJsonArray jaSubRow = json[szAttributeName[AN_ROW]].toArray(); vecAskUpdateData.resize(jaSubPrice.size()); for (int ix = 0; ix != vecAskUpdateData.size(); ++ix) { AskUpdateData& ad = vecAskUpdateData[ix]; ad.dPrice = jaSubPrice[ix].toDouble(); ad.dAmount = jaSubAmount[ix].toDouble(); ad.nRow = jaSubRow[ix].toInt(); } }
bool SpritePackerProjectFile::read(const QString &fileName) { QDir dir(QFileInfo(fileName).absolutePath()); QFile file(fileName); file.open(QIODevice::ReadOnly); QJsonObject json = QJsonDocument::fromJson(file.readAll()).object(); if (json.isEmpty()) { return false; } if (json.contains("algorithm")) _algorithm = json["algorithm"].toString(); if (json.contains("trimMode")) _trimMode = json["trimMode"].toString(); if (json.contains("trimThreshold")) _trimThreshold = json["trimThreshold"].toInt(); if (json.contains("epsilon")) _epsilon = json["epsilon"].toDouble(); if (json.contains("textureBorder")) _textureBorder = json["textureBorder"].toInt(); if (json.contains("spriteBorder")) _spriteBorder = json["spriteBorder"].toInt(); if (json.contains("maxTextureSize")) _maxTextureSize = json["maxTextureSize"].toInt(); if (json.contains("pow2")) _pow2 = json["pow2"].toBool(); if (json.contains("imageFormat")) _imageFormat = json["imageFormat"].toString(); if (json.contains("pixelFormat")) _pixelFormat = json["pixelFormat"].toString(); if (json.contains("optMode")) _optMode = json["optMode"].toString(); if (json.contains("optLevel")) _optLevel = json["optLevel"].toInt(); _scalingVariants.clear(); QJsonArray scalingVariants = json["scalingVariants"].toArray(); for (int i=0; i<scalingVariants.size(); ++i) { QJsonObject scalingVariantObject = scalingVariants[i].toObject(); ScalingVariant scalingVariant; scalingVariant.name = scalingVariantObject["name"].toString(); scalingVariant.scale = scalingVariantObject["scale"].toDouble(); _scalingVariants.push_back(scalingVariant); } if (json.contains("dataFormat")) _dataFormat = json["dataFormat"].toString(); if (json.contains("destPath")) _destPath = QDir(dir.absoluteFilePath(json["destPath"].toString())).canonicalPath(); if (json.contains("spriteSheetName")) _spriteSheetName = json["spriteSheetName"].toString(); _srcList.clear(); QJsonArray srcRelative = json["srcList"].toArray(); for (auto src: srcRelative) { _srcList.push_back(dir.absoluteFilePath(src.toString())); } return true; }
void QPubNub::publishFinished() { QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender()); QJsonArray response; if (handleResponse(reply, response)) { return; } if (response.size() >= 2) { const QJsonValue statusCode(response[0]); if ((int)statusCode.toDouble() == 0) { emit error(response[1].toString(), 0); } else { emit published(response[2].toString()); } } else { emit error("Response array is too small", 0); } }
void PvrManager::loadTasks() { STUB(); m_tasks.clear(); const QString str = m_profile->datasource()->get("PVR", "tasks"); const QJsonArray arr = QJsonDocument::fromJson(str.toUtf8()).array(); for(size_t index = 0; index< arr.size(); index++) { TaskInfo* task = TaskInfo::fromJson(m_profile, arr.at(index).toObject(), this); if(task) { m_tasks.insert(QString::number(task->m_id), task); task->scheduleStart(); } } DEBUG() << "Tasks loaded:" << m_tasks.size(); }
void NgfpReader::containerFromJson (const QJsonArray &j_container, Container *container, Project *project, Screen *screen) { for (int i = 0; i < j_container.size(); i++) { if (!j_container[i].isObject()) { last_warnings.append("Not a proper JSON object for element in .ngfp"); continue; } QJsonValue j_elemview = j_container[i]; QJsonValue j_type = j_elemview.toObject()["type"]; if (!j_type.isString()) { last_warnings.append(QString("No proper \"type\" key for element %1").arg(i)); continue; } QString elem_keyname = g_ngfpFindElemName(j_type.toString()); auto elem_data = ElemRegistrar::get(elem_keyname); auto elemview_fct = ElemViewRegistrar::get(elem_keyname); if (elem_data == nullptr || elem_data->fct == nullptr || elemview_fct == nullptr) { last_warnings.append(QString("Unable to create \"%1\" element. Incorrect keyname or " "factory").arg(elem_keyname)); continue; } Elem *elem = elem_data->fct->create(); ElemView *elemview = elemview_fct->create(elem); QObject::connect(elemview, &ElemView::needToRemoveElem, project, &Core::Project::onNeedToRemoveElem); elemViewFromJson(j_elemview.toObject(), elemview, project); modifySpecificElemView(j_elemview, elemview, project, screen); elem->behave(); // because attribute values have been just loaded from file project->addElem(elem); screen->space_showed = container->getLastSpace(); screen->endMoveNewElemView(elemview); elemview->updateBindingStyle(project->temp_getLayer()->getFields()); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //Coloca m_Widgets[ WidgetID::TempoTotal ] << ui->labelTempoTotal; m_Widgets[ WidgetID::TempoTotal ] << ui->lineEditTempoTotal; m_Widgets[ WidgetID::Dte ] << ui->labelDte; m_Widgets[ WidgetID::Dte ] << ui->lineEditDte; m_Widgets[ WidgetID::Densidade ] << ui->labelDensidade; m_Widgets[ WidgetID::Densidade ] << ui->lineEditDensidade; QFile inputFile("widgets.json"); if (!inputFile.open(QIODevice::ReadOnly)) { qWarning("Couldn't open widgets file."); return; } QByteArray saveData = inputFile.readAll(); QJsonDocument loadDoc(QJsonDocument::fromJson(saveData)); QJsonObject jsonObj = loadDoc.object(); QJsonArray widgetsArray = jsonObj["widgets"].toArray(); for (int levelIndex = 0; levelIndex < widgetsArray.size(); ++levelIndex) { QJsonObject widget = widgetsArray[levelIndex].toObject(); qDebug() << widget["id"].toInt(); qDebug() << widget["name"].toString(); qDebug() << widget["visible"].toBool(); this->setHidden(widget["id"].toInt(), !widget["visible"].toBool()); } // this->setHidden(WidgetID::TempoTotal, true); // this->setHidden(WidgetID::Dte, false); // this->setHidden(WidgetID::Densidade, true); }
void LoginManager::onAccessTokenRequestReady(QByteArray ba) { //qDebug() << "onAccessTokenRequestReady" << ba; if (_oauthManager->lastError() == KQOAuthManager::RequestUnauthorized) { // 401/406 QJsonDocument jsonResponse = QJsonDocument::fromJson(ba); QJsonArray array = jsonResponse.array(); QString message = tr("Unsuccessful login. Please try again."); if (array.size() > 0) { QJsonObject o = array.at(0).toObject(); if (o.value("code") != QJsonValue::Undefined) { QString code = o["code"].toString(); if (code == "USER_AUTHENTICATION_FAILED") { message = tr("Sorry, wrong email address, username or password. Please check again. %1Have you forgotten your password%2?") .arg("<a href=\"https://musescore.com/user/password\">") .arg("</a>"); } else if (code == "USER_DENIED") { message = tr("This account has been blocked."); } else if (code == "USER_NOT_ACTIVATED") { message = tr("Your account has not been activated yet. Please check your mailbox to activate your account or %1request a new activation email%2.") .arg("<a href=\"https://musescore.com/user/resendregistrationpassword\">") .arg("</a>"); } else if (code == "USER_TIMESTAMP_EXPIRED") { message = tr("The local time on your device is not set right. Please check it and adjust. It's advised to set the time/timezone to automatic. If you still can't log in, %1contact us%2.") .arg("<a href=\"https://musescore.com/contact?category=Login%20problems\">") .arg("</a>"); } } } emit loginError(message); } else if (_oauthManager->lastError() == KQOAuthManager::NetworkError) { QMessageBox::critical(0, tr("Network error"), tr("Please check your Internet connection")); } else if (_oauthManager->lastError() == KQOAuthManager::ContentOperationNotPermittedError) { QMessageBox::critical(0, tr("Please upgrade"), tr("Your MuseScore version is too old to use this feature.\n" "%1Please upgrade first%2.") .arg("<a href=\"https://musescore.org\">") .arg("</a>") .replace("\n", "<br/>")); } }
void QTweetFollowersID::parseJsonFinished(const QJsonDocument &jsonDoc) { if (jsonDoc.isObject()) { QList<qint64> idList; QJsonObject respJsonObject = jsonDoc.object(); QJsonArray idJsonArray = respJsonObject["ids"].toArray(); for (int i = 0; i < idJsonArray.size(); ++i) idList.append(static_cast<qint64>(idJsonArray[i].toDouble())); QString nextCursor = respJsonObject["next_cursor_str"].toString(); QString prevCursor = respJsonObject["previous_cursor_str"].toString(); emit parsedIDs(idList, nextCursor, prevCursor); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QStringList DREAM3DSettings::value(const QString& key, const QStringList& defaultList) { if (m_Stack.top()->group[key].isArray() == false) { return defaultList; } QJsonArray jsonArray = m_Stack.top()->group[key].toArray(); QStringList list; for (int i = 0; i < jsonArray.size(); i++) { QString str = jsonArray[i].toString(); list.push_back(str); } return list; }
void DataSummary::read(const QJsonObject &json) { #if QT_VERSION < 0x050200 m_idBegin = json["idbegin"].toVariant().toInt(); m_idEnd = json["idend"].toVariant().toInt(); #else m_idBegin = json["idbegin"].toInt(); m_idEnd = json["idend"].toInt(); #endif // QT_VERSION < 0x050200 m_md5diggest = json["md5diggest"].toString(); QJsonArray dataArray = json["data"].toArray(); for(int i = 0; i < dataArray.size(); i++){ QJsonObject obj = dataArray[i].toObject(); Data data; data.read(obj); m_data.append(data); } }
void ParseAskDepthData(const QJsonObject& json, QList<AskDepthData>& listDepthData) { QJsonArray jaSubPrice = json[szAttributeName[AN_ASKPRICE]].toArray(); QJsonArray jaSubAmount = json[szAttributeName[AN_ASKAMOUNT]].toArray(); QJsonArray jaSubTotal = json[szAttributeName[AN_ASKTOTAL]].toArray(); listDepthData.clear(); for (int ix = 0; ix != jaSubPrice.size(); ++ix) { AskDepthData add; add.dPrice = jaSubPrice[ix].toDouble(); add.dAmount = jaSubAmount[ix].toDouble(); add.dTotal = jaSubTotal[ix].toDouble(); listDepthData.append(add); } }
void ServerCore::parseSupportCmds(QString uid, QByteArray byteArray) { QJsonDocument jsonDoc = QJsonDocument::fromJson(byteArray); QJsonObject jsonObj = jsonDoc.object(); if (jsonObj[JSON_KEY_STATUS].toInt() == STATUS_SUCCESSFUL) { QJsonArray cmdArray = jsonObj[JSON_KEY_SUPPORTCMDS].toArray(); for (int i = 0; i < cmdArray.size(); ++i) { QJsonObject cmdObj = cmdArray.at(i).toObject(); QString devCmd = cmdObj[JSON_KEY_COMMAND].toString(); QString devCmdDisplayName = cmdObj[JSON_KEY_CMD_DISPLAYNAME].toString(); QString paramType = cmdObj[JSON_KEY_PARAM_TYPE].toString(); PARAM_TYPE param_type = PARAM_TYPE::NONE; QString paramMin; QString paramMax; if (paramType == "integer") { param_type = PARAM_TYPE::INTEGER; paramMin = cmdObj[JSON_KEY_PARAM_MIN].toString(); paramMax = cmdObj[JSON_KEY_PARAM_MAX].toString(); } else if (paramType == "float") { param_type = PARAM_TYPE::FLOAT; paramMin = cmdObj[JSON_KEY_PARAM_MIN].toString(); paramMax = cmdObj[JSON_KEY_PARAM_MAX].toString(); } else if (paramType == "text") { param_type = PARAM_TYPE::TEXT; } DeviceCommand commandDetail(devCmd, devCmdDisplayName, param_type, paramMin, paramMax); DeviceManagerModule()->AddDeviceCommand(uid, commandDetail); } } }