A typed, role-keyed data container for passing objects through model/view layers.
More...
#include <entitymetadata.h>
|
| | EntityMetadata () |
| | Default constructor — creates an invalid (type 0) metadata object.
|
| |
| | EntityMetadata (int type) |
| | Construct metadata with only a type identifier.
|
| |
| | EntityMetadata (int type, const QVariant &data, KANOOP::ModelRole role=KANOOP::DataRole) |
| | Construct metadata with a type, data value, and optional role.
|
| |
| | EntityMetadata (int type, const QVariant &data, const QUuid &uuid, KANOOP::ModelRole role=KANOOP::DataRole) |
| | Construct metadata with a type, data value, UUID, and optional role.
|
| |
| bool | operator== (const EntityMetadata &other) const |
| | Equality comparison by type and UUID.
|
| |
| int | type () const |
| | Return the entity type integer.
|
| |
| QString | typeString () const |
| | Return the human-readable name for this entity's type.
|
| |
| int | iconId () const |
| | Return the icon ID associated with this entity's type.
|
| |
| QVariant | data (int role=KANOOP::DataRole) const |
| | Return the data stored under the given role.
|
| |
| void | setData (const QVariant &value, int role=KANOOP::DataRole) |
| | Store a value under the given role.
|
| |
| bool | hasData (int role) const |
| | Test whether data has been stored for a given role.
|
| |
| QUuid | uuid () const |
| | Return the UUID stored under KANOOP::UUidRole.
|
| |
| void | setUuid (const QUuid &value) |
| | Store a UUID under KANOOP::UUidRole.
|
| |
| QVariant | toVariant () const |
| | Wrap this object in a QVariant.
|
| |
| bool | isValid () const |
| | Test whether this metadata has a non-zero type.
|
| |
A typed, role-keyed data container for passing objects through model/view layers.
EntityMetadata wraps an integer entity type together with arbitrary role-keyed QVariant data and an optional UUID. Use registerMetadata() at startup to associate type integers with human-readable names and optional icon IDs.
Definition at line 37 of file entitymetadata.h.
◆ EntityMetadata() [1/4]
| EntityMetadata::EntityMetadata |
( |
| ) |
|
|
inline |
Default constructor — creates an invalid (type 0) metadata object.
Definition at line 41 of file entitymetadata.h.
◆ EntityMetadata() [2/4]
| EntityMetadata::EntityMetadata |
( |
int |
type | ) |
|
Construct metadata with only a type identifier.
- Parameters
-
| type | Application-defined entity type integer |
◆ EntityMetadata() [3/4]
Construct metadata with a type, data value, and optional role.
- Parameters
-
| type | Application-defined entity type integer |
| data | Payload stored under the given role |
| role | Model role key (default KANOOP::DataRole) |
◆ EntityMetadata() [4/4]
Construct metadata with a type, data value, UUID, and optional role.
- Parameters
-
| type | Application-defined entity type integer |
| data | Payload stored under the given role |
| uuid | UUID to associate with this entity |
| role | Model role key (default KANOOP::DataRole) |
◆ data()
Return the data stored under the given role.
- Parameters
-
- Returns
- Stored QVariant, or invalid QVariant if no data for role
Definition at line 95 of file entitymetadata.h.
◆ fromVariant()
| static EntityMetadata EntityMetadata::fromVariant |
( |
const QVariant & |
value | ) |
|
|
inlinestatic |
◆ getMimeTypeString()
| static QString EntityMetadata::getMimeTypeString |
( |
int |
type | ) |
|
|
inlinestatic |
Return a MIME type string for the given entity type.
- Parameters
-
- Returns
- MIME type string of the form "application-epcpower/<name>"
Definition at line 176 of file entitymetadata.h.
◆ getTypeFromString()
| static int EntityMetadata::getTypeFromString |
( |
const QString & |
value | ) |
|
|
static |
Look up the entity type integer for a registered name string.
- Parameters
-
| value | Registered name string |
- Returns
- Matching type integer, or 0 if not found
◆ getTypeString()
| static QString EntityMetadata::getTypeString |
( |
int |
type | ) |
|
|
static |
Look up the registered name for an entity type integer.
- Parameters
-
- Returns
- Registered name string, or empty string if not found
◆ hasData()
| bool EntityMetadata::hasData |
( |
int |
role | ) |
const |
|
inline |
Test whether data has been stored for a given role.
- Parameters
-
| role | Model role key to check |
- Returns
- true if data exists for role
Definition at line 109 of file entitymetadata.h.
◆ iconId()
| int EntityMetadata::iconId |
( |
| ) |
const |
|
inline |
Return the icon ID associated with this entity's type.
- Returns
- Icon ID, or 0 if none was registered
Definition at line 88 of file entitymetadata.h.
◆ isValid()
| bool EntityMetadata::isValid |
( |
| ) |
const |
|
inline |
Test whether this metadata has a non-zero type.
- Returns
- true if type != 0
Definition at line 140 of file entitymetadata.h.
◆ operator==()
Equality comparison by type and UUID.
- Parameters
-
- Returns
- True if type and UUID match.
◆ registerIcon()
| static void EntityMetadata::registerIcon |
( |
int |
type, |
|
|
int |
iconId |
|
) |
| |
|
static |
Associate an icon ID with an already-registered entity type.
- Parameters
-
| type | Registered entity type integer |
| iconId | Icon identifier to associate |
◆ registerMetadata()
| static void EntityMetadata::registerMetadata |
( |
int |
type, |
|
|
const QString & |
name, |
|
|
int |
iconId = 0 |
|
) |
| |
|
static |
Register a name (and optional icon ID) for an entity type integer.
- Parameters
-
| type | Application-defined entity type integer |
| name | Human-readable name for this type |
| iconId | Optional icon identifier to associate with this type |
◆ setData()
| void EntityMetadata::setData |
( |
const QVariant & |
value, |
|
|
int |
role = KANOOP::DataRole |
|
) |
| |
|
inline |
Store a value under the given role.
- Parameters
-
Definition at line 102 of file entitymetadata.h.
◆ setUuid()
| void EntityMetadata::setUuid |
( |
const QUuid & |
value | ) |
|
|
inline |
◆ toVariant()
| QVariant EntityMetadata::toVariant |
( |
| ) |
const |
|
inline |
◆ type()
| int EntityMetadata::type |
( |
| ) |
const |
|
inline |
◆ typeString()
| QString EntityMetadata::typeString |
( |
| ) |
const |
Return the human-readable name for this entity's type.
- Returns
- Registered type name string, or empty string if unknown
◆ uuid()
| QUuid EntityMetadata::uuid |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: