QmlDesigner: ConnectionEditor hide readonly

Hide readonly properties in the ConnectionEditors target item property
ComboBox.

Task-number: QDS-5718
Change-Id: Idee217714d460a0a59954faf3c51641648e0657b
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Henning Gruendl
2021-12-08 15:22:08 +01:00
committed by Henning Gründl
parent e71e6b9583
commit efa8e9fd9a
3 changed files with 31 additions and 18 deletions

View File

@@ -202,26 +202,26 @@ void ActionEditor::prepareConnections()
continue;
const QString name = QString::fromUtf8(propertyName);
const bool writeable = modelNode.metaInfo().propertyIsWritable(propertyName);
TypeName type = modelNode.metaInfo().propertyTypeName(propertyName);
if (type.contains("<cpp>."))
type.remove(0, 6);
connection.properties.append(ActionEditorDialog::PropertyOption(name, type));
connection.properties.append(ActionEditorDialog::PropertyOption(name, type, writeable));
}
for (const VariantProperty &variantProperty : modelNode.variantProperties()) {
if (variantProperty.isValid()) {
if (variantProperty.isDynamic()) {
if (!typeWhiteList.contains(variantProperty.dynamicTypeName()))
continue;
if (variantProperty.isValid() && variantProperty.isDynamic()) {
if (!typeWhiteList.contains(variantProperty.dynamicTypeName()))
continue;
const QString name = QString::fromUtf8(variantProperty.name());
TypeName type = variantProperty.dynamicTypeName();
if (type.contains("<cpp>."))
type.remove(0, 6);
const QString name = QString::fromUtf8(variantProperty.name());
const bool writeable = modelNode.metaInfo().propertyIsWritable(variantProperty.name());
TypeName type = variantProperty.dynamicTypeName();
if (type.contains("<cpp>."))
type.remove(0, 6);
connection.properties.append(ActionEditorDialog::PropertyOption(name, type));
}
connection.properties.append(ActionEditorDialog::PropertyOption(name, type, writeable));
}
}
@@ -266,10 +266,11 @@ void ActionEditor::prepareConnections()
continue;
const QString name = QString::fromUtf8(propertyName);
const bool writeable = metaInfo.propertyIsWritable(propertyName);
if (type.contains("<cpp>."))
type.remove(0, 6);
singelton.properties.append(ActionEditorDialog::PropertyOption(name, type));
singelton.properties.append(ActionEditorDialog::PropertyOption(name, type, writeable));
}
if (!singelton.properties.isEmpty()) {

View File

@@ -472,7 +472,7 @@ void ActionEditorDialog::fillAndSetTargetItem(const QString &value, bool useDefa
} else { // ConnectionType::Assignment
m_assignmentTargetItem->clear();
for (const auto &connection : qAsConst(m_connections)) {
if (!connection.properties.isEmpty())
if (!connection.properties.isEmpty() && connection.hasWriteableProperties())
m_assignmentTargetItem->addItem(connection.item);
}
@@ -516,8 +516,10 @@ void ActionEditorDialog::fillAndSetTargetProperty(const QString &value, bool use
if (idx == -1) {
insertAndSetUndefined(m_assignmentTargetProperty);
} else {
for (const auto &property : qAsConst(m_connections[idx].properties))
m_assignmentTargetProperty->addItem(property.name, property.type);
for (const auto &property : qAsConst(m_connections[idx].properties)) {
if (property.isWriteable)
m_assignmentTargetProperty->addItem(property.name, property.type);
}
if (m_assignmentTargetProperty->findText(value) != -1) {
m_assignmentTargetProperty->setCurrentText(value);

View File

@@ -51,10 +51,10 @@ public:
class PropertyOption
{
public:
PropertyOption() {}
PropertyOption(const QString &n, const TypeName &t)
PropertyOption(const QString &n, const TypeName &t, bool writeable = true)
: name(n)
, type(t)
, isWriteable(writeable)
{}
bool operator==(const QString &value) const { return value == name; }
@@ -62,6 +62,7 @@ public:
QString name;
TypeName type;
bool isWriteable;
};
class SingletonOption
@@ -80,6 +81,16 @@ public:
return false;
}
bool hasWriteableProperties() const
{
for (const auto &p : properties) {
if (p.isWriteable)
return true;
}
return false;
}
bool operator==(const QString &value) const { return value == item; }
bool operator==(const SingletonOption &value) const { return value.item == item; }
@@ -90,7 +101,6 @@ public:
class ConnectionOption : public SingletonOption
{
public:
ConnectionOption() {}
ConnectionOption(const QString &value) : SingletonOption(value) {}
QStringList methods;