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 <eike.ziller@qt.io>
This commit is contained in:
hjk
2020-09-24 14:43:44 +02:00
parent 9dcbb8ca01
commit 5154e1eb02
2 changed files with 9 additions and 7 deletions

View File

@@ -31,6 +31,7 @@
#include <QFormLayout>
#include <QGridLayout>
#include <QLabel>
#include <QWidget>
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
@@ -235,10 +241,7 @@ void LayoutBuilder::flushPendingFormItems()
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);
QTC_CHECK(false);
}
} else {
QTC_CHECK(false);

View File

@@ -62,7 +62,6 @@ public:
QLayout *layout = nullptr;
QWidget *widget = nullptr;
BaseAspect *aspect = nullptr;
QString text;
int span = 1;
Qt::Alignment align;
};