mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
mobile cleanup: restyle construction of locationlist
See also e6e1473e6
. The construction of the locationlist
was not the same as the 3 previous lists, and it needs
the inclusion of a new model file (divelocationmodel.cpp)
in the mobile app. In addition, as the mobile app is mainly
interested in a simple stringList (model) to populate a HintsText
field (or maybe later a combobox), this stringlist is added
to the model, to easy interfacing with QML.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
83259008e7
commit
494ad26540
8 changed files with 24 additions and 24 deletions
|
@ -410,21 +410,3 @@ QString DiveObjectHelper::firstGas() const
|
|||
gas = get_gas_string(m_dive->cylinder[0].gasmix);
|
||||
return gas;
|
||||
}
|
||||
|
||||
QStringList DiveObjectHelper::locationList() const
|
||||
{
|
||||
QStringList locations;
|
||||
struct dive *d;
|
||||
struct dive_site *ds;
|
||||
int i = 0;
|
||||
for_each_dive (i, d) {
|
||||
if ((ds = get_dive_site_by_uuid(d->dive_site_uuid)) != NULL) {
|
||||
QString temp = ds->name;
|
||||
if (!temp.isEmpty())
|
||||
locations << temp;
|
||||
}
|
||||
}
|
||||
locations.removeDuplicates();
|
||||
locations.sort();
|
||||
return locations;
|
||||
}
|
||||
|
|
|
@ -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 locationList READ locationList CONSTANT)
|
||||
public:
|
||||
DiveObjectHelper(struct dive *dive = NULL);
|
||||
~DiveObjectHelper();
|
||||
|
@ -90,7 +89,6 @@ public:
|
|||
QString startPressure() const;
|
||||
QString endPressure() const;
|
||||
QString firstGas() const;
|
||||
QStringList locationList() const;
|
||||
|
||||
private:
|
||||
struct dive *m_dive;
|
||||
|
|
|
@ -129,8 +129,7 @@ Item {
|
|||
}
|
||||
HintsTextEdit {
|
||||
id: txtLocation
|
||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||
diveDetailsListView.currentItem.modelData.dive.locationList : null
|
||||
model: manager.locationList
|
||||
inputMethodHints: Qt.ImhNoPredictiveText
|
||||
Layout.fillWidth: true
|
||||
onEditingFinished: {
|
||||
|
|
|
@ -276,6 +276,7 @@ void QMLManager::openLocalThenRemote(QString url)
|
|||
buddyModel.updateModel(); emit buddyListChanged();
|
||||
suitModel.updateModel(); emit suitListChanged();
|
||||
divemasterModel.updateModel(); emit divemasterListChanged();
|
||||
locationModel.update(); emit locationListChanged();
|
||||
}
|
||||
|
||||
void QMLManager::mergeLocalRepo()
|
||||
|
@ -1567,6 +1568,11 @@ QStringList QMLManager::divemasterList() const
|
|||
return divemasterModel.stringList();
|
||||
}
|
||||
|
||||
QStringList QMLManager::locationList() const
|
||||
{
|
||||
return locationModel.allSiteNames();
|
||||
}
|
||||
|
||||
QStringList QMLManager::cylinderInit() const
|
||||
{
|
||||
QStringList cylinders;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "core/downloadfromdcthread.h"
|
||||
#include "qt-models/divelistmodel.h"
|
||||
#include "qt-models/completionmodels.h"
|
||||
#include "qt-models/divelocationmodel.h"
|
||||
|
||||
class QMLManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -39,6 +40,7 @@ class QMLManager : public QObject {
|
|||
Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged)
|
||||
Q_PROPERTY(QStringList buddyList READ buddyList NOTIFY buddyListChanged)
|
||||
Q_PROPERTY(QStringList divemasterList READ divemasterList NOTIFY divemasterListChanged)
|
||||
Q_PROPERTY(QStringList locationList READ locationList NOTIFY locationListChanged)
|
||||
Q_PROPERTY(QStringList cylinderInit READ cylinderInit CONSTANT)
|
||||
Q_PROPERTY(bool showPin MEMBER m_showPin WRITE setShowPin NOTIFY showPinChanged)
|
||||
Q_PROPERTY(QString progressMessage MEMBER m_progressMessage WRITE setProgressMessage NOTIFY progressMessageChanged)
|
||||
|
@ -134,6 +136,7 @@ public:
|
|||
QStringList suitList() const;
|
||||
QStringList buddyList() const;
|
||||
QStringList divemasterList() const;
|
||||
QStringList locationList() const;
|
||||
QStringList cylinderInit() const;
|
||||
bool showPin() const;
|
||||
void setShowPin(bool enable);
|
||||
|
@ -200,6 +203,7 @@ private:
|
|||
BuddyCompletionModel buddyModel;
|
||||
SuitCompletionModel suitModel;
|
||||
DiveMasterCompletionModel divemasterModel;
|
||||
LocationInformationModel locationModel;
|
||||
QString m_cloudUserName;
|
||||
QString m_cloudPassword;
|
||||
QString m_cloudPin;
|
||||
|
@ -274,6 +278,7 @@ signals:
|
|||
void suitListChanged();
|
||||
void buddyListChanged();
|
||||
void divemasterListChanged();
|
||||
void locationListChanged();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@ set(SUBSURFACE_GENERIC_MODELS_LIB_SRCS
|
|||
diveplotdatamodel.cpp
|
||||
diveimportedmodel.cpp
|
||||
completionmodels.cpp
|
||||
divelocationmodel.cpp
|
||||
)
|
||||
|
||||
# models exclusively used in desktop builds
|
||||
|
@ -25,7 +26,6 @@ set(SUBSURFACE_DESKTOP_MODELS_LIB_SRCS
|
|||
divetripmodel.cpp
|
||||
diveplannermodel.cpp
|
||||
divecomputerextradatamodel.cpp
|
||||
divelocationmodel.cpp
|
||||
ssrfsortfilterproxymodel.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -128,9 +128,17 @@ void LocationInformationModel::update()
|
|||
beginResetModel();
|
||||
internalRowCount = dive_site_table.nr;
|
||||
qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
|
||||
locationNames.clear();
|
||||
for (int i = 0; i < internalRowCount; i++)
|
||||
locationNames << QString(dive_site_table.dive_sites[i]->name);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QStringList LocationInformationModel::allSiteNames() const
|
||||
{
|
||||
return(locationNames);
|
||||
}
|
||||
|
||||
bool LocationInformationModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || index.row() < 2)
|
||||
|
|
|
@ -17,6 +17,7 @@ bool filter_same_gps_cb (QAbstractItemModel *m, int sourceRow, const QModelIndex
|
|||
class LocationInformationModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LocationInformationModel(QObject *obj = 0);
|
||||
enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS};
|
||||
enum Roles { UUID_ROLE = Qt::UserRole + 1 };
|
||||
static LocationInformationModel *instance();
|
||||
|
@ -29,9 +30,10 @@ public:
|
|||
|
||||
public slots:
|
||||
void update();
|
||||
QStringList allSiteNames() const;
|
||||
private:
|
||||
LocationInformationModel(QObject *obj = 0);
|
||||
int internalRowCount;
|
||||
QStringList locationNames;
|
||||
QLineEdit *textField;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue