forked from qt-creator/qt-creator
QmlDesigner: rename nodeId -> internalNodeId
Change-Id: I8f038479f31a282db256144a3254e438eb6a629f Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
@@ -48,7 +48,7 @@ Rectangle {
|
|||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: root.currentStateInternalId = nodeId
|
onClicked: root.currentStateInternalId = internalNodeId
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
ToolButton {
|
||||||
@@ -60,7 +60,7 @@ Rectangle {
|
|||||||
width: 16
|
width: 16
|
||||||
iconSource: "images/darkclose.png"
|
iconSource: "images/darkclose.png"
|
||||||
|
|
||||||
onClicked: root.deleteState(nodeId)
|
onClicked: root.deleteState(internalNodeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
@@ -75,7 +75,7 @@ Rectangle {
|
|||||||
Component.onCompleted: text = delegateStateName
|
Component.onCompleted: text = delegateStateName
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
if (text != delegateStateName)
|
if (text != delegateStateName)
|
||||||
statesEditorModel.renameState(nodeId, text)
|
statesEditorModel.renameState(internalNodeId, text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ Rectangle {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
signal createNewState
|
signal createNewState
|
||||||
signal deleteState(int nodeId)
|
signal deleteState(int internalNodeId)
|
||||||
signal duplicateCurrentState
|
signal duplicateCurrentState
|
||||||
|
|
||||||
property int stateImageSize: 100
|
property int stateImageSize: 100
|
||||||
@@ -92,6 +92,7 @@ Rectangle {
|
|||||||
id: statesDelegate
|
id: statesDelegate
|
||||||
width: delegateWidth
|
width: delegateWidth
|
||||||
height: delegateHeight
|
height: delegateHeight
|
||||||
|
isCurrentState: root.currentStateInternalId == internalNodeId
|
||||||
gradiantBaseColor: isCurrentState ? Qt.darker(highlightColor, 1.8) : root.color
|
gradiantBaseColor: isCurrentState ? Qt.darker(highlightColor, 1.8) : root.color
|
||||||
delegateStateName: stateName
|
delegateStateName: stateName
|
||||||
delegateStateImageSource: stateImageSource
|
delegateStateImageSource: stateImageSource
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ StatesEditorModel::StatesEditorModel(StatesEditorView *view)
|
|||||||
QHash<int, QByteArray> roleNames;
|
QHash<int, QByteArray> roleNames;
|
||||||
roleNames.insert(StateNameRole, "stateName");
|
roleNames.insert(StateNameRole, "stateName");
|
||||||
roleNames.insert(StateImageSourceRole, "stateImageSource");
|
roleNames.insert(StateImageSourceRole, "stateImageSource");
|
||||||
roleNames.insert(NodeId, "nodeId");
|
roleNames.insert(InternalNodeId, "internalNodeId");
|
||||||
setRoleNames(roleNames);
|
setRoleNames(roleNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,11 +72,11 @@ QModelIndex StatesEditorModel::index(int row, int column, const QModelIndex &par
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
|
|
||||||
int internalId = 0;
|
int internalNodeId = 0;
|
||||||
if (row > 0)
|
if (row > 0)
|
||||||
internalId = m_statesEditorView->rootModelNode().nodeListProperty("states").at(row - 1).internalId();
|
internalNodeId = m_statesEditorView->rootModelNode().nodeListProperty("states").at(row - 1).internalId();
|
||||||
|
|
||||||
return hasIndex(row, column, parent) ? createIndex(row, column, internalId) : QModelIndex();
|
return hasIndex(row, column, parent) ? createIndex(row, column, internalNodeId) : QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
int StatesEditorModel::rowCount(const QModelIndex &parent) const
|
int StatesEditorModel::rowCount(const QModelIndex &parent) const
|
||||||
@@ -126,7 +126,7 @@ QVariant StatesEditorModel::data(const QModelIndex &index, int role) const
|
|||||||
else
|
else
|
||||||
return QString("image://qmldesigner_stateseditor/%1-%2").arg(index.internalId()).arg(randomNumber);
|
return QString("image://qmldesigner_stateseditor/%1-%2").arg(index.internalId()).arg(randomNumber);
|
||||||
}
|
}
|
||||||
case NodeId : return index.internalId();
|
case InternalNodeId : return index.internalId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ void StatesEditorModel::removeState(int stateIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorModel::renameState(int nodeId, const QString &newName)
|
void StatesEditorModel::renameState(int internalNodeId, const QString &newName)
|
||||||
{
|
{
|
||||||
if (newName == m_statesEditorView->currentStateName())
|
if (newName == m_statesEditorView->currentStateName())
|
||||||
return;
|
return;
|
||||||
@@ -178,7 +178,7 @@ void StatesEditorModel::renameState(int nodeId, const QString &newName)
|
|||||||
tr("The empty string as a name is reserved for the base state.") :
|
tr("The empty string as a name is reserved for the base state.") :
|
||||||
tr("Name already used in another state"));
|
tr("Name already used in another state"));
|
||||||
} else {
|
} else {
|
||||||
m_statesEditorView->renameState(nodeId, newName);
|
m_statesEditorView->renameState(internalNodeId, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class StatesEditorModel : public QAbstractListModel
|
|||||||
enum {
|
enum {
|
||||||
StateNameRole = Qt::DisplayRole,
|
StateNameRole = Qt::DisplayRole,
|
||||||
StateImageSourceRole = Qt::UserRole,
|
StateImageSourceRole = Qt::UserRole,
|
||||||
NodeId
|
InternalNodeId
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
void insertState(int stateIndex);
|
void insertState(int stateIndex);
|
||||||
void removeState(int stateIndex);
|
void removeState(int stateIndex);
|
||||||
void updateState(int beginIndex, int endIndex);
|
void updateState(int beginIndex, int endIndex);
|
||||||
Q_INVOKABLE void renameState(int nodeId, const QString &newName);
|
Q_INVOKABLE void renameState(int internalNodeId, const QString &newName);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|||||||
@@ -291,10 +291,10 @@ QString StatesEditorView::currentStateName() const
|
|||||||
return currentState().isValid() ? currentState().name() : QString();
|
return currentState().isValid() ? currentState().name() : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::renameState(int nodeId, const QString &newName)
|
void StatesEditorView::renameState(int internalNodeId, const QString &newName)
|
||||||
{
|
{
|
||||||
if (hasModelNodeForInternalId(nodeId)) {
|
if (hasModelNodeForInternalId(internalNodeId)) {
|
||||||
QmlModelState state(modelNodeForInternalId(nodeId));
|
QmlModelState state(modelNodeForInternalId(internalNodeId));
|
||||||
try {
|
try {
|
||||||
if (state.isValid() && state.name() != newName) {
|
if (state.isValid() && state.name() != newName) {
|
||||||
// Jump to base state for the change
|
// Jump to base state for the change
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
explicit StatesEditorView(QObject *parent = 0);
|
explicit StatesEditorView(QObject *parent = 0);
|
||||||
~StatesEditorView();
|
~StatesEditorView();
|
||||||
|
|
||||||
void renameState(int nodeId,const QString &newName);
|
void renameState(int internalNodeId,const QString &newName);
|
||||||
bool validStateName(const QString &name) const;
|
bool validStateName(const QString &name) const;
|
||||||
QString currentStateName() const;
|
QString currentStateName() const;
|
||||||
void setCurrentState(const QmlModelState &state);
|
void setCurrentState(const QmlModelState &state);
|
||||||
|
|||||||
Reference in New Issue
Block a user