Thus, the MainWindow doesn't have to extract the plan from
displayed_dive. This is a tiny step in an attempt to detangle
the interfaces. The bigger goal will be to make displayed_dive
local to the planner.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When calculating variations, they were sent to the mainwindow,
which updated displayed_dive accordingly. Do this directly
in the planner-model.
The idea is to detangle interdependencies and to make the
code reusable (planner on mobile?).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This will be temporarilly used by the planner to mark consumption of
air at the surface. Do this by creating a new function add_cylinder,
which replaces add_to_cylinder_table() and takes care of always adding
a dummy cylinder at the end of the table. Make the original
add_to_cylinder_table() local, so that it cannot be accessed anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It appears that some misguided compiler / library combinations crash
on &vector[0] for empty vectors. Even though very unfriendly, they are
technically correct, so let's remove these constructs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I would have bet money that Android used to send stderr to the logcat
log, but apparently it doesn't (anymore?). So in order to be able to
have a chance to debug weird cloud storage issues on Android, let's do
some wholesale replacement of fprintf(stderr,...) with our own version
of the INFO macro that we long ago borrowed from libdivecomputer (and
rename it to ensure we don't have a conflict there).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In 9310d72943, resetting of the dive
sites was moved to DiveTripModelBase::reset(). This seemed like a
good idea, because it means that the location list is reloaded
every time the dive list is reset.
Unfortunately that function is only used on mobile, thus on desktop
the dive site model is not updated. Do that in
MultiFilterSortModel::resetModel(), because this is always called
when the dive list is reset. Desktop differs from mobile in that
two different models are used depending on whether we are in list
or in tree mode.
Fixes#2749
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When initializing the fulltext-cache and the dive-list, every
100 dives a notification was shown. I had a feeling that this
made startup significantly slower, but that could have been
purely psychological.
Therefore I measured and indeed, removing the fine-grained
notification, it becomes *significantly* faster. For a 3500
dives test log with mobile-on-desktop:
Initialization of the fulltext: 1350 ms -> 730 ms (-46%)
Initialization of the divelistmodel: 689 ms -> 113 ms (-83%)
Let's remove the fine-grained notification. There *is* a visual
indication of work-in-progress anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The planner does not know about events except gas
changes. But if the dive comes from the log, we
should preserve the dive computer events. At least
those that happend before we started to delete
waypoints to let the planner take over.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The DivePictureModel kept a pointer to picture for each entry.
Firstly, this is dangerous from a data-consistency point of view.
Secondly, the entry wasn't even used anywhere. Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of assigning to a QVariant ret and returning at the end,
return directly in the various switch-cases. This makes the code
more readable, and is more idiomatic C++, as it avoids unnecessary
copies.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Parts of the code were not compiled on mobile, because they used
the undo-command infrastructure. However, since mobile now also
compiles that, we might as well remove the conditional compilation.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When editing cylinders or weights directly in the table widgets,
no warning was shown if multiple dives were affected. To solve this,
emit signals from the respective models and catch them in dive
equipment tab. Not very nice, but it works for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Don't overwrite the full cylinder when editing a single field.
Implement three "modes": editing of type, pressure and gasmix.
Don't consider individual fields, because some of them are
related. E.g. you can change the gasmix by setting the MOD.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On desktop, we have two CylindersModel concurrently: One in the
planner and one on the equipment-tab. They act differently, because
the former modifies displayed_dive directly, the latter issues
undo commands.
To differentiate, we used the in_planner() function. However, that
appears extremely brittle, especially when combined with undo-commands.
Therefore when generating the model, pass in a parameter that says
whether this is for the planner or the equipment tab and use
that flag to decide how to act.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Call an undo command when editing cylinders, but only if on
the EquipmentTab.
To keep code changes small, make a copy of the cylinder first,
then edit the cylinder as before and then either call an undo
command (EquipmentTab) or overwrite the old cylinder (Planner).
The memory management here is a bit strange: Since the undo-command
itself makes a deep-copy of the passed in cylinder, we only do
a shallow copy. If we have to change the type, we allocate the
string with an std::string, so that the memory is automatically
freed at the end of the function. However, this means that in
the planner we have to make a deep copy first, swap old and
new cylinder and finally release the old cylinder. Certainly
not ideal, but for now the pragmatic thing to do.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is tricky, as when browsing through the types-combobox,
the user is presented with presets without actually changing the
dive. We do not want an undo-command for every change-event in
the combo-box.
Therefore, implement a scheme analoguous to the weight-editing:
A temporary row can be set / committed or reset. Sadly, the
code is more complex because we have to consider the planner,
which is not included in the undo system.
Firstly, the planner uses a different model, therefore all
interactions are channeled through setData() with special roles.
Secondly, in the planner we shouldn't place an undo command,
but simply overwrite the dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
add() and remove() are not used anymore since this is done using
undo commands. The planner uses CylindersModel instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The CHANGED macro was defined in the cleanerTableModel header.
Since it had only one user, expand it there. The macro was very
questionably anyway, as it would set the local "vString" variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A small code consolidation:
With one exception, all targets of the switch statement would
test for CHANGED(). Instead do the test once and exit early.
This changes the behavior of the function: if not changed, there
will be no more dataChanged-signal. However, this appears to be
the correct thing to do anyway. And it is easily changed if
it matters after all.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Cylinder-editing is controlled by undo (either by saving a planned
dive or by using the equipment tab). There is no point in setting
the dive_list_changed flag.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The cylinders in the events must be reordered if we remove
a cylinder. To avoid duplication of code, move the reordering
function into qthelper.cpp, though it might not be ideal
there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The CylinderModel always accessed the global "displayed_dive" and in
some special cases also "current_dive". To implement cylinder undo,
the model should work on an arbitrary dive. Therefore, in analogy
to the weight model, make the dive dynamic.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Turn the code in CylindersModel that creates a new cylinder for
addition into its own function to avoid code duplication. This
will be used from the undo commands.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To mark invalid dives, we use a struck-out font, which was a static
variable at translation unit scope, i.e. initialized at application
startup. Sadly, this crashes on iOS.
It is unclear when we can initialize fonts. Try to move initialization
to the constructore of DiveTripModelBase and make the font a member
of that class. For consistency, also make the invalidBrush a member
of this class.
This now means that the diveData function cannot be static anymore,
since it needs access to the font and brush. But OK.
Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Mark invalid dives in the dive list by striking them out
and rendering them with a grey color. The color-change is
not sufficient, because the default model delegate ignores
color hints if the item is selected.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When the dive list is cleared or updated, the entries in the
divesite-model become stale and therefore the divesite-model
(with the actual name LocationInformationModel) also must be
updated. This was done manually in some parts of the code and
forgotten in others. Therefore, do it directly in the clear()
and reset() function of the dive list-model.
This might be a bit of a layering violation: why should one
model call into another if they are not in parent/child
relationship? However, this seems easier than introducing
a global "reset dives" function that coordinates the models.
Moreover, it does not appear 100% safe: if the clearing of
the divesite model causes accesses to the divelist-model,
they happen in the midst of a model reset and we had horrible
bugs with that kind of things. However, I don't think that
should happen.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The setData() function was used to edit the number of a dive.
However, that doesn't appear to be functional. Therefore, remove
the code. There is a context-menu entry "renumber dives" for that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The diveListNotifier.divesSelected() signal is used to inform the
models of a selection change. It sent the current dive as a second
parameter. This is redundant, because the only sender of the signal
sets current_dive just before sending the signal. Remove the
parameter, which appears to be an artifact.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveTripModelTree::divesSelected() returned early if
no dives were selected. Thus, the current dive was not
updated. Remove the check for no dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Grammar-nazi ran
git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g'
to prevent future wincing when reading the source code.
Unfortunatly, Qt itself is infected as in
QModelIndexList QItemSelection::indexes() const
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This is only used in the mobile UI where the sort direction is fixed and we
refer to dives based on the tree model. So the terms used and the concepts
that these rely on should be guaranteed to be valid.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
MobileSwipeModel is probably not an ideal name, but all I could come up with.
One of the main complications here is that our list is reversed with respect to
the source model. We should change that one day. Probably by moving the
sorting down to the core-model.
Since looking up the source row is somewhat expensive, the lookup is cached for
a single entry because accesses come in bursts for a single dive. This should
be a good compromise and avoids keeping track of a full row-to-dive array.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In analogy to the DiveTripModel split, derive MobileListModel from a base
model that exports the roles, etc. This will allow us to create a second model,
which nevertheless possesses the same roles and all that without too much code
duplication.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since we want to add a second model, but not have to manage two models
everywhere, create a class MobileModels that contains both of the models. When
calling reset() on that class, it will reset both of the models, etc.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the undo-command for importing dives also on mobile. This should make the
whole disconnect-model shenigans unnecessary.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When the dive data is cleared, all pointers in the undo-stack become stale.
Desktop explicitly called Command::clear() in that case, but mobile doesn't.
Thus, move the clear() call into DiveTripModelBase::clear()
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The weight-undo commands need this. Therefore, we have to compile the
WSInfoModel if we want to access the undo commands from mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
To act as a drop-in replacement (at least as much as possible),
move the roles from the old DiveListModel to the common base
model of mobile and desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a model which represents all top-level items and, potentially, one
expanded trip as a flat list.
Pass down roles to the source model and let the source model handle that. We'll
have to do some ifdef-ery, but so be it.
Additionally, compile the base model on mobile as well.
This contains a couple of hacks to make things compile at all.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Once the the mobile app uses the new models, this will be necessary
to get the correct number of filtered dives after startup.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is an idle "optimization": The compiler may now not need
to access the vtable when calling virtual functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If compiled on mobile, on change of the current dive, don't send
a signal, but send changed-event with the CURRENT_ROLE for both
dives that changed status (previously selected and newly selected).
Mobile does not use this yet, but will do so with the new flattened
models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This role returns true if the given trip contains the current
dive. This will be needed by the mobile list model to decide
if a newly added trip should be expanded right away.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use this role to test whether a dive is the currently displayed dive.
This will be needed to transport changes of the current dive to
the mobile list models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The number of dives was updated when the model of the list was
changed. Since we removed the multi-threading, the model is
not disconnected/connected anymore and therefore we don't get
the appropriate signal. Instead of introducing a different
signal, make the shown-value a Q_PROPERTY. Thus, we can easily
send a changed signal if we have to.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a combo-box where the user can switch between "fulltext",
"people" and "tags" filtering. Connect the combobox to the
already existing filter-code.
Dirk: make combo-box smaller by using a smaller font and restricting
the width. Setting both maximum and preferred widths gives more
consistent results.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the DiveFilter class on mobile to update the filter. This
is mostly for convergence of the mobile and desktop models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Convert to QString instead of a QByteArray. Use qPrintable()
instead of data(). This might do one more UTF16->UTF8 conversion.
However, this is completely irrelevant, since we don't change
the type of a cylinder in a tight loop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The C-string cyl->type.description was set without the old data
being freed. Free the old string before overwriting the pointer.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The tank-info-delegate cast its model to CylindersModelFiltered,
since this is what the equipment-tab uses since implementing the
filtering of unused cylinders. However, the planner users the same
delegate and still uses the unfiltered CylindersModel. This means
that the (dynamic) cast returns a null pointer and crashes.
One possibility would be to derive CylindersModelFiltered and
CylindersModel from the same class that defines virtual functions
and cast to that class.
This is a different attempt: don't cast (i.e. stay with a
QAbstractItemModel and play it via Qt's model-view system. Firstly,
replace the passInData function by a role to setData(). Secondly,
read the working-pressure and size via new columns using data().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This header is a rebase artifact and introduces a pointless
column in the cylinder tables. It was erroneously introduced
in 6622f42aab.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Nobody was ever listening to this signal(?) and the last sender
was removed in ac52034778.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveFilter class defined the showDive() function to test
whether a dive should be filtered or not. This was used in
DiveTripModel to loop over all dives or all dives affected by
an editing action.
This restricts us in how we do filtering: We can't use indexes
that give us directly the result. To make the filtering more
flexible, move the actual loops that do the filtering to
the DiveFilter class.
The undo-commands likewise called directly the showDive()
function to check whether newly added dives are shown.
Use the new interface here as well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When changing the filter-criterion and the current dive is
hidden, a new dive is made current. However, when a dive is
hidden because it was edited, it is still shown.
Make this consistent by also selecing a new current dive
in the latter case. Do this by comparing the current_dive
before and after calculating the filter. Since this is now
done in multiple places move this code to the ShownChange
class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since we now filter at the model level, items are by definition
shown. No need for a flag.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This role was used by the filter-proxy model as filter criterion.
Since we don't use that model to filter anymore, we can remove
the role.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since we're doing the filtering at the core, don't filter
in the sort-model (which is now inappropriately named).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We use a QFilterProxyModel to filter out dives that are hidden
according to the current filter-criterion. Instead, filter the
dives already at the DiveTripModel level. Filter out hidden
dives immediately when receiving them. The only difficult case
is when dives are changed, because then visibility can change.
This means that we have three cases to consider:
1) Visibility unchanged -> send change signal
2) Change from hidden to unhidden -> add dives to model
3) Change from unhidden to hidden -> remove dives from model
Things get complicated by the fact that the tree-version of
the model might have to add/remove full trips!
Suggested-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the planner we used to filter out "unused" cylinders as in the
equipment tab. It is unclear whether that makes sense or can even
easily be reproduced, since such cylinders have to come from an
imported dive.
To be on the save side, let's not do this. Replace the
CylindersFilteredModel introduced recently by a plain
CylindersModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The cylinder-model had an instance() function, but actually
there were two cylinder models: one used by the equipment tab,
one used by the planner.
This is misleading. Therefore, remove the instance() function
and make the cylinder-model a subobject of the planner-model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When the show_unused_cylinders flag is not set, the cylinder tables
in the equipment tab and the planner should not show unused cylinders.
However, the code in CylindersModel is fundamentally broken if the
unused cylinders are not at the end of the list: The correct number
of cylinders is shown, but not the correct cylinders.
Therefore, add a higher-level CylindersModelFiltered model on top
of CylindersModel that does the actual filtering. Some calls are
routed through to the base model (notably those that take indexes,
as these have to be mapped), for some calls the caller has to get
access to the source model first. We might want to adjust this.
For filtering, reuse the already existing show_cylinder function
and export it via CylindersModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
No one will ask you about your dives in the last seven months (and the
existing code actually provided the past 210 days in that case). Instead
do more intuitive periods. Last month, quarter, half year, year.
Use Qt's ability to make sane date calculations easy.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add section headers to the dive summaries on mobile by adding
a section-property. Of course, this will not work on desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of passing the dive summary via a completely unstructured
QStringList to QML, implement a dynamic model. For potential reuse
on desktop (though somewhat unlikely) the model has two interfaces,
one for QtWidgets and one for QML. The former is based on columns,
whereas the later is based on roles. The number of columns is
set dynamically. The roles currently support access to two columns.
If more columns should be accessed from QML, more roles have to
be added manually.
This commit only creates the model and hooks it into QMLs global
context, but does not yet change the QML page.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When editing a dive site, the user can search for close dive sites
to merge duplicates. Dive sites without location are treated as
being located at 0N0E. This makes no sense, because:
When selecting a dive site without location, we shouldn't list
dive sites close to 0N0E.
Likewise when having a dive site close to 0N0E, we shouldn't list
dive sites that have no location.
Therefore, ignore these cases.
This also means that now dive sites without location are not
considered as close to other dive sites without location. That
might be a debatable point.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We tend to use lower-case filenames. Let's do it for these files
as well. Simple search & replace.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
It shouldn't happen, but currently we overwrite the displayed_dive
without updating the CylindersModel. Thus, CylindersModel may now
crash when the new displayed_dive has less cylinders than the old
one.
For now, catch this condition. Treat the root cause later.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In some case the scaling (real value <-> UI value) is different
for mobile and desktop. In order to make the difference understandable
comments are added to each function.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
setBottomSac, setDecoSac and setFactor in diveplannermodel
receives display value which are then converted.
subsurface-mobile have slightly different values, move the
correction of these from plannershared to diveplannermodel, in
order to keep the whole convert in one place.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change ascent/descent setter function names to set_<name>Display
to show the value is prepared for displaying (common for desktop and QML).
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
diveplannermodel already contains set_<asc/desc> function that convert from
screen value to real value; this adds get functions that convert real value to
screen value, so now all conversions are done in one place.
Use prefix Display to identify this is values prepared for the UI (both desktop
and QML).
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to make tests for plannerShared, some qt-models must
be linked, and due to the fact that commands are currently not
available for mobile (which also makes the tests) and #ifdef must
be added.
The test version of diveplannermodel will be specially compiled in
(SUBSURFACE_TESTING set) in the tests directory.
Signed-off-by: Jan Iversen <jan@casacondor.com>
add diveplannermodel to GENERIC instead of DESKTOP
as a consequence other models are need, move those
from DESKTOP to GENERIC
Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
commands (undo) are not available for mobile, but diveplannermodel
is needed
add #ifndef MOBILE around Commands::
Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use std::equal_to instead of lambdas that compare two dive pointers.
One could argue over which version is more readable. For whatever
it's worth, std::equal_to is more compact and expressive.
This removes an old erroneous comment that stated that std::equal_to
is only available since C++14.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
LOG_STP is on longer providing the data needed, since a lot of the startup
is indirectly in QML, furthermore using the xcode project and running profiler
gives much more detailed information
Signed-off-by: Jan Iversen <jani@apache.org>
On desktop, resetting the model is realized by generating a new
model object. This is due to the fact that we have two different
models (tree and list) and for switching between those, we have
to create a new object.
On mobile, currently there are no plans to support the list-mode.
Therefore, there is no reason the recreate the object. Instead,
implement a reset() function that reloads the core data.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveTripModelList forgot to collect the changed dives
when resetting the filter. Fix that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Updating the filter can lead to changes of the current dive.
Keep the UI in the know by re-initializing the selection.
This is not optimal, because the whole selection is reset,
but the pragmatic thing to do for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This part of the code had that horrible pattern, where reseting
the model would invalidate all pointers to the DiveTrip model.
Internalize these complexities in the MultiFilterSortModel.
All accesses are now performed via that proxy model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The UI talks to the filter model. Therefore route clearing of
data through that model instead of accessing the source model
directly.
This will allow us to remove the DiveTripModel::instance()
function and makes control flow less "jumpy".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old code called directly into the DiveListModel. Instead,
send a signal and hook into the signal from the model. This
will allow us to remove the DiveListModel::instance() function.
This, in turn, is a step towards supporting multiple models
at the same time. However, currently the model manually
sets the hidden_by_filter flag in the core and therefore
only one active model is supported at a time.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, the caller is responsible for not reusing a freed
weightsystem / cylinder or resetting the description field to
null. This is very unfriendly. Set the description field to null,
because that allows us to call free_* repeatedly on the same
object. Use the new behavior to make the weightsystem model code
a bit cleaner.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since changes to the weight model are not modal anymore, nobody
queries the changed-flag. Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement the EditWeight undo command. Since there is common code
(storage of the old weight), this creates a common base class for
RemoveWeight and EditWeight. The model calls directly into the undo
command, which is somewhat unfortunate as it feels like a layering
violation. It's the easy thing to do for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The WSInfoDelegate (weight-system-info delegate) is used to display
a combo box of known weightsystem-types and auto-fills the weight if
the weightsystem-type is changed.
This would overwrite the weight data of the displayed dive when the
user hovers over the different entries. Moreover, it saves the original
weight in case the user cancels the editing action.
This is not viable when implementing undo of weightsystem changes,
because hovering over entries should not produce individual undo
commands. Instead, implement a special "temporary" row in the
weightsystem model. On canceling of the edit actions, simply reload
the weightsystem from the unmodified dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make things more future-proof, introduce an empty_weightsystem
constant. Replace explicit aggragate initialization of empty
weightsystems by this constant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Before undoization, the WeightModel could be out-of-sync with
the actual dive and therefore had a row member variable. This
became redundant. Therefore, remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is only one caller of WeightModel::weightSystemAt() and that
certainly does not need a pointer into the weightsystem-table of
the current dive. Return a value type instead of a pointer.
This allows us to mark WeightModel::weightSystemAt() as const and
use it from WeightModel::data(). Slightly cleaner code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is a bit more complicated than weight adding, because the
multiple-dive case is not well defined. If multiple dives are selected,
this implementation will search for weights that are identical to the
weight deleted in the currently shown dive. The position of the weight
in the list is ignored.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When connecting a model to the TableModel class, it would connect
clicking on an item to the remove() slot of the model.
This breaks the program flow implied by the undo code:
Ui --> Undo-Command --> Model --> UI
Moreover, the naming of the remove() slot is illogical, because
clicks can also have different effects, as for example in the
cylinder-table.
Therefore, move the connect() call from TableModel to the
callers. In the case of TabDiveSite, move the remove() function
from the model to the TabWidget, where it makes more sense.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Introduce an AddWeight undo command. This is modelled after the
numerous dive-edit undo commands. The redo and undo actions are
connected to the WeightModel via two new signals, weightAdded
and weightRemoved.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The WeightModel always acted on the displayed dive. To support undo
of weightsystem changes, operate on an arbitrary dive. This is
in line with other models, where the updateDive() function resets
the model to represent a certain dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveListView caught signals from the DiveTripModel
with the corresponding indexes. However, the DiveListView
is actually connected to the MultiFilterSortModel and
thus has to translate the indexes.
Instead, catch the signals in the MultiFilterSortModel,
transform them and resend. Let the DiveListView get
its signal from the MultiFilterSortModel.
Yes, this makes things less efficient because there is
an extra signal. On the upside, the makes data-flow much
more logical. Selection will have to be fixed anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The goal here is to unify desktop and mobile by moving
selection code from the desktop-only view.
Currently, initialization of the selection still has to be
called from the view after connecting the appropriate signals.
This is due to the weird way in which create completely new
models when resetting them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive-trip models now send changed-events if the shown-status
changed. Thus, there is no reason to fully reset the filter on
filter changes.
Simply tell the filter that it has to react to changes of SHOWN_ROLE.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In analogy to the tree-model send signals when dives change
their shown status in the list-view. Do this in two passes
(collect changes; send changes) to be able to reuse the
already existing functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Send signals if the shown-status of top level items changed.
Do this in two passes to be able to use the previously created
function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To avoid having to do full filter reloads, send dive-changed signals
for dives in trips when the shown-status changed. But only for trips
where not all dives are hidden. Because for those, the plan is to
hide the trip as a whole.
Implement the signal sending in its own function so that it can be
reused for top-level items and the list-view.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implementing proper model semantics (only sending a changed
signal for items that actually changed) will be somewhat
complicated. Therefore, move the filtering of trip-items
to its own function to make the nesting a little bit less
deep.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Change the remove() function of the cylinder and weight models
to take the index by value. The code used to take it by reference
and the reference would be invalidated when removing rows from
the model!
Reported-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveListModelBase::clear() implementation was flawed: It cleared
the data in the core, but left the data in the model untouched.
The code was relying on the fact that the caller would reset the
model manually. Not a good idea.
Therefore, clear the internal data to keep the model consistent at
all times.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The way this was accessed via Qt's model semantics was horrible.
This gives arguably more readable code, since we don't have to
shoehorn things through QVariants.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Split out the actual filtering from the MultiFilterSortModel.
Create a DiveFilter class that does the actual filtering.
Currently, mobile and desktop have their own version of this
class, though ultimately we may want to merge them.
The idea here is that the trip-model and undo-commands have
direct access to the filter-function and thus can take care
of keeping track of the number of shown dives, etc.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The filter-model was catching dives-added / dives-deleted signals
from the models to keep track of the number of shown dives.
To simplify the data flow, do this directly in the undo-command.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We mark hidden/shown dives in the core but store the number
of shown dives in the MultiFilterSortModel. Move this datum
to the core for improved locality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Introduce a DiveTripModelBase::clear() function that cleanly
clears all dive data inside a beginResetModel()/endResetModel()
pair. Thus, the UI will be cleanly reset and we can remove
explicit calls to
- graphics->setEmptyState()
- mainTab->clearTabs()
- mainTab->clearTabs()
- diveList->reload()
from MainWindow::closeCurrentFile().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit did the "right" thing by implementing Qt mode semantics
as intended, but for unknown reasons the profile is not properly
cleared on close-file anymore. This code is so convoluted that there
is not point in fighting it at the moment. Revert to remove-rows
instead of reset-model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveTripModelTree::topLevelChanged() has pretty complex code, as
it has to handle the fact that when adding/removing a dive from
a trip, the trip can change its position.
The code did not account for the fact that when moving an object
back in the top level list, one has to subtract one from the new
index, because the object was removed somewhere in the front of
the list.
To make matters worse, when an entry stayed where it was, this
was realized by moving the entry right behind itself, which of
course means that it stays where it is. But this meant that in
the by far most common case (no moving) the wrong entry was
updated.
Fix this by subtracting 1 from the new index when moving an
entry to the back.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the future we might want to use undo-commands for mobile as
well (even if not implementing undo).
Therefore, move the undo-command source from desktop-widgets
to their own commands top-level folder.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To test whether an entry is a trip, we passed a pointer to the
trip through a QVariant and tested that for null-ity.
Passing pointers through QVariants has given us myriads of
problems in QML, therefore introduce a bool IS_TRIP_ROLE
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of accessing the cylinder table directly, use the get_cylinder()
function. This gives less unwieldy expressions. But more importantly,
the function does bound checking. This is crucial for now as the code
hasn't be properly audited since the change to arbitrarily sized
cylinder tables. Accesses of invalid cylinder indexes may lead to
silent data-corruption that is sometimes not even noticed by
valgrind. Returning NULL instead of an invalid pointer will make
debugging much easier.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of using fixed size arrays, use a new cylinder_table structure.
The code copies the weightsystem code, but is significantly more complex
because cylinders are such an integral part of the core.
Two functions to access the cylinders were added:
get_cylinder() and get_or_create_cylinder()
The former does a simple array access and supposes that the cylinder
exists. The latter is used by the parser(s) and if a cylinder with
the given id does not exist, cylinders up to that id are generated.
One point will make C programmers cringe: the cylinder structure is
passed by value. This is due to the way the table-macros work. A
refactoring of the table macros is planned. It has to be noted that
the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit
architecture, so passing on the stack is probably not even significantly
slower than passing as reference.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In qt-models/cylindermodel.cpp the various formatting functions
can take a pointer-to-const cylinder. Thus, the data() function
can likewise treat the cylinder as const - as it should.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some widgets copy the full plot info. Free these data on exit to
prevent monstrous valgrind reports.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All accesses to the pressure data were converted to use functions.
Therefore it is now rather trivial to dynamically allocate the
pressure array and just change the functions.
The only thing to take care of is the idiosyncratic memory
management. Make sure to free and copy the buffer in the
appropriate places.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The model was accessing the pressure data directly. Instead,
use the accessor functions so that the core structure can
be changed more easily.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When keeping track of cylinder related data, the code was using
static arrays of MAX_CYLINDERS length. If we want to use dynamically
sized cylinder arrays, these have to be dynamically allocated.
In C++ code, this is trivial: simply replace the C-style arrays
by std::vector<>. Don't use QVector, as no reference counting or
COW semantics are needed here. These are purely local and unshared
arrays.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
get_gas_used() returns the volume of used gases. Currently,
an array with MAX_CYLINDERS is passed in. If we want to make the
number of cylinders dynamic, the function must use an arbitrarilly
sized array.
Therefore, return a dynamically allocated array and free it
in the caller.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is even harder because setActiveTrip is called from an action slot from
QML. If the C++ code called from that slot causes the object to which this slot
belongs to be destroyed, we get very strange crashes. The only workaround I
could come up with was to update the filter asynchronously.
This all seems very ugly and fragile.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This shouldn't be necessary every time we replace the sort model,
but it can't hurt, either (famous last words?).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This one significantly reduces the number of dives that are handed to the
ListView in QML. For every trip that isn't expanded (only zero or one trips are
expanded at any time, so almost all the others are collapsed), send only first
dive to the View to allow creation of the section. Hide the rest so we don't
have all these invisible, zero height entries for the vertical dive list.
A big part of this commit is moving a few functions from the DiveListSortModel
to the CollapsedDiveListSortModel. Those are the ones that are needed for the
trip header.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When computing the best mix for a target depth, for helium, one
can either require that the partial pressure of N2 is the same
as at the target depth or the partial pressure of N2 plus O2.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The current code of course works just fine. But there's a risk someone might
add something to one of these cases and not realize that there is an implicit
fall through going on. This is cleaner.
Found by Coverity. Fixes CID 350079
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is extremely unlikely to ever happen since we reserve space for a
hundred weight models, but hey, doing this right is quite easy, so let's
fix it.
Found by Coverity. Fixes CID #350117
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of copying the displayed dive, generate an undo command.
This makes the replanning an undoable action and fixes a bug
where the dive details have not been updated correctly.
Fixes#2280
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a couple more roles and remove the dive role that allows accesss to
the DiveObjectHelper in the first place.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
By getting a DiveObjectHelper and then dereferencing that we ended up
creating hundres and hundreds of these objects, only to immediately
destroy them after using a tiny part of the data.
Instead make those data available directly from the model, without
having to create a DiveObjectHelper forst.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The planner has a computeVariations() function that can be run
in a worker thread. The code was not thread safe: a deco_state
object allocated on the stack of the caller was passed down to
the worker thread. It's well possible that the object would go
out of scope before the thread run.
Therefore, when running in the background, copy the object first
and free it in the worker thread.
Side note: Qt makes proper memory management again as difficult
as possible: You can't pass a std::unique_ptr<> to QtConcurrent::run,
because move-only objects are not supported. Not very friendly!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This guarantees that they are actually singletons: there can
only be one application-wide instantiation of these objects.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make this class available from QMLManager, the run_ui()
function would create the object and then set a pointer in
QMLManager. It works, but is inconsistent with the rest of
the code. Therefore, make it a classical singleton class,
which is generated on demand.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
GpsListModel was one of those "special" singletons that could
be created explicitly with new. This would make sense if a
parameter were passed to the constructor. We only passed null,
so one might as well turn that into a classical singleton with
default constructor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveListModel was one of those "special" singletons that could
be created explicitly with new. This would make sense if a
parameter were passed to the constructor. We only passed null,
so one might as well turn that into a classical singleton with
default constructor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The model was initialized in the global run_ui() function.
Move that into the constructor of the class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveImportedModel::recordDives() called add_imported_dives(). But that
actually consumes the dive and dive-site tables. Which in turn will
lead to an inconsistent model.
Properly reset the model by using the consumeTables() function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveImportedModel and DownloadThread used the same table
of dives and dive sites. This made it very hard to keep the
model consistent: Every modification of the download thread
would make the model inconsistent and could lead to memory
corruption owing to dangling pointers.
Therefore, keep a copy in the model. When updating the model,
use move-semantics, i.e. move the data and reset the tables
of the thread to zero elements.
Since the DiveImportedModel and the DownloadThread are very
tightly integrated, remove the accessor-functions of the
dive and dive-site tables. They fulfilled no purpose
whatsoever as they gave the same access-rights as a public
field.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The plan is to make the model the authoritative source of
the imported dives. Therefore, access the number of
downloaded dives from there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When importing dives, consume the tables from DiveImportedModel
and not the DownloadThread. This appears more logical and avoids
an inconsistent state of the DiveImportedModel: On import the
tables would be reset, but the DiveImportedModel wasn't
informed of that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In DiveImportedModel::deleteDeselected(), unselected dives were
deleted from the dive-table. But this left the model in an
inconsistent state and the frontend was not informed of the
missing dives.
Fix this by invoking the appropriate beginRemoveRows()/
endRemoveRows() pairs. Move the functionality into its
own function so that it can be reused by the desktop version.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, desktop and mobile are accessing the DownloadThread
and the DiveImportedModel concurrently. This makes a big data
flow mess. To achieve a more hierarchical data flow, start
by making the DownloadThread a subobject of DiveImportedModel.
Start the download by calling a function in DiveImportedModel.
Route the finished signal through DiveImportedModel. Thus,
the model can reload itself with the new data.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Owing to apparent QML breakage, a model-reset leads to the DiveDetail
page being reloaded for every dive in the list(!). Therefore, add
rows instead.
This leads to extremely subtle code, as it is now imperative that
the model has been properly cleared beforehand. Nevertheless, for
now we have to do this to fix a severe performance regression.
Fixes#2295
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Clearing the dive data directly in the core leaves us with an
inconsistent model. Therefore, clear via the model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of using the GpsLocation singleton in GpsListModel::update()
to extract the gpsTrackers, pass the gpsTrackers as function argument.
The caller has direct access to the GpsLocation object anyway and this
make things less entangled.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The way we handle singletons in QML, QML insists on allocating the
objects. This leads to a very idiosyncratic way of handling
singletons: The global instance pointer is set in the constructor.
Unify all these by implementing a "SillySingleton" template. All
of the weird singleton-classes can derive from this template and
don't have to bother with reimplementing the instance() function
with all the safety-checks, etc.
This serves firstly as documentation but also improves debugging
as we will now see wanted and unwanted creation and destruction
of these weird singletons.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of converting the section-heading string to a trip-pointer
in QML and pass that to the tripTitle() and tripShortDate()
functions, pass the string and convert in C++ code.
Hopefully, this makes the code more robust.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The section heading in the QtQuick ListView has to be a string.
Therefore, we passed a pointer formatted using hexadecimal notation.
Later, that was converted back without being checked.
A very scary proposition, so let's pass unique integer trip-id instead.
This means that on converting back we have to scan the trip table,
but that is a very minor cost comsidering to the gained robustness.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In MultiFilterSortModel::startFilterDiveSites(), the setting of the
dive sites to be filtered is done later in the code. Therefore,
remove the assignment in the first line of the function. Under
some circumstances, this would prevent a needed map reload!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of looping over all dives and search the dive with the given
id, let the source model determine the index and map that. Thus,
we do only one mapping and don't generate a ton of DiveObjectHelpers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Accesses were via DiveObjectHelpers. Provide a direct access to
struct dive *. Use this for the filter - there is no point in
mass generating DiveHelperObjects in the filter code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In DiveListModel::data() a DiveObjectHelper was created for any
data-access. Create it only when a DiveObjectHelper is actually
returned.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since DiveListModel does not keep its own list of dives anymore,
insertDive() doesn't use the DiveObjectHelper argument. Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The clear()/addAllDives() pair was bogus as the former didn't
clear the model (this is not possible anymore - the model
represents the core dive list) and the latter readded all
dives again.
Replace this by a reload() function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of keeping track of a list of DiveObjectHelpers, generate
them on-the-fly in DiveListModel. Thus, there is less danger of
model and core getting out of sync. On the flip-side, now the
DiveListModel and the DiveListSortModel might get out of sync.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveObjectHelper is a tiny wrapper around dive * to allow access
to dive data from QML and grantlee. It doesn't have to be a
full-fledged QObject with support for signals, etc. Therefore,
turn it into a Q_GADGET based object. This allows us passing the
object around as object, not as pointer to DiveObjectHelper.
This makes memory-management distinctly easier.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this data directly
from the model. In this case, don't remove from DiveObjectHelper,
as these data might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>