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
|
||||
category: "EffectMaker"
|
||||
|
||||
showCloseButton: true
|
||||
closeButtonToolTip: qsTr("Remove")
|
||||
onCloseButtonClicked: {
|
||||
EffectMakerBackend.effectMakerModel.removeNode(index)
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include "effectmakeruniformsmodel.h"
|
||||
#include "uniform.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
@@ -46,7 +46,6 @@ QStringList CompositionNode::requiredNodes() const
|
||||
|
||||
void CompositionNode::parse(const QString &qenPath)
|
||||
{
|
||||
|
||||
QFile qenFile(qenPath);
|
||||
|
||||
if (!qenFile.open(QIODevice::ReadOnly)) {
|
||||
|
@@ -6,12 +6,9 @@
|
||||
#include "effectmakeruniformsmodel.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class Uniform;
|
||||
|
||||
class CompositionNode : public QObject
|
||||
{
|
||||
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(roleNames().contains(role), return {});
|
||||
|
||||
return m_nodes.values().at(index.row())->property(roleNames().value(role));
|
||||
}
|
||||
|
||||
void EffectMakerModel::resetModel()
|
||||
{
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
return m_nodes.at(index.row())->property(roleNames().value(role));
|
||||
}
|
||||
|
||||
void EffectMakerModel::addNode(const QString &nodeQenPath)
|
||||
{
|
||||
static int id = 0;
|
||||
|
||||
beginInsertRows({}, m_nodes.size(), m_nodes.size());
|
||||
auto *node = new CompositionNode(nodeQenPath);
|
||||
m_nodes.insert(id++, node);
|
||||
m_nodes.append(node);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void EffectMakerModel::selectEffect(int idx, bool force)
|
||||
void EffectMakerModel::removeNode(int idx)
|
||||
{
|
||||
Q_UNUSED(idx)
|
||||
Q_UNUSED(force)
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void EffectMakerModel::applyToSelected(qint64 internalId, bool add)
|
||||
{
|
||||
Q_UNUSED(internalId)
|
||||
Q_UNUSED(add)
|
||||
|
||||
// TODO: remove?
|
||||
beginRemoveRows({}, idx, idx);
|
||||
m_nodes.removeAt(idx);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -26,17 +26,13 @@ public:
|
||||
|
||||
bool isEmpty() const { return m_isEmpty; }
|
||||
|
||||
void resetModel();
|
||||
|
||||
void addNode(const QString &nodeQenPath);
|
||||
|
||||
Q_INVOKABLE void selectEffect(int idx, bool force = false);
|
||||
Q_INVOKABLE void applyToSelected(qint64 internalId, bool add = false);
|
||||
Q_INVOKABLE void removeNode(int idx);
|
||||
|
||||
signals:
|
||||
void isEmptyChanged();
|
||||
void selectedIndexChanged(int idx);
|
||||
void hasModelSelectionChanged();
|
||||
|
||||
private:
|
||||
enum Roles {
|
||||
@@ -46,7 +42,7 @@ private:
|
||||
|
||||
bool isValidIndex(int idx) const;
|
||||
|
||||
QMap<int, CompositionNode *> m_nodes;
|
||||
QList<CompositionNode *> m_nodes;
|
||||
|
||||
int m_selectedIndex = -1;
|
||||
bool m_isEmpty = true;
|
||||
|
Reference in New Issue
Block a user