- Tag-Filter wird gespeichert - Tag Monitor kann bei einem Tag jetzt pro Key mehrere Werte in einer Tabelle anzeigen - Bug für Clear behoben
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
#include "tagwidget.h"
|
|
|
|
TagWidget::TagWidget(QWidget *parent)
|
|
: QWidget(parent)
|
|
{
|
|
auto *outerLayout = new QVBoxLayout(this);
|
|
outerLayout->setContentsMargins(4, 4, 4, 4);
|
|
outerLayout->setSpacing(4);
|
|
|
|
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);
|
|
|
|
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();
|
|
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);
|
|
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();
|
|
}
|
|
}
|