forked from qt-creator/qt-creator
QmlDesigner Connection View signals fixes
Bug: QDS-1333 Change-Id: Ic0d4206888bd8c5bd3d5cef29225441f19efa59d Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -123,7 +123,7 @@ void ActionEditor::updateWindowName()
|
||||
{
|
||||
if (!m_dialog.isNull())
|
||||
{
|
||||
m_dialog->setWindowTitle(tr("Action Editor"));
|
||||
m_dialog->setWindowTitle(tr("Connection Editor"));
|
||||
m_dialog->raise();
|
||||
}
|
||||
}
|
||||
|
@@ -290,7 +290,28 @@ void ConnectionModel::abstractPropertyChanged(const AbstractProperty &abstractPr
|
||||
|
||||
void ConnectionModel::deleteConnectionByRow(int currentRow)
|
||||
{
|
||||
signalHandlerPropertyForRow(currentRow).parentModelNode().destroy();
|
||||
SignalHandlerProperty targetSignal = signalHandlerPropertyForRow(currentRow);
|
||||
QmlDesigner::ModelNode node = targetSignal.parentModelNode();
|
||||
QList<SignalHandlerProperty> allSignals = node.signalProperties();
|
||||
if (allSignals.size() > 1) {
|
||||
if (allSignals.contains(targetSignal))
|
||||
node.removeProperty(targetSignal.name());
|
||||
}
|
||||
else {
|
||||
node.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionModel::removeRowFromTable(const SignalHandlerProperty &property)
|
||||
{
|
||||
for (int currentRow = 0; currentRow < rowCount(); currentRow++) {
|
||||
SignalHandlerProperty targetSignal = signalHandlerPropertyForRow(currentRow);
|
||||
|
||||
if (targetSignal == property) {
|
||||
removeRow(currentRow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionModel::handleException()
|
||||
|
@@ -63,6 +63,7 @@ public:
|
||||
void abstractPropertyChanged(const AbstractProperty &abstractProperty);
|
||||
|
||||
void deleteConnectionByRow(int currentRow);
|
||||
void removeRowFromTable(const SignalHandlerProperty &property);
|
||||
|
||||
protected:
|
||||
void addModelNode(const ModelNode &modelNode);
|
||||
|
@@ -108,6 +108,8 @@ void ConnectionView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &
|
||||
dynamicPropertiesModel()->bindingRemoved(property.toBindingProperty());
|
||||
} else if (property.isVariantProperty()) {
|
||||
//### dynamicPropertiesModel->bindingRemoved(property.toVariantProperty());
|
||||
} else if (property.isSignalHandlerProperty()) {
|
||||
connectionModel()->removeRowFromTable(property.toSignalHandlerProperty());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,6 +182,11 @@ bool ConnectionView::hasWidget() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectionView::isWidgetEnabled()
|
||||
{
|
||||
return widgetInfo().widget->isEnabled();
|
||||
}
|
||||
|
||||
QTableView *ConnectionView::connectionTableView() const
|
||||
{
|
||||
return connectionViewWidget()->connectionTableView();
|
||||
|
@@ -74,6 +74,7 @@ public:
|
||||
|
||||
WidgetInfo widgetInfo() override;
|
||||
bool hasWidget() const override;
|
||||
bool isWidgetEnabled();
|
||||
|
||||
QTableView *connectionTableView() const;
|
||||
QTableView *bindingTableView() const;
|
||||
|
@@ -63,7 +63,8 @@ ConnectionViewWidget::ConnectionViewWidget(QWidget *parent) :
|
||||
[&]() {
|
||||
if (m_actionEditor->hasModelIndex()) {
|
||||
ConnectionModel *connectionModel = qobject_cast<ConnectionModel *>(ui->connectionView->model());
|
||||
if (connectionModel->rowCount() > m_actionEditor->modelIndex().row())
|
||||
if (connectionModel->connectionView()->isWidgetEnabled()
|
||||
&& (connectionModel->rowCount() > m_actionEditor->modelIndex().row()))
|
||||
{
|
||||
SignalHandlerProperty signalHandler =
|
||||
connectionModel->signalHandlerPropertyForRow(m_actionEditor->modelIndex().row());
|
||||
@@ -166,7 +167,7 @@ void ConnectionViewWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
||||
QMenu menu(this);
|
||||
|
||||
menu.addAction(tr("Open Action Editor"), [&]() {
|
||||
menu.addAction(tr("Open Connection Editor"), [&]() {
|
||||
if (index.isValid()) {
|
||||
m_actionEditor->showWidget(mapToGlobal(event->pos()).x(), mapToGlobal(event->pos()).y());
|
||||
m_actionEditor->setBindingValue(index.data().toString());
|
||||
|
@@ -133,6 +133,7 @@ public:
|
||||
QList<NodeProperty> nodeProperties() const;
|
||||
QList<NodeListProperty> nodeListProperties() const;
|
||||
QList<BindingProperty> bindingProperties() const;
|
||||
QList<SignalHandlerProperty> signalProperties() const;
|
||||
PropertyNameList propertyNames() const;
|
||||
|
||||
bool hasProperties() const;
|
||||
|
@@ -644,6 +644,16 @@ QList<BindingProperty> ModelNode::bindingProperties() const
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
QList<SignalHandlerProperty> ModelNode::signalProperties() const
|
||||
{
|
||||
QList<SignalHandlerProperty> propertyList;
|
||||
|
||||
foreach (const AbstractProperty &property, properties())
|
||||
if (property.isSignalHandlerProperty())
|
||||
propertyList.append(property.toSignalHandlerProperty());
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief removes a property from this node
|
||||
\param name name of the property
|
||||
|
Reference in New Issue
Block a user