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>
In the dive site selection widget there are two special entries
(add dive site with given name). Don't show this if the user didn't
enter a string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive site selection widget implements a lessThan() function, but
that was never called. Apparently in a QListView one has to start
sorting by hand? Do just that.
In any case, the lessThan function was erroneous as it would happily
sort away the first two special entries. Fix it with a special case
for these to.
Finally use case insensitive string comparison.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To reset the filter-model, LocationInformationWidget would extract
the model from the diveSiteListView and then downcasts it. Instead,
it can access it directly, because the filter-model is a subobject
of LocationInformationWidget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveLocationLineEdit stored a pointer to itself in a global variable
so that the DiveLocationModel can access it to access the filter text.
Instead, on change simply pass the filter text down from DiveLocationLineEdit
to DiveLocationModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive-site line edit box features two special entries for adding
new dive sites. These should display different texts depending on
whether the current dive has a dive site or not.
The current check is wrong, because it used displayed_dive, but
since the last set of undo-changes, this might not be filled out
correctly anymore. Instead the code should check the actual current
dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This struct is used to store the completers during construction
of the object. But it is never accessed afterwards. Therefore,
remove it from the object and remove the structure definition
from the header file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Most tabs in the dive-information widget have there own translation
units and ui-files. Only the equipment tab was married with the
main tab. Move it out to get more reasonably sized translation units
and some isolation.
Currently, this needs ugly hacks when entering / checking for edit
mode: Access to MainTab is via the MainWindow. And vice/versa, when
accessing the DiveEquipmentTab from the MainTab, the former is
hardcoded as the first item of an array.
These hacks will soon be removed though, when making equipment
editing undoable. The tabs will then be independent.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The only caller of said function used to check whether MainTab is
in edit mode. For this case there is already a function - use that
instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When adding dives in an undo command, the index is saved in the
command. This seemed logical at first, because why calculate the
index more than once? But actually it made the code rather subtle
and brittle when multiple dives were added.
Moreover, this is a pointless optimization, as it doesn't optimize
the common case (only one execution).
Remove this for now and calculate the index on every execution. If
it ever turns out to be a bottle neck, it will be much more effective
to turn the linear search of the index into a binary search. A
further sensible optimization would be inserting in batches.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The tag-widget was only showing the completer if we were in edit mode.
The edit mode does not exist anymore - therefore remove the check.
Hopefully this has no unintended consequences, like the completer
not disappearing when it should.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Selecting "Selected dives" exports the dive sites for the selected
dives. Selecting "All dives" exports all dive sites.
XML format is the subsection of the divelog XML that describes the
sites headed with a <divesites> section like:
<divesites program='subsurface' version='3'>
</divesites>
Signed-off-by: Doug Junkins <junkins@foghead.com>
Apparently, in some Qt-versions the destructor of the base class
calls hide on child-objects (according to Qt's object hierarchy).
This is obviously called after the derived class has been destructed.
In a concrete case, the base class of the destructed MainWindow
would hide the TabDiveSite object. That would reset the filtering
if a dive site was selected, which would indirectly access the
MainWindow, which is already partially destroyed.
Therefore, destroy the MainTab before destroying the MainWindow.
Do this by keeping it as a std::unique_ptr subobject. Thus, it
will be destroyed before the MainWindow and remove itself from
Qt's object hierarchy.
Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This feels more natural than selecting a single cell. Still,
the "delete" cell is not visibly selected, which give a
strange impression.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The model was not reset on file close, leading to weird effects.
New dive sites would be added at the end of a table full of empty
entries.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive tabs are disabled, when no dive is shown. The dive site tab
is implemented as a dive tab, which is of course conceptually wrong.
Moreover it has the nasty side effect that when adding an empty dive
site, no dives are shown and the tab is disabled, leading to a
UI dead lock.
Therefore, disable all tabs but the dive site tab. The proper fix
will be a refactoring of the UI.
Reported-by: Doug Junkins <junkins@foghead.com>
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>
Editing the dive site of a dive may make a dive site appear
(first dive of that site) or disappear (the last dive of that
site was removed). Therefore, we have to reload the dive site
markers on editing the site of a dive.
This should be made smarter by only reloading the markers if
the dive site status actually changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The editing of a dive field is only performed when focus
is removed from the field. On pressing CTRL-s, the changes
in the currently active field were therefore not saved.
Remove the focus from all fields to trigger an edit command
yand thus ensure that all changes are saved.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Properly implement the unsaved-changes flag(s). Since we currently have
two kinds of changes, there are two flags:
1) dive_list_changed in divelist.c marks non-undoable changes. This flag
is only cleared on save or load.
2) QUndoStack::isClean() is used to determine the state of undoable
changes. Every time the user returns to the state where they saved,
this flag is cleared.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The whole edit logic moved from displayed_dive to current_dive
and it became more and more tedious to keep these in sync.
Therefore, simply always display current_dive. The only exceptions
are the equipment tab and the planner, as these are not yet
integrated in the undo system. Once this is done, displayed_dive
can be removed.
Moreover, remove the clear parameter from updateDiveInfo().
Instead simply clear of there is no current_dive set.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If a dive site was edited, the location field should be updated.
Do this by hooking into the diveSiteChanged signal of DiveListNotifier.
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>
If fields in a trip are edited, select that trip, which will display
the trip in the notes-box.
This is realized by hooking into the tripChanged signal in the dive-list.
A layering-violation, perhaps?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The code in maintab is not called anymore (unless cylinders
or weightsystems are changed). Move the code to the command
that edits water temperature.
This should be audited as it is unclear weather this is
necessary.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since all fields on the maintab are now directly edited,
there is no point in marking fields as changed. Remove
unused functions MainTab::markChangedWidget() and
MainTab::resetPalette().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is copying the dive editing code. It uses an OO design with
virtual functions for getting and setting the values. It doesn't
use templates though, as both fields of strig type. This feels
a bit over-engineered, but it is 1) consistent with the dive edit
code and 2) the number / types of dive trip fields might increase.
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>
Remove a few cases of
void fun() {
...
}
While touching these functions, fix a few other whitespace
coding style violations.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions are now performed by the edit commands and the
macros have no users. Remove them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Moving the tagged-string edit functions into the undo-system made
the MainTab::saveTaggedStrings() and MainTab::diffTaggedStrings()
functions unnecessary. Remove them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Save selected dives when generating an edit-command. Restore the
selection and current dive in undo()/redo().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Undo of editing should probably also restore the old selection and
current dive. Therefore, move the functions that set and restore the
selection and the current dive from the command_divelist.cpp into the
command_private.cpp translation unit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The edit-commands were called with a list of selected dives and
the original value. Move the creation of the list and extraction
of the original value into the edit-commmands.
This removes the "current is last" rule and allows for more
flexibility.
Since the depth- and duration editing applies only to the current
dive and not all selected dives, add a parameter to the edit-commands
controlling whether only the current or all selected dives are edited.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive list was not updated automatically when an edit command was
executed. There was already a signal to do that, viz. divesChanged().
But that signal worked by-trip and didn't have a dive-field specifier.
The edit-commands used the divesEdited() signal that isn't by-trip
but has a dive-field specifier.
Unify these two signals to be by-trip and with dive-field specifier.
This needs common code to generate the by-trip list that is moved to
a command_private.h header.
Since there might now be multiple signals (one per trip) actually
check in the main-tab whether the current trip is affected to
avoid multiple update of fields. This has the positive(?) effect
of not doing any update if the current dive isn't changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The acceptingEdit field was used to ignore edit-signals in
MainTab::acceptEdit(). But an equivalent mechanism already
exists: setting editMode to IGNORE. For consistency, replace
the former by the latter. acceptEdit() resets the editMode
in all cases anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was a bit different from the other editing commands:
1) Only the current dive is edited not all selected dives.
Therefore, create a function that turns the current dive
into a one-element list.
2) The profile has to be replot. Here, likewise, create a
function to do that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The code follows the other edit-commands, but uses its own base
class, because it is distinctly different. Editing the tag field
does not simply mean setting the tag for all dives, but rather
adding and removing individual tags.
This class will be reused for editing of dive buddies and masters.
Modify the tag widget thus that it sends an editingFinished()
signal when it goes out of focus. The editingFinished() signal
was prevented by hooking into the return, enter and tab key-events.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Now that we have dive-changed signal, send it on merging
dive sites so that the notes tab can be updated accordingly.
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>
This is different from the other editing commands, because
date and time editing may change the order of the dive list.
Therefore, this uses an already implemented dive list command.
The command is extended to send a divesEdited() signal.
This signal and the divesChanged() signal, which is used by
the dive list, will be unified in a later commit.
Update of the graphics is now not done via signals, a direct
call is performed in MainTab::divesEdited(). This simplifies
things.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>