diff --git a/dataPanel/dpConfigurationDialog.cpp b/dataPanel/dpConfigurationDialog.cpp index bdaeca4..3b20b72 100644 --- a/dataPanel/dpConfigurationDialog.cpp +++ b/dataPanel/dpConfigurationDialog.cpp @@ -4,6 +4,7 @@ #include "global.h" #include #include +#include dpConfigurationDialog::dpConfigurationDialog(QWidget *parent) : QDialog(parent) @@ -109,10 +110,10 @@ void dpConfigurationDialog::initialize() QRegularExpression regExp_ip("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); QRegularExpressionValidator* validator_ip = new QRegularExpressionValidator(regExp_ip, this); - ui->serverIP->setValidator(validator_ip); + ui->serviceIP->setValidator(validator_ip); QRegularExpression regExp_port("^(?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$"); QRegularExpressionValidator* validator_port = new QRegularExpressionValidator(regExp_port, this); - ui->serverPort->setValidator(validator_port); + ui->servicePort->setValidator(validator_port); } void dpConfigurationDialog::copyModelData(QStandardItemModel* sourceModel, QStandardItemModel* destModel) @@ -161,7 +162,7 @@ void dpConfigurationDialog::createDataSourceList() stationItem->appendRow(componentItem); QStandardItem* currentItem = new QStandardItem("电流"); currentItem->setEditable(false); - currentItem->setData("point", Qt::UserRole + itemRole_tag); + currentItem->setData("current", Qt::UserRole + itemRole_tag); currentItem->setData(0, Qt::UserRole + itemRole_stationID); currentItem->setData(0, Qt::UserRole + itemRole_componentID); currentItem->setData(0, Qt::UserRole + itemRole_pointID); @@ -169,12 +170,20 @@ void dpConfigurationDialog::createDataSourceList() componentItem->appendRow(currentItem); QStandardItem* voltageItem = new QStandardItem("电压"); voltageItem->setEditable(false); - voltageItem->setData("point", Qt::UserRole + itemRole_tag); + voltageItem->setData("voltage", Qt::UserRole + itemRole_tag); voltageItem->setData(0, Qt::UserRole + itemRole_stationID); voltageItem->setData(0, Qt::UserRole + itemRole_componentID); voltageItem->setData(1, Qt::UserRole + itemRole_pointID); voltageItem->setData(RealTimeDataType::voltage, Qt::UserRole + itemRole_dataType); componentItem->appendRow(voltageItem); + QStandardItem* powerItem = new QStandardItem("功率"); + powerItem->setEditable(false); + powerItem->setData("power", Qt::UserRole + itemRole_tag); + powerItem->setData(0, Qt::UserRole + itemRole_stationID); + powerItem->setData(0, Qt::UserRole + itemRole_componentID); + powerItem->setData(2, Qt::UserRole + itemRole_pointID); + powerItem->setData(RealTimeDataType::voltage, Qt::UserRole + itemRole_dataType); + componentItem->appendRow(powerItem); ui->dataSourceList->expandAll(); } @@ -186,6 +195,8 @@ void dpConfigurationDialog::setPanel(DataPanel* pPanel) // m_pModel_typeSelected = pPanel->m_cofigurationResults.m_pModel_dataType; // if(m_pModel_typeSelected) // ui->typeSelectedList->setModel(m_pModel_typeSelected); + ui->serviceIP->setText(pPanel->m_cofigurationResults.dataServiceIP); + ui->servicePort->setText(QString::number(pPanel->m_cofigurationResults.dataServicePort)); } void dpConfigurationDialog::onBtnClicked_tabBtn() @@ -243,8 +254,10 @@ void dpConfigurationDialog::onBtnClicked_confirm() { //m_pDataPanel->m_cofigurationResults.m_pModel_dataType = m_pModel_typeSelected; copyModelData(m_pModel_typeSelected, m_pDataPanel->m_cofigurationResults.m_pModel_dataType); - m_pDataPanel->configurationComplete(); + //m_pDataPanel->configurationComplete(); copyModelData(m_pModel_dataSelected, m_pDataPanel->m_cofigurationResults.m_pModel_dataSource); + m_pDataPanel->m_cofigurationResults.dataServiceIP = ui->serviceIP->text(); + m_pDataPanel->m_cofigurationResults.dataServicePort = ui->servicePort->text().toInt(); m_pDataPanel->configurationComplete(); } } @@ -273,6 +286,21 @@ void dpConfigurationDialog::onItemClicked_typeSource(const QModelIndex& index) if(!bIsHad && m_pModel_typeSelected) { + int nMaximumType = m_pModel_typeSelected->rowCount(); + if(m_pDataPanel && (m_pDataPanel->getType() == lineChart || m_pDataPanel->getType() == curveChart)) + nMaximumType = 2; + + if(m_pModel_typeSelected->rowCount() >= nMaximumType) + { + if(!ui->errorTip->isVisible()) + { + ui->errorTip->setVisible(true); + ui->errorTip->setToolTip(QString("当前面板最多展示 %1 种类型数据").arg(nMaximumType)); + //QTimer::singleShot(6000, this, [this]{ui->errorTip->setVisible(false);}); + } + return; + } + QStandardItem* newItem = new QStandardItem(item->text()); newItem->setEditable(false); m_pModel_typeSelected->appendRow(newItem); @@ -292,6 +320,9 @@ void dpConfigurationDialog::onBtnClicked_remove_type() if(selectionModel && m_pModel_typeSelected) { int nCurrentRow = selectionModel->currentIndex().row(); + if(nCurrentRow == -1) + return; + QList items = m_pModel_typeSelected->takeRow(nCurrentRow); for(QStandardItem* item: items) delete item; @@ -302,6 +333,8 @@ void dpConfigurationDialog::onBtnClicked_remove_type() ui->errorTip->setToolTip(QString::fromStdWString(L"要至少选择一个数据类型")); ui->btnConfirm->setEnabled(false); } + else if(ui->errorTip->isVisible()) + ui->errorTip->setVisible(false); } } diff --git a/dataPanel/dpGlobals.h b/dataPanel/dpGlobals.h index 2383d68..0aa50c9 100644 --- a/dataPanel/dpGlobals.h +++ b/dataPanel/dpGlobals.h @@ -26,11 +26,16 @@ struct configurationResults { QStandardItemModel* m_pModel_dataType; QStandardItemModel* m_pModel_dataSource; + QString dataServiceIP; + int dataServicePort; configurationResults() { m_pModel_dataType = nullptr; m_pModel_dataSource = nullptr; + + dataServiceIP = "127.0.0.1"; + dataServicePort = 1987; } void setParent(QObject* parent) diff --git a/include/dataPanel.h b/include/dataPanel.h index 473dc3b..f7f21ab 100644 --- a/include/dataPanel.h +++ b/include/dataPanel.h @@ -59,6 +59,8 @@ public: void setName(const QString&); const QString& getName(); + DataPanelType getType(); + void setInitialSize(const QSize&); void setDisplayAreaSize(const QSize&); void resizeByRatio(double, double); //通过缩放比例做resize,在所属dasboard的resizeEvent中调用 @@ -111,6 +113,7 @@ private: QBoxLayout* m_pLayout; QScrollArea* m_pScrollArea; PanelToolWidget* m_pToolWidget; + DataPanelType m_type; PanelConfigurationWidget* m_pConfigurationWidget; CustomBorderContainer* m_pCustomBorderContainer; diff --git a/source/dataPanel.cpp b/source/dataPanel.cpp index a58b6b4..0558796 100644 --- a/source/dataPanel.cpp +++ b/source/dataPanel.cpp @@ -29,6 +29,7 @@ PanelToolWidget::~PanelToolWidget() DataPanel::DataPanel(QWidget *parent, DataPanelType type) : QDialog(parent) + ,m_type(type) { setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow); //setAttribute(Qt::WA_StaticContents, false); // 禁用静态内容优化 @@ -308,6 +309,11 @@ const QString& DataPanel::getName() return m_strName; } +DataPanelType DataPanel::getType() +{ + return m_type; +} + void DataPanel::setInitialSize(const QSize& size) { resize(size); @@ -381,7 +387,7 @@ void DataPanel::setDateTime(const QDateTime& dateTime) baseWidget->setDateTime(dateTime); //请求数据 - DataManager::instance()->requestData("dataType", this); + //DataManager::instance()->requestData("dataType", this); } void DataPanel::setTimeRange(TimeUnit unit) diff --git a/ui/dpConfigurationDialog.ui b/ui/dpConfigurationDialog.ui index 0cc9599..34d791c 100644 --- a/ui/dpConfigurationDialog.ui +++ b/ui/dpConfigurationDialog.ui @@ -493,7 +493,7 @@ background-color:transparent; QLineEdit { -font: 10pt "黑体"; +font: 11pt "黑体"; background-color: rgb(24, 32, 38); } @@ -511,7 +511,7 @@ background-color: rgb(24, 32, 38); 数据服务 - + 31 @@ -524,7 +524,7 @@ background-color: rgb(24, 32, 38); 服务地址: - + 110 @@ -534,7 +534,7 @@ background-color: rgb(24, 32, 38); - + 30 @@ -547,7 +547,7 @@ background-color: rgb(24, 32, 38); 服务端口: - + 110