mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: refresh divelist after GPS data was successfully applied
And create a helper to do so to make the code simpler. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
956b864319
commit
4f10f7f7ae
4 changed files with 19 additions and 9 deletions
|
@ -312,6 +312,17 @@ void QMLManager::loadDivesWithValidCredentials()
|
||||||
setLoadFromCloud(true);
|
setLoadFromCloud(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMLManager::refreshDiveList()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct dive *d;
|
||||||
|
DiveListModel::instance()->clear();
|
||||||
|
for_each_dive(i, d) {
|
||||||
|
DiveListModel::instance()->addDive(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// update the dive and return the notes field, stripped of the HTML junk
|
// update the dive and return the notes field, stripped of the HTML junk
|
||||||
QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
||||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
|
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
|
||||||
|
@ -455,11 +466,7 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
|
||||||
if (needResort)
|
if (needResort)
|
||||||
sort_table(&dive_table);
|
sort_table(&dive_table);
|
||||||
if (diveChanged || needResort) {
|
if (diveChanged || needResort) {
|
||||||
int i;
|
refreshDiveList();
|
||||||
DiveListModel::instance()->clear();
|
|
||||||
for_each_dive(i, d) {
|
|
||||||
DiveListModel::instance()->addDive(d);
|
|
||||||
}
|
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
}
|
}
|
||||||
return notes;
|
return notes;
|
||||||
|
@ -501,7 +508,8 @@ QString QMLManager::getCurrentPosition()
|
||||||
|
|
||||||
void QMLManager::applyGpsData()
|
void QMLManager::applyGpsData()
|
||||||
{
|
{
|
||||||
locationProvider->applyLocations();
|
if (locationProvider->applyLocations())
|
||||||
|
refreshDiveList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLManager::sendGpsData()
|
void QMLManager::sendGpsData()
|
||||||
|
|
|
@ -86,6 +86,7 @@ public slots:
|
||||||
QString getDate(QString diveId);
|
QString getDate(QString diveId);
|
||||||
QString getCurrentPosition();
|
QString getCurrentPosition();
|
||||||
void deleteGpsFix(quint64 when);
|
void deleteGpsFix(quint64 when);
|
||||||
|
void refreshDiveList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_cloudUserName;
|
QString m_cloudUserName;
|
||||||
|
|
|
@ -208,14 +208,14 @@ static void copy_gps_location(struct gpsTracker &gps, struct dive *d)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SAME_GROUP 6 * 3600 /* six hours */
|
#define SAME_GROUP 6 * 3600 /* six hours */
|
||||||
void GpsLocation::applyLocations()
|
bool GpsLocation::applyLocations()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
int last = 0;
|
int last = 0;
|
||||||
int cnt = m_trackers.count();
|
int cnt = m_trackers.count();
|
||||||
if (cnt == 0)
|
if (cnt == 0)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// create a table with the GPS information
|
// create a table with the GPS information
|
||||||
QList<struct gpsTracker> gpsTable = m_trackers.values();
|
QList<struct gpsTracker> gpsTable = m_trackers.values();
|
||||||
|
@ -317,6 +317,7 @@ void GpsLocation::applyLocations()
|
||||||
}
|
}
|
||||||
if (changed)
|
if (changed)
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<qint64, gpsTracker> GpsLocation::currentGPSInfo() const
|
QMap<qint64, gpsTracker> GpsLocation::currentGPSInfo() const
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
||||||
~GpsLocation();
|
~GpsLocation();
|
||||||
static GpsLocation *instance();
|
static GpsLocation *instance();
|
||||||
void applyLocations();
|
bool applyLocations();
|
||||||
int getGpsNum() const;
|
int getGpsNum() const;
|
||||||
QString getUserid(QString user, QString passwd);
|
QString getUserid(QString user, QString passwd);
|
||||||
bool hasLocationsSource();
|
bool hasLocationsSource();
|
||||||
|
|
Loading…
Add table
Reference in a new issue