forked from qt-creator/qt-creator
QmlDesigner: Implement command for synchronising the selection
This patch implements the command and dispatchers for synchronising the selection between Qt Creator and the qml2puppet. Qt5InformationNodeInstanceServer::changeSelection() is called whenever the selection is changed in Qt Creator. Qt5InformationNodeInstanceServer::changeSelection() allows to change the selection from the qml2puppet. Change-Id: I73a64d8dc2a3f330433f966b42a10229cbbff649 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Alessandro Portale
parent
e7b481bdee
commit
640044c8f8
@@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2019 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "changeselectioncommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeSelectionCommand::ChangeSelectionCommand() = default;
|
||||
|
||||
ChangeSelectionCommand::ChangeSelectionCommand(const QVector<qint32> &idVector)
|
||||
: m_instanceIdVector(idVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<qint32> ChangeSelectionCommand::instanceIds() const
|
||||
{
|
||||
return m_instanceIdVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeSelectionCommand &command)
|
||||
{
|
||||
out << command.instanceIds();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command)
|
||||
{
|
||||
in >> command.m_instanceIdVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeSelectionCommand(instanceIdVector: " << command.m_instanceIdVector << ")";
|
||||
}
|
||||
|
||||
bool operator ==(const ChangeSelectionCommand &first, const ChangeSelectionCommand &second)
|
||||
{
|
||||
return first.m_instanceIdVector == second.m_instanceIdVector;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2019 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeSelectionCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command);
|
||||
friend bool operator ==(const ChangeSelectionCommand &first,
|
||||
const ChangeSelectionCommand &second);
|
||||
|
||||
public:
|
||||
ChangeSelectionCommand();
|
||||
explicit ChangeSelectionCommand(const QVector<qint32> &idVector);
|
||||
|
||||
QVector<qint32> instanceIds() const;
|
||||
|
||||
private:
|
||||
QVector<qint32> m_instanceIdVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeSelectionCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command);
|
||||
bool operator ==(const ChangeSelectionCommand &first, const ChangeSelectionCommand &second);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeSelectionCommand)
|
@@ -26,6 +26,7 @@ HEADERS += $$PWD/valueschangedcommand.h
|
||||
HEADERS += $$PWD/changeauxiliarycommand.h
|
||||
HEADERS += $$PWD/removesharedmemorycommand.h
|
||||
HEADERS += $$PWD/puppetalivecommand.h
|
||||
HEADERS += $$PWD/changeselectioncommand.h
|
||||
|
||||
SOURCES += $$PWD/synchronizecommand.cpp
|
||||
SOURCES += $$PWD/debugoutputcommand.cpp
|
||||
@@ -53,3 +54,4 @@ SOURCES += $$PWD/pixmapchangedcommand.cpp
|
||||
SOURCES += $$PWD/changeauxiliarycommand.cpp
|
||||
SOURCES += $$PWD/removesharedmemorycommand.cpp
|
||||
SOURCES += $$PWD/puppetalivecommand.cpp
|
||||
SOURCES += $$PWD/changeselectioncommand.cpp
|
||||
|
@@ -67,6 +67,7 @@
|
||||
#include "endpuppetcommand.h"
|
||||
#include "debugoutputcommand.h"
|
||||
#include "puppetalivecommand.h"
|
||||
#include "changeselectioncommand.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -136,6 +137,7 @@ bool compareCommands(const QVariant &command, const QVariant &controlCommand)
|
||||
static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand");
|
||||
static const int tokenCommandType = QMetaType::type("TokenCommand");
|
||||
static const int debugOutputCommandType = QMetaType::type("DebugOutputCommand");
|
||||
static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand");
|
||||
|
||||
if (command.userType() == controlCommand.userType()) {
|
||||
if (command.userType() == informationChangedCommandType)
|
||||
@@ -156,6 +158,8 @@ bool compareCommands(const QVariant &command, const QVariant &controlCommand)
|
||||
return command.value<TokenCommand>() == controlCommand.value<TokenCommand>();
|
||||
else if (command.userType() == debugOutputCommandType)
|
||||
return command.value<DebugOutputCommand>() == controlCommand.value<DebugOutputCommand>();
|
||||
else if (command.userType() == changeSelectionCommandType)
|
||||
return command.value<ChangeSelectionCommand>() == controlCommand.value<ChangeSelectionCommand>();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -233,6 +237,11 @@ void NodeInstanceClientProxy::puppetAlive(const PuppetAliveCommand &command)
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::selectionChanged(const ChangeSelectionCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::flush()
|
||||
{
|
||||
}
|
||||
@@ -252,9 +261,6 @@ qint64 NodeInstanceClientProxy::bytesToWrite() const
|
||||
|
||||
QVariant NodeInstanceClientProxy::readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize)
|
||||
{
|
||||
|
||||
|
||||
|
||||
QDataStream in(ioDevice);
|
||||
in.setVersion(QDataStream::Qt_4_8);
|
||||
|
||||
@@ -416,6 +422,11 @@ void NodeInstanceClientProxy::redirectToken(const EndPuppetCommand & /*command*/
|
||||
QCoreApplication::exit();
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::changeSelection(const ChangeSelectionCommand &command)
|
||||
{
|
||||
nodeInstanceServer()->changeSelection(command);
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
|
||||
{
|
||||
static const int createInstancesCommandType = QMetaType::type("CreateInstancesCommand");
|
||||
@@ -436,6 +447,7 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
|
||||
static const int removeSharedMemoryCommandType = QMetaType::type("RemoveSharedMemoryCommand");
|
||||
static const int tokenCommandType = QMetaType::type("TokenCommand");
|
||||
static const int endPuppetCommandType = QMetaType::type("EndPuppetCommand");
|
||||
static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand");
|
||||
|
||||
const int commandType = command.userType();
|
||||
|
||||
@@ -476,6 +488,9 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
|
||||
else if (commandType == synchronizeCommandType) {
|
||||
SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>();
|
||||
m_synchronizeId = synchronizeCommand.synchronizeId();
|
||||
} else if (commandType == changeSelectionCommandType) {
|
||||
ChangeSelectionCommand changeSelectionCommand = command.value<ChangeSelectionCommand>();
|
||||
changeSelection(changeSelectionCommand);
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class CompleteComponentCommand;
|
||||
class ChangeStateCommand;
|
||||
class ChangeNodeSourceCommand;
|
||||
class EndPuppetCommand;
|
||||
|
||||
class ChangeSelectionCommand;
|
||||
|
||||
class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface
|
||||
{
|
||||
@@ -74,6 +74,7 @@ public:
|
||||
void token(const TokenCommand &command) override;
|
||||
void debugOutput(const DebugOutputCommand &command) override;
|
||||
void puppetAlive(const PuppetAliveCommand &command);
|
||||
void selectionChanged(const ChangeSelectionCommand &command) override;
|
||||
|
||||
void flush() override;
|
||||
void synchronizeWithClientProcess() override;
|
||||
@@ -104,6 +105,7 @@ protected:
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
void redirectToken(const TokenCommand &command);
|
||||
void redirectToken(const EndPuppetCommand &command);
|
||||
void changeSelection(const ChangeSelectionCommand &command);
|
||||
static QVariant readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize);
|
||||
|
||||
protected slots:
|
||||
|
@@ -39,6 +39,7 @@ class TokenCommand;
|
||||
class RemoveSharedMemoryCommand;
|
||||
class DebugOutputCommand;
|
||||
class PuppetAliveCommand;
|
||||
class ChangeSelectionCommand;
|
||||
|
||||
class NodeInstanceClientInterface
|
||||
{
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
virtual void componentCompleted(const ComponentCompletedCommand &command) = 0;
|
||||
virtual void token(const TokenCommand &command) = 0;
|
||||
virtual void debugOutput(const DebugOutputCommand &command) = 0;
|
||||
virtual void selectionChanged(const ChangeSelectionCommand &command) = 0;
|
||||
|
||||
virtual void flush() {}
|
||||
virtual void synchronizeWithClientProcess() {}
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include "completecomponentcommand.h"
|
||||
#include "addimportcontainer.h"
|
||||
#include "changenodesourcecommand.h"
|
||||
#include "changeselectioncommand.h"
|
||||
|
||||
#include "informationchangedcommand.h"
|
||||
#include "pixmapchangedcommand.h"
|
||||
@@ -103,6 +104,9 @@ void NodeInstanceServerInterface::registerCommands()
|
||||
qRegisterMetaType<RemoveInstancesCommand>("RemoveInstancesCommand");
|
||||
qRegisterMetaTypeStreamOperators<RemoveInstancesCommand>("RemoveInstancesCommand");
|
||||
|
||||
qRegisterMetaType<ChangeSelectionCommand>("ChangeSelectionCommand");
|
||||
qRegisterMetaTypeStreamOperators<ChangeSelectionCommand>("ChangeSelectionCommand");
|
||||
|
||||
qRegisterMetaType<RemovePropertiesCommand>("RemovePropertiesCommand");
|
||||
qRegisterMetaTypeStreamOperators<RemovePropertiesCommand>("RemovePropertiesCommand");
|
||||
|
||||
|
@@ -49,6 +49,7 @@ class CompleteComponentCommand;
|
||||
class ChangeNodeSourceCommand;
|
||||
class TokenCommand;
|
||||
class RemoveSharedMemoryCommand;
|
||||
class ChangeSelectionCommand;
|
||||
|
||||
class NodeInstanceServerInterface : public QObject
|
||||
{
|
||||
@@ -77,6 +78,7 @@ public:
|
||||
virtual void changeNodeSource(const ChangeNodeSourceCommand &command) = 0;
|
||||
virtual void token(const TokenCommand &command) = 0;
|
||||
virtual void removeSharedMemory(const RemoveSharedMemoryCommand &command) = 0;
|
||||
virtual void changeSelection(const ChangeSelectionCommand &command) = 0;
|
||||
|
||||
virtual void benchmark(const QString &)
|
||||
{}
|
||||
|
@@ -66,6 +66,7 @@
|
||||
#include <changenodesourcecommand.h>
|
||||
#include <tokencommand.h>
|
||||
#include <removesharedmemorycommand.h>
|
||||
#include <changeselectioncommand.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QQmlEngine>
|
||||
@@ -330,6 +331,10 @@ void NodeInstanceServer::clearScene(const ClearSceneCommand &/*command*/)
|
||||
m_fileUrl.clear();
|
||||
}
|
||||
|
||||
void NodeInstanceServer::changeSelection(const ChangeSelectionCommand & /*command*/)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeInstanceServer::removeInstances(const RemoveInstancesCommand &command)
|
||||
{
|
||||
ServerNodeInstance oldState = activeStateInstance();
|
||||
@@ -1157,6 +1162,17 @@ ComponentCompletedCommand NodeInstanceServer::createComponentCompletedCommand(co
|
||||
return ComponentCompletedCommand(idVector);
|
||||
}
|
||||
|
||||
ChangeSelectionCommand NodeInstanceServer::createChangeSelectionCommand(const QList<ServerNodeInstance> &instanceList)
|
||||
{
|
||||
QVector<qint32> idVector;
|
||||
for (const ServerNodeInstance &instance : instanceList) {
|
||||
if (instance.instanceId() >= 0)
|
||||
idVector.append(instance.instanceId());
|
||||
}
|
||||
|
||||
return ChangeSelectionCommand(idVector);
|
||||
}
|
||||
|
||||
ValuesChangedCommand NodeInstanceServer::createValuesChangedCommand(const QVector<InstancePropertyPair> &propertyList) const
|
||||
{
|
||||
QVector<PropertyValueContainer> valueVector;
|
||||
|
@@ -68,6 +68,7 @@ class ComponentCompletedCommand;
|
||||
class AddImportContainer;
|
||||
class MockupTypeContainer;
|
||||
class IdContainer;
|
||||
class ChangeSelectionCommand;
|
||||
|
||||
namespace Internal {
|
||||
class ChildrenChangeEventFilter;
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
void changeNodeSource(const ChangeNodeSourceCommand &command) override;
|
||||
void token(const TokenCommand &command) override;
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command) override;
|
||||
void changeSelection(const ChangeSelectionCommand &command) override;
|
||||
|
||||
ServerNodeInstance instanceForId(qint32 id) const;
|
||||
bool hasInstanceForId(qint32 id) const;
|
||||
@@ -170,6 +172,7 @@ protected:
|
||||
InformationChangedCommand createAllInformationChangedCommand(const QList<ServerNodeInstance> &instanceList, bool initial = false) const;
|
||||
ChildrenChangedCommand createChildrenChangedCommand(const ServerNodeInstance &parentInstance, const QList<ServerNodeInstance> &instanceList) const;
|
||||
ComponentCompletedCommand createComponentCompletedCommand(const QList<ServerNodeInstance> &instanceList);
|
||||
ChangeSelectionCommand createChangeSelectionCommand(const QList<ServerNodeInstance> &instanceList);
|
||||
|
||||
void addChangedProperty(const InstancePropertyPair &property);
|
||||
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include "createscenecommand.h"
|
||||
#include "tokencommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "changeselectioncommand.h"
|
||||
|
||||
#include "dummycontextobject.h"
|
||||
|
||||
@@ -147,6 +148,12 @@ bool Qt5InformationNodeInstanceServer::isDirtyRecursiveForParentInstances(QQuick
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This method allows changing the selection from the puppet */
|
||||
void Qt5InformationNodeInstanceServer::selectInstance(const ServerNodeInstance &instance)
|
||||
{
|
||||
nodeInstanceClient()->selectionChanged(createChangeSelectionCommand({instance}));
|
||||
}
|
||||
|
||||
QObject *Qt5InformationNodeInstanceServer::findRootNodeOf3DViewport(
|
||||
const QList<ServerNodeInstance> &instanceList) const
|
||||
{
|
||||
@@ -358,4 +365,10 @@ void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const Qml
|
||||
ValuesChangedCommand::removeSharedMemorys(command.keyNumbers());
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command)
|
||||
{
|
||||
// keep track of selection.
|
||||
qDebug() << Q_FUNC_INFO << command;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -42,6 +42,7 @@ public:
|
||||
void completeComponent(const CompleteComponentCommand &command) override;
|
||||
void token(const TokenCommand &command) override;
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command) override;
|
||||
void changeSelection(const ChangeSelectionCommand &command) override;
|
||||
|
||||
protected:
|
||||
void collectItemChangesAndSendChangeCommands() override;
|
||||
@@ -49,6 +50,7 @@ protected:
|
||||
void sendTokenBack();
|
||||
bool isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const;
|
||||
bool isDirtyRecursiveForParentInstances(QQuickItem *item) const;
|
||||
void selectInstance(const ServerNodeInstance &instance);
|
||||
|
||||
private:
|
||||
void setup3DEditView(const QList<ServerNodeInstance> &instanceList);
|
||||
|
@@ -151,6 +151,11 @@ void Qt5TestNodeInstanceServer::clearScene(const ClearSceneCommand &command)
|
||||
Qt5NodeInstanceServer::clearScene(command);
|
||||
}
|
||||
|
||||
void Qt5TestNodeInstanceServer::changeSelection(const ChangeSelectionCommand &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Qt5TestNodeInstanceServer::removeInstances(const RemoveInstancesCommand &command)
|
||||
{
|
||||
ServerNodeInstance oldState = activeStateInstance();
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
void completeComponent(const CompleteComponentCommand &command) override;
|
||||
void changeNodeSource(const ChangeNodeSourceCommand &command) override;
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command) override;
|
||||
void changeSelection(const ChangeSelectionCommand &command) override;
|
||||
|
||||
using Qt5NodeInstanceServer::createInstances;
|
||||
|
||||
|
@@ -138,6 +138,7 @@ extend_qtc_plugin(QmlDesigner
|
||||
synchronizecommand.cpp synchronizecommand.h
|
||||
tokencommand.cpp tokencommand.h
|
||||
valueschangedcommand.cpp valueschangedcommand.h
|
||||
changeselectioncommand.cpp changeselectioncommand.h
|
||||
)
|
||||
|
||||
extend_qtc_plugin(QmlDesigner
|
||||
|
@@ -64,6 +64,7 @@ class ChangeValuesCommand;
|
||||
class ChangeBindingsCommand;
|
||||
class ChangeIdsCommand;
|
||||
class RemoveInstancesCommand;
|
||||
class ChangeSelectionCommand;
|
||||
class RemovePropertiesCommand;
|
||||
class CompleteComponentCommand;
|
||||
class InformationContainer;
|
||||
@@ -134,6 +135,11 @@ public:
|
||||
|
||||
void sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
|
||||
|
||||
void selectionChanged(const ChangeSelectionCommand &command) override;
|
||||
|
||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
const QList<ModelNode> &lastSelectedNodeList) override;
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
@@ -173,6 +179,7 @@ private: // functions
|
||||
ChangeBindingsCommand createChangeBindingCommand(const QList<BindingProperty> &propertyList) const;
|
||||
ChangeIdsCommand createChangeIdsCommand(const QList<NodeInstance> &instanceList) const;
|
||||
RemoveInstancesCommand createRemoveInstancesCommand(const QList<ModelNode> &nodeList) const;
|
||||
ChangeSelectionCommand createChangeSelectionCommand(const QList<ModelNode> &nodeList) const;
|
||||
RemoveInstancesCommand createRemoveInstancesCommand(const ModelNode &node) const;
|
||||
RemovePropertiesCommand createRemovePropertiesCommand(const QList<AbstractProperty> &propertyList) const;
|
||||
RemoveSharedMemoryCommand createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, quint32 keyNumber);
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include <changestatecommand.h>
|
||||
#include <completecomponentcommand.h>
|
||||
#include <changenodesourcecommand.h>
|
||||
#include <changeselectioncommand.h>
|
||||
|
||||
#include <informationchangedcommand.h>
|
||||
#include <pixmapchangedcommand.h>
|
||||
@@ -278,6 +279,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr
|
||||
static const int tokenCommandType = QMetaType::type("TokenCommand");
|
||||
static const int debugOutputCommandType = QMetaType::type("DebugOutputCommand");
|
||||
static const int puppetAliveCommandType = QMetaType::type("PuppetAliveCommand");
|
||||
static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand");
|
||||
|
||||
if (m_destructing)
|
||||
return;
|
||||
@@ -299,6 +301,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr
|
||||
nodeInstanceClient()->token(command.value<TokenCommand>());
|
||||
} else if (command.userType() == debugOutputCommandType) {
|
||||
nodeInstanceClient()->debugOutput(command.value<DebugOutputCommand>());
|
||||
} else if (command.userType() == changeSelectionCommandType) {
|
||||
nodeInstanceClient()->selectionChanged(command.value<ChangeSelectionCommand>());
|
||||
} else if (command.userType() == puppetAliveCommandType) {
|
||||
puppetAlive(puppetStreamType);
|
||||
} else if (command.userType() == synchronizeCommandType) {
|
||||
@@ -645,6 +649,11 @@ void NodeInstanceServerProxy::removeInstances(const RemoveInstancesCommand &comm
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceServerProxy::changeSelection(const ChangeSelectionCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceServerProxy::removeProperties(const RemovePropertiesCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
|
@@ -71,6 +71,7 @@ public:
|
||||
void createScene(const CreateSceneCommand &command) override;
|
||||
void clearScene(const ClearSceneCommand &command) override;
|
||||
void removeInstances(const RemoveInstancesCommand &command) override;
|
||||
void changeSelection(const ChangeSelectionCommand &command) override;
|
||||
void removeProperties(const RemovePropertiesCommand &command) override;
|
||||
void changePropertyBindings(const ChangeBindingsCommand &command) override;
|
||||
void changePropertyValues(const ChangeValuesCommand &command) override;
|
||||
|
@@ -51,6 +51,7 @@
|
||||
#include "changeauxiliarycommand.h"
|
||||
#include "changebindingscommand.h"
|
||||
#include "changeidscommand.h"
|
||||
#include "changeselectioncommand.h"
|
||||
#include "changenodesourcecommand.h"
|
||||
#include "removeinstancescommand.h"
|
||||
#include "removepropertiescommand.h"
|
||||
@@ -1109,6 +1110,21 @@ RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const QLis
|
||||
return RemoveInstancesCommand(idList);
|
||||
}
|
||||
|
||||
ChangeSelectionCommand NodeInstanceView::createChangeSelectionCommand(const QList<ModelNode> &nodeList) const
|
||||
{
|
||||
QVector<qint32> idList;
|
||||
foreach (const ModelNode &node, nodeList) {
|
||||
if (node.isValid() && hasInstanceForModelNode(node)) {
|
||||
NodeInstance instance = instanceForModelNode(node);
|
||||
|
||||
if (instance.instanceId() >= 0)
|
||||
idList.append(instance.instanceId());
|
||||
}
|
||||
}
|
||||
|
||||
return ChangeSelectionCommand(idList);
|
||||
}
|
||||
|
||||
RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const ModelNode &node) const
|
||||
{
|
||||
QVector<qint32> idList;
|
||||
@@ -1364,6 +1380,20 @@ void NodeInstanceView::sendToken(const QString &token, int number, const QVector
|
||||
nodeInstanceServer()->token(TokenCommand(token, number, instanceIdVector));
|
||||
}
|
||||
|
||||
void NodeInstanceView::selectionChanged(const ChangeSelectionCommand &command)
|
||||
{
|
||||
foreach (const qint32 &instanceId, command.instanceIds()) {
|
||||
if (hasModelNodeForInternalId(instanceId))
|
||||
selectModelNode(modelNodeForInternalId(instanceId));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeInstanceView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
const QList<ModelNode> & /*lastSelectedNodeList*/)
|
||||
{
|
||||
nodeInstanceServer()->changeSelection(createChangeSelectionCommand(selectedNodeList));
|
||||
}
|
||||
|
||||
void NodeInstanceView::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_restartProcessTimerId == event->timerId())
|
||||
|
@@ -1464,6 +1464,10 @@ void ModelPrivate::changeSelectedNodes(const QList<InternalNode::Pointer> &newSe
|
||||
Q_ASSERT(view != nullptr);
|
||||
view->selectedNodesChanged(toModelNodeList(newSelectedNodeList, view.data()), toModelNodeList(oldSelectedNodeList, view.data()));
|
||||
}
|
||||
|
||||
if (nodeInstanceView())
|
||||
nodeInstanceView()->selectedNodesChanged(toModelNodeList(newSelectedNodeList, nodeInstanceView()),
|
||||
toModelNodeList(oldSelectedNodeList, nodeInstanceView()));
|
||||
}
|
||||
|
||||
QList<InternalNode::Pointer> ModelPrivate::selectedNodes() const
|
||||
|
@@ -167,6 +167,8 @@ Project {
|
||||
"commands/tokencommand.h",
|
||||
"commands/valueschangedcommand.cpp",
|
||||
"commands/valueschangedcommand.h",
|
||||
"commands/changeselectioncommand.cpp",
|
||||
"commands/changeselectioncommand.h",
|
||||
"container/addimportcontainer.cpp",
|
||||
"container/addimportcontainer.h",
|
||||
"container/idcontainer.cpp",
|
||||
|
@@ -44,6 +44,7 @@ extend_qtc_executable(qml2puppet
|
||||
statepreviewimagechangedcommand.cpp statepreviewimagechangedcommand.h
|
||||
synchronizecommand.cpp synchronizecommand.h
|
||||
tokencommand.cpp tokencommand.h
|
||||
changeselectioncommand.cpp changeselectioncommand.h
|
||||
valueschangedcommand.cpp
|
||||
)
|
||||
|
||||
|
@@ -93,6 +93,8 @@ QtcTool {
|
||||
"commands/tokencommand.h",
|
||||
"commands/valueschangedcommand.cpp",
|
||||
"commands/valueschangedcommand.h",
|
||||
"commands/changeselectioncommand.cpp",
|
||||
"commands/changeselectioncommand.h",
|
||||
"container/addimportcontainer.cpp",
|
||||
"container/addimportcontainer.h",
|
||||
"container/idcontainer.cpp",
|
||||
|
Reference in New Issue
Block a user