forked from qt-creator/qt-creator
Utils: Consolidate LayoutBuilder interface a bit
- the var args template for addItems was overkill creating a lot of
instantiations. Use a temporary list instead.
- allow default constructed LayoutItems to be used for an empty cell,
avoiding the use of a QLabel with empty text
- add an addRow({...}) overload as convenience shortcut for
.startNewRow().addItems({...}
- rename startNewRow() to finishRow()
Change-Id: I6d49dacbac3d7acf140ca526884ba1ceeeca2e0d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -53,6 +53,7 @@ public:
|
||||
class LayoutItem
|
||||
{
|
||||
public:
|
||||
LayoutItem() {} // For empty cells.
|
||||
LayoutItem(QLayout *layout, int span = 1) : layout(layout), span(span) {}
|
||||
LayoutItem(QWidget *widget, int span = 1, Qt::Alignment align = {})
|
||||
: widget(widget), span(span), align(align) {}
|
||||
@@ -67,15 +68,12 @@ public:
|
||||
Qt::Alignment align;
|
||||
};
|
||||
|
||||
template<typename ...Items>
|
||||
LayoutBuilder &addItems(LayoutItem first, Items... rest) {
|
||||
return addItem(first).addItems(rest...);
|
||||
}
|
||||
LayoutBuilder &addItems() { return *this; }
|
||||
LayoutBuilder &addItem(LayoutItem item);
|
||||
LayoutBuilder &addItem(const LayoutItem &item);
|
||||
LayoutBuilder &addItems(const QList<LayoutItem> &items);
|
||||
|
||||
LayoutBuilder &startNewRow();
|
||||
LayoutBuilder &finishRow();
|
||||
LayoutBuilder &addRow(const LayoutItem &item);
|
||||
LayoutBuilder &addRow(const QList<LayoutItem> &items);
|
||||
|
||||
QLayout *layout() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user