void QGeoCodeReplyNokia::networkFinished() { if (!m_reply) return; if (m_reply->error() != QNetworkReply::NoError) { // Removed because this is already done in networkError, which previously caused _two_ errors to be raised for every error. //setError(QGeoCodeReply::CommunicationError, m_reply->errorString()); //m_reply->deleteLater(); //m_reply = 0; return; } QGeoCodeXmlParser parser; if (parser.parse(m_reply)) { QList<QGeoLocation> locations = parser.results(); QGeoShape bounds = viewport(); if (bounds.isValid()) { for (int i = locations.size() - 1; i >= 0; --i) { if (!bounds.contains(locations[i].coordinate())) locations.removeAt(i); } } setLocations(locations); setFinished(true); } else { setError(QGeoCodeReply::ParseError, parser.errorString()); } m_reply->deleteLater(); m_reply = 0; }
IOHandler:: IOHandler(SEXP Robservations, SEXP Rlocations, SEXP Rorder, SEXP Rlambda, SEXP Rbindex, SEXP Rbvalues, SEXP Rc, SEXP Rbeta, SEXP RK, SEXP Ru) { setLocations(Rlocations); setObservations(Robservations); order_ = INTEGER(Rorder)[0]; lambda_ = REAL(Rlambda)[0]; c_ = REAL(Rc)[0]; UInt length_indexes = length(Rbindex); for (UInt i = 0; i<length_indexes; ++i) dirichlet_indexes_.push_back(INTEGER(Rbindex)[i]); for (UInt i = 0; i<length_indexes; ++i) dirichlet_values_.push_back(REAL(Rbvalues)[i]); beta_.push_back(REAL(Rbeta)[0]); beta_.push_back(REAL(Rbeta)[1]); K_ << REAL(RK)[0] , REAL(RK)[2], REAL(RK)[1], REAL(RK)[3]; UInt length_u = length(Ru); u_.resize(length_u); for (UInt i = 0; i<length_u; ++i) u_[i] = REAL(Ru)[i]; }
StelLocationMgr::StelLocationMgr(const LocationList &locations) { setLocations(locations); QSettings* conf = StelApp::getInstance().getSettings(); // Init to Paris France because it's the center of the world. lastResortLocation = locationForString(conf->value("init_location/last_location", "Paris, France").toString()); }
/*************************** LOCATION *******************************/ void QgsGrassNewMapset::setLocationPage( ) { QgsDebugMsg( "entered." ); setLocations(); }
void QgsGrassNewMapset::createMapset() { QgsDebugMsg( "entered." ); // TODO: handle all possible errors better, especially // half created location/mapset QString location; if ( mCreateLocationRadioButton->isChecked() ) { location = mLocationLineEdit->text().trimmed(); // TODO: add QgsGrass::setLocation or G_make_location with // database path QgsGrass::activeMode(); // because it calls private gsGrass::init() #if defined(WIN32) G__setenv(( char * ) "GISDBASE", QgsGrass::shortPath( mDatabaseLineEdit->text() ).toUtf8().data() ); #else G__setenv(( char * ) "GISDBASE", mDatabaseLineEdit->text().toUtf8().data() ); #endif int ret = 0; try { ret = G_make_location( location.toUtf8().data(), &mCellHead, mProjInfo, mProjUnits, stdout ); } catch ( QgsGrass::Exception &e ) { ret = -1; Q_UNUSED( e ); } if ( ret != 0 ) { QMessageBox::warning( this, tr( "Create location" ), tr( "Cannot create new location: %1" ).arg( QgsGrass::errorMessage() ) ); return; } // Location created -> reset widgets setLocations(); mSelectLocationRadioButton->setChecked( true ); mLocationComboBox->setItemText( mLocationComboBox->currentIndex(), location ); mLocationLineEdit->setText( "" ); locationRadioSwitched(); // calls also checkLocation() } else { location = mLocationComboBox->currentText(); } // Create mapset QString mapset = mMapsetLineEdit->text().trimmed(); if ( mapset != "PERMANENT" ) { QString locationPath = mDatabaseLineEdit->text() + "/" + location; QDir d( locationPath ); if ( !d.mkdir( mapset ) ) { QMessageBox::warning( this, tr( "Create mapset" ), tr( "Cannot create new mapset directory" ) ); return; } // Copy WIND Better way to copy file in Qt? QStringList lines; QFile in( locationPath + "/PERMANENT/DEFAULT_WIND" ); if ( !in.open( QIODevice::ReadOnly ) ) { QMessageBox::warning( this, tr( "Create mapset" ), tr( "Cannot open DEFAULT_WIND" ) ); return; } QFile out( locationPath + "/" + mapset + "/WIND" ); if ( !out.open( QIODevice::WriteOnly ) ) { QMessageBox::warning( this, tr( "Create mapset" ), tr( "Cannot open WIND" ) ); return; } QTextStream stream( &out ); //QTextStream stream( &file ); QString line; char buf[100]; while ( in.readLine( buf, 100 ) != -1 ) { stream << buf; } in.close(); out.close(); } QString err = QgsGrass::openMapset( mDatabaseLineEdit->text(), location, mapset ); if ( err.length() > 0 ) { QMessageBox::information( this, tr( "New mapset" ), tr( "New mapset successfully created, but cannot be opened: %1" ).arg( err ) ); } else { QMessageBox::information( this, tr( "New mapset" ), tr( "New mapset successfully created and set as current working mapset." ) ); mPlugin->mapsetChanged(); } deleteLater(); }
QgsGrassSelect::QgsGrassSelect( int type ): QgsGrassSelectBase() { QgsDebugMsg( QString( "QgsGrassSelect() type = %1" ).arg( type ) ); setupUi( this ); connect( buttonBox, SIGNAL( accepted() ), SLOT( on_ok_clicked() ) ); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( on_cancel_clicked() ) ); if ( first ) { if ( QgsGrass::activeMode() ) { lastGisdbase = QgsGrass::getDefaultGisdbase(); lastLocation = QgsGrass::getDefaultLocation(); lastMapset = QgsGrass::getDefaultMapset(); } else { QSettings settings; lastGisdbase = settings.value( "/GRASS/lastGisdbase" ).toString(); //check we got something from qsettings otherwise default to users home dir if ( lastGisdbase.isEmpty() ) { QDir home = QDir::home(); lastGisdbase = QString( home.path() ); } } first = false; } QgsGrassSelect::type = type; switch ( type ) { case QgsGrassSelect::VECTOR: setWindowTitle( tr( "Select GRASS Vector Layer" ) ); break; case QgsGrassSelect::RASTER: /* Remove layer combo box */ Layer->hide(); elayer->hide(); setWindowTitle( tr( "Select GRASS Raster Layer" ) ); break; case QgsGrassSelect::MAPCALC: /* Remove layer combo box */ Layer->hide(); elayer->hide(); setWindowTitle( tr( "Select GRASS mapcalc schema" ) ); break; case QgsGrassSelect::MAPSET: Layer->hide(); elayer->hide(); MapName->hide(); emap->hide(); setWindowTitle( tr( "Select GRASS Mapset" ) ); break; } egisdbase->setText( lastGisdbase ); setLocations(); adjustSize(); }
int BookInfo::update(const BookInfo *other) { qDebug() << Q_FUNC_INFO << "isbn" << other->isbn; int updateType = UPDATE_NONE; if(this == other) return updateType; dirty = true; if (title != other->title) { title = other->title; updateType |= UPDATE_METADATA; } if (isbn != other->isbn) { isbn = other->isbn; updateType |= UPDATE_METADATA; } qDebug() << Q_FUNC_INFO << "lastTimeRead1" << lastTimeRead; qDebug() << Q_FUNC_INFO << "other->lastTimeRead" << other->lastTimeRead; if (lastTimeRead != other->lastTimeRead) { lastTimeRead = other->lastTimeRead; updateType |= UPDATE_METADATA; } qDebug() << Q_FUNC_INFO << "readingStatus" << readingStatus; qDebug() << Q_FUNC_INFO << "other->readingStatus: " << other->readingStatus; if(readingStatus != other->readingStatus) { readingStatus = other->readingStatus; if(other->readingStatus == BookInfo::READ_BOOK || other->readingStatus == BookInfo::NO_READ_BOOK) updateType |= UPDATE_CLOSED; } if (path != other->path) { path = other->path; updateType |= UPDATE_METADATA; } if (author != other->author) { author = other->author; updateType |= UPDATE_METADATA; } if (thumbnail != other->thumbnail) { thumbnail = other->thumbnail; updateType |= UPDATE_METADATA; } if (coverUrl != other->coverUrl) { coverUrl = other->coverUrl; updateType |= UPDATE_METADATA; } if (publishTime != other->publishTime) { publishTime = other->publishTime; updateType |= UPDATE_METADATA; } if (size != other->size) { size = other->size; updateType |= UPDATE_METADATA; } downloadTime = other->downloadTime; if (markCount != other->markCount) { markCount = other->markCount; updateType |= UPDATE_READING_METADATA; } if (noteCount != other->noteCount) { noteCount = other->noteCount; updateType |= UPDATE_READING_METADATA; } if (hiliCount != other->hiliCount) { hiliCount = other->hiliCount; updateType |= UPDATE_READING_METADATA; } if (pageCount != other->pageCount) { pageCount = other->pageCount; updateType |= UPDATE_READING_METADATA; } if (lastReadLink != other->lastReadLink) { lastReadLink = other->lastReadLink; updateType |= UPDATE_READING_POSITION; } if (lastReadPage != other->lastReadPage) { lastReadPage = other->lastReadPage; updateType |= UPDATE_READING_POSITION; } if (fabs(readingProgress - other->readingProgress) > EPS) { readingProgress = other->readingProgress; updateType |= UPDATE_READING_POSITION; } if (fabs(readingPercentage != other->readingPercentage) > EPS) { readingPercentage = other->readingPercentage; updateType |= UPDATE_READING_POSITION; } if (readingPeriod != other->readingPeriod) readingPeriod = other->readingPeriod; if (percentageList != other->percentageList) percentageList = other->percentageList; if (fontSize != other->fontSize) { fontSize = other->fontSize; updateType |= UPDATE_READING_METADATA; } if (pageMode != other->pageMode) { pageMode = other->pageMode; updateType |= UPDATE_READING_METADATA; } if (orientation != other->orientation) { orientation = other->orientation; updateType |= UPDATE_READING_METADATA; } if (timestamp != other->timestamp) { timestamp = other->timestamp; updateType |= UPDATE_METADATA; } publisher = other->publisher; synopsis = other->synopsis; fileSize = other->fileSize; syncDate = other->syncDate; storePrice = other->storePrice; format = other->format; language = other->language; if (m_type != other->m_type) { m_type = other->m_type; updateType |= UPDATE_TYPE; } if (m_expirationDate != other->m_expirationDate) m_expirationDate = other->m_expirationDate; if(hasExpired()) updateType |= UPDATE_EXPIRATION; if(m_type == BOOKINFO_TYPE_SUBSCRIPTION) corrupted = true; else corrupted = other->corrupted; if (m_archived != other->m_archived) { m_archived = other->m_archived; updateType |= UPDATE_ARCHIVED; } if(isDRMFile != other->isDRMFile) isDRMFile = other->isDRMFile; m_collections = other->m_collections; m_cssFileList = other->m_cssFileList; totalReadingTime = other->totalReadingTime; if(locationsHasChanged(other->m_locations)) { qDebug() << Q_FUNC_INFO << "locations has changed"; updateType |= UPDATE_READING_METADATA; setLocations(other->m_locations); } return updateType; }
void QGeoCodeReplyOsm::networkReplyFinished() { if (!m_reply) return; if (m_reply->error() != QNetworkReply::NoError) return; QList<QGeoLocation> locations; QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (document.isObject()) { QJsonObject object = document.object(); QGeoCoordinate coordinate; coordinate.setLatitude(object.value(QStringLiteral("lat")).toString().toDouble()); coordinate.setLongitude(object.value(QStringLiteral("lon")).toString().toDouble()); QGeoLocation location; location.setCoordinate(coordinate); location.setAddress(parseAddressObject(object)); locations.append(location); setLocations(locations); } else if (document.isArray()) { QJsonArray results = document.array(); for (int i = 0; i < results.count(); ++i) { if (!results.at(i).isObject()) continue; QJsonObject object = results.at(i).toObject(); QGeoCoordinate coordinate; coordinate.setLatitude(object.value(QStringLiteral("lat")).toString().toDouble()); coordinate.setLongitude(object.value(QStringLiteral("lon")).toString().toDouble()); QGeoRectangle rectangle; if (object.contains(QStringLiteral("boundingbox"))) { QJsonArray a = object.value(QStringLiteral("boundingbox")).toArray(); if (a.count() == 4) { rectangle.setTopLeft(QGeoCoordinate(a.at(1).toString().toDouble(), a.at(2).toString().toDouble())); rectangle.setBottomRight(QGeoCoordinate(a.at(0).toString().toDouble(), a.at(3).toString().toDouble())); } } QGeoLocation location; location.setCoordinate(coordinate); location.setBoundingBox(rectangle); location.setAddress(parseAddressObject(object)); locations.append(location); } } setLocations(locations); setFinished(true); m_reply->deleteLater(); m_reply = 0; }
/*************************** LOCATION *******************************/ void QgsGrassNewMapset::setLocationPage() { setLocations(); }
void QGeoCodeReplyQGC::networkReplyFinished() { if (!m_reply) return; if (m_reply->error() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); QJsonObject object = document.object(); if (object.value(QStringLiteral("status")) != QStringLiteral("OK")) { QString error = object.value(QStringLiteral("status")).toString(); qWarning() << m_reply->url() << "returned" << error; setError(QGeoCodeReply::CommunicationError, error); m_reply->deleteLater(); m_reply = 0; return; } QList<QGeoLocation> locations; QJsonArray results = object.value(QStringLiteral("results")).toArray(); for (int i=0; i<results.size(); ++i) { if (!results[i].isObject()) continue; QJsonObject geocode = results[i].toObject(); QGeoAddress address; if (geocode.contains(QStringLiteral("formatted_address"))) { address.setText(geocode.value(QStringLiteral("formatted_address")).toString()); } if (geocode.contains(QStringLiteral("address_components"))) { QJsonArray ac = geocode.value(QStringLiteral("address_components")).toArray(); for (int j=0; j<ac.size(); ++j) { if (!ac[j].isObject()) continue; QJsonObject c = ac[j].toObject(); if (!c.contains(QStringLiteral("types"))) continue; QSet<int> types = kMonger.json2QGCGeoCodeType(c[QStringLiteral("types")].toArray()); QString long_name = c[QStringLiteral("long_name")].toString(); QString short_name = c[QStringLiteral("short_name")].toString(); if (types.contains(Country)) { address.setCountry(long_name); address.setCountryCode(short_name); } else if (types.contains(AdministrativeAreaLevel1)) { address.setState(long_name); } else if (types.contains(AdministrativeAreaLevel2)) { address.setCounty(long_name); } else if (types.contains(Locality)) { address.setCity(long_name); } else if (types.contains(Sublocality)) { address.setDistrict(long_name); } else if (types.contains(PostalCode)) { address.setPostalCode(long_name); } else if (types.contains(StreetAddress) || types.contains(Route) || types.contains(Intersection)) { address.setStreet(long_name); } } } QGeoCoordinate coordinate; QGeoRectangle boundingBox; if (geocode.contains(QStringLiteral("geometry"))) { QJsonObject geom = geocode.value(QStringLiteral("geometry")).toObject(); if (geom.contains(QStringLiteral("location"))) { QJsonObject location = geom.value(QStringLiteral("location")).toObject(); coordinate.setLatitude(location.value(QStringLiteral("lat")).toDouble()); coordinate.setLongitude(location.value(QStringLiteral("lng")).toDouble()); } if (geom.contains(QStringLiteral("bounds"))) { QJsonObject bounds = geom.value(QStringLiteral("bounds")).toObject(); QJsonObject northeast = bounds.value(QStringLiteral("northeast")).toObject(); QJsonObject southwest = bounds.value(QStringLiteral("southwest")).toObject(); QGeoCoordinate topRight(northeast.value(QStringLiteral("lat")).toDouble(), northeast.value(QStringLiteral("lng")).toDouble()); QGeoCoordinate bottomLeft(southwest.value(QStringLiteral("lat")).toDouble(), southwest.value(QStringLiteral("lng")).toDouble()); boundingBox.setTopRight(topRight); boundingBox.setBottomLeft(bottomLeft); } } QGeoLocation location; location.setAddress(address); location.setCoordinate(coordinate); location.setBoundingBox(boundingBox); locations << location; } setLocations(locations); setFinished(true); m_reply->deleteLater(); m_reply = 0; }
QgsGrassSelect::QgsGrassSelect( QWidget *parent, int type ) : QDialog( parent ) , QgsGrassSelectBase() , selectedType( 0 ) { QgsDebugMsg( QString( "QgsGrassSelect() type = %1" ).arg( type ) ); setupUi( this ); connect( GisdbaseBrowse, &QPushButton::clicked, this, &QgsGrassSelect::GisdbaseBrowse_clicked ); connect( egisdbase, &QLineEdit::textChanged, this, &QgsGrassSelect::egisdbase_textChanged ); connect( elocation, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsGrassSelect::elocation_activated ); connect( emapset, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsGrassSelect::emapset_activated ); connect( emap, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsGrassSelect::emap_activated ); connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsGrassSelect::accept ); connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject ); if ( sFirst ) { if ( QgsGrass::activeMode() ) { sLastGisdbase = QgsGrass::getDefaultGisdbase(); sLastLocation = QgsGrass::getDefaultLocation(); sLastMapset = QgsGrass::getDefaultMapset(); } else { QgsSettings settings; sLastGisdbase = settings.value( QStringLiteral( "GRASS/lastGisdbase" ) ).toString(); //check we got something from qsettings otherwise default to users home dir if ( sLastGisdbase.isEmpty() ) { QDir home = QDir::home(); sLastGisdbase = QString( home.path() ); } sLastMapset = settings.value( QStringLiteral( "GRASS/lastMapset" ) ).toString(); } sFirst = false; } QgsGrassSelect::type = type; switch ( type ) { case QgsGrassSelect::Vector: setWindowTitle( tr( "Select GRASS Vector Layer" ) ); break; case QgsGrassSelect::Raster: /* Remove layer combo box */ Layer->hide(); elayer->hide(); setWindowTitle( tr( "Select GRASS Raster Layer" ) ); break; case QgsGrassSelect::MapCalc: /* Remove layer combo box */ Layer->hide(); elayer->hide(); setWindowTitle( tr( "Select GRASS Mapcalc Schema" ) ); break; case QgsGrassSelect::MapSet: Layer->hide(); elayer->hide(); MapName->hide(); emap->hide(); setWindowTitle( tr( "Select GRASS Mapset" ) ); break; } egisdbase->setText( sLastGisdbase ); setLocations(); adjustSize(); }
void QGeoCodeReplyOsm::networkReplyFinished() { if (!m_reply) return; if (m_reply->error() != QNetworkReply::NoError) return; QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (document.isObject()) { QJsonObject object = document.object(); QGeoCoordinate coordinate; coordinate.setLatitude(object.value(QStringLiteral("lat")).toString().toDouble()); coordinate.setLongitude(object.value(QStringLiteral("lon")).toString().toDouble()); QJsonObject ao = object.value(QStringLiteral("address")).toObject(); QGeoAddress address; address.setText(object.value(QStringLiteral("display_name")).toString()); address.setCountry(ao.value(QStringLiteral("country")).toString()); address.setCountryCode(ao.value(QStringLiteral("country_code")).toString()); address.setState(ao.value(QStringLiteral("state")).toString()); address.setCity(ao.value(QStringLiteral("city")).toString()); address.setDistrict(ao.value(QStringLiteral("suburb")).toString()); address.setPostalCode(ao.value(QStringLiteral("postcode")).toString()); address.setStreet(ao.value(QStringLiteral("road")).toString()); QGeoLocation location; location.setCoordinate(coordinate); location.setAddress(address); QList<QGeoLocation> locations; locations.append(location); setLocations(locations); setFinished(true); } else if (document.isArray()) { QJsonArray results = document.array(); QList<QGeoLocation> locations; for (int i = 0; i < results.count(); ++i) { if (!results.at(i).isObject()) continue; QJsonObject object = results.at(i).toObject(); QGeoCoordinate coordinate; coordinate.setLatitude(object.value(QStringLiteral("lat")).toString().toDouble()); coordinate.setLongitude(object.value(QStringLiteral("lon")).toString().toDouble()); QGeoRectangle rectangle; if (object.contains(QStringLiteral("boundingbox"))) { QJsonArray a = object.value(QStringLiteral("boundingbox")).toArray(); if (a.count() == 4) { rectangle.setTopLeft(QGeoCoordinate(a.at(1).toString().toDouble(), a.at(2).toString().toDouble())); rectangle.setBottomRight(QGeoCoordinate(a.at(0).toString().toDouble(), a.at(3).toString().toDouble())); } } QJsonObject ao = object.value(QStringLiteral("address")).toObject(); QGeoAddress address; address.setText(object.value(QStringLiteral("display_name")).toString()); address.setCountry(ao.value(QStringLiteral("country")).toString()); address.setCountryCode(ao.value(QStringLiteral("country_code")).toString()); address.setState(ao.value(QStringLiteral("state")).toString()); address.setCity(ao.value(QStringLiteral("city")).toString()); address.setDistrict(ao.value(QStringLiteral("suburb")).toString()); address.setPostalCode(ao.value(QStringLiteral("postcode")).toString()); address.setStreet(ao.value(QStringLiteral("road")).toString()); QGeoLocation location; location.setCoordinate(coordinate); location.setBoundingBox(rectangle); location.setAddress(address); locations.append(location); } setLocations(locations); setFinished(true); } m_reply->deleteLater(); m_reply = 0; }