diff --git a/share/qtcreator/qmldesigner/designsystem/Main.qml b/share/qtcreator/qmldesigner/designsystem/Main.qml index 31967e56b43..7021a91edc1 100644 --- a/share/qtcreator/qmldesigner/designsystem/Main.qml +++ b/share/qtcreator/qmldesigner/designsystem/Main.qml @@ -345,6 +345,8 @@ Rectangle { } component Cell: Rectangle { + id: cell + required property var display required property int row required property int column @@ -356,9 +358,7 @@ Rectangle { required property bool isBinding required property var propertyValue - property bool creatingBinding: false - - readonly property bool bindingEditor: isBinding || creatingBinding + readonly property bool bindingEditor: cell.isBinding || tableView.model.editableOverride color: root.backgroundColor implicitWidth: root.cellWidth @@ -425,11 +425,12 @@ Rectangle { horizontalAlignment: TextInput.AlignLeft verticalAlignment: TextInput.AlignVCenter - text: stringDelegate.bindingEditor ? stringDelegate.propertyValue - : stringDelegate.resolvedValue + text: stringDelegate.isBinding ? stringDelegate.propertyValue + : tableView.model.editableOverride ? "" + : stringDelegate.resolvedValue Component.onCompleted: stringEditDelegate.selectAll() - Component.onDestruction: stringDelegate.creatingBinding = false + Component.onDestruction: tableView.model.editableOverride = false TableView.onCommit: { root.setValue(stringEditDelegate.text, @@ -438,8 +439,6 @@ Rectangle { stringDelegate.bindingEditor) } } - - //Component.onCompleted: console.log("DelegateChoice - string", stringDelegate.resolvedValue) } } @@ -521,13 +520,13 @@ Rectangle { horizontalAlignment: TextInput.AlignLeft verticalAlignment: TextInput.AlignVCenter - text: numberDelegate.propertyValue + text: numberDelegate.isBinding ? numberDelegate.propertyValue : "" focus: numberDelegate.bindingEditor visible: numberDelegate.bindingEditor Component.onCompleted: numberBindingEditDelegate.selectAll() - Component.onDestruction: numberDelegate.creatingBinding = false + Component.onDestruction: tableView.model.editableOverride = false } TableView.onCommit: { @@ -551,8 +550,6 @@ Rectangle { numberEditDelegateFocusScope.alreadyCommited = true } } - - //Component.onCompleted: console.log("DelegateChoice - number", numberDelegate.resolvedValue) } } @@ -611,10 +608,12 @@ Rectangle { horizontalAlignment: TextInput.AlignLeft verticalAlignment: TextInput.AlignVCenter - text: flagDelegate.bindingEditor ? flagDelegate.propertyValue - : flagDelegate.resolvedValue + text: flagDelegate.isBinding ? flagDelegate.propertyValue + : tableView.model.editableOverride ? "" + : flagDelegate.resolvedValue + Component.onCompleted: flagBindingEditDelegate.selectAll() - Component.onDestruction: flagDelegate.creatingBinding = false + Component.onDestruction: tableView.model.editableOverride = false TableView.onCommit: { root.setValue(flagBindingEditDelegate.text, @@ -623,8 +622,6 @@ Rectangle { true) } } - - //Component.onCompleted: console.log("DelegateChoice - bool", flagDelegate.resolvedValue) } } @@ -709,8 +706,9 @@ Rectangle { horizontalAlignment: TextInput.AlignLeft verticalAlignment: TextInput.AlignVCenter - text: colorDelegate.bindingEditor ? colorDelegate.propertyValue - : colorDelegate.resolvedValue + text: colorDelegate.isBinding ? colorDelegate.propertyValue + : tableView.model.editableOverride ? "" + : colorDelegate.resolvedValue RegularExpressionValidator { id: hexValidator @@ -720,7 +718,7 @@ Rectangle { validator: colorDelegate.bindingEditor ? null : hexValidator Component.onCompleted: colorEditDelegate.selectAll() - Component.onDestruction: colorDelegate.creatingBinding = false + Component.onDestruction: tableView.model.editableOverride = false TableView.onCommit: { root.setValue(colorEditDelegate.text, @@ -758,8 +756,6 @@ Rectangle { } } } - - //Component.onCompleted: console.log("DelegateChoice - color", colorDelegate.resolvedValue) } } } @@ -795,7 +791,7 @@ Rectangle { text: qsTr("Set Binding") onTriggered: { let cell = tableView.itemAtIndex(menu.modelIndex) - cell.creatingBinding = true + tableView.model.editableOverride = true tableView.edit(menu.modelIndex) } } diff --git a/src/plugins/qmldesigner/components/designsystemview/collectionmodel.cpp b/src/plugins/qmldesigner/components/designsystemview/collectionmodel.cpp index 227ce1902ec..c4935362b2c 100644 --- a/src/plugins/qmldesigner/components/designsystemview/collectionmodel.cpp +++ b/src/plugins/qmldesigner/components/designsystemview/collectionmodel.cpp @@ -124,7 +124,7 @@ Qt::ItemFlags CollectionModel::flags(const QModelIndex &index) const { // If group type is FLAGS and not binding block editable if (data(index, Roles::GroupRole).value() == GroupType::Flags - && !data(index, Roles::BindingRole).toBool()) + && !data(index, Roles::BindingRole).toBool() && !m_editableOverride) return QAbstractItemModel::flags(index); return Qt::ItemIsEditable | QAbstractItemModel::flags(index); @@ -282,6 +282,20 @@ bool CollectionModel::setHeaderData(int section, return success; } +bool CollectionModel::editableOverride() const +{ + return m_editableOverride; +} + +void CollectionModel::setEditableOverride(bool value) +{ + if (value == m_editableOverride) + return; + + m_editableOverride = value; + emit editableOverrideChanged(); +} + ThemeId CollectionModel::findThemeId(int column) const { QTC_ASSERT(column > -1 && column < static_cast(m_themeIdList.size()), return 0); diff --git a/src/plugins/qmldesigner/components/designsystemview/collectionmodel.h b/src/plugins/qmldesigner/components/designsystemview/collectionmodel.h index a7b0f8a3f9b..c1395fb7178 100644 --- a/src/plugins/qmldesigner/components/designsystemview/collectionmodel.h +++ b/src/plugins/qmldesigner/components/designsystemview/collectionmodel.h @@ -29,6 +29,8 @@ public: Q_ENUM(Roles) Q_PROPERTY(QStringList themeNames READ themeNameList NOTIFY themeNameChanged FINAL) + Q_PROPERTY(bool editableOverride READ editableOverride WRITE setEditableOverride NOTIFY + editableOverrideChanged FINAL) CollectionModel(DSThemeManager *collection, DSStore *store); @@ -66,8 +68,12 @@ public: const QVariant &value, int role = Qt::EditRole) override; + bool editableOverride() const; + void setEditableOverride(bool value); + signals: void themeNameChanged(); + void editableOverrideChanged(); private: ThemeId findThemeId(int column) const; @@ -85,5 +91,7 @@ private: std::vector m_propertyInfoList; QTimer m_saveCompressionTimer; + + bool m_editableOverride = false; }; } // namespace QmlDesigner