From fed2c5b6a1c71649bcb310c0bd118cb1abcf9ea0 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Sun, 28 Jan 2018 09:52:51 +0100 Subject: mobile cleanup: unduplicate code and do not loop over dives (1) This is the first of a set of commits that are (very) similar. It appeared that a number of more or less static lists, which are constructed by a loop over all dives in the logbook, were executed when changing focus to a next dive. For example, the in this commit addressed list of used dive suits. What was wrong was that the suitList was linked to a dive. There is only a need to construct the list of used suits when data is changed (and obviously, once on startup of the app). Further, it appeared that a lot of code was duplicated and that we can use (in this case) the same code from the desktop completionmodels.cpp. Basically, this commit involves the following changes: - include completionmodels.cpp in mobile and desktop (so move it from the desktop only category to the generic category). - remove double code from DiveObjectHelper.cpp - Do not differentiate in the init phase and the normal refresh of the list - the per dive logic is now only the getting of a previously constructed list (in init or update of the divelist). There are no visible changes in the UI, other than a better performance when scrolling over dive details. Signed-off-by: Jan Mulder --- core/subsurface-qt/DiveObjectHelper.cpp | 15 --------------- core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 17 deletions(-) (limited to 'core') diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index bc7bd397c..4a7bc70f9 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -411,21 +411,6 @@ QString DiveObjectHelper::firstGas() const return gas; } -QStringList DiveObjectHelper::suitList() const -{ - QStringList suits; - struct dive *d; - int i = 0; - for_each_dive (i, d) { - QString temp = d->suit; - if (!temp.isEmpty()) - suits << d->suit; - } - suits.removeDuplicates(); - suits.sort(); - return suits; -} - QStringList DiveObjectHelper::locationList() const { QStringList locations; diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index 49542ca62..a8ecc638c 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -47,7 +47,6 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QString startPressure READ startPressure CONSTANT) Q_PROPERTY(QString endPressure READ endPressure CONSTANT) Q_PROPERTY(QString firstGas READ firstGas CONSTANT) - Q_PROPERTY(QStringList suitList READ suitList CONSTANT) Q_PROPERTY(QStringList buddyList READ buddyList CONSTANT) Q_PROPERTY(QStringList divemasterList READ divemasterList CONSTANT) Q_PROPERTY(QStringList locationList READ locationList CONSTANT) @@ -93,7 +92,6 @@ public: QString startPressure() const; QString endPressure() const; QString firstGas() const; - QStringList suitList() const; QStringList locationList() const; QStringList buddyList() const; QStringList divemasterList() const; -- cgit v1.2.3-70-g09d2