Commit graph

139 commits

Author SHA1 Message Date
Tomaz Canabrava
cdac737925 Better positioning of the text on Weightsystems table.
Same as the cylinder, but for weightsystem.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-22 07:34:45 -08:00
Tomaz Canabrava
bc461d091c Added a bunch of tooltips where I thought it was sane.
I think we should actually fill the app with tooltips and
whatsthis hints. justsain ;p

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-22 07:34:24 -08:00
Tomaz Canabrava
cee021ddd3 Better positioning of the text on the table cells.
Better positioning of the text on the table cells. On KDE systems the
text got too near the line that divided the cells, this way the text is
placed on the middle of the cell.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-22 07:33:49 -08:00
Dirk Hohndel
995192c5fb Work around QMessageBox not showing its title on Mac
This is a bit hacky and simply adds the title to the message text when
compiling on a Mac, but hopefully this will be enough.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 04:23:10 -08:00
Anton Lundin
8aadd4d372 Quiet down warning about return in non-void
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 03:35:02 -08:00
Dirk Hohndel
0d512b2dd9 Small whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 18:17:50 -08:00
Dirk Hohndel
6acff53735 Fix trip summary line in dive list
Two errors fixed.

- With no location set, the summary line would start with a ','.
- When auto creating a trip for a manually added dive or when editing the
  dates of dives in a trip, the timestamp for the trip was not updated
  after editing the dive.

Fixes #293

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 14:20:18 -08:00
Dirk Hohndel
1a5e94006c Sanity check on gas percentages
O2 + He + N2 = 100%
(well, there are some other gases, but this is close enough)

Since N2 can't be negative that means we should refuse any change where
O2 + He > 100% (or o2.permille + he.permille > 1000).

Fixes #280

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 05:02:08 -08:00
Tomaz Canabrava
66fdd9bc91 Do not let the dive have the 0 value.
The number 0 means "this dive has not been numbered". So manually
assigning this seems wrong.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 16:54:59 -08:00
Tomaz Canabrava
61ac0a7c8d Make it posible to renumber dives.
If the user doubleclicks on the number of the dive in the dive list,
this will present to him a dialog to change that number. Pressing enter
will renumber the dive if there's no dive with the same number already.

Fixes #288

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 16:53:16 -08:00
Tomaz Canabrava
4f9526ef81 Fix wrong handling of Dive Table, and revert some wrong changes.
This patch just reverts some wrong changes that I'v done on a
past commit ( sorry ) and correctly handles the selectDive,
by using a IDX instead of the dive pointer, as dirk told me
it's extremely error-prone since the pointer can change.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16 20:19:55 -08:00
Tomaz Canabrava
8827ea6f5d This moves the removal code to the model.
It's very important when programming via Model/View, in gtk or qt,
to not mess with the model data outside of the model. We were
deleting stuff that the model controlled outside of the model, so
it thought that there was still data there. This fixes the deletion
part, but there are also lots of other parts that I'll tackle in
the next commits.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 15:13:53 -08:00
Tomaz Canabrava
a07c3d62af Use the correct font for the Air Types Model.
The air types model had a font bigger than the
other models, this patch creates a data() method
that correctly delivers the correct font.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:21:05 +09:00
Tomaz Canabrava
96d5687ab8 Correctly handle changes on the CylinderModel to update the AirModel.
What happened before was that the AirTypes model was only being updated
when the user requested to change the air by clicking directly
on the Air, in the planner ( but not on the Air Table. ).

This fixes it by calling 'repopulate' whenever the cylinder model
changes ( by adding, removing and changing something.)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:19:14 +09:00
Tomaz Canabrava
9f8577a5ea Fix edition of alphanumeric input on equipments.
This patch fixes the edition of alphanumeric input,
columns like depth accepted '23ft', '20m' or '30', with
an inplicit conversion to the unit. But the code ignored
that the input could have a 'ft' or 'm' ( ot anything else
for that matter.

Signed-off-by: Taiane Ramos <exhora.tat@gmail.com>
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:24:48 +09:00
Dirk Hohndel
d7fb6853a3 Connect changes in the tanks with the dive that is being added
- you can no longer delete a tank when its gas is in use
- therefore you can no longer delete the last tank
- when you change the gas mix of a tank, the corresponding segments in the
  dive change as well
- when changing gas for a segment the correct available gases are offered

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:56:22 +09:00
Dirk Hohndel
83a7f1f5b4 Use existing helper function
And remove spurious extra ';'

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 16:33:01 +09:00
Dirk Hohndel
d72c69db7a Add depth colum to cylinder model
To make the planner work this adds a new column to the Cylinder widget
(depth - for the depth at which we want to change to a certain gas
during deco).

This also tries to hide that column in the equipment view and hide the
start/end pressure columns in the planner view. Oddly that fails :-(

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:17:40 +09:00
Dirk Hohndel
ea2e517e39 Fix crash when cancelling dive add on empty dive list
Don't pass NULL dives around.

Fixes #231

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 05:55:20 +09:00
Dirk Hohndel
aa4931e8c6 Show a cylinder widget in the dive planner
This is intended to allow the user to provide the gases / cylinders that
she will be diving with. With that information the planner can warn the
user about insufficient gases, but more importantly it can show relevant
gases in the gas select drop down.

Right now the add cylinder button doesn't add a cylinder - that's a
problem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10 07:07:59 +09:00
Lubomir I. Ivanov
861b524e7a Helpers: move some date related function to qt-gui.cpp
divelist.c:
get_dive_date_string()
get_short_dive_date_string()
get_trip_date_string()

MinGW support for *printf and parameter positions (e.g. %1$d)
is horribly broken. Instead of implementing *proper* support
for this feature Microsoft decide to ignore the standard (again)
and they implement new functions with the '_p' suffix,
such as 'sprintf_p', which seem to be available from a 2003 runtime.
To top that 'sprintf_p' is not really a 'sprintf' but rather
a 'snprintf'.

It seems that the MinGW people ignore the issue and do not provide
wrappers of any sort, or at least for the current recommended compiler
for Qt 4.8.5 on Windows - which is a 4.4.0. A note of warning;
inspecting how MinGW does certain things in headers such as stdio.h,
can ensue bad dreams or other negative effects on to the viewer.

This forces us to move the following functions from the 'back-end'
(divelist.c) to the 'front-end' (qt-gui.cpp) and use QString.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-16 15:04:44 -07:00
Robert Helling
c59d594e00 Printing adjustments
Add units to the SAC in the print-out, reduce max depth in metric to one
decimal place, and leave some more characters of the notes to be printed..

Signed-off-by: Robert C. Helling <helling@atdotde.de
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 10:34:40 -07:00
Lubomir I. Ivanov
88b1e09dee printlayout.cpp: Increase the font size in tables bellow profile
Because of varying font (screen) DPI we use pixel sized fonts
when printing. Apparently 8px does not look that good on Windows
default fonts, but kinda OK on Linux. We compensate by
increasing the font size and table rows to 9px.

Also decrease the padding between the table and profile to 5px.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15 04:23:56 -07:00
Lubomir I. Ivanov
a2a93ff04b Models: fix two potential crashes
CylinderModels::setDive() and WeightModel::setDive() have
potential to pass the 'last' argument to beginInsertRows() as
a negative number which triggers an assert that 'last' cannot
be smaller than 'first'.

Patch attempts to fix that by only calling beginInsertRows()
when there is at least one row to insert.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-13 11:31:25 -07:00
Tim Wootton
a014fb1099 Adds missing "EndPress" column header for cylinder table
The end pressure was appearing in the column headed "O2"

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-13 11:30:56 -07:00
Tomaz Canabrava
beb40ae494 Finish clearing up the TableModels
There are other models ( Tree Models and Model Items
) that are not affected by this commits, this is
already a good cleanup but it can be extended
to also fix those two other possibilities.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 11:42:33 -03:00
Tomaz Canabrava
fac316865c Another Model Cleanup
Conversion of the WSInfoModel, that populates the list
of weigthsystems in the Equipment tab.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 11:13:16 -03:00
Tomaz Canabrava
a4efa8c444 Second model converted to be less boilerplated.
Second model converted to be less boilerplated,
there are right now 7 models that will need to
be ported. each model can remove around 30 to 40
LOC, so this is not such a bigger improvement,
but it's an 'keeping an eye on the future'.

Also fixed a bug where the returned value was dummy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 11:04:27 -03:00
Tomaz Canabrava
26c87fafc2 Begin to Cleanup the Models, trying to reduce boilerplate.
The Model View system in Qt is *very* verbose, this is the
beginning of a series of patches that will concentrate
the boilerplate somewhere and reduce the amount of lines
and will also try to make the code cleaner and easyer to
understand,

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 10:50:40 -03:00
Tomaz Canabrava
1b9a4f2bf8 Good deal of whitespace fixes and code cleanup.
I just went thru all of subsurface code removing
some whitespaces issues and trying to make the
code prettyer, I also removed a few QString issues.d

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 10:21:04 -03:00
Benjamin
ae713763c7 Add a helper function to calculate weight display string
Add a helper function to unify the calculation of the
weight display string, instead of having the same calculation
in two places in the code.

Signed-off-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-04 11:57:28 -07:00
Benjamin
9961cf13b1 Use the same conversion grams->lbs in dive and equipment list
Subsurface stores weight values in grams. When displaying lbs,
the dive list was not rounding the converted weights up, but
rather truncating the value at the decimal place. The equipment
list was rounding the converted weights up. This gave two
different displayed values for the same weight value.

Signed-off-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-04 09:40:05 -07:00
Lubomir I. Ivanov
e727b899a6 Print: provide means to print profile tables
This patch adds a couple of classes and some other modifications
in PrintLayout that handle the printing of tables under a profile.

models.h : ProfilePrintModel
The class uses a 'struct *dive' to output all required data
for a certain dive at specific rows and columns. It also handles
font formatting and text alignment.

modeldelagatates.h : ProfilePrintDelegate
The class is used only for drawing a custom grid for profile tables.

PrintLayout::createProfileTable()
The function is used to create and setup the profile table object

PrintLayout::printProfileDives()
The function now has correct padding of dive profiles on a page
and also the printing of actual tables below them.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 09:38:37 -07:00
Tomaz Canabrava
94c8f64316 Only mark dive list as changed if 'Accepted' was clicked.
The old code marked the dive list as changed on any
of the changes in the model, this was incorrect since
the user could just cancel the edition, wich means
that the divelist shouldn't be marked as changed at all.

when the user clicks on'accept', and the item is indeed
changed on the dive list, then we mark_divelist_changed
to TRUE

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-25 14:30:03 -03:00
Tomaz Canabrava
2c14f3aa3b Added a 'changed' member on Cylinder/Weigth models to know when to Apply a change.
Added a 'changed' member on Cylinders and weigth models to mark when
one was changed or not. Only the changed data should be inserted on
the selected dives, so if the user changes the cylinders on a multi
edit, there's no need ( and it will actually break things if we did that )
set the weigths too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-25 14:23:51 -03:00
Dirk Hohndel
f5b33dede3 Fix row counting bug
When updating the weight system model we have to remove the old ones and
then correctly count the new ones.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-10 14:55:30 -07:00
Dirk Hohndel
e7fd45c7ef Change ws_info and tank_info types
This is correct C. But debuggers in C++ mode are broken and can't display
the global variables. While I hate having to do this change, I hate not
being able to debug my software because of broken tools even more.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-10 11:44:49 -07:00
Dirk Hohndel
e91ac60f49 Fill ws_info structure and use it when entering weight systems
The code to initialize the weight systems from the last datafile loaded
had not been brought over from the Gtk version.

We now correctly update the data structure when loading file (but not yet
when editing values).

Most likely the same needs to be done for the tanks as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-10 11:42:26 -07:00
Lubomir I. Ivanov
e5b18db802 Print: improve table printing by using QTableView
The current QTextDocument implementation is slow due to
HTML parsing. By using QTableView with QAbstractTableModel
we boost the performance of the table print drastically.
This patch completely replaces the old solution.

There is a hidden QTableView widget which is populated
with all data and rendered using a QPainter attached to
the printer device.

A couple of new classes are added in models.h/cpp
that handle the table print model and these are then used
in printlayout.h/cpp.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05 06:59:19 +02:00
Tomaz Canabrava
8ad7216e70 Fixes incorrect editing policies.
The Working Press didn't correctly updated when there was a 'bar'
or 'psi' in the string ( and that was defalt behaviour );

The o2 didn't correctly updated when there was a '%' on the string
(and that was default behaviour ),

The He didn't correctly updated when there was a '%' on the string,
and that was also default behavior.

Now all of them correctly updates.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-18 12:01:48 -07:00
Tomaz Canabrava
3aa55462dc Added the code to revert Weigths when user cancels edition
This is a follow up commit to the previous one that
enabled cancel for cylinders, everything in the commit
log for the cylinders also applyes here.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-18 12:01:48 -07:00
Tomaz Canabrava
7e029980b8 'Cancel' action Cancels editing Cylinders.
Made the default 'Cancel' action correctly cancel
the cylinder edition. This is needed only because
we bypassed the default behavior on Qt that took
care of this, because we wanted to have more control
on how the view would update the items accordingly
with wich one of the cylinders were selected
on the edition pane - the pressure and size of the
cylinders needed to have it's data set, but the Qt
Model/View system *thinks* that cancel-edition is
simply 'do not commit the edition data, then.' wich
would not work with us, because we passed the strange
data already. So, I created a backup data that serves
us very well. When the user cancels, this backup data
is added back on the cylinder, making everything as
it was before.

[Dirk Hohndel: removed the inadvertendly added boost header]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-18 12:01:05 -07:00
Tomaz Canabrava
1a0a4b7e08 Fixes the Combobox behavior on the inline-edit
This patch fixes the combobox behavior on the inline edit
to what it was ( well, similar to ) the GTK version,
up and arrow keys will walk you to the list of choices,
and it will update the other data as soon as you walks over it

one drawback is that you cant ( for now, since I do have a
very big headache at the moment ) cancel, since the cancel
will just forgets the item and do not call 'setData' on the
model, but we already called it while walking on the list.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-16 19:13:58 -03:00
Lubomir I. Ivanov
127cd21137 Models: add the DiveItem::displayDate() helper
Add this helper so that we can easily wrap the required
memory release after calling get_dive_date_string()
(fixes a small memory leak).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-11 12:41:50 +03:00
Lubomir I. Ivanov
adb7dc6fac Models: move the declaration of DiveItem to the header
This should allow external use of the type by
including models.h.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-11 12:40:08 +03:00
Linus Torvalds
5ce5b05521 Qt: Implement trip merging logic
So during my Maui trip, I had a short hiatus in diving, causing
subsurface to start a new trip for the last day of diving.  I could have
just started the old gtk branch to fix it up, but decided that I might
as well try to implement the "merge trip" logic in the Qt branch instead.

This is the end result of that.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 23:00:12 -07:00
Linus Torvalds
09ee8ece5c Show sample pressures in the cylinder equipment page
If we don't have any manually set pressure data, show the data from the
samples instead.  It uses an italic font for this case, mainly because I
couldn't figure out how to gray things out.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:53:34 -07:00
Linus Torvalds
bc24b9320f Don't show '0.0%' gas percentages
It's just distracting.  Leave it empty.  No helium should be visually
very different from actual trimix, and for oxygen, zero means something
different anyway (it's air).  In neither case is '0.0%' a good string to
show, just show it as empty.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:52:58 -07:00
Linus Torvalds
45d9ca09de Fix the imperial cylinder size calculations in equipment handling
This makes us use the same linear calculations as we did in the Gtk
branch.  We don't take compressibility into account, since tank
manufacturers don't seem to either.  A Luxfer AL80 is 11.1 liters, and
with the standard (non-compressibility) calculations, 80 cuft of air at
3000 psi is 11.094 liter, so that is the right model to use.

Also, stop with the horrible "units in edited numbers" stuff.  It uses
up precious space, and doesn't look any better.  If the user asked for
cuft, give him cuft without making a big deal about it.

Oh, and if the working pressure doesn't exist, sizes are always in
liters.  That's what we did in the Gtk branch, that's what we do here.
Again, no reason to even bother stating units, it's not helping.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:40:38 -07:00
Linus Torvalds
02f2768148 O2/He percentages aren't integral
We do gas mixes in permille, not in percent.  Some people really like
using the value they got from the analyzer, which is generally something
like 29.4% or whatever.  So don't truncate percentages to integers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:39:12 -07:00