-
-
Notifications
You must be signed in to change notification settings - Fork 565
desktop: option to change display of decimals of depth in dive table #4432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Artifacts: |
|
Artifacts: |
|
Artifacts: |
mikeller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behaviour in a lot of places (statistics, printing templates, the mobile version, ...), without giving the user a way to control the behaviour.
In all these places, a decimal will now be shown even for large depth numbers, which might result in truncated / overlapping display.
If this is intended then it will need a thorough testing.
| <source>Show units in dive list table</source> | ||
| <translation>Einheiten in der Tauchgangsliste anzeigen</translation> | ||
| </message> | ||
| <message> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our translations are managed in Transifex, and these files are auto-generated, so they should not be updated in pull requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this changes the behaviour in a lot of places.
The function get_depth_string takes the argument "showdecimal", so the calling code can chose whether to have decimals or not! This is not changed (only in a way that depths shallower than 20m will be covered by this choice too, which only shortens some of the delivered depth strings - we could keep the <20m exception, then nothing would change, although I think this behaviour is not what I would expect, when calling with showdecimals==false).
The major change by this patch is that the new prefs.unit.show_mdecimal_table is used in divetripmodel.cpp, where the main divelist table (desktop) is set up. As I understand the code, this will neither affect the statistics, printing templates nor the mobile version. However, for some of this places, the use of show_mdecimal_table could be tested later (printing templates?)
ok, for the translation stuff, I'll have to find out how and where to edit this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this changes the behaviour in a lot of places. The function get_depth_string takes the argument "showdecimal", so the calling code can chose whether to have decimals or not! This is not changed (only in a way that depths shallower than 20m will be covered by this choice too, which only shortens some of the delivered depth strings - we could keep the <20m exception, then nothing would change, although I think this behaviour is not what I would expect, when calling with showdecimals==false).
showdecimalsin get_depth_string() seems to be hardcoded everywhere at the moment, or the default of trueused. With your proposed changes
- the
falsecase will not change; - in the
truecase, a decimal will be shown for every depth, and not just for depths up to 20m, which is the current behaviour.
Looking at the code, a lot of the use of get_depth_string()seems to be using the true case:
➜ subsurface git:(master) ✗ grep -r get_depth_string
./mobile-widgets/qmlmanager.cpp: if (get_depth_string(d->dcs[0].maxdepth.mm, true, true) != depth) {
./core/qthelper.cpp:QString get_depth_string(int mm, bool showunit, bool showdecimal)
./core/qthelper.cpp:QString get_depth_string(depth_t depth, bool showunit, bool showdecimal)
./core/qthelper.cpp: return get_depth_string(depth.mm, showunit, showdecimal);
./core/qthelper.h:QString get_depth_string(depth_t depth, bool showunit = false, bool showdecimal = true);
./core/qthelper.h:QString get_depth_string(int mm, bool showunit = false, bool showdecimal = true);
./core/divelogexportlogic.cpp: out << "\"AVG_DEPTH\":\"" << get_depth_string(s.avg_depth) << "\",";
./core/divelogexportlogic.cpp: out << "\"MIN_DEPTH\":\"" << get_depth_string(s.min_depth) << "\",";
./core/divelogexportlogic.cpp: out << "\"MAX_DEPTH\":\"" << get_depth_string(s.max_depth) << "\",";
./qt-models/diveimportedmodel.cpp: return QVariant(get_depth_string(d.maxdepth.mm, true, false));
./qt-models/cylindermodel.cpp: return get_depth_string(cyl->depth, true);
./qt-models/cylindermodel.cpp: return get_depth_string(d->gas_mod(cyl->gasmix, modpO2, m_or_ft(1, 1)), true);
./qt-models/cylindermodel.cpp: return get_depth_string(d->gas_mnd(cyl->gasmix, prefs.bestmixend, m_or_ft(1, 1)), true);
./qt-models/yearlystatisticsmodel.cpp: return get_depth_string(stats_interval.avg_depth);
./qt-models/yearlystatisticsmodel.cpp: return get_depth_string(stats_interval.combined_max_depth.mm / stats_interval.selection_size);
./qt-models/yearlystatisticsmodel.cpp: return get_depth_string(stats_interval.min_depth);
./qt-models/yearlystatisticsmodel.cpp: return get_depth_string(stats_interval.max_depth);
./qt-models/yearlystatisticsmodel.cpp: QString label = QString(tr("%1 - %2")).arg(get_depth_string(i * (STATS_DEPTH_BUCKET * 1000), true, false),
./qt-models/yearlystatisticsmodel.cpp: get_depth_string((i + 1) * (STATS_DEPTH_BUCKET * 1000), true, false));
./qt-models/divetripmodel.cpp: case MobileListModel::DepthRole: return get_depth_string(d->dcs[0].maxdepth.mm, true, true);
./qt-models/divetripmodel.cpp: case MobileListModel::DepthDurationRole: return QStringLiteral("%1 / %2").arg(get_depth_string(d->dcs[0].maxdepth.mm, true, true),
./qt-models/divetripmodel.cpp: return get_depth_string(d->maxdepth, prefs.units.show_units_table);
./desktop-widgets/templatelayout.cpp: return get_depth_string(object->avg_depth);
./desktop-widgets/templatelayout.cpp: return get_depth_string(object->min_depth);
./desktop-widgets/templatelayout.cpp: return get_depth_string(object->max_depth);
./desktop-widgets/templatelayout.cpp: return get_depth_string(d->dcs[0].maxdepth.mm, true, true);
./desktop-widgets/templatelayout.cpp: return get_depth_string(d->dcs[0].meandepth.mm, true, true);
./desktop-widgets/tab-widgets/TabDiveStatistics.cpp: ui->depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, true));
./desktop-widgets/tab-widgets/TabDiveStatistics.cpp: ui->depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, true));
./desktop-widgets/tab-widgets/TabDiveStatistics.cpp: ui->depthLimits->setAverage(get_depth_string(stats_selection.combined_max_depth.mm / stats_selection.selection_size, true));
./desktop-widgets/tab-widgets/TabDiveStatistics.cpp: ui->depthLimits->setAverage(get_depth_string(stats_selection.max_depth, true));
./desktop-widgets/tab-widgets/TabDiveInformation.cpp: ui->maximumDepthText->setText(get_depth_string(currentDive->maxdepth, true));
./desktop-widgets/tab-widgets/TabDiveInformation.cpp: ui->averageDepthText->setText(get_depth_string(currentDive->meandepth, true));
./desktop-widgets/tab-widgets/TabDiveNotes.cpp: ui.depth->setText(get_depth_string(currentDive->maxdepth, true));
./desktop-widgets/tab-widgets/TabDiveNotes.cpp: ui.depth->setText(get_depth_string(currentDive->maxdepth, true));
./profile-widget/diveprofileitem.cpp: item->set(get_depth_string(entry.depth, true), color);
./profile-widget/diveprofileitem.cpp: text->set(get_depth_string(lrint(lastMeanDepth), true), getColor(TEMP_TEXT));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see below... that's about what I found by grepping through the code...
my approach would be to change all these hardcoded true's to use the show_mdecimal_table property.
if then changing the behaviour in a way, that "false" would actually return decimals for depth <20m, the overall result should be exactly the same. The "true" case would then return decimals for all depths (which would need testing for the optical results).
I'll continue on that, as soon as I'm able to compile the mobile version... to do the required testing.
I consider this as a lesson in subsurface and its development tools, otherwise this would be a lot of wasted time for a couple of centimetres ;-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, that's what I get for looking into emails before going to bed, and then responding first thing in the morning. 😆
my approach would be to change all these hardcoded true's to use the show_mdecimal_table property. if then changing the behaviour in a way, that "false" would actually return decimals for depth <20m, the overall result should be exactly the same.
Yes, that sounds good.
One thought about a potential alternative way of doing this: We could your bool preference to an int, and use it as 'Round to nearest meter for depths greater than' - this will give people flexibility instead of being '20m or nothing'.
And one more thought - do we want to grey out this preference if users have selected 'feet' as the depth unit?
The "true" case would then return decimals for all depths (which would need testing for the optical results). I'll continue on that, as soon as I'm able to compile the mobile version... to do the required testing.
Have a look at https://github.com/subsurface/subsurface/blob/master/packaging/android/README.md#in-a-container - the setup to build the android version is normally quite easy, as all that is needed is docker, and the build itself happens inside a container that comes with all prerequisites installed.
I consider this as a lesson in subsurface and its development tools, otherwise this would be a lot of wasted time for a couple of centimetres ;-/
Another way to look at this is that in volunteered open source development we get the liberty of obsessing over a couple of centimetres. 😉
The qthelper get_depth_string does now what is expected, depending on the given bool showdecimal (<20m exception removed). A preference (units.show_mdecimal_table) was introduced to change whether decimals are displayed for (metric) max depths in the dive list. the setting can be change via UI at preferences/units. Signed-off-by: Hannes Krueger <hanneskrueger@gmail.com>
Signed-off-by: Hannes Krueger <Hannes.Krueger@gmail.com>
|
Artifacts: |
|
Artifacts: |
|
Artifacts: |
|
ohh, silly me overlooked some calls to get_depth_string with the showdecimal=true argument. There is one 'internal' use of get_depth_string in a string comparison (in QMLManager::CheckDepth). I don't overlook, what the consequences will be, if decimals (<20m) change here... I'll further investigate and test... |
Make all calls to get_depth_string use explicit definition regarding showdecimals. For on-screen usage (especially dive list and profile) use the user-setting via prefs.units.show_mdecimal. For statistics, details, etc. decimals are used. Signed-off-by: Hannes Krueger <Hannes.Krueger@gmail.com>
|
The latest iteration uses explicit calls (regarding showdecimal) to get_depth_string everywhere. The look of the dive list and profile is more tidy than before with a mix of decimals / no decimals. For now, on mobile there are no decimals in the dive list/profile, once I found out how to mess with the mobile ui, I'll add that too. Open for discussion and comments on this feature. |
|
Artifacts: |
|
Artifacts: |
|
Artifacts: |
I am a bit wary of the potential of hitting Chesterton's fence with this one - there might be a reason why the existing behaviour was implemented, and users might rely on it. @dirkhh do you have any insights into this? |
|
existing behavior was implemented because it reflected the general user preference. In other words - the reason for this behavior was sanity and the sound reasoning that whatever we choose would be hated and loved by some subset of the users... and this one seemed to create a decent compromise. |
That's what I suspected when I brought up Chesterton's fence. |
The qthelper get_depth_string does now what is expected, depending on the given bool showdecimal (<20m exception removed). A preference (units.show_mdecimal_table) was introduced to change whether decimals are displayed for (metric) max depth values in the dive list. The setting can be change via UI at preferences/units.
This is a more general approach to #4431.
Describe the pull request:
Pull request long description:
Changes made:
Related issues:
Additional information:
Release note:
Documentation change:
Mentions: