return d->alignment;
}
-// DeclarativeFormLayout
class DeclarativeFormLayoutAttached::Private
{
public:
emit labelChanged(label);
}
+class DeclarativeGridLayoutAttached::Private
+{
+ public:
+ Private() : row(0), column(0), rowSpan(1), columnSpan(1), alignment(0) {}
+
+ int row;
+ int column;
+ int rowSpan;
+ int columnSpan;
+ Qt::Alignment alignment;
+};
+
+DeclarativeGridLayoutAttached::DeclarativeGridLayoutAttached(QObject *parent)
+ : QObject(parent), d(new Private)
+{
+}
+
+DeclarativeGridLayoutAttached::~DeclarativeGridLayoutAttached()
+{
+ delete d;
+}
+
+void DeclarativeGridLayoutAttached::setRow(int row)
+{
+ if (row == d->row)
+ return;
+
+ d->row = row;
+ emit rowChanged(row);
+}
+
+int DeclarativeGridLayoutAttached::row() const
+{
+ return d->row;
+}
+
+void DeclarativeGridLayoutAttached::setColumn(int column)
+{
+ if (column == d->column)
+ return;
+
+ d->column = column;
+ emit columnChanged(column);
+}
+
+int DeclarativeGridLayoutAttached::column() const
+{
+ return d->column;
+}
+
+void DeclarativeGridLayoutAttached::setRowSpan(int rowSpan)
+{
+ if (rowSpan == d->rowSpan)
+ return;
+
+ d->rowSpan = rowSpan;
+ emit rowSpanChanged(rowSpan);
+}
+
+int DeclarativeGridLayoutAttached::rowSpan() const
+{
+ return d->rowSpan;
+}
+
+void DeclarativeGridLayoutAttached::setColumnSpan(int columnSpan)
+{
+ if (columnSpan == d->columnSpan)
+ return;
+
+ d->columnSpan = columnSpan;
+ emit columnSpanChanged(columnSpan);
+}
+
+int DeclarativeGridLayoutAttached::columnSpan() const
+{
+ return d->columnSpan;
+}
+
+void DeclarativeGridLayoutAttached::setAlignment(Qt::Alignment alignment)
+{
+ if (alignment == d->alignment)
+ return;
+
+ d->alignment = alignment;
+ emit alignmentChanged(alignment);
+}
+
+Qt::Alignment DeclarativeGridLayoutAttached::alignment() const
+{
+ return d->alignment;
+}
+
QString DeclarativeFormLayoutAttached::label() const
{
return d->label;
}
+// DeclarativeFormLayout
DeclarativeFormLayout::DeclarativeFormLayout(QObject *parent) : DeclarativeLayoutProxy<QFormLayout>(parent)
{
connectAllSignals(m_proxiedObject, this);
CUSTOM_METAOBJECT(DeclarativeFormLayout, QFormLayout)
+// DeclarativeGridLayout
+DeclarativeGridLayout::DeclarativeGridLayout(QObject *parent) : DeclarativeLayoutProxy<QGridLayout>(parent)
+{
+ connectAllSignals(m_proxiedObject, this);
+}
+
+DeclarativeGridLayoutAttached *DeclarativeGridLayout::qmlAttachedProperties(QObject *parent)
+{
+ return new DeclarativeGridLayoutAttached(parent);
+}
+
+void DeclarativeGridLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject)
+{
+ int row = 0;
+ int column = 0;
+ int rowSpan = 1;
+ int columnSpan = 1;
+ Qt::Alignment alignment = 0;
+
+ QObject *attachedProperties = qmlAttachedPropertiesObject<DeclarativeGridLayout>(declarativeObject, false);
+ DeclarativeGridLayoutAttached *properties = qobject_cast<DeclarativeGridLayoutAttached*>(attachedProperties);
+ if (properties) {
+ row = properties->row();
+ column = properties->column();
+ rowSpan = properties->rowSpan();
+ columnSpan = properties->columnSpan();
+ alignment = properties->alignment();
+ }
+
+ m_proxiedObject->addWidget(widget, row, column, rowSpan, columnSpan, alignment);
+ m_children.append(declarativeObject);
+}
+
+void DeclarativeGridLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject)
+{
+ int row = 0;
+ int column = 0;
+ int rowSpan = 1;
+ int columnSpan = 1;
+ Qt::Alignment alignment = 0;
+
+ QObject *attachedProperties = qmlAttachedPropertiesObject<DeclarativeGridLayout>(declarativeObject, false);
+ DeclarativeGridLayoutAttached *properties = qobject_cast<DeclarativeGridLayoutAttached*>(attachedProperties);
+ if (properties) {
+ row = properties->row();
+ column = properties->column();
+ rowSpan = properties->rowSpan();
+ columnSpan = properties->columnSpan();
+ alignment = properties->alignment();
+ }
+
+ m_proxiedObject->addLayout(layout, row, column, rowSpan, columnSpan, alignment);
+ m_children.append(declarativeObject);
+}
+
+CUSTOM_METAOBJECT(DeclarativeGridLayout, QGridLayout)
+
// DeclarativeHBoxLayout
DeclarativeHBoxLayout::DeclarativeHBoxLayout(QObject *parent) : DeclarativeLayoutProxy<QHBoxLayout>(parent)
{
DeclarativeObjectProxy<T>::m_proxiedObject->addWidget(widget);
}
- virtual void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject)
- {
- DeclarativeObjectProxy<T>::m_children.append(declarativeObject);
- DeclarativeObjectProxy<T>::m_proxiedObject->addItem(layout);
- }
+ virtual void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) = 0;
};
//// Objects ///
Private *const d;
};
+class DeclarativeGridLayoutAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged)
+ Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged)
+ Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan NOTIFY rowSpanChanged)
+ Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan NOTIFY columnSpanChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+
+ public:
+ DeclarativeGridLayoutAttached(QObject *parent = 0);
+ ~DeclarativeGridLayoutAttached();
+
+ void setRow(int row);
+ int row() const;
+
+ void setColumn(int column);
+ int column() const;
+
+ void setRowSpan(int rowSpan);
+ int rowSpan() const;
+
+ void setColumnSpan(int columnSpan);
+ int columnSpan() const;
+
+ void setAlignment(Qt::Alignment alignment);
+ Qt::Alignment alignment() const;
+
+ Q_SIGNALS:
+ void rowChanged(int row);
+ void columnChanged(int column);
+ void rowSpanChanged(int rowSpan);
+ void columnSpanChanged(int columnSpan);
+ void alignmentChanged(Qt::Alignment alignment);
+
+ private:
+ class Private;
+ Private *const d;
+};
+
class DeclarativeFormLayout : public DeclarativeLayoutProxy<QFormLayout>
{
DECLARATIVE_OBJECT
QML_DECLARE_TYPEINFO(DeclarativeFormLayout, QML_HAS_ATTACHED_PROPERTIES)
+class DeclarativeGridLayout : public DeclarativeLayoutProxy<QGridLayout>
+{
+ DECLARATIVE_OBJECT
+
+ public:
+ DeclarativeGridLayout(QObject *parent = 0);
+
+ static DeclarativeGridLayoutAttached *qmlAttachedProperties(QObject *parent);
+
+ protected:
+ void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject);
+ void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject);
+};
+
+QML_DECLARE_TYPEINFO(DeclarativeGridLayout, QML_HAS_ATTACHED_PROPERTIES)
+
class DeclarativeHBoxLayout : public DeclarativeLayoutProxy<QHBoxLayout>
{
DECLARATIVE_OBJECT