206 lines
4.3 KiB
C++
206 lines
4.3 KiB
C++
#include "structDataPreviewDlg.h"
|
|
#include "ui_structDataPreviewDlg.h"
|
|
#include <QStandardItemModel>
|
|
#include <QMenuBar>
|
|
#include "titleBar.h"
|
|
#include "instance/extraPropertyManager.h"
|
|
|
|
StructDataPreviewDlg::StructDataPreviewDlg(QWidget *parent)
|
|
: QDialog(parent)
|
|
, ui(new Ui::structDataPreviewDlg)
|
|
,_pExtraProManager(nullptr)
|
|
{
|
|
ui->setupUi(this);
|
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
|
initial();
|
|
}
|
|
|
|
StructDataPreviewDlg::~StructDataPreviewDlg()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void StructDataPreviewDlg::initial()
|
|
{
|
|
// 创建标题栏
|
|
m_titleBar = new TitleBar(this);
|
|
m_titleBar->setTitle("结构数据展示");
|
|
ui->mainLayout->insertWidget(0,m_titleBar);
|
|
|
|
QMenuBar *menuBar = new QMenuBar(this);
|
|
QMenu *fileMenu = menuBar->addMenu("文件");
|
|
QAction *saveAction = fileMenu->addAction("保存");
|
|
menuBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
menuBar->setFixedHeight(33);
|
|
|
|
QString style = R"(
|
|
QMenuBar {
|
|
background: #f1f5f9;
|
|
border-bottom: 1px solid #cbd5e1;
|
|
color: #334155;
|
|
font-weight: 500;
|
|
padding: 2px 0;
|
|
}
|
|
|
|
QMenuBar::item {
|
|
padding: 6px 12px;
|
|
border-radius: 3px;
|
|
margin: 0 1px;
|
|
}
|
|
|
|
QMenuBar::item:hover {
|
|
background: #e2e8f0;
|
|
border: 1px solid #cbd5e1;
|
|
}
|
|
|
|
QMenuBar::item:pressed {
|
|
background: #cbd5e0;
|
|
}
|
|
|
|
QMenu {
|
|
background: #ffffff;
|
|
border: 1px solid #cbd5e1;
|
|
border-radius: 4px;
|
|
color: #475569;
|
|
padding: 4px 0;
|
|
}
|
|
|
|
QMenu::item {
|
|
padding: 2px 20px 2px 6px;
|
|
margin: 1px 2px;
|
|
min-height: 20px;
|
|
}
|
|
|
|
QMenu::item:selected {
|
|
background: #3b82f6;
|
|
color: white;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
QMenu::separator {
|
|
height: 1px;
|
|
background: #e2e8f0;
|
|
margin: 3px 8px;
|
|
}
|
|
)";
|
|
|
|
setStyleSheet(style);
|
|
|
|
ui->mainLayout->insertWidget(1,menuBar);
|
|
ui->mainLayout->setStretchFactor(menuBar, 0);
|
|
ui->splitter_2->setStretchFactor(0,1);
|
|
ui->splitter_2->setStretchFactor(1,4);
|
|
|
|
ui->splitter->setStretchFactor(0,5);
|
|
ui->splitter->setStretchFactor(1,1);
|
|
|
|
connect(saveAction,&QAction::triggered,this,&StructDataPreviewDlg::onSaveClicked);
|
|
|
|
connect(m_titleBar, &TitleBar::maximizeClicked, this, &StructDataPreviewDlg::toggleMaximize);
|
|
connect(m_titleBar, &TitleBar::closeClicked, this, &StructDataPreviewDlg::onExitClicked);
|
|
}
|
|
|
|
|
|
void StructDataPreviewDlg::clearItems()
|
|
{
|
|
if(_treeModel){
|
|
QStandardItem *root = _treeModel->invisibleRootItem(); //先清空model
|
|
int rowCount = root->rowCount();
|
|
if (rowCount > 0) {
|
|
_treeModel->removeRows(0, rowCount);
|
|
}
|
|
}
|
|
}
|
|
|
|
void StructDataPreviewDlg::onExitClicked()
|
|
{
|
|
hide();
|
|
}
|
|
|
|
void StructDataPreviewDlg::onSaveClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::onGridClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::onZoneClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::onStationClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::onBayClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::onDeviceClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::onPropertyClicked()
|
|
{
|
|
|
|
}
|
|
|
|
void StructDataPreviewDlg::showEvent(QShowEvent *event)
|
|
{
|
|
QDialog::showEvent(event);
|
|
if (m_titleBar) {
|
|
m_titleBar->updateMaximizeButton();
|
|
}
|
|
}
|
|
|
|
void StructDataPreviewDlg::showMaximized()
|
|
{
|
|
if (!isMaximized()) {
|
|
m_normalGeometry = geometry(); // 保存当前位置和大小
|
|
}
|
|
|
|
QDialog::showMaximized();
|
|
}
|
|
|
|
void StructDataPreviewDlg::showNormal()
|
|
{
|
|
QDialog::showNormal();
|
|
}
|
|
|
|
void StructDataPreviewDlg::showDlg()
|
|
{
|
|
if(_pExtraProManager)
|
|
{
|
|
QMap<QString, ExtraProperty> mapPro = _pExtraProManager->geAlltProperty();
|
|
}
|
|
}
|
|
|
|
void StructDataPreviewDlg::resizeEvent(QResizeEvent *event)
|
|
{
|
|
QDialog::resizeEvent(event);
|
|
if (m_titleBar) {
|
|
m_titleBar->updateMaximizeButton();
|
|
}
|
|
}
|
|
|
|
void StructDataPreviewDlg::toggleMaximize()
|
|
{
|
|
if (isMaximized()) {
|
|
showNormal();
|
|
} else {
|
|
showMaximized();
|
|
}
|
|
|
|
// 更新标题栏按钮
|
|
if (m_titleBar) {
|
|
m_titleBar->updateMaximizeButton();
|
|
}
|
|
}
|