forked from qt-creator/qt-creator
Layouting: Code cosmetics
Change-Id: I0eea49bc5c39679ca66f73616a98e91546e493c2 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -24,48 +24,15 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Layouting {
|
||||
|
||||
class LayoutBuilder;
|
||||
class LayoutItem;
|
||||
class Span;
|
||||
|
||||
// Special items
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Space
|
||||
{
|
||||
public:
|
||||
explicit Space(int space) : space(space) {}
|
||||
const int space;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Stretch
|
||||
{
|
||||
public:
|
||||
explicit Stretch(int stretch = 1) : stretch(stretch) {}
|
||||
const int stretch;
|
||||
};
|
||||
|
||||
|
||||
// LayoutItem
|
||||
|
||||
class LayoutBuilder;
|
||||
class LayoutItem;
|
||||
using LayoutItems = QList<LayoutItem>;
|
||||
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const std::function<void(QObject *target)> &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, QWidget *t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, QLayout *t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, LayoutItem(*t)());
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const QString &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Span &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Space &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Stretch &t);
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT LayoutItem
|
||||
{
|
||||
public:
|
||||
enum class AlignmentType {
|
||||
DefaultAlignment,
|
||||
AlignAsFormLabel,
|
||||
};
|
||||
|
||||
using Setter = std::function<void(QObject *target)>;
|
||||
|
||||
LayoutItem();
|
||||
@@ -88,7 +55,6 @@ public:
|
||||
void addItem(const LayoutItem &item);
|
||||
void addItems(const LayoutItems &items);
|
||||
void addRow(const LayoutItems &items);
|
||||
void finishRow();
|
||||
|
||||
std::function<void(LayoutBuilder &)> onAdd;
|
||||
std::function<void(LayoutBuilder &)> onExit;
|
||||
@@ -96,6 +62,22 @@ public:
|
||||
LayoutItems subItems;
|
||||
};
|
||||
|
||||
// Special items
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Space
|
||||
{
|
||||
public:
|
||||
explicit Space(int space) : space(space) {}
|
||||
const int space;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Stretch
|
||||
{
|
||||
public:
|
||||
explicit Stretch(int stretch = 1) : stretch(stretch) {}
|
||||
const int stretch;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Span
|
||||
{
|
||||
public:
|
||||
@@ -181,6 +163,17 @@ public:
|
||||
int exec(int &argc, char *argv[]);
|
||||
};
|
||||
|
||||
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const std::function<void(QObject *target)> &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, QWidget *t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, QLayout *t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, LayoutItem(*t)());
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const QString &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Span &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Space &t);
|
||||
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Stretch &t);
|
||||
|
||||
|
||||
// "Singletons"
|
||||
|
||||
QTCREATOR_UTILS_EXPORT LayoutItem br();
|
||||
|
||||
Reference in New Issue
Block a user