From e96b9e8268b6ab60c93cd4f7e21d281c05f7d580 Mon Sep 17 00:00:00 2001 From: boutinb Date: Thu, 28 Nov 2024 11:18:16 +0100 Subject: [PATCH 1/5] Show the right implicit empty values in tooltip If you set a nominal or ordinal variable in a scale VariablesList, a tooltip tells you how the values are transformed into scale. It gives also a list of 'implicit' empty values: that is the not empty values that could not be converted into a double value. This list was not correct, it gave all the convertable values. --- CommonData/column.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/CommonData/column.cpp b/CommonData/column.cpp index 2161284d5a..b701edf0db 100644 --- a/CommonData/column.cpp +++ b/CommonData/column.cpp @@ -2372,20 +2372,27 @@ stringvec Column::previewTransform(columnType transformType) } { - std::stringstream someEmptyValues; + std::stringstream someImplicitEmptyValues; if(transformType == columnType::scale && labelsTempCount() > _labelsTempNumerics) { int count = 0; for(Label * label : _labels) - if(!label->isEmptyValue() && count < showThisMany) - someEmptyValues << (count++ > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"'; - else if(!label->isEmptyValue() && count++ == showThisMany) - someEmptyValues << ", ..."; + { + if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->label())) + { + if(count < showThisMany) + someImplicitEmptyValues << (count++ > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"'; + else if(count++ == showThisMany) + someImplicitEmptyValues << ", ..."; + else + break; // Do not need to loop further over the labels. + } + } } - out.push_back(someEmptyValues.str()); + out.push_back(someImplicitEmptyValues.str()); } return out; From 167cb1cd088a6068890763741304da2f1b77d731 Mon Sep 17 00:00:00 2001 From: Joris Goosen Date: Thu, 28 Nov 2024 17:29:56 +0100 Subject: [PATCH 2/5] The implicit empty values are derived from value not being doubles also make sure empty values are also checked on the original value now --- CommonData/column.cpp | 2 +- CommonData/label.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CommonData/column.cpp b/CommonData/column.cpp index b701edf0db..98c9d15aa3 100644 --- a/CommonData/column.cpp +++ b/CommonData/column.cpp @@ -2380,7 +2380,7 @@ stringvec Column::previewTransform(columnType transformType) for(Label * label : _labels) { - if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->label())) + if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->originalValueAsString())) { if(count < showThisMany) someImplicitEmptyValues << (count++ > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"'; diff --git a/CommonData/label.cpp b/CommonData/label.cpp index 15103c9a43..cf3949fddc 100644 --- a/CommonData/label.cpp +++ b/CommonData/label.cpp @@ -248,7 +248,7 @@ std::string Label::labelIgnoreEmpty() const bool Label::isEmptyValue() const { - return _column->isEmptyValue(_label); + return _column->isEmptyValue(originalValueAsString(false)) || _column->isEmptyValue(label()); } std::string Label::originalValueAsString(bool fancyEmptyValue) const From 52eaf18bef748185f3a6729ef8b5233cb8d9f764 Mon Sep 17 00:00:00 2001 From: Joris Goosen Date: Thu, 28 Nov 2024 17:33:52 +0100 Subject: [PATCH 3/5] remove ugly parentheses --- CommonData/column.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CommonData/column.cpp b/CommonData/column.cpp index 98c9d15aa3..c9d9625c4e 100644 --- a/CommonData/column.cpp +++ b/CommonData/column.cpp @@ -2379,7 +2379,6 @@ stringvec Column::previewTransform(columnType transformType) int count = 0; for(Label * label : _labels) - { if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->originalValueAsString())) { if(count < showThisMany) @@ -2388,8 +2387,7 @@ stringvec Column::previewTransform(columnType transformType) someImplicitEmptyValues << ", ..."; else break; // Do not need to loop further over the labels. - } - } + } } out.push_back(someImplicitEmptyValues.str()); From 02910890aa90235edfdcc62e6043acb3acd65702 Mon Sep 17 00:00:00 2001 From: Joris Goosen Date: Thu, 28 Nov 2024 17:38:12 +0100 Subject: [PATCH 4/5] less crazy if elses --- CommonData/column.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CommonData/column.cpp b/CommonData/column.cpp index c9d9625c4e..99f52ccfd6 100644 --- a/CommonData/column.cpp +++ b/CommonData/column.cpp @@ -2381,12 +2381,13 @@ stringvec Column::previewTransform(columnType transformType) for(Label * label : _labels) if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->originalValueAsString())) { - if(count < showThisMany) + if(count++ < showThisMany) someImplicitEmptyValues << (count++ > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"'; - else if(count++ == showThisMany) - someImplicitEmptyValues << ", ..."; else + { + someImplicitEmptyValues << ", ..."; break; // Do not need to loop further over the labels. + } } } From 0777faa02940cc802a3a1b4fbdf1d03188083299 Mon Sep 17 00:00:00 2001 From: Joris Goosen Date: Thu, 28 Nov 2024 17:40:50 +0100 Subject: [PATCH 5/5] also less count++ --- CommonData/column.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CommonData/column.cpp b/CommonData/column.cpp index 99f52ccfd6..a2b3462d5f 100644 --- a/CommonData/column.cpp +++ b/CommonData/column.cpp @@ -2381,13 +2381,15 @@ stringvec Column::previewTransform(columnType transformType) for(Label * label : _labels) if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->originalValueAsString())) { - if(count++ < showThisMany) - someImplicitEmptyValues << (count++ > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"'; + if(count < showThisMany) + someImplicitEmptyValues << (count > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"'; else { someImplicitEmptyValues << ", ..."; break; // Do not need to loop further over the labels. } + + count++; } }