mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile cleanup: unduplicate code and do not loop over dives (2)
See e6e1473e6
. Exact same commit but here for the
list of buddies.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
fed2c5b6a1
commit
572fc47071
7 changed files with 9 additions and 50 deletions
|
@ -429,28 +429,6 @@ QStringList DiveObjectHelper::locationList() const
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DiveObjectHelper::buddyList() const
|
|
||||||
{
|
|
||||||
QStringList buddies;
|
|
||||||
struct dive *d;
|
|
||||||
int i = 0;
|
|
||||||
for_each_dive (i, d) {
|
|
||||||
QString temp = d->buddy;
|
|
||||||
if (!temp.isEmpty() && !temp.contains(",")){
|
|
||||||
buddies << d->buddy;
|
|
||||||
}
|
|
||||||
else if (!temp.isEmpty()){
|
|
||||||
QRegExp sep("(,\\s)");
|
|
||||||
QStringList tempList = temp.split(sep);
|
|
||||||
buddies << tempList;
|
|
||||||
buddies << tr("Multiple Buddies");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buddies.removeDuplicates();
|
|
||||||
buddies.sort();
|
|
||||||
return buddies;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList DiveObjectHelper::divemasterList() const
|
QStringList DiveObjectHelper::divemasterList() const
|
||||||
{
|
{
|
||||||
QStringList divemasters;
|
QStringList divemasters;
|
||||||
|
|
|
@ -47,7 +47,6 @@ class DiveObjectHelper : public QObject {
|
||||||
Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
|
Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
|
||||||
Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
|
Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
|
||||||
Q_PROPERTY(QString firstGas READ firstGas CONSTANT)
|
Q_PROPERTY(QString firstGas READ firstGas CONSTANT)
|
||||||
Q_PROPERTY(QStringList buddyList READ buddyList CONSTANT)
|
|
||||||
Q_PROPERTY(QStringList divemasterList READ divemasterList CONSTANT)
|
Q_PROPERTY(QStringList divemasterList READ divemasterList CONSTANT)
|
||||||
Q_PROPERTY(QStringList locationList READ locationList CONSTANT)
|
Q_PROPERTY(QStringList locationList READ locationList CONSTANT)
|
||||||
public:
|
public:
|
||||||
|
@ -93,7 +92,6 @@ public:
|
||||||
QString endPressure() const;
|
QString endPressure() const;
|
||||||
QString firstGas() const;
|
QString firstGas() const;
|
||||||
QStringList locationList() const;
|
QStringList locationList() const;
|
||||||
QStringList buddyList() const;
|
|
||||||
QStringList divemasterList() const;
|
QStringList divemasterList() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -18,7 +18,6 @@ Kirigami.Page {
|
||||||
property alias watertemp: detailsEdit.watertempText
|
property alias watertemp: detailsEdit.watertempText
|
||||||
property alias buddyIndex: detailsEdit.buddyIndex
|
property alias buddyIndex: detailsEdit.buddyIndex
|
||||||
property alias buddyText: detailsEdit.buddyText
|
property alias buddyText: detailsEdit.buddyText
|
||||||
property alias buddyModel: detailsEdit.buddyModel
|
|
||||||
property alias divemasterIndex: detailsEdit.divemasterIndex
|
property alias divemasterIndex: detailsEdit.divemasterIndex
|
||||||
property alias divemasterText: detailsEdit.divemasterText
|
property alias divemasterText: detailsEdit.divemasterText
|
||||||
property alias divemasterModel: detailsEdit.divemasterModel
|
property alias divemasterModel: detailsEdit.divemasterModel
|
||||||
|
@ -240,7 +239,7 @@ Kirigami.Page {
|
||||||
if (currentItem.modelData.dive.buddy.indexOf(",") > 0) {
|
if (currentItem.modelData.dive.buddy.indexOf(",") > 0) {
|
||||||
buddyText = currentItem.modelData.dive.buddy;
|
buddyText = currentItem.modelData.dive.buddy;
|
||||||
} else {
|
} else {
|
||||||
buddyIndex = currentItem.modelData.dive.buddyList.indexOf(currentItem.modelData.dive.buddy)
|
buddyIndex = manager.buddyList.indexOf(currentItem.modelData.dive.buddy)
|
||||||
}
|
}
|
||||||
divemasterIndex = currentItem.modelData.dive.divemasterList.indexOf(currentItem.modelData.dive.divemaster)
|
divemasterIndex = currentItem.modelData.dive.divemasterList.indexOf(currentItem.modelData.dive.divemaster)
|
||||||
notes = currentItem.modelData.dive.notes
|
notes = currentItem.modelData.dive.notes
|
||||||
|
|
|
@ -236,8 +236,7 @@ Item {
|
||||||
}
|
}
|
||||||
HintsTextEdit {
|
HintsTextEdit {
|
||||||
id: buddyBox
|
id: buddyBox
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: manager.buddyList
|
||||||
diveDetailsListView.currentItem.modelData.dive.buddyList : null
|
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ Kirigami.ApplicationWindow {
|
||||||
detailsWindow.date = manager.getDate(detailsWindow.dive_id)
|
detailsWindow.date = manager.getDate(detailsWindow.dive_id)
|
||||||
detailsWindow.airtemp = ""
|
detailsWindow.airtemp = ""
|
||||||
detailsWindow.watertemp = ""
|
detailsWindow.watertemp = ""
|
||||||
detailsWindow.buddyModel = manager.buddyInit
|
detailsWindow.buddyModel = manager.buddyList
|
||||||
detailsWindow.buddyIndex = -1
|
detailsWindow.buddyIndex = -1
|
||||||
detailsWindow.buddyText = ""
|
detailsWindow.buddyText = ""
|
||||||
detailsWindow.depth = ""
|
detailsWindow.depth = ""
|
||||||
|
|
|
@ -273,7 +273,7 @@ void QMLManager::openLocalThenRemote(QString url)
|
||||||
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
|
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
|
||||||
tryRetrieveDataFromBackend();
|
tryRetrieveDataFromBackend();
|
||||||
}
|
}
|
||||||
buddyModel.updateModel();
|
buddyModel.updateModel(); emit buddyListChanged();
|
||||||
suitModel.updateModel(); emit suitListChanged();
|
suitModel.updateModel(); emit suitListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1556,25 +1556,9 @@ QStringList QMLManager::suitList() const
|
||||||
return suitModel.stringList();
|
return suitModel.stringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QMLManager::buddyInit() const
|
QStringList QMLManager::buddyList() const
|
||||||
{
|
{
|
||||||
QStringList buddies;
|
return buddyModel.stringList();
|
||||||
struct dive *d;
|
|
||||||
int i = 0;
|
|
||||||
for_each_dive (i, d) {
|
|
||||||
QString temp = d->buddy;
|
|
||||||
if (!temp.isEmpty() && !temp.contains(",")){
|
|
||||||
buddies << d->buddy;
|
|
||||||
}
|
|
||||||
else if (!temp.isEmpty()){
|
|
||||||
QRegExp sep("(,\\s)");
|
|
||||||
QStringList tempList = temp.split(sep);
|
|
||||||
buddies << tempList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buddies.removeDuplicates();
|
|
||||||
buddies.sort();
|
|
||||||
return buddies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QMLManager::divemasterInit() const
|
QStringList QMLManager::divemasterInit() const
|
||||||
|
|
|
@ -37,7 +37,7 @@ class QMLManager : public QObject {
|
||||||
Q_PROPERTY(int updateSelectedDive MEMBER m_updateSelectedDive WRITE setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
|
Q_PROPERTY(int updateSelectedDive MEMBER m_updateSelectedDive WRITE setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
|
||||||
Q_PROPERTY(int selectedDiveTimestamp MEMBER m_selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
|
Q_PROPERTY(int selectedDiveTimestamp MEMBER m_selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
|
||||||
Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged)
|
Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged)
|
||||||
Q_PROPERTY(QStringList buddyInit READ buddyInit CONSTANT)
|
Q_PROPERTY(QStringList buddyList READ buddyList NOTIFY buddyListChanged)
|
||||||
Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)
|
Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)
|
||||||
Q_PROPERTY(QStringList cylinderInit READ cylinderInit CONSTANT)
|
Q_PROPERTY(QStringList cylinderInit READ cylinderInit CONSTANT)
|
||||||
Q_PROPERTY(bool showPin MEMBER m_showPin WRITE setShowPin NOTIFY showPinChanged)
|
Q_PROPERTY(bool showPin MEMBER m_showPin WRITE setShowPin NOTIFY showPinChanged)
|
||||||
|
@ -132,7 +132,7 @@ public:
|
||||||
DiveListSortModel *dlSortModel;
|
DiveListSortModel *dlSortModel;
|
||||||
|
|
||||||
QStringList suitList() const;
|
QStringList suitList() const;
|
||||||
QStringList buddyInit() const;
|
QStringList buddyList() const;
|
||||||
QStringList divemasterInit() const;
|
QStringList divemasterInit() const;
|
||||||
QStringList cylinderInit() const;
|
QStringList cylinderInit() const;
|
||||||
bool showPin() const;
|
bool showPin() const;
|
||||||
|
@ -271,6 +271,7 @@ signals:
|
||||||
void developerChanged();
|
void developerChanged();
|
||||||
void btEnabledChanged();
|
void btEnabledChanged();
|
||||||
void suitListChanged();
|
void suitListChanged();
|
||||||
|
void buddyListChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue