If this is the last dive and if the previous dive had a number, give this
dive the next number.
Of course there are a couple of issues with the current implementation. We
have no way of changing the date / time of the added dive, so we KNOW that
it will be the last one. But I put that check there so that once we add
the ability to change the date / time (and hopefully remember to then move
the dive to the correct spot in the dive_table), we only assign a number
if it is the last dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was surprisingly easy - which of course has me worried that I'm
missing something that I should do when cancelling out of this dialog.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This gets things mostly right.
It creates a dive and uses the planner widget to create samples which are
copied into the dive. It fills in some reasonable defaults (DC model,
timestamp), but doesn't allow editing the timestamp (or the temperatures
and air pressure).
On accept the planner gets reset and the dive appears correctly in the
dive list.
Cancel still needs to be handled.
And I bet there are many subtle bugs lurking here and there. But it's a
start.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reset coordinates properly when clicking undo.
When auto-completing location, only copy coordinates if they have not
been manually edited.
Set the background to red if the gps coordinates won't change, e.g.
there is a parse error, the change is too small or only whitespace
changes.
Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added the Message and the ok/cancel buttons on the Equipment
Tab, they don't control the Equipment edition yet, but already
does the same as the Notes one, Now I need to merge the other
part - the actuall Equipment Edition.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Adds a Warning icon on the changed tabs, this is important as
usability, for you could change something on the 'notes' tab,
change the tab and did't realized that something was changed
( by forgotting or something ), then clicking on the cancel
button. so now there's a friendly reminder that you actually
changed something.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Some cleanup was needed in the MainTab code for ages,
now the Edition / Cancel / Ok of the Notes tab is
way more intuitive on the code level.
This is needed to support multidive edition on the
Cylinders and Weigths too, since it's a bit more
complicated, I didn't want to start with a Spaguetti
Code.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Coordinates are copied when auto-completing location, they are also
displayed and editable in maintab.
Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merged the shared code for the three table views into
one code, this way less code is needed if we need to
construct another tableview in the future.
I still need to clean some of the models too.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Made the tableviews share a bit of code, and code cleanup.
The tableviews for Cylinders, Weigth and Dive Planner Points
now shares the CSS and I also implemented the save / load
methods for the dive planner points, so the functionality
is mostly done on the vieualization side. - since we are
now using three tables maybe it's a better idea to create
one class SubSurfaceTable that knows how to handle saving
/ loading of the columns... TODO for the future. ;)
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This is a bit of code cleanup that I'm not sure that will
pass, since it's all macro-based, but I don't have a thing
against macros at all. Sometimes they helps us keep a better
and cleaner code base. I think I managed to remove around 120
lines of code, wich isn't much, but I replaced it by 14. and the
code is now easyer to maintain, so hooray.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Change the background color of edited parts of the dive
on the interface. Specially util if you are editing multi
dives in a single step, and went to eat something or did
anything else for five minutes, then come back and don't
quite remember what did you changed. now it's in a cute
yellowish background.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This patch enables multi dive editing on the selected
dives. It's a bit of big patch where I reworked how it
worked since it was written just for a single dive.
this means that this can introduce bugs - I'v tested it
quite a bit but a thing could slip thru my fingers. :)
How this is supposed to work:
Select a few dives that you want ( one or more ) then
click on the field that you wanna edit / multi edit, and
press 'accept'. *only* the edited field will be modified
thru all dives.
Next patch - I'll change the bg color of the edited fields.A
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Fixed a bug where the auto-completion would not work via command
line, I fixed it by reloading the information of dives when a
dive file is open via command line or via UI.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Added completion for buddy, divemaster, location and suit.
The completions uses some models that I created in the last
commit - everytime that a divelog file is loaded, it creates
a list of completion items.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This patches fixes showing back the labels 'Dive master' and 'Buddy'
after a trip selection was done, then back to single dive selection.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This patch makes the auto editon behave in a better way,
now you can scroll the notes widget without marking it as
editable, and also adds a bit of code cleanup, and a better
logic for editing the other widgets.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This is a linus request, adds a Single-click edition
on the tableview to make it more consistent with the
rest of the interface where edition is permitted.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
1) Make a call mark_divelist_changed(TRUE) when the user adds new
cylinder or weight entries.
2) Call mark_divelist_changed(FALSE) in
MainWindow::on_actionClose_triggered() so that each time after
a file is closed or a new one is created it does not ask immediately
the user for a save confirmation for the blank file/divelist.
3) Call mark_divelist_changed(TRUE) once a dive's geo location
has changed in GlobeGPS::changeDiveGeoPosition().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There are a couple of problems with said icons:
- When the Equip. tab is first seen, no relative event is monitored
so that the correct position is updated and the icons are positioned.
To solve that we connect the signal MainTab::currentChanged(int)
and call MainTab::equipmentPlusUpdate().
- When the info-profile QSplitter resizes with a snap towards/from
the edges of the main window, no resize handler is called such as
MainTab::resizeEvent().
A solution is to monitor the resize of the info-profile splitter
with MainWindow::on_infoProfileSplitter_splitterMoved() and again
call MainTab::equipmentPlusUpdate()
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch saves / restores the sizes of the columns in the cylinders
and weigth table widgets, so everything is now properly behaved. There
's still other things to do - but I'm tired. i's sunday and there's a
protest against the brazilian government to go.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Make the columns on Cylinders edit and Wheight Edit to
have sane values for 'type', this is needed because the
old behavior was to set it fixed size, and the default fixed
size was silly. this calculates a good predefined value
taking the font size in consideration.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Better handling of default sizes on the Cylinder and weight widgets,
the weigth widget didn't had a CSS applied so it looked odd compared
to the cylinder one, also the default behavior for the combobox delegate
didn't worked very well with the css applied, being too small.
this patch fixes that.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
While we still show the selected_dive in the profile and use it for Dive
Info and Equipment, in the Dive Notes tab we now show the trip location
and trip notes (and none of the other fields), if the user directly
selects a whole trip by clicking on the trip header.
This clever reuse of the widget now allows trip location and notes to be
edited in place.
As a side note: the Gtk version has long allowed the user to edit the
trip location and trip notes, but nowhere did it ever SHOW the trip
notes... so this is more than just feature parity...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit c4f06dc536 introduced Document
Mode on the MainTab QTabWidget. This doesn't look good on MacOSX.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added a new widget, MinMaxAvgWidget, a simple widget
that displays values in 'min, max, avg' fashion.
it has a setMaximum, setAverage and setMinimum
methods, that is userful for setting the minimum,
maximum and average of stuff. Ah, it also shows
the minimum, maximum and average of things.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Things got broken. Again. We no longer kept track of the selected dives in
our structures which broke statistics.
This attempts to fix that, but appears to still have a bug when selecting
trips. Sometimes this results in 0 dives being selected according to our
data structures, while Qt happily shows all dives of the trip as seected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There was already a code for that on the maintab.cpp, but
since I moved all labels to groupboxes, the code stopped
working, and I tougth it'd better to kill the code since
it's faster and safer to use the interface builder for that.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
My attempts to actually set the width of the columns with the
SizeHintRole all failed - so I gave up on that and am forcing things to
work by making the texts in the header somewhat longer and then resizing
to that. Definitely not what I wanted to do - but that plus reducing the
font size gives us a much more reasonable / compact look.
I really hope that someone else can explain to me how to get the
SizeHintRole to affect the width (and not just the height - that part
worked just fine) of a the cells in a column. Then we can replace this
hack by a much better solution (that won't fail if the translated strings
look different).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the more familiar Save/Undo instead of OK/reset
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is very much analogous to the way cylinders are implemented.
That means that just like with cylinders, if the user enters a new type
and hits 'tab' before hitting 'enter', Subsurface will crash.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The .ui components were removed in commit 0c7a575f7b3b ("Rework on the
Equipment tab to make it look more Modern.") but the "automagic" slots
were still here.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now when you edit 'Type', a drop-down list will appear
and will enable you to choose from it's contents.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
So, the Cylinders and Weigthsystems got a new Trash icon,
and the interface already intercepts the clicks ( on all
columns ) and send this to the 'remove' method on boch
models. On the model I'm just filtering the indexes that
are not 'DELETE' and creating a stub method to be filled
later.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Note that this is a WIP and it does break functionality
- ie, not possible to add Equipments, but this will be
fixed in the next commit. Removed add / edit / remove
buttons, only a single '+' icon appears on the widget
now. the edit / delete will be done in place.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This patch adds support showing and for editing weigthsystems in the equipment tab,
so, now the two things that are missing are 'edit' and 'delete', wich are quite easy to do.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
i
Added the code to show the cylinders from a dive,
this code also already permits additions from the
interface, so the user can click 'add' and insert
what he wants there.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This also removes some incorrect code from the clear() function for the
DiveInfo tab. Putting the readOnly() calls for the DiveNotes tab there was
wrong.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This would be correct if the current selection code wasn't broken. Right
now we only add to our internal notion of what is selected - we never
deselect anything.
Once that is fixed, thestatistics should be correctly displayed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's not editable. And of course it continues to look like utter crap -
even more so now since this is left aligned and everything else is
centered.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This also fixes a potential crash if no dives were loaded and the user
started editing the fields and clicked OK.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old names made sense in the initial model (where you'd click on the
edit button to start an edit). The new names seem much more natural given
what we do now.
Also a tiny code cleanup removing a redundant if statement.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit 7b00668b400b ("Improve the Dirk edit mode.") had what looks like an
"autocomplete" typo. This also stops us from changing the text on the
button that in this edit mode is always just the "OK" button.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Pulled one more helper from statistics-gtk.c (but didn't modify the code
there to use it as that code is no longer being compiled).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The dirk edit mode will be triggered as soon as the user
clicks on the field that he wants to edit. then he can
edit all fields, till he press ok / reset.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This is just a for choosing the default edit style in the
future. I prefer the new edit style as the user is sure
what the hell is going on ( ie - if he chooses to edit,
he is editing, there's a message warning him that he is
editing and everything else is blocked till he finishes
editing. ) and the GTK version is 'edit whenever I feel like',
wich I think is more unsafe but dirk asked me to put an option
and let the others choose.
e
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This seemed more logical than keeping it as "edit" and basically having to
hit "edit" a second time in order to save a change.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is to prevent loss of data, so if the user is editing something,
either cancel the edition or save it, to continue moving around on
the Dive List. - Only the dive list is affected, user can still
play with the globe and the profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added option to edit the selected dive.
Now the user can click on 'Edit', and a nice box will
appear stating that the dive is in edit mode, and the user
can edit all of the 'Notes' tab fields, including the
rating. When the edition is finished, the user needs to
click on 'edit' again to mark as accepted, or in
reset to reset the fields to it's original state
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Cosmetic commit to clean up some of the annoying typos in qt-ui
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Align statistics tab labels as per infotab.
Amend helper function to show degree symbol for temp measurements.
Change order of member initialisation list to match order of decl
(ProfileGraphicsView::ProfileGraphicsView)
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Left aligning text values looked wrong.
Use Qobject cast to filter labels from any other qobjects around and
set alignment. Doing this via Qt Designer would be tedious.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A null pointer dereference occured after right click on a dive trip
because updateDiveInfo was called with dive == -1 causing get_dive(int)
to return null.
Wrap to avoid crash and clear dive info widget text labels.
[Dirk Hohndel: this is different from the fix I had committed earlier;
I decided to combine the ideas, clean this one up a bit
more and this is the result]
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I missed to spots where we would unconditionally dereference the dive
pointer.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Reported-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Establish some useful helpers and use them when updating the values.
One of the helpers (from statistics.c) puzzlingly doesn't link - so that's
ifdefed out.
Also had to re-arrange the settings reading code (it came too late) and to
extract the expanding code of the top dive from the settings reading code
(as it had no business being there to begin with).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So, this is what happens now:
Every tab should be populated from updateDiveInfo method, it will be
called whenever a new dive is selected
I'm already populating the 'notes' box to show how it can be done.
If you are unsure what's the name of anything, open the file maintab.ui on
the designer, click on the item and check its objectName, the access is
ui->objectName from here on.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Rename various labels and text into clear pairs and reflect changes into
.cpp file.
To avoid clashes with names on other tabs use '..All..' to emphasise
that this page deals with an aggregate across the selected dives.
Re-format the statistics tab.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Clean up the formatting.
Distinguish between headings and value labels.
Tidy up text appearance (remove trailing ':')
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The constructor letf the currentWeightsytem variable uninitialized.
Instead of creating the memory leak by malloc-ing the newWeightsystem in
the on_addWeight_clicked() function use a local variable instead and pass
its address around.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
My first attempt to create a Qt dialog and to hook it up with the program.
Unsurprisingly this doesn't quite work as expected (i.e., the values I
enter aren't populated in the model), but it's a start...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The Qtr_ hack isn't needed as in commit 720fc15b2dcd ("Introduce
QApplication") had already made sure that we are using gettext.
I didn't revert the two commits as I wanted to keep the added header
comments and fix the tooling in the Makefile as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Removed the use of operator<<() in a bunch of lines to do direct calls
this way the code will not scare non-c++ hearted people. :)
s
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This should wrap gettext nicely and replace the "_()" macros we use in C
code.
Also added comments to the top of all the new files.
Suggested-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
1 - Open File already open files, it tries to not break the Gtk version,
but some methods on the GTK version still need to be called inside Qt
because the code is too tight-coupled.
2 - Close file already close files, same comments for the open file dialog
applies here.
3 - The code for adding new cylinders in the cylinder dialog is done,
already works and it's integrated with the system. There's a need to
implement the edit and delete now, but it will be easyer since I'm
starting to not get lost on the code.
4 - Some functions that were used to convert unities have been moved to
convert.h ( can be changed later, put there because it's easyer to
find something that converts in a convert.h =p ) because they were
static functions that operated in the GTK version but I need those
functions in the Qt version too.
[Dirk Hohndel: lots and lots of whitespace and coding style changes]
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add some magic rules to detect which files need to be processed by the
moc or uic tools, as well as a way to manually specify exceptions.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is based on several commits from Tomaz - mingled together and mildly
extended by Dirk (mostly Makefile hacking).
All Qt UI related stuff should eventually move into the qt-ui directory.
So the Makefile rules for moc and uic have been adjusted accordingly.
The MainWindow class has been moved into its own file in qt-ui (but just
with a placeholder, the existing class has simply been ifdef'ed out in
qt-gui.cpp for the moment).
We still have a couple of Qt things in qt-gui.cpp in the main directory...
all this needs to move into the qt-ui directory and be built with separate
.h files. Right now we have the one-off Makefile rule to create the
qt-gui.moc file from the qt-gui.cpp file.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>