C

SafeRenderer::QSafeLayout Class

class SafeRenderer::QSafeLayout

The QSafeLayout class provides an abstract class for accessing the Qt Safe Renderer layout data. More...

Header: #include <QSafeLayout>
Since: QtSafeRenderer 1.0
Inherited By:

SafeRenderer::QSafeLayoutFileReader and SafeRenderer::QSafeLayoutResourceReader

Public Functions

QSafeLayout(SafeRenderer::QSafeBitmapReader *const bitmapReader)
void advanceAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)
const SafeRenderer::QSafeBitmap *bitmapForItem(const SafeRenderer::quint32 idArg) const
virtual SafeRenderer::QSafeFontCache *fontCache() const = 0
SafeRenderer::LayoutItem &getLayoutItem(const SafeRenderer::quint32 idArg) &
const SafeRenderer::LayoutItem &getLayoutItem(const SafeRenderer::quint32 idArg) const &
const SafeRenderer::QSafeStateTransition &getStateTransition(const SafeRenderer::quint32 indexArg) const &
bool isPositionValidForItem(const SafeRenderer::quint32 itemId, const SafeRenderer::qint32 x, const SafeRenderer::qint32 y)
SafeRenderer::quint32 layoutId() const
SafeRenderer::LayoutParserState parserState() const
virtual const SafeRenderer::QSafeByteArray readDataFromFile(const SafeRenderer::qchar *const filenameArg) = 0
void restartAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)
void setAlphaForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint8 alphaArg)
void setBitmapForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint32 bitmapIdArg)
void setColorForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::ARGB colorArg)
void setLayoutId(const SafeRenderer::quint32 &layoutIdArg)
void setPositionForItem(const SafeRenderer::qchar *const name, const SafeRenderer::qint32 x, const SafeRenderer::qint32 y)
void setPositionForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::qint32 x, const SafeRenderer::qint32 y)
void setTextForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::QSafeString &textArg)
SafeRenderer::quint32 stateTransitionsCount() const

Static Public Members

size_t layoutDataSize(const SafeRenderer::quint32 layoutVersionArg)
SafeRenderer::quint32 layoutVersion(const SafeRenderer::QSafeByteArray &layoutDataArg)
SafeRenderer::quint32 validateLayout(const SafeRenderer::QSafeByteArray &layoutDataArg)

Detailed Description

The QSafeLayout class provides an abstract class for accessing the Qt Safe Renderer layout data.

Member Function Documentation

[explicit] QSafeLayout::QSafeLayout(SafeRenderer::QSafeBitmapReader *const bitmapReader)

Constructs a safe layout object using a bitmapReader instance to access the bitmap data.

void QSafeLayout::advanceAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)

Advances the stateIndexArg at transitionIndexArg.

const SafeRenderer::QSafeBitmap *QSafeLayout::bitmapForItem(const SafeRenderer::quint32 idArg) const

Returns the bitmap object of the layout item identified by idArg. Returns nullptr if bitmaps is not found.

See also setBitmapForItem().

[pure virtual] SafeRenderer::QSafeFontCache *QSafeLayout::fontCache() const

Returns a pointer to the font cache. This function is implemented in the inherited classes.

SafeRenderer::LayoutItem &QSafeLayout::getLayoutItem(const SafeRenderer::quint32 idArg) &

Non-const reference to requested LayoutItem with id idArg. \see const LayoutItem &QSafeLayout::getLayoutItem(const quint32 idArg) const & Returns reference to LayoutItem data of the requested item idArg

const SafeRenderer::LayoutItem &QSafeLayout::getLayoutItem(const SafeRenderer::quint32 idArg) const &

The id value is the hash of the safe item's objectName in a QML UI Form file. In case of a item is not found, an exception will be thrown:

For example:

SafePicture {
    objectName: "iconCoolant"
    width: 64
    height: 64
    color: "#e41e25"
    source: "qrc:/iso-icons/iso_grs_7000_4_2426.dat"
}

The ID value can be calculated as follows:

quint32 id = qt_hash("iconCoolant", safe_strlen("iconCoolant");

Returns SafeRenderer::LayoutItem item idenfified by idArg.

const SafeRenderer::QSafeStateTransition &QSafeLayout::getStateTransition(const SafeRenderer::quint32 indexArg) const &

Returns the QSafeStateTransition at indexArg

In case the indexArg is greater than the count of states SafeRenderer::QSafeStates::StatesException::IndexOutOfBounds is thrown.

bool QSafeLayout::isPositionValidForItem(const SafeRenderer::quint32 itemId, const SafeRenderer::qint32 x, const SafeRenderer::qint32 y)

Checks that the given x and y position are valid for the object identified by itemId. Returns true if position is valid. false if item cannot be moved to the new position.

Note: This function does not throw. If item is not found or it's bitmap is not set, the function will return false, just as it will if the item would be out of bounds after move.

[static] size_t QSafeLayout::layoutDataSize(const SafeRenderer::quint32 layoutVersionArg)

Returns the layout size for the given layout version. 0 if version is not supported.

SafeRenderer::quint32 QSafeLayout::layoutId() const

Getter function for the layout id.

LayoutId is a unique id for each layout instances. By default layoutId is the hash value of the layout filename.

See also setLayoutId().

[static] SafeRenderer::quint32 QSafeLayout::layoutVersion(const SafeRenderer::QSafeByteArray &layoutDataArg)

Returns the layout version fetched from the given layoutDataArg.

SafeRenderer::LayoutParserState QSafeLayout::parserState() const

Returns the state of the parser.

[pure virtual] const SafeRenderer::QSafeByteArray QSafeLayout::readDataFromFile(const SafeRenderer::qchar *const filenameArg)

Reads a file with filenameArg. Returns the reference to the read data. This function is implemented in the inherited classes.

void QSafeLayout::restartAnimation(const SafeRenderer::quint32 stateIndexArg, const SafeRenderer::quint32 transitionIndexArg)

Restarts the stateIndexArg at transitionIndexArg.

void QSafeLayout::setAlphaForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint8 alphaArg)

Sets the alphaArg alpha value to the object identified by idArg.

In case of a failure, the following exceptions will be thrown:

void QSafeLayout::setBitmapForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::quint32 bitmapIdArg)

Sets the bitmapIdArg value to the object identified by idArg.

In case of a failure, one of the following exceptions will be thrown:

See also bitmapForItem().

void QSafeLayout::setColorForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::ARGB colorArg)

Sets the colorArg color to the object identified by idArg.

This method allows to change mutable objects' like picture's color.

In case of a failure, one of the following exceptions will be thrown:

void QSafeLayout::setLayoutId(const SafeRenderer::quint32 &layoutIdArg)

Sets the layout id to the value layoutIdArg.

See also layoutId().

void QSafeLayout::setPositionForItem(const SafeRenderer::qchar *const name, const SafeRenderer::qint32 x, const SafeRenderer::qint32 y)

Sets the x and y positions to the object named name.

In case of a failure, one of the following exceptions will be thrown:

void QSafeLayout::setPositionForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::qint32 x, const SafeRenderer::qint32 y)

Sets the x and y positions to the object identified by idArg.

In case of a failure, one of the following exceptions will be thrown:

void QSafeLayout::setTextForItem(const SafeRenderer::quint32 idArg, const SafeRenderer::QSafeString &textArg)

Sets the textArg text to the object identified by idArg.

In case of a failure, the following exception will be thrown:

ExceptionIdDescription
SafeRenderer::QSafeLayoutExceptionSafeRenderer::QSafeLayoutException::LayoutException::UnknownItemThe item idArg does not exist or is not a text layout item

SafeRenderer::quint32 QSafeLayout::stateTransitionsCount() const

Returns the count of the states.

[static] SafeRenderer::quint32 QSafeLayout::validateLayout(const SafeRenderer::QSafeByteArray &layoutDataArg)

QSafeLayout::validateLayout validates the data in the layoutDataArg. layoutDataArg Returns the count of the items in the layout file.

Available under certain Qt licenses.
Find out more.