Files
hfut-bishe/client/gui/props/BlackholePropertySection.cpp
T
2026-05-14 13:30:06 +08:00

48 lines
1.4 KiB
C++

#include "props/BlackholePropertySection.h"
#include "widgets/PropertyPanelControls.h"
#include <QFormLayout>
#include <QLabel>
#include <QVBoxLayout>
namespace gui {
BlackholePropertySection::BlackholePropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
polishPropertyFormLayout(form);
m_name = new QLabel(this);
m_status = new QLabel(this);
m_method = new QLabel(this);
for (QLabel* lab : {m_name, m_status, m_method}) {
lab->setWordWrap(true);
}
form->addRow(QStringLiteral("黑洞"), m_name);
form->addRow(QStringLiteral("是否解决"), m_status);
form->addRow(QStringLiteral("解决方案"), m_method);
lay->addLayout(form);
lay->addStretch(1);
}
void BlackholePropertySection::clearDisconnected() {
if (m_name) m_name->setText(QStringLiteral("-"));
if (m_status) m_status->setText(QStringLiteral("-"));
if (m_method) m_method->setText(QStringLiteral("-"));
}
void BlackholePropertySection::applyState(const BlackholePropertyUiState& s) {
if (m_name) m_name->setText(s.blackholeName.isEmpty() ? QStringLiteral("-") : s.blackholeName);
if (m_status) m_status->setText(s.statusText.isEmpty() ? QStringLiteral("-") : s.statusText);
if (m_method) m_method->setText(s.methodText.isEmpty() ? QStringLiteral("-") : s.methodText);
}
} // namespace gui