17#ifndef AEONGAMES_SCENEMODEL_H
18#define AEONGAMES_SCENEMODEL_H
19#include <QAbstractItemModel>
22#include "aeongames/Node.hpp"
45 QModelIndex
index (
int row,
int column,
const QModelIndex &
parent = QModelIndex() )
const override;
49 QModelIndex
parent (
const QModelIndex &
index )
const override;
53 int rowCount (
const QModelIndex &
index = QModelIndex() )
const override;
57 int columnCount (
const QModelIndex &
index = QModelIndex() )
const override;
62 QVariant
data (
const QModelIndex &
index,
int role = Qt::DisplayRole )
const override;
68 QVariant
headerData (
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
72 bool hasChildren (
const QModelIndex &
index = QModelIndex() )
const override;
76 Qt::ItemFlags
flags (
const QModelIndex &
index )
const override;
82 bool setData (
const QModelIndex &
index,
const QVariant & value,
int role )
override;
90 bool moveRows (
const QModelIndex & sourceParent,
int sourceRow,
int count,
const QModelIndex & destinationParent,
int destinationRow )
override;
101 bool dropMimeData (
const QMimeData *
data, Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
override;
105 QMimeData *
mimeData (
const QModelIndexList & indexes )
const override;
116 void InsertNode (
int row,
const QModelIndex &
parent = QModelIndex(), std::unique_ptr<Node> aNode = {} );
133 std::string
Serialize (
bool aAsBinary =
true )
const;
138 void Deserialize (
const std::string& aSerializedScene );
Header for the Scene class.
Scene class. Scene is the container for all elements in a game level, takes care of collision,...
QMimeData * mimeData(const QModelIndexList &indexes) const override
Return serialized MIME data for the given model indexes.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handle data supplied by a drag-and-drop operation.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Return the index of the item at the given row and column under parent.
int rowCount(const QModelIndex &index=QModelIndex()) const override
Return the number of rows under the given parent.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Return the header data for the given section, orientation, and role.
const Scene & GetScene() const
Get a const reference to the underlying scene.
std::string Serialize(bool aAsBinary=true) const
Serialize the scene to a string.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Set the data for the given index and role.
void Deserialize(const std::string &aSerializedScene)
Deserialize a scene from a string.
QModelIndex parent(const QModelIndex &index) const override
Return the parent of the given model index.
int columnCount(const QModelIndex &index=QModelIndex()) const override
Return the number of columns for children of the given parent.
void InsertNode(int row, const QModelIndex &parent=QModelIndex(), std::unique_ptr< Node > aNode={})
Insert a node into the scene tree.
bool hasChildren(const QModelIndex &index=QModelIndex()) const override
Return whether the given parent index has any children.
Qt::ItemFlags flags(const QModelIndex &index) const override
Return the item flags for the given model index.
SceneModel(QObject *parent=nullptr)
Construct the scene model.
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationRow) override
Move rows from one parent to another.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Return the data for the given index and role.
void SetCameraNode(const QModelIndex &index=QModelIndex())
Set the camera to the node at the given index.
Qt::DropActions supportedDropActions() const override
Return the drop actions supported by this model.
void RemoveNode(int row, const QModelIndex &parent=QModelIndex())
Remove a node from the scene tree.
virtual ~SceneModel()
Destructor.
QStringList mimeTypes() const override
Return the list of MIME types that can be used to describe model indexes.
<- This is here just for the literals