forked from qt-creator/qt-creator
QmlDesigner: Implement removing a composition node
Fixes: QDS-10410 Change-Id: I4c4922c82f294d676dbf1e82f8c6dbb0f4089fdb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -15,6 +15,12 @@ HelperWidgets.Section {
|
|||||||
caption: nodeName
|
caption: nodeName
|
||||||
category: "EffectMaker"
|
category: "EffectMaker"
|
||||||
|
|
||||||
|
showCloseButton: true
|
||||||
|
closeButtonToolTip: qsTr("Remove")
|
||||||
|
onCloseButtonClicked: {
|
||||||
|
EffectMakerBackend.effectMakerModel.removeNode(index)
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
#include "effectmakeruniformsmodel.h"
|
#include "effectmakeruniformsmodel.h"
|
||||||
#include "uniform.h"
|
#include "uniform.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFile>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@@ -46,7 +46,6 @@ QStringList CompositionNode::requiredNodes() const
|
|||||||
|
|
||||||
void CompositionNode::parse(const QString &qenPath)
|
void CompositionNode::parse(const QString &qenPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
QFile qenFile(qenPath);
|
QFile qenFile(qenPath);
|
||||||
|
|
||||||
if (!qenFile.open(QIODevice::ReadOnly)) {
|
if (!qenFile.open(QIODevice::ReadOnly)) {
|
||||||
|
@@ -6,12 +6,9 @@
|
|||||||
#include "effectmakeruniformsmodel.h"
|
#include "effectmakeruniformsmodel.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class Uniform;
|
|
||||||
|
|
||||||
class CompositionNode : public QObject
|
class CompositionNode : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@@ -34,39 +34,22 @@ QVariant EffectMakerModel::data(const QModelIndex &index, int role) const
|
|||||||
QTC_ASSERT(index.isValid() && index.row() < m_nodes.size(), return {});
|
QTC_ASSERT(index.isValid() && index.row() < m_nodes.size(), return {});
|
||||||
QTC_ASSERT(roleNames().contains(role), return {});
|
QTC_ASSERT(roleNames().contains(role), return {});
|
||||||
|
|
||||||
return m_nodes.values().at(index.row())->property(roleNames().value(role));
|
return m_nodes.at(index.row())->property(roleNames().value(role));
|
||||||
}
|
|
||||||
|
|
||||||
void EffectMakerModel::resetModel()
|
|
||||||
{
|
|
||||||
beginResetModel();
|
|
||||||
endResetModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectMakerModel::addNode(const QString &nodeQenPath)
|
void EffectMakerModel::addNode(const QString &nodeQenPath)
|
||||||
{
|
{
|
||||||
static int id = 0;
|
|
||||||
|
|
||||||
beginInsertRows({}, m_nodes.size(), m_nodes.size());
|
beginInsertRows({}, m_nodes.size(), m_nodes.size());
|
||||||
auto *node = new CompositionNode(nodeQenPath);
|
auto *node = new CompositionNode(nodeQenPath);
|
||||||
m_nodes.insert(id++, node);
|
m_nodes.append(node);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectMakerModel::selectEffect(int idx, bool force)
|
void EffectMakerModel::removeNode(int idx)
|
||||||
{
|
{
|
||||||
Q_UNUSED(idx)
|
beginRemoveRows({}, idx, idx);
|
||||||
Q_UNUSED(force)
|
m_nodes.removeAt(idx);
|
||||||
|
endRemoveRows();
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void EffectMakerModel::applyToSelected(qint64 internalId, bool add)
|
|
||||||
{
|
|
||||||
Q_UNUSED(internalId)
|
|
||||||
Q_UNUSED(add)
|
|
||||||
|
|
||||||
// TODO: remove?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -26,17 +26,13 @@ public:
|
|||||||
|
|
||||||
bool isEmpty() const { return m_isEmpty; }
|
bool isEmpty() const { return m_isEmpty; }
|
||||||
|
|
||||||
void resetModel();
|
|
||||||
|
|
||||||
void addNode(const QString &nodeQenPath);
|
void addNode(const QString &nodeQenPath);
|
||||||
|
|
||||||
Q_INVOKABLE void selectEffect(int idx, bool force = false);
|
Q_INVOKABLE void removeNode(int idx);
|
||||||
Q_INVOKABLE void applyToSelected(qint64 internalId, bool add = false);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void isEmptyChanged();
|
void isEmptyChanged();
|
||||||
void selectedIndexChanged(int idx);
|
void selectedIndexChanged(int idx);
|
||||||
void hasModelSelectionChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
@@ -46,7 +42,7 @@ private:
|
|||||||
|
|
||||||
bool isValidIndex(int idx) const;
|
bool isValidIndex(int idx) const;
|
||||||
|
|
||||||
QMap<int, CompositionNode *> m_nodes;
|
QList<CompositionNode *> m_nodes;
|
||||||
|
|
||||||
int m_selectedIndex = -1;
|
int m_selectedIndex = -1;
|
||||||
bool m_isEmpty = true;
|
bool m_isEmpty = true;
|
||||||
|
Reference in New Issue
Block a user