DiagramDesigner/diagramCavas/source/monitorSelectedItemsDlg.cpp

61 lines
1.6 KiB
C++
Raw Normal View History

2025-11-21 19:22:41 +08:00
#include "monitorSelectedItemsDlg.h"
#include "monitorSideBarDlg.h"
#include "monitorPanel.h"
2025-11-26 20:33:13 +08:00
#include <QLabel>
2025-11-21 19:22:41 +08:00
MonitorSelectedItemsDlg::MonitorSelectedItemsDlg(QWidget* parent)
: QDialog(parent)
,_treeView(nullptr)
,_parent(nullptr)
2025-11-25 20:29:32 +08:00
,_pLayout(nullptr)
2025-11-21 19:22:41 +08:00
{
_parent = dynamic_cast<MonitorSideBarDlg*>(parent);
initial();
}
MonitorSelectedItemsDlg::~MonitorSelectedItemsDlg()
{
}
void MonitorSelectedItemsDlg::initial()
{
_treeView = new QTreeView(this);
_treeView->setModel(_parent->getParent()->getLstModel());
_treeView->setHeaderHidden(true);
2025-11-25 20:29:32 +08:00
2025-11-26 20:33:13 +08:00
// 创建标题栏
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);
2025-11-25 20:29:32 +08:00
_pLayout = new QVBoxLayout(this);
2025-11-26 20:33:13 +08:00
_pLayout->addWidget(titleBar);
2025-11-25 20:29:32 +08:00
_pLayout->addWidget(_treeView);
connect(_treeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &MonitorSelectedItemsDlg::onSelectionChanged);
2025-11-21 19:22:41 +08:00
}
void MonitorSelectedItemsDlg::updateItems()
{
_treeView->expandAll();
}
2025-11-25 20:29:32 +08:00
void MonitorSelectedItemsDlg::onSelectionChanged(const QModelIndex &current, const QModelIndex &previous)
{
if(current.isValid()){
QUuid uid = current.data(Qt::UserRole+3).toUuid();
_parent->getParent()->getModelController()->monitorItemSelected(uid);
}
}