Erste lauffähige Version

This commit is contained in:
2026-06-08 23:31:24 +02:00
commit cc102c93eb
20 changed files with 1827 additions and 0 deletions

58
src/tagwidget.cpp Normal file
View File

@@ -0,0 +1,58 @@
#include "tagwidget.h"
TagWidget::TagWidget(QWidget *parent)
: QWidget(parent)
{
auto *outerLayout = new QVBoxLayout(this);
outerLayout->setContentsMargins(4, 4, 4, 4);
outerLayout->setSpacing(4);
// Header row
auto *headerLayout = new QHBoxLayout();
auto *titleLabel = new QLabel(tr("<b>Tag Monitor</b>"), this);
auto *clearBtn = new QPushButton(tr("Clear all"), this);
clearBtn->setMaximumWidth(80);
connect(clearBtn, &QPushButton::clicked, this, &TagWidget::clearAll);
headerLayout->addWidget(titleLabel);
headerLayout->addStretch();
headerLayout->addWidget(clearBtn);
outerLayout->addLayout(headerLayout);
// Scrollable panel area
auto *scrollArea = new QScrollArea(this);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
auto *container = new QWidget(scrollArea);
m_panelLayout = new QVBoxLayout(container);
m_panelLayout->setContentsMargins(0, 0, 0, 0);
m_panelLayout->setSpacing(6);
m_panelLayout->addStretch(); // pushes panels to the top
scrollArea->setWidget(container);
outerLayout->addWidget(scrollArea, 1);
}
void TagWidget::handleTag(const QString &tag, const QString &value)
{
if (!m_panels.contains(tag)) {
auto *panel = new TagPanel(tag, this);
m_panels.insert(tag, panel);
// Insert before the stretch at the end
m_panelLayout->insertWidget(m_panelLayout->count() - 1, panel);
}
m_panels[tag]->update(value);
}
void TagWidget::clearAll()
{
for (auto *p : m_panels)
p->deleteLater();
m_panels.clear();
}
void TagWidget::removeTag(const QString &tag)
{
if (auto *p = m_panels.take(tag)) {
m_panelLayout->removeWidget(p);
p->deleteLater();
}
}