Commit graph

199 commits

Author SHA1 Message Date
Dirk Hohndel
7bf07b890a Small fixes to the model
Prevent a crash when no cylinder type description is set.

Correctly calculate the cylinder volume.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 16:22:21 -07:00
Dirk Hohndel
76903849de Get the math right for cylinder model setData function
This is a fun one.

We only want to mark the divelist changed if the user actually changed
something. So we try really hard to compare what was entered with what was
there and only if it is different do we overwrite existing values and
record this as a change to the divelist.

An additional challenge here is the fact that the user needs to enter a
working pressure before they can enter a size (when in cuft mode). That is
not really intuitive. We work around this by assuming working pressure is
3000psi if a size is given in cuft - but then if the user changes the
working pressure, that changes the volume. Now going back and changing the
volume again does the trick. Or enter the working pressure FIRST and then
the volume...

This also changes the incorrect MAXPRESSURE to WORKINGPRESSURE and uses
the text WorkPress in English (Gtk code used MaxPress which was simply
wrong - this is just the design pressure or working pressure, not some
hard maximum. In fact, people quite commonly "overfill" these tanks.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 14:51:41 -07:00
Dirk Hohndel
63b6f7d5a2 Merge branch 'comboBoxDelegate' of https://github.com/tcanabrava/subsurface 2013-05-22 12:14:06 -07:00
Tomaz Canabrava
134e20bdc2 Removed the unused add cylinder and add weigthsystem dialogs.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-22 14:52:38 -03:00
Tomaz Canabrava
3e51476d87 Removed unused debug, and set the correct data on the delegates.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-22 14:27:41 -03:00
Dirk Hohndel
56c58bdd24 Actually remove cylinders and weightsystems from the data structures
The UI had only stubbed this code out. This adds the implementation of the
helpers and calls them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 10:12:15 -07:00
Tomaz Canabrava
75956f0f91 Added basic editing functionality for Cylinders and Weigthsystems
This patch adds basic editing functionality for Cylinders and Weigthsystems,
it still doesn't use delegates to show the data to the user in a better
way, and it does not take in consideration user preferences yet, but
it's a starting point.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-22 12:20:00 -03:00
Tomaz Canabrava
8cfb2aa237 Extend a bit the skeleton 'removes' on cylinder and weigth to help dirk.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-22 11:40:57 -03:00
Tomaz Canabrava
0b30c821ae Added a 'trash' icon on the Cylinders and Weigthsystem models
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>
2013-05-22 11:00:20 -03:00
Dirk Hohndel
3009930aee Correctly format the values shown for cylinders and weights
Make use of all the nice helpers that we have...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-21 12:03:05 -07:00
Dirk Hohndel
19586081ed Correctly use the weightsystem_none / cylinder_none helpers
Plus a couple of minor formatting changes

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-21 11:29:21 -07:00
Tomaz Canabrava
be31a53b0d Added support for visualization the Weigthssystems on the Equipment Tab.
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>
2013-05-21 09:59:41 -03:00
Tomaz Canabrava
126bc8cfa3 Added the code to show the cylinders from a dive.
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>
2013-05-21 09:33:55 -03:00
Tomaz Canabrava
d853e9bcff Make the Text on the DiveList be 30% smaller than other text
This makes the DiveList be similiar to the GTK one, comparing
the size of the text. The current code makes text on the
table be 30% smaller.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-19 10:46:49 -03:00
Henrik Brautaset Aronsen
a55a2e5d88 Don't add half a kilo/pound when adding weights
The weight management widget added 500 grams / 0.5 lbs
when a new entry was added.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-14 09:26:45 -04:00
Henrik Brautaset Aronsen
5868b37e6b Fix inaccurate weight and temperature display in dive list
A nonexisting temperature (mkelvin==0) was displayed as -273°C.
Weight was always displayed with an extra 500 grams/0.5 lbs.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-14 05:33:58 -04:00
Henrik Brautaset Aronsen
f9598f062c Clean up some typos
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>
2013-05-14 05:24:28 -04:00
Tomaz Canabrava
ee7f579242 Trying to make the DiveList selection behave correctly
And rip out all the code that Dirk put there to do that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-13 21:37:08 -05:00
Amit Chaudhuri
5105d6a333 Fix crash in DiveTripModel.
A left click in the treeview header leads to a call to createIndex which
results in a null pointer dereference.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-11 06:51:19 -07:00
Dirk Hohndel
b75a89aa86 Start populating the maintab Dive Info widget
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>
2013-05-06 20:38:38 -07:00
Dirk Hohndel
ff2ce39970 Merge branch 'tomaz-css' into Qt
Tomaz' code does a much better job of shading the dive list!

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 17:02:55 -07:00
Tomaz Canabrava
696c9ccacd Added code to Select a dive, fixed minor annoyances.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 16:56:48 -07:00
Tomaz Canabrava
82b1b04920 Test the CSS for styling the TableView
This is a test and I shouldn't be taken seriously.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 16:56:13 -07:00
Dirk Hohndel
021ef8ad09 Alternate background colors for dive list
This was written with massive hand-holding by Tomaz - actually, this was
mostly proposed via IRC by Tomaz and then implemented by me...

Right now because of the list-of-lists nature of the model we have the
small issue that every trip starts with a dark background dive, even if
the trip itself has a dark background.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 14:52:26 -07:00
Dirk Hohndel
c4e2c322a3 Set better column widths in the dive list
This code seems rather crude to me. I'm sure this could be done better.

This also makes the column alignment work again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 14:49:56 -07:00
Dirk Hohndel
f9c97ff97d Show cylinder and gas used in the Qt dive list
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 10:48:09 -07:00
Dirk Hohndel
e6ec626c97 Show trip date (with number of dives) in dive/trip list
That was easy :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-02 09:33:51 -07:00
Dirk Hohndel
6b7797140b Minor style updates
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-01 22:00:08 -07:00
Tomaz Canabrava
e5ad47e459 Merge branch 'Qt' into RenderStarsOnTable 2013-05-01 23:54:38 -03:00
Tomaz Canabrava
764a863082 Added Support for the Trips and Dives on the DiveList model.
Now the list and dives will work in the same way that the GTK
version does. The code got changed heavly because the old one
was just looking at the dives and didn't worked like a tree.

small adaptations on the list view and model delegates because
of the changes done on this model.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-01 23:51:34 -03:00
Dirk Hohndel
482bea84c2 Don't add cylinders and weightsystems past the MAX
We actually should disable the 'Add' button, I guess.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-01 14:49:17 -07:00
Dirk Hohndel
04e59a0e1c Hook up adding a weightsystem
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-01 14:43:07 -07:00
Dirk Hohndel
5c2ce0ac20 Add data and add functions for WeightModel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-01 10:11:46 -07:00
Dirk Hohndel
730e055e5a Use the existing current_dive macro in Qt code
Replicating this with the currentDive member seems to make no sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-01 10:10:16 -07:00
Tomaz Canabrava
0be521bb25 Fixed loading the stars when opening with file as argv. minor cleanup
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-04-28 08:45:22 -03:00
Tomaz Canabrava
2f4d6bbe53 Added support for showing the Stars on the DiveTable
For the stars on the dive table I had to rework a bit my
StarRating widget, because it used a pixmap for each widget
that were created. Not it uses only 2 pixmaps: the active
and inactive ones.

A new file was created named modeldelegates(h, cpp) that
should hold all delegates of the models. For the GTK / C
folks, a 'Delegate' ia s way to bypass the default behavior
of the view that's displaying the data.

I also added the code to display the stars if no delegate
is set ( good for debugging. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-04-27 12:27:27 -03:00
Dirk Hohndel
1d0d42f861 Remove the explicit UTF-8 conversions
Thanks to commit bdbfdcdfa0fb ('Ask Qt 4 to use the UTF-8 codec as the
"codec for C strings"') we no longer need the explicit UTF-8 conversion
when creating QStrings from char *.

Suggested-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-25 21:10:05 -07:00
Dirk Hohndel
98027be1c1 Minor cleanup of constructors and one accessor for DiveItem
Suggested-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-25 08:39:40 -07:00
Henrik Brautaset Aronsen
8a884d2cf7 Remove useless members of DiveItem
Just use the dive struct directly.

Suggested-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-25 07:13:19 -07:00
Henrik Brautaset Aronsen
5d4d40df91 Simplify DiveItem
The DiveItem constructor had 13 variables.  By passing it the full
dive we reduce that to 2.

[Dirk Hohndel: changed to use "struct dive *" instead of just "dive *"]

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-25 06:39:02 -07:00
Dirk Hohndel
fde0f49df8 Use Subsurface's data structures for DiveItem
We have these data structures for a reason. They provide context
about the units used and prevent mistakes. And of course they
are used everywhere else so we should use them here, too.

This also tries to display some more data and make things look
a bit more like the Gtk version when it comes to alignment and
formatting.

My guess is this will make Qt developers' eyes bleed. My apologies.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24 23:21:57 -07:00
Dirk Hohndel
ce235bd581 Correctly format depth and time
We really need those leading 0s.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24 16:03:14 -07:00
Dirk Hohndel
e156b00f05 Fix column headings for divelist
This looks better and is consistent with the Gtk version.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24 16:02:41 -07:00
Amit Chaudhuri
edab566105 Amend divetrip model to use int units
Amend the DiveItem class to avoid float in favour of int. Add getters
which return display friendly QStrings reflecting user preferences for
(e.g.) depth.

Modify DiveTripModel to support controlled alignment by column; right
align for depth and duration.

Fix problems with utf8 encoding on rating stars, degree symbols and
O2 subscript.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-24 13:06:42 -07:00
Tomaz Canabrava
a0280ae7d2 Move model related code from MainWindow and adjustments.
Moves the DiveTrip model related code to models.h

The DiveTripModel was implemented in three parts:

 DiveTripModel.h
 DiveTripModel.cpp
 MainWindow.cpp (the code to populate the model)

This patch changes the DiveTripModel from it's original
implementation to the file models.h, wich should store
all models (Dirk requested the Qt developers to not create
2 files per class, but instead to use a file for functionality,
and data-models are one functionality.)

Besides that, this code cleans up a bit the style:
removed operator<< for .push_back, const references where they apply,
moved the internal DiveItem class to the .cpp since it should be visible
only to the DiveTripModel class, and redesigned the current interface of
the model to be identical of the GTK one (used the UTF8-star and 2
subscribed, for instance).

Amit (the creator of the original code) should comment here if it's ok
with my changes.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-22 09:42:13 -07:00
Tomaz Canabrava
115ee47bfc Added the code that will load and populate the Tank Info
Added the code that will load and populate the Tank Info
ComboBox that`s used by the user to select the Cylinder
description.

Code curerntly implements more than the GTK version since
the GTK version of it was a plain-list, this one is a
table based model that can be used in ListViews ( like
we use now in the ComboBox ) but also in TableViews
( if there`s a need in the future to see everything
that`s catalogued in the Tank Info struct. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-15 17:34:44 -07:00
Dirk Hohndel
d8e11439ad Undoing the last Qtr_ hack
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>
2013-04-14 06:58:56 -07:00
Dirk Hohndel
f5c958ad73 Add Qtr_ macros that uses gettext in a tr() compatible manner
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>
2013-04-13 20:44:02 -07:00
Tomaz Canabrava
92397a2bad Started the real code on the Qt Interface.
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>
2013-04-13 14:08:16 -07:00