Skip to content

Commit

Permalink
Set computed column to not computed (#5327)
Browse files Browse the repository at this point in the history
* Set Column added by analysis to Not computed when analysis removed

* Remove warnings

* Not sure when BeforeChangingColumn gets called exactly, but it probably should look at the active BasicColumnInfo.qml

---------

Co-authored-by: Joris Goosen <[email protected]>
  • Loading branch information
boutinb and JorisGoosen committed Jan 2, 2024
1 parent f91ebf4 commit 125aae0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Desktop/analysis/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ Analysis::~Analysis()

if(DataSetPackage::pkg() && DataSetPackage::pkg()->hasDataSet())
for(const std::string & col : computedColumns())
if(!DataSetPackage::pkg()->isColumnAnalysisNotComputed(col))
if(DataSetPackage::pkg()->isColumnAnalysisNotComputed(col))
DataSetPackage::pkg()->setColumnComputedType(col, computedColumnType::notComputed);
else
emit requestComputedColumnDestruction(col);
}

Expand Down
5 changes: 5 additions & 0 deletions Desktop/components/JASP/Widgets/ColumnBasicInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Item
implicitHeight: Math.max(leftColumn.childrenRect.height, rightColumn.childrenRect.height) + 2 * jaspTheme.generalAnchorMargin
height: implicitHeight
property bool closeIcon: true
property alias columnNameValue: columnNameVariablesWindow.value
property alias columnTitleValue: columnTitleVariablesWindow.value
property alias columnDescriptionValue: columnDescriptionVariablesWindow.text
property alias columnComputedTypeValue: computedTypeVariableWindow.value
property alias columnTypeValue: columnTypeVariableWindow.value

Column
{
Expand Down
10 changes: 5 additions & 5 deletions Desktop/components/JASP/Widgets/VariablesWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ FocusScope
{
if (columnModel.visible && columnModel.chosenColumn >= 0)
{
columnModel.columnName = columnNameVariablesWindow.value
columnModel.columnTitle = columnTitleVariablesWindow.value
columnModel.columnDescription = columnDescriptionVariablesWindow.text
columnModel.computedType = computedTypeVariableWindow.value
columnModel.currentColumnType = columnTypeVariableWindow.value
columnModel.columnName = (columnModel.compactMode ? tabInfo : columnInfoTop).columnNameValue
columnModel.columnTitle = (columnModel.compactMode ? tabInfo : columnInfoTop).columnTitleValue
columnModel.columnDescription = (columnModel.compactMode ? tabInfo : columnInfoTop).columnDescriptionValue
columnModel.computedType = (columnModel.compactMode ? tabInfo : columnInfoTop).columnComputedTypeValue
columnModel.currentColumnType = (columnModel.compactMode ? tabInfo : columnInfoTop).columnTypeValue
}
}

Expand Down
7 changes: 6 additions & 1 deletion Desktop/data/datasetpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ void DataSetPackage::setColumnDescription(size_t columnIndex, const std::string
column->setDescription(newDescription);
}

void DataSetPackage::setColumnAsComputed(size_t columnIndex, computedColumnType type)
void DataSetPackage::setColumnComputedType(size_t columnIndex, computedColumnType type)
{
if(!_dataSet)
return;
Expand All @@ -1797,6 +1797,11 @@ void DataSetPackage::setColumnAsComputed(size_t columnIndex, computedColumnType

}

void DataSetPackage::setColumnComputedType(const std::string & columnName, computedColumnType type)
{
setColumnComputedType(getColumnIndex(columnName), type);
}

void DataSetPackage::setColumnHasCustomEmptyValues(size_t columnIndex, bool hasCustomEmptyValue)
{
if(!_dataSet)
Expand Down
3 changes: 2 additions & 1 deletion Desktop/data/datasetpackage.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ class DataSetPackage : public QAbstractItemModel //Not QAbstractTableModel becau
void setColumnName( size_t columnIndex, const std::string & newName, bool resetModel = true);
void setColumnTitle( size_t columnIndex, const std::string & newTitle);
void setColumnDescription( size_t columnIndex, const std::string & newDescription);
void setColumnAsComputed( size_t columnIndex, computedColumnType type);
void setColumnComputedType( size_t columnIndex, computedColumnType type);
void setColumnComputedType( const std::string & columnName, computedColumnType type);
void setColumnHasCustomEmptyValues( size_t columnIndex, bool hasCustomEmptyValue);
void setColumnCustomEmptyValues( size_t columnIndex, const stringset & customEmptyValues);
void setColumnDataInts( size_t columnIndex, const intvec & ints);
Expand Down
4 changes: 2 additions & 2 deletions Desktop/data/undostack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void SetColumnPropertyCommand::undo()
DataSetPackage::pkg()->setColumnDescription(_colId, fq(_oldValue.toString()));
break;
case ColumnProperty::ComputedColumn:
DataSetPackage::pkg()->setColumnAsComputed(_colId, computedColumnType(_oldValue.toInt()));
DataSetPackage::pkg()->setColumnComputedType(_colId, computedColumnType(_oldValue.toInt()));
break;
}
}
Expand All @@ -299,7 +299,7 @@ void SetColumnPropertyCommand::redo()
DataSetPackage::pkg()->setColumnDescription(_colId, fq(_newValue.toString()));
break;
case ColumnProperty::ComputedColumn:
DataSetPackage::pkg()->setColumnAsComputed(_colId, computedColumnType(_newValue.toInt()));
DataSetPackage::pkg()->setColumnComputedType(_colId, computedColumnType(_newValue.toInt()));
break;
}

Expand Down

0 comments on commit 125aae0

Please sign in to comment.