forked from qt-creator/qt-creator
QmlDesigner: Fix flag binding design system
* Fix setting bindings on flag types via the context menu
* Clear edit delegate input when creating a binding
* Remove comments
Change-Id: Ibfd281ee37500db88480c7c0f7820c00214d46ed
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
(cherry picked from commit dde640d75b
)
This commit is contained in:
committed by
Thomas Hartmann
parent
ae7567e2ba
commit
a60a027254
@@ -345,6 +345,8 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
component Cell: Rectangle {
|
component Cell: Rectangle {
|
||||||
|
id: cell
|
||||||
|
|
||||||
required property var display
|
required property var display
|
||||||
required property int row
|
required property int row
|
||||||
required property int column
|
required property int column
|
||||||
@@ -356,9 +358,7 @@ Rectangle {
|
|||||||
required property bool isBinding
|
required property bool isBinding
|
||||||
required property var propertyValue
|
required property var propertyValue
|
||||||
|
|
||||||
property bool creatingBinding: false
|
readonly property bool bindingEditor: cell.isBinding || tableView.model.editableOverride
|
||||||
|
|
||||||
readonly property bool bindingEditor: isBinding || creatingBinding
|
|
||||||
|
|
||||||
color: root.backgroundColor
|
color: root.backgroundColor
|
||||||
implicitWidth: root.cellWidth
|
implicitWidth: root.cellWidth
|
||||||
@@ -425,11 +425,12 @@ Rectangle {
|
|||||||
horizontalAlignment: TextInput.AlignLeft
|
horizontalAlignment: TextInput.AlignLeft
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
|
|
||||||
text: stringDelegate.bindingEditor ? stringDelegate.propertyValue
|
text: stringDelegate.isBinding ? stringDelegate.propertyValue
|
||||||
: stringDelegate.resolvedValue
|
: tableView.model.editableOverride ? ""
|
||||||
|
: stringDelegate.resolvedValue
|
||||||
|
|
||||||
Component.onCompleted: stringEditDelegate.selectAll()
|
Component.onCompleted: stringEditDelegate.selectAll()
|
||||||
Component.onDestruction: stringDelegate.creatingBinding = false
|
Component.onDestruction: tableView.model.editableOverride = false
|
||||||
|
|
||||||
TableView.onCommit: {
|
TableView.onCommit: {
|
||||||
root.setValue(stringEditDelegate.text,
|
root.setValue(stringEditDelegate.text,
|
||||||
@@ -438,8 +439,6 @@ Rectangle {
|
|||||||
stringDelegate.bindingEditor)
|
stringDelegate.bindingEditor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Component.onCompleted: console.log("DelegateChoice - string", stringDelegate.resolvedValue)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,13 +520,13 @@ Rectangle {
|
|||||||
horizontalAlignment: TextInput.AlignLeft
|
horizontalAlignment: TextInput.AlignLeft
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
|
|
||||||
text: numberDelegate.propertyValue
|
text: numberDelegate.isBinding ? numberDelegate.propertyValue : ""
|
||||||
|
|
||||||
focus: numberDelegate.bindingEditor
|
focus: numberDelegate.bindingEditor
|
||||||
visible: numberDelegate.bindingEditor
|
visible: numberDelegate.bindingEditor
|
||||||
|
|
||||||
Component.onCompleted: numberBindingEditDelegate.selectAll()
|
Component.onCompleted: numberBindingEditDelegate.selectAll()
|
||||||
Component.onDestruction: numberDelegate.creatingBinding = false
|
Component.onDestruction: tableView.model.editableOverride = false
|
||||||
}
|
}
|
||||||
|
|
||||||
TableView.onCommit: {
|
TableView.onCommit: {
|
||||||
@@ -551,8 +550,6 @@ Rectangle {
|
|||||||
numberEditDelegateFocusScope.alreadyCommited = true
|
numberEditDelegateFocusScope.alreadyCommited = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Component.onCompleted: console.log("DelegateChoice - number", numberDelegate.resolvedValue)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,10 +608,12 @@ Rectangle {
|
|||||||
horizontalAlignment: TextInput.AlignLeft
|
horizontalAlignment: TextInput.AlignLeft
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
|
|
||||||
text: flagDelegate.bindingEditor ? flagDelegate.propertyValue
|
text: flagDelegate.isBinding ? flagDelegate.propertyValue
|
||||||
: flagDelegate.resolvedValue
|
: tableView.model.editableOverride ? ""
|
||||||
|
: flagDelegate.resolvedValue
|
||||||
|
|
||||||
Component.onCompleted: flagBindingEditDelegate.selectAll()
|
Component.onCompleted: flagBindingEditDelegate.selectAll()
|
||||||
Component.onDestruction: flagDelegate.creatingBinding = false
|
Component.onDestruction: tableView.model.editableOverride = false
|
||||||
|
|
||||||
TableView.onCommit: {
|
TableView.onCommit: {
|
||||||
root.setValue(flagBindingEditDelegate.text,
|
root.setValue(flagBindingEditDelegate.text,
|
||||||
@@ -623,8 +622,6 @@ Rectangle {
|
|||||||
true)
|
true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Component.onCompleted: console.log("DelegateChoice - bool", flagDelegate.resolvedValue)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,8 +706,9 @@ Rectangle {
|
|||||||
horizontalAlignment: TextInput.AlignLeft
|
horizontalAlignment: TextInput.AlignLeft
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
|
|
||||||
text: colorDelegate.bindingEditor ? colorDelegate.propertyValue
|
text: colorDelegate.isBinding ? colorDelegate.propertyValue
|
||||||
: colorDelegate.resolvedValue
|
: tableView.model.editableOverride ? ""
|
||||||
|
: colorDelegate.resolvedValue
|
||||||
|
|
||||||
RegularExpressionValidator {
|
RegularExpressionValidator {
|
||||||
id: hexValidator
|
id: hexValidator
|
||||||
@@ -720,7 +718,7 @@ Rectangle {
|
|||||||
validator: colorDelegate.bindingEditor ? null : hexValidator
|
validator: colorDelegate.bindingEditor ? null : hexValidator
|
||||||
|
|
||||||
Component.onCompleted: colorEditDelegate.selectAll()
|
Component.onCompleted: colorEditDelegate.selectAll()
|
||||||
Component.onDestruction: colorDelegate.creatingBinding = false
|
Component.onDestruction: tableView.model.editableOverride = false
|
||||||
|
|
||||||
TableView.onCommit: {
|
TableView.onCommit: {
|
||||||
root.setValue(colorEditDelegate.text,
|
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")
|
text: qsTr("Set Binding")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
let cell = tableView.itemAtIndex(menu.modelIndex)
|
let cell = tableView.itemAtIndex(menu.modelIndex)
|
||||||
cell.creatingBinding = true
|
tableView.model.editableOverride = true
|
||||||
tableView.edit(menu.modelIndex)
|
tableView.edit(menu.modelIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -124,7 +124,7 @@ Qt::ItemFlags CollectionModel::flags(const QModelIndex &index) const
|
|||||||
{
|
{
|
||||||
// If group type is FLAGS and not binding block editable
|
// If group type is FLAGS and not binding block editable
|
||||||
if (data(index, Roles::GroupRole).value<GroupType>() == GroupType::Flags
|
if (data(index, Roles::GroupRole).value<GroupType>() == GroupType::Flags
|
||||||
&& !data(index, Roles::BindingRole).toBool())
|
&& !data(index, Roles::BindingRole).toBool() && !m_editableOverride)
|
||||||
return QAbstractItemModel::flags(index);
|
return QAbstractItemModel::flags(index);
|
||||||
|
|
||||||
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
|
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
|
||||||
@@ -282,6 +282,20 @@ bool CollectionModel::setHeaderData(int section,
|
|||||||
return success;
|
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
|
ThemeId CollectionModel::findThemeId(int column) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(column > -1 && column < static_cast<int>(m_themeIdList.size()), return 0);
|
QTC_ASSERT(column > -1 && column < static_cast<int>(m_themeIdList.size()), return 0);
|
||||||
|
@@ -29,6 +29,8 @@ public:
|
|||||||
Q_ENUM(Roles)
|
Q_ENUM(Roles)
|
||||||
|
|
||||||
Q_PROPERTY(QStringList themeNames READ themeNameList NOTIFY themeNameChanged FINAL)
|
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);
|
CollectionModel(DSThemeManager *collection, DSStore *store);
|
||||||
|
|
||||||
@@ -66,8 +68,12 @@ public:
|
|||||||
const QVariant &value,
|
const QVariant &value,
|
||||||
int role = Qt::EditRole) override;
|
int role = Qt::EditRole) override;
|
||||||
|
|
||||||
|
bool editableOverride() const;
|
||||||
|
void setEditableOverride(bool value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void themeNameChanged();
|
void themeNameChanged();
|
||||||
|
void editableOverrideChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThemeId findThemeId(int column) const;
|
ThemeId findThemeId(int column) const;
|
||||||
@@ -85,5 +91,7 @@ private:
|
|||||||
std::vector<PropInfo> m_propertyInfoList;
|
std::vector<PropInfo> m_propertyInfoList;
|
||||||
|
|
||||||
QTimer m_saveCompressionTimer;
|
QTimer m_saveCompressionTimer;
|
||||||
|
|
||||||
|
bool m_editableOverride = false;
|
||||||
};
|
};
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
Reference in New Issue
Block a user