Commit graph

1288 commits

Author SHA1 Message Date
Berthold Stoeger
cabe70be80 Desktop: reload map after refreshing the list
In MainWindow::refreshDisplay() with doRecreateDiveList=true
the map was reset before the dive list was recreated. This
makes no sense and only worked because the map was reloaded
again when a dive in the list was selected.

Reload the map after recreating the dive list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
bce31ab862 Map: generate pixmap name in model
Experimentation has shown that the image of a flag will
only be changed after dataChanged() if it is a simple
property. The old code had a complex QML expression and
then - for some reason - it didn't work.

To give us better control over the flags and avoid full
reloads of the map therefore introduce a model-property
pixmap name. The name depends on whether the site is
selected and if not, whether we are in divesite-edit mode.
This makes the code rather convoluted. Firstly, we have
to save whether the site is selected in the map-item.
Secondly we have to access the global map-widget, which
in turn has to go to the map-widget helper (layering
violation!).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
009f47c5dc Desktop: improve recognition of HTML-notes
To recognize HTML-notes the text was scanned for <div> tags. But
apparently the planner notes do not feature such a thing. Therefore
extend recognition of HTML to <table> tags.

Note we can't use the <html> or <span> tags, because these are
*always* produced by the QTextEdit::toHtml() function.

Fixes #2265

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-30 09:31:50 -07:00
Paul Buxton
3c4fd5d599 Fix broken windows build with latest MXE
Replaces some enums with names that do not clash with windows #defines.
Specifically:
ERROR -> ERRORED, PASCAL->PASCALS, IGNORE->IGNORED,FLOAT->FLOATVAL

Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
2019-08-29 12:55:25 -07:00
Berthold Stoeger
97380d6a36 Desktop: fix crash on copy & paste
The constructor of PasteState was clearing an uninitialized
weightsystem-table. Very silly. Initialize it instead.

Fixes #2253

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-24 14:00:06 -07:00
Berthold Stoeger
f25fa2adc5 Cleanup: turn CylinderObjectHelper into value type
CylinderObjectHelper is used for structured formatting of cylinder
values in grantlee types. Instead of keeping a reference to a
cylinder, turn it into a value type containing the formatted strings.

This should be distinctly safer, as we don't risk having stale
references flying around. Moreover, we don't have to use pointers
but can use containers containing plain CylinderObjectHelper. Thus,
no explicit memory management is needed, making the code distinctly
easier to understand.

Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY.
Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be
removed in due course, as a patch to remedy this issue is in current
grantlee master.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22 10:13:40 -07:00
Dirk Hohndel
5ffca686c2 Desktop: show local git repos in recent files
But don't show our cloud storage entry (as that is already in the File menu,
anyway).

This is extremely useful because while you can manually enter a file name to
save to (and therefore can use the 'magic' git repo syntax), on most OSs there
is no way to enter that non-existing 'file name' (which is the git branch in
square brackets) in the file open dialog.

Fixes: #2236

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-18 23:37:17 +03:00
Berthold Stoeger
594d1d3514 Cleanup: move file-related function declarations to file.h
A number of architecture-dependent functions were declared in
dive.h. Move them to file.h so that not all file-manipulating
translation units have to include dive.h. This is a small step
in avoiding mass-recompilation on every change to dive.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:31 -07:00
Berthold Stoeger
5da09a21bb Cleanup: move error reporting function declarations to errorhelper.h
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 16:26:30 -07:00
willemferguson
78f425de68 Move the Suit text box from the Notes tab to the Equipment tab
Sqash latest commit with previous one.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-08-08 09:12:09 -07:00
Berthold Stoeger
344c85f499 Desktop: display trip time on main-tab
On the main tab, the trip time was not shown when switching to
a trip. Implement showing of the trip date in a function, as the
undo-code will also have to update the trip date in certain
circumstances.

Fixes #2207

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-08 09:03:33 -07:00
Dirk Hohndel
29f5d15a66 Desktop: correct tooltip for filter close button
This button only closes the filter panel but doesn't clear it.

Reported-by: Adric Norris <landstander668@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-29 07:24:05 +02:00
Berthold Stoeger
999a63a5bb Desktop: fix index in weightsystems_equal()
The weightsystem_equal() function compares weightsystems of two dives
to decide whether the "commit changes" message should be shown and
to decide which dives are edited when changing multiple dives.

Due to an index mixup the function returned wrong results for
more than two weightsystems. Fix it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-27 11:51:34 -07:00
Berthold Stoeger
726d08c2f7 Undo: make editing of dive number undoable
When pressing F2 in the dive list, the number can be edited.
Make this action undoable by implementing a EditNumber command.

This command is differs from the other undo commands, as not the
currently selected dives are changed. This means that the EditCommand
needs an alternative constructor taking a single dive. This constructor
was implemented in the base class so that all edit commands can now
be called with a single dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-19 21:44:13 -07:00
Berthold Stoeger
a5e7f4253a Core: dynamically resize weight table
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.

The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
e3577ffd7e Cleanup: Remove unused function calls in main tab
per_cylinder_mean_depth() and selected_dives_gas_parts() are used
in the dive-information and statistics tab, respectively. Nevertheless,
these functions are called on the main tab as well and the result is
trashed. Therefore remove the calls. Must have been an artifact.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:47:27 -07:00
Berthold Stoeger
8f119dcf72 Cleanup: remove includes from qthelper.h
To reduce interdependencies, remove the dive.h and divelist.h
includes in qthelper.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
0136d76cf4 Cleanup: move deco function declarations to deco.h
Another tiny step in making dive.h smaller: move function
declarations to deco.h if these functions are defined in deco.c
and don't directly concern dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Berthold Stoeger
16214e753a Cleanup: remove includes from qt-models/models.h
qt-models/models.h included dive.h and divelist.h. Remove these
unnecessary includes, to reduce interdependencies. A drop in the
bucket, for sure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18 05:42:55 -07:00
Doug Junkins
0fb4ac7602 Fixed filter scrollarea not adjusting to parent height
Changed the Qt Layout for FilterWidget2 to "Lay Out on a Grid" to
allow the scrollarea to adjust when the height of FilterWidget2
changes. Fixes issues #2174.

Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-07-13 09:38:40 -07:00
Berthold Stoeger
5886550434 Desktop: clear notes on empty dive
If no dive is set, all fields except the note field were cleared.
Also clear notes.

Fixes #2172

Reported-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-11 15:58:30 +02:00
Berthold Stoeger
66a5b394d7 Preferences: warn if ffmpeg can't be loaded
In the preferences widget warn the user when they enter a non-executable
path to ffmpeg. Thus they don't have to start thumbnailing just to
find out that the path is wrong.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-11 00:24:23 +09:00
Dirk Hohndel
25bee36fcc Desktop: update BT selection when picking remembered dive computer
When switching to a BT dive computer, the device selection dialog is opened,
when switching away from BT, the device address is set.

Fixes #2139

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-09 21:41:04 +02:00
Dirk Hohndel
774e9ae143 Desktop: reduce minimum vertical size
The Filter widget really needed to be scrollable as it is very tall.

Fixes #2152

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-04 17:21:23 +09:00
Berthold Stoeger
09163c1ee7 Cleanup: remove DiveLocationLineEdit::currType
Apparently this field was never used...?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-04 10:41:09 +09:00
Berthold Stoeger
02e94de062 Desktop: enable clearing of dive site
Clearing dive site did not work for two reasons:
1) We didn't get a signal when editing was finished.
2) When clearing the dive site, the "add new dive site" site was set.

Thus, connect to the editingFinished signal and in
DiveLocationLineEdit::currDiveSite() return a null pointer if
the string is empty.

This means that it is not possible to have a dive site with an
empty string, but that shouldn't be a problem, right?

Fixes #2148

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-04 10:41:09 +09:00
Berthold Stoeger
57c22d3dcc Cleanup: avoid spurious updateDiveInfo() calls
In 2e230da361 the dive-selection signals
were unified. Sadly, this was done in a suboptimal way resulting in
numerous calls to updateDiveInfo(), which refreshes the main-tab.

Firstly, the MainWindow connected to selection changes from both,
the undo-command and the divelist. Secondly, every selected dive
in the divelist caused a single signal.

Thus, connect only to the divelist (this is necessary for user-initiated
selection changes) and only send a single signal in the divelist
per selection-reset.

This is still less than perfect as updateDiveInfo() is called even
if the current dive doesn't change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-04 10:40:47 +09:00
Berthold Stoeger
019eeec93d Dive merge: don't use unset dive numbers
On merging, don't use the number of the first dive if it is 0.
Use the first non-zero number.

Fixes #2126

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-28 20:23:01 +09:00
Dirk Hohndel
bc4c8d7d74 Desktop: small optimization
This way we don't need to iteratively grow the QVector.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24 13:01:25 +02:00
Dirk Hohndel
d0df6a0073 Desktop: update dive list when dive sites change
Now when we change dive site location or name through a redo, the dive
list is updated as expected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24 13:01:25 +02:00
Dirk Hohndel
e599d58531 Desktop: update flags on the map when dive sites change
Now when we change dive site location or name through a redo, the flags and
associated name are always reflected correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24 13:01:25 +02:00
Dirk Hohndel
ae6ce93775 Cleanup: simple consistency
Same pattern as the other functions in this group.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24 13:01:25 +02:00
Dirk Hohndel
ca496c63ae Desktop: fix time editing
We were shifting in the wrong direction. Which caused the field to be marked as
'edited' again, which meant we shifted the wrong way and twice the distance.
This seems to fix the problem for both date and time editing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-24 10:32:41 +02:00
Berthold Stoeger
2e230da361 Cleanup: unify selection signals
For historic reasons, there where three distinct signals concerning
dive-selection from the undo-machinery:
1) divesSelected: sent newly selected dives
2) currentDiveChanged: sent if the current dive changed
3) selectionChanged: sent at the end of a command if either the selection
   or the current dive changed

Since now the undo-commands do a full reset of the selection, merge these
three signals into a single signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
4716c82032 Cleanup: remove selectionChanged logic from dive-list commands
Since all commands now fully reset the selection, there is no point
in keeping track of whether the selection changed on addition or
removal of dives. This can be done in the function that sets the
selection.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
e1abf9485c Undo: unify selection behavior in dive-list commands
Some commands tried to retain the current selection on undo/redo,
others set the selection to the modified dives.

The latter was introduced because it was easier in some cases, but
it is probably more user-friendly because the user gets feedback
on the change.

Therefore, unify to always select the affected dives on undo()/redo().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Berthold Stoeger
27944a52b1 Undo: don't send signals batched by trip
Since the default view is batched by trips, signals were sent trip-wise.
This seemed like a good idea at first, but when more and more parts used
these signals, it became a burden. Therefore push the batching to the
part of the code where it is needed: the trip view.

The divesAdded and divesDeleted are not yet converted, because these
are combined with trip addition/deletion. This should also be detangled,
but not now.

Since the dive-lists were sorted in the processByTrip function, the
dive-list model now does its own sorting. This will have to be
audited.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-23 20:08:46 +02:00
Dirk Hohndel
4b0f90ced3 Desktop: use local variable instead of displayed_dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-23 11:29:52 +02:00
Dirk Hohndel
6619bd972c Desktop: don't use planner to manually add dive
Instead of calling into the planner, simply create the dive computer
information right there, using the existing helper function we have to
create simple profiles.

Fixes #2128

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-23 11:29:52 +02:00
Berthold Stoeger
12a13d722a Undo: sort dives by dive_less_than() in signals
In signals dives were sorted by date. This criterion is not be unique.
Therefore sort by the dive_less_than() function of the core to avoid
any inconsistencies between the Qt-models and the core data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
54d6c3f004 Cleanup: remove unnecessary get_gas_used() call
The result was not used anywhere, so why bother?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
5d34103cb9 Cleanup: use quotation marks for non-system includes
That's common practice, so lets do it that way.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
3df32044ee Cleanup: generate clear_*_table() functions by macro
In analogy to the other table functions, generate these by
a macro as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
7f4d9db962 Cleanup: move trip-related functions into own translation unit
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
6200909ba4 Cleanup: move tag functions into own translation unit
Make dive.h a bit slimmer. It's only a drop in the bucket - but at
least when modifying tag functions not the *whole* application is
rebuilt anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-19 13:11:10 -07:00
Berthold Stoeger
e329a53aab Undo: add undo button to multi-dive-edited warning message
Simply connect the button the the undo-action and the hide-message
action.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00
Berthold Stoeger
a20c22d907 Undo: hide multi-dive-edit warning message on subsequent edit
When a different field is edited, hide any old multi-dive-edit
warning message. The reason is that we might want to add an "undo"
button to the message. But this will undo the wrong command if
we don't hide the message.

Sadly, this means that we can't use animated show / hide, because
an animatedHide() followed immediately by an animatedShow() does
not necessarily show the message. In other words, and animatedShow()
does not interupt a started animatedHide()!?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00
Berthold Stoeger
f51e402e04 Undo: only show warning message if dives were actually edited
The multiple-dives-edited message was shown even if the value was
not changed. Notably, when tab-flipping through the dive fields.

Therefore, changed the execute_edit() function to return zero
when no command was executed. For this, return a boolean from
the execute() function indicating whether the command was really
executed or trashed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00
Berthold Stoeger
944a9aed54 Undo: show warning message if more than one dive edited
On the MainTab, warn if more than one dive was edited. To this purpose,
add a new KMessageWidget with an "OK" button that closes the message.
Code is mostly a copy of the already existing "Editing dive" message.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00
Berthold Stoeger
99dc528a10 Cleanup: remove MainTab::addMessageAction() function
This is a pointless one-liner function. Let's remove it. The
message it shows will probably be moved to the profile in the
not-so-distant future anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15 11:20:49 -07:00