- Use a beginResetModel()/endResetModel() pair instead of distinct
addRows / removeRows pairs.
- Reuse the update function in the constructor().
- Let "rows" be the number of rows, not the number of rows minus one.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The TankInfoModel and WeightInfoModel had biggerString() functions
to determine the correct column widths for the tank- and weight-type
columns. The users were removed around 2013. Remove these functions
and the corresponding member variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit adds an entry to the dive media context
menu which offers to write a subtitle file. This
creates an .ass file for the selected videos.
In an attempt to to clutter the screen too much, don't
show irrelevant entries (zero temperature or
NDL and show TTS only for dives with stops).
VLC is able to show these subtitles directly, they
can be integrated into the video file with ffmpeg.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The only external caller of add_single_dive() used it to append a
dive to the global dive list. Rename the function accordingly and
remove the index parameter.
The internal caller can use the local insert_dive() function, which
doesn't consider selection. That shouldn't be a problem, as the
caller is doing import.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When in dive site tab and some dive sites are selected, show only
dives at those sites. Simply read the selection and pass it to the
filter.
Start and stop filtering when switching to and from the tab,
respectively.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the edit-dive-site tab the filter is switched to a particular
mode where only dives at that site are shown.
If we want to reuse this for the dive-site tab the mode has to
be extended to allow for multiple dive sites. This is trivially
done by replacing a pointer by a vector of pointers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of sending a signal when counts change, catching them
in the filter widget and update the window title there,
directly update the window title in the model. This removes a
signal/slot pair.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of letting the user edit the fields before adding a dive,
simply add an empty dive. Thus, the ADD mode of the main tab can
be removed.
Constructing a new dive with default-depth and making sure that
the dive is displayed correctly is very subtle. This all needs
to be detangled in due course.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Merging dive sites is currently only possible if dive sites are at
the exact same position.
Introduce a field where the user can enter a distance up to which all
dive sites should be listed. These can then be merged.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The filter code is strange: it actually only checks the
dive->hidden_by_filter flag. Thus, before propagating the dive
changed signal, this flag has to be updated. Do this in the
DiveTripModel. Ultimately, this should be refactored.
Moreover, if the filter-flag changed notify the frontend
of a changed trip so that the trip is hidden / unhidden.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In tree-mode, the trip locations are displayed. Update the corresponding
entries if the trip changed, by hooking into the tripChanged() signal.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When pasting (or undoing paste) the cylinders or weights may change.
Send the appropriate signals and update the models accordingly.
Currently, this means copying from current dive to displayed dive,
but hopefully we can get rid of "displayed_dive" in the not so
distant future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is a bit more tricky. There are two modes: set dive site
and set newly created dive site. This is realized using an OO model
with derived classed. Quite convoluted - but it seems to work.
Moreover, editing a dive site is not simply setting a value,
but the list of dives in a dive site has to be kept up to date.
Finally, we have to inform the dive site list of the changed
number of dives. Therefore add a new signal diveSiteDivesChanged.
To send only one signal per dive site, hook into the undo() and
redo() functions and call the functions of the base class there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add an edit column that calls the new editDiveSite() function
of MainWindow. The calling code is in DiveSiteSortedModel.
Quite illogical, but that's how TableView works, for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In analogy to the trash-icons, cache a small rendered version of
the edit icon. This will be used in the dive-site table. Rename
the icon alias from "duplicate-edit-icon" to "edit-icon", as
it actually is not a duplicated. The other "edit" icon is an
"undo" icon!
Move the accessor functions to cleanertablemode.cpp. This is not
the ideal place, but since the functions are declared in
cleanertablemodel.h it's certainly better than the old place
(models.cpp)!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Simply copy the code of note editing. It's a bit more complex,
since we have to parse the Gps coordinates. For consitency,
rename the COORD field to LOCATION (the field in the dive_site
struct is called LOCATION).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These were never used and it's hard to imagine when one of these
would be used. Typically users are more interested in the coordinates
than just one component, no?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Simply copy the code of notes editing, but use the taxonomy_* functions
to read and set the value. Moreover, replace the three TAXONOMY_n field
ids by a single TAXONOMY id. We will probably never show one column per
taxonomy field, but rather a single column with a string derived from all
taxonomy fields.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Simply duplicate the code of dive site name editing. Split out
the common functionality that swaps a C and a Qt string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a way of deleting dive sites by clearing all fields.
This is not necessary anymore, as now the user can delete a
dive site in the dive site list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement an undo command that edits the name of a dive site.
Connect it to the dive site table, so that names can be edited
directly in the table.
Send signals on undo / redo so that the dive site table and
the dive site edit widget can be updated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a new undo-command for deleting dive sites. If there are dives
associated with that site, the dives will be removed. The frontend
is not yet updated in such a case, as that infrastructure is in a
different PR.
Connect the trashcan icon of the dive site table to the undo command.
Currently, this code is in the dive site model, which makes little
sense, but is how the TableView class works. We might want to change
that when cylinder and weight editing are made undoable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The LocationInformationModel used to sort its entries and was completely
rebuilt after every change. This makes it rather complex to support
incremental changes.
Instead, keep LocationInformationModel sorted by UUID so that indexes
are consistent with indices in the core dive site table.
Implement sorting by other columns than name and enable sorting in the
dive site view.
Finally, don't cache the list of dive site names for the mobile app,
since that would also need some rather convoluted methods of keeping
the list up to date. Calculate it on the fly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Introduce two DiveListNotifier signals which are sent by
the undo commands if dives are added to / removed from the
core.
The signal has the dive site and the index in the global
dive site table as payload. Thus, the model has only to
remove the appropriate rows.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a new signal to DiveListNotifier. Send signal if dives are
added or removed and therefore the dive count of a dive site
changes. The dive sites are collected and the signal is sent
at the end of the command.
Add code to update the table view.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a very simple tab-widget presenting the list of known dive sites.
The table is rendered using our custom "TableView".
The (mis)uses the "LocationInformationModel". It moves the items
to be displayed (delete, name, description, number of dives) to the
front and makes the others hidden.
Moreover, it was necessary to limit the geo-tag decoration role to
the name to avoid having the icon next to each column.
Make the trash-can icon active and the name and description editable.
This is modelled after the cylinders-table code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a dive site table to each dive site to keep track of dives
that have been added to a dive site. Add two functions to add
dives to / remove dives from dive sites.
Since dive sites now contain a dive table, the order of includes
had to be changed: "divesite.h" now includes "dive.h" and not
vice-versa. This caused some include churn.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
As opposed to dive trips, dive sites were always directly added
to the global table, even on import. Instead, parse the divesites
into a distinct table and merge them on import.
Currently, this does not do any merging of dive sites, i.e. dive
sites are considered as either equal or different. Nevertheless,
merging of data should be rather easy to implement and simply
follow the code of the dive merging.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To enable undo of dive site functions, it is crucial to work
with different dive site tables. Therefore add a dive site table
parameter to dive site functions. For now, always pass the global
dive site table. Thus, this commit shouldn't alter any functionality.
After this change, a simple search for dive_site_table reveals all
places where the global dive site table is accessed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
See https://www.kdab.com/goodbye-q_foreach/
This is reduced to the places where the container is const or can be made const
without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7)
and std::as_const (C++17) are not available in all supported setups.
Also do some minor cleanups along the way.
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
The LGTM checker complained about passing large objects. Instead of
passing pointers, keep the old semantics and pass a reference. This
is more idiomatic C++.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When updating the coordinates of a dive site, the MapLocationModel
is updated. The code created a (col, row) index with col = 0.
[The idea of course being col = x, row = y]. Alas, that's not
how Qt works - its models want (row, col) indices. The code
worked, because the only time when the dive site locations were
updated was in dive site edit mode, when only one site is visible,
i.e. there is only one row leading to the correct (0, 0) index.
Fix this so that we can also change dive site positions if more
than one site is displayed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a label for each line added for the depth and temperature
statistics buckets
Add line to statistics widget for each bucket to be displayed
Signed-off-by: Doug Junkins <junkins@foghead.com>
CMake will do the expansion internally itself. Not doing it here is not only
less code, it also makes sure one does not accidentially get a double expansion.
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
All the field in the Notes Panel of the main window are now supported.
This needs some testing especially for the Notes field that may contain
markup. It appears ok to me for single term searches. One would like
to think about the default search option for the Notes.
There is a vertical spacer in the Filter panel that I moved downwards
and whose function I am not quite sure of.
[Dirk Hohndel: small adjustments]
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This allows one to filter dives by divemode, e.g. by typing
"CCR" or "Open circuit" in the tags textbox of the filter tool.
Quite useful if one dives using more than one dive mode. For the
purpose of the filter tool only the dive mode attribute is added
to the list of tags for the specific dive being considered. The
tag list for the same dive (in the XML dive log) is not affected
in any way.
Provide for translation in alternative languages (Response to
bstoeger's suggestion).
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Since a dive has only one location all-of makes little sense. It
*can* make sense if the user enters two substrings (e.g. Tofo and Reef),
but generally it won't. Therefore change the default to any-of.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add an additional mode to the tags, people and location filters: any_of.
Replace the original invert-bool by an enum.
Move the common code into a distinct function.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The thumbnails were fetched in the background to achieve a
snappier UI. The problem with that is that on LaTeX etc.
export only placeholder thumbnails were shown.
Therefore, implement a synchronous mode. This only tries
to fetch cached thumbnails or calculate thumbnails for
images. Videos and remote files are not supported.
Fixes#1963
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add negate buttons to the Tags, People, Location and Equipment
filters. Currently, if nothing is entered the filter is ignored
whether negate is on or off. One might think about filtering all
dives without tags, etc. instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move initialization to a separate function and connect that to the
reset button.
Two points of note:
1) Reseting the text-fields causes signals. Thus, signals have to
be ignored during reset. Do this with a new flag.
2) To make reset of the from-date work, the from-date has to be
initialized to a distinct value. Setting a default-constructed
QDateTime leaves the widget unchanged.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Update the filter counts if dives were added removed by the
undo commands. The undo commands call into the filter model
at the right time so that hidden_by_filter is already set.
The filter model keeps track of the counts and emits a signal,
which is caught by the widget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>