forked from qt-creator/qt-creator
QmlDesigner: bulk clang-format trial
Task-number: QDS-9097 Change-Id: I9b063614030831a2dda6dbdc2bbc79205d6baeaf Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -6,14 +6,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner::Internal {
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
StatesEditorImageProvider::StatesEditorImageProvider()
|
StatesEditorImageProvider::StatesEditorImageProvider()
|
||||||
: QQuickImageProvider(QQuickImageProvider::Image)
|
: QQuickImageProvider(QQuickImageProvider::Image)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
||||||
{
|
{
|
||||||
@@ -28,7 +25,8 @@ QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, c
|
|||||||
bool canBeConverted;
|
bool canBeConverted;
|
||||||
int instanceId = imageId.toInt(&canBeConverted);
|
int instanceId = imageId.toInt(&canBeConverted);
|
||||||
if (canBeConverted && m_nodeInstanceView->hasModelNodeForInternalId(instanceId)) {
|
if (canBeConverted && m_nodeInstanceView->hasModelNodeForInternalId(instanceId)) {
|
||||||
image = m_nodeInstanceView->statePreviewImage(m_nodeInstanceView->modelNodeForInternalId(instanceId));
|
image = m_nodeInstanceView->statePreviewImage(
|
||||||
|
m_nodeInstanceView->modelNodeForInternalId(instanceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +35,7 @@ QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, c
|
|||||||
//creating white QImage
|
//creating white QImage
|
||||||
QSize newSize = requestedSize;
|
QSize newSize = requestedSize;
|
||||||
if (newSize.isEmpty())
|
if (newSize.isEmpty())
|
||||||
newSize = QSize (100, 100);
|
newSize = QSize(100, 100);
|
||||||
|
|
||||||
QImage image(newSize, QImage::Format_ARGB32);
|
QImage image(newSize, QImage::Format_ARGB32);
|
||||||
image.fill(0xFFFFFFFF);
|
image.fill(0xFFFFFFFF);
|
||||||
@@ -54,7 +52,4 @@ void StatesEditorImageProvider::setNodeInstanceView(const NodeInstanceView *node
|
|||||||
m_nodeInstanceView = nodeInstanceView;
|
m_nodeInstanceView = nodeInstanceView;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // QmlDesigner::Internal
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include"abstractview.h"
|
#include "abstractview.h"
|
||||||
|
|
||||||
#include <QQuickImageProvider>
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QQuickImageProvider>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@@ -6,30 +6,26 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <nodelistproperty.h>
|
|
||||||
#include <modelnode.h>
|
|
||||||
#include <bindingproperty.h>
|
#include <bindingproperty.h>
|
||||||
#include <variantproperty.h>
|
#include <modelnode.h>
|
||||||
|
#include <nodelistproperty.h>
|
||||||
#include <rewriterview.h>
|
#include <rewriterview.h>
|
||||||
|
#include <variantproperty.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
enum {
|
enum { debug = false };
|
||||||
debug = false
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
StatesEditorModel::StatesEditorModel(StatesEditorView *view)
|
StatesEditorModel::StatesEditorModel(StatesEditorView *view)
|
||||||
: QAbstractListModel(view),
|
: QAbstractListModel(view)
|
||||||
m_statesEditorView(view),
|
, m_statesEditorView(view)
|
||||||
m_updateCounter(0)
|
, m_updateCounter(0)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
int StatesEditorModel::count() const
|
int StatesEditorModel::count() const
|
||||||
{
|
{
|
||||||
@@ -43,9 +39,12 @@ QModelIndex StatesEditorModel::index(int row, int column, const QModelIndex &par
|
|||||||
|
|
||||||
int internalNodeId = 0;
|
int internalNodeId = 0;
|
||||||
if (row > 0 && row < rowCount() - 1) // first and last rows are base state, add state
|
if (row > 0 && row < rowCount() - 1) // first and last rows are base state, add state
|
||||||
internalNodeId = m_statesEditorView->acitveStatesGroupNode().nodeListProperty("states").at(row - 1).internalId();
|
internalNodeId = m_statesEditorView->acitveStatesGroupNode()
|
||||||
|
.nodeListProperty("states")
|
||||||
|
.at(row - 1)
|
||||||
|
.internalId();
|
||||||
|
|
||||||
return hasIndex(row, column, parent) ? createIndex(row, column, internalNodeId) : 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
|
||||||
@@ -56,7 +55,8 @@ int StatesEditorModel::rowCount(const QModelIndex &parent) const
|
|||||||
if (!m_statesEditorView->acitveStatesGroupNode().hasNodeListProperty("states"))
|
if (!m_statesEditorView->acitveStatesGroupNode().hasNodeListProperty("states"))
|
||||||
return 2; // base state + add new state
|
return 2; // base state + add new state
|
||||||
|
|
||||||
return m_statesEditorView->acitveStatesGroupNode().nodeListProperty("states").count() + 2; // 2 = base state + add new state
|
return m_statesEditorView->acitveStatesGroupNode().nodeListProperty("states").count()
|
||||||
|
+ 2; // 2 = base state + add new state
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorModel::reset()
|
void StatesEditorModel::reset()
|
||||||
@@ -67,7 +67,8 @@ void StatesEditorModel::reset()
|
|||||||
|
|
||||||
QVariant StatesEditorModel::data(const QModelIndex &index, int role) const
|
QVariant StatesEditorModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (index.parent().isValid() || index.column() != 0 || m_statesEditorView.isNull() || !m_statesEditorView->hasModelNodeForInternalId(index.internalId()))
|
if (index.parent().isValid() || index.column() != 0 || m_statesEditorView.isNull()
|
||||||
|
|| !m_statesEditorView->hasModelNodeForInternalId(index.internalId()))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
ModelNode stateNode;
|
ModelNode stateNode;
|
||||||
@@ -121,16 +122,14 @@ QVariant StatesEditorModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
QHash<int, QByteArray> StatesEditorModel::roleNames() const
|
QHash<int, QByteArray> StatesEditorModel::roleNames() const
|
||||||
{
|
{
|
||||||
static QHash<int, QByteArray> roleNames {
|
static QHash<int, QByteArray> roleNames{{StateNameRole, "stateName"},
|
||||||
{StateNameRole, "stateName"},
|
{StateImageSourceRole, "stateImageSource"},
|
||||||
{StateImageSourceRole, "stateImageSource"},
|
{InternalNodeId, "internalNodeId"},
|
||||||
{InternalNodeId, "internalNodeId"},
|
{HasWhenCondition, "hasWhenCondition"},
|
||||||
{HasWhenCondition, "hasWhenCondition"},
|
{WhenConditionString, "whenConditionString"},
|
||||||
{WhenConditionString, "whenConditionString"},
|
{IsDefault, "isDefault"},
|
||||||
{IsDefault, "isDefault"},
|
{ModelHasDefaultState, "modelHasDefaultState"},
|
||||||
{ModelHasDefaultState, "modelHasDefaultState"},
|
{StateType, "type"}};
|
||||||
{StateType, "type"}
|
|
||||||
};
|
|
||||||
return roleNames;
|
return roleNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,19 +166,17 @@ void StatesEditorModel::renameState(int internalNodeId, const QString &newName)
|
|||||||
if (newName == m_statesEditorView->currentStateName())
|
if (newName == m_statesEditorView->currentStateName())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) {
|
if (newName.isEmpty() || !m_statesEditorView->validStateName(newName)) {
|
||||||
QTimer::singleShot(0, [newName]{
|
QTimer::singleShot(0, [newName] {
|
||||||
Core::AsynchronousMessageBox::warning(
|
Core::AsynchronousMessageBox::warning(
|
||||||
tr("Invalid State Name"),
|
tr("Invalid State Name"),
|
||||||
newName.isEmpty() ?
|
newName.isEmpty() ? 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."));
|
|
||||||
});
|
});
|
||||||
reset();
|
reset();
|
||||||
} else {
|
} else {
|
||||||
m_statesEditorView->renameState(internalNodeId, newName);
|
m_statesEditorView->renameState(internalNodeId, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorModel::setWhenCondition(int internalNodeId, const QString &condition)
|
void StatesEditorModel::setWhenCondition(int internalNodeId, const QString &condition)
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class StatesEditorView;
|
class StatesEditorView;
|
||||||
@@ -52,7 +51,6 @@ public:
|
|||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changedToState(int n);
|
void changedToState(int n);
|
||||||
|
|
||||||
|
@@ -2,30 +2,30 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "stateseditorview.h"
|
#include "stateseditorview.h"
|
||||||
#include "stateseditorwidget.h"
|
|
||||||
#include "stateseditormodel.h"
|
#include "stateseditormodel.h"
|
||||||
|
#include "stateseditorwidget.h"
|
||||||
|
|
||||||
#include <rewritingexception.h>
|
#include <rewritingexception.h>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <cmath>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <nodemetainfo.h>
|
|
||||||
|
|
||||||
#include <bindingproperty.h>
|
#include <bindingproperty.h>
|
||||||
#include <variantproperty.h>
|
|
||||||
#include <nodelistproperty.h>
|
#include <nodelistproperty.h>
|
||||||
|
#include <nodemetainfo.h>
|
||||||
|
#include <variantproperty.h>
|
||||||
#include <qmldesignerconstants.h>
|
#include <qmldesignerconstants.h>
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
#include <qmlitemnode.h>
|
#include <qmlitemnode.h>
|
||||||
#include <qmlstate.h>
|
#include <qmlstate.h>
|
||||||
|
|
||||||
#include <annotationeditor/annotationeditor.h>
|
#include <annotationeditor/annotationeditor.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -63,7 +63,9 @@ WidgetInfo StatesEditorView::widgetInfo()
|
|||||||
tr("States view"));
|
tr("States view"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)
|
void StatesEditorView::rootNodeTypeChanged(const QString & /*type*/,
|
||||||
|
int /*majorVersion*/,
|
||||||
|
int /*minorVersion*/)
|
||||||
{
|
{
|
||||||
checkForStatesAvailability();
|
checkForStatesAvailability();
|
||||||
}
|
}
|
||||||
@@ -94,13 +96,14 @@ void StatesEditorView::removeState(int nodeId)
|
|||||||
QStringList lockedTargets;
|
QStringList lockedTargets;
|
||||||
const auto propertyChanges = modelState.propertyChanges();
|
const auto propertyChanges = modelState.propertyChanges();
|
||||||
|
|
||||||
// confirm removing not empty states
|
// confirm removing not empty states
|
||||||
if (!propertyChanges.isEmpty()) {
|
if (!propertyChanges.isEmpty()) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setTextFormat(Qt::RichText);
|
msgBox.setTextFormat(Qt::RichText);
|
||||||
msgBox.setIcon(QMessageBox::Question);
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
msgBox.setWindowTitle(tr("Remove State"));
|
msgBox.setWindowTitle(tr("Remove State"));
|
||||||
msgBox.setText(tr("This state is not empty. Are you sure you want to remove it?"));
|
msgBox.setText(
|
||||||
|
tr("This state is not empty. Are you sure you want to remove it?"));
|
||||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||||
|
|
||||||
@@ -129,8 +132,9 @@ void StatesEditorView::removeState(int nodeId)
|
|||||||
msgBox.setTextFormat(Qt::RichText);
|
msgBox.setTextFormat(Qt::RichText);
|
||||||
msgBox.setIcon(QMessageBox::Question);
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
msgBox.setWindowTitle(tr("Remove State"));
|
msgBox.setWindowTitle(tr("Remove State"));
|
||||||
msgBox.setText(QString(tr("Removing this state will modify locked components.") + "<br><br>%1")
|
msgBox.setText(QString(tr("Removing this state will modify locked components.")
|
||||||
.arg(detailedText));
|
+ "<br><br>%1")
|
||||||
|
.arg(detailedText));
|
||||||
msgBox.setInformativeText(tr("Continue by removing the state?"));
|
msgBox.setInformativeText(tr("Continue by removing the state?"));
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
@@ -154,7 +158,7 @@ void StatesEditorView::removeState(int nodeId)
|
|||||||
|
|
||||||
stateNode.destroy();
|
stateNode.destroy();
|
||||||
}
|
}
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
e.showException();
|
e.showException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,12 +489,14 @@ void StatesEditorView::modelAboutToBeDetached(Model *model)
|
|||||||
resetModel();
|
resetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::propertiesRemoved(const QList<AbstractProperty>& propertyList)
|
void StatesEditorView::propertiesRemoved(const QList<AbstractProperty> &propertyList)
|
||||||
{
|
{
|
||||||
for (const AbstractProperty &property : propertyList) {
|
for (const AbstractProperty &property : propertyList) {
|
||||||
if (property.name() == "states" && property.parentModelNode() == activeStateGroup().modelNode())
|
if (property.name() == "states"
|
||||||
|
&& property.parentModelNode() == activeStateGroup().modelNode())
|
||||||
resetModel();
|
resetModel();
|
||||||
if (property.name() == "when" && QmlModelState::isValidQmlModelState(property.parentModelNode()))
|
if (property.name() == "when"
|
||||||
|
&& QmlModelState::isValidQmlModelState(property.parentModelNode()))
|
||||||
resetModel();
|
resetModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,22 +505,29 @@ void StatesEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
|||||||
{
|
{
|
||||||
if (removedNode.hasParentProperty()) {
|
if (removedNode.hasParentProperty()) {
|
||||||
const NodeAbstractProperty propertyParent = removedNode.parentProperty();
|
const NodeAbstractProperty propertyParent = removedNode.parentProperty();
|
||||||
if (propertyParent.parentModelNode() == activeStateGroup().modelNode() && propertyParent.name() == "states")
|
if (propertyParent.parentModelNode() == activeStateGroup().modelNode()
|
||||||
|
&& propertyParent.name() == "states")
|
||||||
m_lastIndex = propertyParent.indexOf(removedNode);
|
m_lastIndex = propertyParent.indexOf(removedNode);
|
||||||
}
|
}
|
||||||
if (currentState().isValid() && removedNode == currentState())
|
if (currentState().isValid() && removedNode == currentState())
|
||||||
setCurrentState(baseState());
|
setCurrentState(baseState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::nodeRemoved(const ModelNode & /*removedNode*/, const NodeAbstractProperty &parentProperty, PropertyChangeFlags /*propertyChange*/)
|
void StatesEditorView::nodeRemoved(const ModelNode & /*removedNode*/,
|
||||||
|
const NodeAbstractProperty &parentProperty,
|
||||||
|
PropertyChangeFlags /*propertyChange*/)
|
||||||
{
|
{
|
||||||
if (parentProperty.isValid() && parentProperty.parentModelNode() == activeStateGroup().modelNode() && parentProperty.name() == "states") {
|
if (parentProperty.isValid() && parentProperty.parentModelNode() == activeStateGroup().modelNode()
|
||||||
|
&& parentProperty.name() == "states") {
|
||||||
m_statesEditorModel->removeState(m_lastIndex);
|
m_statesEditorModel->removeState(m_lastIndex);
|
||||||
m_lastIndex = -1;
|
m_lastIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags /*propertyChange*/)
|
void StatesEditorView::nodeAboutToBeReparented(const ModelNode &node,
|
||||||
|
const NodeAbstractProperty & /*newPropertyParent*/,
|
||||||
|
const NodeAbstractProperty &oldPropertyParent,
|
||||||
|
AbstractView::PropertyChangeFlags /*propertyChange*/)
|
||||||
{
|
{
|
||||||
if (oldPropertyParent.isValid()
|
if (oldPropertyParent.isValid()
|
||||||
&& oldPropertyParent.parentModelNode() == activeStateGroup().modelNode()
|
&& oldPropertyParent.parentModelNode() == activeStateGroup().modelNode()
|
||||||
@@ -522,8 +535,10 @@ void StatesEditorView::nodeAboutToBeReparented(const ModelNode &node, const Node
|
|||||||
m_lastIndex = oldPropertyParent.indexOf(node);
|
m_lastIndex = oldPropertyParent.indexOf(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatesEditorView::nodeReparented(const ModelNode &node,
|
||||||
void StatesEditorView::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags /*propertyChange*/)
|
const NodeAbstractProperty &newPropertyParent,
|
||||||
|
const NodeAbstractProperty &oldPropertyParent,
|
||||||
|
AbstractView::PropertyChangeFlags /*propertyChange*/)
|
||||||
{
|
{
|
||||||
if (oldPropertyParent.isValid()
|
if (oldPropertyParent.isValid()
|
||||||
&& oldPropertyParent.parentModelNode() == activeStateGroup().modelNode()
|
&& oldPropertyParent.parentModelNode() == activeStateGroup().modelNode()
|
||||||
@@ -552,7 +567,8 @@ void StatesEditorView::bindingPropertiesChanged(
|
|||||||
[[maybe_unused]] AbstractView::PropertyChangeFlags propertyChange)
|
[[maybe_unused]] AbstractView::PropertyChangeFlags propertyChange)
|
||||||
{
|
{
|
||||||
for (const BindingProperty &property : propertyList) {
|
for (const BindingProperty &property : propertyList) {
|
||||||
if (property.name() == "when" && QmlModelState::isValidQmlModelState(property.parentModelNode()))
|
if (property.name() == "when"
|
||||||
|
&& QmlModelState::isValidQmlModelState(property.parentModelNode()))
|
||||||
resetModel();
|
resetModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,7 +583,8 @@ void StatesEditorView::variantPropertiesChanged(const QList<VariantProperty> &pr
|
|||||||
auto guard = qScopeGuard([&]() { m_block = false; });
|
auto guard = qScopeGuard([&]() { m_block = false; });
|
||||||
|
|
||||||
for (const VariantProperty &property : propertyList) {
|
for (const VariantProperty &property : propertyList) {
|
||||||
if (property.name() == "name" && QmlModelState::isValidQmlModelState(property.parentModelNode()))
|
if (property.name() == "name"
|
||||||
|
&& QmlModelState::isValidQmlModelState(property.parentModelNode()))
|
||||||
resetModel();
|
resetModel();
|
||||||
else if (property.name() == "state"
|
else if (property.name() == "state"
|
||||||
&& property.parentModelNode() == activeStateGroup().modelNode())
|
&& property.parentModelNode() == activeStateGroup().modelNode())
|
||||||
|
@@ -13,14 +13,15 @@ class StatesEditorModel;
|
|||||||
class StatesEditorWidget;
|
class StatesEditorWidget;
|
||||||
class AnnotationEditor;
|
class AnnotationEditor;
|
||||||
|
|
||||||
class StatesEditorView : public AbstractView {
|
class StatesEditorView : public AbstractView
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StatesEditorView(ExternalDependenciesInterface &externalDependencies);
|
explicit StatesEditorView(ExternalDependenciesInterface &externalDependencies);
|
||||||
~StatesEditorView() override;
|
~StatesEditorView() override;
|
||||||
|
|
||||||
void renameState(int internalNodeId,const QString &newName);
|
void renameState(int internalNodeId, const QString &newName);
|
||||||
void setWhenCondition(int internalNodeId, const QString &condition);
|
void setWhenCondition(int internalNodeId, const QString &condition);
|
||||||
void resetWhenCondition(int internalNodeId);
|
void resetWhenCondition(int internalNodeId);
|
||||||
void setStateAsDefault(int internalNodeId);
|
void setStateAsDefault(int internalNodeId);
|
||||||
@@ -38,7 +39,7 @@ public:
|
|||||||
// AbstractView
|
// AbstractView
|
||||||
void modelAttached(Model *model) override;
|
void modelAttached(Model *model) override;
|
||||||
void modelAboutToBeDetached(Model *model) override;
|
void modelAboutToBeDetached(Model *model) override;
|
||||||
void propertiesRemoved(const QList<AbstractProperty>& propertyList) override;
|
void propertiesRemoved(const QList<AbstractProperty> &propertyList) override;
|
||||||
void nodeAboutToBeRemoved(const ModelNode &removedNode) override;
|
void nodeAboutToBeRemoved(const ModelNode &removedNode) override;
|
||||||
void nodeRemoved(const ModelNode &removedNode,
|
void nodeRemoved(const ModelNode &removedNode,
|
||||||
const NodeAbstractProperty &parentProperty,
|
const NodeAbstractProperty &parentProperty,
|
||||||
@@ -52,9 +53,10 @@ public:
|
|||||||
const NodeAbstractProperty &oldPropertyParent,
|
const NodeAbstractProperty &oldPropertyParent,
|
||||||
AbstractView::PropertyChangeFlags propertyChange) override;
|
AbstractView::PropertyChangeFlags propertyChange) override;
|
||||||
void nodeOrderChanged(const NodeListProperty &listProperty) override;
|
void nodeOrderChanged(const NodeListProperty &listProperty) override;
|
||||||
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) override;
|
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList,
|
||||||
void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange) override;
|
PropertyChangeFlags propertyChange) override;
|
||||||
|
void variantPropertiesChanged(const QList<VariantProperty> &propertyList,
|
||||||
|
PropertyChangeFlags propertyChange) override;
|
||||||
|
|
||||||
// AbstractView
|
// AbstractView
|
||||||
void currentStateChanged(const ModelNode &node) override;
|
void currentStateChanged(const ModelNode &node) override;
|
||||||
@@ -68,7 +70,6 @@ public:
|
|||||||
ModelNode acitveStatesGroupNode() const;
|
ModelNode acitveStatesGroupNode() const;
|
||||||
void setAcitveStatesGroupNode(const ModelNode &modelNode);
|
void setAcitveStatesGroupNode(const ModelNode &modelNode);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void synchonizeCurrentStateFromWidget();
|
void synchonizeCurrentStateFromWidget();
|
||||||
void createNewState();
|
void createNewState();
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "stateseditorwidget.h"
|
#include "stateseditorwidget.h"
|
||||||
|
#include "stateseditorimageprovider.h"
|
||||||
#include "stateseditormodel.h"
|
#include "stateseditormodel.h"
|
||||||
#include "stateseditorview.h"
|
#include "stateseditorview.h"
|
||||||
#include "stateseditorimageprovider.h"
|
|
||||||
|
|
||||||
#include <designersettings.h>
|
#include <designersettings.h>
|
||||||
#include <theme.h>
|
#include <theme.h>
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
#include <invalidqmlsourceexception.h>
|
#include <invalidqmlsourceexception.h>
|
||||||
|
|
||||||
#include <coreplugin/messagebox.h>
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/messagebox.h>
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -22,18 +22,16 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QShortcut>
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
#include <QShortcut>
|
||||||
|
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
|
||||||
enum {
|
enum { debug = false };
|
||||||
debug = false
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -70,10 +68,11 @@ void StatesEditorWidget::showAddNewStatesButton(bool showAddNewStatesButton)
|
|||||||
rootContext()->setContextProperty(QLatin1String("canAddNewStates"), showAddNewStatesButton);
|
rootContext()->setContextProperty(QLatin1String("canAddNewStates"), showAddNewStatesButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, StatesEditorModel *statesEditorModel)
|
StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView,
|
||||||
: m_statesEditorView(statesEditorView),
|
StatesEditorModel *statesEditorModel)
|
||||||
m_imageProvider(nullptr),
|
: m_statesEditorView(statesEditorView)
|
||||||
m_qmlSourceUpdateShortcut(nullptr)
|
, m_imageProvider(nullptr)
|
||||||
|
, m_qmlSourceUpdateShortcut(nullptr)
|
||||||
{
|
{
|
||||||
m_imageProvider = new Internal::StatesEditorImageProvider;
|
m_imageProvider = new Internal::StatesEditorImageProvider;
|
||||||
m_imageProvider->setNodeInstanceView(statesEditorView->nodeInstanceView());
|
m_imageProvider->setNodeInstanceView(statesEditorView->nodeInstanceView());
|
||||||
@@ -89,11 +88,9 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
|
|||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
rootContext()->setContextProperties(
|
rootContext()->setContextProperties(
|
||||||
QVector<QQmlContext::PropertyPair>{
|
QVector<QQmlContext::PropertyPair>{{{"statesEditorModel"},
|
||||||
{{"statesEditorModel"}, QVariant::fromValue(statesEditorModel)},
|
QVariant::fromValue(statesEditorModel)},
|
||||||
{{"canAddNewStates"}, true}
|
{{"canAddNewStates"}, true}});
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
Theme::setupTheme(engine());
|
Theme::setupTheme(engine());
|
||||||
|
|
||||||
@@ -147,14 +144,17 @@ void StatesEditorWidget::reloadQmlSource()
|
|||||||
|
|
||||||
Core::AsynchronousMessageBox::warning(tr("Cannot Create QtQuick View"),
|
Core::AsynchronousMessageBox::warning(tr("Cannot Create QtQuick View"),
|
||||||
tr("StatesEditorWidget: %1 cannot be created.%2")
|
tr("StatesEditorWidget: %1 cannot be created.%2")
|
||||||
.arg(qmlSourcesPath(), errorString));
|
.arg(qmlSourcesPath(), errorString));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget()));
|
connect(rootObject(),
|
||||||
|
SIGNAL(currentStateInternalIdChanged()),
|
||||||
|
m_statesEditorView.data(),
|
||||||
|
SLOT(synchonizeCurrentStateFromWidget()));
|
||||||
connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
|
connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
|
||||||
connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
|
connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
|
||||||
m_statesEditorView.data()->synchonizeCurrentStateFromWidget();
|
m_statesEditorView.data()->synchonizeCurrentStateFromWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -19,7 +19,9 @@ class StatesEditorModel;
|
|||||||
class StatesEditorView;
|
class StatesEditorView;
|
||||||
class NodeInstanceView;
|
class NodeInstanceView;
|
||||||
|
|
||||||
namespace Internal { class StatesEditorImageProvider; }
|
namespace Internal {
|
||||||
|
class StatesEditorImageProvider;
|
||||||
|
}
|
||||||
|
|
||||||
class StatesEditorWidget : public StudioQuickWidget
|
class StatesEditorWidget : public StudioQuickWidget
|
||||||
{
|
{
|
||||||
@@ -52,4 +54,4 @@ private:
|
|||||||
QElapsedTimer m_usageTimer;
|
QElapsedTimer m_usageTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace QmlDesigner
|
||||||
|
Reference in New Issue
Block a user