DiagramDesigner/diagramCavas/source/monitorSelectedItemsDlg.cpp

45 lines
1.1 KiB
C++

#include "monitorSelectedItemsDlg.h"
#include "monitorSideBarDlg.h"
#include "monitorPanel.h"
#include "global.h"
MonitorSelectedItemsDlg::MonitorSelectedItemsDlg(QWidget* parent)
: QDialog(parent)
,_treeView(nullptr)
,_parent(nullptr)
,_pLayout(nullptr)
{
_parent = dynamic_cast<MonitorSideBarDlg*>(parent);
initial();
}
MonitorSelectedItemsDlg::~MonitorSelectedItemsDlg()
{
}
void MonitorSelectedItemsDlg::initial()
{
_treeView = new QTreeView(this);
_treeView->setModel(_parent->getParent()->getLstModel());
_treeView->setHeaderHidden(true);
_pLayout = new QVBoxLayout(this);
_pLayout->addWidget(_treeView);
connect(_treeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &MonitorSelectedItemsDlg::onSelectionChanged);
}
void MonitorSelectedItemsDlg::updateItems()
{
_treeView->expandAll();
}
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);
}
}