QmlDesigner: Suppress datatype warning when creating new column

- Ignores datatype warnings for cells with null values and cells with Unknown datatype

Task-number: QDS-11645
Change-Id: I0f0247bcfcbd8bd2a7377e587351c1a984c269be
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Shrief Gabr
2024-01-15 17:12:37 +02:00
parent 17b64c7ccd
commit 3afe85fff8
2 changed files with 17 additions and 29 deletions

View File

@@ -221,9 +221,18 @@ Rectangle {
clip: true clip: true
implicitWidth: 100 implicitWidth: 100
implicitHeight: StudioTheme.Values.baseHeight implicitHeight: StudioTheme.Values.baseHeight
border.color: dataTypeWarning !== CollectionDetails.Warning.None ? color: itemSelected ? StudioTheme.Values.themeControlBackgroundInteraction
StudioTheme.Values.themeWarning : StudioTheme.Values.themeControlBackgroundInteraction : StudioTheme.Values.themeControlBackground
border.width: 1 border.width: 1
border.color: {
if (dataTypeWarning !== CollectionDetails.Warning.None)
return StudioTheme.Values.themeWarning
if (itemSelected)
return StudioTheme.Values.themeControlOutlineInteraction
return StudioTheme.Values.themeControlBackgroundInteraction
}
HelperWidgets.ToolTipArea { HelperWidgets.ToolTipArea {
anchors.fill: parent anchors.fill: parent
@@ -254,9 +263,8 @@ Rectangle {
Text { Text {
text: display text: display
color: itemSelected color: itemSelected ? StudioTheme.Values.themeInteraction
? StudioTheme.Values.themeInteraction : StudioTheme.Values.themePlaceholderTextColorInteraction
: StudioTheme.Values.themePlaceholderTextColorInteraction
leftPadding: 5 leftPadding: 5
topPadding: 3 topPadding: 3
bottomPadding: 3 bottomPadding: 3
@@ -274,7 +282,7 @@ Rectangle {
} }
function resetSource() { function resetSource() {
if (columnType == CollectionDetails.DataType.Color) if (columnType === CollectionDetails.DataType.Color)
cellContentLoader.sourceComponent = colorEditorComponent cellContentLoader.sourceComponent = colorEditorComponent
else else
cellContentLoader.sourceComponent = cellText cellContentLoader.sourceComponent = cellText
@@ -291,28 +299,6 @@ Rectangle {
} }
} }
states: [
State {
name: "default"
when: !itemSelected
PropertyChanges {
target: itemCell
color: StudioTheme.Values.themeControlBackground
}
},
State {
name: "selected"
when: itemSelected
PropertyChanges {
target: itemCell
color: StudioTheme.Values.themeControlBackgroundInteraction
border.color: StudioTheme.Values.themeControlBackground
}
}
]
StudioControls.Menu { StudioControls.Menu {
id: cellContextMenu id: cellContextMenu

View File

@@ -375,8 +375,10 @@ DataTypeWarning::Warning CollectionDetails::cellWarningCheck(int row, int column
const QString &propertyName = d->properties.at(column).name; const QString &propertyName = d->properties.at(column).name;
const QJsonObject &element = d->elements.at(row); const QJsonObject &element = d->elements.at(row);
if (element.isEmpty()) if (typeAt(column) == DataType::Unknown || element.isEmpty()
|| data(row, column) == QVariant::fromValue(nullptr)) {
return DataTypeWarning::Warning::None; return DataTypeWarning::Warning::None;
}
if (element.contains(propertyName) && typeAt(column) != typeAt(row, column)) if (element.contains(propertyName) && typeAt(column) != typeAt(row, column))
return DataTypeWarning::Warning::CellDataTypeMismatch; return DataTypeWarning::Warning::CellDataTypeMismatch;