From 5154e1eb023ca73fe4ac24025bc6bcadd931c9f1 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 24 Sep 2020 14:43:44 +0200 Subject: [PATCH] Utils: Remove the text option for LayoutItem This is converted to QLabels on the Qt side anyway, so we can can just do that and avoid the special casing later for form layouts later and gain the functionality for grids. Use the opportunity to make the all mouse-selectable. Change-Id: I37830b028b8d2987ea4925f364c79e905be725c8 Reviewed-by: Eike Ziller --- src/libs/utils/layoutbuilder.cpp | 15 +++++++++------ src/libs/utils/layoutbuilder.h | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/layoutbuilder.cpp b/src/libs/utils/layoutbuilder.cpp index bc4e4c59f70..34f00bec5b8 100644 --- a/src/libs/utils/layoutbuilder.cpp +++ b/src/libs/utils/layoutbuilder.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace Utils { @@ -96,7 +97,12 @@ LayoutBuilder::LayoutItem::LayoutItem(BaseAspect *aspect) /*! Constructs a layout item containing some static \a text. */ -LayoutBuilder::LayoutItem::LayoutItem(const QString &text) : text(text) {} +LayoutBuilder::LayoutItem::LayoutItem(const QString &text) +{ + auto label = new QLabel(text); + label->setTextInteractionFlags(Qt::TextBrowserInteraction); + widget = label; +} /*! \class Utils::LayoutBuilder @@ -234,11 +240,8 @@ void LayoutBuilder::flushPendingFormItems() m_formLayout->addRow(label, layout); else if (auto widget = m_pendingFormItems.at(1).widget) m_formLayout->addRow(label, widget); - } else { - if (auto layout = m_pendingFormItems.at(1).layout) - m_formLayout->addRow(m_pendingFormItems.at(0).text, layout); - else if (auto widget = m_pendingFormItems.at(1).widget) - m_formLayout->addRow(m_pendingFormItems.at(0).text, widget); + } else { + QTC_CHECK(false); } } else { QTC_CHECK(false); diff --git a/src/libs/utils/layoutbuilder.h b/src/libs/utils/layoutbuilder.h index ddf60185181..567f6d373fc 100644 --- a/src/libs/utils/layoutbuilder.h +++ b/src/libs/utils/layoutbuilder.h @@ -62,7 +62,6 @@ public: QLayout *layout = nullptr; QWidget *widget = nullptr; BaseAspect *aspect = nullptr; - QString text; int span = 1; Qt::Alignment align; };