C

QSafeLayout 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 Types

enum LayoutException { UnknownBitmapId, UnknownItem, ItemOutOfBounds, ItemOverlapsWithOthers, ..., TooLongFilename }
enum LayoutParserState { INVALID, OK }

Public Functions

QSafeLayout()
QSafeLayout(QSafeBitmapReader * const bitmapReader)
virtual ~QSafeLayout()
QSafeBitmap *bitmapForItem(const quint32 id)
quint32 count() const
LayoutData &item(const quint32 idx)
quint32 layoutId() const
LayoutParserState parserState() const
QSafePoint position() const
QSafePoint positionForItem(const quint32 id) const
void setLayoutId(const quint32 &layoutIdArg)
void setPositionForItem(const qchar * const name, const quint32 x, const quint32 y)
void setPositionForItem(const quint32 id, const quint32 x, const quint32 y)
QSafeSize size() const

Detailed Description

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

Member Type Documentation

enum QSafeLayout::LayoutException

This enum describes the exception values in the QSafeLayout class.

ConstantValueDescription
SafeRenderer::QSafeLayout::UnknownBitmapId0The bitmap ID is not found from layout.
SafeRenderer::QSafeLayout::UnknownItem1The item is not found.
SafeRenderer::QSafeLayout::ItemOutOfBounds2The item's new position is out of bounds.
SafeRenderer::QSafeLayout::ItemOverlapsWithOthers3The item's new position overlaps with the other items.
SafeRenderer::QSafeLayout::SizeErrorWidth5The width of the layout size too long.
SafeRenderer::QSafeLayout::SizeErrorHeight6The height of the layout size too long.
SafeRenderer::QSafeLayout::DataSizeMismatch4The layout file size is not multiple of the layout data size, or the layout data size is too small.
SafeRenderer::QSafeLayout::InvalidLayoutVersion7Layout version is not supported.
SafeRenderer::QSafeLayout::CheckSumFailed8Layout file checksum fails
SafeRenderer::QSafeLayout::TooLongFilename9Bitmap's filename is too long to fit in temporary buffer.

enum QSafeLayout::LayoutParserState

This enum describes the status values in the QSafeLayout class.

ConstantValueDescription
SafeRenderer::QSafeLayout::INVALID0The layout data is invalid.
SafeRenderer::QSafeLayout::OK1Layout data read and validated.

Member Function Documentation

QSafeLayout::QSafeLayout()

Default constructs an instance of QSafeLayout.

QSafeLayout::QSafeLayout(QSafeBitmapReader * const bitmapReader)

Constructs a safe layout object.

bitmapReader instance need to be passed as it is used for accessing the bitmap data.

[virtual] QSafeLayout::~QSafeLayout()

Destroys the safe layout object.

QSafeBitmap *QSafeLayout::bitmapForItem(const quint32 id)

id is the ID of the layout item.

Returns the bitmap object of the layout item.

In case of a failure, an exception will be thrown:

ConstantDescription
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBoundsThe bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS.

quint32 QSafeLayout::count() const

Returns the count of the layout items.

LayoutData &QSafeLayout::item(const quint32 idx)

Returns the reference to LayoutData at idx.

quint32 QSafeLayout::layoutId() const

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

See also setLayoutId().

LayoutParserState QSafeLayout::parserState() const

Returns the state of the parser.

QSafePoint QSafeLayout::position() const

Returns the position of the layout.

QSafePoint QSafeLayout::positionForItem(const quint32 id) const

id is the ID of the layout item. The ID value is the hash of the safe item's objectName in a QML UI Form file.

Returns the position of the layout item.

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");

See also setPositionForItem().

void QSafeLayout::setLayoutId(const quint32 &layoutIdArg)

Set layoutid to the value layoutIdArg.

See also layoutId().

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

Set the x, y position to the object named name.

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

ConstantDescription
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBoundsThe bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS.
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBoundsThe item's new position is outside the window boundaries.
SafeRenderer::QSafeLayout::LayoutException::ItemOverlapsWithOthersThe new position overlaps with the other objects.
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item name does not exist.
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapIdThe bitmap that is associated with the layout item is not found.

See also positionForItem().

void QSafeLayout::setPositionForItem(const quint32 id, const quint32 x, const quint32 y)

Set the x, y position to the object identified by id.

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

ConstantDescription
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBoundsThe bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS.
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBoundsThe item's new position is outside the window boundaries.
SafeRenderer::QSafeLayout::LayoutException::ItemOverlapsWithOthersThe new position overlaps with the other objects.
SafeRenderer::QSafeLayout::LayoutException::UnknownItemThe item id does not exist.
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapIdThe bitmap that is associated with the layout item is not found.

QSafeSize QSafeLayout::size() const

Returns the size of the layout.

Available under certain Qt licenses.
Find out more.