Re: [PATCH 1/3] Add init function to qmlmanager

2016-05-20 Thread Tomaz Canabrava
Joakim,

Acked,
But I do think this should be different controllers. But anyway, this looks
good and I'll probably change it on the future just to make qmlmanager a
managed, not a God class.

Tomaz
Em 20 de mai de 2016 13:50, "Joakim Bygdell"  escreveu:

In order to get autocomplete to work on manual dive add
we apparently need a separate init function.

Signed-off-by: Joakim Bygdell 
---
 mobile-widgets/qmlmanager.cpp | 51
+++
 mobile-widgets/qmlmanager.h   |  7 ++
 2 files changed, 58 insertions(+)

diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 82ea319..1c3e121 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1337,3 +1337,54 @@ void QMLManager::quit()
saveChangesCloud(false);
QApplication::quit();
 }
+
+QStringList QMLManager::suitInit() 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 QMLManager::buddyInit() 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.removeDuplicates();
+   buddies.sort();
+   return buddies;
+}
+
+QStringList QMLManager::divemasterInit() const
+{
+   QStringList divemasters;
+   struct dive *d;
+   int i = 0;
+   for_each_dive (i, d) {
+   QString temp = d->divemaster;
+   if (!temp.isEmpty())
+   divemasters << d->divemaster;
+   }
+   divemasters.removeDuplicates();
+   divemasters.sort();
+   return divemasters;
+}
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 906e7b0..10ff0ba 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -29,6 +29,9 @@ class QMLManager : public QObject {
Q_PROPERTY(bool syncToCloud READ syncToCloud WRITE setSyncToCloud
NOTIFY syncToCloudChanged)
Q_PROPERTY(int updateSelectedDive READ updateSelectedDive WRITE
setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
Q_PROPERTY(int selectedDiveTimestamp READ selectedDiveTimestamp
WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
+   Q_PROPERTY(QStringList suitInit READ suitInit CONSTANT)
+   Q_PROPERTY(QStringList buddyInit READ buddyInit CONSTANT)
+   Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)

 public:
QMLManager();
@@ -97,6 +100,10 @@ public:
typedef void (QMLManager::*execute_function_type)();
DiveListSortModel *dlSortModel;

+   QStringList suitInit() const;
+   QStringList buddyInit() const;
+   QStringList divemasterInit() const;
+
 public slots:
void applicationStateChanged(Qt::ApplicationState state);
void savePreferences();
--
2.5.4 (Apple Git-61)

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 3/3] White space cleanup

2016-05-20 Thread Joakim Bygdell
Signed-off-by: Joakim Bygdell 
---
 mobile-widgets/qml/DiveDetails.qml | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mobile-widgets/qml/DiveDetails.qml 
b/mobile-widgets/qml/DiveDetails.qml
index aee8a89..3dfb879 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -15,16 +15,16 @@ Kirigami.Page {
property alias date: detailsEdit.dateText
property alias airtemp: detailsEdit.airtempText
property alias watertemp: detailsEdit.watertempText
-property alias buddyIndex: detailsEdit.buddyIndex
+   property alias buddyIndex: detailsEdit.buddyIndex
property alias buddyModel: detailsEdit.buddyModel
-property alias divemasterIndex: detailsEdit.divemasterIndex
+   property alias divemasterIndex: detailsEdit.divemasterIndex
property alias divemasterModel: detailsEdit.divemasterModel
property alias depth: detailsEdit.depthText
property alias duration: detailsEdit.durationText
property alias location: detailsEdit.locationText
property alias gps: detailsEdit.gpsText
property alias notes: detailsEdit.notesText
-property alias suitIndex: detailsEdit.suitIndex
+   property alias suitIndex: detailsEdit.suitIndex
property alias suitModel: detailsEdit.suitModel
property alias weight: detailsEdit.weightText
property alias startpressure: detailsEdit.startpressureText
@@ -152,9 +152,9 @@ Kirigami.Page {
depth = diveDetailsListView.currentItem.modelData.dive.depth
airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp
watertemp = 
diveDetailsListView.currentItem.modelData.dive.waterTemp
-suitIndex = 
diveDetailsListView.currentItem.modelData.dive.suitList.indexOf(diveDetailsListView.currentItem.modelData.dive.suit)
-buddyIndex = 
diveDetailsListView.currentItem.modelData.dive.buddyList.indexOf(diveDetailsListView.currentItem.modelData.dive.buddy)
-divemasterIndex = 
diveDetailsListView.currentItem.modelData.dive.divemasterList.indexOf(diveDetailsListView.currentItem.modelData.dive.divemaster)
+   suitIndex = 
diveDetailsListView.currentItem.modelData.dive.suitList.indexOf(diveDetailsListView.currentItem.modelData.dive.suit)
+   buddyIndex = 
diveDetailsListView.currentItem.modelData.dive.buddyList.indexOf(diveDetailsListView.currentItem.modelData.dive.buddy)
+   divemasterIndex = 
diveDetailsListView.currentItem.modelData.dive.divemasterList.indexOf(diveDetailsListView.currentItem.modelData.dive.divemaster)
notes = diveDetailsListView.currentItem.modelData.dive.notes
if 
(diveDetailsListView.currentItem.modelData.dive.singleWeight) {
// we have only one weight, go ahead, have fun and edit 
it
-- 
2.5.4 (Apple Git-61)

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 1/3] Add init function to qmlmanager

2016-05-20 Thread Joakim Bygdell
In order to get autocomplete to work on manual dive add
we apparently need a separate init function.

Signed-off-by: Joakim Bygdell 
---
 mobile-widgets/qmlmanager.cpp | 51 +++
 mobile-widgets/qmlmanager.h   |  7 ++
 2 files changed, 58 insertions(+)

diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 82ea319..1c3e121 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1337,3 +1337,54 @@ void QMLManager::quit()
saveChangesCloud(false);
QApplication::quit();
 }
+
+QStringList QMLManager::suitInit() 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 QMLManager::buddyInit() 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.removeDuplicates();
+   buddies.sort();
+   return buddies;
+}
+
+QStringList QMLManager::divemasterInit() const
+{
+   QStringList divemasters;
+   struct dive *d;
+   int i = 0;
+   for_each_dive (i, d) {
+   QString temp = d->divemaster;
+   if (!temp.isEmpty())
+   divemasters << d->divemaster;
+   }
+   divemasters.removeDuplicates();
+   divemasters.sort();
+   return divemasters;
+}
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 906e7b0..10ff0ba 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -29,6 +29,9 @@ class QMLManager : public QObject {
Q_PROPERTY(bool syncToCloud READ syncToCloud WRITE setSyncToCloud 
NOTIFY syncToCloudChanged)
Q_PROPERTY(int updateSelectedDive READ updateSelectedDive WRITE 
setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
Q_PROPERTY(int selectedDiveTimestamp READ selectedDiveTimestamp WRITE 
setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
+   Q_PROPERTY(QStringList suitInit READ suitInit CONSTANT)
+   Q_PROPERTY(QStringList buddyInit READ buddyInit CONSTANT)
+   Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)
 
 public:
QMLManager();
@@ -97,6 +100,10 @@ public:
typedef void (QMLManager::*execute_function_type)();
DiveListSortModel *dlSortModel;
 
+   QStringList suitInit() const;
+   QStringList buddyInit() const;
+   QStringList divemasterInit() const;
+
 public slots:
void applicationStateChanged(Qt::ApplicationState state);
void savePreferences();
-- 
2.5.4 (Apple Git-61)

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 2/3] Make autocomplete work on add dive

2016-05-20 Thread Joakim Bygdell
This sets the list models for autocompleting suit, buddy and
divemaster.

Signed-off-by: Joakim Bygdell 
---
 mobile-widgets/qml/DiveDetails.qml | 3 +++
 mobile-widgets/qml/DiveDetailsEdit.qml | 3 +++
 mobile-widgets/qml/main.qml| 9 ++---
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/mobile-widgets/qml/DiveDetails.qml 
b/mobile-widgets/qml/DiveDetails.qml
index 167eb69..aee8a89 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -16,13 +16,16 @@ Kirigami.Page {
property alias airtemp: detailsEdit.airtempText
property alias watertemp: detailsEdit.watertempText
 property alias buddyIndex: detailsEdit.buddyIndex
+   property alias buddyModel: detailsEdit.buddyModel
 property alias divemasterIndex: detailsEdit.divemasterIndex
+   property alias divemasterModel: detailsEdit.divemasterModel
property alias depth: detailsEdit.depthText
property alias duration: detailsEdit.durationText
property alias location: detailsEdit.locationText
property alias gps: detailsEdit.gpsText
property alias notes: detailsEdit.notesText
 property alias suitIndex: detailsEdit.suitIndex
+   property alias suitModel: detailsEdit.suitModel
property alias weight: detailsEdit.weightText
property alias startpressure: detailsEdit.startpressureText
property alias endpressure: detailsEdit.endpressureText
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml 
b/mobile-widgets/qml/DiveDetailsEdit.qml
index 5b582d1..ad62997 100644
--- a/mobile-widgets/qml/DiveDetailsEdit.qml
+++ b/mobile-widgets/qml/DiveDetailsEdit.qml
@@ -26,6 +26,9 @@ Item {
property alias endpressureText: txtEndPressure.text
property alias gasmixText: txtGasMix.text
property alias gpsCheckbox: checkboxGPS.checked
+   property alias suitModel: suitBox.model
+   property alias divemasterModel: divemasterBox.model
+   property alias buddyModel: buddyBox.model
 
function saveData() {
// apply the changes to the dive_table
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml
index e025224..b4c6f36 100644
--- a/mobile-widgets/qml/main.qml
+++ b/mobile-widgets/qml/main.qml
@@ -71,14 +71,17 @@ Kirigami.ApplicationWindow {
detailsWindow.date = manager.getDate(detailsWindow.dive_id)
detailsWindow.airtemp = ""
detailsWindow.watertemp = ""
-   detailsWindow.buddy = ""
+   detailsWindow.buddyModel = manager.buddyInit
+   detailsWindow.buddyIndex = -1
detailsWindow.depth = ""
-   detailsWindow.divemaster = ""
+   detailsWindow.divemasterModel = manager.divemasterInit
+   detailsWindow.divemasterIndex = -1
detailsWindow.notes = ""
detailsWindow.location = ""
detailsWindow.gps = ""
detailsWindow.duration = ""
-   detailsWindow.suit = ""
+   detailsWindow.suitModel = manager.suitInit
+   detailsWindow.suitIndex = -1
detailsWindow.weight = ""
detailsWindow.gasmix = ""
detailsWindow.startpressure = ""
-- 
2.5.4 (Apple Git-61)

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: QML inconsistency Android <-> Desktop

2016-05-20 Thread Dirk Hohndel

> On May 20, 2016, at 9:44 AM, Joakim Bygdell  wrote:
> 
> 
>> On 16 May 2016, at 21:32, Dirk Hohndel  wrote:
>> 
>> On Mon, May 16, 2016 at 09:24:33PM +0200, Joakim Bygdell wrote:
 Can you send a follow up patch that addresses that?
>>> Sure.
>> 
>> Thanks
>> 
> Do you prefer a full patch series or just the new patches standalone?

Just the new patches is fine.

/D
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: QML inconsistency Android <-> Desktop

2016-05-20 Thread Joakim Bygdell

> On 16 May 2016, at 21:32, Dirk Hohndel  wrote:
> 
> On Mon, May 16, 2016 at 09:24:33PM +0200, Joakim Bygdell wrote:
>>> Can you send a follow up patch that addresses that?
>> Sure.
> 
> Thanks
> 
Do you prefer a full patch series or just the new patches standalone?

/Jocke

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface