C
QSafeLayout Class
class SafeRenderer::QSafeLayoutThe QSafeLayout class provides an abstract class for accessing the Qt Safe Renderer layout data. More...
Header: | #include <QSafeLayout> |
Inherited By: | SafeRenderer::QSafeLayoutFileReader and SafeRenderer::QSafeLayoutResourceReader |
Public Types
enum | LayoutException { UnknownBitmapId, UnknownItem, ItemOutOfBounds, SizeErrorWidth, SizeErrorHeight, …, InvalidLayoutType } |
enum | LayoutParserState { INVALID, OK } |
Public Functions
QSafeLayout(SafeRenderer::QSafeBitmapReader *const bitmapReader) | |
virtual | ~QSafeLayout() |
const SafeRenderer::QSafeBitmap * | bitmapForItem(const SafeRenderer::quint32 id) |
bool | contains(const SafeRenderer::quint32 idArg) const |
SafeRenderer::quint32 | count() const |
virtual SafeRenderer::QSafeFontCache * | fontCache() const = 0 |
SafeRenderer::LayoutData & | item(const SafeRenderer::quint32 idx) |
SafeRenderer::quint32 | layoutId() const |
SafeRenderer::QSafeLayout::LayoutParserState | parserState() const |
SafeRenderer::QSafePoint | position() const |
SafeRenderer::QSafePoint | positionForItem(const SafeRenderer::quint32 id) const |
virtual void | readDataFromFile(const SafeRenderer::qchar *const fileName, SafeRenderer::LayoutDataBuffer &buffer) = 0 |
void | setLayoutId(const SafeRenderer::quint32 &layoutIdArg) |
void | setPositionForItem(const SafeRenderer::qchar *const name, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y) |
void | setPositionForItem(const SafeRenderer::quint32 id, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y) |
SafeRenderer::QSafeSize | size() const |
SafeRenderer::QSafeTextLayout * | textLayoutById(const SafeRenderer::quint32 id) |
Member Type Documentation
enum QSafeLayout::LayoutException
This enum describes the exception values in the QSafeLayout class.
Constant | Value | Description |
---|---|---|
SafeRenderer::QSafeLayout::UnknownBitmapId | 0 | The bitmap ID is not found from layout. |
SafeRenderer::QSafeLayout::UnknownItem | 1 | The item is not found. |
SafeRenderer::QSafeLayout::ItemOutOfBounds | 2 | The item's new position is out of bounds. |
SafeRenderer::QSafeLayout::SizeErrorWidth | 4 | The width of the layout size too long. |
SafeRenderer::QSafeLayout::SizeErrorHeight | 5 | The height of the layout size too long. |
SafeRenderer::QSafeLayout::DataSizeMismatch | 3 | The layout file size is not multiple of the layout data size, or the layout data size is too small. |
SafeRenderer::QSafeLayout::InvalidLayoutVersion | 6 | Layout version is not supported. |
SafeRenderer::QSafeLayout::CheckSumFailed | 7 | Layout file checksum fails |
SafeRenderer::QSafeLayout::TooLongFilename | 8 | Bitmap's filename is too long to fit in temporary buffer. |
SafeRenderer::QSafeLayout::InvalidLayoutType | 9 | The layout type is Invalid. |
enum QSafeLayout::LayoutParserState
This enum describes the status values in the QSafeLayout class.
Constant | Value | Description |
---|---|---|
SafeRenderer::QSafeLayout::INVALID | 0 | The layout data is invalid. |
SafeRenderer::QSafeLayout::OK | 1 | Layout data read and validated. |
Member Function Documentation
QSafeLayout::QSafeLayout(SafeRenderer::QSafeBitmapReader *const bitmapReader)
Constructs a safe layout object using a bitmapReader instance to access the bitmap data.
[virtual]
QSafeLayout::~QSafeLayout()
Destroys the safe layout object.
const SafeRenderer::QSafeBitmap *QSafeLayout::bitmapForItem(const SafeRenderer::quint32 id)
Returns the bitmap object of the layout item identified by id.
In case of a failure, an exception will be thrown:
Constant | Description |
---|---|
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBounds | The bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS. |
bool QSafeLayout::contains(const SafeRenderer::quint32 idArg) const
Returns true if layout data contains idArg. Otherwise returns false.
SafeRenderer::quint32 QSafeLayout::count() const
Returns the count of the layout items.
[pure virtual]
SafeRenderer::QSafeFontCache *QSafeLayout::fontCache() const
Interface function to return a pointer to the font cache.
SafeRenderer::LayoutData &QSafeLayout::item(const SafeRenderer::quint32 idx)
Returns the reference to LayoutData at idx.
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().
SafeRenderer::QSafeLayout::LayoutParserState QSafeLayout::parserState() const
Returns the state of the parser.
SafeRenderer::QSafePoint QSafeLayout::position() const
Returns the position of the layout.
SafeRenderer::QSafePoint QSafeLayout::positionForItem(const SafeRenderer::quint32 id) const
Returns the position of the layout item idenfified by id.
The id value is the hash of the safe item's objectName
in a QML UI Form file.
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().
[pure virtual]
void QSafeLayout::readDataFromFile(const SafeRenderer::qchar *const fileName, SafeRenderer::LayoutDataBuffer &buffer)
Interface function to read a file with fileName to buffer.
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::quint32 x, const SafeRenderer::quint32 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:
Constant | Description |
---|---|
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBounds | The bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS. |
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBounds | The item's new position is outside the window boundaries. |
SafeRenderer::QSafeLayout::LayoutException::UnknownItem | The item name does not exist. |
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapId | The bitmap that is associated with the layout item is not found. |
See also positionForItem().
void QSafeLayout::setPositionForItem(const SafeRenderer::quint32 id, const SafeRenderer::quint32 x, const SafeRenderer::quint32 y)
Sets the x and y positions to the object identified by id.
In case of a failure, one of the following exceptions will be thrown:
Constant | Description |
---|---|
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBounds | The bitmap index exceeds the value defined in SafeRenderer::Constraints::MAX_AMOUNT_OF_BITMAPS. |
SafeRenderer::QSafeLayout::LayoutException::ItemOutOfBounds | The item's new position is outside the window boundaries. |
SafeRenderer::QSafeLayout::LayoutException::UnknownItem | The item id does not exist. |
SafeRenderer::QSafeLayout::LayoutException::UnknownBitmapId | The bitmap that is associated with the layout item is not found. |
SafeRenderer::QSafeSize QSafeLayout::size() const
Returns the size of the layout.
SafeRenderer::QSafeTextLayout *QSafeLayout::textLayoutById(const SafeRenderer::quint32 id)
Returns the bitmap object of the layout item identified by id. In case of a failure, an exception will be thrown:
Constant | Value |
---|---|
SafeRenderer::QSafeBitmapFileReader::BitmapFileReaderException::IndexOutOfBounds |
This function was introduced in QtSafeRenderer 1.1.
Available under certain Qt licenses.
Find out more.