Accelerated Computation Engine
|
#include <ace_metadatamodel.h>
Classes | |
class | Node |
Public Types | |
enum | Roles { RawImageData = 10000 } |
Public Member Functions | |
virtual QStringList | mimeTypes () const override final |
virtual Qt::DropActions | supportedDropActions () const override final |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role) const override final |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent) const override final |
virtual QModelIndex | parent (const QModelIndex &child) const override final |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const override final |
virtual int | rowCount (const QModelIndex &parent) const override final |
virtual int | columnCount (const QModelIndex &parent) const override final |
virtual QMimeData * | mimeData (const QModelIndexList &indexes) const override final |
virtual QVariant | data (const QModelIndex &index, int role) const override final |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) override final |
virtual bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override final |
MetadataModel (QObject *parent=nullptr) | |
bool | isImage (const QModelIndex &index) const |
bool | isContainer (const QModelIndex &index) const |
bool | readOnly () const |
EMetadata | meta () const |
bool | insert (const QModelIndex &parent, EMetadata::Type type) |
bool | remove (const QModelIndex &index) |
void | setMeta (const EMetadata &newRoot) |
void | setReadOnly (bool state) |
This provides a Qt item model for a metadata structure. The root of the metadata structure must be an object type. This model is primarily used for the GUI dialog to edit the metadata of a data object. It can however be used as a general model for any purpose. The model can insert or remove a row, and drag and drop a single row that either copies or pastes the row. It consists of three columns. The first column is the name, the second is the type, and the last column is the value.
|
explicit |
This constructs a new metadata model with the given parent, if any.
parent | The parent for this new model. |
|
finaloverridevirtual |
This implements the interface that returns the number of columns a given index contains. For this model the number of columns is always 3.
parent | This is not used because the number of columns is static. |
|
finaloverridevirtual |
This implements the interface that returns data from the given index and role. This model only returns data based off the display role or custom raw image data role. This model returns a string suitable for a view with the display role. Only if the node of the given index is a bytes type then the byte array is returned with the raw image data role.
index | The index whose data is being requested. |
role | The role of the data being requested. |
|
finaloverridevirtual |
This implements the interface that handles the end of a drag and drop operation where the drop has occurred. This model only implements the copy and move actions.
data | Pointer to qt mime data object that was created when the drag was initiated. |
action | The drag and drop action being requested. |
row | The row where the drop occurred. |
column | The column where the drop occurred. |
parent | The parent index where the drop occurred. |
|
finaloverridevirtual |
This implements the interface that returns the flags for a given index of this mode. The flags inform anyone what can and cannot be done to the given index.
index | The index whose flags are returned. |
|
finaloverridevirtual |
This implements the interface that informs any view what the headers should be for columns and/or rows of the view. This returns the header data for the given section, orientation, and role. This model has no headers for the row and has headers for the first three columns denoting "key", "type", and "value".
section | The section for the requested header data. This is the indent, starting at 0, for the given orientation of vertical or horizontal. |
orientation | The orientation for the requested header data. |
role | The role for the requested header data. |
|
finaloverridevirtual |
This implements the interface that creates a new index from the given row, column, and parent index.
row | Row for the requested index. |
column | Column for the requested index. |
parent | Parent index for the requested index. |
bool MetadataModel::insert | ( | const QModelIndex & | parent, |
EMetadata::Type | type | ||
) |
Inserts a new empty node with the given metadata type into the given parent. If the parent is a map type a new key is generated else if the parent is an array type the new node is prepended to the array.
parent | |
type |
bool MetadataModel::isContainer | ( | const QModelIndex & | index | ) | const |
Tests if the given index is a container type, either an array or object type.
index | The given index to test if it is a container type. |
bool MetadataModel::isImage | ( | const QModelIndex & | index | ) | const |
Tests if the given index is a bytes type which stores the data of an image.
index | The given index to test if it is an image. |
EMetadata MetadataModel::meta | ( | ) | const |
Returns this model's data tree in the form of metadata objects. The root metadata object returned is an object type that is the root of the tree for the model.
|
finaloverridevirtual |
This implements the interface that creates a new qt mime data object when a drag and drop action is initiated. This model creates a custom mime data type just for this model which consists of a node pointer that will be copied or moved. This model does not support multiple indexes being drag and dropped at once so only the first index in the list of indexes will ever be used.
indexes | List of indexes that is being requested for drag and drop action. This model only uses the first index in the list. |
|
finaloverridevirtual |
This implements the interface that informs Qt what mime types this model supports for drag and drop support.
|
finaloverridevirtual |
This implements the interface that returns the parent index of the given index for this model.
child | The child index of the parent index to be found. |
bool MetadataModel::readOnly | ( | ) | const |
Returns the read only state of this model.
bool MetadataModel::remove | ( | const QModelIndex & | index | ) |
Removes the given index from this model.
index | The given index that is deleted. |
|
finaloverridevirtual |
This implements the interface that returns the number of rows a given index contains. This number resolves to the number of nodes contained in the node of the given index. If the node is not a container 0 is returned.
parent | The index whose number of rows are returned. |
|
finaloverridevirtual |
This implements the interface that sets the data of a given index with the given role. The only role this model implements is the edit role. All other roles are ignored and false is returned.
index | The index whose data will be changed. |
value | The new value for the given index's data. |
role | The role of the data being set. |
void MetadataModel::setMeta | ( | const EMetadata & | newRoot | ) |
This sets its model's data to the given metadata value. Any data stored within the model is removed and overwritten. The metadata object given must be an object type or this will throw an exception.
newRoot | The given metadata root object that will be copied into this model's data. |
void MetadataModel::setReadOnly | ( | bool | state | ) |
Set the read only state of this model.
state | New boolean value for this model's read only state. |
|
finaloverridevirtual |
This implements the interface that informs Qt what drag and drop actions this model supports. The drag and drop actions this model supports is moving and copying.