aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
AgeCommit message (Collapse)Author
2014-03-23Enable parts of planner based on defineGravatar Anton Lundin
In bf205726 DEPTH/Switch at was disabled by commenting out that code. This puts it back behind ifdefs Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15Correctly check if tank is in useGravatar Dirk Hohndel
We always checked if the tank was in use by the planner / dive editor - even if we were not in dive edit mode. With this patch, when not in dive edit mode, we check our cylinder "used" flag instead. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05Another small tweak to whitespace toolGravatar Dirk Hohndel
clang-format doesn't appear to reindent multi line #define statements correctly - so this hopefully will clean those up. The included whitespace corrections to the code should stay in place when using the updated tool. This includes cleaning up some multi-line comments that were messed up the last time around as well as a few other minor changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03Fix possibly uninitialized valueGravatar Dirk Hohndel
I'm not sure about this one. It's possible that there's something happening behind the scenes that I don't understand. But let's just initialize this to 0 and be sure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Replace mainWindow() with MainWindow::instance()Gravatar Boris Barbulovski
C++ style of accessing single instance class object. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Whitespace and dead code cleanupGravatar Dirk Hohndel
The coding style for switch isn't the prettiest, but let's at least keep things consistent. Also, those ugly break statements never got reached, anyway. And there was no need to re-declare and re-generate currentString. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11Update #include statement for QStringListModelGravatar Boris Barbulovski
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26Disable the switching depth column for cylindersGravatar Dirk Hohndel
Since the planner is disabled this column isn't needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Fix some memory leaks.Gravatar Boris Barbulovski
Memory leaks were caused by broken parent/child relations. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Whitespace and coding style updatesGravatar Dirk Hohndel
Another futile attempt to cleanup the code and make coding style and whitespace consistent. I tried to add a file that describes the key points of our coding style. I have no illusions that this will help the least bit... This commit should ONLY change whitespace Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15Fix "hide unused cylinder" behaviorGravatar Dirk Hohndel
There are at least two scenarios where our old code was flat out wrong. If you manually add a cylinder (because you may want to switch to it in the profile), then at least until the next time you restart Subsurface this cylinder should be shown. Also, when you switch to a cylinder by adding a gas switch event on the profile, that change should then make that cylinder visible. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15In Qt5 reset() is depricated.Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15Convert to TRUE/FALSE to stdbools true/falseGravatar Anton Lundin
I had problems with this one on Qt5. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-11Don't show tanks that aren't used during a diveGravatar Dirk Hohndel
Some dive computers will always download all tanks that they store, not just the ones used in a dive. Most people only want to see the tanks that they actually used during the dive (and for the others there's an option to go back to the old behavior, just in case). All this is only in memory / during runtime. If the dive computer provided the extra data we will not throw it away. Fixes #373 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09Remove now stale arguments to "CHANGED()" macroGravatar Linus Torvalds
We now never remove units or percentage signs, and always just compare the string data, so we should remove the hacky arguments that are no longer used. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09Add and use 'string_to_fraction()' helper converter functionGravatar Linus Torvalds
This matches the pattern of unit conversion, and will allow us to remove all the code that uses the old complex "CHANGED()" macro that tries to remove units or percent signs. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09Add unit-aware cylinder size string parsercGravatar Linus Torvalds
Whittling down on the string parsing that doesn't check user-specified units. Still need to handle temperatures (and will do percentages to match the pattern too), but this is getting us closer to always honoring user-specified units. With this you can say that you have a "10l" cylinder at "3000psi", and it will do the right thing (it's basically a 72 cuft cylinder in imperial measurements). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09Add unit-aware conversion of pressure dataGravatar Linus Torvalds
This just adds (and uses) a string_to_pressure() to parse pressure units correctly when filling in cylinder pressures. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08Add a string_to_depth() helper function to match our string_to_weight oneGravatar Linus Torvalds
It's currently only used for the setting of the cylinder switching depth, but now that one should work with user-specified units (so you can set a max depth in feet even if you use metric, and vice versa). In the future, if we also make the unit preferences something you can pass in (with user preferences as a default argument value), we might want to use this for parsing the XML too, so that we'd honor explicit units in the XML strings. But the XML input unit preferences are not necessarily at all the same as the user preferences, so that does require us to extend the conversion functions to do possibly explicit unit preference selection. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08const'ify our strtod() helper functionsGravatar Linus Torvalds
The C library doesn't use const char pointers for legacy reasons (and because you *can* modify the string the end pointer points to), but let's do it in our internal implementation just because it's a nice guarantee to have. We actually used to have a non-const end pointer and replace a decimal comma with a decimal dot, but that was because we didn't have the fancy "allow commas" flags. So by using our own strtod_flags() function, we can now keep all the strings we parse read-only rather than modify them as we parse them. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08Make 'string_to_grams()' use proper type safe typesGravatar Linus Torvalds
Make it use 'weight_t' and hide the "grams" part inside the type. That was the whole point of the weight_t type, after all. Returning a "double" was always bogus, since we internally always do integer grams (and the function actually used "rint()" to get all the rounding right anyway). As a result, it's now called "string_to_weight()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07Not everything can be done with the diveIdGravatar Dirk Hohndel
In commit c3fe1a9e9f79 ("Get rid of pointers to dive structures in the UI") I was a bit too aggressive moving away from pointers to dives. This is only needed for pointers that are held across operations that could change the dive_table. I figured that it wouldn't hurt to get rid of some more pointers as well, but it turns out I was wrong. The current dive that we store in the Cylinder and Weight models can be a dive that isn't in the dive_table at all: the multiEditEquipmentPlaceholder. And when using the diveId we end up finding the original dive in the dive_table and therefore modify the wrong structure. This undoes two thirds of the above mentioned commit. Reported-and-analyzed-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07Restructure overly agressive Q_ASSERTGravatar Dirk Hohndel
Turns out this function can be called when there is no valid dive - so only protect those parts that dereference the dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-07Get rid of pointers to dive structures in the UIGravatar Dirk Hohndel
The assumption that the pointer will keep pointing to a valid structure is fundamentally flawed. And even if that is true today, it might change in the future - just don't do it. Use the diveId instead. The exception is when you own the structure and use it within one UI interaction during which any way to change the dive_table is disabled (e.g., while adding / editing a dive). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-03Parse localized weight unitsGravatar Dirk Hohndel
We have the wonderful Qt string functions. Let's use them to make the code simpler and easier to read. Suggested-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02Fix imperial cylinder sizes in equipment tabGravatar Linus Torvalds
The imperial cylinder sizes are not just in cubic feet: they are in cubic feet of gas at STP. So the imperial/metric difference is not just about converting blindly from liters to cubic feet, you also have to take the working pressure of the cylinder into account. This was broken by commit f9b7c5dfe9d0 ("Make units in cells consistant in CylindersModel"), because those poor sheltered Swedish people have never had to work with the wondrous imperial cylinder sizing, and think that units should make _sense_. Hah. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02Allow the user to specify weight units explicitlyGravatar Linus Torvalds
Instead of always assuming that all numbers are in the users locale weight units, allow the user to say "kg" or "lbs" explicitly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-02Ignore units when entering values for equipmentGravatar Dirk Hohndel
Note that this is IMHO the wrong fix. Because we shouldn't just ignore the units, we should do correct conversions. Before this patch, if the user is in metric mode and then types in 4.5kg or 10lbs for a weight, Subsurface ignores the entry and throws it away. Very much not the expected behavior. With this patch Subsurface will take the value, but ignore the unit and assume that the user meant kg (since it's in metric mode). Still not really the expected behavior for 10lbs (which is now 10kg), but if the user typed 4.5kg (which admittedly is much more likely), then with this change Subsurface will do the right thing. Fixes #395 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Kill the use of CSS - Fixes a Lot of issues on dark color schemes.Gravatar Tomaz Canabrava
The css was done by me in the first days of subsurface for Qt, and it was a code that I was never proud of. Mostly because I tougth at the time that it was better to write it into CSS than to create a new class just to take care of the size of the default cell height on a tree view. Now I see that it was a biased approach since it created issues on dark color schemes and it also didn't make a 'native' experience on Gnome or OSX, only on KDE. This fixes that. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07Build language list from Subsurface translationsGravatar Sergey Starosek
On Windows platform translation/ folder contains Qt translation files as well. This results in extra languages in preferences. From now we filter these translations and choose only those matching ^subsurface_*.qm$ Fixes #339 Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07Language chooser improvementsGravatar Sergey Starosek
Show language instead of country, sort the list. Show country in brackets to avoid ambiguity for locales like de_DE and de_CH. Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07Make units in cells consistant in CylindersModelGravatar Anton Lundin
Now they all have units in the cells. Fixes #259 Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Do not change the current DirectoryGravatar Tomaz Canabrava
Qt has a really strange API for directories. when you create a QDir and set's the currentDir on *that* QDir you created, it's for the whole application and not just for that variable. Then when the variable is out of scope, the directory doesn't change back - ugh. The solution is not to call setCurrentDir on the newly created QDir (which was quite good since it's also a code cleanup. ) [Dirk Hohndel: modified to undo the far less elegant fix I had made in an earlier commit] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Don't change working directory when looking for tranlationsGravatar Dirk Hohndel
And only replace 'bin' if there is a bin in the path... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Added 'English' and 'Use System Default' options.Gravatar Tomaz Canabrava
These complete the ability to select languages from the preferences panel. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Added a language preference to the Settings.Gravatar Tomaz Canabrava
When the user first opens the application the default language is selected; this can be changed to a hardcoded one by going to system preferences and choosing the one you want. Restart required. Fixes #136 [Dirk Hohndel: whitespace fixes, removed qDebug() call, rephrased the message displayed prompting the user to restart.] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06Print: add a safe-guard if table print rows are too bigGravatar Lubomir I. Ivanov
We do not support rows larger than a single page as the PrintLayout algorithm will enter an infinite loop, therefore we put a limit of 15 lines for the location text. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>