forked from qt-creator/qt-creator
QmlDesigner: Add QML front-end for ConnectionView
This is still disabled by default until the UI gets polished. Add roles to models. ConnectionModel, BindingModel and DynamicPropertiesModel. In QML roles are used in the ListView to "mimic" columns. The columns are only relevant for the "old" cpp QTableView and can be removed. Making currentIndex part of the model. If rows are removed and added again we have to "reset/keep" the currentIndex as part of the model, because the index is temporarly invalid on the view. Implementing DynamicPropertiesModelBackendDelegate as reference. This is a pure "backend delegate" that exposes all relevant properties for a current row to QML. Adding StudioQuickWidget and exposing the backend. Adding StudioQmlTextBackend and StudioQmlComboBoxBackend to StudioQuickWidget (should be moved into their own files). Those helper classes make is easy to expose a property to a combobox or textfield. The backend has to know nothing about the actual frontend and those classes act as a mini-model for a view in QML. The API is similar to UI controls. Change-Id: I7a2c6ad951306fbca1d586fb8f278acdd91a064b Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
This commit is contained in:
@@ -252,6 +252,19 @@ void ConnectionModel::updateCustomData(QStandardItem *item, const SignalHandlerP
|
||||
{
|
||||
item->setData(signalHandlerProperty.parentModelNode().internalId(), UserRoles::InternalIdRole);
|
||||
item->setData(signalHandlerProperty.name(), UserRoles::TargetPropertyNameRole);
|
||||
item->setData(signalHandlerProperty.parentModelNode()
|
||||
.bindingProperty("target")
|
||||
.resolveToModelNode()
|
||||
.id(),
|
||||
UserRoles::TargetNameRole);
|
||||
|
||||
// TODO signalHandlerProperty.source() contains a statement that defines the type.
|
||||
// foo.bar() <- function call
|
||||
// foo.state = "literal" //state change
|
||||
//anything else is assignment
|
||||
// e.g. foo.bal = foo2.bula ; foo.bal = "literal" ; goo.gal = true
|
||||
|
||||
item->setData("Assignment", UserRoles::ActionTypeRole);
|
||||
}
|
||||
|
||||
ModelNode ConnectionModel::getTargetNodeForConnection(const ModelNode &connection) const
|
||||
@@ -370,6 +383,16 @@ void ConnectionModel::removeRowFromTable(const SignalHandlerProperty &property)
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionModel::add()
|
||||
{
|
||||
addConnection();
|
||||
}
|
||||
|
||||
void ConnectionModel::remove(int row)
|
||||
{
|
||||
deleteConnectionByRow(row);
|
||||
}
|
||||
|
||||
void ConnectionModel::handleException()
|
||||
{
|
||||
QMessageBox::warning(nullptr, tr("Error"), m_exceptionError);
|
||||
@@ -522,4 +545,12 @@ QStringList ConnectionModel::getPossibleSignalsForConnection(const ModelNode &co
|
||||
return stringList;
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ConnectionModel::roleNames() const
|
||||
{
|
||||
static QHash<int, QByteArray> roleNames{{TargetPropertyNameRole, "signal"},
|
||||
{TargetNameRole, "target"},
|
||||
{ActionTypeRole, "action"}};
|
||||
return roleNames;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user