mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Correct usage of QString on qmlmanager
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6575a0b4b8
commit
1773f5e447
2 changed files with 35 additions and 32 deletions
|
@ -46,9 +46,9 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
appendTextToLog(getUserAgent());
|
appendTextToLog(getUserAgent());
|
||||||
appendTextToLog(QString("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()));
|
appendTextToLog(QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()));
|
||||||
qDebug() << "Starting" << getUserAgent();
|
qDebug() << "Starting" << getUserAgent();
|
||||||
qDebug() << QString("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion());
|
qDebug() << QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion());
|
||||||
m_startPageText = tr("Searching for dive data");
|
m_startPageText = tr("Searching for dive data");
|
||||||
// create location manager service
|
// create location manager service
|
||||||
locationProvider = new GpsLocation(&appendTextToLogStandalone, this);
|
locationProvider = new GpsLocation(&appendTextToLogStandalone, this);
|
||||||
|
@ -75,7 +75,7 @@ void QMLManager::finishSetup()
|
||||||
int error = parse_file(fileNamePrt.data());
|
int error = parse_file(fileNamePrt.data());
|
||||||
prefs.git_local_only = false;
|
prefs.git_local_only = false;
|
||||||
if (error) {
|
if (error) {
|
||||||
appendTextToLog(QString("loading dives from cache failed %1").arg(error));
|
appendTextToLog(QStringLiteral("loading dives from cache failed %1").arg(error));
|
||||||
} else {
|
} else {
|
||||||
prefs.unit_system = informational_prefs.unit_system;
|
prefs.unit_system = informational_prefs.unit_system;
|
||||||
if (informational_prefs.unit_system == IMPERIAL)
|
if (informational_prefs.unit_system == IMPERIAL)
|
||||||
|
@ -88,12 +88,12 @@ void QMLManager::finishSetup()
|
||||||
for_each_dive (i, d) {
|
for_each_dive (i, d) {
|
||||||
DiveListModel::instance()->addDive(d);
|
DiveListModel::instance()->addDive(d);
|
||||||
}
|
}
|
||||||
appendTextToLog(QString("%1 dives loaded from cache").arg(i));
|
appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(i));
|
||||||
}
|
}
|
||||||
appendTextToLog("have cloud credentials, trying to connect");
|
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
|
||||||
tryRetrieveDataFromBackend();
|
tryRetrieveDataFromBackend();
|
||||||
} else {
|
} else {
|
||||||
appendTextToLog("no cloud credentials, tell user no dives found");
|
appendTextToLog(QStringLiteral("no cloud credentials, tell user no dives found"));
|
||||||
setStartPageText(tr("No recorded dives found. You can download your dives to this device from the Subsurface cloud storage service, from your dive computer, or add them manually."));
|
setStartPageText(tr("No recorded dives found. You can download your dives to this device from the Subsurface cloud storage service, from your dive computer, or add them manually."));
|
||||||
}
|
}
|
||||||
setDistanceThreshold(prefs.distance_threshold);
|
setDistanceThreshold(prefs.distance_threshold);
|
||||||
|
@ -225,7 +225,7 @@ void QMLManager::handleError(QNetworkReply::NetworkError nError)
|
||||||
void QMLManager::retrieveUserid()
|
void QMLManager::retrieveUserid()
|
||||||
{
|
{
|
||||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
|
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
|
||||||
appendTextToLog(QString("Cloud storage connection not working correctly: ") + reply->readAll());
|
appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: ") + reply->readAll());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString userid(prefs.userid);
|
QString userid(prefs.userid);
|
||||||
|
@ -234,7 +234,7 @@ void QMLManager::retrieveUserid()
|
||||||
appendTextToLog("cloud user name or password are empty, can't retrieve web user id");
|
appendTextToLog("cloud user name or password are empty, can't retrieve web user id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
appendTextToLog(QString("calling getUserid with user %1").arg(prefs.cloud_storage_email));
|
appendTextToLog(QStringLiteral("calling getUserid with user %1").arg(prefs.cloud_storage_email));
|
||||||
userid = locationProvider->getUserid(prefs.cloud_storage_email, prefs.cloud_storage_password);
|
userid = locationProvider->getUserid(prefs.cloud_storage_email, prefs.cloud_storage_password);
|
||||||
}
|
}
|
||||||
if (!userid.isEmpty()) {
|
if (!userid.isEmpty()) {
|
||||||
|
@ -262,7 +262,7 @@ void QMLManager::loadDiveProgress(int percent)
|
||||||
void QMLManager::loadDivesWithValidCredentials()
|
void QMLManager::loadDivesWithValidCredentials()
|
||||||
{
|
{
|
||||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
|
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
|
||||||
appendTextToLog(QString("Cloud storage connection not working correctly: ") + reply->readAll());
|
appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: ") + reply->readAll());
|
||||||
setStartPageText(tr("Cannot connect to cloud storage"));
|
setStartPageText(tr("Cannot connect to cloud storage"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ void QMLManager::loadDivesWithValidCredentials()
|
||||||
for_each_dive (i, d) {
|
for_each_dive (i, d) {
|
||||||
DiveListModel::instance()->addDive(d);
|
DiveListModel::instance()->addDive(d);
|
||||||
}
|
}
|
||||||
appendTextToLog(QString("%1 dives loaded").arg(i));
|
appendTextToLog(QStringLiteral("%1 dives loaded").arg(i));
|
||||||
if (dive_table.nr == 0)
|
if (dive_table.nr == 0)
|
||||||
setStartPageText(tr("Cloud storage open successfully. No dives in dive list."));
|
setStartPageText(tr("Cloud storage open successfully. No dives in dive list."));
|
||||||
setLoadFromCloud(true);
|
setLoadFromCloud(true);
|
||||||
|
@ -349,9 +349,9 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
|
||||||
// what a pain - Qt will not parse dates if the day of the week is incorrect
|
// what a pain - Qt will not parse dates if the day of the week is incorrect
|
||||||
// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
|
// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
|
||||||
// we need to make sure we don't try to parse that
|
// we need to make sure we don't try to parse that
|
||||||
QString format(QString(prefs.date_format) + " " + prefs.time_format);
|
QString format(QString(prefs.date_format) + QChar(' ') + prefs.time_format);
|
||||||
if (format.contains("ddd") || format.contains("dddd")) {
|
if (format.contains(QLatin1String("ddd")) || format.contains(QLatin1String("dddd"))) {
|
||||||
QString dateFormatToDrop = format.contains("ddd") ? "ddd" : "dddd";
|
QString dateFormatToDrop = format.contains(QLatin1String("ddd")) ? QStringLiteral("ddd") : QStringLiteral("dddd");
|
||||||
QDateTime ts;
|
QDateTime ts;
|
||||||
QLocale loc = getLocale();
|
QLocale loc = getLocale();
|
||||||
ts.setMSecsSinceEpoch(d->when * 1000L);
|
ts.setMSecsSinceEpoch(d->when * 1000L);
|
||||||
|
@ -397,11 +397,11 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
|
||||||
if (get_dive_duration_string(d->duration.seconds, tr("h:"), tr("min")) != duration) {
|
if (get_dive_duration_string(d->duration.seconds, tr("h:"), tr("min")) != duration) {
|
||||||
diveChanged = true;
|
diveChanged = true;
|
||||||
int h = 0, m = 0, s = 0;
|
int h = 0, m = 0, s = 0;
|
||||||
QRegExp r1(QString("(\\d*)%1[\\s,:]*(\\d*)%2[\\s,:]*(\\d*)%3").arg(tr("h")).arg(tr("min")).arg(tr("sec")), Qt::CaseInsensitive);
|
QRegExp r1(QStringLiteral("(\\d*)%1[\\s,:]*(\\d*)%2[\\s,:]*(\\d*)%3").arg(tr("h")).arg(tr("min")).arg(tr("sec")), Qt::CaseInsensitive);
|
||||||
QRegExp r2(QString("(\\d*)%1[\\s,:]*(\\d*)%2").arg(tr("h")).arg(tr("min")), Qt::CaseInsensitive);
|
QRegExp r2(QStringLiteral("(\\d*)%1[\\s,:]*(\\d*)%2").arg(tr("h")).arg(tr("min")), Qt::CaseInsensitive);
|
||||||
QRegExp r3(QString("(\\d*)%1").arg(tr("min")), Qt::CaseInsensitive);
|
QRegExp r3(QStringLiteral("(\\d*)%1").arg(tr("min")), Qt::CaseInsensitive);
|
||||||
QRegExp r4(QString("(\\d*):(\\d*):(\\d*)"));
|
QRegExp r4(QStringLiteral("(\\d*):(\\d*):(\\d*)"));
|
||||||
QRegExp r5(QString("(\\d*):(\\d*)"));
|
QRegExp r5(QStringLiteral("(\\d*):(\\d*)"));
|
||||||
if (r1.indexIn(duration) >= 0) {
|
if (r1.indexIn(duration) >= 0) {
|
||||||
h = r1.cap(1).toInt();
|
h = r1.cap(1).toInt();
|
||||||
m = r1.cap(2).toInt();
|
m = r1.cap(2).toInt();
|
||||||
|
@ -671,13 +671,13 @@ QString QMLManager::startPageText() const
|
||||||
return m_startPageText;
|
return m_startPageText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLManager::setStartPageText(QString text)
|
void QMLManager::setStartPageText(const QString& text)
|
||||||
{
|
{
|
||||||
m_startPageText = text;
|
m_startPageText = text;
|
||||||
emit startPageTextChanged();
|
emit startPageTextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLManager::showMap(QString location)
|
void QMLManager::showMap(const QString& location)
|
||||||
{
|
{
|
||||||
if (!location.isEmpty()) {
|
if (!location.isEmpty()) {
|
||||||
QString link = QString("https://www.google.com/maps/place/%1/@%2,5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0")
|
QString link = QString("https://www.google.com/maps/place/%1/@%2,5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0")
|
||||||
|
@ -687,7 +687,7 @@ void QMLManager::showMap(QString location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QMLManager::getNumber(QString diveId)
|
QString QMLManager::getNumber(const QString& diveId)
|
||||||
{
|
{
|
||||||
int dive_id = diveId.toInt();
|
int dive_id = diveId.toInt();
|
||||||
struct dive *d = get_dive_by_uniq_id(dive_id);
|
struct dive *d = get_dive_by_uniq_id(dive_id);
|
||||||
|
@ -697,7 +697,7 @@ QString QMLManager::getNumber(QString diveId)
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QMLManager::getDate(QString diveId)
|
QString QMLManager::getDate(const QString& diveId)
|
||||||
{
|
{
|
||||||
int dive_id = diveId.toInt();
|
int dive_id = diveId.toInt();
|
||||||
struct dive *d = get_dive_by_uniq_id(dive_id);
|
struct dive *d = get_dive_by_uniq_id(dive_id);
|
||||||
|
@ -707,7 +707,7 @@ QString QMLManager::getDate(QString diveId)
|
||||||
return datestring;
|
return datestring;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QMLManager::getCylinder(QString diveId)
|
QString QMLManager::getCylinder(const QString& diveId)
|
||||||
{
|
{
|
||||||
int dive_id = diveId.toInt();
|
int dive_id = diveId.toInt();
|
||||||
struct dive *d = get_dive_by_uniq_id(dive_id);
|
struct dive *d = get_dive_by_uniq_id(dive_id);
|
||||||
|
@ -723,7 +723,7 @@ QString QMLManager::getCylinder(QString diveId)
|
||||||
return cylinder;
|
return cylinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QMLManager::getWeights(QString diveId)
|
QString QMLManager::getWeights(const QString& diveId)
|
||||||
{
|
{
|
||||||
int dive_id = diveId.toInt();
|
int dive_id = diveId.toInt();
|
||||||
struct dive *d = get_dive_by_uniq_id(dive_id);
|
struct dive *d = get_dive_by_uniq_id(dive_id);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
void setLoadFromCloud(bool done);
|
void setLoadFromCloud(bool done);
|
||||||
|
|
||||||
QString startPageText() const;
|
QString startPageText() const;
|
||||||
void setStartPageText(QString text);
|
void setStartPageText(const QString& text);
|
||||||
|
|
||||||
QString logText() const;
|
QString logText() const;
|
||||||
void setLogText(const QString &logText);
|
void setLogText(const QString &logText);
|
||||||
|
@ -70,8 +70,11 @@ public slots:
|
||||||
void loadDivesWithValidCredentials();
|
void loadDivesWithValidCredentials();
|
||||||
void loadDiveProgress(int percent);
|
void loadDiveProgress(int percent);
|
||||||
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
||||||
QString commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
QString commitChanges(QString diveId,QString date, QString location,
|
||||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
|
QString gps, QString duration, QString depth,
|
||||||
|
QString airtemp, QString watertemp, QString suit,
|
||||||
|
QString buddy, QString diveMaster, QString notes);
|
||||||
|
|
||||||
void saveChanges();
|
void saveChanges();
|
||||||
QString addDive();
|
QString addDive();
|
||||||
void applyGpsData();
|
void applyGpsData();
|
||||||
|
@ -80,12 +83,12 @@ public slots:
|
||||||
void populateGpsData();
|
void populateGpsData();
|
||||||
void clearGpsData();
|
void clearGpsData();
|
||||||
void finishSetup();
|
void finishSetup();
|
||||||
void showMap(QString location);
|
void showMap(const QString& location);
|
||||||
QString getNumber(QString diveId);
|
QString getNumber(const QString& diveId);
|
||||||
QString getDate(QString diveId);
|
QString getDate(const QString& diveId);
|
||||||
QString getCurrentPosition();
|
QString getCurrentPosition();
|
||||||
QString getCylinder(QString diveId);
|
QString getCylinder(const QString& diveId);
|
||||||
QString getWeights(QString diveId);
|
QString getWeights(const QString& diveId);
|
||||||
void deleteGpsFix(quint64 when);
|
void deleteGpsFix(quint64 when);
|
||||||
void refreshDiveList();
|
void refreshDiveList();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue