aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.cpp
AgeCommit message (Collapse)Author
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10mobile: fix crash on delete dive from divelistGravatar Jan Mulder
This is a somewhat hacky commit. For a very long time, the delete from the divelist on mobile crashed. That is, not always for anyone, but for me almost consistently. This commit tries to solve it. I found that trying to save the delete immediately after removing data from the underlying model seemed to cause the crash. Hacking around, I found that a simple beginResetModel/endResetModel between the delete of the underlying model data and actual save is sufficient to solve the crash. The big question is, why does this all work? I suspect some of race condition between deleting model data, and giving the QML engine the opportunity to do its thing. This is also related to issue #311, but that is not implemented here. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-07Fix small memory leakGravatar Jan Mulder
When deleting a dive from the divelist model, also free the pointed to DiveObjectHelper data. There seems no harm done (other than a memory leak) by this missing free. Found while (again) investigating the infamous crash occuring when deleting a dive from the mobile app when deleting a dive from the dive list. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-14mobile: stay on same dive after editGravatar Jan Mulder
See issue #875. In hindsight the reason for this bug is easy to understand. When updating a dive, the dive was first removed from the model, and added in its new state again. This does seems resonable, but the delete in the model causes the internal (QML) state to be changed, and the previous state (like the currentIndex that was pointing to the just deleted row, so that one is changed to something valid internally) is not restored at recreation of the edited dive. The QML engine has no way to understand that the remove and subsequent add are in fact one atomic operation. This can be solved by simply updating the underlying data in place, and notifying the change using a dataChanged emitted signal. The dataChanged signal takes care of the repaint of the screen, and there is no need for removeRow/insertRow pairs. Fixes: #875 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-28QML UI: add downloaded dives to dive listGravatar Dirk Hohndel
This already takes into account which of those dives were selected. Right now all we have is select all or none - this needs actual support in the UI, but once that's there, it will just work (famous last words). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to Qt modelsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05DiveListModel: don't add the dives one at a timeGravatar Dirk Hohndel
Most of the time we are adding all the dives, so do this in a single model operation. This makes the case when adding a single dive (in the undo delete function) slightly more complicated, but that seems totally worth it for the speedup in the common case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02QML UI: resolve confusion about dive list model orderingGravatar Dirk Hohndel
Oops, I forgot to take the sort model on top of the model into account. Now everything should stay consistent - ListView order when accessed from QML, but internal order when accessing the underlying array. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02QML UI: create a chronological dive list when manually adding diveGravatar Dirk Hohndel
The dive list might contain dives in the future, don't add the new dive to then end but instead add it at the correct spot in the list Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02Add helper functions to identify the position of a dive in the dive listGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-29QML UI: pick new highest dive number when manually adding diveGravatar Dirk Hohndel
It's possible that this will create an out of order dive list, but it seems the most consistent way to do things and to avoid more than one dive with the same dive number (which could have happened if you add several dives manually that are not the newest dives in the dive list). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-29Add helper to remove dive from modelGravatar Dirk Hohndel
I tried various things to do this from QML but it just doesn't seem to work at all. So I gave up and instead added a trivial helper function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-28Add our own sort proxy class which provides two helper functionsGravatar Dirk Hohndel
These can then be used from QML to map the index into the model (the sort model corresponds directly to the indices in QML) to the dive id and back. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-27Change the api to update a single diveGravatar Dirk Hohndel
Instead of searching for the dive in the list, just make sure we are given the index. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-27QML UI: correctly notify of model changeGravatar Dirk Hohndel
This may seem weird, but it seems to work to make sure that the model actually is correctly updated when updating a dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08Move Dive class from qthelper.h/cpp to it's own fileGravatar Tomaz Canabrava
and rename it to DiveObjectHelper, since it should be an QObject based class to make it easier on the QML, grantlee and widgets side to display the dive's internal data. each Q_PROPERTY defined in the DiveObjectHelper.h file can be acessed directly via it's name. So, if you are on a model that returns a dive, acess it's name by dive.name Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-01QML UI: handle editing of depthGravatar Dirk Hohndel
Getting closer to being able to really edit / add dives in the mobile UI. This works for manually added dives - needs a bit more thought for dives downloaded from dive computers as we don't necessarily want to change the maxdepth in conflict with the samples. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-26QML UI: get add dive closer to being usefulGravatar Dirk Hohndel
Now we at least start out with the corret date, time and number. This still isn't functional as a lot of the data aren't used and the way you save the data is completely silly, but it's another step in the right direction. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-26QML UI: set up time and dive number when adding diveGravatar Dirk Hohndel
Most likely when you manually add a dive on a device it is just about to happen or just ended, so starting out with the current time is likely a good guess. Which makes it the last dive in the dive list, so give it the next sequential number. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-26Dive list model: add GPS string accessGravatar Dirk Hohndel
If the QML UI needs the GPS information, we need a way to get to it. I'm not convinced that having it as comma separated string is the best way to go, but that's what I need for the Google API so that's what I picked for now. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-07QML-UI: we need a way to update the dive modelGravatar Dirk Hohndel
Otherwise our UI will get out of sync with our dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-03Fix crasherGravatar Sebastian Kügler
m_dives can be empty, so make sure we don't push an invalid QModelIndex into the mode. Signed-off-by: Sebastian Kügler <sebas@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-30Clear the Dive model before repopulating itGravatar Dirk Hohndel
Otherwise we could get duplicate dives in the dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-16Make Subsurface-mobile compile againGravatar Dirk Hohndel
This is a quick fix but it changes semantice. Previously weight() gave you the total weight carried, now it just gives you the first weight item on the list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31QML UI: Remove unneeded MobileDive classGravatar Grace Karanja
The MobileDive class in divelistmodel.h is a duplication of the Dive class in templatelayout.h. This patch moves the Dive to the qthelper file. [Dirk Hohndel: merged with upstream master - let's hope I didn't mess anything up] Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31QML UI: Use AddDive instead of clear diveGravatar Grace Karanja
No need to clear the dives when adding a new one. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
2015-08-31QML UI: Clear divelist model before starting new diveGravatar Grace Karanja
When user clicks on AddDive, we should clear the model. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
2015-07-24QML UI: sort by date, not by date stringGravatar Dirk Hohndel
Just a quick bit of cleanup to separate date (the sortable, numeric value) from the date string that we want to display (but not sort by). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-17QL UI: Add DiveId role to DiveListModelGravatar Grace Karanja
This will be used when rendering the dive profile and also when saving the dive changes. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
2015-07-10QML UI: whitespace fixGravatar Grace Karanja
Fix some whitespace issues in the QMLManager and DiveListModel classes. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
2015-06-20Rename dive class to avoid conflictGravatar Grace Karanja
Rename the Dive class in divelistmodel.h to a void a conflict with the Dive class in templatelayout.h Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Add more dive details to the DiveListModelGravatar Grace Karanja
Add some more details to the model. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Group dives by tripsGravatar Grace Karanja
Group dives according to the allocated dive trips. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Add dive notes to the divelistmodelGravatar Grace Karanja
Add the dive notes field into the DiveListModel class. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20Add DiveListModelGravatar Grace Karanja
This model will be used to show the dives in QML. This commit adds the model, and the means to link it to QML. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>