Files
IfcOpenShell/src/interface/components/KeyValueTable.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
3.3 KiB
C++
Raw Normal View History

2026-05-06 10:47:03 +10:00
// This file was generated with the assistance of an AI coding tool.
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#include "KeyValueTable.h"
#include "SvgIcon.h"
2026-05-06 13:13:37 +10:00
#include <QGridLayout>
2026-05-06 10:47:03 +10:00
#include <QLabel>
namespace ifcinterface::components {
KeyValueTable::KeyValueTable(const QList<KeyValueTableRow>& rows, QWidget* parent)
: QWidget(parent)
{
2026-05-06 12:36:28 +10:00
setObjectName("keyValueTable");
2026-05-06 10:47:03 +10:00
2026-05-06 13:13:37 +10:00
auto* layout = new QGridLayout(this);
2026-05-06 10:47:03 +10:00
layout->setContentsMargins(0, 0, 0, 0);
2026-05-06 13:13:37 +10:00
layout->setHorizontalSpacing(12);
layout->setVerticalSpacing(6);
layout->setColumnStretch(1, 1);
2026-05-06 10:47:03 +10:00
2026-05-06 13:13:37 +10:00
int row_index = 0;
2026-05-06 10:47:03 +10:00
for (const auto& row_data : rows) {
2026-05-06 13:13:37 +10:00
auto* key = new QLabel(row_data.key, this);
key->setProperty("textRole", "secondary");
2026-05-06 10:47:03 +10:00
if (row_data.key_minimum_width > 0) {
key->setMinimumWidth(row_data.key_minimum_width);
}
2026-05-06 13:13:37 +10:00
auto* value = new QLabel(row_data.value, this);
2026-05-06 10:47:03 +10:00
value->setObjectName(row_data.value_object_name.isEmpty()
2026-05-06 12:36:28 +10:00
? "keyValueValueLabel"
2026-05-06 10:47:03 +10:00
: row_data.value_object_name);
value->setWordWrap(true);
value->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
2026-05-06 13:13:37 +10:00
layout->addWidget(key, row_index, 0, Qt::AlignLeft | Qt::AlignTop);
layout->addWidget(value, row_index, 1);
2026-05-06 10:47:03 +10:00
if (!row_data.trailing_icon_path.isEmpty()) {
2026-05-06 13:13:37 +10:00
auto* icon = new QLabel(this);
2026-05-06 10:47:03 +10:00
icon->setObjectName(row_data.trailing_icon_object_name.isEmpty()
2026-05-06 13:13:37 +10:00
? "keyValueTrailingIconLabel"
2026-05-06 10:47:03 +10:00
: row_data.trailing_icon_object_name);
icon->setPixmap(icons::makePanelSvgPixmap(row_data.trailing_icon_path, QSize(14, 14)));
icon->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
2026-05-06 13:13:37 +10:00
layout->addWidget(icon, row_index, 2, Qt::AlignRight | Qt::AlignTop);
2026-05-06 10:47:03 +10:00
}
2026-05-06 13:13:37 +10:00
++row_index;
2026-05-06 10:47:03 +10:00
}
}
} // namespace ifcinterface::components