void VkAuth::get_access_token() { common::log("get_access_token"); QUrl url = web_view->url(); common::log(url.toString()); QUrlQuery url_query(url.toString().replace("#", "&")); common::OAuthData oauth_data; oauth_data.access_token = url_query.queryItemValue("access_token"); oauth_data.user_id = url_query.queryItemValue("user_id"); common::log(oauth_data.access_token); emit login_state((oauth_data.access_token.isEmpty() ? false : true), oauth_data); step = 0; }
QUrl MapAdapterWMS::tileQuery(const int& x, const int& y, const int& controller_zoom) const { // Get the url's query details. QUrlQuery url_query(getBaseUrl()); // Calculate the number of coordinates per tile. const int coord_per_tile_x = 360.0 / projection::get().tilesX(controller_zoom); const int coord_per_tile_y = 180.0 / projection::get().tilesY(controller_zoom); // Set BBOX (x1,y1,x2,y2). url_query.removeQueryItem("BBOX"); url_query.addQueryItem("BBOX", getBBox(-180 + x * coord_per_tile_x, 90 - (y + 1) * coord_per_tile_y, (-180 + x * coord_per_tile_x) + coord_per_tile_x, (90 - (y + 1) * coord_per_tile_y) + coord_per_tile_y)); // Create a new url with the modified url query. QUrl modified_url(getBaseUrl()); modified_url.setQuery(url_query); // Return the modified url. return QUrl(modified_url); }
void AnimePanel::accept() { QString score = ""; QString notes = ui->txtNotes->text(); int eps = ui->spinEps->value(); QString status = ui->comboStatus->currentText(); int rewatch = ui->spinRewatch->value(); if ((score_type == 0) || (score_type == 1)) { int i_score = static_cast<QSpinBox *>(score_widget)->value(); score = QString::number(i_score); } else if ((score_type == 3) || (score_type == 2)) { score = static_cast<QComboBox *>(score_widget)->currentText(); } else { double d_score = static_cast<QDoubleSpinBox *>(score_widget)->value(); score = QString::number(d_score); } if (((anime->getMyNotes() != notes) || (anime->getMyProgress() != eps) || (anime->getMyScore() != score) || (anime->getMyStatus() != status.toLower()) || (anime->getMyRewatch() != rewatch)) && !new_entry) { QMap<QString, QString> data; data.insert("id", anime->getID()); if (anime->getMyStatus() != status.toLower()) { data.insert("list_status", status.toLower()); anime->setMyStatus(status); } if (anime->getMyScore() != score) { data.insert("score", score); anime->setMyScore(score); } if (anime->getMyProgress() != eps) { data.insert("episodes_watched", QString::number(eps)); anime->setMyProgress(eps); } if (anime->getMyRewatch() != rewatch) { data.insert("rewatched", QString::number(rewatch)); anime->setMyRewatch(rewatch); } if (anime->getMyNotes() != notes) { data.insert("notes", notes); anime->setMyNotes(notes); } API::sharedAPI()->sharedAniListAPI()->put( API::sharedAPI()->sharedAniListAPI()->API_EDIT_LIST, data); } if (new_entry) { QUrl url = API::sharedAPI()->sharedAniListAPI()->API_EDIT_LIST; QUrlQuery url_query(url); url_query.addQueryItem("id", anime->getID()); url_query.addQueryItem("list_status", status.toLower()); anime->setMyStatus(status); if (("0" != score) && ("0.0" != score)) { url_query.addQueryItem("score", score); anime->setMyScore(score); } if (0 != eps) { url_query.addQueryItem("episodes_watched", QString::number(eps)); anime->setMyProgress(eps); } if (anime->getMyRewatch() != rewatch) { url_query.addQueryItem("rewatched", QString::number(rewatch)); anime->setMyRewatch(rewatch); } if (anime->getMyNotes() != notes) { url_query.addQueryItem("notes", notes); anime->setMyNotes(notes); } url.setQuery(url_query); API::sharedAPI()->sharedAniListAPI()->post(url, url_query.query().toLocal8Bit()); } done(QDialog::Accepted); }
void MapAdapterWMS::setBaseUrl(const QUrl& base_url) { // Get the url's query details. QUrlQuery url_query(base_url); // Enforce SERVICE (WMS). url_query.removeQueryItem("SERVICE"); url_query.addQueryItem("SERVICE", "WMS"); // Enforce REQUEST (GetMap). url_query.removeQueryItem("REQUEST"); url_query.addQueryItem("REQUEST", "GetMap"); // Enforce TILED (TRUE). url_query.removeQueryItem("TILED"); url_query.addQueryItem("TILED", "TRUE"); // Enforce WIDTH (the tile size). url_query.removeQueryItem("WIDTH"); url_query.addQueryItem("WIDTH", QString::number(ImageManager::get().tileSizePx())); // Enforce HEIGHT (the tile size). url_query.removeQueryItem("HEIGHT"); url_query.addQueryItem("HEIGHT", QString::number(ImageManager::get().tileSizePx())); // Is VERSION specified? if(url_query.hasQueryItem("VERSION") == false) { // Set the default version (1.1.1). /// @todo default to 1.3.0 instead? url_query.addQueryItem("VERSION", "1.1.1"); } // Is TRANSPARENT specified? if(url_query.hasQueryItem("TRANSPARENT") == false) { // Set the default transparent (true). url_query.addQueryItem("TRANSPARENT", "TRUE"); } // Is LAYERS specified? //if(url_query.hasQueryItem("LAYERS") == false) //{ // // Set the default layers (TBD). // url_query.addQueryItem("LAYERS", TBD); //} // Is SRS or CRS specified? if(url_query.hasQueryItem("SRS") == false && url_query.hasQueryItem("CRS") == false) { // Set the default srs (projection system value). url_query.addQueryItem("SRS", QString("EPSG:") + QString::number(projection::get().epsg())); url_query.addQueryItem("CRS", QString("EPSG:") + QString::number(projection::get().epsg())); //url_query.addQueryItem("SRS", "EPSG:4326"); // Equirectangular projection (lat/long) //url_query.addQueryItem("SRS", "EPSG:900913"); // Google Mercator projection //url_query.addQueryItem("SRS", "EPSG:3857"); // Spherical Mercator projection } // Is STYLES specified? if(url_query.hasQueryItem("STYLES") == false) { // Set the default styles (blank). url_query.addQueryItem("STYLES", QString()); } // Is FORMAT specified? if(url_query.hasQueryItem("FORMAT") == false) { // Set the default format (png). url_query.addQueryItem("FORMAT", "IMAGE/PNG"); } // Remove BBOX (is added at time of actually query). url_query.removeQueryItem("BBOX"); // Create a new url with the modified url query. QUrl modified_url(base_url); modified_url.setQuery(url_query); // Quick check that the url has a path. if(modified_url.path().isEmpty()) { // Set a default path (/wms/). modified_url.setPath("/wms/"); } // Set the url path. MapAdapter::setBaseUrl(modified_url); }