#ifndef PQGRIDLAYOUT
#define PQGRIDLAYOUT

#include <QGridLayout>
#include "classes/pqwidget.h"

class PQGridLayout;
class PQGridLayout : public QGridLayout {
    Q_OBJECT
    PQ_OBJECT_EX(QGridLayout)

    Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
    Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
    Q_PROPERTY(int spacing READ spacing WRITE setSpacing)

public:
    Q_INVOKABLE explicit PQGridLayout(QWidget * parent=0);
    virtual ~PQGridLayout();

    Q_INVOKABLE int addSpacer(int w, int h, int row, int col, int hData = 1, int vData = 1);
    Q_INVOKABLE bool removeSpacer(int index);
    Q_INVOKABLE int horizontalSpacing();
    Q_INVOKABLE int verticalSpacing();
    Q_INVOKABLE int spacing();
    Q_INVOKABLE void setContentsMargins(int left, int top, int right, int bottom);
    Q_INVOKABLE int count();

    Q_INVOKABLE bool setAlignment(QWidget *w, int alignment);
    Q_INVOKABLE bool setAlignment(QLayout *l, int alignment);

public Q_SLOTS:
    Q_INVOKABLE void addWidget(QWidget *qw, int row, int col);
    Q_INVOKABLE void addWidget(QWidget *qw, int row, int col, int rowSpan, int colSpan);
    Q_INVOKABLE void setMargin(int margin);
    Q_INVOKABLE void setHorizontalSpacing(int spacing);
    Q_INVOKABLE void setVerticalSpacing(int spacing);
    Q_INVOKABLE void setSpacing(int spacing);
    Q_INVOKABLE void setRowMinimumHeight(int row, int minHeight);
    Q_INVOKABLE void setColumnMinimumWidth(int col, int minWidth);
    Q_INVOKABLE void addLayout(QLayout *layout, int row, int col);
    Q_INVOKABLE void addLayout(QLayout *layout, int row, int col, int rowSpan, int colSpan);

private:
    QHash<int, QSpacerItem *> spacers;
};

Q_DECLARE_METATYPE(PQGridLayout*)

#endif // PQGRIDLAYOUT

