#include "monitorSelectedItemsDlg.h" #include "monitorSideBarDlg.h" #include "monitorPanel.h" #include MonitorSelectedItemsDlg::MonitorSelectedItemsDlg(QWidget* parent) : QDialog(parent) ,_treeView(nullptr) ,_parent(nullptr) ,_pLayout(nullptr) { _parent = dynamic_cast(parent); initial(); } MonitorSelectedItemsDlg::~MonitorSelectedItemsDlg() { } void MonitorSelectedItemsDlg::initial() { _treeView = new QTreeView(this); _treeView->setModel(_parent->getParent()->getLstModel()); _treeView->setHeaderHidden(true); // 创建标题栏 QWidget *titleBar = new QWidget(this); titleBar->setFixedHeight(21); titleBar->setStyleSheet("background-color: #2b579a; color: white;"); // 标题栏布局 QHBoxLayout *titleLayout = new QHBoxLayout(titleBar); titleLayout->setContentsMargins(10, 0, 5, 0); // 标题标签 QLabel *titleLabel = new QLabel("图元列表"); titleLabel->setStyleSheet("color: white; font-weight: bold;"); titleLayout->addWidget(titleLabel); _pLayout = new QVBoxLayout(this); _pLayout->addWidget(titleBar); _pLayout->addWidget(_treeView); connect(_treeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &MonitorSelectedItemsDlg::onSelectionChanged); } void MonitorSelectedItemsDlg::updateItems() { _treeView->expandAll(); } void MonitorSelectedItemsDlg::onSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous) { if(current.isValid()){ QUuid uid = current.data(Qt::UserRole+3).toUuid(); _parent->getParent()->getModelController()->monitorItemSelected(uid); } }