Commit graph

59 commits

Author SHA1 Message Date
Berthold Stoeger
7c70459f6c cleanup: remove unnecessary includes from maintab
These are artifacts from when the maintab contained more stuff.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-28 11:27:58 +01:00
Berthold Stoeger
00ff63f186 desktop: update date and time fields if user changes format
This was more painful than expected, because we get the "preferences"
changed signal too early when the user switches to system format.
The correct format is set by the preferences-widget, not the preferences
subsystem.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22 10:00:43 -07:00
Berthold Stoeger
1c590783e0 cleanup: free tab-widgets when exiting the application
This is completely irrelevant, however out of principle,
let's free the tab-widgets at the end of the application.
To do so, use Qt's object hierarchy. I'm not a fan of this
kind of memory management, but it is how it is.

Moreover, remove the explicit constructor of MainTab, since
it doesn't differ from the default constructor anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:59 -07:00
Berthold Stoeger
c50e58d761 desktop: avoid spurious undo commands for date/time editing
The date and time fields of the main tab posted undo events
for every date/timeChanged signal. Thus, when changing the
day of the month to e.g. 21, this would result in two date
change events: one to the 2nd and one to the 21st. This is
very irritating.

Instead listen to editingFinished() events, which thankfully
exist for these widgets.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:19:57 -07:00
Berthold Stoeger
20e7064658 desktop/tabwidgets: replace editMode by boolean
There was only one editMode left (MANUALLY_ADDED_DIVE).
Therefore replace by a flag. This makes the code more consistent,
because the conditions "editMode != NONE" and "editMode ==
MANUALLY_ADDED_DIVE) actually meant the same thing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
3b9913d828 desktop/tabwidgets: replace IGNORE_MODE by flag
The editMode was set to IGNORE_MODE when programatically setting
fields so that we can ignore changed-signals.

That seems to be orthogonal to whether we are in edit mode
and indeed when setting IGNORE_MODE the edit mode was
saved and restored.

Therefore, replace the IGNORE_MODE by an independent ignoreInput
flag.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
dcc1d3ed63 cleanup: remove DIVE EditMode in MainTab
That mode is not used anymore, since only the editing of
profiles of manually added dives enters editing mode. For
that case we have the MANUALLY_ADDED_DIVE edit mode.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
13d339451e cleanup: remove parameter to MainTab::enableEdition
All remaining callers were passing MANUALLY_ADDED_DIVE as a new
mode, so we may just as well remove the parameter and thus
simplify the logic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
0306109e95 cleanup: remove MainTab::modified
This field was not set to true since introducing undo of
dive fields.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27 14:49:01 -08:00
Berthold Stoeger
9ed886e4be Cleanup: lower-case filenames in core/subsurface-qt/
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>
2020-02-04 02:16:46 +01:00
willemferguson
08db77333b Notes tab: Use top RH for depth and duretion fields
Currently the top righthand part of the notes tab is used for
    showing and editing air teperature and water temperature. But
    these fields were moved over to the Information tab and are not
    required in the Notes tab any more. Rather use this space for the
    depth and duration data for manually-entered dives. Currently
    extra vertical space is created in the Notes tab for showing this
    field, resulting in inefficient use of screen space and
    inelegant layout. This code moves the Duration and Depth fields
    into the top righthand of the Notes tab.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-11-11 20:19:22 +01:00
Willem Ferguson
7a4abd7477 Reorganise the Information tab of the Info panel
1)  Reorganise the existing widgets in the Information tab
2)  Move divemode widget and visibility widget from Notes tab to
    Information tab
3)  Translate water density to a word indicating water type
4)  Reorganise the Notes tab to compensate for the moving the
    divemode and visibility widgets to the Information tab
5)  Remove the problems in showing a QGroupBox in Qt Windows. I do
    this by removing the CSS specifying border characteristics

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-10 13:10:03 -08: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
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
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
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
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
Berthold Stoeger
32720a7c18 Dive site: Add button to display all dive sites
On the main dive tab, add a button that opens the dive-site selection
widget showing all dive sites. This is done by setting the "temporary
dive site name" to the empty string. Thus no dive sites are filtered
and the "add new dive site" entries are not shown. Moreover, the
text is selected. The user can therefore immediately start typing to
activate the filter or enter the name of a new dive site.

The idea is that after downloading dives with GPS information the
user can select one of the close dive sites.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:35:11 -07:00
Berthold Stoeger
d4a91a52fa Map: reload on selection change directly
When changing the dive selection, we have to reload the map to show
the correctly highlighted flags. Do this directly by hooking into
the DiveListNotifier::divesChanged signal instead of indirectly
via the MainTab.

Moreover, on reload center on the highlighted dive sites.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:06:19 -07:00
Berthold Stoeger
822b88ab3d Cleanup: remove completers from MainTab object
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>
2019-04-15 10:30:04 +12:00
Berthold Stoeger
fe61f6b69e Cleanup: Move dive-equipment tab into own translation units
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>
2019-04-15 10:30:04 +12:00
Berthold Stoeger
4bb002d137 Cleanup: Remove MainTab::getEditMode() function
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>
2019-04-15 10:30:04 +12:00
Berthold Stoeger
8c6205fc0d Undo: on save remove focus from active fields
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
837ab6c90b Desktop: read tab-items from current_dive, not displayed_dive
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
bfb6a55707 Undo: inform maintab if dive site changed
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
4a3ffeba05 Undo: remove ADD mode from main tab
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
c4ad477d07 Cleanup: remove field-coloring code in MainTab
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
d7d408a99e Undo: implement undo of dive trip editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
73a230b6e6 Cleanup: remove EDIT_TEXT and EDIT_VALUE macros in maintab.cpp
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
53b4d84a6e Undo: remove MainTab::*TaggedStrings() functions
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
cddd5942f8 Undo: update dive list after edit command
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
d5691cd7cb Cleanup: remove MainTab::acceptingEdit
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
c82f4487f9 Undo: implement undo of depth and duration editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
02d572226d Undo: implement undo of divemaster editing
This is mostly a trivial copy of the buddies code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
a9bd0690fe Undo: implement undo of buddy editing
This was mostly trivial by reusing the code for tag-editing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
8c89f6fe15 Undo: implement undo of tag editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
6f574c53a3 Undo: implement undo of dive site editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
4cb1ceefff Undo: implement undo of dive date- and time-editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
de579c1a1a Undo: implement undo of air and water temperature editing
Mostly trivial. Since now on editing the field is re-set, the
validation function becomes unnecessary.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
512a2e6b68 Undo: implement undo of suit editing
This one was trivially modelled after notes editing. Only difference:
the textChanged() signal was replaced by the editingFinished()
signal so that we're not generating undo-commands on every key-press.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f11ac40593 Undo: implement undo of dive mode editing
Add a new UndoCommand for dive mode editing. This one is a bit
special, as the mode is associated with a dive computer (DC),
not a dive. Thus the edit command has an additional parameter,
viz. the index of the DC.

This does not fit properly to the EditBase class, as this class
isn't aware of additional parameters and therefore this parameter
is not sent via signals. At the moment this doesn't matter. In
any case, the semantics of editing are weird and therefore let's
do the simple thing (derive from EditBase) and let's see what
the future brings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
45ef879546 Undo: update notes field if changed by undo commands
To keep the UI in a consistent state, update the notes field if
it is changed by an undo command. To that purpose, add a new
signal to diveListNotifier with a list of dives and a field-id
as payload.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9e603cbe2b Undo: implement rudimentary undo of dive-notes editing
Implement a first rudimentary dive-editing command. The main code
resides in a base class Command::Edit, which calls virtual functions
to read / set the fields and extract the field name.

Implement an example: editing of dive notes.

This dose not yet update the UI on undo / redo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
5e2dfd546e Cleanup: remove unused function MainTab::setCurrentLocationIndex
The last caller was removed in ce8199cdfd.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-02 19:35:36 +02:00
Berthold Stoeger
b9b1b3146b Dive site: remove UUIDs from LocationInformationModel
Replace UUIDs from LocationInformationModel and fix the fallout.
Notably, replace the UUID "column" by a DIVESITE "column".
Getting pointers through Qt's QVariant is horrible, we'll have
to think about a better solution.

RECENTLY_ADDED_DIVESITE now defines to a special pointer to
struct dive_site (defined as ~0).

This fixes an interesting logic bug:
The old code checked the uuid of the LocationInformationModel (currUuid)
for the value "1", which corresponded to RECENTLY_ADDED_DIVESITE.
If equal, currType would be set to NEW_DIVE_SITE. Later, _currType_
was compared against _RECENTLY_ADDED_DIVESITE_. This would only work
because NEW_DIVE_SITE and RECENTLY_ADDED_DIVESITE both were defined
as 1.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Berthold Stoeger
5d1c30acbf Cleanup: remove unused function MainTab::showLocation()
The last caller was removed way back in 266e754d08.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-12 13:05:35 +02:00
Jan Mulder
a47df05ce5 Edit: prevent not needed change marking
While trying to understand more of the big change from PR 1528,
I found that the divelist was marked changed while it was not
changed at all. Reason is simple. The MODIFY_DIVES code assumes
its called only for truly changed data. But in case of saving
tagged strings, it was not.

This fixes this. And I do not believe this has any visual effects.
Further, the now broken indentation is fixed seperately.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-12 13:03:54 +02:00
Berthold Stoeger
ce8199cdfd Cleanup: remove ReverseGeoLookupThread
Fetching the taxonomy from GPS coordinates was implemented in
a QThread. But the only access to the main function was a
direct call to run(). Thus, the thread was *never* started.
The function call was always asynchronous [it was using an
event loop though, so the UI doesn't hang]. Notably this
means that the signals connected to the thread would never
fire. And the spinner would never be activated.

Thus:
1) Turn the thread into a simple function.
2) Remove the spinner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:02 -07:00