Commit 790ec1a3 authored by André Hoarau's avatar André Hoarau 🍆

Merge branch '165-erreur-d-unites-dans-les-pdf-commandes-de-semences' into 'master'

Resolve "Erreur d'unités dans les pdf commandes de semences"

Closes #165

See merge request !97
parents d636155c 34809536
......@@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Improve the translation infrastructure.
### Fixed
- *PDF* − Fix bad unit for weights : kg instead of g (#165).
- *Planting map* − Fix duplication bug when using complete dates (#175).
- *Field map* - Fix automatic numbering of location names (#164).
- Fixed date picker's bad year selection (#171).
......
......@@ -12,6 +12,7 @@ Tous les changements importants seront documentés dans ce fichier.
- Amélioration de l'infrastructure des traductions.
### Corrections
- *PDF* − Correction des mauvaises unités pour les poids : kg au lieu de g (#165).
- *Plan de culture* − Correction du bogue de duplication lors de l'utilisation
de dates complètes (#175).
- Correction de la numérotation automatique des emplacements (#164).
......
......@@ -238,12 +238,16 @@ void TablePrinter::drawRow(int row)
int flags = Qt::AlignVCenter | Qt::TextWordWrap;
switch (colInfo.type) {
case TablePrinter::Weight: {
double weight = value.toDouble();
if (weight > 1000) {
weight = std::floor(weight / 10) / 100;
bool ok = true;
double weight = value.toDouble(&ok);
if (qIsInf(weight)) {
string = "−";
} else if (weight >= 1000) {
weight = std::ceil(weight / 10) / 100;
string = QString("%L1 kg").arg(weight);
} else {
string = QString("%L1 g").arg(std::ceil(weight * 10) / 10);
}
string = QString("%L1 g").arg(std::floor(weight * 100) / 100);
flags |= Qt::AlignRight;
break;
}
......
......@@ -487,9 +487,11 @@ Page {
model.variety,
model.seed_company,
"%L1".arg(seedsRadioButton.checked ? model.seeds_number : model.plants_needed),
model.seeds_quantity > 1000
? qsTr("%L1 kg").arg(Math.round(model.seeds_quantity * 0.1) / 100)
: qsTr("%L1 g").arg(Math.round(model.seeds_quantity * 100) / 100)
isFinite(model.seeds_quantity)
? (model.seeds_quantity >= 1000
? qsTr("%L1 kg").arg(Math.ceil(model.seeds_quantity / 10) / 100)
: qsTr("%L1 g").arg(Math.ceil(model.seeds_quantity * 10) / 10))
: ""
]
color: rowMouseArea.containsMouse
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment