aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
AgeCommit message (Collapse)Author
2013-12-03Text cleanup to amend lacking consistencyGravatar Henrik Brautaset Aronsen
- Removed the "Visible:" header on the column selector. It doesn't have to be there, and it's not in the similar equipment column selector - PO2 --> pO₂ (and others) - Use same initial case in the units selector in preferences Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02Don't store translated standard weight system namesGravatar Dirk Hohndel
For the names that we have in our "default set" we need to store the English name so Subsurface will "do the right thing" when opening the file in a different locale. With manually entered names in a local language there's not much we can do. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02Remove unused variableGravatar Anton Lundin
Leftover from previous code that called get_gas_string Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02Third time's a charm: translating weight system descriptionGravatar Dirk Hohndel
Still trying to fix the same issue that I already tried to address in commit e0b70b82cad9 ("Fix translation of weightsystem names") and before in commit dc03b7e7d689 ("We need the correct context to translate event names"). I missed the WeightModel. Hopefully this was indeed the real fix. Fixes #312 (I know, I keep saying that) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-02Fix translation of weightsystem namesGravatar Dirk Hohndel
This is very much the same as in commit dc03b7e7d689 ("We need the correct context to translate event names"). I didn't pay enough attention when reading the bug report and missed that the weight system names were also not correctly translated. Fixes #312 (I hope this time for real) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Fix all leak-at-exit from singletons in SubsurfaceGravatar Thiago Macieira
Subsurface creates a lot of singleton instances on demand, but nothing ever deleted them. Since they are singletons, these memory allocations are technically not leaks. However, they clutter the output in valgrind and other memory analysers, hiding the real issues. The solution is to delete these items at exit. For the models and for gettextFromC, the solution is to use a QScopedPointer, which will delete its payload when it gets destroyed. For the dialogs and other widgets, we can't do that: they need to be deleted before QApplication exits, so we just set the parent in all of them to the main window. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Print: fix wrong Max. CNS / SAC columnsGravatar Lubomir I. Ivanov
Swap the places of the CNS and SAC values in the profile tables. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Merge branch 'print' of github.com:neolit123/subsurfaceGravatar Dirk Hohndel
2013-11-30Fix a crash when no trip existsGravatar Miika Turkia
When there are no trips at all, we have to skip the Yearly statistics alltogether, including the header line (that should display all the dives added together). Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Print: yet another font adjustment for the profile tableGravatar Lubomir I. Ivanov
We now only use a slightly large font for the "Dive #" entry. All other font sizes remain at 9px. Another change is that we now attempt to use 11px for individual row height. This makes the table at least 12px bigger (n_rows * increment), but does not cut letters like 'g', which go slightly bellow the font baseline. Perhaps this can be improved later by adjusting the font and row sizes again. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Minor text cleanupGravatar Henrik Brautaset Aronsen
Use the same case for the first letter in the dive table column headers, use '%' for both gases in the planner, and show "Start time" instead of "Starttime". Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Print: update the values for DM, buddy, suit, etcGravatar Lubomir I. Ivanov
We update the values for divemaster, buddy and etc... Rating and visibility are currently displayed as "x / 5" values. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: update printing for gas, CNS, SAC and weightsGravatar Lubomir I. Ivanov
Following the new layout for the profile print, we separate the used gas like so: AL80 / EAN33 / ... Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: add more table headings for Divemaster, Buddy, etc..Gravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: set correct row/column location for profile notesGravatar Lubomir I. Ivanov
NOTE: also comment out the old cylinder/weight printing code... Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: update the profile print table Gas, SAC, CNS titlesGravatar Lubomir I. Ivanov
This only updates the titles to correct column offsets. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: remove the helper function to truncate stringsGravatar Lubomir I. Ivanov
ProfilePrintPmode::truncateString() was not really needed, because long text *should* be trunctated by the table itself. Also we now are going to have multiple lines for notes, so the auto-trim should work. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: adjustments to font sizes and alignmentGravatar Lubomir I. Ivanov
The new profile table requires different alignment and different font sizes for specific cells. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-30Print: setup for a new profile table layoutGravatar Lubomir I. Ivanov
- Adjust the new rows and column count - Set new row and column spans Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-11-29Units should be lower caseGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-27Show/save weights up to and including last validGravatar Anton Lundin
Previous show and save code would have aborted at the first invalid weight system. This makes sure we save and show all weight systems up until and including the last valid. If we had: integrated: 1kg belt: 2kg ankle: 3kg And changed belt to 0 kg, we would have only saved integrated 1kg, and nothing about the belt or the ankle weights. This will save all of them, and show all of them. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-27Show cylinders up to and including the last validGravatar Anton Lundin
Previous code aborted at the first invalid cylinder. This instead finds the last valid and prints all the ones up until that one. Fixes #295 Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-23Adding trip based statisticsGravatar Miika Turkia
This adds trip based statistics to the Yearly Statistics view. Signed-off-by: Miika Turkia <miika.turkia@nixu.fi> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-22Small code cleanup on the CylindersModelGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-22Better positioning of the text on Weightsystems table.Gravatar Tomaz Canabrava
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-22Added a bunch of tooltips where I thought it was sane.Gravatar Tomaz Canabrava
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-22Better positioning of the text on the table cells.Gravatar Tomaz Canabrava
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-21Work around QMessageBox not showing its title on MacGravatar Dirk Hohndel
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-21Quiet down warning about return in non-voidGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19Small whitespace cleanupGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19Fix trip summary line in dive listGravatar Dirk Hohndel
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-19Sanity check on gas percentagesGravatar Dirk Hohndel
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-18Do not let the dive have the 0 value.Gravatar Tomaz Canabrava
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-18Make it posible to renumber dives.Gravatar Tomaz Canabrava
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-16Fix wrong handling of Dive Table, and revert some wrong changes.Gravatar Tomaz Canabrava
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-15This moves the removal code to the model.Gravatar Tomaz Canabrava
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-15Use the correct font for the Air Types Model.Gravatar Tomaz Canabrava
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-15Correctly handle changes on the CylinderModel to update the AirModel.Gravatar Tomaz Canabrava
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-14Fix edition of alphanumeric input on equipments.Gravatar Tomaz Canabrava
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-13Connect changes in the tanks with the dive that is being addedGravatar Dirk Hohndel
- 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-12Use existing helper functionGravatar Dirk Hohndel
And remove spurious extra ';' Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12Add depth colum to cylinder modelGravatar Dirk Hohndel
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-11Fix crash when cancelling dive add on empty dive listGravatar Dirk Hohndel
Don't pass NULL dives around. Fixes #231 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10Show a cylinder widget in the dive plannerGravatar Dirk Hohndel
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-10-16Helpers: move some date related function to qt-gui.cppGravatar Lubomir I. Ivanov
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-15Printing adjustmentsGravatar Robert Helling
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-15printlayout.cpp: Increase the font size in tables bellow profileGravatar Lubomir I. Ivanov
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-13Models: fix two potential crashesGravatar Lubomir I. Ivanov
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-13Adds missing "EndPress" column header for cylinder tableGravatar Tim Wootton
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-11Finish clearing up the TableModelsGravatar Tomaz Canabrava
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>