On 03/03/2017 08:17, Jérémie Guichard wrote:
Hello Willem,

Unfortunately I am not very advanced in QML, but like with any other technologies I like to learn, dig for issues and get things forward. Furthermore when I have interest in the final goal :)

First things first, I'd have to get the code so I can have a look at the current state, I guess there is a branch in Subsurface repo, is it: android-kirigami2 <https://github.com/Subsurface-divelog/subsurface/tree/android-kirigami2>? If not, just point me to the right one :) Then I guess you could tell me what you'd like me to have a look at. I'll be able then to tell you then if I'm up for the task :)

I'm currently abroad passing my dive instructor course, so I will sometimes be busy with it, but it generally gives me a bit of free time every day.

Best regards,

Jeremie

Hi Jérémie,

I started some work on downloading dives to Subsurface-mobile about 18-24 months ago. At that stage the major problem was that the USB back end was not available like today. Therefore the work stalled. Since then, Anton has finalised the USB back end and only a UI is required to do the downloads.

In Subsurface-desktop, the UI is based on Qt-widgets. However this approach is not viable in the mobile environment. Consequently, the mobile UI is based on QML / Kirigami. This means that UI components in the desktop code cannot be directly ported to mobile but need a rewrite. However, both the Qt-widgets as well as the QML have access to background code independent of the UI. This background code is in C++.

The file subsurface/mobile-widgets/qml/main.qml contains the main menu system for Subsurface-mobile. Line 144 contains the code:
            Kirigami.Action {
                text: qsTr("Manage dives")....etc
This is the menu item that appears when selecting "Manage dives" in Subsurface-mobile.
If you insert the following after line 149 in that file:
                Kirigami.Action {
                    text: qsTr("Get dives from dive computer")
                    onTriggered: {
                        stackView.push(downloadDivesWindow)
                    }
                }
then the mobile download screen is activated.

The file subsurface/mobile-widgets/qml/DownloadFromDiveComputer.qml contains the QML for downloads. Apart from the buttons, it comprises two comboboxes to select the vendor/make and model of the dive computer being downloaded from. E.g. vendor "Mares" and model "Matrix". The names in the combo-boxes are supplied by QStringLists in the background C++ code. A QStringListModel is then used to store the information in the QStringList. It is also used by the QML to display the correct dive computer vendor or model names. Similarly, there is a table of dives that have been downloaded to Subsurface-Mobile with headers "Date/Time, Duration, Depth". When download is complete, this table is populated with the correct information. Similar to the comboboxes, this table is actually a Qt QAbstractTable that is accessed using a QAbstractTableModel, which is also visible on the QML side. There is also a progress bar in this screen.

The main download code for the desktop version is located in subsurface/desktop-widgets/downloadfromdivecomputer.cpp. This file cannot be directly accessed by the mobile code because it contains Qt-widgets. However, within this file there is a large amount of background C++ code that is usable both from the desktop and from the mobile side. It is therefore necessary to remove all the background (UI-independent) code from downloadfromdivecomputer.cpp and to save it as a separate C++ file, the header file of which can be #included in downloadfromdivecomputer.cpp. I did a large proportion of that but I see my code has been removed.

Within downloadfromdivecomputer.cpp there is an object DownloadThread. Instantiation of that thread starts the USB back end that Anton completed. One does not need to deal with any low-level code to execute the download.

So the tasks are:
1) Separate the existing C++ code in downloadfromdivecomputer that is usable from the QML side into a separate file, callable from both the desktop as well as the mobile side.
Create C++ code that serves as a back end for QML, including:
2) Populate the two comboboxes with the approapriate vendor and model data. This means: create the appropriate QStrinList and QStringListModels. I did this before the switch to kirigami, but I see the code has been removed. 3) Create an appropriate QAbstartcTable and a corresponding QAbstractTableModel to feed the right dive download data to the table on the mobile screen and to allow later integration of the selected downloaded dives into the dive list.
4) Instantiate the DownloadThread.

I hope this makes some sense to you. I am as new as you are to kirigami. I am not experienced with QML. But creating a download interface for Subsurface-mobile is likely to have a huge effect on its usability and the degree to which divers make use of Subsurface-mobile. Therefore this work is definitely worth it.

Kind regards,
willem






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

Reply via email to