2024-11-05 15:17:03 +08:00
|
|
|
|
#include "dashboardFrame.h"
|
|
|
|
|
|
#include "./ui_dashboardFrame.h"
|
2024-11-14 09:19:14 +08:00
|
|
|
|
#include "dvieMainWindow.h"
|
|
|
|
|
|
#include "dvieSecondaryWindow.h"
|
2024-11-05 15:17:03 +08:00
|
|
|
|
#include "transparentMask.h"
|
|
|
|
|
|
#include "messageDialog.h"
|
|
|
|
|
|
#include "customTabBar.h"
|
|
|
|
|
|
#include "dashboard.h"
|
|
|
|
|
|
#include "customTab.h"
|
|
|
|
|
|
#include "dashboardNamingDialog.h"
|
|
|
|
|
|
#include "panelSelectionDialog.h"
|
|
|
|
|
|
#include "dateTimeWidget.h"
|
2024-12-06 16:58:07 +08:00
|
|
|
|
#include "util/TimeLine/timeLineWidget.h"
|
2024-11-05 15:17:03 +08:00
|
|
|
|
|
|
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
|
#include <QMenu>
|
2024-12-13 16:41:08 +08:00
|
|
|
|
#include <QTimer>
|
2024-11-05 15:17:03 +08:00
|
|
|
|
#include <QDateTime>
|
2024-11-07 12:08:56 +08:00
|
|
|
|
#include <QMimeData>
|
2024-11-05 15:17:03 +08:00
|
|
|
|
|
2024-11-14 09:19:14 +08:00
|
|
|
|
DashboardFrame::DashboardFrame(const QString& strName, dashboardFrame::frameType fType, QWidget *parent)
|
2024-11-05 15:17:03 +08:00
|
|
|
|
: QWidget(parent)
|
|
|
|
|
|
, ui(new Ui::dashboardFrame)
|
|
|
|
|
|
, m_pParentWindow(nullptr)
|
|
|
|
|
|
, m_pTransparentMask(nullptr)
|
2024-11-14 12:11:49 +08:00
|
|
|
|
, m_pDashboardHighlight(nullptr)
|
2024-11-05 15:17:03 +08:00
|
|
|
|
, m_pMessageDialog(nullptr)
|
|
|
|
|
|
, m_pDashboardTabBar(nullptr)
|
|
|
|
|
|
, m_pDashboardNamingDialog(nullptr)
|
|
|
|
|
|
, m_curActiveDashboard(nullptr)
|
|
|
|
|
|
, m_curOperationDashboard(nullptr)
|
|
|
|
|
|
, m_pPanelSelectionDialog(nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
2024-11-07 12:08:56 +08:00
|
|
|
|
setAcceptDrops(true);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
|
2024-11-07 12:08:56 +08:00
|
|
|
|
m_strName = strName;
|
2024-11-14 09:19:14 +08:00
|
|
|
|
setObjectName(strName);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
m_pParentWindow = parent;
|
2024-11-14 09:19:14 +08:00
|
|
|
|
m_type = fType;
|
|
|
|
|
|
if(m_type == dashboardFrame::ft_secondary) //只有主window具有报警提示
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->btnEventNotication->setVisible(false);
|
|
|
|
|
|
ui->btnAlarmNoticatio->setVisible(false);
|
|
|
|
|
|
}
|
2024-11-05 15:17:03 +08:00
|
|
|
|
|
2024-12-17 16:48:46 +08:00
|
|
|
|
initializeGlobalVariable();
|
|
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
m_pDateTimeWidget = new DateTimeWidget(this);
|
2024-12-13 16:41:08 +08:00
|
|
|
|
m_pDateTimeWidget->setObjectName("dateTimeWidget");
|
2024-11-05 15:17:03 +08:00
|
|
|
|
ui->layout_dateTime->addWidget(m_pDateTimeWidget);
|
|
|
|
|
|
connect(m_pDateTimeWidget, SIGNAL(showMask()), this, SLOT(onSignal_showMask()));
|
|
|
|
|
|
connect(m_pDateTimeWidget, SIGNAL(hideMask()), this, SLOT(onSignal_hideMask()));
|
2024-12-17 16:48:46 +08:00
|
|
|
|
connect(m_pDateTimeWidget, SIGNAL(viewRealTimeData()), this, SLOT(onSignal_viewRealTimeData()));
|
2024-11-05 15:17:03 +08:00
|
|
|
|
connect(m_pDateTimeWidget, SIGNAL(viewHistoricalData(QDateTime)), this, SLOT(onSignal_viewHistoricalData(QDateTime)));
|
2024-12-17 16:48:46 +08:00
|
|
|
|
connect(m_pDateTimeWidget, SIGNAL(timeRangeChanged(TimeUnit)), this, SLOT(onSignal_timeRangeChanged(TimeUnit)));
|
2024-11-05 15:17:03 +08:00
|
|
|
|
|
|
|
|
|
|
m_pDashboardTabBar = new CustomTabBar(this);
|
2024-11-14 09:19:14 +08:00
|
|
|
|
m_pDashboardTabBar->setFrame(this);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
ui->hLayout_dashboardTabBar->addWidget(m_pDashboardTabBar);
|
|
|
|
|
|
connect(m_pDashboardTabBar, SIGNAL(tabMoved(int, int)), this, SLOT(onSignal_dashboardTabMoved(int, int)));
|
|
|
|
|
|
|
2024-12-06 16:58:07 +08:00
|
|
|
|
m_pTimeLineWidget = new TimeLineWidget(this);
|
2024-12-13 16:41:08 +08:00
|
|
|
|
m_pTimeLineWidget->setObjectName("timeLineWidget");
|
2024-12-06 16:58:07 +08:00
|
|
|
|
m_pTimeLineWidget->setBackground(QColor(24, 32, 38));
|
|
|
|
|
|
m_pTimeLineWidget->setTimelineColor(QColor(250, 250, 250));
|
|
|
|
|
|
m_pTimeLineWidget->setTimeScaleSize(200);
|
|
|
|
|
|
ui->layout_timeLine->addWidget(m_pTimeLineWidget);
|
2024-12-17 16:48:46 +08:00
|
|
|
|
connect(m_pTimeLineWidget, SIGNAL(viewHistoricalData(QDateTime)), this, SLOT(onSignal_viewHistoricalData(QDateTime)));
|
|
|
|
|
|
connect(m_pTimeLineWidget, SIGNAL(timeScaleUnitChanged(TimeUnit)), this, SLOT(onSignal_timeRangeChanged(TimeUnit)));
|
|
|
|
|
|
m_pTimeLineWidget->syncTimeUnit();
|
2024-12-06 16:58:07 +08:00
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
connect(ui->btnAddDashboard, SIGNAL(clicked()), this, SLOT(onBtnClicked_addDashboard()));
|
|
|
|
|
|
connect(ui->btnAddPanel, SIGNAL(clicked()), this, SLOT(onBtnClicked_addDataPanel()));
|
|
|
|
|
|
//connect(ui->btnDashboradList1, SIGNAL(clicked()), this, SLOT(onBtnClicked_dashboardList()));
|
|
|
|
|
|
connect(ui->btnDashboradList2, SIGNAL(clicked()), this, SLOT(onBtnClicked_dashboardList()));
|
2024-12-13 16:41:08 +08:00
|
|
|
|
|
|
|
|
|
|
m_pTimer_RealTime = new QTimer(this);
|
|
|
|
|
|
connect(m_pTimer_RealTime, SIGNAL(timeout()), this, SLOT(onTimeout_realTime()));
|
|
|
|
|
|
m_pTimer_RealTime->start(1000);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DashboardFrame::~DashboardFrame()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
2024-12-17 16:48:46 +08:00
|
|
|
|
|
|
|
|
|
|
if(m_pTimer_RealTime->isActive())
|
|
|
|
|
|
m_pTimer_RealTime->stop();
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DashboardFrame::eventFilter(QObject* obj, QEvent* event)
|
|
|
|
|
|
{
|
|
|
|
|
|
QDialog *pDialog = qobject_cast<QDialog*>(obj);
|
|
|
|
|
|
if(pDialog)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(event->type() == QEvent::KeyPress)
|
|
|
|
|
|
{
|
|
|
|
|
|
QKeyEvent* pKeyEvent = static_cast<QKeyEvent*>(event);
|
|
|
|
|
|
if (pKeyEvent->key() == Qt::Key_Escape)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return QObject::eventFilter(obj, event);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-20 17:29:29 +08:00
|
|
|
|
void DashboardFrame::resizeEvent(QResizeEvent* event)
|
|
|
|
|
|
{
|
2024-11-21 17:29:37 +08:00
|
|
|
|
//qDebug() << "oldSize:" << event->oldSize() << " size:" << event->size();
|
|
|
|
|
|
if(event->oldSize() != QSize(-1, -1)) //Qt默认的初始化创建过程中会有从QSize(-1, -1)的变化,需要忽略
|
2024-11-20 17:29:29 +08:00
|
|
|
|
{
|
2024-11-21 17:29:37 +08:00
|
|
|
|
if(m_pTransparentMask && m_pTransparentMask->isVisible())
|
|
|
|
|
|
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
2024-11-20 17:29:29 +08:00
|
|
|
|
|
2024-11-21 17:29:37 +08:00
|
|
|
|
if(m_pMessageDialog && m_pMessageDialog->isVisible())
|
|
|
|
|
|
{
|
|
|
|
|
|
int nX = (ui->navigationPanel->width() - m_pMessageDialog->width()) * 0.5;
|
|
|
|
|
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
|
|
|
|
|
m_pMessageDialog->move(nX, nY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(m_pDashboardNamingDialog && m_pDashboardNamingDialog->isVisible())
|
|
|
|
|
|
{
|
|
|
|
|
|
int nX = (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
|
|
|
|
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
|
|
|
|
|
m_pDashboardNamingDialog->move(nX, nY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double ratioX = (double)event->size().width() / (double)event->oldSize().width();
|
|
|
|
|
|
double ratioY = (double)event->size().height() / (double)event->oldSize().height();
|
|
|
|
|
|
//qDebug() << ratioX << ", " << ratioY;
|
|
|
|
|
|
if(m_curActiveDashboard)
|
|
|
|
|
|
m_curActiveDashboard->resizePanel(ratioX, ratioY);
|
2024-11-20 17:29:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget::resizeEvent(event);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 12:08:56 +08:00
|
|
|
|
void DashboardFrame::dragEnterEvent(QDragEnterEvent* event)
|
|
|
|
|
|
{
|
|
|
|
|
|
const QMimeData* mimeData = event->mimeData();
|
2024-11-14 09:19:14 +08:00
|
|
|
|
if( mimeData->hasFormat("dragData/customTab") )
|
2024-11-07 12:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
|
event->acceptProposedAction();
|
2024-11-14 12:11:49 +08:00
|
|
|
|
setDashboardAreaHighlight(true);
|
2024-11-07 12:08:56 +08:00
|
|
|
|
//qDebug() << "dragEnterEvent-frame";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
event->ignore();
|
|
|
|
|
|
}
|
|
|
|
|
|
void DashboardFrame::dragLeaveEvent(QDragLeaveEvent* event)
|
|
|
|
|
|
{
|
2024-11-14 12:11:49 +08:00
|
|
|
|
setDashboardAreaHighlight(false);
|
2024-11-07 12:08:56 +08:00
|
|
|
|
//qDebug() << "dragLeaveEvent-frame";
|
|
|
|
|
|
}
|
|
|
|
|
|
void DashboardFrame::dropEvent(QDropEvent* event)
|
|
|
|
|
|
{
|
|
|
|
|
|
//qDebug() << "dropEvent-frame";
|
2024-11-14 12:11:49 +08:00
|
|
|
|
setDashboardAreaHighlight(false);
|
2024-11-07 12:08:56 +08:00
|
|
|
|
event->setDropAction(Qt::MoveAction);
|
|
|
|
|
|
event->accept();
|
|
|
|
|
|
|
2024-11-14 09:19:14 +08:00
|
|
|
|
QByteArray itemData = event->mimeData()->data("dragData/customTab");
|
2024-11-07 12:08:56 +08:00
|
|
|
|
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
|
|
|
|
|
|
QString strTabText = "";
|
2024-11-14 09:19:14 +08:00
|
|
|
|
QString strFromFrame = "";
|
|
|
|
|
|
dataStream >> strTabText >> strFromFrame;
|
2024-11-07 12:08:56 +08:00
|
|
|
|
|
2024-11-14 09:19:14 +08:00
|
|
|
|
if(strFromFrame != this->objectName()) //来自别的frame
|
2024-11-07 12:08:56 +08:00
|
|
|
|
{
|
2024-11-14 09:19:14 +08:00
|
|
|
|
for(int n=0; n<m_listDashboard.count(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_listDashboard.at(n)->name() == strTabText)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strError = QString::fromStdWString(L"已存在同名看板");
|
|
|
|
|
|
showTransparentMask();
|
|
|
|
|
|
showMessageDialog(type_warning, QString::fromWCharArray(L"错误"), strError);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DashboardFrame* fromFrame = getDashboardFrame(strFromFrame);
|
|
|
|
|
|
if(fromFrame != this && fromFrame != nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dashboard* dashboard = fromFrame->takeDashboard(strTabText);
|
|
|
|
|
|
addDashboard(dashboard);
|
|
|
|
|
|
}
|
2024-11-07 12:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
void DashboardFrame::showTransparentMask()
|
|
|
|
|
|
{
|
2024-11-20 16:57:26 +08:00
|
|
|
|
if(m_pParentWindow) //遮罩作为子组件最多只能在自身范围内覆盖,无法覆盖到父组件,因此需要父组件其它部分需要父组件去完成
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_type == dashboardFrame::ft_main)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieMainWindow* dvieWindow = qobject_cast<DvieMainWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
dvieWindow->showTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(m_type == dashboardFrame::ft_secondary)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
dvieWindow->showTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
if(m_pTransparentMask == nullptr)
|
|
|
|
|
|
m_pTransparentMask = new TransparentMask(this);
|
|
|
|
|
|
|
2024-11-20 16:57:26 +08:00
|
|
|
|
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
2024-11-05 15:17:03 +08:00
|
|
|
|
m_pTransparentMask->show();
|
|
|
|
|
|
}
|
|
|
|
|
|
void DashboardFrame::hideTransparentMask()
|
|
|
|
|
|
{
|
2024-11-20 16:57:26 +08:00
|
|
|
|
if(m_type == dashboardFrame::ft_main)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieMainWindow* dvieWindow = qobject_cast<DvieMainWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
dvieWindow->hideTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(m_type == dashboardFrame::ft_secondary)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
dvieWindow->hideTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-20 17:29:29 +08:00
|
|
|
|
if(m_pTransparentMask && m_pTransparentMask->isVisible())
|
2024-11-05 15:17:03 +08:00
|
|
|
|
m_pTransparentMask->hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::showMessageDialog(MessageDialogType type,const QString& strTitle,const QString& strContent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_pMessageDialog == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pMessageDialog = new MessageDialog(this);
|
|
|
|
|
|
m_pMessageDialog->installEventFilter(this);
|
|
|
|
|
|
connect(m_pMessageDialog, SIGNAL(sgl_hide()), this, SLOT(onSignal_subDialogClose()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
2024-11-20 16:57:26 +08:00
|
|
|
|
int nX = (ui->navigationPanel->width() - m_pMessageDialog->width()) * 0.5;
|
|
|
|
|
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
2024-11-20 17:29:29 +08:00
|
|
|
|
m_pMessageDialog->move(nX, nY);
|
2024-11-20 16:57:26 +08:00
|
|
|
|
m_pMessageDialog->raise();
|
2024-11-05 15:17:03 +08:00
|
|
|
|
if(type == type_question)
|
|
|
|
|
|
m_pMessageDialog->exec();
|
|
|
|
|
|
else
|
|
|
|
|
|
m_pMessageDialog->show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::addDashboard(const QString& strName)
|
|
|
|
|
|
{
|
2024-11-07 12:08:56 +08:00
|
|
|
|
Dashboard* dashboard = new Dashboard(strName);
|
|
|
|
|
|
insertDashboard(m_listDashboard.count(), dashboard);
|
|
|
|
|
|
}
|
2024-11-14 09:19:14 +08:00
|
|
|
|
void DashboardFrame::addDashboard(Dashboard* dashboard)
|
|
|
|
|
|
{
|
|
|
|
|
|
insertDashboard(m_listDashboard.count(), dashboard);
|
|
|
|
|
|
}
|
2024-11-07 12:08:56 +08:00
|
|
|
|
void DashboardFrame::insertDashboard(int index, Dashboard* dashboard)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(index < 0)
|
|
|
|
|
|
index = 0;
|
|
|
|
|
|
else if(index > m_listDashboard.count())
|
|
|
|
|
|
index = m_listDashboard.count();
|
|
|
|
|
|
|
|
|
|
|
|
dashboard->setFrame(this);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
connect(dashboard, SIGNAL(sgl_rename()), this, SLOT(onSignal_renameDashboard()));
|
|
|
|
|
|
connect(dashboard, SIGNAL(sgl_remove()), this, SLOT(onSignal_removeDashboard()));
|
|
|
|
|
|
dashboard->setDisplayAreaLayout(ui->hLayout_dashboardDisplayArea);
|
|
|
|
|
|
|
|
|
|
|
|
//添加tab
|
|
|
|
|
|
CustomTab* tab = dashboard->tab();
|
2024-11-07 12:08:56 +08:00
|
|
|
|
m_pDashboardTabBar->insertTab(index, tab);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
connect(tab, SIGNAL(clicked()), this, SLOT(onBtnClicked_dashboardTab()));
|
|
|
|
|
|
|
2024-11-07 12:08:56 +08:00
|
|
|
|
m_listDashboard.insert(index, dashboard);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
if(m_curActiveDashboard)
|
|
|
|
|
|
m_curActiveDashboard->setActive(false);
|
|
|
|
|
|
dashboard->setActive(true);
|
|
|
|
|
|
m_curActiveDashboard = dashboard;
|
|
|
|
|
|
}
|
2024-11-14 09:19:14 +08:00
|
|
|
|
int DashboardFrame::dashboardCount()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_listDashboard.count();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Dashboard* DashboardFrame::getDashboard(const QString& strName)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dashboard* dashboard = nullptr;
|
|
|
|
|
|
for(int n=0; n<m_listDashboard.count(); n++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_listDashboard.at(n)->name() == strName)
|
|
|
|
|
|
{
|
|
|
|
|
|
dashboard = m_listDashboard.at(n);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return dashboard;
|
|
|
|
|
|
}
|
|
|
|
|
|
Dashboard* DashboardFrame::takeDashboard(const QString& strName)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dashboard* dashboard = getDashboard(strName);
|
|
|
|
|
|
dashboard->setParent(nullptr);
|
|
|
|
|
|
if(dashboard)
|
|
|
|
|
|
removeDashboard(strName, false);
|
|
|
|
|
|
return dashboard;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DashboardFrame* DashboardFrame::getDashboardFrame(const QString& strName)
|
|
|
|
|
|
{
|
|
|
|
|
|
DashboardFrame* frame = nullptr;
|
|
|
|
|
|
if(strName == m_strName)
|
|
|
|
|
|
frame = this;
|
|
|
|
|
|
|
|
|
|
|
|
if(m_type == dashboardFrame::ft_main)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieMainWindow* dvieWindow = qobject_cast<DvieMainWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
frame = dvieWindow->getDashboardFrame(strName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(m_type == dashboardFrame::ft_secondary)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
frame = dvieWindow->getDashboardFrame(strName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
|
|
}
|
2024-11-05 15:17:03 +08:00
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::removeDashboard(const QString& strName, bool bDelete) //右键删除和移动到别的frame下均会调用该函数,只有删除时才会delete
|
|
|
|
|
|
{
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
Dashboard* dashboard = nullptr;
|
|
|
|
|
|
for(int n=0; n<m_listDashboard.count(); n++)
|
|
|
|
|
|
{
|
2024-11-14 09:19:14 +08:00
|
|
|
|
if(m_listDashboard.at(n)->name() == strName)
|
2024-11-05 15:17:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
nIndex = n;
|
|
|
|
|
|
dashboard = m_listDashboard.at(n);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if( !dashboard )
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(dashboard == m_curActiveDashboard) //删除的是当前所选
|
|
|
|
|
|
{
|
|
|
|
|
|
dashboard->setActive(false);
|
|
|
|
|
|
if(m_listDashboard.count() == 1) //唯一一个
|
|
|
|
|
|
m_curActiveDashboard = nullptr;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if(nIndex != 0) //不是第一个,将其前一个置为选中状态
|
|
|
|
|
|
{
|
|
|
|
|
|
m_listDashboard.at(nIndex - 1)->setActive(true);
|
|
|
|
|
|
m_curActiveDashboard = m_listDashboard.at(nIndex - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else //是第一个,将下一个置为选中状态
|
|
|
|
|
|
{
|
|
|
|
|
|
m_listDashboard.at(nIndex + 1)->setActive(true);
|
|
|
|
|
|
m_curActiveDashboard = m_listDashboard.at(nIndex + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CustomTab* tab = dashboard->tab();
|
|
|
|
|
|
if(tab)
|
|
|
|
|
|
m_pDashboardTabBar->removeTab(tab);
|
|
|
|
|
|
m_listDashboard.removeAt(nIndex);
|
|
|
|
|
|
if(bDelete)
|
|
|
|
|
|
{
|
|
|
|
|
|
dashboard->deleteSubWidgets();
|
|
|
|
|
|
delete dashboard;
|
|
|
|
|
|
}
|
2024-11-07 12:08:56 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dashboard->disconnect(this); //断开和当前frame的信号/槽链接
|
|
|
|
|
|
}
|
2024-11-14 09:19:14 +08:00
|
|
|
|
|
|
|
|
|
|
if(m_type == dashboardFrame::ft_secondary && m_listDashboard.count() == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
dvieWindow->close();
|
|
|
|
|
|
}
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::setCurrentDashboard(const QString& strName)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(int n=0; n<m_listDashboard.count(); n++)
|
|
|
|
|
|
{
|
2024-11-14 09:19:14 +08:00
|
|
|
|
if(m_listDashboard.at(n)->name() == strName)
|
2024-11-05 15:17:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
if(m_listDashboard.at(n) == m_curActiveDashboard)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_curActiveDashboard->setActive(false);
|
|
|
|
|
|
m_listDashboard.at(n)->setActive(true);
|
|
|
|
|
|
CustomTab* tab = m_listDashboard.at(n)->tab();
|
|
|
|
|
|
m_pDashboardTabBar->ensureWidgetVisible(tab);
|
|
|
|
|
|
m_curActiveDashboard = m_listDashboard.at(n);
|
2024-11-21 17:29:37 +08:00
|
|
|
|
return;
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-14 12:11:49 +08:00
|
|
|
|
void DashboardFrame::setDashboardAreaHighlight(bool bVisible)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_pDashboardHighlight == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pDashboardHighlight = new QWidget(this);
|
|
|
|
|
|
m_pDashboardHighlight->setStyleSheet("background-color: rgba(0, 141, 212, 85);");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(bVisible)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pDashboardHighlight->setGeometry(ui->mainStack->geometry());
|
|
|
|
|
|
m_pDashboardHighlight->show();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
m_pDashboardHighlight->hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-14 09:19:14 +08:00
|
|
|
|
void DashboardFrame::moveDashboardToNewDVIEWindow(const QString& strDashboard, QPoint pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dashboard* dashboard = takeDashboard(strDashboard);
|
|
|
|
|
|
if(dashboard)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_type == dashboardFrame::ft_main)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieMainWindow* dvieWindow = qobject_cast<DvieMainWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
dvieWindow->creatSecondaryWindowAndAddDashboard(pos, dashboard);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(m_type == dashboardFrame::ft_secondary)
|
|
|
|
|
|
{
|
|
|
|
|
|
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
|
|
|
|
|
if(dvieWindow)
|
|
|
|
|
|
{
|
|
|
|
|
|
dvieWindow->creatSecondaryWindowAndAddDashboard(pos, dashboard);
|
|
|
|
|
|
// if(m_listDashboard.count() == 0)
|
|
|
|
|
|
// dvieWindow->close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
void DashboardFrame::onSignal_showMask()
|
|
|
|
|
|
{
|
|
|
|
|
|
showTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
void DashboardFrame::onSignal_hideMask()
|
|
|
|
|
|
{
|
|
|
|
|
|
hideTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onBtnClicked_addDashboard()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_pDashboardNamingDialog == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pDashboardNamingDialog = new DashboardNamingDialog(this);
|
|
|
|
|
|
m_pDashboardNamingDialog->installEventFilter(this);
|
|
|
|
|
|
connect(m_pDashboardNamingDialog, SIGNAL(sgl_hide()), this, SLOT(onSignal_subDialogClose()));
|
|
|
|
|
|
connect(m_pDashboardNamingDialog, SIGNAL(dashboardName(const QString&, const QString&)), this, SLOT(onSignal_dashboardNaming(const QString&, const QString&)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showTransparentMask();
|
2024-11-20 16:57:26 +08:00
|
|
|
|
int nX = (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
|
|
|
|
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
2024-11-20 17:29:29 +08:00
|
|
|
|
m_pDashboardNamingDialog->move(nX, nY);
|
2024-11-05 15:17:03 +08:00
|
|
|
|
m_pDashboardNamingDialog->showUsedForCreat();
|
2024-11-20 16:57:26 +08:00
|
|
|
|
m_pDashboardNamingDialog->raise();
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onBtnClicked_addDataPanel()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_listDashboard.count() == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
showTransparentMask();
|
|
|
|
|
|
showMessageDialog(type_warning, QString::fromWCharArray(L"错误"), QString::fromWCharArray(L"只能在数据看板内创建展项,请先创建一个数据看板"));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(m_pPanelSelectionDialog == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pPanelSelectionDialog = new PanelSelectionDialog(this);
|
|
|
|
|
|
m_pPanelSelectionDialog->installEventFilter(this);
|
|
|
|
|
|
connect(m_pPanelSelectionDialog, SIGNAL(sgl_hide()), this, SLOT(onSignal_subDialogClose()));
|
|
|
|
|
|
connect(m_pPanelSelectionDialog, SIGNAL(panelType(const QString&)), this, SLOT(onSignal_panelSelectResult(const QString&)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showTransparentMask();
|
|
|
|
|
|
QPoint originPoint = ui->navigationPanel->mapToGlobal(QPoint(0, 0));
|
|
|
|
|
|
int nX = originPoint.x() + (ui->navigationPanel->width() - m_pPanelSelectionDialog->width()) * 0.5;
|
|
|
|
|
|
int nY = originPoint.y() + ui->navigationPanel->height() * 0.5;
|
|
|
|
|
|
m_pPanelSelectionDialog->setGeometry(nX, nY, m_pPanelSelectionDialog->width(), m_pPanelSelectionDialog->height());
|
|
|
|
|
|
m_pPanelSelectionDialog->show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onBtnClicked_dashboardList()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_listDashboard.count() ==0 )
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
|
|
menu.setStyleSheet("QMenu{\n"
|
|
|
|
|
|
" background-color:rgb(36,43,50);\n"
|
|
|
|
|
|
" border:1px solid rgb(6, 6, 6);\n"
|
|
|
|
|
|
"}\n"
|
|
|
|
|
|
"QMenu:scroller{\n"
|
|
|
|
|
|
" show-arrows:true;\n"
|
|
|
|
|
|
"}\n"
|
|
|
|
|
|
"QMenu:item{\n"
|
|
|
|
|
|
" padding-left:15px;\n"
|
|
|
|
|
|
" padding-right:15px;\n"
|
|
|
|
|
|
" font:9pt \"微软雅黑\";\n"
|
|
|
|
|
|
" color:rgb(220,220,220);\n"
|
|
|
|
|
|
" height:26px;\n"
|
|
|
|
|
|
"}\n"
|
|
|
|
|
|
"QMenu:item:selected{\n"
|
|
|
|
|
|
" background-color: rgba(67,160,249, 80);\n"
|
|
|
|
|
|
"}\n");
|
|
|
|
|
|
for(int n=0; n<m_listDashboard.count(); n++)
|
|
|
|
|
|
{
|
2024-11-14 09:19:14 +08:00
|
|
|
|
menu.addAction(m_listDashboard.at(n)->name(), this, SLOT(onMenuAction_dashboardList()));
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QPoint originPoint = ui->btnDashboradList2->mapToGlobal(QPoint(0, 0));
|
|
|
|
|
|
int nX = originPoint.x();
|
|
|
|
|
|
originPoint = ui->navigationPanel->mapToGlobal(QPoint(0, 0));
|
|
|
|
|
|
int nY = originPoint.y() + ui->navigationPanel->height();
|
|
|
|
|
|
menu.exec(QPoint(nX, nY));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onBtnClicked_dashboardTab()
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomTab* pBtn = qobject_cast<CustomTab*>(sender());
|
|
|
|
|
|
QString strName = pBtn->text();
|
|
|
|
|
|
setCurrentDashboard(strName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onMenuAction_dashboardList()
|
|
|
|
|
|
{
|
|
|
|
|
|
QAction* action = qobject_cast<QAction*>(sender());
|
|
|
|
|
|
QString strName = action->text();
|
|
|
|
|
|
setCurrentDashboard(strName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-13 16:41:08 +08:00
|
|
|
|
void DashboardFrame::onTimeout_realTime()
|
|
|
|
|
|
{
|
|
|
|
|
|
QDateTime curDateTime = QDateTime::currentDateTime();
|
|
|
|
|
|
m_pDateTimeWidget->setDateTime(curDateTime);
|
|
|
|
|
|
m_pTimeLineWidget->setDateTime(curDateTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
void DashboardFrame::onSignal_subDialogClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
hideTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onSignal_dashboardNaming(const QString& strName, const QString& strUsedFor)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(int n=0; n<m_listDashboard.count(); n++)
|
|
|
|
|
|
{
|
2024-11-14 09:19:14 +08:00
|
|
|
|
if(m_listDashboard.at(n)->name() == strName)
|
2024-11-05 15:17:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
QString strError = QString::fromStdWString(L"已存在同名看板");
|
|
|
|
|
|
m_pDashboardNamingDialog->showErrorInfo(strError);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(strUsedFor == "create")
|
|
|
|
|
|
addDashboard(strName);
|
|
|
|
|
|
else if(strUsedFor == "rename" && m_curOperationDashboard)
|
|
|
|
|
|
m_curOperationDashboard->setName(strName);
|
|
|
|
|
|
m_pDashboardNamingDialog->hide();
|
|
|
|
|
|
hideTransparentMask();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onSignal_dashboardTabMoved(int nFromIndex, int nToIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
//同步相应数据在其存储接结构中的位置
|
|
|
|
|
|
Dashboard* movingDashboard = m_listDashboard.takeAt(nFromIndex);
|
|
|
|
|
|
m_listDashboard.insert(nToIndex, movingDashboard);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onSignal_removeDashboard()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dashboard* dashboard = qobject_cast<Dashboard*>(sender());
|
|
|
|
|
|
if(dashboard)
|
|
|
|
|
|
{
|
|
|
|
|
|
showTransparentMask();
|
2024-11-14 09:19:14 +08:00
|
|
|
|
QString strName = dashboard->name();
|
2024-11-05 15:17:03 +08:00
|
|
|
|
QString strMsg = QString::fromStdWString(L"确认删除名为 \"") + strName + QString::fromStdWString(L"\" 的数据看板吗?");
|
|
|
|
|
|
showMessageDialog(type_question, QString::fromStdWString(L"删除看板"), strMsg);
|
|
|
|
|
|
if(g_msgDlgBtn == btn_No)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
removeDashboard(strName, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onSignal_renameDashboard()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_curOperationDashboard = qobject_cast<Dashboard*>(sender());
|
|
|
|
|
|
|
|
|
|
|
|
if(m_pDashboardNamingDialog == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pDashboardNamingDialog = new DashboardNamingDialog(this);
|
|
|
|
|
|
connect(m_pDashboardNamingDialog, SIGNAL(dlgHide()), this, SLOT(onSignal_subDialogClose()));
|
|
|
|
|
|
connect(m_pDashboardNamingDialog, SIGNAL(dashboardName(const QString&, const QString&)), this, SLOT(onSignal_dashboardNaming(const QString&, const QString&)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showTransparentMask();
|
2024-12-17 16:48:46 +08:00
|
|
|
|
//QPoint originPoint = ui->navigationPanel->mapToGlobal(QPoint(0, 0));
|
2024-12-11 15:23:58 +08:00
|
|
|
|
int nX = (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
|
|
|
|
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
2024-11-05 15:17:03 +08:00
|
|
|
|
m_pDashboardNamingDialog->setGeometry(nX, nY, m_pDashboardNamingDialog->width(), m_pDashboardNamingDialog->height());
|
|
|
|
|
|
m_pDashboardNamingDialog->showUsedForRename();
|
2024-12-11 15:23:58 +08:00
|
|
|
|
m_pDashboardNamingDialog->raise();
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onSignal_panelSelectResult(const QString& strType)
|
|
|
|
|
|
{
|
|
|
|
|
|
//m_pPanelSelectionDialog->hide();
|
|
|
|
|
|
hideTransparentMask();
|
|
|
|
|
|
m_curActiveDashboard->addPanel(strType);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-17 16:48:46 +08:00
|
|
|
|
void DashboardFrame::onSignal_timeRangeChanged(TimeUnit unit)
|
|
|
|
|
|
{
|
|
|
|
|
|
QObject* pObject = QObject::sender();
|
|
|
|
|
|
if(pObject->objectName() == "dateTimeWidget")
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pTimeLineWidget->setTimeScaleUnit(unit);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(pObject->objectName() == "timeLineWidget")
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pDateTimeWidget->setRange(unit);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DashboardFrame::onSignal_viewRealTimeData()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!m_pTimer_RealTime->isActive())
|
|
|
|
|
|
m_pTimer_RealTime->start(1000);
|
|
|
|
|
|
|
|
|
|
|
|
m_pTimeLineWidget->setDisplayState(realTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 15:17:03 +08:00
|
|
|
|
void DashboardFrame::onSignal_viewHistoricalData(QDateTime dateTime)
|
|
|
|
|
|
{
|
2024-12-13 16:41:08 +08:00
|
|
|
|
//qDebug() << "viewHistoricalData: " + dateTime.date().toString("yyyy/MM/dd");
|
2024-11-05 15:17:03 +08:00
|
|
|
|
hideTransparentMask();
|
2024-12-13 16:41:08 +08:00
|
|
|
|
|
2024-12-17 16:48:46 +08:00
|
|
|
|
if(m_pTimer_RealTime->isActive())
|
|
|
|
|
|
m_pTimer_RealTime->stop();
|
|
|
|
|
|
|
2024-12-13 16:41:08 +08:00
|
|
|
|
QObject* pObject = QObject::sender();
|
|
|
|
|
|
if(pObject->objectName() == "dateTimeWidget")
|
|
|
|
|
|
{
|
2024-12-17 16:48:46 +08:00
|
|
|
|
m_pTimeLineWidget->setDateTime(dateTime);
|
|
|
|
|
|
m_pTimeLineWidget->setDisplayState(historical);
|
2024-12-13 16:41:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if(pObject->objectName() == "timeLineWidget")
|
|
|
|
|
|
{
|
2024-12-17 16:48:46 +08:00
|
|
|
|
m_pDateTimeWidget->setDateTime(dateTime);
|
|
|
|
|
|
m_pDateTimeWidget->setState(historical);
|
2024-12-13 16:41:08 +08:00
|
|
|
|
}
|
2024-11-05 15:17:03 +08:00
|
|
|
|
}
|