Skip to content

Commit

Permalink
disable the requisite edit-column in variablewindow label editor
Browse files Browse the repository at this point in the history
also make sure that it will update the generated filter for labels after a computed column is updated
and make sure the labelfiltergenerator actually compares with labels (also for scale columns)
  • Loading branch information
JorisGoosen committed Nov 6, 2024
1 parent 4ba1d80 commit 671e8b4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
17 changes: 4 additions & 13 deletions CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ bool Column::overwriteDataAndType(stringvec data, columnType colType)

setValues(values, labels, 0, &changes);
setType(colType);
labelsTempReset();

labelsHandleAutoSort();

return changes;
}
Expand Down Expand Up @@ -1711,8 +1714,6 @@ Labelset Column::labelsByValue(const std::string & value) const
return Labelset(found.begin(), found.end());
}



Label * Column::labelByValueAndDisplay(const std::string &value, const std::string &labelText) const
{
JASPTIMER_SCOPE(Column::labelsByValueAndDisplay);
Expand Down Expand Up @@ -1816,18 +1817,8 @@ void Column::labelsOrderByValue(bool doDbUpdateEtc)
{
JASPTIMER_SCOPE(Column::labelsOrderByValue);

bool replaceAllDoubles = false;
static double dummy;

for(Label * label : labels())
if(!label->isEmptyValue() && !(label->originalValue().isDouble() || ColumnUtils::getDoubleValue(label->originalValueAsString(), dummy)))
{
replaceAllDoubles = true;
break;
}

if(replaceAllDoubles)
replaceDoublesTillLabelsRowWithLabels(labelsTempCount());
replaceDoublesTillLabelsRowWithLabels(labelsTempCount());

doublevec asc = valuesNumericOrdered();
auto alpha = valuesAlphabeticalOffsets();
Expand Down
23 changes: 15 additions & 8 deletions Desktop/components/JASP/Widgets/LabelEditorWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ FocusScope
}
}

property real filterColWidth: 60 * jaspTheme.uiScale
property real remainingWidth: width - filterColWidth
property real valueColWidth: Math.min(columnModel.valueMaxWidth + 10, remainingWidth * 0.5) * jaspTheme.uiScale
property real labelColWidth: Math.min(columnModel.labelMaxWidth + 10, remainingWidth * 0.5) * jaspTheme.uiScale
property int selectedRow: -1
property real filterColWidth: 60 * jaspTheme.uiScale
property real remainingWidth: width - filterColWidth
property real valueColWidth: Math.min(columnModel.valueMaxWidth + 10, remainingWidth * 0.5) * jaspTheme.uiScale
property real labelColWidth: Math.min(columnModel.labelMaxWidth + 10, remainingWidth * 0.5) * jaspTheme.uiScale
property int selectedRow: -1

property bool isBasicComputed: columnModel.computedType == "rCode" || columnModel.computedType == "constructorCode"
property bool valueEditable: !isBasicComputed || columnModel.currentColumnType != "scale"
property bool labelEditable: !isBasicComputed || columnModel.currentColumnType == "scale"
property bool filterEditable: true // columnModel.computedType == "notComputed"

columnHeaderDelegate: Item
{
Expand All @@ -85,7 +89,7 @@ FocusScope
{
text: qsTr("Filter")
font: jaspTheme.font
color: jaspTheme.textEnabled
color: levelsTableView.filterEditable ? jaspTheme.textEnabled : jaspTheme.textDisabled
width: levelsTableView.filterColWidth;
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignHCenter
Expand All @@ -100,7 +104,7 @@ FocusScope
{
text: qsTr("Value")
font: jaspTheme.font
color: jaspTheme.textEnabled
color: levelsTableView.valueEditable ? jaspTheme.textEnabled : jaspTheme.textDisabled
width: levelsTableView.valueColWidth;
leftPadding: 3 * jaspTheme.uiScale
anchors.verticalCenter: parent.verticalCenter
Expand All @@ -115,7 +119,7 @@ FocusScope
{
text: qsTr("Label")
font: jaspTheme.font
color: jaspTheme.textEnabled
color: levelsTableView.labelEditable ? jaspTheme.textEnabled : jaspTheme.textDisabled
leftPadding: 3 * jaspTheme.uiScale
anchors.verticalCenter: parent.verticalCenter
width: levelsTableView.labelColWidth;
Expand Down Expand Up @@ -208,6 +212,7 @@ FocusScope
height: parent.height
z: -1
cursorShape: Qt.PointingHandCursor
enabled: levelsTableView.filterEditable


onClicked:
Expand Down Expand Up @@ -251,6 +256,7 @@ FocusScope
width: levelsTableView.valueColWidth;
height: parent.height
clip: true
enabled: levelsTableView.valueEditable

MouseArea
{
Expand Down Expand Up @@ -336,6 +342,7 @@ FocusScope
width: levelsTableView.remainingWidth - (levelsTableView.valueColWidth + 2 + (2 * levelsTableView.itemHorizontalPadding)) //+2 for line-rectangles!
height: parent.height
clip: true
enabled: levelsTableView.labelEditable

MouseArea
{
Expand Down
2 changes: 2 additions & 0 deletions Desktop/data/computedcolumnmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ void ComputedColumnModel::computeColumnSucceeded(QString columnNameQ, QString wa

if(dataChanged)
checkForDependentColumnsToBeSent(columnNameQ);

DataSetPackage::pkg()->labelFilterChanged(); //in case the user had enabled some labelfilter on the computed column?
}

void ComputedColumnModel::computeColumnFailed(QString columnNameQ, QString errorQ)
Expand Down
2 changes: 1 addition & 1 deletion Desktop/data/datasetpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ bool DataSetPackage::initColumnWithStrings(QVariant colId, const std::string & n
column -> setType(column->type() != columnType::unknown ? column->type() : desiredType == columnType::unknown ? suggestedType : desiredType);
column -> endBatchedLabelsDB();

if(PreferencesModel::prefs()->orderByValueByDefault())
if(PreferencesModel::prefs()->orderByValueByDefault())
column->labelsOrderByValue();

return anyChanges || column->type() != prevType;
Expand Down
4 changes: 2 additions & 2 deletions Desktop/data/labelfiltergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ std::string labelFilterGenerator::generateLabelFilter(size_t col)
std::stringstream out;

for(size_t row=0; row<filterAllows.size(); row++)
if(filterAllows[row] == bePositive)
out << (cnt++ > 0 ? (bePositive ? " | " : " & ") : "") << columnName << (bePositive ? " == \"" : " != \"") << labels[row] << "\"";
if(filterAllows[row] == bePositive) //Also make sure we use .nominal because otherwise we might be comparing to the value instead...
out << (cnt++ > 0 ? (bePositive ? " | " : " & ") : "") << columnName << ".nominal" << (bePositive ? " == \"" : " != \"") << labels[row] << "\"";

return "(" + out.str() + ")";
}

0 comments on commit 671e8b4

Please sign in to comment.