Commit 896a76e1 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add QQuickTableContainer

Fix QQmlListPropertyHelper
parent c3f109c2
Pipeline #1007 passed with stage
in 21 seconds
......@@ -12,6 +12,7 @@
#include "QQuickGridContainer.h"
#include "QQuickRowContainer.h"
#include "QQuickStackContainer.h"
#include "QQuickTableContainer.h"
#include "QQuickSvgIconHelper.h"
#include "QQuickRoundedRectangleItem.h"
#include "QQmlMimeIconsHelper.h"
......@@ -31,7 +32,11 @@ void QtQmlTricks::registerComponents (QQmlEngine * engine) {
qmlRegisterType<QQuickStackContainer> ("QtQmlTricks", 3, 0, "StackContainer");
qmlRegisterType<QQuickFormContainer> ("QtQmlTricks", 3, 0, "FormContainer");
qmlRegisterType<QQuickRowContainer> ("QtQmlTricks", 3, 0, "RowContainer");
qmlRegisterType<QQuickFastObjectListView> ("QtQmlTricks", 3, 0, "FastObjectListView");
qmlRegisterType<QQuickTableContainer> ("QtQmlTricks", 3, 0, "TableContainer");
qmlRegisterType<QQmlTableDivision> ("QtQmlTricks", 3, 0, "TableDiv");
qmlRegisterUncreatableType<QQmlTableCellPosH> ("QtQmlTricks", 3, 0, "TableCellPosH", ERR_ENUM_CLASS);
qmlRegisterUncreatableType<QQmlTableCellPosV> ("QtQmlTricks", 3, 0, "TableCellPosV", ERR_ENUM_CLASS);
qmlRegisterUncreatableType<QQmlTableAttachedObject> ("QtQmlTricks", 3, 0, "TableCell", ERR_ATTACHED_OBJ);
qmlRegisterUncreatableType<VerticalDirections> ("QtQmlTricks", 3, 0, "VerticalDirections", ERR_ENUM_CLASS);
qmlRegisterUncreatableType<HorizontalDirections> ("QtQmlTricks", 3, 0, "HorizontalDirections", ERR_ENUM_CLASS);
qmlRegisterUncreatableType<FlowDirections> ("QtQmlTricks", 3, 0, "FlowDirections", ERR_ENUM_CLASS);
......@@ -42,6 +47,7 @@ void QtQmlTricks::registerComponents (QQmlEngine * engine) {
qmlRegisterUncreatableType<QQmlFastObjectListModelBase> ("QtQmlTricks", 3, 0, "FastObjectListModel", ERR_ABSTRACT_BASE);
qmlRegisterUncreatableType<QQmlAbstractMaterial> ("QtQmlTricks", 3, 0, "AbstractMaterial", ERR_ABSTRACT_BASE);
qmlRegisterUncreatableType<QQmlAbstractGradientMaterial> ("QtQmlTricks", 3, 0, "AbstractGradientMaterial", ERR_ABSTRACT_BASE);
qmlRegisterType<QQuickFastObjectListView> ("QtQmlTricks", 3, 0, "FastObjectListView");
qmlRegisterType<QQmlFlatColorMaterial> ("QtQmlTricks", 3, 0, "FlatColorMaterial");
qmlRegisterType<QQmlVerticalGradientMaterial> ("QtQmlTricks", 3, 0, "VerticalGradientMaterial");
qmlRegisterType<QQmlHorizontalGradientMaterial> ("QtQmlTricks", 3, 0, "HorizontalGradientMaterial");
......
......@@ -39,6 +39,12 @@ public:
inline const_iterator constBegin (void) const { return m_items.constBegin (); }
inline const_iterator constEnd (void) const { return m_items.constEnd (); }
inline int length (void) const { return m_items.length (); }
inline T * operator[] (const int idx) const {
return (idx >= 0 && idx < m_items.length () ? m_items.at (idx) : nullptr);
}
private:
cpp_list_type m_items;
};
......
This diff is collapsed.
#ifndef QQUICKTABLECONTAINER_H
#define QQUICKTABLECONTAINER_H
#include <QObject>
#include <QQuickItem>
#include "QmlEnumHelpers.h"
#include "QmlPropertyHelpers.h"
#include "QQmlListPropertyHelper.h"
QML_ENUM_CLASS (QQmlTableCellPosV,
TOP,
BOTTOM,
V_FILL,
V_CENTER,
)
QML_ENUM_CLASS (QQmlTableCellPosH,
LEFT,
RIGHT,
H_FILL,
H_CENTER,
)
class QQmlTableAttachedObject : public QObject {
Q_OBJECT
QML_WRITABLE_VAR_PROPERTY (row, int) // idx
QML_WRITABLE_VAR_PROPERTY (col, int) // idx
QML_WRITABLE_VAR_PROPERTY (rowPos, int) // enum QQmlTableCellPosV::Type
QML_WRITABLE_VAR_PROPERTY (colPos, int) // enum QQmlTableCellPosH::Type
public:
explicit QQmlTableAttachedObject (QObject * parent = nullptr);
virtual ~QQmlTableAttachedObject (void);
static QQmlTableAttachedObject * qmlAttachedProperties (QObject * object);
};
class QQmlTableDivision : public QObject {
Q_OBJECT
QML_WRITABLE_VAR_PROPERTY (fixedSize, int) // px
QML_WRITABLE_VAR_PROPERTY (stretchFactor, int) // int factor
QML_READONLY_VAR_PROPERTY (implicitSize, int) // px
QML_READONLY_VAR_PROPERTY (optimalSize, int) // px
QML_READONLY_VAR_PROPERTY (actualSize, int) // px
QML_READONLY_VAR_PROPERTY (beginPos, int) // px
QML_READONLY_VAR_PROPERTY (endPos, int) // px
public:
explicit QQmlTableDivision (QObject * parent = nullptr);
virtual ~QQmlTableDivision (void);
inline void beginComputeImplicitSize (void) {
m_tmpImplicitSize = 0;
}
inline void doComputeImplicitSize (const int size) {
if (size > m_tmpImplicitSize) {
m_tmpImplicitSize = size;
}
}
inline void endComputeImplicitSize (void) {
set_implicitSize (m_tmpImplicitSize);
}
private:
int m_tmpImplicitSize;
};
class QQuickTableContainer : public QQuickItem {
Q_OBJECT
QML_WRITABLE_VAR_PROPERTY (rowSpacing, int)
QML_WRITABLE_VAR_PROPERTY (colSpacing, int)
QML_LIST_PROPERTY (rows, QQmlTableDivision)
QML_LIST_PROPERTY (cols, QQmlTableDivision)
public:
explicit QQuickTableContainer (QQuickItem * parent = nullptr);
virtual ~QQuickTableContainer (void);
protected:
void classBegin (void) Q_DECL_FINAL;
void componentComplete (void) Q_DECL_FINAL;
void updatePolish (void) Q_DECL_FINAL;
void itemChange (ItemChange changeType, const ItemChangeData & changeData) Q_DECL_FINAL;
private:
QQmlTableAttachedObject * getTableAttachedObject (QQuickItem * item) const;
};
QML_DECLARE_TYPE (QQmlTableAttachedObject)
QML_DECLARE_TYPEINFO (QQmlTableAttachedObject, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKTABLECONTAINER_H
......@@ -78,6 +78,8 @@ Product {
"gui/containers/QQuickRowContainer.h",
"gui/containers/QQuickStackContainer.cpp",
"gui/containers/QQuickStackContainer.h",
"gui/containers/QQuickTableContainer.cpp",
"gui/containers/QQuickTableContainer.h",
"gui/helpers/QQuickExtraAnchors.cpp",
"gui/helpers/QQuickExtraAnchors.h",
"gui/helpers/QQuickSvgIconHelper.cpp",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment