2018-10-07 03:40:25 +00:00
|
|
|
#pragma once
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2018-08-07 07:09:23 +00:00
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QStyledItemDelegate>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QTableView>
|
|
|
|
|
|
|
|
#include "EditorWidget.hpp"
|
|
|
|
#include "ProjectModel.hpp"
|
|
|
|
|
|
|
|
#include <amuse/AudioGroupPool.hpp>
|
|
|
|
#include <amuse/Common.hpp>
|
2018-08-07 07:09:23 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class SoundMacroDelegate : public BaseObjectDelegate {
|
|
|
|
Q_OBJECT
|
2018-08-26 04:57:02 +00:00
|
|
|
protected:
|
2019-08-25 04:37:47 +00:00
|
|
|
ProjectModel::INode* getNode(const QAbstractItemModel* model, const QModelIndex& index) const override;
|
2018-12-08 05:20:09 +00:00
|
|
|
|
2018-08-07 07:09:23 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit SoundMacroDelegate(QObject* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~SoundMacroDelegate() override;
|
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
|
|
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
|
|
|
|
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-07 07:09:23 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void smIndexChanged();
|
2018-08-07 07:09:23 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class LayersModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class LayersEditor;
|
|
|
|
friend class SoundMacroDelegate;
|
|
|
|
friend class LayersTableView;
|
|
|
|
amuse::ObjToken<ProjectModel::LayersNode> m_node;
|
|
|
|
|
2018-08-07 07:09:23 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit LayersModel(QObject* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~LayersModel() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void loadData(ProjectModel::LayersNode* node);
|
|
|
|
void unloadData();
|
2018-08-07 07:09:23 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
|
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
|
|
|
Qt::DropActions supportedDropActions() const override;
|
|
|
|
Qt::DropActions supportedDragActions() const override;
|
|
|
|
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
|
|
|
const QModelIndex& parent) override;
|
2018-08-07 07:09:23 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
2018-12-08 05:20:09 +00:00
|
|
|
bool moveRows(const QModelIndex& sourceParent, int sourceRow, int count, const QModelIndex& destinationParent,
|
2019-08-25 04:37:47 +00:00
|
|
|
int destinationChild) override;
|
|
|
|
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
2018-08-14 08:36:02 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void _insertRow(int row, const amuse::LayerMapping& data);
|
|
|
|
amuse::LayerMapping _removeRow(int row);
|
2018-08-07 07:09:23 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class LayersTableView : public QTableView {
|
|
|
|
Q_OBJECT
|
|
|
|
SoundMacroDelegate m_smDelegate;
|
|
|
|
RangedValueFactory<-128, 127> m_signedFactory;
|
|
|
|
RangedValueFactory<0, 127> m_unsignedFactory;
|
|
|
|
QStyledItemDelegate m_signedDelegate, m_unsignedDelegate;
|
|
|
|
|
2018-08-07 07:09:23 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit LayersTableView(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~LayersTableView() override;
|
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
void setModel(QAbstractItemModel* model) override;
|
2018-12-08 05:20:09 +00:00
|
|
|
void deleteSelection();
|
2018-08-07 07:09:23 +00:00
|
|
|
};
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class LayersEditor : public EditorWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class LayersModel;
|
|
|
|
LayersModel m_model;
|
|
|
|
LayersTableView m_tableView;
|
|
|
|
AddRemoveButtons m_addRemoveButtons;
|
|
|
|
|
2018-07-09 18:05:31 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit LayersEditor(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~LayersEditor() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(ProjectModel::LayersNode* node);
|
2019-08-25 04:37:47 +00:00
|
|
|
void unloadData() override;
|
|
|
|
ProjectModel::INode* currentNode() const override;
|
|
|
|
void resizeEvent(QResizeEvent* ev) override;
|
|
|
|
AmuseItemEditFlags itemEditFlags() const override;
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-30 20:34:10 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void rowsInserted(const QModelIndex& parent, int first, int last);
|
|
|
|
void rowsMoved(const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row);
|
|
|
|
void doAdd();
|
|
|
|
void doSelectionChanged();
|
2019-08-25 04:37:47 +00:00
|
|
|
void itemDeleteAction() override;
|
2018-08-07 07:09:23 +00:00
|
|
|
};
|