NodeInstance NodeInstanceView::instanceForId(qint32 id) { if (id < 0 || !hasModelNodeForInternalId(id)) return NodeInstance(); return m_nodeInstanceHash.value(modelNodeForInternalId(id)); }
bool NodeInstanceView::hasInstanceForId(qint32 id) { if (id < 0 || !hasModelNodeForInternalId(id)) return false; return m_nodeInstanceHash.contains(modelNodeForInternalId(id)); }
void StatesEditorView::removeState(int nodeId) { try { if (nodeId > 0 && hasModelNodeForInternalId(nodeId)) { ModelNode stateNode(modelNodeForInternalId(nodeId)); Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick.State", -1, -1)); NodeListProperty parentProperty = stateNode.parentProperty().toNodeListProperty(); if (parentProperty.count() <= 1) { setCurrentState(baseState()); } else if (parentProperty.isValid()){ int index = parentProperty.indexOf(stateNode); if (index == 0) setCurrentState(parentProperty.at(1)); else setCurrentState(parentProperty.at(index - 1)); } stateNode.destroy(); } } catch (RewritingException &e) { QMessageBox::warning(0, "Error", e.description()); } }
ModelNode ComponentView::modelNode(int index) const { if (m_standardItemModel->hasIndex(index, 0)) { QStandardItem *item = m_standardItemModel->item(index, 0); return modelNodeForInternalId(qint32(item->data(ModelNodeRole).toInt())); } return ModelNode(); }
void StatesEditorView::synchonizeCurrentStateFromWidget() { if (!model()) return; int internalId = m_statesEditorWidget->currentStateInternalId(); if (internalId > 0 && hasModelNodeForInternalId(internalId)) { ModelNode node = modelNodeForInternalId(internalId); QmlModelState modelState(node); if (modelState.isValid() && modelState != currentState()) setCurrentState(modelState); } else { setCurrentState(baseState()); } }
void StatesEditorView::renameState(int nodeId, const QString &newName) { if (hasModelNodeForInternalId(nodeId)) { QmlModelState state(modelNodeForInternalId(nodeId)); try { if (state.isValid() && state.name() != newName) { // Jump to base state for the change QmlModelState oldState = currentState(); setCurrentState(baseState()); state.setName(newName); setCurrentState(oldState); } } catch (RewritingException &e) { QMessageBox::warning(0, "Error", e.description()); } } }
void StatesEditorView::renameState(int internalNodeId, const QString &newName) { if (hasModelNodeForInternalId(internalNodeId)) { QmlModelState state(modelNodeForInternalId(internalNodeId)); try { if (state.isValid() && state.name() != newName) { // Jump to base state for the change QmlModelState oldState = currentState(); setCurrentState(baseState()); state.setName(newName); setCurrentState(oldState); } } catch (const RewritingException &e) { e.showException(); } } }