Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::SceneModel Class Reference

Item model representing a scene's node tree for Qt views. More...

#include <C:/Code/AeonEngine/tools/worldeditor/models/SceneModel.h>

Inheritance diagram for AeonGames::SceneModel:
Inheritance graph
Collaboration diagram for AeonGames::SceneModel:
Collaboration graph

Public Member Functions

 SceneModel (QObject *parent=nullptr)
 Construct the scene model.
virtual ~SceneModel ()
 Destructor.

Qt QAbstractItemModel overrides

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.
QModelIndex parent (const QModelIndex &index) const override
 Return the parent of the given model index.
int rowCount (const QModelIndex &index=QModelIndex()) const override
 Return the number of rows under the given parent.
int columnCount (const QModelIndex &index=QModelIndex()) const override
 Return the number of columns for children of the given parent.
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Return the data for the given index and role.
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Return the header data for the given section, orientation, and role.
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.
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Set the data for the given index and role.
bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationRow) override
 Move rows from one parent to another.
Qt::DropActions supportedDropActions () const override
 Return the drop actions supported by this model.
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.
QMimeData * mimeData (const QModelIndexList &indexes) const override
 Return serialized MIME data for the given model indexes.
QStringList mimeTypes () const override
 Return the list of MIME types that can be used to describe model indexes.
void InsertNode (int row, const QModelIndex &parent=QModelIndex(), std::unique_ptr< Node > aNode={})
 Insert a node into the scene tree.
void RemoveNode (int row, const QModelIndex &parent=QModelIndex())
 Remove a node from the scene tree.
void SetCameraNode (const QModelIndex &index=QModelIndex())
 Set the camera to the node at the given index.
std::string Serialize (bool aAsBinary=true) const
 Serialize the scene to a string.
void Deserialize (const std::string &aSerializedScene)
 Deserialize a scene from a string.
const SceneGetScene () const
 Get a const reference to the underlying scene.

Detailed Description

Item model representing a scene's node tree for Qt views.

Definition at line 27 of file SceneModel.h.

Constructor & Destructor Documentation

◆ SceneModel()

AeonGames::SceneModel::SceneModel ( QObject * parent = nullptr)

Construct the scene model.

Parameters
parentParent QObject.

Definition at line 30 of file SceneModel.cpp.

Member Function Documentation

◆ columnCount()

int AeonGames::SceneModel::columnCount ( const QModelIndex & index = QModelIndex()) const
override

Return the number of columns for children of the given parent.

Parameters
indexParent model index.
Returns
Number of columns.

Definition at line 93 of file SceneModel.cpp.

◆ data()

QVariant AeonGames::SceneModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Return the data for the given index and role.

Parameters
indexModel index.
roleData role.
Returns
Data as a QVariant.

Definition at line 107 of file SceneModel.cpp.

◆ Deserialize()

void AeonGames::SceneModel::Deserialize ( const std::string & aSerializedScene)

Deserialize a scene from a string.

Parameters
aSerializedSceneSerialized scene data.

Definition at line 341 of file SceneModel.cpp.

◆ dropMimeData()

bool AeonGames::SceneModel::dropMimeData ( const QMimeData * data,
Qt::DropAction action,
int row,
int column,
const QModelIndex & parent )
override

Handle data supplied by a drag-and-drop operation.

Parameters
dataMIME data from the drop.
actionThe drop action performed.
rowTarget row.
columnTarget column.
parentParent model index.
Returns
True if the data was handled successfully.

Definition at line 235 of file SceneModel.cpp.

◆ flags()

Qt::ItemFlags AeonGames::SceneModel::flags ( const QModelIndex & index) const
override

Return the item flags for the given model index.

Parameters
indexModel index.
Returns
Item flags.

Definition at line 136 of file SceneModel.cpp.

◆ GetScene()

const Scene & AeonGames::SceneModel::GetScene ( ) const

Get a const reference to the underlying scene.

Returns
Const reference to the scene.

Definition at line 348 of file SceneModel.cpp.

◆ hasChildren()

bool AeonGames::SceneModel::hasChildren ( const QModelIndex & index = QModelIndex()) const
override

Return whether the given parent index has any children.

Parameters
indexParent model index.
Returns
True if the parent has children.

Definition at line 98 of file SceneModel.cpp.

◆ headerData()

QVariant AeonGames::SceneModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Return the header data for the given section, orientation, and role.

Parameters
sectionHeader section index.
orientationHorizontal or vertical header.
roleData role.
Returns
Header data as a QVariant.

Definition at line 35 of file SceneModel.cpp.

◆ index()

QModelIndex AeonGames::SceneModel::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.

Parameters
rowRow number.
columnColumn number.
parentParent model index.
Returns
Model index for the specified item.

Definition at line 50 of file SceneModel.cpp.

◆ InsertNode()

void AeonGames::SceneModel::InsertNode ( int row,
const QModelIndex & parent = QModelIndex(),
std::unique_ptr< Node > aNode = {} )

Insert a node into the scene tree.

Parameters
rowRow position for the new node.
parentParent model index.
aNodeOptional node to insert; a default node is created if empty.

Definition at line 294 of file SceneModel.cpp.

◆ mimeData()

QMimeData * AeonGames::SceneModel::mimeData ( const QModelIndexList & indexes) const
override

Return serialized MIME data for the given model indexes.

Parameters
indexesList of model indexes to serialize.
Returns
Pointer to a QMimeData object containing the serialized data.

Definition at line 266 of file SceneModel.cpp.

◆ mimeTypes()

QStringList AeonGames::SceneModel::mimeTypes ( ) const
override

Return the list of MIME types that can be used to describe model indexes.

Returns
List of supported MIME type strings.

Definition at line 287 of file SceneModel.cpp.

◆ moveRows()

bool AeonGames::SceneModel::moveRows ( const QModelIndex & sourceParent,
int sourceRow,
int count,
const QModelIndex & destinationParent,
int destinationRow )
override

Move rows from one parent to another.

Parameters
sourceParentParent index of the source rows.
sourceRowStarting row to move.
countNumber of rows to move.
destinationParentParent index of the destination.
destinationRowDestination row position.
Returns
True if the rows were moved successfully.

Definition at line 157 of file SceneModel.cpp.

◆ parent()

QModelIndex AeonGames::SceneModel::parent ( const QModelIndex & index) const
override

Return the parent of the given model index.

Parameters
indexThe child model index.
Returns
Parent model index, or an invalid index if the item has no parent.

Definition at line 70 of file SceneModel.cpp.

◆ RemoveNode()

void AeonGames::SceneModel::RemoveNode ( int row,
const QModelIndex & parent = QModelIndex() )

Remove a node from the scene tree.

Parameters
rowRow position of the node to remove.
parentParent model index.

Definition at line 308 of file SceneModel.cpp.

◆ rowCount()

int AeonGames::SceneModel::rowCount ( const QModelIndex & index = QModelIndex()) const
override

Return the number of rows under the given parent.

Parameters
indexParent model index.
Returns
Number of rows.

Definition at line 84 of file SceneModel.cpp.

◆ Serialize()

std::string AeonGames::SceneModel::Serialize ( bool aAsBinary = true) const

Serialize the scene to a string.

Parameters
aAsBinaryIf true, serialize as binary; otherwise as text.
Returns
Serialized scene data.

Definition at line 336 of file SceneModel.cpp.

◆ SetCameraNode()

void AeonGames::SceneModel::SetCameraNode ( const QModelIndex & index = QModelIndex())

Set the camera to the node at the given index.

Parameters
indexModel index of the camera node.

Definition at line 322 of file SceneModel.cpp.

◆ setData()

bool AeonGames::SceneModel::setData ( const QModelIndex & index,
const QVariant & value,
int role )
override

Set the data for the given index and role.

Parameters
indexModel index.
valueNew value.
roleData role.
Returns
True if the data was set successfully.

Definition at line 145 of file SceneModel.cpp.

◆ supportedDropActions()

Qt::DropActions AeonGames::SceneModel::supportedDropActions ( ) const
override

Return the drop actions supported by this model.

Returns
Supported drop actions.

Definition at line 230 of file SceneModel.cpp.


The documentation for this class was generated from the following files: