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())
|
if (!m_dialog.isNull())
|
||||||
{
|
{
|
||||||
m_dialog->setWindowTitle(tr("Action Editor"));
|
m_dialog->setWindowTitle(tr("Connection Editor"));
|
||||||
m_dialog->raise();
|
m_dialog->raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -290,7 +290,28 @@ void ConnectionModel::abstractPropertyChanged(const AbstractProperty &abstractPr
|
|||||||
|
|
||||||
void ConnectionModel::deleteConnectionByRow(int currentRow)
|
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()
|
void ConnectionModel::handleException()
|
||||||
|
@@ -63,6 +63,7 @@ public:
|
|||||||
void abstractPropertyChanged(const AbstractProperty &abstractProperty);
|
void abstractPropertyChanged(const AbstractProperty &abstractProperty);
|
||||||
|
|
||||||
void deleteConnectionByRow(int currentRow);
|
void deleteConnectionByRow(int currentRow);
|
||||||
|
void removeRowFromTable(const SignalHandlerProperty &property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addModelNode(const ModelNode &modelNode);
|
void addModelNode(const ModelNode &modelNode);
|
||||||
|
@@ -108,6 +108,8 @@ void ConnectionView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &
|
|||||||
dynamicPropertiesModel()->bindingRemoved(property.toBindingProperty());
|
dynamicPropertiesModel()->bindingRemoved(property.toBindingProperty());
|
||||||
} else if (property.isVariantProperty()) {
|
} else if (property.isVariantProperty()) {
|
||||||
//### dynamicPropertiesModel->bindingRemoved(property.toVariantProperty());
|
//### dynamicPropertiesModel->bindingRemoved(property.toVariantProperty());
|
||||||
|
} else if (property.isSignalHandlerProperty()) {
|
||||||
|
connectionModel()->removeRowFromTable(property.toSignalHandlerProperty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,6 +182,11 @@ bool ConnectionView::hasWidget() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConnectionView::isWidgetEnabled()
|
||||||
|
{
|
||||||
|
return widgetInfo().widget->isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
QTableView *ConnectionView::connectionTableView() const
|
QTableView *ConnectionView::connectionTableView() const
|
||||||
{
|
{
|
||||||
return connectionViewWidget()->connectionTableView();
|
return connectionViewWidget()->connectionTableView();
|
||||||
|
@@ -74,6 +74,7 @@ public:
|
|||||||
|
|
||||||
WidgetInfo widgetInfo() override;
|
WidgetInfo widgetInfo() override;
|
||||||
bool hasWidget() const override;
|
bool hasWidget() const override;
|
||||||
|
bool isWidgetEnabled();
|
||||||
|
|
||||||
QTableView *connectionTableView() const;
|
QTableView *connectionTableView() const;
|
||||||
QTableView *bindingTableView() const;
|
QTableView *bindingTableView() const;
|
||||||
|
@@ -63,7 +63,8 @@ ConnectionViewWidget::ConnectionViewWidget(QWidget *parent) :
|
|||||||
[&]() {
|
[&]() {
|
||||||
if (m_actionEditor->hasModelIndex()) {
|
if (m_actionEditor->hasModelIndex()) {
|
||||||
ConnectionModel *connectionModel = qobject_cast<ConnectionModel *>(ui->connectionView->model());
|
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 =
|
SignalHandlerProperty signalHandler =
|
||||||
connectionModel->signalHandlerPropertyForRow(m_actionEditor->modelIndex().row());
|
connectionModel->signalHandlerPropertyForRow(m_actionEditor->modelIndex().row());
|
||||||
@@ -166,7 +167,7 @@ void ConnectionViewWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
menu.addAction(tr("Open Action Editor"), [&]() {
|
menu.addAction(tr("Open Connection Editor"), [&]() {
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
m_actionEditor->showWidget(mapToGlobal(event->pos()).x(), mapToGlobal(event->pos()).y());
|
m_actionEditor->showWidget(mapToGlobal(event->pos()).x(), mapToGlobal(event->pos()).y());
|
||||||
m_actionEditor->setBindingValue(index.data().toString());
|
m_actionEditor->setBindingValue(index.data().toString());
|
||||||
|
@@ -133,6 +133,7 @@ public:
|
|||||||
QList<NodeProperty> nodeProperties() const;
|
QList<NodeProperty> nodeProperties() const;
|
||||||
QList<NodeListProperty> nodeListProperties() const;
|
QList<NodeListProperty> nodeListProperties() const;
|
||||||
QList<BindingProperty> bindingProperties() const;
|
QList<BindingProperty> bindingProperties() const;
|
||||||
|
QList<SignalHandlerProperty> signalProperties() const;
|
||||||
PropertyNameList propertyNames() const;
|
PropertyNameList propertyNames() const;
|
||||||
|
|
||||||
bool hasProperties() const;
|
bool hasProperties() const;
|
||||||
|
@@ -644,6 +644,16 @@ QList<BindingProperty> ModelNode::bindingProperties() const
|
|||||||
return propertyList;
|
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
|
\brief removes a property from this node
|
||||||
\param name name of the property
|
\param name name of the property
|
||||||
|
Reference in New Issue
Block a user