From 6eaf239777a3166f2504b0dff90bb4afcacba89f Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 15 Oct 2019 17:20:51 +0200 Subject: ProjectExplorer: Prepare more flexibility to aspect layouting This hides the explicit use of a QFormLayout from the aspect interface in a new LayoutBuilder class. That currently works only on a QFormLayout in the back, but opens the possibility to use e.g. a QGridLayout as use on the Kits and some option pages. The aspects now only announce sub-widgets they like to add, actuall positioning is does by a new LayoutBuilder class, also cramming several widgets in an hbox in the right column of the QFormLayout is done there. Change-Id: I2b788192c465f2ab82261849d34e514697c5a491 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/projectconfiguration.h | 38 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src/plugins/projectexplorer/projectconfiguration.h') diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index bc6d33fce8..76b3080291 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -35,10 +35,7 @@ #include #include #include - -QT_BEGIN_NAMESPACE -class QFormLayout; -QT_END_NAMESPACE +#include namespace ProjectExplorer { @@ -46,6 +43,36 @@ class Project; class ProjectConfigurationAspects; class Target; +class PROJECTEXPLORER_EXPORT LayoutBuilder +{ +public: + explicit LayoutBuilder(QWidget *parent); + ~LayoutBuilder(); + + class LayoutItem + { + public: + LayoutItem(QLayout *layout) : layout(layout) {} + LayoutItem(QWidget *widget) : widget(widget) {} + LayoutItem(const QString &text) : text(text) {} + + QLayout *layout = nullptr; + QWidget *widget = nullptr; + QString text; + }; + + void addItem(LayoutItem item); + void startNewRow(); + + QLayout *layout() const; + +private: + void flushPendingItems(); + + QLayout *m_layout = nullptr; + QList m_pendingItems; +}; + class PROJECTEXPLORER_EXPORT ProjectConfigurationAspect : public QObject { Q_OBJECT @@ -71,9 +98,10 @@ public: virtual void fromMap(const QVariantMap &) {} virtual void toMap(QVariantMap &) const {} - virtual void addToConfigurationLayout(QFormLayout *) {} virtual void acquaintSiblings(const ProjectConfigurationAspects &) {} + virtual void addToLayout(LayoutBuilder &builder); + signals: void changed(); -- cgit v1.2.3