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>
The selection changes upon completing the filter are handled by
the core. Don't do this explicitly in the DiveListView.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Update schemes to only allow run.
Now it is possible to build/run/debug mobileExecutable as
well as desktop from within Xcode.
Xcode demands that the path to the debug executable it not relative,
this of course gives a portability problem.
The path selected are
~/develop/src/subsurface/build....
to at least give it a shine of not being fixed.
Signed-off-by: Jan Iversen <jani@apache.org>
Sadly, there's an explicit change in the sources to of QtConnectivity
that requires this workaround when running the build on a case sensitive
file system.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently, selecting a single dive or deselecting all dives was
quite awkward: One had to pass in a single-dive vector and the
dive itself (as current dive). Provide a convenience function
that selects a single dive or deselects all dives if null is
passed in.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This appears to prevent Bluetooth from working.
Fixes: #2370
Suggested-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also deal more gracefully with other potential bugs so that
we don't add an spurious '-' at the end if the branch is empty
for some reason (as that makes the image name invalid).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Really, this is just here to re-trigger that container build now
that things are merged and stage 2 will actually work...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Q_PROPERTY contains an internal ";", making clang produce a warning
when ending the line with a ;
Remove ; at the end of Q_PROPERTY lines.
Signed-off-by: Jan Iversen <jani@apache.org>
For some reason Documentation/mobile-images is linked to
Documentation/mobile-images/mobile-images ignored
Use of the ios compiler generates
packaging/ios/asset_catalog_compiler.Info.plist ignored
Signed-off-by: Jan Iversen <jani@apache.org>
We relied upon the translators to remove the parenthesis in cases
like "Edited notes (%n dives)" for n = 1 dives. Dirk doesn't want
that. Therefore, do it in the C++-code.
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>
Instead of freeing internal data of the weightsystem structure,
call the free_weightsystem function (which has to be made extern
at first). This makes things more future-proof, should the
weightsystem struct ever be extended.
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>
DiveFilter is not available in Mobile, so another solution
is needed.
Use "for_each_dive_site" to loop over dive sites instead.
Signed-off-by: Jan Iversen <jan@casacondor.com>
The QList served as backing store for backupExpandedRows()
and restoreExpandedRows(). However, these always came in
pairs in the same scope. There is no reason to store the
expanded rows over a longer time.
Therefore, return the expanded rows from backupExpandedRows()
and take them as argument in restoreExpandedRows(). Morover
replace the QList<int> by the much lighter std::vector<int>.
We certainly don't need copy-on-write, reference-counting and
immutability of iterators in this case.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Calls of these functions were removed in the previous commits.
Now, remove the functions themselves.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old code saved, cleared and restored the selection. This
is not necessary anymore, because on model reset the selection,
which is stored in the core, is reset. Remove the unnecessary
selection handling.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When accepting changes, the main tab refreshes the display in
a remember/restoreSelection() pair. Since the display refresh
doesn't lose selection, these calls can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old renumbering-dives code had to remember and restore the
selection. This became unnecessary with the undo-code. The
restore-call was removed, the remember-call left in. Remove it
as well.
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 DiveListView has a function to select the first dive. Move
this to the core to be able to call it from all parts (not only
desktop) of the code.
Currently, this has a (small?) UI regression: when filtering dives
and no selected dive is visible anymore, the old code would select
the first dive in the list. The new code selects the newest dive,
which might not be the first if some sort-criterion is active.
To revert to the old behavior, it will be necessary to move the
sorting function likewise to the core.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since we now have a selection.c translation unit, put the selection-
related functions there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The file command_private.cpp had functions concerning selections
only. To make these functions accessible from outside the undo
machinery, turn it into a part of the core-library. Currently,
only C++ functions are exported. We might think about also
exporting a C interface.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>