// QGridLayout/QFormLayout Helpers: get item position/add item (overloads to make templates work)
-void getGridItemPosition(QGridLayout *gridLayout, int index, int *row, int *column, int *rowspan, int *colspan)
-{
- gridLayout->getItemPosition(index, row, column, rowspan, colspan);
-}
-
void addWidgetToGrid(QGridLayout *lt, QWidget * widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment)
{
lt->addWidget(widget, row, column, rowSpan, columnSpan, alignment);
}
-inline void getGridItemPosition(QFormLayout *formLayout, int index, int *row, int *column, int *rowspan, int *colspan)
-{
- getFormLayoutItemPosition(formLayout, index, row, column, rowspan, colspan);
-}
-
inline void addWidgetToGrid(QFormLayout *lt, QWidget * widget, int row, int column, int, int columnSpan, Qt::Alignment)
{
formLayoutAddWidget(lt, widget, QRect(column, row, columnSpan, 1), false);
virtual void sort() { setWidgets(buildGrid(widgets())); }
protected:
- QWidget *widgetAt(GridLikeLayout *layout, int row, int column) const;
-
-protected:
QWidgetList buildGrid(const QWidgetList &);
Grid m_grid;
};
}
template <class GridLikeLayout, int LayoutType, int GridMode>
-QWidget *GridLayout<GridLikeLayout, LayoutType, GridMode>::widgetAt(GridLikeLayout *layout, int row, int column) const
-{
- int index = 0;
- while (QLayoutItem *item = layout->itemAt(index)) {
- if (item->widget()) {
- int r, c, rowspan, colspan;
- getGridItemPosition(layout, index, &r, &c, &rowspan, &colspan);
- if (row == r && column == c)
- return item->widget();
- }
- ++index;
- }
- return 0;
-}
-
-template <class GridLikeLayout, int LayoutType, int GridMode>
void GridLayout<GridLikeLayout, LayoutType, GridMode>::doLayout()
{
bool needMove, needReparent;