mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: use QStringLiterals in core/gpslocation.cpp
Not that this would make any noticeable difference, but out of principle, let's use Qt's string-literal macro for string-literals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8f043138ba
commit
5808a57e48
1 changed files with 29 additions and 29 deletions
|
@ -28,7 +28,7 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) :
|
||||||
showMessageCB = showMsgCB;
|
showMessageCB = showMsgCB;
|
||||||
// create a QSettings object that's separate from the main application settings
|
// create a QSettings object that's separate from the main application settings
|
||||||
geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope,
|
geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope,
|
||||||
QString("org.subsurfacedivelog"), QString("subsurfacelocation"), this);
|
QStringLiteral("org.subsurfacedivelog"), QStringLiteral("subsurfacelocation"), this);
|
||||||
userAgent = getUserAgent();
|
userAgent = getUserAgent();
|
||||||
(void)getGpsSource();
|
(void)getGpsSource();
|
||||||
loadFromStorage();
|
loadFromStorage();
|
||||||
|
@ -58,7 +58,7 @@ void GpsLocation::setGpsTimeThreshold(int seconds)
|
||||||
{
|
{
|
||||||
if (m_GpsSource) {
|
if (m_GpsSource) {
|
||||||
m_GpsSource->setUpdateInterval(seconds * 1000);
|
m_GpsSource->setUpdateInterval(seconds * 1000);
|
||||||
status(QString("Set GPS service update interval to %1 s").arg(m_GpsSource->updateInterval() / 1000));
|
status(QStringLiteral("Set GPS service update interval to %1 s").arg(m_GpsSource->updateInterval() / 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ QGeoPositionInfoSource *GpsLocation::getGpsSource()
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
if (verbose)
|
if (verbose)
|
||||||
#endif
|
#endif
|
||||||
status(QString("Created position source %1").arg(m_GpsSource->sourceName()));
|
status(QStringLiteral("Created position source %1").arg(m_GpsSource->sourceName()));
|
||||||
connect(m_GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
connect(m_GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
||||||
connect(m_GpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
connect(m_GpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
||||||
connect(m_GpsSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(positionSourceError(QGeoPositionInfoSource::Error)));
|
connect(m_GpsSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(positionSourceError(QGeoPositionInfoSource::Error)));
|
||||||
|
@ -120,7 +120,7 @@ void GpsLocation::serviceEnable(bool toggle)
|
||||||
}
|
}
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
gpsSource->startUpdates();
|
gpsSource->startUpdates();
|
||||||
status(QString("Starting Subsurface GPS service with update interval %1").arg(gpsSource->updateInterval()));
|
status(QStringLiteral("Starting Subsurface GPS service with update interval %1").arg(gpsSource->updateInterval()));
|
||||||
} else {
|
} else {
|
||||||
gpsSource->stopUpdates();
|
gpsSource->stopUpdates();
|
||||||
status("Stopping Subsurface GPS service");
|
status("Stopping Subsurface GPS service");
|
||||||
|
@ -172,7 +172,7 @@ void GpsLocation::newPosition(QGeoPositionInfo pos)
|
||||||
int64_t delta = (int64_t)pos.timestamp().toTime_t() + gettimezoneoffset() - lastTime;
|
int64_t delta = (int64_t)pos.timestamp().toTime_t() + gettimezoneoffset() - lastTime;
|
||||||
if (!nr || waitingForPosition || delta > prefs.time_threshold ||
|
if (!nr || waitingForPosition || delta > prefs.time_threshold ||
|
||||||
lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) {
|
lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) {
|
||||||
QString msg("received new position %1 after delta %2 threshold %3 (now %4 last %5)");
|
QString msg = QStringLiteral("received new position %1 after delta %2 threshold %3 (now %4 last %5)");
|
||||||
status(qPrintable(msg.arg(pos.coordinate().toString()).arg(delta).arg(prefs.time_threshold).arg(pos.timestamp().toString()).arg(QDateTime().fromMSecsSinceEpoch(lastTime * 1000).toString())));
|
status(qPrintable(msg.arg(pos.coordinate().toString()).arg(delta).arg(prefs.time_threshold).arg(pos.timestamp().toString()).arg(QDateTime().fromMSecsSinceEpoch(lastTime * 1000).toString())));
|
||||||
waitingForPosition = false;
|
waitingForPosition = false;
|
||||||
acquiredPosition();
|
acquiredPosition();
|
||||||
|
@ -329,13 +329,13 @@ QMap<qint64, gpsTracker> GpsLocation::currentGPSInfo() const
|
||||||
|
|
||||||
void GpsLocation::loadFromStorage()
|
void GpsLocation::loadFromStorage()
|
||||||
{
|
{
|
||||||
int nr = geoSettings->value(QString("count")).toInt();
|
int nr = geoSettings->value(QStringLiteral("count")).toInt();
|
||||||
for (int i = 0; i < nr; i++) {
|
for (int i = 0; i < nr; i++) {
|
||||||
struct gpsTracker gt;
|
struct gpsTracker gt;
|
||||||
gt.when = geoSettings->value(QString("gpsFix%1_time").arg(i)).toLongLong();
|
gt.when = geoSettings->value(QStringLiteral("gpsFix%1_time").arg(i)).toLongLong();
|
||||||
gt.location.lat.udeg = geoSettings->value(QString("gpsFix%1_lat").arg(i)).toInt();
|
gt.location.lat.udeg = geoSettings->value(QStringLiteral("gpsFix%1_lat").arg(i)).toInt();
|
||||||
gt.location.lon.udeg = geoSettings->value(QString("gpsFix%1_lon").arg(i)).toInt();
|
gt.location.lon.udeg = geoSettings->value(QStringLiteral("gpsFix%1_lon").arg(i)).toInt();
|
||||||
gt.name = geoSettings->value(QString("gpsFix%1_name").arg(i)).toString();
|
gt.name = geoSettings->value(QStringLiteral("gpsFix%1_name").arg(i)).toString();
|
||||||
gt.idx = i;
|
gt.idx = i;
|
||||||
m_trackers.insert(gt.when, gt);
|
m_trackers.insert(gt.when, gt);
|
||||||
}
|
}
|
||||||
|
@ -348,10 +348,10 @@ void GpsLocation::replaceFixToStorage(gpsTracker >)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpsTracker replacedTracker = m_trackers.value(gt.when);
|
gpsTracker replacedTracker = m_trackers.value(gt.when);
|
||||||
geoSettings->setValue(QString("gpsFix%1_time").arg(replacedTracker.idx), gt.when);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_time").arg(replacedTracker.idx), gt.when);
|
||||||
geoSettings->setValue(QString("gpsFix%1_lat").arg(replacedTracker.idx), gt.location.lat.udeg);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_lat").arg(replacedTracker.idx), gt.location.lat.udeg);
|
||||||
geoSettings->setValue(QString("gpsFix%1_lon").arg(replacedTracker.idx), gt.location.lon.udeg);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_lon").arg(replacedTracker.idx), gt.location.lon.udeg);
|
||||||
geoSettings->setValue(QString("gpsFix%1_name").arg(replacedTracker.idx), gt.name);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_name").arg(replacedTracker.idx), gt.name);
|
||||||
replacedTracker.location = gt.location;
|
replacedTracker.location = gt.location;
|
||||||
replacedTracker.name = gt.name;
|
replacedTracker.name = gt.name;
|
||||||
}
|
}
|
||||||
|
@ -360,10 +360,10 @@ void GpsLocation::addFixToStorage(gpsTracker >)
|
||||||
{
|
{
|
||||||
int nr = m_trackers.count();
|
int nr = m_trackers.count();
|
||||||
geoSettings->setValue("count", nr + 1);
|
geoSettings->setValue("count", nr + 1);
|
||||||
geoSettings->setValue(QString("gpsFix%1_time").arg(nr), gt.when);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_time").arg(nr), gt.when);
|
||||||
geoSettings->setValue(QString("gpsFix%1_lat").arg(nr), gt.location.lat.udeg);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_lat").arg(nr), gt.location.lat.udeg);
|
||||||
geoSettings->setValue(QString("gpsFix%1_lon").arg(nr), gt.location.lon.udeg);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_lon").arg(nr), gt.location.lon.udeg);
|
||||||
geoSettings->setValue(QString("gpsFix%1_name").arg(nr), gt.name);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_name").arg(nr), gt.name);
|
||||||
gt.idx = nr;
|
gt.idx = nr;
|
||||||
geoSettings->sync();
|
geoSettings->sync();
|
||||||
m_trackers.insert(gt.when, gt);
|
m_trackers.insert(gt.when, gt);
|
||||||
|
@ -377,26 +377,26 @@ void GpsLocation::deleteFixFromStorage(gpsTracker >)
|
||||||
qDebug() << "no gps fix with timestamp" << when;
|
qDebug() << "no gps fix with timestamp" << when;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (geoSettings->value(QString("gpsFix%1_time").arg(gt.idx)).toLongLong() != when) {
|
if (geoSettings->value(QStringLiteral("gpsFix%1_time").arg(gt.idx)).toLongLong() != when) {
|
||||||
qDebug() << "uh oh - index for tracker has gotten out of sync...";
|
qDebug() << "uh oh - index for tracker has gotten out of sync...";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cnt > 1) {
|
if (cnt > 1) {
|
||||||
// now we move the last tracker into that spot (so our settings stay consecutive)
|
// now we move the last tracker into that spot (so our settings stay consecutive)
|
||||||
// and delete the last settings entry
|
// and delete the last settings entry
|
||||||
when = geoSettings->value(QString("gpsFix%1_time").arg(cnt - 1)).toLongLong();
|
when = geoSettings->value(QStringLiteral("gpsFix%1_time").arg(cnt - 1)).toLongLong();
|
||||||
struct gpsTracker movedTracker = m_trackers.value(when);
|
struct gpsTracker movedTracker = m_trackers.value(when);
|
||||||
movedTracker.idx = gt.idx;
|
movedTracker.idx = gt.idx;
|
||||||
m_trackers.remove(movedTracker.when);
|
m_trackers.remove(movedTracker.when);
|
||||||
m_trackers.insert(movedTracker.when, movedTracker);
|
m_trackers.insert(movedTracker.when, movedTracker);
|
||||||
geoSettings->setValue(QString("gpsFix%1_time").arg(movedTracker.idx), when);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_time").arg(movedTracker.idx), when);
|
||||||
geoSettings->setValue(QString("gpsFix%1_lat").arg(movedTracker.idx), movedTracker.location.lat.udeg);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_lat").arg(movedTracker.idx), movedTracker.location.lat.udeg);
|
||||||
geoSettings->setValue(QString("gpsFix%1_lon").arg(movedTracker.idx), movedTracker.location.lon.udeg);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_lon").arg(movedTracker.idx), movedTracker.location.lon.udeg);
|
||||||
geoSettings->setValue(QString("gpsFix%1_name").arg(movedTracker.idx), movedTracker.name);
|
geoSettings->setValue(QStringLiteral("gpsFix%1_name").arg(movedTracker.idx), movedTracker.name);
|
||||||
geoSettings->remove(QString("gpsFix%1_lat").arg(cnt - 1));
|
geoSettings->remove(QStringLiteral("gpsFix%1_lat").arg(cnt - 1));
|
||||||
geoSettings->remove(QString("gpsFix%1_lon").arg(cnt - 1));
|
geoSettings->remove(QStringLiteral("gpsFix%1_lon").arg(cnt - 1));
|
||||||
geoSettings->remove(QString("gpsFix%1_time").arg(cnt - 1));
|
geoSettings->remove(QStringLiteral("gpsFix%1_time").arg(cnt - 1));
|
||||||
geoSettings->remove(QString("gpsFix%1_name").arg(cnt - 1));
|
geoSettings->remove(QStringLiteral("gpsFix%1_name").arg(cnt - 1));
|
||||||
}
|
}
|
||||||
geoSettings->setValue("count", cnt - 1);
|
geoSettings->setValue("count", cnt - 1);
|
||||||
geoSettings->sync();
|
geoSettings->sync();
|
||||||
|
@ -426,5 +426,5 @@ void GpsLocation::clearGpsData()
|
||||||
|
|
||||||
void GpsLocation::postError(QNetworkReply::NetworkError)
|
void GpsLocation::postError(QNetworkReply::NetworkError)
|
||||||
{
|
{
|
||||||
status(QString("error when sending a GPS fix: %1").arg(reply->errorString()));
|
status(QStringLiteral("error when sending a GPS fix: %1").arg(reply->errorString()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue