forked from qt-creator/qt-creator
QmlDesigner: Add alias export to node
Change-Id: Ifa7ae959f6aa4622549e5c32a5df14893124c1b6 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -624,8 +624,33 @@ static QStringList getSortedSignalNameList(const ModelNode &modelNode)
|
|||||||
void gotoImplementation(const SelectionContext &selectionState)
|
void gotoImplementation(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
QString itemId;
|
QString itemId;
|
||||||
if (selectionState.singleNodeIsSelected())
|
ModelNode modelNode;
|
||||||
|
if (selectionState.singleNodeIsSelected()) {
|
||||||
itemId = selectionState.selectedModelNodes().first().id();
|
itemId = selectionState.selectedModelNodes().first().id();
|
||||||
|
modelNode = selectionState.selectedModelNodes().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
QmlObjectNode qmlObjectNode(modelNode);
|
||||||
|
|
||||||
|
if (!qmlObjectNode.isValid()) {
|
||||||
|
QString title = QCoreApplication::translate("ModelNodeOperations", "Go to Implementation");
|
||||||
|
QString description = QCoreApplication::translate("ModelNodeOperations", "Invalid item.");
|
||||||
|
Core::AsynchronousMessageBox::warning(title, description);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!qmlObjectNode.isRootModelNode()) {
|
||||||
|
try {
|
||||||
|
RewriterTransaction transaction =
|
||||||
|
qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
|
||||||
|
|
||||||
|
QmlObjectNode qmlObjectNode(modelNode);
|
||||||
|
qmlObjectNode.ensureAliasExport();
|
||||||
|
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
||||||
|
exception.showException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QString fileName = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName().toString();
|
const QString fileName = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName().toString();
|
||||||
const QString typeName = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName().toFileInfo().baseName();
|
const QString typeName = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName().toFileInfo().baseName();
|
||||||
|
|
||||||
|
|||||||
@@ -425,9 +425,8 @@ void NavigatorTreeModel::handleChangedExportItem(QStandardItem *exportItem, Mode
|
|||||||
RewriterTransaction transaction =
|
RewriterTransaction transaction =
|
||||||
m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
|
m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
|
||||||
|
|
||||||
modelNode.validId();
|
QmlObjectNode qmlObjectNode(modelNode);
|
||||||
modelNodeId = modelNode.id().toUtf8();
|
qmlObjectNode.ensureAliasExport();
|
||||||
rootModelNode.bindingProperty(modelNodeId).setDynamicTypeNameAndExpression("alias", modelNodeId);
|
|
||||||
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
|
||||||
exception.showException();
|
exception.showException();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user