diff --git a/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.cpp b/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.cpp index a0b75db8..e62319d6 100644 --- a/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.cpp @@ -1,6 +1,12 @@ #include "CommonCfgpluginwidget.h" #include "commonwidget.h" +#include +#include +#include +#include "../model_common/common.h" +#include "pub_widget/PubWidgetInit.h" + CommonCfgPluginWidget::CommonCfgPluginWidget(QObject *parent) : QObject(parent) { @@ -15,6 +21,12 @@ bool CommonCfgPluginWidget::createWidget(QWidget *parent, bool editMode, QWidget { Q_UNUSED(ptrVec) Q_UNUSED(editMode) + + QTranslator * qtTranslator = new QTranslator; + qtTranslator->load(Common::getTranslatePath("Common_config_plugin_EN.qm")); + qApp->installTranslator(qtTranslator); + iot_public::installTranslator(Common::getLanguage().toStdString()); + CommonWidget *pWidget = new CommonWidget(parent); *widget = (QWidget *)pWidget; *pTrendWindow = (IPluginWidget *)pWidget; diff --git a/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.h b/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.h index bb7ac422..c3930ae8 100644 --- a/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.h +++ b/product/src/tools/model_plugin/CommonWidget/CommonCfgpluginwidget.h @@ -7,7 +7,7 @@ class CommonCfgPluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/CommonWidget/CommonWidget.pro b/product/src/tools/model_plugin/CommonWidget/CommonWidget.pro index a1c8ab31..dcd1c1e5 100644 --- a/product/src/tools/model_plugin/CommonWidget/CommonWidget.pro +++ b/product/src/tools/model_plugin/CommonWidget/CommonWidget.pro @@ -36,12 +36,13 @@ PLATFORM_INCLUDE_PATH = $$SRC_ROOT_PATH/../../platform/src/include/ INCLUDEPATH += $$PWD\ $$PLATFORM_INCLUDE_PATH/tools/model_common \ $$PLATFORM_INCLUDE_PATH/tools/model_table \ - $$PLATFORM_INCLUDE_PATH/tools/model_excel/xlsx + $$PLATFORM_INCLUDE_PATH/public/pub_excel/xlsx -LIBS += -lmodel_common -lmodel_excel +LIBS += -lmodel_common -lpub_excel LIBS += -lmodel_table -lScriptForm_lua +LIBS += -lpub_widget HEADERS += \ commonwidget.h \ @@ -67,3 +68,5 @@ SOURCES += \ kbdstatetextwidget.cpp \ CommonCfgpluginwidget.cpp +TRANSLATIONS += Common_config_plugin_EN.ts + diff --git a/product/src/tools/model_plugin/CommonWidget/commonwidget.cpp b/product/src/tools/model_plugin/CommonWidget/commonwidget.cpp index 57b70276..61ecf0f0 100644 --- a/product/src/tools/model_plugin/CommonWidget/commonwidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/commonwidget.cpp @@ -12,7 +12,7 @@ #include "kbdlockdefinewidget.h" #include "kbdlockparawidget.h" #include "kbdstatetextwidget.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdctrlactwidget.h" #include "kbdoutlinewidget.h" #include @@ -84,15 +84,20 @@ QWidget *CommonWidget::initTotal() QToolBar *bar = new QToolBar(widget); m_tableTotal = new KbdTable(widget,REWRITE_COMMIT); - bar->setIconSize(QSize(24,24)); - - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTableTotalRow())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_tableTotal,SLOT(onRemoveRowNotCommit())); - bar->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_tableTotal,SLOT(onUndo())); - bar->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveTableTotal())); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddTableTotalRow())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除记录"),m_tableTotal,SLOT(onRemoveRowNotCommit())); + bar->widgetForAction(act)->setObjectName("icon_delete"); + act = bar->addAction(tr("撤销更改"),m_tableTotal,SLOT(onUndo())); + bar->widgetForAction(act)->setObjectName("icon_undo"); + act = bar->addAction(tr("保存"),this,SLOT(onSaveTableTotal())); + bar->widgetForAction(act)->setObjectName("icon_save"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/Excel-export.png"),tr("Excel导出"),m_tableTotal,SLOT(onExcelExport())); - bar->addAction(QIcon(":/icons/icons/Excel-Impor.png"),tr("Excel导入"),m_tableTotal,SLOT(onImportExcel())); + act = bar->addAction(tr("Excel导出"),m_tableTotal,SLOT(onExcelExport())); + bar->widgetForAction(act)->setObjectName("icon_excel_export"); + act = bar->addAction(tr("Excel导入"),m_tableTotal,SLOT(onImportExcel())); + bar->widgetForAction(act)->setObjectName("icon_excel_import"); vLayout1->addWidget(bar); vLayout1->addWidget(m_tableTotal); @@ -124,13 +129,20 @@ QWidget *CommonWidget::creatPointTypeWidget() kbdSearchWidget* search = new kbdSearchWidget(widget); QToolBar *bar = new QToolBar(widget); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddPointTypeTableRow())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_tablePointType->getTable(),SLOT(onRemoveRowNotCommit())); - bar->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_tablePointType->getTable(),SLOT(onUndo())); - bar->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),[this](){m_tablePointType->getTable()->saveWithReWrite(false);}); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddPointTypeTableRow())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除记录"),m_tablePointType->getTable(),SLOT(onRemoveRowNotCommit())); + bar->widgetForAction(act)->setObjectName("icon_delete"); + act = bar->addAction(tr("撤销更改"),m_tablePointType->getTable(),SLOT(onUndo())); + bar->widgetForAction(act)->setObjectName("icon_undo"); + act = bar->addAction(tr("保存"),[this](){m_tablePointType->getTable()->saveWithReWrite(false);}); + bar->widgetForAction(act)->setObjectName("icon_save"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/Excel-export.png"),tr("Excel导出"),m_tablePointType->getTable(),SLOT(onExcelExport())); - bar->addAction(QIcon(":/icons/icons/Excel-Impor.png"),tr("Excel导入"),m_tablePointType->getTable(),SLOT(onImportExcel())); + act = bar->addAction(tr("Excel导出"),m_tablePointType->getTable(),SLOT(onExcelExport())); + bar->widgetForAction(act)->setObjectName("icon_excel_export"); + act = bar->addAction(tr("Excel导入"),m_tablePointType->getTable(),SLOT(onImportExcel())); + bar->widgetForAction(act)->setObjectName("icon_excel_import"); hLayout->addWidget(bar); hLayout->addSpacing(10); @@ -389,7 +401,7 @@ void CommonWidget::onExport() QFile file(filePath); if(!file.open(QIODevice::WriteOnly)) { - QMessageBox::information(this,tr("消息"),tr("文件打开不成功")); + N_MessageBox::information(this,tr("消息"),tr("文件打开不成功")); return ; } QXlsx::Document xlsx(&file); @@ -399,15 +411,15 @@ void CommonWidget::onExport() { if(xlsx.saveAs(filePath)) { - QMessageBox::information(this,tr("消息"),tr("导出配置成功!\n导出路径:")+filePath); + N_MessageBox::information(this,tr("消息"),tr("导出配置成功!\n导出路径:")+filePath); } else { - QMessageBox::information(this,tr("消息"),tr("保存失败")); + N_MessageBox::information(this,tr("消息"),tr("保存失败")); } } else - QMessageBox::information(this,tr("消息"),tr("导出失败:%1").arg(error)); + N_MessageBox::information(this,tr("消息"),tr("导出失败:%1").arg(error)); /* @@ -417,9 +429,9 @@ void CommonWidget::onExport() QString filePath = Common::getSysModelPath() + "/" + model->getTableName() + ".xml"; if(model->exportFile(filePath)) - QMessageBox::information(this,tr("消息"),tr("导出配置成功!\n导出路径:")+filePath); + N_MessageBox::information(this,tr("消息"),tr("导出配置成功!\n导出路径:")+filePath); else - QMessageBox::information(this,tr("消息"),tr("导出失败")); + N_MessageBox::information(this,tr("消息"),tr("导出失败")); */ } @@ -434,7 +446,7 @@ void CommonWidget::onImport() QFile file(filePath); if(!file.open(QIODevice::ReadOnly)) { - QMessageBox::information(this,tr("消息"),tr("文件打开不成功")); + N_MessageBox::information(this,tr("消息"),tr("文件打开不成功")); return ; } QXlsx::Document xlsx(&file); diff --git a/product/src/tools/model_plugin/CommonWidget/kbdapcanawidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdapcanawidget.cpp index 04cee036..6c0e8dbe 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdapcanawidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdapcanawidget.cpp @@ -2,7 +2,7 @@ #include #include "kbdtable.h" #include "../model_common/common.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdtabledatamgr.h" #include #include "kbdpropertypanel.h" @@ -23,9 +23,11 @@ void KbdApcAnaWidget::initLayout() { QToolBar *bar = new QToolBar(this); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddRow())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveRow())); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddRow())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveRow())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_table = new KbdTable(this,EXTERN_COMMIT); m_table->setModel(KbdTableDataMgr::getInstance()->createModel("APC_ANALOG.xml")); @@ -53,7 +55,7 @@ void KbdApcAnaWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName QStringList keyIdTagList = text.split("."); if(keyIdTagList.size() != 5) { - QMessageBox::information(NULL,tr("消息"),tr("输出测点 %1 格式不正确,请重新输入").arg(keyIdTagList.join("."))); + N_MessageBox::information(NULL,tr("消息"),tr("输出测点 %1 格式不正确,请重新输入").arg(keyIdTagList.join("."))); return; } QString tagName, tableName; @@ -68,12 +70,12 @@ void KbdApcAnaWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName KbdDbDesign ds; if(!ds.getThreeColumnResult(sql.arg(tableName).arg(tagName),locationIdList,subSystemList,descList)) { - QMessageBox::information(NULL,tr("消息"),tr("数据库查询错误")); + N_MessageBox::information(NULL,tr("消息"),tr("数据库查询错误")); return; } if(locationIdList.size() != 1 || subSystemList.size() != 1) { - QMessageBox::information(NULL,tr("消息"),tr("输出测点%1 不存在对应的车站和专业信息").arg(tagName)); + N_MessageBox::information(NULL,tr("消息"),tr("输出测点%1 不存在对应的车站和专业信息").arg(tagName)); return; } @@ -89,7 +91,7 @@ void KbdApcAnaWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName QStringList keyIdTagList = text.split("."); if(keyIdTagList.size() != 5) { - QMessageBox::information(NULL,tr("消息"),tr("超时输出测点 %1 格式不正确").arg(keyIdTagList.join("."))); + N_MessageBox::information(NULL,tr("消息"),tr("超时输出测点 %1 格式不正确").arg(keyIdTagList.join("."))); return; } QString tagName, tableName; @@ -103,12 +105,12 @@ void KbdApcAnaWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName KbdDbDesign ds; if(!ds.getTwoColumnResult(sql.arg(tableName).arg(tagName),locationIdList,subSystemList)) { - QMessageBox::information(NULL,tr("消息"),tr("数据库查询错误")); + N_MessageBox::information(NULL,tr("消息"),tr("数据库查询错误")); return; } if(locationIdList.size() != 1 || subSystemList.size() != 1) { - QMessageBox::information(NULL,tr("消息"),tr("超时输出测点%1 不存在对应的车站和专业信息").arg(tagName)); + N_MessageBox::information(NULL,tr("消息"),tr("超时输出测点%1 不存在对应的车站和专业信息").arg(tagName)); return; } const ColMgrDataList& modelCols = dlg.panel()->currentModel()->getHeadCols(); @@ -120,7 +122,7 @@ void KbdApcAnaWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName if(oldLocation != locationIdList.first() || oldSubSystem != subSystemList.first()) { - QMessageBox::information(NULL,tr("消息"),tr("超时输出测点与输出测点不是同一个车站和专业")); + N_MessageBox::information(NULL,tr("消息"),tr("超时输出测点与输出测点不是同一个车站和专业")); return; } @@ -239,9 +241,9 @@ void KbdApcAnaWidget::onAddRow() void KbdApcAnaWidget::onRemoveRow() { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("是否删除?"), - QMessageBox::Yes,QMessageBox::No)) + N_MessageBox::Yes,N_MessageBox::No)) return; KbdTableModel *model = qobject_cast(m_table->model()); @@ -325,21 +327,21 @@ void KbdApcAnaWidget::onModifyRow() void KbdApcAnaWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } void KbdApcAnaWidget::onMsg(const QString &text) { - QMessageBox::information(this,tr("消息"),text); + N_MessageBox::information(this,tr("消息"),text); } void KbdApcAnaWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdApcAnaWidget::onRollbackError() { - QMessageBox::information(this,tr("消息"),tr("回滚事务失败!")); + N_MessageBox::information(this,tr("消息"),tr("回滚事务失败!")); } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdapcdigwidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdapcdigwidget.cpp index 44027b7f..e011f2e9 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdapcdigwidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdapcdigwidget.cpp @@ -2,7 +2,7 @@ #include #include "kbdtable.h" #include "../model_common/common.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdtabledatamgr.h" #include #include "kbdpropertypanel.h" @@ -22,9 +22,11 @@ KbdApcDigWidget::~KbdApcDigWidget() void KbdApcDigWidget::initLayout() { QToolBar *bar = new QToolBar(this); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddRow())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveRow())); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddRow())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveRow())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_table = new KbdTable(this,EXTERN_COMMIT); m_table->setModel(KbdTableDataMgr::getInstance()->createModel("APC_DIGITAL.xml")); @@ -48,7 +50,7 @@ void KbdApcDigWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName QStringList keyIdTagList = text.split("."); if(keyIdTagList.size() != 5) { - QMessageBox::information(NULL,tr("消息"),tr("输出测点 %1 格式不正确,请重新输入").arg(keyIdTagList.join("."))); + N_MessageBox::information(NULL,tr("消息"),tr("输出测点 %1 格式不正确,请重新输入").arg(keyIdTagList.join("."))); return; } QString tagName, tableName; @@ -63,12 +65,12 @@ void KbdApcDigWidget::changeProperty(KbdPropertyDlg &dlg, const QString &sqlName KbdDbDesign ds; if(!ds.getThreeColumnResult(sql.arg(tableName).arg(tagName),locationIdList,subSystemList,descList)) { - QMessageBox::information(NULL,tr("消息"),tr("数据库查询错误")); + N_MessageBox::information(NULL,tr("消息"),tr("数据库查询错误")); return; } if(locationIdList.size() != 1 || subSystemList.size() != 1) { - QMessageBox::information(NULL,tr("消息"),tr("输出测点%1 不存在对应的车站和专业信息").arg(tagName)); + N_MessageBox::information(NULL,tr("消息"),tr("输出测点%1 不存在对应的车站和专业信息").arg(tagName)); return; } @@ -120,9 +122,9 @@ void KbdApcDigWidget::onAddRow() void KbdApcDigWidget::onRemoveRow() { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("是否删除?"), - QMessageBox::Yes,QMessageBox::No)) + N_MessageBox::Yes,N_MessageBox::No)) return; KbdTableModel *model = qobject_cast(m_table->model()); @@ -202,21 +204,21 @@ void KbdApcDigWidget::onModifyRow() void KbdApcDigWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } void KbdApcDigWidget::onMsg(const QString &text) { - QMessageBox::information(this,tr("消息"),text); + N_MessageBox::information(this,tr("消息"),text); } void KbdApcDigWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdApcDigWidget::onRollbackError() { - QMessageBox::information(this,tr("消息"),tr("回滚事务失败!")); + N_MessageBox::information(this,tr("消息"),tr("回滚事务失败!")); } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdctrlactwidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdctrlactwidget.cpp index a4fb2f1a..d7eb576b 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdctrlactwidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdctrlactwidget.cpp @@ -9,7 +9,7 @@ #include "model_common/common.h" #include "kbdtable.h" #include "kbdtabledatamgr.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdpropertydlg.h" #include "kbdpropertypanel.h" #include "kbdmsgcontrl.h" @@ -67,16 +67,22 @@ void KbdCtrlActWidget::initLayout() mainLayout->addWidget(hSplitter); setLayout(mainLayout); - bar1->setIconSize(QSize(24,24)); - bar1->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTree())); - bar1->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyTree())); - bar1->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveTree())); + QAction* act = nullptr; + act = bar1->addAction(tr("添加记录"),this,SLOT(onAddTree())); + bar1->widgetForAction(act)->setObjectName("icon_add"); + act = bar1->addAction(tr("修改记录"),this,SLOT(onModifyTree())); + bar1->widgetForAction(act)->setObjectName("icon_edit"); + act = bar1->addAction(tr("删除记录"),this,SLOT(onRemoveTree())); + bar1->widgetForAction(act)->setObjectName("icon_delete"); - bar2->setIconSize(QSize(24,24)); - bar2->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTable())); - bar2->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_table,SLOT(onRemoveRowNotCommit())); - bar2->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_table,SLOT(onUndo())); - bar2->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveTable())); + act = bar2->addAction(tr("添加记录"),this,SLOT(onAddTable())); + bar2->widgetForAction(act)->setObjectName("icon_add"); + act = bar2->addAction(tr("删除记录"),m_table,SLOT(onRemoveRowNotCommit())); + bar2->widgetForAction(act)->setObjectName("icon_delete"); + act = bar2->addAction(tr("撤销更改"),m_table,SLOT(onUndo())); + bar2->widgetForAction(act)->setObjectName("icon_undo"); + act = bar2->addAction(tr("保存"),this,SLOT(onSaveTable())); + bar2->widgetForAction(act)->setObjectName("icon_save"); connect(m_tree,SIGNAL(clicked(const QModelIndex &)),this,SLOT(onTreeClick(const QModelIndex &))); connect(m_tree,SIGNAL(doubleClicked(const QModelIndex &)),this,SLOT(onModifyTree())); @@ -348,18 +354,18 @@ void KbdCtrlActWidget::onSaveTable() void KbdCtrlActWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void KbdCtrlActWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdCtrlActWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.cpp index 53674708..92fa45ef 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "pub_widget/MessageBox.h" #include "kbdtabledatamgr.h" #include "kbdcheckrole.h" #include "kbdmsgcontrl.h" @@ -50,10 +50,10 @@ void KbdLockDefineWidget::hideEvent(QHideEvent *event) // QStringList oldDatas = model->getRowData(m_panel->currentRow()); // if(!stringListEqual(panelDatas,oldDatas)) // { -// int ret = QMessageBox::information(this,tr("消息"), +// int ret = N_MessageBox::information(this,tr("消息"), // tr("闭锁函数修改未提交,是否提交到数据库?"), -// QMessageBox::Yes,QMessageBox::No); -// if(ret == QMessageBox::Yes) +// N_MessageBox::Yes,N_MessageBox::No); +// if(ret == N_MessageBox::Yes) // { // onSave(); // } @@ -71,10 +71,13 @@ void KbdLockDefineWidget::initLayout() QVBoxLayout *vLayoutTree = new QVBoxLayout; QToolBar *bar = new QToolBar(widgetTree); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加"),this,SLOT(onAdd())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除"),this,SLOT(onRemove())); - bar->addAction(QIcon(":/icons/icons/modify.png"), tr("修改"), this, SLOT(onModify())); + QAction* act = nullptr; + act = bar->addAction(tr("添加"),this,SLOT(onAdd())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除"),this,SLOT(onRemove())); + bar->widgetForAction(act)->setObjectName("icon_delete"); + act = bar->addAction(tr("修改"), this, SLOT(onModify())); + bar->widgetForAction(act)->setObjectName("icon_edit"); m_tree = new KbdTreeView(widgetTree); KbdSqlTreeModel *treeModel = new KbdSqlTreeModel(Common::getTreePath("lockDefineTree.xml"),this); @@ -92,7 +95,8 @@ void KbdLockDefineWidget::initLayout() QGroupBox *box = new QGroupBox(tr("闭锁函数定义"),widgetDetail); QHBoxLayout *boxLayout = new QHBoxLayout; - m_te = new ScriptFormWidget(box); + using namespace ScriptForm_lua; + m_te = new ScriptForm_lua::ScriptFormWidget(box); boxLayout->addWidget(m_te); boxLayout->setMargin(0); box->setLayout(boxLayout); @@ -307,10 +311,10 @@ void KbdLockDefineWidget::onTreeClicked(const QModelIndex &index) QStringList oldDatas = model1->getRowData(m_panel->panel()->currentRow()); if(!stringListEqual(panelDatas,oldDatas)) { - int ret = QMessageBox::information(this,tr("消息"), + int ret = N_MessageBox::information(this,tr("消息"), tr("闭锁函数修改未提交,是否提交到数据库?"), - QMessageBox::Yes,QMessageBox::No); - if(ret == QMessageBox::Yes) + N_MessageBox::Yes,N_MessageBox::No); + if(ret == N_MessageBox::Yes) { onSave(); } @@ -345,18 +349,18 @@ void KbdLockDefineWidget::onTreeClicked(const QModelIndex &index) void KbdLockDefineWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void KbdLockDefineWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdLockDefineWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.h b/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.h index c9c679a1..5f00ea86 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.h +++ b/product/src/tools/model_plugin/CommonWidget/kbdlockdefinewidget.h @@ -2,11 +2,13 @@ #define KBDLOCKDEFINEWIDGET_H #include - +#include "ScriptForm/ScriptForm.h" class KbdPropertyDlg; class QTextEdit; class KbdTreeView; + +using namespace ScriptForm_lua; class ScriptFormWidget; /** @@ -26,7 +28,7 @@ private: private: KbdTreeView *m_tree; KbdPropertyDlg *m_panel; - ScriptFormWidget* m_te; + ScriptForm_lua::ScriptFormWidget* m_te; private slots: void onAdd(); diff --git a/product/src/tools/model_plugin/CommonWidget/kbdlockparawidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdlockparawidget.cpp index 0fccaa8a..fa8a899a 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdlockparawidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdlockparawidget.cpp @@ -10,7 +10,7 @@ #include #include "kbdselctlockparadlg.h" #include -#include +#include "pub_widget/MessageBox.h" #include #include #include @@ -20,6 +20,7 @@ #include "CustomWidget/kbddevinstwidget.h" #include "kbdtableproperty.h" #include "CustomWidget/kbdsearchwidget.h" +#include "pub_widget/CustomDialog.h" KbdLockParaWidget::KbdLockParaWidget(QWidget *parent) : QSplitter(parent) { @@ -45,13 +46,18 @@ void KbdLockParaWidget::initLayout() search->setPlaceholderText(tr("请输入DO描述关键字")); search->setMaximumWidth(350); - bar2->setIconSize(QSize(24,24)); - bar2->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTable())); - bar2->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyTable())); - bar2->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveTable())); + QAction* act = nullptr; + act = bar2->addAction(tr("添加记录"),this,SLOT(onAddTable())); + bar2->widgetForAction(act)->setObjectName("icon_add"); + act = bar2->addAction(tr("修改记录"),this,SLOT(onModifyTable())); + bar2->widgetForAction(act)->setObjectName("icon_edit"); + act = bar2->addAction(tr("删除记录"),this,SLOT(onRemoveTable())); + bar2->widgetForAction(act)->setObjectName("icon_delete"); bar2->addSeparator(); - bar2->addAction(QIcon(":/icons/icons/Excel-export.png"),tr("Excel导出"),m_table->getTable(),SLOT(onExcelExport())); - bar2->addAction(QIcon(":/icons/icons/Excel-Impor.png"),tr("Excel导入"),m_table->getTable(),SLOT(onImportExcel())); + act = bar2->addAction(tr("Excel导出"),m_table->getTable(),SLOT(onExcelExport())); + bar2->widgetForAction(act)->setObjectName("icon_excel_export"); + act = bar2->addAction(tr("Excel导入"),m_table->getTable(),SLOT(onImportExcel())); + bar2->widgetForAction(act)->setObjectName("icon_excel_import"); bar2->addSeparator(); bar2->addWidget(search); @@ -121,7 +127,8 @@ void KbdLockParaWidget::onAddTable() wig->setPointTypeHide(0); wig->setPointValueEnable(false); - QDialog dlg; + CustomDialog dlg; + dlg.setWindowTitle(tr("添加闭锁参数配置")); QHBoxLayout* hLayout = new QHBoxLayout; hLayout->addWidget(wig); hLayout->setMargin(0); @@ -300,17 +307,17 @@ void KbdLockParaWidget::onTableSearch(QString text) void KbdLockParaWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void KbdLockParaWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdLockParaWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdoutlinewidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdoutlinewidget.cpp index c8ca463b..1c686720 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdoutlinewidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdoutlinewidget.cpp @@ -7,7 +7,7 @@ #include "model_common/common.h" #include "kbdtable.h" #include "kbdtabledatamgr.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdpropertydlg.h" #include "kbdpropertypanel.h" #include @@ -50,9 +50,11 @@ void KbdOutLineWidget::initLayout() QWidget *widgetTree = new QWidget(hSplitter); QVBoxLayout *vLayout1 = new QVBoxLayout; QToolBar *bar1 = new QToolBar(widgetTree); - bar1->setIconSize(QSize(24,24)); - bar1->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTree())); - bar1->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveTree())); + QAction* act = nullptr; + act = bar1->addAction(tr("添加记录"),this,SLOT(onAddTree())); + bar1->widgetForAction(act)->setObjectName("icon_add"); + act = bar1->addAction(tr("删除记录"),this,SLOT(onRemoveTree())); + bar1->widgetForAction(act)->setObjectName("icon_delete"); m_tree = new KbdTreeView(widgetTree); m_treeModel = new KbdSqlTreeModel("",this); @@ -66,11 +68,14 @@ void KbdOutLineWidget::initLayout() QVBoxLayout *vlayout2 = new QVBoxLayout; QToolBar *bar2 = new QToolBar(widgetDetail); m_table = new KbdTable(widgetDetail,REWRITE_COMMIT); - bar2->setIconSize(QSize(24,24)); - bar2->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTable())); - bar2->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_table,SLOT(onRemoveRowNotCommit())); - bar2->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_table,SLOT(onUndo())); - bar2->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveTable())); + act = bar2->addAction(tr("添加记录"),this,SLOT(onAddTable())); + bar2->widgetForAction(act)->setObjectName("icon_add"); + act = bar2->addAction(tr("删除记录"),m_table,SLOT(onRemoveRowNotCommit())); + bar2->widgetForAction(act)->setObjectName("icon_delete"); + act = bar2->addAction(tr("撤销更改"),m_table,SLOT(onUndo())); + bar2->widgetForAction(act)->setObjectName("icon_undo"); + act = bar2->addAction(tr("保存"),this,SLOT(onSaveTable())); + bar2->widgetForAction(act)->setObjectName("icon_save"); vlayout2->addWidget(bar2); vlayout2->addWidget(m_table); @@ -208,16 +213,16 @@ void KbdOutLineWidget::onSaveTable() void KbdOutLineWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void KbdOutLineWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdOutLineWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.cpp b/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.cpp index c532deaf..e9847a19 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.cpp @@ -9,10 +9,10 @@ #include #include #include -#include +#include "pub_widget/MessageBox.h" #include "kbddbdesign.h" -KbdSelctLockParaDlg::KbdSelctLockParaDlg(QWidget *parent) : QDialog(parent) +KbdSelctLockParaDlg::KbdSelctLockParaDlg(QWidget *parent) : CustomDialog(parent) { QStringList strList; strList << QString("sql@SELECT * FROM SYS_MODEL_LOCATION_INFO;%1:%2").arg(CN_LOCATION_ID).arg(CN_DESC) @@ -131,7 +131,7 @@ void KbdSelctLockParaDlg::onSelectByLocationAndSubSystem() QString pointDesc = m_findPointWidget->getSelectDescByIndex(6); if(pointDesc.isEmpty()) { - QMessageBox::information(this,tr("消息"),tr("请先选中测点")); + N_MessageBox::information(this,tr("消息"),tr("请先选中测点")); return; } diff --git a/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.h b/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.h index 0923c560..d1948d90 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.h +++ b/product/src/tools/model_plugin/CommonWidget/kbdselctlockparadlg.h @@ -2,13 +2,14 @@ #define KBDSELCTLOCKPARADLG_H #include +#include "pub_widget/CustomDialog.h" class KbdFindPointWidget; class QListWidget; class QLabel; class QRadioButton; -class KbdSelctLockParaDlg : public QDialog +class KbdSelctLockParaDlg : public CustomDialog { Q_OBJECT public: diff --git a/product/src/tools/model_plugin/CommonWidget/kbdstatetextwidget.cpp b/product/src/tools/model_plugin/CommonWidget/kbdstatetextwidget.cpp index 2eaa7089..1c32ac04 100644 --- a/product/src/tools/model_plugin/CommonWidget/kbdstatetextwidget.cpp +++ b/product/src/tools/model_plugin/CommonWidget/kbdstatetextwidget.cpp @@ -7,7 +7,7 @@ #include "model_common/common.h" #include "kbdtable.h" #include "kbdtabledatamgr.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdpropertydlg.h" #include "kbdpropertypanel.h" #include "kbdmsgcontrl.h" @@ -64,15 +64,20 @@ void KbdStateTextWidget::initLayout() mainLayout->addWidget(hSplitter); setLayout(mainLayout); - bar1->setIconSize(QSize(24,24)); - bar1->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTree())); - bar1->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveTree())); + QAction* act = nullptr; + act = bar1->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTree())); + bar1->widgetForAction(act)->setObjectName("icon_add"); + act = bar1->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveTree())); + bar1->widgetForAction(act)->setObjectName("icon_delete"); - bar2->setIconSize(QSize(24,24)); - bar2->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTable())); - bar2->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_table,SLOT(onRemoveRowNotCommit())); - bar2->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_table,SLOT(onUndo())); - bar2->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveTable())); + act = bar2->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddTable())); + bar2->widgetForAction(act)->setObjectName("icon_add"); + act = bar2->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_table,SLOT(onRemoveRowNotCommit())); + bar2->widgetForAction(act)->setObjectName("icon_delete"); + act = bar2->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_table,SLOT(onUndo())); + bar2->widgetForAction(act)->setObjectName("icon_undo"); + act = bar2->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveTable())); + bar2->widgetForAction(act)->setObjectName("icon_save"); connect(m_tree,SIGNAL(clicked(const QModelIndex &)),this,SLOT(onTreeClick(const QModelIndex &))); @@ -240,18 +245,18 @@ void KbdStateTextWidget::onSaveTable() void KbdStateTextWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void KbdStateTextWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void KbdStateTextWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/ExpressionWidget/ExpressionWidget.pro b/product/src/tools/model_plugin/ExpressionWidget/ExpressionWidget.pro index b7089e57..b779d49e 100644 --- a/product/src/tools/model_plugin/ExpressionWidget/ExpressionWidget.pro +++ b/product/src/tools/model_plugin/ExpressionWidget/ExpressionWidget.pro @@ -36,11 +36,11 @@ PLATFORM_INCLUDE_PATH = $$SRC_ROOT_PATH/../../platform/src/include/ INCLUDEPATH += $$PWD\ $$PLATFORM_INCLUDE_PATH/tools/model_common \ $$PLATFORM_INCLUDE_PATH/tools/model_table \ - $$PLATFORM_INCLUDE_PATH/tools/model_excel/xlsx + $$PLATFORM_INCLUDE_PATH/public/pub_excel/xlsx -LIBS += -lmodel_common -lmodel_excel +LIBS += -lmodel_common -lpub_excel -lpub_widget LIBS += -lmodel_table -lScriptForm_lua -lcalc_lua_api HEADERS += \ @@ -51,5 +51,5 @@ SOURCES += \ expressionpluginwidget.cpp \ expressionwidget.cpp - +TRANSLATIONS += expression_plugin_EN.ts diff --git a/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.cpp b/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.cpp index 54ee85a9..a8a5debe 100644 --- a/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.cpp +++ b/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.cpp @@ -1,6 +1,12 @@ #include "expressionpluginwidget.h" #include "expressionwidget.h" +#include +#include +#include +#include "../model_common/common.h" +#include "pub_widget/PubWidgetInit.h" + ExpressionPluginWidget::ExpressionPluginWidget(QObject *parent) : QObject(parent) { @@ -15,6 +21,12 @@ bool ExpressionPluginWidget::createWidget(QWidget *parent, bool editMode, QWidge { Q_UNUSED(ptrVec) Q_UNUSED(editMode) + + QTranslator * qtTranslator = new QTranslator; + qtTranslator->load(Common::getTranslatePath("expression_plugin_EN.qm")); + qApp->installTranslator(qtTranslator); + iot_public::installTranslator(Common::getLanguage().toStdString()); + ExpressionWidget *pWidget = new ExpressionWidget(parent); *widget = (QWidget *)pWidget; *pTrendWindow = (IPluginWidget *)pWidget; diff --git a/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.h b/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.h index 671dc39e..5788f0ff 100644 --- a/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.h +++ b/product/src/tools/model_plugin/ExpressionWidget/expressionpluginwidget.h @@ -7,7 +7,7 @@ class ExpressionPluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.cpp b/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.cpp index 675f8910..3e4af412 100644 --- a/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.cpp +++ b/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.cpp @@ -17,7 +17,7 @@ #include #include "kbddbdesign.h" #include "kbdpropertydlg.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdmsgcontrl.h" #include "../../../include/tools/calc_lua_api/CCalcLua.h" #include "ScriptForm/ScriptForm.h" @@ -30,6 +30,8 @@ ExpressionWidget::ExpressionWidget(QWidget *parent) : KbdWidget(parent) void ExpressionWidget::initLayout() { + QVBoxLayout *mainLayout = new QVBoxLayout; + QHBoxLayout *hLayout = new QHBoxLayout; QSplitter *splitter = new QSplitter(Qt::Horizontal,this); @@ -37,17 +39,25 @@ void ExpressionWidget::initLayout() m_tree = new KbdTreeView(splitter); m_tree->setModel(m_treeModel); m_tree->setHeaderVisible(false); + m_tree->hide(); //把树隐藏,使用tabbar代替 splitter->addWidget(m_tree); + //因为借用了m_treeModel的解析数据,所以tabbar初始化必须放在m_treeModel后面 + m_mainTabBar = initMainTabBar(m_treeModel); + mainLayout->addWidget(m_mainTabBar); + m_stack = new QStackedWidget(splitter); initStack(); splitter->addWidget(m_stack); splitter->setSizes(QList()<<100<<800); hLayout->addWidget(splitter); - this->setLayout(hLayout); + + mainLayout->addLayout(hLayout); + this->setLayout(mainLayout); connect(m_tree,SIGNAL(clicked(const QModelIndex &)),this,SLOT(onLeftTreeClick(const QModelIndex &))); + connect(m_mainTabBar,SIGNAL(currentChanged(int)),this,SLOT(onMainTabBarCurrentChanged(int))); } void ExpressionWidget::initStack() @@ -65,12 +75,16 @@ QWidget *ExpressionWidget::initGroupWidget() QVBoxLayout *vLayout1 = new QVBoxLayout; QToolBar *bar = new QToolBar(widget); m_tableGroup = new KbdTable(widget,REWRITE_COMMIT); - bar->setIconSize(QSize(24,24)); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddGroup())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveGroup())); + bar->widgetForAction(act)->setObjectName("icon_delete"); + act = bar->addAction(tr("撤销更改"),m_tableGroup,SLOT(onUndo())); + bar->widgetForAction(act)->setObjectName("icon_undo"); + act = bar->addAction(tr("保存"),this,SLOT(onSaveGroup())); + bar->widgetForAction(act)->setObjectName("icon_save"); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddGroup())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveGroup())); - bar->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_tableGroup,SLOT(onUndo())); - bar->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveGroup())); vLayout1->addWidget(bar); vLayout1->addWidget(m_tableGroup); vLayout1->setMargin(0); @@ -89,9 +103,11 @@ QWidget *ExpressionWidget::initFuncWidget() QVBoxLayout *vLayoutTree = new QVBoxLayout; QToolBar *bar = new QToolBar(widgetTree); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加"),this,SLOT(onAddFunc())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除"),this,SLOT(onRemoveFunc())); + QAction* act = nullptr; + act = bar->addAction(tr("添加"),this,SLOT(onAddFunc())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除"),this,SLOT(onRemoveFunc())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_treeFunc = new KbdTreeView(widgetTree); KbdSqlTreeModel *treeModel = new KbdSqlTreeModel(Common::getTreePath("calcFunc.xml"),this); @@ -110,7 +126,7 @@ QWidget *ExpressionWidget::initFuncWidget() QGroupBox *box = new QGroupBox(tr("函数定义"),widgetDetail); QHBoxLayout *boxLayout = new QHBoxLayout; - m_teFunc = new ScriptFormWidget(box); + m_teFunc = new ScriptForm_lua::ScriptFormWidget(box); boxLayout->addWidget(m_teFunc); box->setLayout(boxLayout); @@ -146,10 +162,13 @@ QWidget *ExpressionWidget::initParamWidget() m_cbSubSystem = new QComboBox(widgetLeft); m_cbSubSystem->setView(new QListView); QToolBar *barleft = new QToolBar(widgetLeft); - barleft->setIconSize(QSize(24,24)); - barleft->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddOutPut())); - barleft->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyOutPut())); - barleft->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveOutPut())); + QAction* act = nullptr; + act = barleft->addAction(tr("添加记录"),this,SLOT(onAddOutPut())); + barleft->widgetForAction(act)->setObjectName("icon_add"); + act = barleft->addAction(tr("修改记录"),this,SLOT(onModifyOutPut())); + barleft->widgetForAction(act)->setObjectName("icon_edit"); + act = barleft->addAction(tr("删除记录"),this,SLOT(onRemoveOutPut())); + barleft->widgetForAction(act)->setObjectName("icon_delete"); QGroupBox *box = new QGroupBox(tr("计算输出点列表"),widgetLeft); QVBoxLayout *vl = new QVBoxLayout; @@ -174,11 +193,14 @@ QWidget *ExpressionWidget::initParamWidget() QVBoxLayout *vLayoutRight = new QVBoxLayout; QToolBar *barRight = new QToolBar(widgetRight); m_tableInput = new KbdTable(box,REWRITE_COMMIT); - barRight->setIconSize(QSize(24,24)); - barRight->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddInput())); - barRight->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),m_tableInput,SLOT(onRemoveRowNotCommit())); - barRight->addAction(QIcon(":/icons/icons/undo.png"),tr("撤销更改"),m_tableInput,SLOT(onUndo())); - barRight->addAction(QIcon(":/icons/icons/save.png"),tr("保存"),this,SLOT(onSaveInput())); + act = barRight->addAction(tr("添加记录"),this,SLOT(onAddInput())); + barRight->widgetForAction(act)->setObjectName("icon_add"); + act = barRight->addAction(tr("删除记录"),m_tableInput,SLOT(onRemoveRowNotCommit())); + barRight->widgetForAction(act)->setObjectName("icon_delete"); + act = barRight->addAction(tr("撤销更改"),m_tableInput,SLOT(onUndo())); + barRight->widgetForAction(act)->setObjectName("icon_undo"); + act = barRight->addAction(tr("保存更改"),this,SLOT(onSaveInput())); + barRight->widgetForAction(act)->setObjectName("icon_save"); box = new QGroupBox(tr("输入变量列表"),widgetLeft); vl = new QVBoxLayout; @@ -234,6 +256,9 @@ void ExpressionWidget::initData() } } + //默认展示第一个tab + m_mainTabBar->setCurrentIndex(0); + onMainTabBarCurrentChanged(0); } void ExpressionWidget::reloadListWidget(QListWidget *listWidget, const QList &items) @@ -271,6 +296,23 @@ bool ExpressionWidget::getLocationInfo(const QString &keyIdTag, QString &locatio return false; } +QTabBar *ExpressionWidget::initMainTabBar(const KbdSqlTreeModel *pModel) +{ + QTabBar *mainTabBar = new QTabBar; + mainTabBar->setObjectName("expressionMainTabBar"); + mainTabBar->setExpanding(false); + + for(int i = 0;i < pModel->rowCount();i++) + { + QStandardItem *item = pModel->item(i,0); + + mainTabBar->addTab(item->icon(),item->text()); + mainTabBar->setTabData(i,item->data(Common::ClickRole)); + } + + return mainTabBar; +} + void ExpressionWidget::onLeftTreeClick(const QModelIndex &index) { if(!index.isValid()) @@ -302,6 +344,11 @@ void ExpressionWidget::onLeftTreeClick(const QModelIndex &index) m_stack->setCurrentIndex(m_stack->count() - 1); } +void ExpressionWidget::onMainTabBarCurrentChanged(int index) +{ + onLeftTreeClick(m_treeModel->index(index,0)); +} + void ExpressionWidget::onAddGroup() { KbdTableModel *model = qobject_cast(m_tableGroup->model()); @@ -547,6 +594,7 @@ void ExpressionWidget::onAddOutPut() return; KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("新增计算输出点")); dlg.panel()->setDisplayRow(model,model->rowCount()); if(dlg.exec() == QDialog::Rejected) @@ -607,6 +655,7 @@ void ExpressionWidget::onModifyOutPut() } KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("修改计算输出点")); dlg.panel()->setDisplayRow(model,0); if(dlg.exec() == QDialog::Rejected) diff --git a/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.h b/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.h index 961290f7..1852be11 100644 --- a/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.h +++ b/product/src/tools/model_plugin/ExpressionWidget/expressionwidget.h @@ -6,6 +6,7 @@ #endif #include "kbdwidget.h" +#include "ScriptForm/ScriptForm.h" class KbdSqlTreeModel; class KbdTreeView; @@ -16,6 +17,9 @@ class QTextEdit; class QComboBox; class QListWidget; class QListWidgetItem; +class QTabBar; + +using namespace ScriptForm_lua; class ScriptFormWidget; class ExpressionWidget : public KbdWidget @@ -40,18 +44,22 @@ private: KbdTreeView *m_treeFunc; KbdPropertyPanel *m_panelFunc; - ScriptFormWidget* m_teFunc; + ScriptForm_lua::ScriptFormWidget* m_teFunc; QComboBox *m_cbLocation; QComboBox *m_cbSubSystem; QListWidget * m_listOutPut; KbdTable *m_tableInput; + QTabBar *m_mainTabBar; void reloadListWidget(QListWidget *listWidget, const QList &items); bool getLocationInfo(const QString &keyIdTag,QString &locationId,QString &subSystem); + QTabBar* initMainTabBar(const KbdSqlTreeModel *pModel); + private slots: void onLeftTreeClick(const QModelIndex &index); + void onMainTabBarCurrentChanged(int index); void onAddGroup(); void onRemoveGroup(); diff --git a/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSetting.cpp b/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSetting.cpp index d4f96b95..0a47f7c4 100644 --- a/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSetting.cpp +++ b/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSetting.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "pub_widget/MessageBox.h" #include #include #include @@ -238,7 +238,7 @@ void IPSettingWidget::onShowModifyResult(QString result) } if(result.contains("Network")) { - QMessageBox::information(this,tr("消息"),tr("修改网口参数成功")); + N_MessageBox::information(this,tr("消息"),tr("修改网口参数成功")); m_timer->start(3000); if(!m_progressBar) @@ -262,7 +262,7 @@ void IPSettingWidget::onShowModifyResult(QString result) } if(result.contains("Time")) { - QMessageBox::information(this,tr("消息"),tr("修改管理机时间成功")); + N_MessageBox::information(this,tr("消息"),tr("修改管理机时间成功")); setOptEnable(true); } } @@ -277,7 +277,7 @@ void IPSettingWidget::onUpdateProgress() { m_timer->stop(); m_progressBar->hide(); - QMessageBox::information(this,tr("消息"),tr("重启超时,请检查设备")); + N_MessageBox::information(this,tr("消息"),tr("重启超时,请检查设备")); } } m_Pcs->findPcsDevice(m_strRebootDev); diff --git a/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSettingPluginWidget.h b/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSettingPluginWidget.h index 6d6aec24..59197f3b 100644 --- a/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSettingPluginWidget.h +++ b/product/src/tools/model_plugin/PCPMS_IP_Setting/IPSettingPluginWidget.h @@ -7,7 +7,7 @@ class IPSettingPluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/PCPMS_IP_Setting/PCPMS_IP_Setting.pro b/product/src/tools/model_plugin/PCPMS_IP_Setting/PCPMS_IP_Setting.pro index 8be0a4cd..c84e7fec 100644 --- a/product/src/tools/model_plugin/PCPMS_IP_Setting/PCPMS_IP_Setting.pro +++ b/product/src/tools/model_plugin/PCPMS_IP_Setting/PCPMS_IP_Setting.pro @@ -48,3 +48,4 @@ LIBS += \ -lpub_utility_api \ -llog4cplus \ -lpub_logger_api +LIBS += -lpub_widget diff --git a/product/src/tools/model_plugin/PCPMS_Screen_Brightness_Setting/ScreenBrightnessSettingPluginWidget.h b/product/src/tools/model_plugin/PCPMS_Screen_Brightness_Setting/ScreenBrightnessSettingPluginWidget.h index d29dc5ab..1eea5be7 100644 --- a/product/src/tools/model_plugin/PCPMS_Screen_Brightness_Setting/ScreenBrightnessSettingPluginWidget.h +++ b/product/src/tools/model_plugin/PCPMS_Screen_Brightness_Setting/ScreenBrightnessSettingPluginWidget.h @@ -7,7 +7,7 @@ class ScreenBrightnessSettingPluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/StaticsWidget/StaticsWidget.pro b/product/src/tools/model_plugin/StaticsWidget/StaticsWidget.pro index 1063c4f7..aa72ff17 100644 --- a/product/src/tools/model_plugin/StaticsWidget/StaticsWidget.pro +++ b/product/src/tools/model_plugin/StaticsWidget/StaticsWidget.pro @@ -42,6 +42,7 @@ INCLUDEPATH += $$PWD\ LIBS += -lmodel_common -lmodel_excel LIBS += -lmodel_table -ldb_base_api +LIBS += -lpub_widget HEADERS += \ kbdpointdlg.h \ @@ -57,5 +58,7 @@ SOURCES += \ staticswidget.cpp \ statlinkinstdlg.cpp +TRANSLATIONS += statics_analysis_EN.ts + diff --git a/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.cpp b/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.cpp index 4bc90cad..ff259d67 100644 --- a/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.cpp +++ b/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.cpp @@ -8,8 +8,9 @@ #include "kbddbdesign.h" #include -KbdPointDlg::KbdPointDlg(QWidget *parent) : QDialog(parent) +KbdPointDlg::KbdPointDlg(QWidget *parent) : CustomDialog(parent) { + setWindowTitle(tr("选择测点")); initLayout(); initData(); } diff --git a/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.h b/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.h index 93808d5e..5f4620c0 100644 --- a/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.h +++ b/product/src/tools/model_plugin/StaticsWidget/kbdpointdlg.h @@ -3,12 +3,13 @@ #include #include +#include "pub_widget/CustomDialog.h" class QComboBox; class QLineEdit; class MyPointListWidget; class MyDevListWidget; -class KbdPointDlg : public QDialog +class KbdPointDlg : public CustomDialog { Q_OBJECT public: diff --git a/product/src/tools/model_plugin/StaticsWidget/staticspluginwidget.h b/product/src/tools/model_plugin/StaticsWidget/staticspluginwidget.h index 3b644244..3f522e27 100644 --- a/product/src/tools/model_plugin/StaticsWidget/staticspluginwidget.h +++ b/product/src/tools/model_plugin/StaticsWidget/staticspluginwidget.h @@ -7,7 +7,7 @@ class StaticsPluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/StaticsWidget/staticswidget.cpp b/product/src/tools/model_plugin/StaticsWidget/staticswidget.cpp index ee9bbe15..2cc5440e 100644 --- a/product/src/tools/model_plugin/StaticsWidget/staticswidget.cpp +++ b/product/src/tools/model_plugin/StaticsWidget/staticswidget.cpp @@ -16,7 +16,7 @@ #include #include "kbdtabledatamgr.h" #include "kbddbdesign.h" -#include +#include "pub_widget/MessageBox.h" #include #include "kbdcheckrole.h" #include @@ -28,6 +28,8 @@ #include "statlinkinstdlg.h" #include #include "kbdtable.h" +#include +#include "pub_widget/PubWidgetInit.h" #define CLK_STATICS_TEMP "CLK_STATICS_TEMP" #define CLK_STATICS_INST "CLK_STATICS_INST" @@ -41,6 +43,7 @@ StaticsWidget::StaticsWidget(QWidget *parent) : KbdWidget(parent) { + loadTranslate(); initLayout(); initMenu(); initData(); @@ -53,21 +56,47 @@ StaticsWidget::~StaticsWidget() void StaticsWidget::initLayout() { + QVBoxLayout *mainLayout = new QVBoxLayout; + QHBoxLayout *hLayout = new QHBoxLayout; QSplitter *hSplitter = new QSplitter(Qt::Horizontal,this); m_tree = new KbdTreeView(hSplitter); m_tree->setHeaderVisible(false); m_treeModel = new KbdSqlTreeModel(Common::getTreePath("staticsTree.xml"),this); m_tree->setModel(m_treeModel); + m_tree->hide(); //把树隐藏,使用tabbar代替 hSplitter->addWidget(m_tree); + //因为借用了m_treeModel的解析数据,所以tabbar初始化必须放在m_treeModel后面 + m_mainTabBar = initMainTabBar(m_treeModel); + mainLayout->addWidget(m_mainTabBar); + m_stackForTree = new QStackedWidget(hSplitter); initStackWidget(); hSplitter->addWidget(m_stackForTree); hSplitter->setSizes(QList()<<100<<1000); hLayout->addWidget(hSplitter); - this->setLayout(hLayout); + + mainLayout->addLayout(hLayout); + this->setLayout(mainLayout); +} + +QTabBar *StaticsWidget::initMainTabBar(const KbdSqlTreeModel *pModel) +{ + QTabBar *mainTabBar = new QTabBar; + mainTabBar->setObjectName("staticsMainTabBar"); + mainTabBar->setExpanding(false); + + for(int i = 0;i < pModel->rowCount();i++) + { + QStandardItem *item = pModel->item(i,0); + + mainTabBar->addTab(item->icon(),item->text()); + mainTabBar->setTabData(i,item->data(Common::ClickRole)); + } + + return mainTabBar; } void StaticsWidget::initStackWidget() @@ -84,11 +113,14 @@ QWidget *StaticsWidget::initFuncTempWidget() QWidget *widgetLeft = new QWidget(hSplitter); QToolBar *bar = new QToolBar(widgetLeft); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddFuncTemp())); - bar->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyFuncTemp())); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddFuncTemp())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("修改记录"),this,SLOT(onModifyFuncTemp())); + bar->widgetForAction(act)->setObjectName("icon_edit"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveFuncTemp())); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveFuncTemp())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_listFuncTemp = new QListWidget(widgetLeft); @@ -191,12 +223,15 @@ QWidget *StaticsWidget::initInstWidget() QToolBar *bar = new QToolBar(widgetLeft); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddFuncInst())); - bar->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyFuncInst())); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddFuncInst())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("修改记录"),this,SLOT(onModifyFuncInst())); + bar->widgetForAction(act)->setObjectName("icon_edit"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveFuncInst())); - bar->addAction(tr("禁用所有统计实例"),this,SLOT(onForbiddenInsts())); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveFuncInst())); + bar->widgetForAction(act)->setObjectName("icon_delete"); + act = bar->addAction(tr("禁用所有统计实例"),this,SLOT(onForbiddenInsts())); m_listFuncInst = new MyStatInstListWidget(widgetLeft); m_listFuncInst->setAcceptDrops(true); @@ -266,11 +301,14 @@ QWidget *StaticsWidget::initLinkWidget() QWidget *widgetLeft = new QWidget(hSplitter); QToolBar *bar = new QToolBar(widgetLeft); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddLinkTemp())); - bar->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyLinkTemp())); + QAction* act = nullptr; + act = bar->addAction(tr("添加记录"),this,SLOT(onAddLinkTemp())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("修改记录"),this,SLOT(onModifyLinkTemp())); + bar->widgetForAction(act)->setObjectName("icon_edit"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveLinkTemp())); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveLinkTemp())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_listLinkTemp = new QListWidget(widgetLeft); @@ -287,11 +325,13 @@ QWidget *StaticsWidget::initLinkWidget() QGroupBox* box = new QGroupBox(tr("输入参数关联"),widgetRight); bar = new QToolBar(this); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddLinkInputTable())); - bar->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyLinkInputTable())); + act = bar->addAction(tr("添加记录"),this,SLOT(onAddLinkInputTable())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("修改记录"),this,SLOT(onModifyLinkInputTable())); + bar->widgetForAction(act)->setObjectName("icon_edit"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveLinkInputTable())); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveLinkInputTable())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_TableLinkInput = new KbdTable(this); QVBoxLayout *vLayout = new QVBoxLayout; @@ -302,11 +342,13 @@ QWidget *StaticsWidget::initLinkWidget() box = new QGroupBox(tr("输出参数关联"),widgetRight); bar = new QToolBar(this); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加记录"),this,SLOT(onAddLinkOutputTable())); - bar->addAction(QIcon(":/icons/icons/modify.png"),tr("修改记录"),this,SLOT(onModifyLinkOutputTable())); + act = bar->addAction(tr("添加记录"),this,SLOT(onAddLinkOutputTable())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("修改记录"),this,SLOT(onModifyLinkOutputTable())); + bar->widgetForAction(act)->setObjectName("icon_edit"); bar->addSeparator(); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除记录"),this,SLOT(onRemoveLinkOutputTable())); + act = bar->addAction(tr("删除记录"),this,SLOT(onRemoveLinkOutputTable())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_TableLinkOutput = new KbdTable(this); vLayout = new QVBoxLayout; @@ -423,6 +465,7 @@ void StaticsWidget::initData() connect(m_teFuncOutputTemp,&QTextEdit::customContextMenuRequested,[&]{m_menuFuncReturn->exec(QCursor::pos());}); connect(m_teFuncInputTemp,&QTextEdit::customContextMenuRequested,[&]{m_menuFuncHead->exec(QCursor::pos());}); connect(m_tree,SIGNAL(clicked(const QModelIndex &)),this,SLOT(onLeftTreeClick(const QModelIndex &))); + connect(m_mainTabBar,SIGNAL(currentChanged(int)),this,SLOT(onMainTabBarCurrentChanged(int))); connect(m_listFuncTemp,SIGNAL(doubleClicked(const QModelIndex &)),this,SLOT(onModifyFuncTemp())); connect(m_listFuncInst,SIGNAL(doubleClicked(const QModelIndex &)),this,SLOT(onModifyFuncInst())); connect(m_listFuncTemp,SIGNAL(clicked(const QModelIndex &)),this,SLOT(onListFuncTempClicked())); @@ -453,6 +496,17 @@ void StaticsWidget::initData() connect(m_TableLinkOutput->model(), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), m_TableLinkOutput, SLOT(resizeColumnsToContents())); + //默认展示第一个tab + m_mainTabBar->setCurrentIndex(0); + onMainTabBarCurrentChanged(0); +} + +void StaticsWidget::loadTranslate() +{ + QTranslator * qtTranslator = new QTranslator; + qtTranslator->load(Common::getTranslatePath("statics_analysis_EN.qm")); + qApp->installTranslator(qtTranslator); + iot_public::installTranslator(Common::getLanguage().toStdString()); } void StaticsWidget::addListItem(QListWidget *list, const QString &tag, const QString &desc) @@ -970,6 +1024,11 @@ void StaticsWidget::onLeftTreeClick(const QModelIndex &index) m_stackForTree->setCurrentIndex(m_stackForTree->count() - 1); } +void StaticsWidget::onMainTabBarCurrentChanged(int index) +{ + onLeftTreeClick(m_treeModel->index(index,0)); +} + void StaticsWidget::onAddFuncTemp() { KbdTableModel *modelFuncTemp = KbdTableDataMgr::getInstance()->createModel(TBL_STAT_TEMPLATE_DEF); @@ -977,6 +1036,7 @@ void StaticsWidget::onAddFuncTemp() return; KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("新增统计模板")); dlg.panel()->setDisplayRow(modelFuncTemp,modelFuncTemp->rowCount()); if(dlg.exec() == QDialog::Rejected) @@ -1031,6 +1091,7 @@ void StaticsWidget::onModifyFuncTemp() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true, this); + dlg.setWindowTitle(tr("修改统计模板")); dlg.panel()->setDisplayRow(modelFuncTemp,0); if(dlg.exec()) { @@ -1327,6 +1388,7 @@ void StaticsWidget::onAddLinkTemp() return; KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("新增统计关联")); dlg.panel()->setDisplayRow(modelLinkTemp,0); if(dlg.exec() == QDialog::Rejected) return; @@ -1380,6 +1442,7 @@ void StaticsWidget::onModifyLinkTemp() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true, this); + dlg.setWindowTitle(tr("修改统计关联")); dlg.panel()->setDisplayRow(modelLinkTemp,0); //不允许切换模板 @@ -1763,6 +1826,7 @@ void StaticsWidget::onAddFuncInst() return; KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("新增统计实例")); connect(dlg.panel(),&KbdPropertyPanel::signalPropertyChanged, [&dlg](const QString &sqlName, const QString &text) { @@ -1844,6 +1908,7 @@ void StaticsWidget::onModifyFuncInst() } KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("修改统计实例")); connect(dlg.panel(),&KbdPropertyPanel::signalPropertyChanged, [&dlg](const QString &sqlName, const QString &text) { @@ -1999,6 +2064,7 @@ void StaticsWidget::onAddLinkInputTable() if(retStr.isEmpty()) { KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("新增输入参数")); dlg.panel()->setDisplayRow(model,model->rowCount()); dlg.panel()->setPropertyValue(CN_LINK_TAG,devTag); dlg.panel()->setDotStringPrefix(CN_TAG_NAME,item->data(Qt::UserRole).toString()); @@ -2038,6 +2104,7 @@ void StaticsWidget::onModifyLinkInputTable() if(retStr.isEmpty()) { KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("修改输入参数")); dlg.panel()->setDisplayRow(model,index.row()); if(dlg.exec()) @@ -2115,6 +2182,7 @@ void StaticsWidget::onAddLinkOutputTable() if(retStr.isEmpty()) { KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("新增输出参数")); dlg.panel()->setDisplayRow(model,model->rowCount()); dlg.panel()->setPropertyValue(CN_LINK_TAG,devTag); dlg.panel()->setDotStringPrefix(CN_TAG_NAME,item->data(Qt::UserRole).toString()); @@ -2154,6 +2222,7 @@ void StaticsWidget::onModifyLinkOutputTable() if(retStr.isEmpty()) { KbdPropertyDlg dlg(false, this); + dlg.setWindowTitle(tr("修改输出参数")); dlg.panel()->setDisplayRow(model,index.row()); if(dlg.exec()) @@ -4517,10 +4586,10 @@ void StaticsWidget::onDropDevToInst(int index, const QStringList &itemDevs) qDebug()<<"strSrc:"<text()).arg(list.at(2)), - QMessageBox::Yes, - QMessageBox::No)) + N_MessageBox::Yes, + N_MessageBox::No)) return; diff --git a/product/src/tools/model_plugin/StaticsWidget/staticswidget.h b/product/src/tools/model_plugin/StaticsWidget/staticswidget.h index c147e437..7ade7dca 100644 --- a/product/src/tools/model_plugin/StaticsWidget/staticswidget.h +++ b/product/src/tools/model_plugin/StaticsWidget/staticswidget.h @@ -20,7 +20,7 @@ class QTreeView; class KbdTableModel; class MyStatInstListWidget; class KbdTable; - +class QTabBar; class StaticsWidget : public KbdWidget { @@ -31,12 +31,14 @@ public: private: void initLayout(); + QTabBar* initMainTabBar(const KbdSqlTreeModel *pModel); void initStackWidget(); QWidget *initFuncTempWidget();//模板控件 QWidget *initInstWidget();//实例控件 QWidget *initLinkWidget();//关联控件 void initMenu(); void initData(); + void loadTranslate(); void addListItem(QListWidget *list, const QString &tag,const QString &desc); void reloadListItem(QListWidget *list, const QList &items); @@ -67,6 +69,7 @@ private: bool isExistLinkInst(const QString &linkTag); private slots: void onLeftTreeClick(const QModelIndex &index); + void onMainTabBarCurrentChanged(int index); void onAddFuncTemp(); void onModifyFuncTemp(); @@ -161,6 +164,8 @@ private: //树形控件 KbdTreeView *m_tree; KbdSqlTreeModel* m_treeModel; + QTabBar *m_mainTabBar; + //堆栈控件 QStackedWidget *m_stackForTree; diff --git a/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.cpp b/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.cpp index 2dc3ed1b..47ac14c6 100644 --- a/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.cpp +++ b/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.cpp @@ -7,7 +7,7 @@ #include #include #include "kbddbdesign.h" -#include +#include "pub_widget/MessageBox.h" #include #include #include @@ -31,12 +31,12 @@ StatLinkInstDlg::StatLinkInstDlg(QWidget *parent, QString strInstTag, QString strInstDesc): - QDialog(parent), + CustomDialog(parent), m_strDestInstTag(strInstTag), m_strDestInstDesc(strInstDesc), m_emCurDevDest(EmNone) { - + setWindowTitle(tr("统计关联")); this->setMinimumWidth(900); this->setMinimumHeight(500); initLayout(); @@ -68,10 +68,10 @@ void StatLinkInstDlg::onClose() void StatLinkInstDlg::onStartLink() { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("是否开始关联统计实例[ %1 ]\n这将清空现有的参数组的子参数以及参数的测点绑定").arg(m_strDestInstDesc), - QMessageBox::Yes, - QMessageBox::No)) + N_MessageBox::Yes, + N_MessageBox::No)) { return; } @@ -338,20 +338,20 @@ void StatLinkInstDlg::onLinkPara() QTreeWidgetItem* item = paraTree->currentItem(); if(isItemGrp(item)) { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("开始关联统计实例[ %1 ]\n这将清空与[ %2 ]有关的参数组下的子参数和关联\n是否继续").arg(m_strDestInstDesc).arg(item->text(0)), - QMessageBox::Yes, - QMessageBox::No)) + N_MessageBox::Yes, + N_MessageBox::No)) { return; } } else { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("开始关联统计实例[ %1 ]\n这将清空[ %2 ]有关的关联和\n是否继续").arg(m_strDestInstDesc).arg(item->text(0)), - QMessageBox::Yes, - QMessageBox::No)) + N_MessageBox::Yes, + N_MessageBox::No)) { return; } @@ -387,20 +387,20 @@ void StatLinkInstDlg::onLinkRet() QTreeWidgetItem* item = retTree->currentItem(); if(isItemGrp(item)) { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("开始关联统计实例[ %1 ]\n这将清空与[ %2 ]有关的参数组下的子参数和关联\n是否继续").arg(m_strDestInstDesc).arg(item->text(0)), - QMessageBox::Yes, - QMessageBox::No)) + N_MessageBox::Yes, + N_MessageBox::No)) { return; } } else { - if(QMessageBox::No == QMessageBox::information(this,tr("消息"), + if(N_MessageBox::No == N_MessageBox::information(this,tr("消息"), tr("开始关联统计实例[ %1 ]\n这将清空[ %2 ]有关的关联和\n是否继续").arg(m_strDestInstDesc).arg(item->text(0)), - QMessageBox::Yes, - QMessageBox::No)) + N_MessageBox::Yes, + N_MessageBox::No)) { return; } @@ -793,29 +793,17 @@ void StatLinkInstDlg::addRow2RetMap(int row, QWidget *retTree) void StatLinkInstDlg::onMsg(const QString &text) { - QMessageBox m( QMessageBox::Information, tr("消息"),text, QMessageBox::NoButton, this ); - if(isInit == true) - m.exec(); - else - { - QSize mSize = m.sizeHint(); // here's what you want, not m.width()/height() - QRect screenRect = QDesktopWidget().screen()->rect(); - m.move( QPoint( screenRect.width()/2 - mSize.width()/2, - screenRect.height()/2 - mSize.height()/2 ) ); - - m.exec(); - } - + N_MessageBox::information(this,tr("消息"),text ); } void StatLinkInstDlg::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void StatLinkInstDlg::onStartTransactionError(const QString &erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } QString StatLinkInstDlg::getFirstTag(const QString &str, const QString &separater) diff --git a/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.h b/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.h index feab4dfd..16b99b6e 100644 --- a/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.h +++ b/product/src/tools/model_plugin/StaticsWidget/statlinkinstdlg.h @@ -9,10 +9,10 @@ #include #include #include "kbdwidget.h" +#include "pub_widget/CustomDialog.h" - -class StatLinkInstDlg : public QDialog +class StatLinkInstDlg : public CustomDialog { Q_OBJECT public: diff --git a/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstPluginWidget.h b/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstPluginWidget.h index 6bb15c95..5b33ae6a 100644 --- a/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstPluginWidget.h +++ b/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstPluginWidget.h @@ -7,7 +7,7 @@ class SystemConfigPluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstWizard.pro b/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstWizard.pro index 20ec8c48..46e0f09c 100644 --- a/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstWizard.pro +++ b/product/src/tools/model_plugin/iec61850InstWizard/iec61850InstWizard.pro @@ -40,6 +40,8 @@ INCLUDEPATH += $$PWD\ LIBS += -lmodel_common -lmodel_excel -lboost_system -lpub_utility_api LIBS += -lmodel_table -llibcfgtool -llog4cplus -lpub_logger_api +LIBS += -lpub_widget + HEADERS += \ iec61850InstPluginWidget.h \ diff --git a/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.cpp b/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.cpp index 627a1f6d..f3e5e73b 100644 --- a/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.cpp +++ b/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include "pub_widget/MessageBox.h" #include #include #include @@ -50,7 +50,7 @@ kbdInst61850DevWizard::kbdInst61850DevWizard(QWidget *parent) : QWizard(parent) connect(m_SecondInstWizardPage,&kbdSecondInstWizardPage::sigMsg,this,&kbdInst61850DevWizard::onMsg); connect(m_ThirdInstWizardPage,&kbdThirdInstWizardPage::sigMsg,this,&kbdInst61850DevWizard::onMsg); connect(m_firstInstWizardPage->m_LinEdit,&QLineEdit::textChanged,this,&kbdInst61850DevWizard::onCfgFilePathChange); - resize(1000,610); + resize(1080,610); } void kbdInst61850DevWizard::onCurrentIdChanged(int id) @@ -86,6 +86,17 @@ bool kbdInst61850DevWizard::validateCurrentPage() addPage(m_ThirdInstWizardPage); } + if(m_SecondInstWizardPage->m_InstType == Update) + { + m_SecondInstWizardPage->m_pOnlyUpdate61850->show(); + m_SecondInstWizardPage->m_bOnlyUpdate61850 = m_SecondInstWizardPage->m_pOnlyUpdate61850->isChecked(); + } + else + { + m_SecondInstWizardPage->m_pOnlyUpdate61850->hide(); + m_SecondInstWizardPage->m_bOnlyUpdate61850 = false; + } + return m_SecondInstWizardPage->onUpdataTable(); } else if(currentId() == 2) @@ -154,10 +165,13 @@ void kbdInst61850DevWizard::accept() break; } - if(!creatDevGrp()) + if(!m_SecondInstWizardPage->m_bOnlyUpdate61850) { - m_errorMsg = tr("创建设备组失败!"); - break; + if(!creatDevGrp())//todo:caodingfa更新时前面将设备组都删除了 + { + m_errorMsg = tr("创建设备组失败!"); + break; + } } //开启实例化 @@ -520,6 +534,12 @@ bool kbdInst61850DevWizard::creatDevGrp() for(auto iterGrp = m_listGrpInfo.begin();iterGrp!=m_listGrpInfo.end();iterGrp++) { QString strTagName = locationTag + "." + iterGrp->at(0); + //如果已经存在设备组,跳过,用来实现不同套件创建到同一个设备组下 + if(m_SecondInstWizardPage->m_mapExistDevGrp2PluginName.contains(strTagName)) + { + continue; + } + QString strDesCol = iterGrp->at(1); QString rtuTag = iterGrp->at(2); @@ -584,7 +604,12 @@ void kbdInst61850DevWizard::inst61850Dev() FesDevDesList << iter.value().at(i).at(4); rtuTagList << iter.value().at(i).at(6); } - w.instPluginByFesDev(pluginName,rtuTagList,devGrpList,FesDevTagList,FesDevDesList); + + if(!m_SecondInstWizardPage->m_bOnlyUpdate61850) + { + w.instPluginByFesDev(pluginName,rtuTagList,devGrpList,FesDevTagList,FesDevDesList); + } + sigInst61850DevProcess(process++); } @@ -635,7 +660,7 @@ bool kbdInst61850DevWizard::set61850Cfg() void kbdInst61850DevWizard::onMsg(const QString &text) { - QMessageBox::information(this,tr("消息"),text); + N_MessageBox::information(this,tr("消息"),text); } void kbdInst61850DevWizard::onCfgFilePathChange() @@ -787,6 +812,11 @@ void kbdSecondInstWizardPage::initLayout() HLayout->addWidget(m_cbRegion); HLayout->addSpacing(50); + m_pOnlyUpdate61850 = new QCheckBox(tr("只更新61850"),this); + m_pOnlyUpdate61850->setChecked(true); + HLayout->addWidget(m_pOnlyUpdate61850); + m_bOnlyUpdate61850 = m_pOnlyUpdate61850->isChecked(); + QPushButton* btnSelectAll = new QPushButton(tr("全选"),this); HLayout->addWidget(btnSelectAll); @@ -829,6 +859,10 @@ void kbdSecondInstWizardPage::initLayout() connect(btnSelectOver,&QPushButton::clicked,this,&kbdSecondInstWizardPage::onSelectOver); connect(m_refresh,&QPushButton::clicked,this,&kbdSecondInstWizardPage::onUpdataTable); connect(m_tableCfgInfo,&QTableWidget::itemChanged,this,&kbdSecondInstWizardPage::onUpdateIP); + // QCheckBox 在状态改变时会发送一个 stateChanged 信号,该信号有一个参数 state; + connect(m_pOnlyUpdate61850, &QCheckBox::stateChanged, [=](int state){ + m_bOnlyUpdate61850 = m_pOnlyUpdate61850->isChecked(); + }); } void kbdSecondInstWizardPage::initData() @@ -1431,7 +1465,17 @@ void kbdSecondInstWizardPage::delete61850Device(EM_INST_TYPE type) QStringList listError; for(int i = 0;i < m_listFesTag.size();i++) { - listSql << QString("delete from dev_group where TAG_NAME = '%1';").arg(m_listFesTag.at(i).first()); + //在map中存在表示原来的设备组已经存在,所以删除时只删除设备组下对应的设备,原来的保持不动 + if(m_mapExistDevGrp2PluginName.contains(m_listFesTag.at(i).first())) + { + QString strDevGrp = m_listFesTag.at(i).first(); + QString strPluginName = m_mapExistDevGrp2PluginName[m_listFesTag.at(i).first()]; + listSql << QString("delete from dev_info where TAG_NAME in (SELECT concat('%1_',temp_name) FROM temp_plugin_fes_dev_map WHERE plugin_name='%2');").arg(strDevGrp).arg(strPluginName); + } + else + { + listSql << QString("delete from dev_group where TAG_NAME = '%1';").arg(m_listFesTag.at(i).first()); + } if(type == Delele) { @@ -1454,7 +1498,11 @@ void kbdSecondInstWizardPage::delete61850Device(EM_INST_TYPE type) } } - KbdTableDataMgr::getInstance()->executeOnly(listSql); + if(!m_bOnlyUpdate61850) + { + KbdTableDataMgr::getInstance()->executeOnly(listSql); + } + m_CfgModel->delete61850Device(listFesTag,listError); } @@ -1476,13 +1524,14 @@ bool kbdSecondInstWizardPage::checkDevGrp() return false; } + m_mapExistDevGrp2PluginName.clear(); m_listFesTag.clear(); m_listIedName.clear(); QStringList listFesDevGrp; for(int i = 0;i < m_tableCfgInfo->rowCount();i++) { - QString devGrpTag,fesGrpTag, chanTag, RTUTag; + QString pluginLable,devGrpTag,fesGrpTag, chanTag, RTUTag; QTableWidgetItem* item = m_tableCfgInfo->item(i,0); if(item->checkState() == Qt::Unchecked) @@ -1490,6 +1539,9 @@ bool kbdSecondInstWizardPage::checkDevGrp() item = m_tableCfgInfo->item(i,1); m_listIedName << item->text(); + item = m_tableCfgInfo->item(i,2); + pluginLable = item->data(Qt::UserRole).toString(); + item = m_tableCfgInfo->item(i,3); devGrpTag = item->text(); @@ -1506,6 +1558,9 @@ bool kbdSecondInstWizardPage::checkDevGrp() << locationTagName + "." + subSystemTag + "." + chanTag + "." + RTUTag << locationTagName + "." + subSystemTag + "." + chanTag << locationTagName + "." + subSystemTag + "." + chanTag + "." + RTUTag + "." + fesGrpTag); listFesDevGrp << locationTagName + "." + subSystemTag + "." + chanTag + "." + RTUTag + "." + fesGrpTag; + + //存储设备组名与套件名的映射 + m_mapExistDevGrp2PluginName[locationTagName + "." + devGrpTag] = pluginLable; } bool bResult = true; @@ -1542,8 +1597,22 @@ bool kbdSecondInstWizardPage::checkDevGrp() ds.isExist(sql.arg(m_listFesTag.at(i).first()),bExist); if(bExist) { - m_textError->append(QString(tr("错误:后台设备%1 已经存在")).arg(m_listFesTag.at(i).first())); - bResult = false; + QString strTempDevGrp = m_listFesTag.at(i).first(); + QString strTempPluginName = m_mapExistDevGrp2PluginName[strTempDevGrp]; + m_textError->append(QString(tr("提示:后台设备组%1 已经存在")).arg(strTempDevGrp)); + + sql = "SELECT * FROM dev_info WHERE tag_name in(SELECT concat('%1_',temp_name) FROM temp_plugin_fes_dev_map WHERE plugin_name='%2')"; + ds.isExist(sql.arg(strTempDevGrp).arg(strTempPluginName),bExist); + if(bExist) + { + m_textError->append(QString(tr("错误:后台设备组%1 中已经存在 %2套件中设备")).arg(strTempDevGrp).arg(strTempPluginName)); + bResult = false; + } + } + else + { + //只保留已经存在的设备组名,用于后面不同套件创建在同一个设备组失败时,单独删除对应的设备,而不删除整个用户组 + m_mapExistDevGrp2PluginName.remove(m_listFesTag.at(i).first()); } sql = "select* from fes_dev_info where TAG_NAME = '%1';"; @@ -1555,6 +1624,26 @@ bool kbdSecondInstWizardPage::checkDevGrp() } } } + else if (m_InstType == Delele) + { + //记录不同套件创建到同一个设备组下的设备组信息,用于勾选删除61850设备时区分是删除整个设备组还是单独删除设备 + for(int nIdx = 0;nIdx < m_listFesTag.size();nIdx++) + { + QString sql = "SELECT * FROM dev_info WHERE group_tag_name = '%1' and tag_name not in" + "(SELECT concat('%2_',temp_name) FROM temp_plugin_fes_dev_map WHERE plugin_name='%3');"; + QString strTempDevGrp = m_listFesTag.at(nIdx).first(); + QString strTempPluginName = m_mapExistDevGrp2PluginName[strTempDevGrp]; + + KbdDbDesign ds; + bool bExist = false; + ds.isExist(sql.arg(strTempDevGrp).arg(strTempDevGrp).arg(strTempPluginName),bExist); + if(!bExist) + { + //只保留包含不同套件的设备组名,用于执行删除61850设备的操作 + m_mapExistDevGrp2PluginName.remove(m_listFesTag.at(nIdx).first()); + } + } + } return bResult; } @@ -2193,7 +2282,7 @@ void CboxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, cons model->setData(index,cb->currentData(),Qt::UserRole); } -kbdRcbDialog::kbdRcbDialog(ST_Rcb* stRcb, QWidget *parent): QDialog(parent) +kbdRcbDialog::kbdRcbDialog(ST_Rcb* stRcb, QWidget *parent): CustomDialog(parent) { m_stRCB = stRcb; inItLayout(); diff --git a/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.h b/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.h index 99a74ea4..09c4e071 100644 --- a/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.h +++ b/product/src/tools/model_plugin/iec61850InstWizard/kbdinst61850devwizard.h @@ -10,6 +10,7 @@ #include "kbd61850CfgModel.h" #include "xlsxdocument.h" #include "pub_logger_api/logger.h" +#include "pub_widget/CustomDialog.h" class QComboBox; class QTextEdit; @@ -150,7 +151,11 @@ public: QString m_strFilePath; QMap m_tempPlugin; QList m_listFesTag; + //已经存在的设备组标签名,用于实现不同套件创建在同一个设备组下,key:设备组标签,value:套件标签 + QMap m_mapExistDevGrp2PluginName; kbd61850CfgModel* m_CfgModel; + bool m_bOnlyUpdate61850; + QCheckBox *m_pOnlyUpdate61850; friend class kbdThirdInstWizardPage; }; @@ -260,7 +265,7 @@ public: -class kbdRcbDialog : public QDialog +class kbdRcbDialog : public CustomDialog { Q_OBJECT public: diff --git a/product/src/tools/model_plugin/model_linkage/cctvactdlg.cpp b/product/src/tools/model_plugin/model_linkage/cctvactdlg.cpp index 3ffdefed..dc93ae47 100644 --- a/product/src/tools/model_plugin/model_linkage/cctvactdlg.cpp +++ b/product/src/tools/model_plugin/model_linkage/cctvactdlg.cpp @@ -12,7 +12,7 @@ #include #include #include "kbdtabledatamgr.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdmsgcontrl.h" #include "linkage.h" #include @@ -20,7 +20,7 @@ #include //用于添加 -CctvActDlg::CctvActDlg(KbdTableModel* modelAct,QWidget *parent) : QDialog(parent) +CctvActDlg::CctvActDlg(KbdTableModel* modelAct,QWidget *parent) : CustomDialog(parent) { m_modelAct = modelAct; initLayout(); @@ -29,7 +29,7 @@ CctvActDlg::CctvActDlg(KbdTableModel* modelAct,QWidget *parent) : QDialog(parent } //用于修改 -CctvActDlg::CctvActDlg(KbdTableModel* modelAct,const QStringList& oldDatas,QWidget *parent) : QDialog(parent) +CctvActDlg::CctvActDlg(KbdTableModel* modelAct,const QStringList& oldDatas,QWidget *parent) : CustomDialog(parent) { m_modelAct = modelAct; m_oldDatas << oldDatas; @@ -41,6 +41,7 @@ CctvActDlg::CctvActDlg(KbdTableModel* modelAct,const QStringList& oldDatas,QWidg void CctvActDlg::initLayout() { + setWindowTitle("CCTV配置"); QHBoxLayout *hLayout = new QHBoxLayout; QGridLayout *grid = new QGridLayout; m_stackWidget = new QStackedWidget(this); @@ -281,7 +282,7 @@ bool CctvActDlg::check() //已经存在,不准添加 if(ifExisted() == false ) { - QMessageBox::information(this,tr("消息"),tr("已经存在,无法添加!")); + N_MessageBox::information(this,tr("消息"),tr("已经存在,无法添加!")); return false; } @@ -578,10 +579,10 @@ void CctvActDlg::onOk() } if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - QMessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); + N_MessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); } else - QMessageBox::information(this,tr("消息"),tr("开启事务失败")); + N_MessageBox::information(this,tr("消息"),tr("开启事务失败")); if(!success) return; diff --git a/product/src/tools/model_plugin/model_linkage/cctvactdlg.h b/product/src/tools/model_plugin/model_linkage/cctvactdlg.h index 7ca3f21f..31eebfa0 100644 --- a/product/src/tools/model_plugin/model_linkage/cctvactdlg.h +++ b/product/src/tools/model_plugin/model_linkage/cctvactdlg.h @@ -2,6 +2,7 @@ #define CCTVACTDLG_H #include +#include "pub_widget/CustomDialog.h" class QStackedWidget; class QComboBox; @@ -11,7 +12,7 @@ class QStandardItemModel; class QDialogButtonBox; class KbdTableModel; -class CctvActDlg : public QDialog +class CctvActDlg : public CustomDialog { Q_OBJECT diff --git a/product/src/tools/model_plugin/model_linkage/kbdperioddlg.cpp b/product/src/tools/model_plugin/model_linkage/kbdperioddlg.cpp index b0c14ea3..88216d0c 100644 --- a/product/src/tools/model_plugin/model_linkage/kbdperioddlg.cpp +++ b/product/src/tools/model_plugin/model_linkage/kbdperioddlg.cpp @@ -11,13 +11,13 @@ #include "kbdtable.h" #include "kbdtabledatamgr.h" #include "../model_common/common.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdcheckrole.h" #include #include #include -KbdPeriodDlg::KbdPeriodDlg(QWidget *parent) : QDialog(parent) +KbdPeriodDlg::KbdPeriodDlg(QWidget *parent) : CustomDialog(parent) { initLayout(); connect(m_cbType,SIGNAL(currentIndexChanged(int)),this,SLOT(onTypeChanged(int))); @@ -252,13 +252,13 @@ void KbdPeriodDlg::onOk() { if(m_leName->text().isEmpty()) { - QMessageBox::information(this,tr("消息"),tr("名称为空")); + N_MessageBox::information(this,tr("消息"),tr("名称为空")); return; } if(m_leDesc->text().isEmpty()) { - QMessageBox::information(this,tr("消息"),tr("描述为空")); + N_MessageBox::information(this,tr("消息"),tr("描述为空")); return; } diff --git a/product/src/tools/model_plugin/model_linkage/kbdperioddlg.h b/product/src/tools/model_plugin/model_linkage/kbdperioddlg.h index 2e475442..94bba51f 100644 --- a/product/src/tools/model_plugin/model_linkage/kbdperioddlg.h +++ b/product/src/tools/model_plugin/model_linkage/kbdperioddlg.h @@ -2,13 +2,13 @@ #define KBDPERIODDLG_H #include - +#include "pub_widget/CustomDialog.h" class QLineEdit; class QDateTimeEdit; class QComboBox; class QSpinBox; -class KbdPeriodDlg : public QDialog +class KbdPeriodDlg : public CustomDialog { Q_OBJECT public: diff --git a/product/src/tools/model_plugin/model_linkage/linkage.cpp b/product/src/tools/model_plugin/model_linkage/linkage.cpp index 4346808c..e77806c9 100644 --- a/product/src/tools/model_plugin/model_linkage/linkage.cpp +++ b/product/src/tools/model_plugin/model_linkage/linkage.cpp @@ -1,2683 +1,2706 @@ -#include "linkage.h" -#include -#include "kbdtabledatamgr.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "kbdtable.h" -#include -#include -#include -#include "kbdpropertydlg.h" -#include "kbdpropertypanel.h" -#include -#include "kbddbdesign.h" -#include -#include "periodwidget.h" -#include "triggerfuncwidget.h" -#include "triggerparawidget.h" -#include "kbdmsgcontrl.h" -#include -#include -#include -#include -#include "cctvactdlg.h" - -class LinkagePrivate -{ - Linkage *q_ptr; - Q_DECLARE_PUBLIC(Linkage) -public: - QTabWidget *tab; - //联动动作 - KbdTable *tableActList; - QLineEdit *leSearchAct; - QActionGroup *actGroupOfActs; - //联动功能 - KbdTable *tableFuncList; - KbdTable *tableActsOfFunc; - QLineEdit *leSearchFunc; - QActionGroup *actGroupOfFuncs; - //联动定义 - KbdTable *tableLinkageList; - KbdTable *tableFuncOfLinkage; - QLineEdit *leSearchLinkage; - QActionGroup *actGroupOfLinkage; - //触发定义 - QStackedWidget *stackTrigger; - QActionGroup *actGroupTrigger; - KbdTable *tableTriggerTimer;//定时触发 - //周期触发 - KbdTable *tableTriggerPeriod; - QComboBox *cbPeriodType; - QTranslator* m_translates; - - - LinkagePrivate() { - loadTranslate(); - } - ~LinkagePrivate(){ - removeTranslate(); - } - void init(){ - initTableModule(); - initLayout(); - initData(); - } - - void initTableModule(); - void initLayout(); - void initData(); - void loadTranslate(); - void removeTranslate(); - - QWidget *initActWidget(); - QWidget *initFuncWidget(); - QWidget *initLinkageWidget(); - QWidget *initTriggerWidget(); - QWidget *timerWidget(); - QWidget *periodWidget(); - /** - * @brief pushToolBarData 把对应comboboxFormat的信息写入工具条,返回工具条的ActiongGroup - * @param bar - * @param comboboxFormat - */ - QActionGroup * pushToolBarData(QToolBar *bar, const QString &comboboxFormat); -}; - -void LinkagePrivate::initTableModule(){ -// QSettings settings("KbdSoft.ZHJK","ISCS6000.tools"); -// KbdTableDataMgr::getInstance()->initDBLink(DataBaseInterface::DirectLink, -// settings.value("login/user","root").toString(), -// settings.value("login/psw","kbdct@0755").toString(), -// settings.value("login/ip","192.168.190.128").toString(), -// settings.value("login/port","3306").toInt(), -// settings.value("login/dbname","ISCS6000").toString(), -// DataBaseInterface::MySql -// ); - KbdTableDataMgr::getInstance()->initDBLink(DataBaseInterface::CenterLink); -} - -void LinkagePrivate::initLayout(){ - Q_Q(Linkage); - tab = new QTabWidget(q); - tab->addTab(initActWidget(), QObject::tr("联动动作")); - tab->addTab(initFuncWidget(), QObject::tr("联动功能")); - tab->addTab(initLinkageWidget(), QObject::tr("联动定义")); - tab->addTab(initTriggerWidget(), QObject::tr("触发定义")); - - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->addWidget(tab); - q->setLayout(hLayout); -} - -void LinkagePrivate::initData(){ - Q_Q(Linkage); - if(!actGroupOfActs->actions().isEmpty()) - actGroupOfActs->actions().first()->setChecked(true); - if(!actGroupOfFuncs->actions().isEmpty()) - actGroupOfFuncs->actions().first()->setChecked(true); - if(!actGroupOfLinkage->actions().isEmpty()) - actGroupOfLinkage->actions().first()->setChecked(true); - if(!actGroupTrigger->actions().isEmpty()) - actGroupTrigger->actions().first()->setChecked(true); - - QObject::connect(actGroupOfActs,SIGNAL(triggered(QAction*)),q,SLOT(onActTypeChanged())); - QObject::connect(actGroupOfFuncs,SIGNAL(triggered(QAction*)),q,SLOT(onFuncTypeChanged())); - QObject::connect(actGroupOfLinkage,SIGNAL(triggered(QAction*)),q,SLOT(onLinkageTypeChanged())); - QObject::connect(actGroupTrigger,SIGNAL(triggered(QAction*)),q,SLOT(onTriggerTypeChanged())); - - q->onActTypeChanged(); - q->onFuncTypeChanged(); - q->onLinkageTypeChanged(); - - tableFuncList->useDefaultHidePolicy(false); - tableActsOfFunc->useDefaultHidePolicy(false); - KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_FUNCTION); - if(modelFunc) - { - const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); - QList cols; - int colName = modelFuncCols.findCol(CN_NAME); - int colDesc = modelFuncCols.findCol(CN_DESC); - cols << colName << colDesc; - tableFuncList->setShowCol(cols); - cols = modelFuncCols.getShowCol(); - cols.removeAll(colName); - cols.removeAll(colDesc); - tableActsOfFunc->setShowCol(cols); - } - QObject::connect(tableFuncList,SIGNAL(clicked(const QModelIndex &)), - q,SLOT(onFuncTableClicked(const QModelIndex &))); - QObject::connect(tableLinkageList,SIGNAL(clicked(const QModelIndex &)), - q,SLOT(onLinkageTableClicked(const QModelIndex &))); - QObject::connect(tableTriggerTimer,SIGNAL(doubleClicked(const QModelIndex &)), - q,SLOT(onModifyTimer())); - - KbdTableModel *modelTimer = KbdTableDataMgr::getInstance()->createModel(TBL_TRIGGER_TIMER_DEFINE); - tableTriggerTimer->setModel(modelTimer); - -} - -void LinkagePrivate::loadTranslate() -{ - m_translates = new QTranslator; - m_translates->load(Common::getTranslatePath("model_linkage_EN.qm")); - qApp->installTranslator(m_translates); -} - -void LinkagePrivate::removeTranslate() -{ - qApp->removeTranslator(m_translates); -} - -QWidget *LinkagePrivate::initActWidget(){ - Q_Q(Linkage); - - QGroupBox *boxActType = new QGroupBox(QObject::tr("动作类型"),tab); - QGroupBox *boxActList = new QGroupBox(QObject::tr("动作列表"),tab); - - //左侧工具条 - QScrollArea *area = new QScrollArea(boxActType); - QToolBar *bar = new QToolBar(area); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - QString comboboxFormat = ""; - if(modelAct) - { - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - comboboxFormat = modelActCols.at(modelActCols.findCol(CN_ACTION_TYPE)).valueLimit; - } - actGroupOfActs = pushToolBarData(bar,comboboxFormat); - - area->setWidget(bar); - area->setBackgroundRole(QPalette::Light); - area->verticalScrollBar()->setVisible(false); - area->horizontalScrollBar()->setVisible(false); - area->setAlignment(Qt::AlignHCenter); - QHBoxLayout *hLayout1 = new QHBoxLayout; - hLayout1->addWidget(area); - boxActType->setLayout(hLayout1); - - //右上角动作列表 - QHBoxLayout *hLayout2 = new QHBoxLayout; - - QHBoxLayout *hLayoutSearch = new QHBoxLayout; - leSearchAct = new QLineEdit(boxActList); - leSearchAct->setPlaceholderText(QObject::tr("搜索动作描述")); - hLayoutSearch->addWidget(leSearchAct); - tableActList = new KbdTable(boxActList); - QVBoxLayout *vLayoutTable = new QVBoxLayout; - vLayoutTable->addLayout(hLayoutSearch); - vLayoutTable->addWidget(tableActList); - - QVBoxLayout *vLayoutBts = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),boxActList); - QPushButton *btModify = new QPushButton(QObject::tr("修改"),boxActList); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),boxActList); - vLayoutBts->addStretch(); - vLayoutBts->addWidget(btAdd); - vLayoutBts->addWidget(btModify); - vLayoutBts->addWidget(btRemove); - vLayoutBts->addStretch(); - - hLayout2->addLayout(vLayoutTable); - hLayout2->addLayout(vLayoutBts); - boxActList->setLayout(hLayout2); - - //右下角动作定义 - QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); - hSplitter->addWidget(boxActType); - hSplitter->addWidget(boxActList); - hSplitter->setSizes(QList()<<150<<1150); - hSplitter->setContentsMargins(0,10,0,0); - - QObject::connect(btAdd,SIGNAL(clicked(bool)),q,SLOT(onAddAction())); - QObject::connect(btRemove,SIGNAL(clicked(bool)),q,SLOT(onRemoveAction())); - QObject::connect(btModify,SIGNAL(clicked(bool)),q,SLOT(onModifyAction())); - QObject::connect(leSearchAct,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchAct())); - QObject::connect(tableActList,SIGNAL(doubleClicked(const QModelIndex &)), - q,SLOT(onModifyAction())); - - return hSplitter; -} - -QWidget *LinkagePrivate::initFuncWidget(){ - Q_Q(Linkage); - - QGroupBox *boxFuncType = new QGroupBox(QObject::tr("功能类型"),tab); - QGroupBox *boxFuncList = new QGroupBox(QObject::tr("功能列表"),tab); - QGroupBox *boxActsOfFunc = new QGroupBox(QObject::tr("功能所含动作列表"),tab); - - //左侧工具条 - QScrollArea *area = new QScrollArea(boxFuncType); - QToolBar *bar = new QToolBar(area); - KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_FUNCTION); - QString comboboxFormat = ""; - if(modelFunc) - { - const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); - comboboxFormat = modelFuncCols.at(modelFuncCols.findCol(CN_FUNC_TYPE)).valueLimit; - } - actGroupOfFuncs = pushToolBarData(bar,comboboxFormat); - - area->setWidget(bar); - area->setBackgroundRole(QPalette::Light); - area->verticalScrollBar()->setVisible(false); - area->horizontalScrollBar()->setVisible(false); - area->setAlignment(Qt::AlignHCenter); - QHBoxLayout *hLayout1 = new QHBoxLayout; - hLayout1->addWidget(area); - boxFuncType->setLayout(hLayout1); - - //右上角列表 - QHBoxLayout *hLayout2 = new QHBoxLayout; - - QHBoxLayout *hLayoutSearch = new QHBoxLayout; - leSearchFunc = new QLineEdit(boxFuncList); - leSearchFunc->setPlaceholderText(QObject::tr("搜索功能描述")); - hLayoutSearch->addWidget(leSearchFunc); - - tableFuncList = new KbdTable(boxFuncList); - QVBoxLayout *vLayoutTable = new QVBoxLayout; - vLayoutTable->addLayout(hLayoutSearch); - vLayoutTable->addWidget(tableFuncList); - - QVBoxLayout *vLayoutBts = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),boxFuncList); - QPushButton *btModify = new QPushButton(QObject::tr("修改"),boxFuncList); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),boxFuncList); - vLayoutBts->addStretch(); - vLayoutBts->addWidget(btAdd); - vLayoutBts->addWidget(btModify); - vLayoutBts->addWidget(btRemove); - vLayoutBts->addStretch(); - - hLayout2->addLayout(vLayoutTable); - hLayout2->addLayout(vLayoutBts); - boxFuncList->setLayout(hLayout2); - - //右下角功能列表 - QVBoxLayout *vLayoutBox = new QVBoxLayout; - QToolBar *toolbar = new QToolBar(boxActsOfFunc); - tableActsOfFunc = new KbdTable(boxActsOfFunc); - toolbar->setIconSize(QSize(24,24)); - toolbar->addAction(QIcon(":/icons/icons/new.png"),QObject::tr("添加记录"),q,SLOT(onAddActOfFunc())); - toolbar->addAction(QIcon(":/icons/icons/modify.png"),QObject::tr("修改记录"),q,SLOT(onModifyActOfFunc())); - toolbar->addAction(QIcon(":/icons/icons/delete.png"),QObject::tr("删除记录"),q,SLOT(onRemoveActOfFunc())); - - vLayoutBox->addWidget(toolbar); - vLayoutBox->addWidget(tableActsOfFunc); - boxActsOfFunc->setLayout(vLayoutBox); - - QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); - QSplitter *vSplitter = new QSplitter(Qt::Vertical,hSplitter); - vSplitter->addWidget(boxFuncList); - vSplitter->addWidget(boxActsOfFunc); - hSplitter->addWidget(boxFuncType); - hSplitter->addWidget(vSplitter); - hSplitter->setSizes(QList()<<150<<1150); - vSplitter->setSizes(QList()<<200<<200); - hSplitter->setContentsMargins(0,10,0,0); - - QObject::connect(btAdd,SIGNAL(clicked(bool)),q,SLOT(onAddFunc())); - QObject::connect(btRemove,SIGNAL(clicked(bool)),q,SLOT(onRemoveFunc())); - QObject::connect(btModify,SIGNAL(clicked(bool)),q,SLOT(onModifyFunc())); - - QObject::connect(leSearchFunc,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchFunc())); - QObject::connect(tableFuncList,SIGNAL(doubleClicked(const QModelIndex &)), - q,SLOT(onModifyFunc())); - QObject::connect(tableActsOfFunc,SIGNAL(doubleClicked(const QModelIndex &)),q,SLOT(onModifyActOfFunc())); - return hSplitter; -} - -QWidget *LinkagePrivate::initLinkageWidget(){ - Q_Q(Linkage); - - QGroupBox *boxLinkageType = new QGroupBox(QObject::tr("联动类型"),tab); - QGroupBox *boxLinkageList = new QGroupBox(QObject::tr("联动列表"),tab); - QGroupBox *boxFuncOfLinkage = new QGroupBox(QObject::tr("联动所含功能列表"),tab); - - //左侧工具条 - QScrollArea *area = new QScrollArea(boxLinkageType); - QToolBar *bar = new QToolBar(area); - KbdTableModel *modelLinkageSettiing = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING); - QString comboboxFormat = ""; - if(modelLinkageSettiing) - { - const ColMgrDataList& modelLinkageSettiingCols = modelLinkageSettiing->getHeadCols(); - comboboxFormat = modelLinkageSettiingCols.at(modelLinkageSettiingCols.findCol(CN_LINK_TYPE)).valueLimit; - } - actGroupOfLinkage = pushToolBarData(bar,comboboxFormat); - - area->setWidget(bar); - area->setBackgroundRole(QPalette::Light); - area->verticalScrollBar()->setVisible(false); - area->horizontalScrollBar()->setVisible(false); - area->setAlignment(Qt::AlignHCenter); - QHBoxLayout *hLayout1 = new QHBoxLayout; - hLayout1->addWidget(area); - boxLinkageType->setLayout(hLayout1); - - //右上角列表 - QHBoxLayout *hLayout2 = new QHBoxLayout; - - QHBoxLayout *hLayoutSearch = new QHBoxLayout; - leSearchLinkage = new QLineEdit(boxLinkageList); - leSearchLinkage->setPlaceholderText(QObject::tr("搜索联动描述")); - hLayoutSearch->addWidget(leSearchLinkage); - - tableLinkageList = new KbdTable(boxLinkageList); - QVBoxLayout *vLayoutTable = new QVBoxLayout; - vLayoutTable->addLayout(hLayoutSearch); - vLayoutTable->addWidget(tableLinkageList); - - QVBoxLayout *vLayoutBts = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),boxLinkageList); - QPushButton *btModify = new QPushButton(QObject::tr("修改"),boxLinkageList); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),boxLinkageList); - vLayoutBts->addStretch(); - vLayoutBts->addWidget(btAdd); - vLayoutBts->addWidget(btModify); - vLayoutBts->addWidget(btRemove); - vLayoutBts->addStretch(); - - hLayout2->addLayout(vLayoutTable); - hLayout2->addLayout(vLayoutBts); - boxLinkageList->setLayout(hLayout2); - - //右下角功能列表 - QVBoxLayout *vLayoutBox = new QVBoxLayout; - QToolBar *toolbar = new QToolBar(boxFuncOfLinkage); - tableFuncOfLinkage = new KbdTable(boxFuncOfLinkage); - toolbar->setIconSize(QSize(24,24)); - toolbar->addAction(QIcon(":/icons/icons/new.png"),QObject::tr("添加记录"),q,SLOT(onAddFuncOfLinkage())); - toolbar->addAction(QIcon(":/icons/icons/modify.png"),QObject::tr("修改记录"),q,SLOT(onModifyFuncOfLinkage())); - toolbar->addAction(QIcon(":/icons/icons/delete.png"),QObject::tr("删除记录"),q,SLOT(onRemoveFuncOfLinkage())); - - vLayoutBox->addWidget(toolbar); - vLayoutBox->addWidget(tableFuncOfLinkage); - boxFuncOfLinkage->setLayout(vLayoutBox); - - QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); - QSplitter *vSplitter = new QSplitter(Qt::Vertical,hSplitter); - vSplitter->addWidget(boxLinkageList); - vSplitter->addWidget(boxFuncOfLinkage); - hSplitter->addWidget(boxLinkageType); - hSplitter->addWidget(vSplitter); - hSplitter->setSizes(QList()<<150<<1150); - vSplitter->setSizes(QList()<<200<<200); - hSplitter->setContentsMargins(0,10,0,0); - - QObject::connect(btAdd,SIGNAL(clicked(bool)),q,SLOT(onAddLinkage())); - QObject::connect(btModify,SIGNAL(clicked(bool)),q,SLOT(onModifyLinkage())); - QObject::connect(btRemove,SIGNAL(clicked(bool)),q,SLOT(onRemoveLinkage())); - QObject::connect(tableLinkageList,SIGNAL(doubleClicked(const QModelIndex &)), - q,SLOT(onModifyLinkage())); - - QObject::connect(leSearchLinkage,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchLinkage())); - QObject::connect(tableFuncOfLinkage,SIGNAL(doubleClicked(const QModelIndex &)),q,SLOT(onModifyFuncOfLinkage())); - return hSplitter; -} - -QWidget *LinkagePrivate::initTriggerWidget() -{ - - QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); - QGroupBox *boxType = new QGroupBox(QObject::tr("触发类型"),hSplitter); - stackTrigger = new QStackedWidget(hSplitter); - - //左侧工具条 - QScrollArea *area = new QScrollArea(boxType); - QToolBar *bar = new QToolBar(area); - QString comboboxFormat = QObject::tr("0:定时触发/1:周期触发/2:触发函数/3:触发器定义"); - actGroupTrigger = pushToolBarData(bar,comboboxFormat); - area->setWidget(bar); - area->setBackgroundRole(QPalette::Light); - area->verticalScrollBar()->setVisible(false); - area->horizontalScrollBar()->setVisible(false); - area->setAlignment(Qt::AlignHCenter); - - QHBoxLayout *hLayout1 = new QHBoxLayout; - hLayout1->addWidget(area); - boxType->setLayout(hLayout1); - - //右边 - stackTrigger->addWidget(timerWidget()); - stackTrigger->addWidget(new PeriodWidget(stackTrigger)); - stackTrigger->addWidget(new TriggerFuncWidget(stackTrigger)); - stackTrigger->addWidget(new TriggerParaWidget(stackTrigger)); - - hSplitter->addWidget(boxType); - hSplitter->addWidget(stackTrigger); - hSplitter->setSizes(QList()<<150<<1150); - hSplitter->setContentsMargins(0,10,0,0); - - return hSplitter; -} - -QWidget *LinkagePrivate::timerWidget() -{ - Q_Q(Linkage); - QWidget *widget = new QWidget(stackTrigger); - QHBoxLayout *hLayout = new QHBoxLayout; - tableTriggerTimer = new KbdTable(widget); - - QVBoxLayout *vLayout = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),widget); - QPushButton *btModify = new QPushButton(QObject::tr("修改"),widget); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),widget); - vLayout->addStretch(); - vLayout->addWidget(btAdd); - vLayout->addWidget(btModify); - vLayout->addWidget(btRemove); - vLayout->addStretch(); - - hLayout->addWidget(tableTriggerTimer); - hLayout->addLayout(vLayout); - widget->setLayout(hLayout); - - QObject::connect(btAdd,SIGNAL(clicked(bool)),q,SLOT(onAddTimer())); - QObject::connect(btModify,SIGNAL(clicked(bool)),q,SLOT(onModifyTimer())); - QObject::connect(btRemove,SIGNAL(clicked(bool)),q,SLOT(onRemoveTimer())); - return widget; -} - -QWidget *LinkagePrivate::periodWidget() -{ - QWidget *widget = new QWidget(stackTrigger); - - QHBoxLayout *hLayoutTop = new QHBoxLayout; - tableTriggerPeriod = new KbdTable(widget); - QVBoxLayout *vLayoutVts = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),widget); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),widget); - vLayoutVts->addWidget(btAdd); - vLayoutVts->addWidget(btRemove); - hLayoutTop->addWidget(tableTriggerPeriod); - hLayoutTop->addLayout(vLayoutVts); - - PeriodWidget *periodWidget = new PeriodWidget(widget); - QPushButton *btSave = new QPushButton(QObject::tr("保存"),widget); - QHBoxLayout *hLayoutSave = new QHBoxLayout; - hLayoutSave->addStretch(); - hLayoutSave->addWidget(btSave); - hLayoutSave->addStretch(); - - QVBoxLayout *vLayout = new QVBoxLayout; - vLayout->addLayout(hLayoutTop); - vLayout->addWidget(periodWidget); - vLayout->addLayout(hLayoutSave); - - widget->setLayout(vLayout); - return widget; -} - -QActionGroup * LinkagePrivate::pushToolBarData(QToolBar *bar, const QString &comboboxFormat) -{ - Q_ASSERT(bar != NULL); - - bar->clear(); - bar->setOrientation(Qt::Vertical); - bar->setBackgroundRole(QPalette::Light); - bar->setStyleSheet("spacing:10px;margin-top:5px;font:14px;"); - - QActionGroup *actGroup = new QActionGroup(bar); - actGroup->setExclusive(true); - QStringList list = comboboxFormat.split("/"); - QStringList list2; - QAction *act; - - foreach (QString element, list) { - if(element.isEmpty()) - continue; - - list2 = element.split(":"); - act = new QAction(list2.last(),bar); - act->setData(list2.first()); - bar->addAction(act); - - actGroup->addAction(act); - act->setCheckable(true); - } - - return actGroup; - -} - -Linkage::Linkage(QWidget *parent):QWidget(parent) -{ - d_ptr = new LinkagePrivate; - d_ptr->q_ptr = this; - d_ptr->init(); -} - -Linkage::~Linkage() -{ - if(d_ptr) - delete d_ptr; -} - -void Linkage::addPscadaAction() -{ - Q_D(Linkage); - KbdTableModel *modelActPscada = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PSCADA); - if(modelActPscada == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActPscada,modelActPscada->rowCount()); - if(dlg.exec()) - { - //根据返回的点,分割.字符,获取车站和设备 - rowDatas = pscadaDataToActData( dlg.panel()->getPropertyData()); - if(rowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->addRow(rowDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:(success=success&&false)) - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::addBasAction() -{ - Q_D(Linkage); - KbdTableModel *modelActBas = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_BAS); - if(modelActBas == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActBas,modelActBas->rowCount()); - if(dlg.exec()) - { - //根据返回的点,分割.字符,获取车站和设备 - rowDatas = basDataToActData(dlg.panel()->getPropertyData()); - if(rowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->addRow(rowDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::addPaAction() -{ - Q_D(Linkage); - KbdTableModel *modelActPa = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PA); - if(modelActPa == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActPa,modelActPa->rowCount()); - if(dlg.exec()) - { - //根据返回的点,分割.字符,获取车站和设备 - rowDatas = paDataToActData(dlg.panel()->getPropertyData()); - if(rowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->addRow(rowDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::addCctvAction() -{ - Q_D(Linkage); - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - CctvActDlg dlg(modelAct,this); - dlg.exec(); -} - -void Linkage::addPisAction() -{ - Q_D(Linkage); - KbdTableModel *modelActPis = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PIS); - if(modelActPis == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActPis,modelActPis->rowCount()); - if(dlg.exec()) - { - //根据返回的点,分割.字符,获取车站和设备 - rowDatas = pisDataToActData(dlg.panel()->getPropertyData()); - if(rowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->addRow(rowDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::addPicAction() -{ - Q_D(Linkage); - KbdTableModel *modelPushPic = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PUSH_PIC); - if(modelPushPic == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelPushPic,modelPushPic->rowCount()); - if(dlg.exec()) - { - //根据返回的点,分割.字符,获取车站和设备 - rowDatas = pushPicDataToActData(dlg.panel()->getPropertyData()); - if(rowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->addRow(rowDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::addMsgAction() -{ - Q_D(Linkage); - KbdTableModel *modelMsg = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_MSG); - if(modelMsg == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelMsg,modelMsg->rowCount()); - if(dlg.exec()) - { - //根据返回的点,分割.字符,获取车站和设备 - rowDatas = msgDataToActData(dlg.panel()->getPropertyData()); - if(rowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->addRow(rowDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::modifyPscadaAction() -{ - Q_D(Linkage); - KbdTableModel *modelActPscada = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PSCADA); - if(modelActPscada == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList newRowDatas; - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActPscada,modelActPscada->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); - QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); - QStringList listStr = linkageStr.split("*"); - if(listStr.size() != 3) - return; - dlg.panel()->setPropertyValue(CN_CTRL_POINT,listStr.at(1)); - dlg.panel()->setPropertyValue(CN_CTRL_TYPE,listStr.at(2)); - dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); - if(dlg.exec()) - { - newRowDatas = pscadaDataToActData(dlg.panel()->getPropertyData()); - if(newRowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(newRowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->modifyRow(oldRowDatas,newRowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - onActTypeChanged(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::modifyBasAction() -{ - Q_D(Linkage); - KbdTableModel *modelActBas = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_BAS); - if(modelActBas == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList newRowDatas; - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActBas,modelActBas->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); - QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); - QStringList listStr = linkageStr.split("*"); - if(listStr.size() != 3) - return; - dlg.panel()->setPropertyValue(CN_CTRL_POINT,listStr.at(1)); - dlg.panel()->setPropertyValue(CN_CTRL_TYPE,listStr.at(2)); - dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); - if(dlg.exec()) - { - newRowDatas = basDataToActData(dlg.panel()->getPropertyData()); - if(newRowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(newRowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->modifyRow(oldRowDatas,newRowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - onActTypeChanged(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::modifyPaAction() -{ - Q_D(Linkage); - KbdTableModel *modelActPa = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PA); - if(modelActPa == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList newRowDatas; - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - QStringList strList = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)).split("*"); - if(strList.size() != 10) - { - onMsg(tr("动作内容错误")); - return; - } - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActPa,modelActPa->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); - dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); - - dlg.panel()->setPropertyValue(CN_CTRL_TYPE,strList.at(1)); - dlg.panel()->setPropertyValue(CN_PA_AREA,strList.at(2)+"*"+strList.at(3)); - dlg.panel()->setPropertyValue(CN_PA_AUDIO,strList.at(4)); - dlg.panel()->setPropertyValue(CN_PA_REPEAT,strList.at(5)); - dlg.panel()->setPropertyValue(CN_PA_PRIORITY,strList.at(6)); - dlg.panel()->setPropertyValue(CN_CTRL_POINT,strList.at(7)); - dlg.panel()->setPropertyValue(CN_PLAY_TYPE,strList.at(8)); - dlg.panel()->setPropertyValue("PA_OPERATOR",strList.at(9)); - - if(dlg.exec()) - { - newRowDatas = paDataToActData(dlg.panel()->getPropertyData()); - if(newRowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(newRowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->modifyRow(oldRowDatas,newRowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - onActTypeChanged(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::modifyCctvAction() -{ - Q_D(Linkage); - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList unWrapDatas = modelAct->unwrapData(oldRowDatas); - CctvActDlg dlg(modelAct,unWrapDatas, this); - dlg.exec(); -} - -void Linkage::modifyPisAction() -{ - Q_D(Linkage); - KbdTableModel *modelActPis = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PIS); - if(modelActPis == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList newRowDatas; - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - QStringList strList = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)).split("*"); - if(strList.size() != 10) - { - onMsg(tr("动作内容错误")); - return; - } - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelActPis,modelActPis->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); - dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); - - dlg.panel()->setPropertyValue(CN_CTRL_TYPE,strList.at(1)); - dlg.panel()->setPropertyValue(CN_PIS_AREA,strList.at(2)+"*"+strList.at(3)); - dlg.panel()->setPropertyValue(CN_PIS_MSG,strList.at(4)); - dlg.panel()->setPropertyValue(CN_PIS_TIME,strList.at(5)); - dlg.panel()->setPropertyValue(CN_PRIORITY,strList.at(6)); - dlg.panel()->setPropertyValue(CN_PIS_SPACE_TIME,strList.at(7)); - dlg.panel()->setPropertyValue(CN_CTRL_POINT,strList.at(8)); - dlg.panel()->setPropertyValue("PIS_MESSAGE",strList.at(9)); - - if(dlg.exec()) - { - newRowDatas = pisDataToActData(dlg.panel()->getPropertyData()); - if(newRowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(newRowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->modifyRow(oldRowDatas,newRowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - onActTypeChanged(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::modifyPicAction() -{ - Q_D(Linkage); - KbdTableModel *modelPushPic = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PUSH_PIC); - if(modelPushPic == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList newRowDatas; - - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelPushPic,modelPushPic->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); - QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); - QStringList listStr = linkageStr.split("*"); - if(listStr.size() != 3) - return; - dlg.panel()->setPropertyValue(CN_PIC_NAME,listStr.at(1)); - dlg.panel()->setPropertyValue(CN_HOST_NAME,listStr.at(2)); - dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); - if(dlg.exec()) - { - newRowDatas = pushPicDataToActData(dlg.panel()->getPropertyData()); - if(newRowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(newRowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->modifyRow(oldRowDatas,newRowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - onActTypeChanged(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::modifyMsgAction() -{ - Q_D(Linkage); - KbdTableModel *modelMsg = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_MSG); - if(modelMsg == NULL) - return; - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QModelIndex index = d->tableActList->currentIndex(); - if(!index.isValid()) - return; - - QStringList oldRowDatas = modelAct->getRowData(index.row()); - QStringList newRowDatas; - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelMsg,modelMsg->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); - QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); - QStringList listStr = linkageStr.split("*"); - if(listStr.size() != 3) - return; - dlg.panel()->setPropertyValue(CN_MSG,listStr.at(1)); - dlg.panel()->setPropertyValue(CN_HOST_NAME,listStr.at(2)); - dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); - if(dlg.exec()) - { - newRowDatas = msgDataToActData(dlg.panel()->getPropertyData()); - if(newRowDatas.isEmpty()) - { - onMsg(tr("联动动作定义错误")); - return; - } - } - - if(newRowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->modifyRow(oldRowDatas,newRowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - onActTypeChanged(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -bool Linkage::getLocationInfo(const QString &keyIdTag, QString &locationId, QString &subSystem) -{ - QStringList pointList = keyIdTag.split("."); - if(pointList.size() != 5)//必须是表名+TAG_NAME的形式 - return false; - QString tableName = pointList.first(); - pointList.removeFirst(); - pointList.removeLast(); - QString sql = QString("SELECT * FROM %1 WHERE TAG_NAME = '%2';").arg(tableName) - .arg(pointList.join(".")); - QSqlQuery result; - if(!KbdTableDataMgr::getInstance()->selectOnly(sql,result)) - return false; - - if(result.size() == 1) - { - while (result.next()) { - locationId = result.value(CN_LOCATION_ID).toString(); - subSystem = result.value(CN_SUB_SYSTEM).toString(); - break; - } - return true; - } - else - return false; -} - -QStringList Linkage::pscadaDataToActData(const QStringList &pscadaData) -{ - Q_D(Linkage); - QStringList temp; - if(pscadaData.isEmpty()) - return temp; - KbdTableModel *modelActPscada = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PSCADA); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - if(modelAct == NULL || modelActPscada == NULL) - return temp; - const ColMgrDataList& modelActPscadaCols = modelActPscada->getHeadCols(); - QStringList unwrapPscadaData = modelActPscada->unwrapData(pscadaData); - QString ctrlPoint = unwrapPscadaData.at(modelActPscadaCols.findCol(CN_CTRL_POINT)); - QString ctrlType = unwrapPscadaData.at(modelActPscadaCols.findCol(CN_CTRL_TYPE)); - - QStringList dotList = ctrlPoint.split("."); - if(dotList.size() != 5) - return temp; - - QString pointType; - if(QString("ANALOG").compare(dotList.first(),Qt::CaseInsensitive) == 0) - { - pointType = "ao_ctrl"; - } - else if(QString("DIGITAL").compare(dotList.first(),Qt::CaseInsensitive) == 0) - { - pointType = "do_ctrl"; - } - else - { - return temp; - } - - //根据所选择的点自动获取信息 - QString locationId; - QString subSystem; - if(!getLocationInfo(ctrlPoint,locationId,subSystem)) - { - return temp; - } - - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - { - return temp; - } - - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - - temp = modelAct->createDefaultValue(); - temp.replace(modelActCols.findCol(CN_NAME), - unwrapPscadaData.at(modelActPscadaCols.findCol(CN_NAME))); - - temp.replace(modelActCols.findCol(CN_DESC), - unwrapPscadaData.at(modelActPscadaCols.findCol(CN_DESC))); - temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), - pointType+"*"+ctrlPoint+"*"+ctrlType); - temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), - unwrapPscadaData.at(modelActPscadaCols.findCol(CN_CTRL_TIMEOUT))); - temp.replace(modelActCols.findCol(CN_ACTION_TYPE), - act->data().toString()); - temp.replace(modelActCols.findCol(CN_LOCATION_ID),locationId); - temp.replace(modelActCols.findCol(CN_SUB_SYSTEM),subSystem); - - temp.replace(modelActCols.findCol(CN_TIMEFLAG), - QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); - - return temp; -} - -QStringList Linkage::basDataToActData(const QStringList &basData) -{ - Q_D(Linkage); - QStringList temp; - if(basData.isEmpty()) - return temp; - KbdTableModel *modelActBas = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_BAS); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - if(modelAct == NULL || modelActBas == NULL) - return temp; - QStringList unwrapBasData = modelActBas->unwrapData(basData); - const ColMgrDataList& modelActBasCols = modelActBas->getHeadCols(); - QString ctrlPoint = unwrapBasData.at(modelActBasCols.findCol(CN_CTRL_POINT)); - QString ctrlType = unwrapBasData.at(modelActBasCols.findCol(CN_CTRL_TYPE)); - - QStringList dotList = ctrlPoint.split("."); - if(dotList.size() != 5) - return temp; - - QString pointType; - if(QString("ANALOG").compare(dotList.first(),Qt::CaseInsensitive) == 0) - { - pointType = "ao_ctrl"; - } - else if(QString("DIGITAL").compare(dotList.first(),Qt::CaseInsensitive) == 0) - { - pointType = "do_ctrl"; - } - else - { - return temp; - } - - //根据所选择的点自动获取域信息 - QString locationId; - QString subSystem; - if(!getLocationInfo(ctrlPoint,locationId,subSystem)) - { - return temp; - } - - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - { - return temp; - } - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - temp = modelAct->createDefaultValue(); - temp.replace(modelActCols.findCol(CN_NAME), - unwrapBasData.at(modelActBasCols.findCol(CN_NAME))); - - temp.replace(modelActCols.findCol(CN_DESC), - unwrapBasData.at(modelActBasCols.findCol(CN_DESC))); - temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), - pointType+"*"+ctrlPoint+"*"+ctrlType); - temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), - unwrapBasData.at(modelActBasCols.findCol(CN_CTRL_TIMEOUT))); - temp.replace(modelActCols.findCol(CN_ACTION_TYPE), - act->data().toString()); - - temp.replace(modelActCols.findCol(CN_SUB_SYSTEM),subSystem); - temp.replace(modelActCols.findCol(CN_LOCATION_ID),locationId); - temp.replace(modelActCols.findCol(CN_TIMEFLAG), - QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); - - return temp; -} - -QStringList Linkage::pushPicDataToActData(const QStringList &pushPicData) -{ - Q_D(Linkage); - QStringList temp; - if(pushPicData.isEmpty()) - return temp; - KbdTableModel *modelPushPic = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PUSH_PIC); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - if(modelAct == NULL || modelPushPic == NULL) - return temp; - - const ColMgrDataList& modelPushPicCols = modelPushPic->getHeadCols(); - QStringList unwrapPushPicData = modelPushPic->unwrapData(pushPicData); - QString hostName = unwrapPushPicData.at(modelPushPicCols.findCol(CN_HOST_NAME)); - QString picname = unwrapPushPicData.at(modelPushPicCols.findCol(CN_PIC_NAME)); - - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - { - return temp; - } - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - temp = modelAct->createDefaultValue(); - temp.replace(modelActCols.findCol(CN_NAME), - unwrapPushPicData.at(modelPushPicCols.findCol(CN_NAME))); - - temp.replace(modelActCols.findCol(CN_DESC), - unwrapPushPicData.at(modelPushPicCols.findCol(CN_DESC))); - temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), - "push_ctrl*"+picname+"*"+hostName); - temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), - unwrapPushPicData.at(modelPushPicCols.findCol(CN_CTRL_TIMEOUT))); - temp.replace(modelActCols.findCol(CN_ACTION_TYPE), - act->data().toString()); - - temp.replace(modelActCols.findCol(CN_LOCATION_ID), - unwrapPushPicData.at(modelPushPicCols.findCol(CN_LOCATION_ID))); - temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), - unwrapPushPicData.at(modelPushPicCols.findCol(CN_SUB_SYSTEM))); - temp.replace(modelActCols.findCol(CN_TIMEFLAG), - QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); - - return temp; -} - -QStringList Linkage::msgDataToActData(const QStringList &msgData) -{ - Q_D(Linkage); - QStringList temp; - if(msgData.isEmpty()) - return temp; - KbdTableModel *modelMsg = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_MSG); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - if(modelAct == NULL || modelMsg == NULL) - return temp; - - const ColMgrDataList& modelMsgCols = modelMsg->getHeadCols(); - QStringList unwrapMsgData = modelMsg->unwrapData(msgData); - QString hostName = unwrapMsgData.at(modelMsgCols.findCol(CN_HOST_NAME)); - QString msg = unwrapMsgData.at(modelMsgCols.findCol(CN_MSG)); - - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - { - return temp; - } - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - temp = modelAct->createDefaultValue(); - temp.replace(modelActCols.findCol(CN_NAME), - unwrapMsgData.at(modelMsgCols.findCol(CN_NAME))); - - temp.replace(modelActCols.findCol(CN_DESC), - unwrapMsgData.at(modelMsgCols.findCol(CN_DESC))); - temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), - "hint_ctrl*"+msg+"*"+hostName); - temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), - unwrapMsgData.at(modelMsgCols.findCol(CN_CTRL_TIMEOUT))); - temp.replace(modelActCols.findCol(CN_ACTION_TYPE), - act->data().toString()); - temp.replace(modelActCols.findCol(CN_LOCATION_ID), - unwrapMsgData.at(modelMsgCols.findCol(CN_LOCATION_ID))); - temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), - unwrapMsgData.at(modelMsgCols.findCol(CN_SUB_SYSTEM))); - temp.replace(modelActCols.findCol(CN_TIMEFLAG), - QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); - - return temp; -} - -QStringList Linkage::paDataToActData(const QStringList &paData) -{ - Q_D(Linkage); - QStringList temp; - if(paData.isEmpty()) - return temp; - KbdTableModel *modelPa = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PA); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - if(modelAct == NULL || modelPa == NULL) - return temp; - - const ColMgrDataList& modelPaCols = modelPa->getHeadCols(); - QStringList unwrapPaData = modelPa->unwrapData(paData); - QString ctrlType = unwrapPaData.at(modelPaCols.findCol(CN_CTRL_TYPE)); - QString paArea = unwrapPaData.at(modelPaCols.findCol(CN_PA_AREA)); - QString paAudio = unwrapPaData.at(modelPaCols.findCol(CN_PA_AUDIO)); - QString paRepeat = unwrapPaData.at(modelPaCols.findCol(CN_PA_REPEAT)); - QString paPriority = unwrapPaData.at(modelPaCols.findCol(CN_PA_PRIORITY)); - QString ctrlPoint = unwrapPaData.at(modelPaCols.findCol(CN_CTRL_POINT)); - QString playType = unwrapPaData.at(modelPaCols.findCol(CN_PLAY_TYPE)); - QString paOperator = unwrapPaData.at(modelPaCols.findCol("PA_OPERATOR")); - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - { - return temp; - } - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - temp = modelAct->createDefaultValue(); - temp.replace(modelActCols.findCol(CN_NAME), - unwrapPaData.at(modelPaCols.findCol(CN_NAME))); - - temp.replace(modelActCols.findCol(CN_DESC), - unwrapPaData.at(modelPaCols.findCol(CN_DESC))); - //目标域去掉,不需要 - temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), - "pa_ctrl*"+ctrlType+"*"+paArea+"*"+paAudio+"*"+paRepeat+"*"+paPriority+"*"+ctrlPoint+"*"+playType+"*"+paOperator); - temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), - unwrapPaData.at(modelPaCols.findCol(CN_CTRL_TIMEOUT))); - temp.replace(modelActCols.findCol(CN_ACTION_TYPE), - act->data().toString()); - temp.replace(modelActCols.findCol(CN_LOCATION_ID), - unwrapPaData.at(modelPaCols.findCol(CN_LOCATION_ID))); - temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), - unwrapPaData.at(modelPaCols.findCol(CN_SUB_SYSTEM))); - temp.replace(modelActCols.findCol(CN_TIMEFLAG), - QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); - - return temp; -} - -QStringList Linkage::pisDataToActData(const QStringList &pisData) -{ - Q_D(Linkage); - QStringList temp; - if(pisData.isEmpty()) - return temp; - KbdTableModel *modelPis = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PIS); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); - if(modelAct == NULL || modelPis == NULL) - return temp; - - QStringList unwrapPisData = modelPis->unwrapData(pisData); - const ColMgrDataList& modelPisCols = modelPis->getHeadCols(); - QString ctrlType = unwrapPisData.at(modelPisCols.findCol(CN_CTRL_TYPE)); - QString pisArea = unwrapPisData.at(modelPisCols.findCol(CN_PIS_AREA)); - QString pisMsg = unwrapPisData.at(modelPisCols.findCol(CN_PIS_MSG)); - QString pisTime = unwrapPisData.at(modelPisCols.findCol(CN_PIS_TIME)); - QString priority = unwrapPisData.at(modelPisCols.findCol(CN_PRIORITY)); - QString pisSpaceTime = unwrapPisData.at(modelPisCols.findCol(CN_PIS_SPACE_TIME)); - QString ctrlPoint = unwrapPisData.at(modelPisCols.findCol(CN_CTRL_POINT)); - QString pisMessage = unwrapPisData.at(modelPisCols.findCol("PIS_MESSAGE")); - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - { - return temp; - } - if(pisMsg.contains("*")) - { - onMsg(tr("发布内容包含非法字符*,请替换掉*字符")); - return temp; - } - - temp = modelAct->createDefaultValue(); - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - temp.replace(modelActCols.findCol(CN_NAME), - unwrapPisData.at(modelPisCols.findCol(CN_NAME))); - - temp.replace(modelActCols.findCol(CN_DESC), - unwrapPisData.at(modelPisCols.findCol(CN_DESC))); - //目标域去掉,不需要 - temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), - "pis_ctrl*"+ctrlType+"*"+pisArea+"*"+pisMsg+"*"+pisTime+"*"+priority+"*"+pisSpaceTime+"*"+ctrlPoint+"*"+pisMessage); - temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), - unwrapPisData.at(modelPisCols.findCol(CN_CTRL_TIMEOUT))); - temp.replace(modelActCols.findCol(CN_ACTION_TYPE), - act->data().toString()); - temp.replace(modelActCols.findCol(CN_LOCATION_ID), - unwrapPisData.at(modelPisCols.findCol(CN_LOCATION_ID))); - temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), - unwrapPisData.at(modelPisCols.findCol(CN_SUB_SYSTEM))); - temp.replace(modelActCols.findCol(CN_TIMEFLAG), - QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); - - return temp; -} - -QString Linkage::convertTriggerTypeToInt(const QString &strTriggerType) -{ - if(strTriggerType.compare("TRIGGER_CONDITION_DEFINE:条件触发",Qt::CaseInsensitive) == 0) - return "1:条件触发"; - else if(strTriggerType.compare("TRIGGER_TIMER_DEFINE:定时触发",Qt::CaseInsensitive) == 0) - return "2:定时触发"; - else if(strTriggerType.compare("TRIGGER_PERIOD_DEFINE:周期触发",Qt::CaseInsensitive) == 0) - return "3:周期触发"; - else - return "0:不触发"; -} - -QString Linkage::convertTriggerTypeToStr(const QString &intTriggerType) -{ - if(intTriggerType.compare("1:条件触发",Qt::CaseInsensitive) == 0) - return "TRIGGER_CONDITION_DEFINE:条件触发"; - else if(intTriggerType.compare("2:定时触发",Qt::CaseInsensitive) == 0) - return "TRIGGER_TIMER_DEFINE:定时触发"; - else if(intTriggerType.compare("3:周期触发",Qt::CaseInsensitive) == 0) - return "TRIGGER_PERIOD_DEFINE:周期触发"; - else - return "iot_debug_flag:不触发"; -} - -void Linkage::onActTypeChanged() -{ - Q_D(Linkage); - QAction *act = d->actGroupOfActs->checkedAction(); - if(act == NULL) - return; - QString filter = QString("%1='%2'").arg(CN_ACTION_TYPE).arg(act->data().toString()); - KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( - TBL_LINKAGE_ACTION,filter)); - if(modelAct == NULL) - return; - - modelAct->load(true); - d->tableActList->setModel(modelAct); - -} - -void Linkage::onSearchAct() -{ - Q_D(Linkage); - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - int colDesc = modelActCols.findCol(CN_DESC); - QString key = d->leSearchAct->text(); - - for(int i = 0; i < modelAct->rowCount(); i++) - { - if(modelAct->item(i,colDesc)->text().contains(key)) - d->tableActList->showRow(i); - else - d->tableActList->hideRow(i); - } -} - -void Linkage::onAddAction() -{ - Q_D(Linkage); - int actData = d->actGroupOfActs->checkedAction()->data().toInt(); - if(actData == 0) - addPscadaAction(); - else if(actData == 1) - addBasAction(); - else if(actData == 2) - addPaAction(); - else if(actData == 3) - addCctvAction(); - else if(actData == 4) - addPisAction(); - else if(actData == 5) - addPicAction(); - else if(actData == 6) - addMsgAction(); - else - QMessageBox::information(this,tr("消息"),tr("该动作未定义:")+d->actGroupOfActs->checkedAction()->text()); - -} - -void Linkage::onModifyAction() -{ - Q_D(Linkage); - int actData = d->actGroupOfActs->checkedAction()->data().toInt(); - if(actData == 0) - modifyPscadaAction(); - else if(actData == 1) - modifyBasAction(); - else if(actData == 2) - modifyPaAction(); - else if(actData == 3) - modifyCctvAction(); - else if(actData == 4) - modifyPisAction(); - else if(actData == 5) - modifyPicAction(); - else if(actData == 6) - modifyMsgAction(); - else - QMessageBox::information(this,tr("消息"),tr("该动作未定义:")+d->actGroupOfActs->checkedAction()->text()); - -} - -void Linkage::onRemoveAction() -{ - QUESTION_REMOVE(this) - Q_D(Linkage); - KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); - if(modelAct == NULL) - return; - QList list; - foreach (QModelIndex index, d->tableActList->selectionModel()->selectedRows()) { - list<< index.row(); - } - if(list.isEmpty()) - return; - const ColMgrDataList& modelActCols = modelAct->getHeadCols(); - QString actName; - int colActName = modelActCols.findCol(CN_NAME); - QStringList listFuncs; - KbdDbDesign ds; - foreach (int row, list) { - actName = modelAct->item(row,colActName)->text(); - if(!ds.actionInLinkageFunc(actName,listFuncs)) - { - return; - } - if(!listFuncs.isEmpty()) - { - onMsg(tr("以下功能使用了该动作,请先修改对应功能设置!\n") + listFuncs.join("\n")); - return; - } - } - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelAct->removeTableRows(list); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); - -} - -void Linkage::onFuncTypeChanged() -{ - Q_D(Linkage); - QAction *act = d->actGroupOfFuncs->checkedAction(); - if(act == NULL) - return; - QString filter = QString("%1='%2' GROUP BY NAME,DESCRIPTION").arg(CN_FUNC_TYPE).arg(act->data().toString()); - KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( - TBL_LINKAGE_FUNCTION_LIST,filter)); - if(modelFunc == NULL) - return; - - ColMgrDataList& modelCols = modelFunc->getHeadColsNoConst(); - - modelFunc->load(true); - modelCols.setHeadColUnique(CN_NAME,true); - d->tableFuncList->setModel(modelFunc); - d->tableActsOfFunc->setModel(NULL); -} - -void Linkage::onSearchFunc() -{ - Q_D(Linkage); - KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); - if(modelFunc == NULL) - return; - - const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); - int colDesc = modelFuncCols.findCol(CN_DESC); - QString key = d->leSearchFunc->text(); - - for(int i = 0; i < modelFunc->rowCount(); i++) - { - if(modelFunc->item(i,colDesc)->text().contains(key)) - d->tableFuncList->showRow(i); - else - d->tableFuncList->hideRow(i); - } - - -} - -void Linkage::onAddFunc() -{ - Q_D(Linkage); - KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_FUNCTION); - if(modelFunc == NULL) - return; - QAction *actType = d->actGroupOfFuncs->checkedAction(); - if(actType == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelFunc,modelFunc->rowCount()); - dlg.panel()->setPropertyValue(CN_FUNC_TYPE,actType->data().toString()); - dlg.panel()->setPropertyEditable(CN_NAME,true); - dlg.panel()->setPropertyEditable(CN_DESC,true); - dlg.panel()->setPropertyEditable(CN_ACTION_NAME,true); - dlg.panel()->setPropertyValue(CN_ACTION_NO,"1"); - if(dlg.exec()) - { - rowDatas = dlg.panel()->getPropertyData(); - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelFunc->addRow(rowDatas,false); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableActsOfFunc->setModel(NULL); - d->tableFuncList->reFresh(); - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::onModifyFunc() -{ - Q_D(Linkage); - KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); - if(modelFunc == NULL) - return; - QModelIndex index = d->tableFuncList->currentIndex(); - if(!index.isValid()) - return; - - QStringList newDatas; - QStringList oldDatas; - KbdPropertyDlg dlg(false,this); - QList cols ; - const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); - cols<setDisplayRow(modelFunc,index.row(), modelFuncCols.getGroup(),cols); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyEditable(CN_DESC,true); - if(dlg.exec()) - { - newDatas = dlg.panel()->getPropertyData(); - } - - if(newDatas.isEmpty()) - return; - - //判断是否重名 - QString newName = newDatas.at(modelFuncCols.findCol(CN_NAME)); - oldDatas = modelFunc->getRowData(index.row()); - QString oldName = oldDatas.at(modelFuncCols.findCol(CN_NAME)); - KbdDbDesign ds; - if(newName != oldName && ds.isExistLinkageFunc(newName)) - { - onMsg(tr("功能名称重复")); - return; - } - - //开启事务 - bool success = false; - QMap setValues; - QMap filterMap; - setValues.insert(CN_NAME,newDatas.at(modelFuncCols.findCol(CN_NAME))); - setValues.insert(CN_DESC,newDatas.at(modelFuncCols.findCol(CN_DESC))); - filterMap.insert(CN_NAME,oldDatas.at(modelFuncCols.findCol(CN_NAME))); - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelFunc->modifyRow(setValues,filterMap); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableFuncList->reFresh(); - d->tableActsOfFunc->setModel(NULL); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::onRemoveFunc() -{ - QUESTION_REMOVE(this) - Q_D(Linkage); - KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); - if(modelFunc == NULL) - return; - QList list; - foreach (QModelIndex index, d->tableFuncList->selectionModel()->selectedRows()) { - list<< index.row(); - } - if(list.isEmpty()) - return; - - QString funcName; - const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); - int colFuncName = modelFuncCols.findCol(CN_NAME); - QStringList listLinkages; - KbdDbDesign ds; - foreach (int row, list) { - funcName = modelFunc->item(row,colFuncName)->text(); - if(!ds.funcInLinkages(funcName,listLinkages)) - { - return; - } - if(!listLinkages.isEmpty()) - { - onMsg(tr("以下联动使用了该功能,请先修改对应联动设置!\n") + listLinkages.join("\n")); - return; - } - } - - //开启事务 - bool success = false; - QMap filterMap; - int colName = modelFuncCols.findCol(CN_NAME); - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - foreach (int row, list) { - filterMap.clear(); - filterMap.insert(CN_NAME,modelFunc->item(row,colName)->text()); - success = modelFunc->removeTableRows(filterMap); - if(!success) - break; - } - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableFuncList->reFresh(); - d->tableActsOfFunc->setModel(NULL); - KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); - -} - -void Linkage::onAddActOfFunc() -{ - Q_D(Linkage); - if(d->tableActsOfFunc->needSave()) - { - onMsg(tr("请先保存修改")); - return; - } - - KbdTableModel *modelActsOfFunc = qobject_cast(d->tableActsOfFunc->model()); - if(modelActsOfFunc == NULL) - { - onMsg(tr("请选中要添加的功能")); - return; - } - QAction *actType = d->actGroupOfFuncs->checkedAction(); - if(actType == NULL) - return; - QModelIndex index = d->tableFuncList->currentIndex(); - if(!index.isValid()) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - const ColMgrDataList& modelActsOfFuncCols = modelActsOfFunc->getHeadCols(); - QList cols = modelActsOfFuncCols.getShowCol(); - int colFuncName = modelActsOfFuncCols.findCol(CN_NAME); - int colFuncDesc = modelActsOfFuncCols.findCol(CN_DESC); - cols.removeAll(colFuncName); - cols.removeAll(colFuncDesc); - dlg.panel()->setDisplayRow(modelActsOfFunc,modelActsOfFunc->rowCount(), modelActsOfFuncCols.getGroup(),cols); - dlg.panel()->setPropertyEditable(CN_ACTION_NAME,true); - dlg.panel()->setPropertyValue(CN_FUNC_TYPE,actType->data().toString()); - dlg.panel()->setPropertyValue(CN_NAME,index.sibling(index.row(),colFuncName).data().toString()); - dlg.panel()->setPropertyValue(CN_DESC,index.sibling(index.row(),colFuncDesc).data().toString()); - if(dlg.exec()) - { - rowDatas = dlg.panel()->getPropertyData(); - - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelActsOfFunc->addRow(rowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableActsOfFunc->reFresh(); - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::onRemoveActOfFunc() -{ - QUESTION_REMOVE(this) - Q_D(Linkage); - if(d->tableActsOfFunc->needSave()) - { - onMsg(tr("请先保存修改")); - return; - } - KbdTableModel *modelActsOfFunc = qobject_cast(d->tableActsOfFunc->model()); - if(modelActsOfFunc == NULL) - return; - QList list; - foreach (QModelIndex index, d->tableActsOfFunc->selectionModel()->selectedRows()) { - list<< index.row(); - } - if(list.isEmpty()) - return; - - const ColMgrDataList& modelActsOfFuncCols = modelActsOfFunc->getHeadCols(); - QString funcName = modelActsOfFunc->item(list.first(),modelActsOfFuncCols.findCol(CN_NAME))->text(); - //FIX:有可能把功能自身删除了,所以要加入判断提示,假如把功能完全删除,先判断该功能是否有联动定义,有引用,有则提示,先删除联动定义 - if(list.size() == modelActsOfFunc->rowCount()) - { - KbdDbDesign ds; - QStringList linkages; - if(!ds.funcInLinkages(funcName,linkages)) - { - return; - } - if(!linkages.isEmpty()) - { - onMsg(tr("以下联动使用了该功能,请先修改对应联动设置!\n") + linkages.join("\n")); - return; - } - } - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelActsOfFunc->removeTableRows(list); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - - if(d->tableActsOfFunc->model()->rowCount() == 0) - d->tableActsOfFunc->setModel(NULL); - - d->tableFuncList->reFresh(); - d->tableActsOfFunc->reFresh(); - KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); -} - -void Linkage::onModifyActOfFunc() -{ - - Q_D(Linkage); - KbdTableModel *modelActsOfFunc = qobject_cast(d->tableActsOfFunc->model()); - if(modelActsOfFunc == NULL) - return; - - QModelIndex index = d->tableActsOfFunc->currentIndex(); - if(!index.isValid()) - { - onMsg(tr("请选中要修改的行")); - return; - } - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - const ColMgrDataList& modelActsOfFuncCols = modelActsOfFunc->getHeadCols(); - QList showCols = modelActsOfFuncCols.getShowCol(true); - showCols.removeAll(modelActsOfFuncCols.findCol(CN_NAME)); - showCols.removeAll(modelActsOfFuncCols.findCol(CN_DESC)); - showCols.removeAll(modelActsOfFuncCols.findCol(CN_TIMEFLAG)); - KbdPropertyDlg dlg(true,this); - dlg.panel()->setDisplayRow(modelActsOfFunc,index.row(), modelActsOfFuncCols.getGroup(),showCols); - if(dlg.exec()) - { - success = true; - } - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); - -} - -void Linkage::onFuncTableClicked(const QModelIndex &index) -{ - Q_D(Linkage); - if(!index.isValid()) - return; - KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); - if(modelFunc == NULL) - return; - const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); - int colFuncName = modelFuncCols.findCol(CN_NAME); - QString filter = QString("%1='%2' ORDER BY ACTION_NO").arg(CN_NAME).arg(index.sibling(index.row(),colFuncName).data().toString()); - KbdTableModel *modelActsOfFunc = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( - TBL_LINKAGE_FUNCTION,filter)); - if(modelActsOfFunc == NULL) - return; - d->tableActsOfFunc->setModel(modelActsOfFunc); -} - -void Linkage::onLinkageTypeChanged() -{ - Q_D(Linkage); - QAction *act = d->actGroupOfLinkage->checkedAction(); - if(act == NULL) - return; - QString filter = QString("%1='%2'").arg(CN_LINK_TYPE).arg(act->data().toString()); - KbdTableModel *modelLinkage = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( - TBL_LINKAGE_SETTING,filter)); - if(modelLinkage == NULL) - return; - - modelLinkage->load(true); - d->tableLinkageList->setModel(modelLinkage); - d->tableFuncOfLinkage->setModel(NULL); -} - -void Linkage::onSearchLinkage() -{ - Q_D(Linkage); - KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); - if(modelLinkageSetting == NULL) - return; - const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); - int colDesc = modelLinkageSettingCols.findCol(CN_DESC); - QString key = d->leSearchLinkage->text(); - - for(int i = 0; i < modelLinkageSetting->rowCount(); i++) - { - if(modelLinkageSetting->item(i,colDesc)->text().contains(key)) - d->tableLinkageList->showRow(i); - else - d->tableLinkageList->hideRow(i); - } -} - -void Linkage::onAddLinkage() -{ - Q_D(Linkage); - KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); - if(modelLinkageSetting == NULL) - return; - KbdTableModel *modelAddAndModify = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING_FOR_ADD_AND_MODIFY); - if(modelAddAndModify == NULL) - return; - - QAction *actType = d->actGroupOfLinkage->checkedAction(); - if(actType == NULL) - return; - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelAddAndModify,modelAddAndModify->rowCount()); - dlg.panel()->setPropertyValue(CN_LINK_TYPE,actType->data().toString()); - if(dlg.exec()) - { - rowDatas = dlg.panel()->getPropertyData(); - } - - if(rowDatas.isEmpty()) - return; - - const ColMgrDataList& modelAddAndModifyCols = modelAddAndModify->getHeadCols(); - //触发方式做以下转换 - QStringList newDatas = modelLinkageSetting->createDefaultValue(); - const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); - newDatas.replace(modelLinkageSettingCols.findCol(CN_NAME),rowDatas.at(modelAddAndModifyCols.findCol(CN_NAME))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_DESC),rowDatas.at(modelAddAndModifyCols.findCol(CN_DESC))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_TYPE))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_CONDITION),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_CONDITION))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_EXEC_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_EXEC_TYPE))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_LINK_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_LINK_TYPE))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_LOCATION_ID),rowDatas.at(modelAddAndModifyCols.findCol(CN_LOCATION_ID))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_TIMEFLAG),rowDatas.at(modelAddAndModifyCols.findCol(CN_TIMEFLAG))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_MUTEX_LIST),rowDatas.at(modelAddAndModifyCols.findCol(CN_MUTEX_LIST))); - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelLinkageSetting->addRow(newDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableFuncOfLinkage->setModel(NULL); - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::onModifyLinkage() -{ - Q_D(Linkage); - KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); - if(modelLinkageSetting == NULL) - return; - QModelIndex index = d->tableLinkageList->currentIndex(); - if(!index.isValid()) - return; - KbdTableModel *modelAddAndModify = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING_FOR_ADD_AND_MODIFY); - if(modelAddAndModify == NULL) - return; - - QStringList oldDatas = modelLinkageSetting->getRowData(index.row()); - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - - const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); - dlg.panel()->setDisplayRow(modelAddAndModify,modelAddAndModify->rowCount()); - dlg.panel()->setPropertyEditable(CN_NAME,false); - dlg.panel()->setPropertyValue(CN_NAME,oldDatas.at(modelLinkageSettingCols.findCol(CN_NAME))); - dlg.panel()->setPropertyValue(CN_DESC,oldDatas.at(modelLinkageSettingCols.findCol(CN_DESC))); - dlg.panel()->setPropertyValue(CN_TRIGGER_TYPE,oldDatas.at(modelLinkageSettingCols.findCol(CN_TRIGGER_TYPE))); - dlg.panel()->setPropertyValue(CN_TRIGGER_CONDITION,oldDatas.at(modelLinkageSettingCols.findCol(CN_TRIGGER_CONDITION))); - dlg.panel()->setPropertyValue(CN_EXEC_TYPE,oldDatas.at(modelLinkageSettingCols.findCol(CN_EXEC_TYPE))); - dlg.panel()->setPropertyValue(CN_LINK_TYPE,oldDatas.at(modelLinkageSettingCols.findCol(CN_LINK_TYPE))); - dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldDatas.at(modelLinkageSettingCols.findCol(CN_LOCATION_ID))); - dlg.panel()->setPropertyValue(CN_TIMEFLAG,oldDatas.at(modelLinkageSettingCols.findCol(CN_TIMEFLAG))); - dlg.panel()->setPropertyValue(CN_MUTEX_LIST,oldDatas.at(modelLinkageSettingCols.findCol(CN_MUTEX_LIST))); - - - if(dlg.exec()) - { - rowDatas = dlg.panel()->getPropertyData(); - } - - if(rowDatas.isEmpty()) - return; - const ColMgrDataList& modelAddAndModifyCols = modelAddAndModify->getHeadCols(); - QStringList newDatas = modelLinkageSetting->createDefaultValue(); - newDatas.replace(modelLinkageSettingCols.findCol(CN_NAME),rowDatas.at(modelAddAndModifyCols.findCol(CN_NAME))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_DESC),rowDatas.at(modelAddAndModifyCols.findCol(CN_DESC))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_TYPE))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_CONDITION),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_CONDITION))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_EXEC_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_EXEC_TYPE))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_LINK_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_LINK_TYPE))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_LOCATION_ID),rowDatas.at(modelAddAndModifyCols.findCol(CN_LOCATION_ID))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_TIMEFLAG),rowDatas.at(modelAddAndModifyCols.findCol(CN_TIMEFLAG))); - newDatas.replace(modelLinkageSettingCols.findCol(CN_MUTEX_LIST),rowDatas.at(modelAddAndModifyCols.findCol(CN_MUTEX_LIST))); - //开启事务 - bool success = false; - - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelLinkageSetting->modifyRow(index.row(),newDatas,true); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableFuncOfLinkage->reFresh(); - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::onRemoveLinkage() -{ - QUESTION_REMOVE(this) - //数据库触发器,会触发删除LINKAGE_DEFINE表中的内容 - Q_D(Linkage); - KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); - if(modelLinkageSetting == NULL) - return; - QList list; - foreach (QModelIndex index, d->tableLinkageList->selectionModel()->selectedRows()) { - list<< index.row(); - } - if(list.isEmpty()) - return; - - int ret = QMessageBox::No; - ret = QMessageBox::information(this,tr("消息"),tr("如果此联动正在执行或者已触发会导致联动终止,确定删除?"), - QMessageBox::Yes,QMessageBox::No); - if(ret != QMessageBox::Yes) - { - return; - } - //开启事务 - bool success = false; - - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelLinkageSetting->removeTableRows(list); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - - d->tableFuncOfLinkage->setModel(NULL); - KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); -} - -void Linkage::onAddFuncOfLinkage() -{ - Q_D(Linkage); - if(d->tableFuncOfLinkage->needSave()) - { - onMsg(tr("请先保存修改")); - return; - } - KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); - if(modelLinkageSetting == NULL) - return; - QModelIndex index = d->tableLinkageList->currentIndex(); - if(!index.isValid()) - return; - KbdTableModel *modelLinkageDefine = qobject_cast(d->tableFuncOfLinkage->model()); - if(modelLinkageDefine == NULL) - return; - - const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); - - QStringList rowDatas; - KbdPropertyDlg dlg(false,this); - dlg.panel()->setDisplayRow(modelLinkageDefine,modelLinkageDefine->rowCount()); - dlg.panel()->setPropertyEditable(CN_FUNC_NAME,true); - dlg.panel()->setPropertyValue(CN_LINKAGE_NAME,modelLinkageSetting->item(index.row(), - modelLinkageSettingCols.findCol(CN_NAME))->text()); - - if(dlg.exec()) - { - rowDatas = dlg.panel()->getPropertyData(); - - } - - if(rowDatas.isEmpty()) - return; - - //开启事务 - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelLinkageDefine->addRow(rowDatas); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - d->tableFuncOfLinkage->reFresh(); - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::onRemoveFuncOfLinkage() -{ - QUESTION_REMOVE(this) - Q_D(Linkage); - if(d->tableFuncOfLinkage->needSave()) - { - onMsg(tr("请先保存修改")); - return; - } - KbdTableModel *modelLinkageDefine = qobject_cast(d->tableFuncOfLinkage->model()); - if(modelLinkageDefine == NULL) - return; - QList list; - foreach (QModelIndex index, d->tableFuncOfLinkage->selectionModel()->selectedRows()) { - list<< index.row(); - } - if(list.isEmpty()) - return; - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = modelLinkageDefine->removeTableRows(list); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); -} - -void Linkage::onModifyFuncOfLinkage() -{ - //先获取原始数据,直接修改数据库,然后刷新控件 - Q_D(Linkage); - KbdTableModel *modelFuncOfLinkage = qobject_cast(d->tableFuncOfLinkage->model()); - if(modelFuncOfLinkage == NULL) - return; - QModelIndex index = d->tableFuncOfLinkage->currentIndex(); - if(!index.isValid()) - { - onMsg(tr("请选中要修改的行")); - return; - } - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - const ColMgrDataList& modelFuncOfLinkageCols = modelFuncOfLinkage->getHeadCols(); - QList showCols = modelFuncOfLinkageCols.getShowCol(true); - showCols.removeAll(modelFuncOfLinkageCols.findCol(CN_LINKAGE_NAME)); - showCols.removeAll(modelFuncOfLinkageCols.findCol(CN_TIMEFLAG)); - KbdPropertyDlg dlg(true,this); - dlg.panel()->setDisplayRow(modelFuncOfLinkage,index.row(), modelFuncOfLinkageCols.getGroup(),showCols); - if(dlg.exec()) - { - success = true; - } - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::onLinkageTableClicked(const QModelIndex &index) -{ - Q_D(Linkage); - if(!index.isValid()) - return; - KbdTableModel *modelLinkageSetting = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING); - if(modelLinkageSetting == NULL) - return; - - const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); - int colName = modelLinkageSettingCols.findCol(CN_NAME); - QString filter = QString("%1='%2' ORDER BY FUNC_NO").arg(CN_LINKAGE_NAME).arg(index.sibling(index.row(),colName).data().toString()); - KbdTableModel *model = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( - TBL_LINKAGE_DEFINE,filter)); - if(model == NULL) - return; - d->tableFuncOfLinkage->setModel(model); -} - -void Linkage::onTriggerTypeChanged() -{ - Q_D(Linkage); - QAction *act = d->actGroupTrigger->checkedAction(); - if(act == NULL) - return; - QString actData = act->data().toString(); - d->stackTrigger->setCurrentIndex(actData.toInt()); -} - -void Linkage::onAddTimer() -{ - Q_D(Linkage); - KbdTableModel *model = qobject_cast(d->tableTriggerTimer->model()); - if(model == NULL) - return; - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - KbdPropertyDlg dlg(true,this); - dlg.panel()->setDisplayRow(model,model->rowCount()); - if(dlg.exec()) - { - success = true; - } - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); -} - -void Linkage::onRemoveTimer() -{ - QUESTION_REMOVE(this) - Q_D(Linkage); - - KbdTableModel *model = qobject_cast(d->tableTriggerTimer->model()); - if(model == NULL) - return; - QList list; - foreach (QModelIndex index, d->tableTriggerTimer->selectionModel()->selectedRows()) { - list<< index.row(); - } - if(list.isEmpty()) - return; - - //后面加判断是否有引用该定时 - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - success = model->removeTableRows(list); - if(!success) - onMsg(tr("删除失败!")); - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); -} - -void Linkage::onModifyTimer() -{ - Q_D(Linkage); - - KbdTableModel *model = qobject_cast(d->tableTriggerTimer->model()); - if(model == NULL) - return; - QModelIndex index = d->tableTriggerTimer->currentIndex(); - if(!index.isValid()) - { - onMsg(tr("请选中要修改的条目")); - return; - } - - bool success = false; - QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); - if(retStr.isEmpty()) - { - KbdPropertyDlg dlg(true,this); - dlg.panel()->setDisplayRow(model,index.row()); - if(dlg.exec()) - { - success = true; - } - - if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) - onCommitError(); - } - else - onStartTransactionError(retStr); - - if(!success) - return; - - KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); -} - -void Linkage::onStartTransactionError(const QString&erroStr) -{ - QMessageBox::information(this,tr("消息"),erroStr); -} - -void Linkage::onCommitError() -{ - QMessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); -} - -void Linkage::onMsg(const QString &msg) -{ - QMessageBox::information(this,tr("消息"),msg); -} - - +#include "linkage.h" +#include +#include "kbdtabledatamgr.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kbdtable.h" +#include +#include +#include +#include "kbdpropertydlg.h" +#include "kbdpropertypanel.h" +#include "pub_widget/MessageBox.h" +#include "pub_widget/PubWidgetInit.h" +#include "kbddbdesign.h" +#include +#include "periodwidget.h" +#include "triggerfuncwidget.h" +#include "triggerparawidget.h" +#include "kbdmsgcontrl.h" +#include +#include +#include +#include +#include "cctvactdlg.h" + +class LinkagePrivate +{ + Linkage *q_ptr; + Q_DECLARE_PUBLIC(Linkage) +public: + QTabWidget *tab; + //联动动作 + KbdTable *tableActList; + QLineEdit *leSearchAct; + QActionGroup *actGroupOfActs; + //联动功能 + KbdTable *tableFuncList; + KbdTable *tableActsOfFunc; + QLineEdit *leSearchFunc; + QActionGroup *actGroupOfFuncs; + //联动定义 + KbdTable *tableLinkageList; + KbdTable *tableFuncOfLinkage; + QLineEdit *leSearchLinkage; + QActionGroup *actGroupOfLinkage; + //触发定义 + QStackedWidget *stackTrigger; + QActionGroup *actGroupTrigger; + KbdTable *tableTriggerTimer;//定时触发 + //周期触发 + KbdTable *tableTriggerPeriod; + QComboBox *cbPeriodType; + QTranslator* m_translates; + + + LinkagePrivate() { + loadTranslate(); + } + ~LinkagePrivate(){ + removeTranslate(); + } + void init(){ + initTableModule(); + initLayout(); + initData(); + } + + void initTableModule(); + void initLayout(); + void initData(); + void loadTranslate(); + void removeTranslate(); + + QWidget *initActWidget(); + QWidget *initFuncWidget(); + QWidget *initLinkageWidget(); + QWidget *initTriggerWidget(); + QWidget *timerWidget(); + QWidget *periodWidget(); + /** + * @brief pushToolBarData 把对应comboboxFormat的信息写入工具条,返回工具条的ActiongGroup + * @param bar + * @param comboboxFormat + */ + QActionGroup * pushToolBarData(QToolBar *bar, const QString &comboboxFormat); +}; + +void LinkagePrivate::initTableModule(){ +// QSettings settings("IOT","ISCS6000.tools"); +// KbdTableDataMgr::getInstance()->initDBLink(DataBaseInterface::DirectLink, +// settings.value("login/user","root").toString(), +// settings.value("login/psw","ems@byd23").toString(), +// settings.value("login/ip","192.168.190.128").toString(), +// settings.value("login/port","3306").toInt(), +// settings.value("login/dbname","ISCS6000").toString(), +// DataBaseInterface::MySql +// ); + KbdTableDataMgr::getInstance()->initDBLink(DataBaseInterface::CenterLink); +} + +void LinkagePrivate::initLayout(){ + Q_Q(Linkage); + tab = new QTabWidget(q); + tab->addTab(initActWidget(), QObject::tr("联动动作")); + tab->addTab(initFuncWidget(), QObject::tr("联动功能")); + tab->addTab(initLinkageWidget(), QObject::tr("联动定义")); + tab->addTab(initTriggerWidget(), QObject::tr("触发定义")); + + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->addWidget(tab); + q->setLayout(hLayout); +} + +void LinkagePrivate::initData(){ + Q_Q(Linkage); + if(!actGroupOfActs->actions().isEmpty()) + actGroupOfActs->actions().first()->setChecked(true); + if(!actGroupOfFuncs->actions().isEmpty()) + actGroupOfFuncs->actions().first()->setChecked(true); + if(!actGroupOfLinkage->actions().isEmpty()) + actGroupOfLinkage->actions().first()->setChecked(true); + if(!actGroupTrigger->actions().isEmpty()) + actGroupTrigger->actions().first()->setChecked(true); + + QObject::connect(actGroupOfActs,SIGNAL(triggered(QAction*)),q,SLOT(onActTypeChanged())); + QObject::connect(actGroupOfFuncs,SIGNAL(triggered(QAction*)),q,SLOT(onFuncTypeChanged())); + QObject::connect(actGroupOfLinkage,SIGNAL(triggered(QAction*)),q,SLOT(onLinkageTypeChanged())); + QObject::connect(actGroupTrigger,SIGNAL(triggered(QAction*)),q,SLOT(onTriggerTypeChanged())); + + q->onActTypeChanged(); + q->onFuncTypeChanged(); + q->onLinkageTypeChanged(); + + tableFuncList->useDefaultHidePolicy(false); + tableActsOfFunc->useDefaultHidePolicy(false); + KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_FUNCTION); + if(modelFunc) + { + const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); + QList cols; + int colName = modelFuncCols.findCol(CN_NAME); + int colDesc = modelFuncCols.findCol(CN_DESC); + cols << colName << colDesc; + tableFuncList->setShowCol(cols); + cols = modelFuncCols.getShowCol(); + cols.removeAll(colName); + cols.removeAll(colDesc); + tableActsOfFunc->setShowCol(cols); + } + QObject::connect(tableFuncList,SIGNAL(clicked(const QModelIndex &)), + q,SLOT(onFuncTableClicked(const QModelIndex &))); + QObject::connect(tableLinkageList,SIGNAL(clicked(const QModelIndex &)), + q,SLOT(onLinkageTableClicked(const QModelIndex &))); + QObject::connect(tableTriggerTimer,SIGNAL(doubleClicked(const QModelIndex &)), + q,SLOT(onModifyTimer())); + + KbdTableModel *modelTimer = KbdTableDataMgr::getInstance()->createModel(TBL_TRIGGER_TIMER_DEFINE); + tableTriggerTimer->setModel(modelTimer); + +} + +void LinkagePrivate::loadTranslate() +{ + m_translates = new QTranslator; + m_translates->load(Common::getTranslatePath("model_linkage_EN.qm")); + qApp->installTranslator(m_translates); + iot_public::installTranslator(Common::getLanguage().toStdString()); +} + +void LinkagePrivate::removeTranslate() +{ + qApp->removeTranslator(m_translates); +} + +QWidget *LinkagePrivate::initActWidget(){ + Q_Q(Linkage); + + QGroupBox *boxActType = new QGroupBox(QObject::tr("动作类型"),tab); + QGroupBox *boxActList = new QGroupBox(QObject::tr("动作列表"),tab); + + //左侧工具条 + QScrollArea *area = new QScrollArea(boxActType); + QToolBar *bar = new QToolBar(area); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + QString comboboxFormat = ""; + if(modelAct) + { + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + comboboxFormat = modelActCols.at(modelActCols.findCol(CN_ACTION_TYPE)).valueLimit; + } + actGroupOfActs = pushToolBarData(bar,comboboxFormat); + + area->setWidget(bar); + area->setBackgroundRole(QPalette::Light); + area->verticalScrollBar()->setVisible(false); + area->horizontalScrollBar()->setVisible(false); + area->setAlignment(Qt::AlignHCenter); + QHBoxLayout *hLayout1 = new QHBoxLayout; + hLayout1->addWidget(area); + boxActType->setLayout(hLayout1); + + //右上角动作列表 + QHBoxLayout *hLayout2 = new QHBoxLayout; + + QHBoxLayout *hLayoutSearch = new QHBoxLayout; + QToolBar *topBar = new QToolBar(boxActList); //动作列表中的工具栏 + QAction* act = nullptr; + act = topBar->addAction(QObject::tr("添加记录"),q,SLOT(onAddAction())); + topBar->widgetForAction(act)->setObjectName("icon_add"); + act = topBar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyAction())); + topBar->widgetForAction(act)->setObjectName("icon_edit"); + act = topBar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveAction())); + topBar->widgetForAction(act)->setObjectName("icon_delete"); + leSearchAct = new QLineEdit(boxActList); + leSearchAct->setPlaceholderText(QObject::tr("搜索动作描述")); + + hLayoutSearch->addWidget(topBar); + hLayoutSearch->addWidget(leSearchAct); + tableActList = new KbdTable(boxActList); + QVBoxLayout *vLayoutTable = new QVBoxLayout; + vLayoutTable->addLayout(hLayoutSearch); + vLayoutTable->addWidget(tableActList); + + hLayout2->addLayout(vLayoutTable); + boxActList->setLayout(hLayout2); + + //右下角动作定义 + QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); + hSplitter->addWidget(boxActType); + hSplitter->addWidget(boxActList); + hSplitter->setSizes(QList()<<150<<1150); + hSplitter->setContentsMargins(0,10,0,0); + + QObject::connect(leSearchAct,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchAct())); + QObject::connect(tableActList,SIGNAL(doubleClicked(const QModelIndex &)), + q,SLOT(onModifyAction())); + + return hSplitter; +} + +QWidget *LinkagePrivate::initFuncWidget(){ + Q_Q(Linkage); + + QGroupBox *boxFuncType = new QGroupBox(QObject::tr("功能类型"),tab); + QGroupBox *boxFuncList = new QGroupBox(QObject::tr("功能列表"),tab); + QGroupBox *boxActsOfFunc = new QGroupBox(QObject::tr("功能所含动作列表"),tab); + + //左侧工具条 + QScrollArea *area = new QScrollArea(boxFuncType); + QToolBar *bar = new QToolBar(area); + KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_FUNCTION); + QString comboboxFormat = ""; + if(modelFunc) + { + const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); + comboboxFormat = modelFuncCols.at(modelFuncCols.findCol(CN_FUNC_TYPE)).valueLimit; + } + actGroupOfFuncs = pushToolBarData(bar,comboboxFormat); + + area->setWidget(bar); + area->setBackgroundRole(QPalette::Light); + area->verticalScrollBar()->setVisible(false); + area->horizontalScrollBar()->setVisible(false); + area->setAlignment(Qt::AlignHCenter); + QHBoxLayout *hLayout1 = new QHBoxLayout; + hLayout1->addWidget(area); + boxFuncType->setLayout(hLayout1); + + //右上角列表 + QHBoxLayout *hLayout2 = new QHBoxLayout; + + QHBoxLayout *hLayoutSearch = new QHBoxLayout; + + QToolBar *topBar = new QToolBar(boxFuncList); //功能列表中的工具栏 + QAction* act = nullptr; + act = topBar->addAction(QObject::tr("添加记录"),q,SLOT(onAddFunc())); + topBar->widgetForAction(act)->setObjectName("icon_add"); + act = topBar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyFunc())); + topBar->widgetForAction(act)->setObjectName("icon_edit"); + act = topBar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveFunc())); + topBar->widgetForAction(act)->setObjectName("icon_delete"); + + leSearchFunc = new QLineEdit(boxFuncList); + leSearchFunc->setPlaceholderText(QObject::tr("搜索功能描述")); + hLayoutSearch->addWidget(topBar); + hLayoutSearch->addWidget(leSearchFunc); + + tableFuncList = new KbdTable(boxFuncList); + QVBoxLayout *vLayoutTable = new QVBoxLayout; + vLayoutTable->addLayout(hLayoutSearch); + vLayoutTable->addWidget(tableFuncList); + + hLayout2->addLayout(vLayoutTable); + boxFuncList->setLayout(hLayout2); + + //右下角功能列表 + QVBoxLayout *vLayoutBox = new QVBoxLayout; + QToolBar *toolbar = new QToolBar(boxActsOfFunc); + tableActsOfFunc = new KbdTable(boxActsOfFunc); + act = toolbar->addAction(QObject::tr("添加记录"),q,SLOT(onAddActOfFunc())); + toolbar->widgetForAction(act)->setObjectName("icon_add"); + act = toolbar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyActOfFunc())); + toolbar->widgetForAction(act)->setObjectName("icon_edit"); + act = toolbar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveActOfFunc())); + toolbar->widgetForAction(act)->setObjectName("icon_delete"); + + vLayoutBox->addWidget(toolbar); + vLayoutBox->addWidget(tableActsOfFunc); + boxActsOfFunc->setLayout(vLayoutBox); + + QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); + QSplitter *vSplitter = new QSplitter(Qt::Vertical,hSplitter); + vSplitter->addWidget(boxFuncList); + vSplitter->addWidget(boxActsOfFunc); + hSplitter->addWidget(boxFuncType); + hSplitter->addWidget(vSplitter); + hSplitter->setSizes(QList()<<150<<1150); + vSplitter->setSizes(QList()<<200<<200); + hSplitter->setContentsMargins(0,10,0,0); + + QObject::connect(leSearchFunc,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchFunc())); + QObject::connect(tableFuncList,SIGNAL(doubleClicked(const QModelIndex &)), + q,SLOT(onModifyFunc())); + QObject::connect(tableActsOfFunc,SIGNAL(doubleClicked(const QModelIndex &)),q,SLOT(onModifyActOfFunc())); + return hSplitter; +} + +QWidget *LinkagePrivate::initLinkageWidget(){ + Q_Q(Linkage); + + QGroupBox *boxLinkageType = new QGroupBox(QObject::tr("联动类型"),tab); + QGroupBox *boxLinkageList = new QGroupBox(QObject::tr("联动列表"),tab); + QGroupBox *boxFuncOfLinkage = new QGroupBox(QObject::tr("联动所含功能列表"),tab); + + //左侧工具条 + QScrollArea *area = new QScrollArea(boxLinkageType); + QToolBar *bar = new QToolBar(area); + KbdTableModel *modelLinkageSettiing = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING); + QString comboboxFormat = ""; + if(modelLinkageSettiing) + { + const ColMgrDataList& modelLinkageSettiingCols = modelLinkageSettiing->getHeadCols(); + comboboxFormat = modelLinkageSettiingCols.at(modelLinkageSettiingCols.findCol(CN_LINK_TYPE)).valueLimit; + } + actGroupOfLinkage = pushToolBarData(bar,comboboxFormat); + + area->setWidget(bar); + area->setBackgroundRole(QPalette::Light); + area->verticalScrollBar()->setVisible(false); + area->horizontalScrollBar()->setVisible(false); + area->setAlignment(Qt::AlignHCenter); + QHBoxLayout *hLayout1 = new QHBoxLayout; + hLayout1->addWidget(area); + boxLinkageType->setLayout(hLayout1); + + //右上角列表 + QHBoxLayout *hLayout2 = new QHBoxLayout; + + QHBoxLayout *hLayoutSearch = new QHBoxLayout; + + QToolBar *topBar = new QToolBar(boxLinkageList); //联动列表中的工具栏 + QAction* act = nullptr; + act = topBar->addAction(QObject::tr("添加记录"),q,SLOT(onAddLinkage())); + topBar->widgetForAction(act)->setObjectName("icon_add"); + act = topBar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyLinkage())); + topBar->widgetForAction(act)->setObjectName("icon_edit"); + act = topBar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveLinkage())); + topBar->widgetForAction(act)->setObjectName("icon_delete"); + leSearchLinkage = new QLineEdit(boxLinkageList); + leSearchLinkage->setPlaceholderText(QObject::tr("搜索联动描述")); + + hLayoutSearch->addWidget(topBar); + hLayoutSearch->addWidget(leSearchLinkage); + + tableLinkageList = new KbdTable(boxLinkageList); + QVBoxLayout *vLayoutTable = new QVBoxLayout; + vLayoutTable->addLayout(hLayoutSearch); + vLayoutTable->addWidget(tableLinkageList); + + hLayout2->addLayout(vLayoutTable); + boxLinkageList->setLayout(hLayout2); + + //右下角功能列表 + QVBoxLayout *vLayoutBox = new QVBoxLayout; + QToolBar *toolbar = new QToolBar(boxFuncOfLinkage); + tableFuncOfLinkage = new KbdTable(boxFuncOfLinkage); + act = toolbar->addAction(QObject::tr("添加记录"),q,SLOT(onAddFuncOfLinkage())); + toolbar->widgetForAction(act)->setObjectName("icon_add"); + act = toolbar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyFuncOfLinkage())); + toolbar->widgetForAction(act)->setObjectName("icon_edit"); + act = toolbar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveFuncOfLinkage())); + toolbar->widgetForAction(act)->setObjectName("icon_delete"); + + vLayoutBox->addWidget(toolbar); + vLayoutBox->addWidget(tableFuncOfLinkage); + boxFuncOfLinkage->setLayout(vLayoutBox); + + QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); + QSplitter *vSplitter = new QSplitter(Qt::Vertical,hSplitter); + vSplitter->addWidget(boxLinkageList); + vSplitter->addWidget(boxFuncOfLinkage); + hSplitter->addWidget(boxLinkageType); + hSplitter->addWidget(vSplitter); + hSplitter->setSizes(QList()<<150<<1150); + vSplitter->setSizes(QList()<<200<<200); + hSplitter->setContentsMargins(0,10,0,0); + + QObject::connect(tableLinkageList,SIGNAL(doubleClicked(const QModelIndex &)), + q,SLOT(onModifyLinkage())); + + QObject::connect(leSearchLinkage,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchLinkage())); + QObject::connect(tableFuncOfLinkage,SIGNAL(doubleClicked(const QModelIndex &)),q,SLOT(onModifyFuncOfLinkage())); + return hSplitter; +} + +QWidget *LinkagePrivate::initTriggerWidget() +{ + + QSplitter *hSplitter = new QSplitter(Qt::Horizontal,tab); + QGroupBox *boxType = new QGroupBox(QObject::tr("触发类型"),hSplitter); + stackTrigger = new QStackedWidget(hSplitter); + + //左侧工具条 + QScrollArea *area = new QScrollArea(boxType); + QToolBar *bar = new QToolBar(area); + QString comboboxFormat = QObject::tr("0:定时触发/1:周期触发/2:触发函数/3:触发器定义"); + actGroupTrigger = pushToolBarData(bar,comboboxFormat); + area->setWidget(bar); + area->setBackgroundRole(QPalette::Light); + area->verticalScrollBar()->setVisible(false); + area->horizontalScrollBar()->setVisible(false); + area->setAlignment(Qt::AlignHCenter); + + QHBoxLayout *hLayout1 = new QHBoxLayout; + hLayout1->addWidget(area); + boxType->setLayout(hLayout1); + + //右边 + stackTrigger->addWidget(timerWidget()); + stackTrigger->addWidget(new PeriodWidget(stackTrigger)); + stackTrigger->addWidget(new TriggerFuncWidget(stackTrigger)); + stackTrigger->addWidget(new TriggerParaWidget(stackTrigger)); + + hSplitter->addWidget(boxType); + hSplitter->addWidget(stackTrigger); + hSplitter->setSizes(QList()<<150<<1150); + hSplitter->setContentsMargins(0,10,0,0); + + return hSplitter; +} + +QWidget *LinkagePrivate::timerWidget() +{ + Q_Q(Linkage); + QWidget *widget = new QWidget(stackTrigger); + QVBoxLayout *vLayout = new QVBoxLayout; + tableTriggerTimer = new KbdTable(widget); + + QToolBar *topBar = new QToolBar(widget); //触发器-定时触发列表中的工具栏 + QAction* act = nullptr; + act = topBar->addAction(QObject::tr("添加记录"),q,SLOT(onAddTimer())); + topBar->widgetForAction(act)->setObjectName("icon_add"); + act = topBar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyTimer())); + topBar->widgetForAction(act)->setObjectName("icon_edit"); + act = topBar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveTimer())); + topBar->widgetForAction(act)->setObjectName("icon_delete"); + + QHBoxLayout *hLayoutSearch = new QHBoxLayout; + hLayoutSearch->addWidget(topBar); + + vLayout->addLayout(hLayoutSearch); + vLayout->addWidget(tableTriggerTimer); + widget->setLayout(vLayout); + + return widget; +} + +QWidget *LinkagePrivate::periodWidget() +{ + QWidget *widget = new QWidget(stackTrigger); + + QHBoxLayout *hLayoutTop = new QHBoxLayout; + tableTriggerPeriod = new KbdTable(widget); + QVBoxLayout *vLayoutVts = new QVBoxLayout; + QPushButton *btAdd = new QPushButton(QObject::tr("添加"),widget); + QPushButton *btRemove = new QPushButton(QObject::tr("删除"),widget); + vLayoutVts->addWidget(btAdd); + vLayoutVts->addWidget(btRemove); + hLayoutTop->addWidget(tableTriggerPeriod); + hLayoutTop->addLayout(vLayoutVts); + + PeriodWidget *periodWidget = new PeriodWidget(widget); + QPushButton *btSave = new QPushButton(QObject::tr("保存"),widget); + QHBoxLayout *hLayoutSave = new QHBoxLayout; + hLayoutSave->addStretch(); + hLayoutSave->addWidget(btSave); + hLayoutSave->addStretch(); + + QVBoxLayout *vLayout = new QVBoxLayout; + vLayout->addLayout(hLayoutTop); + vLayout->addWidget(periodWidget); + vLayout->addLayout(hLayoutSave); + + widget->setLayout(vLayout); + return widget; +} + +QActionGroup * LinkagePrivate::pushToolBarData(QToolBar *bar, const QString &comboboxFormat) +{ + Q_ASSERT(bar != NULL); + + bar->clear(); + bar->setOrientation(Qt::Vertical); + bar->setBackgroundRole(QPalette::Light); + bar->setStyleSheet("spacing:10px;margin-top:5px;font:14px;"); + + QActionGroup *actGroup = new QActionGroup(bar); + actGroup->setExclusive(true); + QStringList list = comboboxFormat.split("/"); + QStringList list2; + QAction *act; + + foreach (QString element, list) { + if(element.isEmpty()) + continue; + + list2 = element.split(":"); + act = new QAction(list2.last(),bar); + act->setData(list2.first()); + bar->addAction(act); + + actGroup->addAction(act); + act->setCheckable(true); + } + + return actGroup; + +} + +Linkage::Linkage(QWidget *parent):QWidget(parent) +{ + d_ptr = new LinkagePrivate; + d_ptr->q_ptr = this; + d_ptr->init(); +} + +Linkage::~Linkage() +{ + if(d_ptr) + delete d_ptr; +} + +void Linkage::addPscadaAction() +{ + Q_D(Linkage); + KbdTableModel *modelActPscada = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PSCADA); + if(modelActPscada == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动动作")); + dlg.panel()->setDisplayRow(modelActPscada,modelActPscada->rowCount()); + if(dlg.exec()) + { + //根据返回的点,分割.字符,获取车站和设备 + rowDatas = pscadaDataToActData( dlg.panel()->getPropertyData()); + if(rowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->addRow(rowDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:(success=success&&false)) + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::addBasAction() +{ + Q_D(Linkage); + KbdTableModel *modelActBas = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_BAS); + if(modelActBas == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动动作")); + dlg.panel()->setDisplayRow(modelActBas,modelActBas->rowCount()); + if(dlg.exec()) + { + //根据返回的点,分割.字符,获取车站和设备 + rowDatas = basDataToActData(dlg.panel()->getPropertyData()); + if(rowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->addRow(rowDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::addPaAction() +{ + Q_D(Linkage); + KbdTableModel *modelActPa = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PA); + if(modelActPa == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动动作")); + dlg.panel()->setDisplayRow(modelActPa,modelActPa->rowCount()); + if(dlg.exec()) + { + //根据返回的点,分割.字符,获取车站和设备 + rowDatas = paDataToActData(dlg.panel()->getPropertyData()); + if(rowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->addRow(rowDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::addCctvAction() +{ + Q_D(Linkage); + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + CctvActDlg dlg(modelAct,this); + dlg.exec(); +} + +void Linkage::addPisAction() +{ + Q_D(Linkage); + KbdTableModel *modelActPis = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PIS); + if(modelActPis == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动动作")); + dlg.panel()->setDisplayRow(modelActPis,modelActPis->rowCount()); + if(dlg.exec()) + { + //根据返回的点,分割.字符,获取车站和设备 + rowDatas = pisDataToActData(dlg.panel()->getPropertyData()); + if(rowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->addRow(rowDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::addPicAction() +{ + Q_D(Linkage); + KbdTableModel *modelPushPic = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PUSH_PIC); + if(modelPushPic == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动动作")); + dlg.panel()->setDisplayRow(modelPushPic,modelPushPic->rowCount()); + if(dlg.exec()) + { + //根据返回的点,分割.字符,获取车站和设备 + rowDatas = pushPicDataToActData(dlg.panel()->getPropertyData()); + if(rowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->addRow(rowDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::addMsgAction() +{ + Q_D(Linkage); + KbdTableModel *modelMsg = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_MSG); + if(modelMsg == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动动作")); + dlg.panel()->setDisplayRow(modelMsg,modelMsg->rowCount()); + if(dlg.exec()) + { + //根据返回的点,分割.字符,获取车站和设备 + rowDatas = msgDataToActData(dlg.panel()->getPropertyData()); + if(rowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->addRow(rowDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::modifyPscadaAction() +{ + Q_D(Linkage); + KbdTableModel *modelActPscada = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PSCADA); + if(modelActPscada == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList newRowDatas; + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动动作")); + dlg.panel()->setDisplayRow(modelActPscada,modelActPscada->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); + QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); + QStringList listStr = linkageStr.split("*"); + if(listStr.size() != 3) + return; + dlg.panel()->setPropertyValue(CN_CTRL_POINT,listStr.at(1)); + dlg.panel()->setPropertyValue(CN_CTRL_TYPE,listStr.at(2)); + dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); + if(dlg.exec()) + { + newRowDatas = pscadaDataToActData(dlg.panel()->getPropertyData()); + if(newRowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(newRowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->modifyRow(oldRowDatas,newRowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + onActTypeChanged(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::modifyBasAction() +{ + Q_D(Linkage); + KbdTableModel *modelActBas = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_BAS); + if(modelActBas == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList newRowDatas; + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动动作")); + dlg.panel()->setDisplayRow(modelActBas,modelActBas->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); + QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); + QStringList listStr = linkageStr.split("*"); + if(listStr.size() != 3) + return; + dlg.panel()->setPropertyValue(CN_CTRL_POINT,listStr.at(1)); + dlg.panel()->setPropertyValue(CN_CTRL_TYPE,listStr.at(2)); + dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); + if(dlg.exec()) + { + newRowDatas = basDataToActData(dlg.panel()->getPropertyData()); + if(newRowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(newRowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->modifyRow(oldRowDatas,newRowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + onActTypeChanged(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::modifyPaAction() +{ + Q_D(Linkage); + KbdTableModel *modelActPa = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PA); + if(modelActPa == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList newRowDatas; + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + QStringList strList = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)).split("*"); + if(strList.size() != 10) + { + onMsg(tr("动作内容错误")); + return; + } + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动动作")); + dlg.panel()->setDisplayRow(modelActPa,modelActPa->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); + dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); + + dlg.panel()->setPropertyValue(CN_CTRL_TYPE,strList.at(1)); + dlg.panel()->setPropertyValue(CN_PA_AREA,strList.at(2)+"*"+strList.at(3)); + dlg.panel()->setPropertyValue(CN_PA_AUDIO,strList.at(4)); + dlg.panel()->setPropertyValue(CN_PA_REPEAT,strList.at(5)); + dlg.panel()->setPropertyValue(CN_PA_PRIORITY,strList.at(6)); + dlg.panel()->setPropertyValue(CN_CTRL_POINT,strList.at(7)); + dlg.panel()->setPropertyValue(CN_PLAY_TYPE,strList.at(8)); + dlg.panel()->setPropertyValue("PA_OPERATOR",strList.at(9)); + + if(dlg.exec()) + { + newRowDatas = paDataToActData(dlg.panel()->getPropertyData()); + if(newRowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(newRowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->modifyRow(oldRowDatas,newRowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + onActTypeChanged(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::modifyCctvAction() +{ + Q_D(Linkage); + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList unWrapDatas = modelAct->unwrapData(oldRowDatas); + CctvActDlg dlg(modelAct,unWrapDatas, this); + dlg.exec(); +} + +void Linkage::modifyPisAction() +{ + Q_D(Linkage); + KbdTableModel *modelActPis = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PIS); + if(modelActPis == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList newRowDatas; + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + QStringList strList = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)).split("*"); + if(strList.size() != 10) + { + onMsg(tr("动作内容错误")); + return; + } + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动动作")); + dlg.panel()->setDisplayRow(modelActPis,modelActPis->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); + dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); + + dlg.panel()->setPropertyValue(CN_CTRL_TYPE,strList.at(1)); + dlg.panel()->setPropertyValue(CN_PIS_AREA,strList.at(2)+"*"+strList.at(3)); + dlg.panel()->setPropertyValue(CN_PIS_MSG,strList.at(4)); + dlg.panel()->setPropertyValue(CN_PIS_TIME,strList.at(5)); + dlg.panel()->setPropertyValue(CN_PRIORITY,strList.at(6)); + dlg.panel()->setPropertyValue(CN_PIS_SPACE_TIME,strList.at(7)); + dlg.panel()->setPropertyValue(CN_CTRL_POINT,strList.at(8)); + dlg.panel()->setPropertyValue("PIS_MESSAGE",strList.at(9)); + + if(dlg.exec()) + { + newRowDatas = pisDataToActData(dlg.panel()->getPropertyData()); + if(newRowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(newRowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->modifyRow(oldRowDatas,newRowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + onActTypeChanged(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::modifyPicAction() +{ + Q_D(Linkage); + KbdTableModel *modelPushPic = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PUSH_PIC); + if(modelPushPic == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList newRowDatas; + + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动动作")); + dlg.panel()->setDisplayRow(modelPushPic,modelPushPic->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); + QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); + QStringList listStr = linkageStr.split("*"); + if(listStr.size() != 3) + return; + dlg.panel()->setPropertyValue(CN_PIC_NAME,listStr.at(1)); + dlg.panel()->setPropertyValue(CN_HOST_NAME,listStr.at(2)); + dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); + if(dlg.exec()) + { + newRowDatas = pushPicDataToActData(dlg.panel()->getPropertyData()); + if(newRowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(newRowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->modifyRow(oldRowDatas,newRowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + onActTypeChanged(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::modifyMsgAction() +{ + Q_D(Linkage); + KbdTableModel *modelMsg = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_MSG); + if(modelMsg == NULL) + return; + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QModelIndex index = d->tableActList->currentIndex(); + if(!index.isValid()) + return; + + QStringList oldRowDatas = modelAct->getRowData(index.row()); + QStringList newRowDatas; + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动动作")); + dlg.panel()->setDisplayRow(modelMsg,modelMsg->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldRowDatas.at(modelActCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldRowDatas.at(modelActCols.findCol(CN_DESC))); + QString linkageStr = oldRowDatas.at(modelActCols.findCol(CN_LINKAGE_STRING)); + QStringList listStr = linkageStr.split("*"); + if(listStr.size() != 3) + return; + dlg.panel()->setPropertyValue(CN_MSG,listStr.at(1)); + dlg.panel()->setPropertyValue(CN_HOST_NAME,listStr.at(2)); + dlg.panel()->setPropertyValue(CN_CTRL_TIMEOUT,oldRowDatas.at(modelActCols.findCol(CN_CTRL_TIMEOUT))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldRowDatas.at(modelActCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_SUB_SYSTEM,oldRowDatas.at(modelActCols.findCol(CN_SUB_SYSTEM))); + if(dlg.exec()) + { + newRowDatas = msgDataToActData(dlg.panel()->getPropertyData()); + if(newRowDatas.isEmpty()) + { + onMsg(tr("联动动作定义错误")); + return; + } + } + + if(newRowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->modifyRow(oldRowDatas,newRowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + onActTypeChanged(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +bool Linkage::getLocationInfo(const QString &keyIdTag, QString &locationId, QString &subSystem) +{ + QStringList pointList = keyIdTag.split("."); + if(pointList.size() != 5)//必须是表名+TAG_NAME的形式 + return false; + QString tableName = pointList.first(); + pointList.removeFirst(); + pointList.removeLast(); + QString sql = QString("SELECT * FROM %1 WHERE TAG_NAME = '%2';").arg(tableName) + .arg(pointList.join(".")); + QSqlQuery result; + if(!KbdTableDataMgr::getInstance()->selectOnly(sql,result)) + return false; + + if(result.size() == 1) + { + while (result.next()) { + locationId = result.value(CN_LOCATION_ID).toString(); + subSystem = result.value(CN_SUB_SYSTEM).toString(); + break; + } + return true; + } + else + return false; +} + +QStringList Linkage::pscadaDataToActData(const QStringList &pscadaData) +{ + Q_D(Linkage); + QStringList temp; + if(pscadaData.isEmpty()) + return temp; + KbdTableModel *modelActPscada = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PSCADA); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + if(modelAct == NULL || modelActPscada == NULL) + return temp; + const ColMgrDataList& modelActPscadaCols = modelActPscada->getHeadCols(); + QStringList unwrapPscadaData = modelActPscada->unwrapData(pscadaData); + QString ctrlPoint = unwrapPscadaData.at(modelActPscadaCols.findCol(CN_CTRL_POINT)); + QString ctrlType = unwrapPscadaData.at(modelActPscadaCols.findCol(CN_CTRL_TYPE)); + + QStringList dotList = ctrlPoint.split("."); + if(dotList.size() != 5) + return temp; + + QString pointType; + if(QString("ANALOG").compare(dotList.first(),Qt::CaseInsensitive) == 0) + { + pointType = "ao_ctrl"; + } + else if(QString("DIGITAL").compare(dotList.first(),Qt::CaseInsensitive) == 0) + { + pointType = "do_ctrl"; + } + else if(QString("MIX").compare(dotList.first(),Qt::CaseInsensitive) == 0) + { + pointType = "mo_ctrl"; + } + else + { + return temp; + } + + //根据所选择的点自动获取信息 + QString locationId; + QString subSystem; + if(!getLocationInfo(ctrlPoint,locationId,subSystem)) + { + return temp; + } + + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + { + return temp; + } + + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + + temp = modelAct->createDefaultValue(); + temp.replace(modelActCols.findCol(CN_NAME), + unwrapPscadaData.at(modelActPscadaCols.findCol(CN_NAME))); + + temp.replace(modelActCols.findCol(CN_DESC), + unwrapPscadaData.at(modelActPscadaCols.findCol(CN_DESC))); + temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), + pointType+"*"+ctrlPoint+"*"+ctrlType); + temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), + unwrapPscadaData.at(modelActPscadaCols.findCol(CN_CTRL_TIMEOUT))); + temp.replace(modelActCols.findCol(CN_ACTION_TYPE), + act->data().toString()); + temp.replace(modelActCols.findCol(CN_LOCATION_ID),locationId); + temp.replace(modelActCols.findCol(CN_SUB_SYSTEM),subSystem); + + temp.replace(modelActCols.findCol(CN_TIMEFLAG), + QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); + + return temp; +} + +QStringList Linkage::basDataToActData(const QStringList &basData) +{ + Q_D(Linkage); + QStringList temp; + if(basData.isEmpty()) + return temp; + KbdTableModel *modelActBas = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_BAS); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + if(modelAct == NULL || modelActBas == NULL) + return temp; + QStringList unwrapBasData = modelActBas->unwrapData(basData); + const ColMgrDataList& modelActBasCols = modelActBas->getHeadCols(); + QString ctrlPoint = unwrapBasData.at(modelActBasCols.findCol(CN_CTRL_POINT)); + QString ctrlType = unwrapBasData.at(modelActBasCols.findCol(CN_CTRL_TYPE)); + + QStringList dotList = ctrlPoint.split("."); + if(dotList.size() != 5) + return temp; + + QString pointType; + if(QString("ANALOG").compare(dotList.first(),Qt::CaseInsensitive) == 0) + { + pointType = "ao_ctrl"; + } + else if(QString("DIGITAL").compare(dotList.first(),Qt::CaseInsensitive) == 0) + { + pointType = "do_ctrl"; + } + else if(QString("MIX").compare(dotList.first(),Qt::CaseInsensitive) == 0) + { + pointType = "mo_ctrl"; + } + else + { + return temp; + } + + //根据所选择的点自动获取域信息 + QString locationId; + QString subSystem; + if(!getLocationInfo(ctrlPoint,locationId,subSystem)) + { + return temp; + } + + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + { + return temp; + } + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + temp = modelAct->createDefaultValue(); + temp.replace(modelActCols.findCol(CN_NAME), + unwrapBasData.at(modelActBasCols.findCol(CN_NAME))); + + temp.replace(modelActCols.findCol(CN_DESC), + unwrapBasData.at(modelActBasCols.findCol(CN_DESC))); + temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), + pointType+"*"+ctrlPoint+"*"+ctrlType); + temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), + unwrapBasData.at(modelActBasCols.findCol(CN_CTRL_TIMEOUT))); + temp.replace(modelActCols.findCol(CN_ACTION_TYPE), + act->data().toString()); + + temp.replace(modelActCols.findCol(CN_SUB_SYSTEM),subSystem); + temp.replace(modelActCols.findCol(CN_LOCATION_ID),locationId); + temp.replace(modelActCols.findCol(CN_TIMEFLAG), + QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); + + return temp; +} + +QStringList Linkage::pushPicDataToActData(const QStringList &pushPicData) +{ + Q_D(Linkage); + QStringList temp; + if(pushPicData.isEmpty()) + return temp; + KbdTableModel *modelPushPic = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PUSH_PIC); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + if(modelAct == NULL || modelPushPic == NULL) + return temp; + + const ColMgrDataList& modelPushPicCols = modelPushPic->getHeadCols(); + QStringList unwrapPushPicData = modelPushPic->unwrapData(pushPicData); + QString hostName = unwrapPushPicData.at(modelPushPicCols.findCol(CN_HOST_NAME)); + QString picname = unwrapPushPicData.at(modelPushPicCols.findCol(CN_PIC_NAME)); + + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + { + return temp; + } + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + temp = modelAct->createDefaultValue(); + temp.replace(modelActCols.findCol(CN_NAME), + unwrapPushPicData.at(modelPushPicCols.findCol(CN_NAME))); + + temp.replace(modelActCols.findCol(CN_DESC), + unwrapPushPicData.at(modelPushPicCols.findCol(CN_DESC))); + temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), + "push_ctrl*"+picname+"*"+hostName); + temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), + unwrapPushPicData.at(modelPushPicCols.findCol(CN_CTRL_TIMEOUT))); + temp.replace(modelActCols.findCol(CN_ACTION_TYPE), + act->data().toString()); + + temp.replace(modelActCols.findCol(CN_LOCATION_ID), + unwrapPushPicData.at(modelPushPicCols.findCol(CN_LOCATION_ID))); + temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), + unwrapPushPicData.at(modelPushPicCols.findCol(CN_SUB_SYSTEM))); + temp.replace(modelActCols.findCol(CN_TIMEFLAG), + QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); + + return temp; +} + +QStringList Linkage::msgDataToActData(const QStringList &msgData) +{ + Q_D(Linkage); + QStringList temp; + if(msgData.isEmpty()) + return temp; + KbdTableModel *modelMsg = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_MSG); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + if(modelAct == NULL || modelMsg == NULL) + return temp; + + const ColMgrDataList& modelMsgCols = modelMsg->getHeadCols(); + QStringList unwrapMsgData = modelMsg->unwrapData(msgData); + QString hostName = unwrapMsgData.at(modelMsgCols.findCol(CN_HOST_NAME)); + QString msg = unwrapMsgData.at(modelMsgCols.findCol(CN_MSG)); + + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + { + return temp; + } + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + temp = modelAct->createDefaultValue(); + temp.replace(modelActCols.findCol(CN_NAME), + unwrapMsgData.at(modelMsgCols.findCol(CN_NAME))); + + temp.replace(modelActCols.findCol(CN_DESC), + unwrapMsgData.at(modelMsgCols.findCol(CN_DESC))); + temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), + "hint_ctrl*"+msg+"*"+hostName); + temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), + unwrapMsgData.at(modelMsgCols.findCol(CN_CTRL_TIMEOUT))); + temp.replace(modelActCols.findCol(CN_ACTION_TYPE), + act->data().toString()); + temp.replace(modelActCols.findCol(CN_LOCATION_ID), + unwrapMsgData.at(modelMsgCols.findCol(CN_LOCATION_ID))); + temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), + unwrapMsgData.at(modelMsgCols.findCol(CN_SUB_SYSTEM))); + temp.replace(modelActCols.findCol(CN_TIMEFLAG), + QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); + + return temp; +} + +QStringList Linkage::paDataToActData(const QStringList &paData) +{ + Q_D(Linkage); + QStringList temp; + if(paData.isEmpty()) + return temp; + KbdTableModel *modelPa = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PA); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + if(modelAct == NULL || modelPa == NULL) + return temp; + + const ColMgrDataList& modelPaCols = modelPa->getHeadCols(); + QStringList unwrapPaData = modelPa->unwrapData(paData); + QString ctrlType = unwrapPaData.at(modelPaCols.findCol(CN_CTRL_TYPE)); + QString paArea = unwrapPaData.at(modelPaCols.findCol(CN_PA_AREA)); + QString paAudio = unwrapPaData.at(modelPaCols.findCol(CN_PA_AUDIO)); + QString paRepeat = unwrapPaData.at(modelPaCols.findCol(CN_PA_REPEAT)); + QString paPriority = unwrapPaData.at(modelPaCols.findCol(CN_PA_PRIORITY)); + QString ctrlPoint = unwrapPaData.at(modelPaCols.findCol(CN_CTRL_POINT)); + QString playType = unwrapPaData.at(modelPaCols.findCol(CN_PLAY_TYPE)); + QString paOperator = unwrapPaData.at(modelPaCols.findCol("PA_OPERATOR")); + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + { + return temp; + } + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + temp = modelAct->createDefaultValue(); + temp.replace(modelActCols.findCol(CN_NAME), + unwrapPaData.at(modelPaCols.findCol(CN_NAME))); + + temp.replace(modelActCols.findCol(CN_DESC), + unwrapPaData.at(modelPaCols.findCol(CN_DESC))); + //目标域去掉,不需要 + temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), + "pa_ctrl*"+ctrlType+"*"+paArea+"*"+paAudio+"*"+paRepeat+"*"+paPriority+"*"+ctrlPoint+"*"+playType+"*"+paOperator); + temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), + unwrapPaData.at(modelPaCols.findCol(CN_CTRL_TIMEOUT))); + temp.replace(modelActCols.findCol(CN_ACTION_TYPE), + act->data().toString()); + temp.replace(modelActCols.findCol(CN_LOCATION_ID), + unwrapPaData.at(modelPaCols.findCol(CN_LOCATION_ID))); + temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), + unwrapPaData.at(modelPaCols.findCol(CN_SUB_SYSTEM))); + temp.replace(modelActCols.findCol(CN_TIMEFLAG), + QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); + + return temp; +} + +QStringList Linkage::pisDataToActData(const QStringList &pisData) +{ + Q_D(Linkage); + QStringList temp; + if(pisData.isEmpty()) + return temp; + KbdTableModel *modelPis = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION_FOR_PIS); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_ACTION); + if(modelAct == NULL || modelPis == NULL) + return temp; + + QStringList unwrapPisData = modelPis->unwrapData(pisData); + const ColMgrDataList& modelPisCols = modelPis->getHeadCols(); + QString ctrlType = unwrapPisData.at(modelPisCols.findCol(CN_CTRL_TYPE)); + QString pisArea = unwrapPisData.at(modelPisCols.findCol(CN_PIS_AREA)); + QString pisMsg = unwrapPisData.at(modelPisCols.findCol(CN_PIS_MSG)); + QString pisTime = unwrapPisData.at(modelPisCols.findCol(CN_PIS_TIME)); + QString priority = unwrapPisData.at(modelPisCols.findCol(CN_PRIORITY)); + QString pisSpaceTime = unwrapPisData.at(modelPisCols.findCol(CN_PIS_SPACE_TIME)); + QString ctrlPoint = unwrapPisData.at(modelPisCols.findCol(CN_CTRL_POINT)); + QString pisMessage = unwrapPisData.at(modelPisCols.findCol("PIS_MESSAGE")); + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + { + return temp; + } + if(pisMsg.contains("*")) + { + onMsg(tr("发布内容包含非法字符*,请替换掉*字符")); + return temp; + } + + temp = modelAct->createDefaultValue(); + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + temp.replace(modelActCols.findCol(CN_NAME), + unwrapPisData.at(modelPisCols.findCol(CN_NAME))); + + temp.replace(modelActCols.findCol(CN_DESC), + unwrapPisData.at(modelPisCols.findCol(CN_DESC))); + //目标域去掉,不需要 + temp.replace(modelActCols.findCol(CN_LINKAGE_STRING), + "pis_ctrl*"+ctrlType+"*"+pisArea+"*"+pisMsg+"*"+pisTime+"*"+priority+"*"+pisSpaceTime+"*"+ctrlPoint+"*"+pisMessage); + temp.replace(modelActCols.findCol(CN_CTRL_TIMEOUT), + unwrapPisData.at(modelPisCols.findCol(CN_CTRL_TIMEOUT))); + temp.replace(modelActCols.findCol(CN_ACTION_TYPE), + act->data().toString()); + temp.replace(modelActCols.findCol(CN_LOCATION_ID), + unwrapPisData.at(modelPisCols.findCol(CN_LOCATION_ID))); + temp.replace(modelActCols.findCol(CN_SUB_SYSTEM), + unwrapPisData.at(modelPisCols.findCol(CN_SUB_SYSTEM))); + temp.replace(modelActCols.findCol(CN_TIMEFLAG), + QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); + + return temp; +} + +QString Linkage::convertTriggerTypeToInt(const QString &strTriggerType) +{ + if(strTriggerType.compare("TRIGGER_CONDITION_DEFINE:条件触发",Qt::CaseInsensitive) == 0) + return "1:条件触发"; + else if(strTriggerType.compare("TRIGGER_TIMER_DEFINE:定时触发",Qt::CaseInsensitive) == 0) + return "2:定时触发"; + else if(strTriggerType.compare("TRIGGER_PERIOD_DEFINE:周期触发",Qt::CaseInsensitive) == 0) + return "3:周期触发"; + else + return "0:不触发"; +} + +QString Linkage::convertTriggerTypeToStr(const QString &intTriggerType) +{ + if(intTriggerType.compare("1:条件触发",Qt::CaseInsensitive) == 0) + return "TRIGGER_CONDITION_DEFINE:条件触发"; + else if(intTriggerType.compare("2:定时触发",Qt::CaseInsensitive) == 0) + return "TRIGGER_TIMER_DEFINE:定时触发"; + else if(intTriggerType.compare("3:周期触发",Qt::CaseInsensitive) == 0) + return "TRIGGER_PERIOD_DEFINE:周期触发"; + else + return "trigger_debug_flag:不触发"; +} + +void Linkage::onActTypeChanged() +{ + Q_D(Linkage); + QAction *act = d->actGroupOfActs->checkedAction(); + if(act == NULL) + return; + QString filter = QString("%1='%2'").arg(CN_ACTION_TYPE).arg(act->data().toString()); + KbdTableModel *modelAct = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( + TBL_LINKAGE_ACTION,filter)); + if(modelAct == NULL) + return; + + modelAct->load(true); + d->tableActList->setModel(modelAct); + +} + +void Linkage::onSearchAct() +{ + Q_D(Linkage); + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + int colDesc = modelActCols.findCol(CN_DESC); + QString key = d->leSearchAct->text(); + + for(int i = 0; i < modelAct->rowCount(); i++) + { + if(modelAct->item(i,colDesc)->text().contains(key)) + d->tableActList->showRow(i); + else + d->tableActList->hideRow(i); + } +} + +void Linkage::onAddAction() +{ + Q_D(Linkage); + int actData = d->actGroupOfActs->checkedAction()->data().toInt(); + if(actData == 0) + addPscadaAction(); + else if(actData == 1) + addBasAction(); + else if(actData == 2) + addPaAction(); + else if(actData == 3) + addCctvAction(); + else if(actData == 4) + addPisAction(); + else if(actData == 5) + addPicAction(); + else if(actData == 6) + addMsgAction(); + else + N_MessageBox::information(this,tr("消息"),tr("该动作未定义:")+d->actGroupOfActs->checkedAction()->text()); + +} + +void Linkage::onModifyAction() +{ + Q_D(Linkage); + int actData = d->actGroupOfActs->checkedAction()->data().toInt(); + if(actData == 0) + modifyPscadaAction(); + else if(actData == 1) + modifyBasAction(); + else if(actData == 2) + modifyPaAction(); + else if(actData == 3) + modifyCctvAction(); + else if(actData == 4) + modifyPisAction(); + else if(actData == 5) + modifyPicAction(); + else if(actData == 6) + modifyMsgAction(); + else + N_MessageBox::information(this,tr("消息"),tr("该动作未定义:")+d->actGroupOfActs->checkedAction()->text()); + +} + +void Linkage::onRemoveAction() +{ + QUESTION_REMOVE(this) + Q_D(Linkage); + KbdTableModel *modelAct = qobject_cast(d->tableActList->model()); + if(modelAct == NULL) + return; + QList list; + foreach (QModelIndex index, d->tableActList->selectionModel()->selectedRows()) { + list<< index.row(); + } + if(list.isEmpty()) + return; + const ColMgrDataList& modelActCols = modelAct->getHeadCols(); + QString actName; + int colActName = modelActCols.findCol(CN_NAME); + QStringList listFuncs; + KbdDbDesign ds; + foreach (int row, list) { + actName = modelAct->item(row,colActName)->text(); + if(!ds.actionInLinkageFunc(actName,listFuncs)) + { + return; + } + if(!listFuncs.isEmpty()) + { + onMsg(tr("以下功能使用了该动作,请先修改对应功能设置!\n") + listFuncs.join("\n")); + return; + } + } + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelAct->removeTableRows(list); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); + +} + +void Linkage::onFuncTypeChanged() +{ + Q_D(Linkage); + QAction *act = d->actGroupOfFuncs->checkedAction(); + if(act == NULL) + return; + QString filter = QString("%1='%2' GROUP BY NAME,DESCRIPTION").arg(CN_FUNC_TYPE).arg(act->data().toString()); + KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( + TBL_LINKAGE_FUNCTION_LIST,filter)); + if(modelFunc == NULL) + return; + + ColMgrDataList& modelCols = modelFunc->getHeadColsNoConst(); + + modelFunc->load(true); + modelCols.setHeadColUnique(CN_NAME,true); + d->tableFuncList->setModel(modelFunc); + d->tableActsOfFunc->setModel(NULL); +} + +void Linkage::onSearchFunc() +{ + Q_D(Linkage); + KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); + if(modelFunc == NULL) + return; + + const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); + int colDesc = modelFuncCols.findCol(CN_DESC); + QString key = d->leSearchFunc->text(); + + for(int i = 0; i < modelFunc->rowCount(); i++) + { + if(modelFunc->item(i,colDesc)->text().contains(key)) + d->tableFuncList->showRow(i); + else + d->tableFuncList->hideRow(i); + } + + +} + +void Linkage::onAddFunc() +{ + Q_D(Linkage); + KbdTableModel *modelFunc = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_FUNCTION); + if(modelFunc == NULL) + return; + QAction *actType = d->actGroupOfFuncs->checkedAction(); + if(actType == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动功能")); + dlg.panel()->setDisplayRow(modelFunc,modelFunc->rowCount()); + dlg.panel()->setPropertyValue(CN_FUNC_TYPE,actType->data().toString()); + dlg.panel()->setPropertyEditable(CN_NAME,true); + dlg.panel()->setPropertyEditable(CN_DESC,true); + dlg.panel()->setPropertyEditable(CN_ACTION_NAME,true); + dlg.panel()->setPropertyValue(CN_ACTION_NO,"1"); + if(dlg.exec()) + { + rowDatas = dlg.panel()->getPropertyData(); + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelFunc->addRow(rowDatas,false); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableActsOfFunc->setModel(NULL); + d->tableFuncList->reFresh(); + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::onModifyFunc() +{ + Q_D(Linkage); + KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); + if(modelFunc == NULL) + return; + QModelIndex index = d->tableFuncList->currentIndex(); + if(!index.isValid()) + return; + + QStringList newDatas; + QStringList oldDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动功能")); + QList cols ; + const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); + cols<setDisplayRow(modelFunc,index.row(), modelFuncCols.getGroup(),cols); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyEditable(CN_DESC,true); + if(dlg.exec()) + { + newDatas = dlg.panel()->getPropertyData(); + } + + if(newDatas.isEmpty()) + return; + + //判断是否重名 + QString newName = newDatas.at(modelFuncCols.findCol(CN_NAME)); + oldDatas = modelFunc->getRowData(index.row()); + QString oldName = oldDatas.at(modelFuncCols.findCol(CN_NAME)); + KbdDbDesign ds; + if(newName != oldName && ds.isExistLinkageFunc(newName)) + { + onMsg(tr("功能名称重复")); + return; + } + + //开启事务 + bool success = false; + QMap setValues; + QMap filterMap; + setValues.insert(CN_NAME,newDatas.at(modelFuncCols.findCol(CN_NAME))); + setValues.insert(CN_DESC,newDatas.at(modelFuncCols.findCol(CN_DESC))); + filterMap.insert(CN_NAME,oldDatas.at(modelFuncCols.findCol(CN_NAME))); + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelFunc->modifyRow(setValues,filterMap); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableFuncList->reFresh(); + d->tableActsOfFunc->setModel(NULL); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::onRemoveFunc() +{ + QUESTION_REMOVE(this) + Q_D(Linkage); + KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); + if(modelFunc == NULL) + return; + QList list; + foreach (QModelIndex index, d->tableFuncList->selectionModel()->selectedRows()) { + list<< index.row(); + } + if(list.isEmpty()) + return; + + QString funcName; + const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); + int colFuncName = modelFuncCols.findCol(CN_NAME); + QStringList listLinkages; + KbdDbDesign ds; + foreach (int row, list) { + funcName = modelFunc->item(row,colFuncName)->text(); + if(!ds.funcInLinkages(funcName,listLinkages)) + { + return; + } + if(!listLinkages.isEmpty()) + { + onMsg(tr("以下联动使用了该功能,请先修改对应联动设置!\n") + listLinkages.join("\n")); + return; + } + } + + //开启事务 + bool success = false; + QMap filterMap; + int colName = modelFuncCols.findCol(CN_NAME); + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + foreach (int row, list) { + filterMap.clear(); + filterMap.insert(CN_NAME,modelFunc->item(row,colName)->text()); + success = modelFunc->removeTableRows(filterMap); + if(!success) + break; + } + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableFuncList->reFresh(); + d->tableActsOfFunc->setModel(NULL); + KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); + +} + +void Linkage::onAddActOfFunc() +{ + Q_D(Linkage); + if(d->tableActsOfFunc->needSave()) + { + onMsg(tr("请先保存修改")); + return; + } + + KbdTableModel *modelActsOfFunc = qobject_cast(d->tableActsOfFunc->model()); + if(modelActsOfFunc == NULL) + { + onMsg(tr("请选中要添加的功能")); + return; + } + QAction *actType = d->actGroupOfFuncs->checkedAction(); + if(actType == NULL) + return; + QModelIndex index = d->tableFuncList->currentIndex(); + if(!index.isValid()) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("添加联动功能")); + const ColMgrDataList& modelActsOfFuncCols = modelActsOfFunc->getHeadCols(); + QList cols = modelActsOfFuncCols.getShowCol(); + int colFuncName = modelActsOfFuncCols.findCol(CN_NAME); + int colFuncDesc = modelActsOfFuncCols.findCol(CN_DESC); + cols.removeAll(colFuncName); + cols.removeAll(colFuncDesc); + dlg.panel()->setDisplayRow(modelActsOfFunc,modelActsOfFunc->rowCount(), modelActsOfFuncCols.getGroup(),cols); + dlg.panel()->setPropertyEditable(CN_ACTION_NAME,true); + dlg.panel()->setPropertyValue(CN_FUNC_TYPE,actType->data().toString()); + dlg.panel()->setPropertyValue(CN_NAME,index.sibling(index.row(),colFuncName).data().toString()); + dlg.panel()->setPropertyValue(CN_DESC,index.sibling(index.row(),colFuncDesc).data().toString()); + if(dlg.exec()) + { + rowDatas = dlg.panel()->getPropertyData(); + + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelActsOfFunc->addRow(rowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableActsOfFunc->reFresh(); + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::onRemoveActOfFunc() +{ + QUESTION_REMOVE(this) + Q_D(Linkage); + if(d->tableActsOfFunc->needSave()) + { + onMsg(tr("请先保存修改")); + return; + } + KbdTableModel *modelActsOfFunc = qobject_cast(d->tableActsOfFunc->model()); + if(modelActsOfFunc == NULL) + return; + QList list; + foreach (QModelIndex index, d->tableActsOfFunc->selectionModel()->selectedRows()) { + list<< index.row(); + } + if(list.isEmpty()) + return; + + const ColMgrDataList& modelActsOfFuncCols = modelActsOfFunc->getHeadCols(); + QString funcName = modelActsOfFunc->item(list.first(),modelActsOfFuncCols.findCol(CN_NAME))->text(); + //FIX:有可能把功能自身删除了,所以要加入判断提示,假如把功能完全删除,先判断该功能是否有联动定义,有引用,有则提示,先删除联动定义 + if(list.size() == modelActsOfFunc->rowCount()) + { + KbdDbDesign ds; + QStringList linkages; + if(!ds.funcInLinkages(funcName,linkages)) + { + return; + } + if(!linkages.isEmpty()) + { + onMsg(tr("以下联动使用了该功能,请先修改对应联动设置!\n") + linkages.join("\n")); + return; + } + } + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelActsOfFunc->removeTableRows(list); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + + if(d->tableActsOfFunc->model()->rowCount() == 0) + d->tableActsOfFunc->setModel(NULL); + + d->tableFuncList->reFresh(); + d->tableActsOfFunc->reFresh(); + KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); +} + +void Linkage::onModifyActOfFunc() +{ + + Q_D(Linkage); + KbdTableModel *modelActsOfFunc = qobject_cast(d->tableActsOfFunc->model()); + if(modelActsOfFunc == NULL) + return; + + QModelIndex index = d->tableActsOfFunc->currentIndex(); + if(!index.isValid()) + { + onMsg(tr("请选中要修改的行")); + return; + } + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + const ColMgrDataList& modelActsOfFuncCols = modelActsOfFunc->getHeadCols(); + QList showCols = modelActsOfFuncCols.getShowCol(true); + showCols.removeAll(modelActsOfFuncCols.findCol(CN_NAME)); + showCols.removeAll(modelActsOfFuncCols.findCol(CN_DESC)); + showCols.removeAll(modelActsOfFuncCols.findCol(CN_TIMEFLAG)); + KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("修改联动功能")); + dlg.panel()->setDisplayRow(modelActsOfFunc,index.row(), modelActsOfFuncCols.getGroup(),showCols); + if(dlg.exec()) + { + success = true; + } + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); + +} + +void Linkage::onFuncTableClicked(const QModelIndex &index) +{ + Q_D(Linkage); + if(!index.isValid()) + return; + KbdTableModel *modelFunc = qobject_cast(d->tableFuncList->model()); + if(modelFunc == NULL) + return; + const ColMgrDataList& modelFuncCols = modelFunc->getHeadCols(); + int colFuncName = modelFuncCols.findCol(CN_NAME); + QString filter = QString("%1='%2' ORDER BY ACTION_NO").arg(CN_NAME).arg(index.sibling(index.row(),colFuncName).data().toString()); + KbdTableModel *modelActsOfFunc = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( + TBL_LINKAGE_FUNCTION,filter)); + if(modelActsOfFunc == NULL) + return; + d->tableActsOfFunc->setModel(modelActsOfFunc); +} + +void Linkage::onLinkageTypeChanged() +{ + Q_D(Linkage); + QAction *act = d->actGroupOfLinkage->checkedAction(); + if(act == NULL) + return; + QString filter = QString("%1='%2'").arg(CN_LINK_TYPE).arg(act->data().toString()); + KbdTableModel *modelLinkage = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( + TBL_LINKAGE_SETTING,filter)); + if(modelLinkage == NULL) + return; + + modelLinkage->load(true); + d->tableLinkageList->setModel(modelLinkage); + d->tableFuncOfLinkage->setModel(NULL); +} + +void Linkage::onSearchLinkage() +{ + Q_D(Linkage); + KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); + if(modelLinkageSetting == NULL) + return; + const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); + int colDesc = modelLinkageSettingCols.findCol(CN_DESC); + QString key = d->leSearchLinkage->text(); + + for(int i = 0; i < modelLinkageSetting->rowCount(); i++) + { + if(modelLinkageSetting->item(i,colDesc)->text().contains(key)) + d->tableLinkageList->showRow(i); + else + d->tableLinkageList->hideRow(i); + } +} + +void Linkage::onAddLinkage() +{ + Q_D(Linkage); + KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); + if(modelLinkageSetting == NULL) + return; + KbdTableModel *modelAddAndModify = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING_FOR_ADD_AND_MODIFY); + if(modelAddAndModify == NULL) + return; + + QAction *actType = d->actGroupOfLinkage->checkedAction(); + if(actType == NULL) + return; + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("新增联动")); + dlg.panel()->setDisplayRow(modelAddAndModify,modelAddAndModify->rowCount()); + dlg.panel()->setPropertyValue(CN_LINK_TYPE,actType->data().toString()); + if(dlg.exec()) + { + rowDatas = dlg.panel()->getPropertyData(); + } + + if(rowDatas.isEmpty()) + return; + + const ColMgrDataList& modelAddAndModifyCols = modelAddAndModify->getHeadCols(); + //触发方式做以下转换 + QStringList newDatas = modelLinkageSetting->createDefaultValue(); + const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); + newDatas.replace(modelLinkageSettingCols.findCol(CN_NAME),rowDatas.at(modelAddAndModifyCols.findCol(CN_NAME))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_DESC),rowDatas.at(modelAddAndModifyCols.findCol(CN_DESC))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_TYPE))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_CONDITION),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_CONDITION))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_EXEC_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_EXEC_TYPE))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_LINK_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_LINK_TYPE))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_LOCATION_ID),rowDatas.at(modelAddAndModifyCols.findCol(CN_LOCATION_ID))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_TIMEFLAG),rowDatas.at(modelAddAndModifyCols.findCol(CN_TIMEFLAG))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_MUTEX_LIST),rowDatas.at(modelAddAndModifyCols.findCol(CN_MUTEX_LIST))); + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelLinkageSetting->addRow(newDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableFuncOfLinkage->setModel(NULL); + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::onModifyLinkage() +{ + Q_D(Linkage); + KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); + if(modelLinkageSetting == NULL) + return; + QModelIndex index = d->tableLinkageList->currentIndex(); + if(!index.isValid()) + return; + KbdTableModel *modelAddAndModify = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING_FOR_ADD_AND_MODIFY); + if(modelAddAndModify == NULL) + return; + + QStringList oldDatas = modelLinkageSetting->getRowData(index.row()); + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改联动")); + const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); + dlg.panel()->setDisplayRow(modelAddAndModify,modelAddAndModify->rowCount()); + dlg.panel()->setPropertyEditable(CN_NAME,false); + dlg.panel()->setPropertyValue(CN_NAME,oldDatas.at(modelLinkageSettingCols.findCol(CN_NAME))); + dlg.panel()->setPropertyValue(CN_DESC,oldDatas.at(modelLinkageSettingCols.findCol(CN_DESC))); + dlg.panel()->setPropertyValue(CN_TRIGGER_TYPE,oldDatas.at(modelLinkageSettingCols.findCol(CN_TRIGGER_TYPE))); + dlg.panel()->setPropertyValue(CN_TRIGGER_CONDITION,oldDatas.at(modelLinkageSettingCols.findCol(CN_TRIGGER_CONDITION))); + dlg.panel()->setPropertyValue(CN_EXEC_TYPE,oldDatas.at(modelLinkageSettingCols.findCol(CN_EXEC_TYPE))); + dlg.panel()->setPropertyValue(CN_LINK_TYPE,oldDatas.at(modelLinkageSettingCols.findCol(CN_LINK_TYPE))); + dlg.panel()->setPropertyValue(CN_LOCATION_ID,oldDatas.at(modelLinkageSettingCols.findCol(CN_LOCATION_ID))); + dlg.panel()->setPropertyValue(CN_TIMEFLAG,oldDatas.at(modelLinkageSettingCols.findCol(CN_TIMEFLAG))); + dlg.panel()->setPropertyValue(CN_MUTEX_LIST,oldDatas.at(modelLinkageSettingCols.findCol(CN_MUTEX_LIST))); + + + if(dlg.exec()) + { + rowDatas = dlg.panel()->getPropertyData(); + } + + if(rowDatas.isEmpty()) + return; + const ColMgrDataList& modelAddAndModifyCols = modelAddAndModify->getHeadCols(); + QStringList newDatas = modelLinkageSetting->createDefaultValue(); + newDatas.replace(modelLinkageSettingCols.findCol(CN_NAME),rowDatas.at(modelAddAndModifyCols.findCol(CN_NAME))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_DESC),rowDatas.at(modelAddAndModifyCols.findCol(CN_DESC))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_TYPE))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_TRIGGER_CONDITION),rowDatas.at(modelAddAndModifyCols.findCol(CN_TRIGGER_CONDITION))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_EXEC_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_EXEC_TYPE))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_LINK_TYPE),rowDatas.at(modelAddAndModifyCols.findCol(CN_LINK_TYPE))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_LOCATION_ID),rowDatas.at(modelAddAndModifyCols.findCol(CN_LOCATION_ID))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_TIMEFLAG),rowDatas.at(modelAddAndModifyCols.findCol(CN_TIMEFLAG))); + newDatas.replace(modelLinkageSettingCols.findCol(CN_MUTEX_LIST),rowDatas.at(modelAddAndModifyCols.findCol(CN_MUTEX_LIST))); + //开启事务 + bool success = false; + + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelLinkageSetting->modifyRow(index.row(),newDatas,true); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableFuncOfLinkage->reFresh(); + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::onRemoveLinkage() +{ + QUESTION_REMOVE(this) + //数据库触发器,会触发删除LINKAGE_DEFINE表中的内容 + Q_D(Linkage); + KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); + if(modelLinkageSetting == NULL) + return; + QList list; + foreach (QModelIndex index, d->tableLinkageList->selectionModel()->selectedRows()) { + list<< index.row(); + } + if(list.isEmpty()) + return; + + int ret = N_MessageBox::No; + ret = N_MessageBox::information(this,tr("消息"),tr("如果此联动正在执行或者已触发会导致联动终止,确定删除?"), + N_MessageBox::Yes,N_MessageBox::No); + if(ret != N_MessageBox::Yes) + { + return; + } + //开启事务 + bool success = false; + + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelLinkageSetting->removeTableRows(list); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + + d->tableFuncOfLinkage->setModel(NULL); + KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); +} + +void Linkage::onAddFuncOfLinkage() +{ + Q_D(Linkage); + if(d->tableFuncOfLinkage->needSave()) + { + onMsg(tr("请先保存修改")); + return; + } + KbdTableModel *modelLinkageSetting = qobject_cast(d->tableLinkageList->model()); + if(modelLinkageSetting == NULL) + return; + QModelIndex index = d->tableLinkageList->currentIndex(); + if(!index.isValid()) + return; + KbdTableModel *modelLinkageDefine = qobject_cast(d->tableFuncOfLinkage->model()); + if(modelLinkageDefine == NULL) + return; + + const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); + + QStringList rowDatas; + KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("添加联动功能")); + dlg.panel()->setDisplayRow(modelLinkageDefine,modelLinkageDefine->rowCount()); + dlg.panel()->setPropertyEditable(CN_FUNC_NAME,true); + dlg.panel()->setPropertyValue(CN_LINKAGE_NAME,modelLinkageSetting->item(index.row(), + modelLinkageSettingCols.findCol(CN_NAME))->text()); + + if(dlg.exec()) + { + rowDatas = dlg.panel()->getPropertyData(); + + } + + if(rowDatas.isEmpty()) + return; + + //开启事务 + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelLinkageDefine->addRow(rowDatas); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + d->tableFuncOfLinkage->reFresh(); + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::onRemoveFuncOfLinkage() +{ + QUESTION_REMOVE(this) + Q_D(Linkage); + if(d->tableFuncOfLinkage->needSave()) + { + onMsg(tr("请先保存修改")); + return; + } + KbdTableModel *modelLinkageDefine = qobject_cast(d->tableFuncOfLinkage->model()); + if(modelLinkageDefine == NULL) + return; + QList list; + foreach (QModelIndex index, d->tableFuncOfLinkage->selectionModel()->selectedRows()) { + list<< index.row(); + } + if(list.isEmpty()) + return; + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = modelLinkageDefine->removeTableRows(list); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); +} + +void Linkage::onModifyFuncOfLinkage() +{ + //先获取原始数据,直接修改数据库,然后刷新控件 + Q_D(Linkage); + KbdTableModel *modelFuncOfLinkage = qobject_cast(d->tableFuncOfLinkage->model()); + if(modelFuncOfLinkage == NULL) + return; + QModelIndex index = d->tableFuncOfLinkage->currentIndex(); + if(!index.isValid()) + { + onMsg(tr("请选中要修改的行")); + return; + } + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + const ColMgrDataList& modelFuncOfLinkageCols = modelFuncOfLinkage->getHeadCols(); + QList showCols = modelFuncOfLinkageCols.getShowCol(true); + showCols.removeAll(modelFuncOfLinkageCols.findCol(CN_LINKAGE_NAME)); + showCols.removeAll(modelFuncOfLinkageCols.findCol(CN_TIMEFLAG)); + KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("修改联动功能")); + dlg.panel()->setDisplayRow(modelFuncOfLinkage,index.row(), modelFuncOfLinkageCols.getGroup(),showCols); + if(dlg.exec()) + { + success = true; + } + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::onLinkageTableClicked(const QModelIndex &index) +{ + Q_D(Linkage); + if(!index.isValid()) + return; + KbdTableModel *modelLinkageSetting = KbdTableDataMgr::getInstance()->createModel(TBL_LINKAGE_SETTING); + if(modelLinkageSetting == NULL) + return; + + const ColMgrDataList& modelLinkageSettingCols = modelLinkageSetting->getHeadCols(); + int colName = modelLinkageSettingCols.findCol(CN_NAME); + QString filter = QString("%1='%2' ORDER BY FUNC_NO").arg(CN_LINKAGE_NAME).arg(index.sibling(index.row(),colName).data().toString()); + KbdTableModel *model = KbdTableDataMgr::getInstance()->createModel(Common::createViewName( + TBL_LINKAGE_DEFINE,filter)); + if(model == NULL) + return; + d->tableFuncOfLinkage->setModel(model); +} + +void Linkage::onTriggerTypeChanged() +{ + Q_D(Linkage); + QAction *act = d->actGroupTrigger->checkedAction(); + if(act == NULL) + return; + QString actData = act->data().toString(); + d->stackTrigger->setCurrentIndex(actData.toInt()); +} + +void Linkage::onAddTimer() +{ + Q_D(Linkage); + KbdTableModel *model = qobject_cast(d->tableTriggerTimer->model()); + if(model == NULL) + return; + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("新增触发器")); + dlg.panel()->setDisplayRow(model,model->rowCount()); + if(dlg.exec()) + { + success = true; + } + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("添加成功"),this); +} + +void Linkage::onRemoveTimer() +{ + QUESTION_REMOVE(this) + Q_D(Linkage); + + KbdTableModel *model = qobject_cast(d->tableTriggerTimer->model()); + if(model == NULL) + return; + QList list; + foreach (QModelIndex index, d->tableTriggerTimer->selectionModel()->selectedRows()) { + list<< index.row(); + } + if(list.isEmpty()) + return; + + //后面加判断是否有引用该定时 + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + success = model->removeTableRows(list); + if(!success) + onMsg(tr("删除失败!")); + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("删除成功"),this); +} + +void Linkage::onModifyTimer() +{ + Q_D(Linkage); + + KbdTableModel *model = qobject_cast(d->tableTriggerTimer->model()); + if(model == NULL) + return; + QModelIndex index = d->tableTriggerTimer->currentIndex(); + if(!index.isValid()) + { + onMsg(tr("请选中要修改的条目")); + return; + } + + bool success = false; + QString retStr = KbdTableDataMgr::getInstance()->startTransaction(); + if(retStr.isEmpty()) + { + KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("修改触发器")); + dlg.panel()->setDisplayRow(model,index.row()); + if(dlg.exec()) + { + success = true; + } + + if(KbdTableDataMgr::getInstance()->commit()?false:((success=false)||true)) + onCommitError(); + } + else + onStartTransactionError(retStr); + + if(!success) + return; + + KbdMsgContrl::getInstance()->showMsg(tr("修改成功"),this); +} + +void Linkage::onStartTransactionError(const QString&erroStr) +{ + N_MessageBox::information(this,tr("消息"),erroStr); +} + +void Linkage::onCommitError() +{ + N_MessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); +} + +void Linkage::onMsg(const QString &msg) +{ + N_MessageBox::information(this,tr("消息"),msg); +} + + diff --git a/product/src/tools/model_plugin/model_linkage/model_linkage.pro b/product/src/tools/model_plugin/model_linkage/model_linkage.pro index 43bea988..9bce0766 100644 --- a/product/src/tools/model_plugin/model_linkage/model_linkage.pro +++ b/product/src/tools/model_plugin/model_linkage/model_linkage.pro @@ -36,12 +36,14 @@ PLATFORM_INCLUDE_PATH = $$SRC_ROOT_PATH/../../platform/src/include/ INCLUDEPATH += $$PWD\ $$PLATFORM_INCLUDE_PATH/tools/model_common \ $$PLATFORM_INCLUDE_PATH/tools/model_table \ - $$PLATFORM_INCLUDE_PATH/tools/model_excel/xlsx + $$PLATFORM_INCLUDE_PATH/public/pub_excel/xlsx -LIBS += -lmodel_common -lmodel_excel +LIBS += -lmodel_common -lpub_excel LIBS += -lmodel_table -lScriptForm_lua +LIBS += -lpub_widget + DISTFILES += \ model_linkage_EN.ts @@ -65,4 +67,4 @@ SOURCES += \ triggerfuncwidget.cpp \ triggerparawidget.cpp - +TRANSLATIONS = $$PWD/model_linkage_EN.ts diff --git a/product/src/tools/model_plugin/model_linkage/model_linkage_EN.ts b/product/src/tools/model_plugin/model_linkage/model_linkage_EN.ts index 4b98a471..80ea0e15 100644 --- a/product/src/tools/model_plugin/model_linkage/model_linkage_EN.ts +++ b/product/src/tools/model_plugin/model_linkage/model_linkage_EN.ts @@ -4,348 +4,351 @@ CctvActDlg - + 选择监视器: - Select monitor: - - - - 单画面 - Single camera + Select monitor: - 四画面 - Four Camera + 单画面 + Single camera - 九画面 - Nine camera + 四画面 + Four Camera + 九画面 + Nine camera + + + 序列显示 - serial display + serial display - + 选择车站: - select location: - - - - 选择摄像机: - Select camera: + select location: + 选择摄像机: + Select camera: + + + 选择预设位: - Select orient location: + Select orient location: - + 选择序列 - Selece series + Selece series - + 序号 - Sequence number + Sequence number - + 摄像机 - Camera + Camera - - - + + + 消息 - Message + Message - + 已经存在,无法添加! - Can't be added,alreay existed! + Can't be added,alreay existed! - + 提交事务失败,已回滚 - Commit transaction failed,rolled back + Commit transaction failed,rolled back - + 开启事务失败 - Start transaction failed + Start transaction failed - + 添加成功 - Add succcess + Add succcess - + 修改成功 - modify success + modify success KbdPeriodDlg - - - 名称 - Name - - 描述 - Description + 名称 + Name - 开始时间 - Start time + 描述 + Description + 开始时间 + Start time + + + 结束时间 - End time + End time - + 月 - Month + Month - + 1:星期一/2:星期二/3:星期三/4:星期四/5:星期五/6:星期六/0:星期天 - 1:Monday/2:Tuesday/3:Wednesday/4:Thursday/5:Friday/6:Saturday/0:Sunday + 1:Monday/2:Tuesday/3:Wednesday/4:Thursday/5:Friday/6:Saturday/0:Sunday - + 日 - Day + Day - + 时 - Hour + Hour - + 分 - Minute + Minute - + 秒 - Second + Second - - + + 消息 - Message + Message - + 名称为空 - Name is null + Name is null - + 描述为空 - Description is null + Description is null Linkage - - - - - - - - - - - - + + + + + + + + + + + + 联动动作定义错误 - Linkage action define error + Linkage action define error - - - - - - - - - - - + + + + + + + + + + + 添加成功 - Add success + Add success - - - - - - - - - - - + + + + + + + + + + + 修改成功 - Modify success + Modify success - - + + 动作内容错误 - Action content error + Action content error - + 发布内容包含非法字符*,请替换掉*字符 - Content posting contains illegal characters*, please replace * characters + Content posting contains illegal characters*, please replace * characters - - - - - - + + + + + + 消息 - Message + Message - - + + 该动作未定义: - Not define the action: + Not define the action: - + 以下功能使用了该动作,请先修改对应功能设置! - The following functions use this action,please modify the corresponding function settings first! + file:///D:/work/gitProject/project/ems/product/src/tools/model_plugin/model_plan_curve/model_plan_curve_EN.ts + The following functions use this action,please modify the corresponding function settings first! + - - - - - - + + + + + + 删除成功 - Delete success + Delete success - + 功能名称重复 - Function name repeat + Function name repeat - - + + 以下联动使用了该功能,请先修改对应联动设置! - The following linkage uses this function,please modify the corresponding linkage settings first! + The following linkage uses this function,please modify the corresponding linkage settings first! + - - - - + + + + 请先保存修改 - Please save modify first + Please save modify first - + 请选中要添加的功能 - Please select the function want to add + Please select the function want to add - - + + 请选中要修改的行 - Please select the line to modify + Please select the line to modify - + 如果此联动正在执行或者已触发会导致联动终止,确定删除? - If this linkage is being executed or triggered, the linkage will be terminated and the deletion will be confirmed? + If this linkage is being executed or triggered, the linkage will be terminated and the deletion will be confirmed? - + 删除失败! - Delete failed! + Delete failed! - + 请选中要修改的条目 - Please select items to modify + Please select items to modify - + 提交事务失败,已回滚 - Transaction submit failed,rollback has started + Transaction submit failed,rollback has started PeriodWidget - + 添加失败 - Add failed + Add failed - + 添加成功 - Add success + Add success - + 修改失败 - Modify failed + Modify failed - + 修改成功 - Modify success + Modify success - + 删除失败! - Delete failed! + Delete failed! - + 删除成功 - Delete success + Delete success - - - + + + 消息 - Message + Message - + 提交事务失败,已回滚 - Transaction submit failed,rollback has started + Transaction submit failed,rollback has started @@ -353,139 +356,139 @@ 联动动作 - Linkage action + Linkage action 联动功能 - Linkage function + Linkage function 联动定义 - Linkage define + Linkage define 触发定义 - Trigger define + Trigger define - + 动作类型 - Action type + Action type - + 动作列表 - Action list + Action list - + 搜索动作描述 - Search action description + Search action description - - - - - + + + + + 添加 - Add + Add - - - - + + + + 修改 - Modify + Modify - - - - - + + + + + 删除 - Delete + Delete - + 功能类型 - Function type + Function type - + 功能列表 - Function list + Function list - + 功能所含动作列表 - List of actions included in the function + List of actions included in the function - + 搜索功能描述 - Search function description + Search function description - - + + 添加记录 - Add record + Add record - - + + 修改记录 - Modify record + Modify record - - + + 删除记录 - Delete record + Delete record - + 联动类型 - Linkage type + Linkage type - + 联动列表 - Linkage list + Linkage list - + 联动所含功能列表 - List of actions included in the linkage + List of actions included in the linkage - + 搜索联动描述 - Search linkage description + Search linkage description - + 触发类型 - Trigger type + Trigger type - + 0:定时触发/1:周期触发/2:触发函数/3:触发器定义 - 0:Timed trigger/1:Cycle trigger/2:Trigger function/3:Trigger definition + 0:Timed trigger/1:Cycle trigger/2:Trigger function/3:Trigger definition - + 保存 - Save + Save @@ -493,118 +496,118 @@ 添加 - Add + Add - + 删除 - Delete + Delete - + 函数定义 - Function define + Function define - + 保存 - Save + Save - + 请选中要添加的专业! - Please select the subsystem to add! + Please select the subsystem to add! - - + + 请选中要删除的触发函数! - Please select the trigger function you want to delete! + Please select the trigger function you want to delete! - - + + 写入数据库不成功 - Write into database failed + Write into database failed - + 删除成功 - Delete success + Delete success - + 保存成功 - Save success + Save success - - - + + + 消息 - Message + Message - + 此次修改失败,已启动回滚! - This modification failed,rollback has started! + This modification failed,rollback has started! TriggerParaWidget - + 添加 - Add + Add 删除 - Delete + Delete - + 保存 - Save + Save - + 请选中要添加的专业! - Please select the subSystem to add! + Please select the subSystem to add! - - + + 请选中要删除的触发器! - Please select the trigger you want to delete! + Please select the trigger you want to delete! - - + + 写入数据库不成功 - Write into database failed + Write into database failed - + 删除成功 - Delete success + Delete success - + 保存成功 - Save success + Save success - - - + + + 消息 - Message + Message - + 此次修改失败,已启动回滚! - This modification failed,rollback has started! + This modification failed,rollback has started! diff --git a/product/src/tools/model_plugin/model_linkage/modellinkagepluginwidget.h b/product/src/tools/model_plugin/model_linkage/modellinkagepluginwidget.h index 03013630..deaef13c 100644 --- a/product/src/tools/model_plugin/model_linkage/modellinkagepluginwidget.h +++ b/product/src/tools/model_plugin/model_linkage/modellinkagepluginwidget.h @@ -7,7 +7,7 @@ class ModelLinkagePluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/model_linkage/periodwidget.cpp b/product/src/tools/model_plugin/model_linkage/periodwidget.cpp index 21c81609..0fd9c7e2 100644 --- a/product/src/tools/model_plugin/model_linkage/periodwidget.cpp +++ b/product/src/tools/model_plugin/model_linkage/periodwidget.cpp @@ -11,7 +11,7 @@ #include "kbdtable.h" #include "kbdtabledatamgr.h" #include "../model_common/common.h" -#include +#include "pub_widget/MessageBox.h" #include "kbdcheckrole.h" #include #include "kbdperioddlg.h" @@ -25,30 +25,25 @@ PeriodWidget::PeriodWidget(QWidget *parent) : QWidget(parent) void PeriodWidget::initLayout() { - QHBoxLayout *hLayout = new QHBoxLayout; - m_table = new KbdTable(this); QVBoxLayout *vLayout = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),this); - QPushButton *btModify = new QPushButton(QObject::tr("修改"),this); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),this); - vLayout->addStretch(); - vLayout->addWidget(btAdd); - vLayout->addWidget(btModify); - vLayout->addWidget(btRemove); - vLayout->addStretch(); + m_table = new KbdTable(this); - hLayout->addWidget(m_table); - hLayout->addLayout(vLayout); - setLayout(hLayout); + QHBoxLayout *hLayoutSearch = new QHBoxLayout; + QToolBar *topBar = new QToolBar(this); //触发器-定时触发列表中的工具栏 + QAction* act = nullptr; + act = topBar->addAction(QObject::tr("添加记录"),this,SLOT(onAdd())); + topBar->widgetForAction(act)->setObjectName("icon_add"); + act = topBar->addAction(QObject::tr("修改记录"),this,SLOT(onModify())); + topBar->widgetForAction(act)->setObjectName("icon_edit"); + act = topBar->addAction(QObject::tr("删除记录"),this,SLOT(onRemove())); + topBar->widgetForAction(act)->setObjectName("icon_delete"); + hLayoutSearch->addWidget(topBar); + vLayout->addLayout(hLayoutSearch); + vLayout->addWidget(m_table); + setLayout(vLayout); - connect(btAdd,SIGNAL(clicked(bool)),this,SLOT(onAdd())); - connect(btModify,SIGNAL(clicked(bool)),this,SLOT(onModify())); - connect(btRemove,SIGNAL(clicked(bool)),this,SLOT(onRemove())); connect(m_table,SIGNAL(doubleClicked(const QModelIndex &)),this,SLOT(onModify())); - - - } void PeriodWidget::initData() @@ -59,7 +54,8 @@ void PeriodWidget::initData() void PeriodWidget::add() { - KbdPeriodDlg dlg; + KbdPeriodDlg dlg(this); + dlg.setWindowTitle(tr("新增触发器")); if(dlg.exec() != QDialog::Accepted) return; @@ -108,7 +104,8 @@ void PeriodWidget::add() void PeriodWidget::modify() { - KbdPeriodDlg dlg; + KbdPeriodDlg dlg(this); + dlg.setWindowTitle(tr("修改触发器")); QModelIndex index = m_table->currentIndex(); if(!index.isValid()) return; @@ -214,15 +211,15 @@ void PeriodWidget::onRemove() void PeriodWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } void PeriodWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); + N_MessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); } void PeriodWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } diff --git a/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.cpp b/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.cpp index fa6cb822..0ff4140c 100644 --- a/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.cpp +++ b/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "pub_widget/MessageBox.h" #include "kbdtabledatamgr.h" #include "kbdcheckrole.h" #include "kbdmsgcontrl.h" @@ -30,9 +30,11 @@ void TriggerFuncWidget::initLayout() QVBoxLayout *vLayoutTree = new QVBoxLayout; QToolBar *bar = new QToolBar(widgetTree); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加"),this,SLOT(onAdd())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除"),this,SLOT(onRemove())); + QAction* act = nullptr; + act = bar->addAction(tr("添加"),this,SLOT(onAdd())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除"),this,SLOT(onRemove())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_tree = new KbdTreeView(widgetTree); KbdSqlTreeModel *treeModel = new KbdSqlTreeModel(Common::getTreePath("TriggerFuncTree.xml"),this); @@ -51,7 +53,8 @@ void TriggerFuncWidget::initLayout() QGroupBox *box = new QGroupBox(tr("函数定义"),widgetDetail); QHBoxLayout *boxLayout = new QHBoxLayout; - m_te = new ScriptFormWidget(box); + using namespace ScriptForm_lua; + m_te = new ScriptForm_lua::ScriptFormWidget(box); boxLayout->addWidget(m_te); box->setLayout(boxLayout); @@ -246,17 +249,17 @@ void TriggerFuncWidget::onTreeClicked(const QModelIndex &index) void TriggerFuncWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void TriggerFuncWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void TriggerFuncWidget::onStartTransactionError(const QString& erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.h b/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.h index 0128ec6b..000b7a53 100644 --- a/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.h +++ b/product/src/tools/model_plugin/model_linkage/triggerfuncwidget.h @@ -2,14 +2,19 @@ #define TRIGGERFUNCWIDGET_H #include +#include "../../../tools/ScriptForm/ScriptForm.h" class KbdPropertyPanel; class QTextEdit; class KbdTreeView; + +using namespace ScriptForm_lua; class ScriptFormWidget; /** * @brief The TriggerFuncWidget class 触发器函数定义控件 */ + + class TriggerFuncWidget : public QWidget { Q_OBJECT @@ -21,7 +26,7 @@ private: private: KbdTreeView *m_tree; KbdPropertyPanel *m_panel; - ScriptFormWidget* m_te; + ScriptForm_lua::ScriptFormWidget* m_te; private slots: void onAdd(); void onRemove(); diff --git a/product/src/tools/model_plugin/model_linkage/triggerparawidget.cpp b/product/src/tools/model_plugin/model_linkage/triggerparawidget.cpp index 78ed952b..3aef434f 100644 --- a/product/src/tools/model_plugin/model_linkage/triggerparawidget.cpp +++ b/product/src/tools/model_plugin/model_linkage/triggerparawidget.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include "pub_widget/MessageBox.h" #include "kbdtabledatamgr.h" #include "kbdcheckrole.h" #include "kbdmsgcontrl.h" @@ -29,9 +29,11 @@ void TriggerParaWidget::initLayout() QVBoxLayout *vLayoutTree = new QVBoxLayout; QToolBar *bar = new QToolBar(widgetTree); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),tr("添加"),this,SLOT(onAdd())); - bar->addAction(QIcon(":/icons/icons/delete.png"),tr("删除"),this,SLOT(onRemove())); + QAction* act = nullptr; + act = bar->addAction(tr("添加"),this,SLOT(onAdd())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(tr("删除"),this,SLOT(onRemove())); + bar->widgetForAction(act)->setObjectName("icon_delete"); m_tree = new KbdTreeView(widgetTree); KbdSqlTreeModel *treeModel = new KbdSqlTreeModel(Common::getTreePath("TriggerParaTree.xml"),this); @@ -222,17 +224,17 @@ void TriggerParaWidget::onTreeClicked(const QModelIndex &index) void TriggerParaWidget::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } void TriggerParaWidget::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); + N_MessageBox::information(this,tr("消息"),tr("此次修改失败,已启动回滚!")); } void TriggerParaWidget::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } diff --git a/product/src/tools/model_plugin/model_plan_curve/CDbInterface.cpp b/product/src/tools/model_plugin/model_plan_curve/CDbInterface.cpp index 5f1c64e3..eae13d56 100644 --- a/product/src/tools/model_plugin/model_plan_curve/CDbInterface.cpp +++ b/product/src/tools/model_plugin/model_plan_curve/CDbInterface.cpp @@ -1,7 +1,7 @@ #include "CDbInterface.h" #include "dbms/db_sysinfo_api/CDbSysInfo.h" #include "pub_logger_api/logger.h" -#include +#include "pub_widget/MessageBox.h" using namespace iot_dbms; @@ -20,12 +20,12 @@ CDbInterface::~CDbInterface() void CDbInterface::onStartTransactionError(const QString&erroStr) { Q_UNUSED(erroStr); -// QMessageBox::information(NULL,tr("消息"),tr("开启事务失败"), QMessageBox::Ok); +// N_MessageBox::information(NULL,tr("消息"),tr("开启事务失败"), N_MessageBox::Ok); } void CDbInterface::onCommitError() { - // QMessageBox::information(NULL,tr("消息"),tr("提交事务失败,已回滚"), QMessageBox::Ok); + // N_MessageBox::information(NULL,tr("消息"),tr("提交事务失败,已回滚"), N_MessageBox::Ok); } void CDbInterface::readUnit() diff --git a/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigure.cpp b/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigure.cpp index d2935a08..73c04b00 100644 --- a/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigure.cpp +++ b/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigure.cpp @@ -6,9 +6,10 @@ #include "CDbInterface.h" #include #include -#include +#include "pub_widget/MessageBox.h" #include #include "pub_utility_api/FileStyle.h" +#include "../model_common/common.h" CPlanCurvesConfigure::CPlanCurvesConfigure(QWidget *parent, bool hideNavBar, bool editMode) : QWidget(parent), @@ -45,7 +46,10 @@ CPlanCurvesConfigure::CPlanCurvesConfigure(QWidget *parent, bool hideNavBar, boo } else { - ui->planConfigType->setMinimumWidth(150); +// ui->planConfigType->setMinimumWidth(150); + ui->planConfigType->hide(); + + initMainTabBar(); } m_dbInterface = NULL; @@ -279,8 +283,8 @@ void CPlanCurvesConfigure::initTable() ui->tmplTableView->setItemDelegateForColumn(0, new CLineEditDelegate(this, E_MaxLength, 0, 0, 128)); m_dayModel = new QStandardItemModel(this); - m_dayModel->setColumnCount(4); - m_dayModel->setHorizontalHeaderLabels(QStringList()<< tr("日时段名称") << tr("开始时间") << tr("结束时间") << tr("值")); + m_dayModel->setColumnCount(5); + m_dayModel->setHorizontalHeaderLabels(QStringList()<< tr("日时段名称") << tr("开始时间") << tr("结束时间") << tr("值") << tr("单位")); ui->dayTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->dayTableView->setModel(m_dayModel); connect(m_dayModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(slot_DayTableItemChanged(QStandardItem*))); @@ -288,11 +292,28 @@ void CPlanCurvesConfigure::initTable() ui->dayTableView->setItemDelegateForColumn(1, new CTimeEditDelegate(this, true)); ui->dayTableView->setItemDelegateForColumn(2, new CTimeEditDelegate(this)); ui->dayTableView->setItemDelegateForColumn(3, new CLineEditDelegate(this, E_DoubleRange, -999999, 999999)); + ui->dayTableView->setItemDelegateForColumn(4, new CLineEditDelegate(this, true)); ui->splitter->setStretchFactor(1,2); ui->splitter_2->setStretchFactor(0,2); ui->splitter_3->setStretchFactor(1,2); } +void CPlanCurvesConfigure::initMainTabBar() +{ + QTabBar *mainTabBar = new QTabBar; + mainTabBar->setObjectName("planCurveMainTabBar"); + mainTabBar->setExpanding(false); + + for(int i = 0; i < ui->planConfigType->count();i++) + { + mainTabBar->addTab(ui->planConfigType->item(i)->text()); + } + + ui->mainTabBarLayout->addWidget(mainTabBar); + + connect(mainTabBar, SIGNAL(currentChanged(int)), this, SLOT(slot_stackWidgetChg(int))); +} + void CPlanCurvesConfigure::initPlanTypeComb(QComboBox* combox) { combox->clear(); @@ -523,7 +544,7 @@ void CPlanCurvesConfigure::saveTypeData(QTableWidget *tableWidget, int table) QString desc = tableWidget->item(i, 1)->text(); if(desc.isEmpty() && !tableWidget->isRowHidden(i)) { - QMessageBox::information(this,tr("提示"),tr("名称不能为空!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("名称不能为空!"),N_MessageBox::Ok); return; } curveType type = curveType(tableWidget->item(i, 0)->data(Qt::UserRole).toInt()); @@ -538,11 +559,11 @@ void CPlanCurvesConfigure::saveTypeData(QTableWidget *tableWidget, int table) } if(success) { - QMessageBox::information(this,tr("提示"),tr("保存成功!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存成功!"),N_MessageBox::Ok); emit ui->planConfigType->currentRowChanged(0); } else{ - QMessageBox::information(this,tr("提示"),tr("保存失败!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存失败!"),N_MessageBox::Ok); } } @@ -563,14 +584,14 @@ bool CPlanCurvesConfigure::checkDaysData(QStandardItemModel* stanModel, bool isI int endSec = stanModel->data(endIndex, Qt::UserRole).toInt(); if(isInterrupt && name.isEmpty()) { - QMessageBox::information(this,tr("提示"),tr("名称不能为空!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("名称不能为空!"),N_MessageBox::Ok); return false; } if(endSec < startSec) { if(isInterrupt) { - QMessageBox::information(this,tr("提示"),tr("行: %1 结束时间不能小于开始时间!").arg(endIndex.row()+1),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("行: %1 结束时间不能小于开始时间!").arg(endIndex.row()+1),N_MessageBox::Ok); return false; } endSec = startSec; @@ -579,8 +600,8 @@ bool CPlanCurvesConfigure::checkDaysData(QStandardItemModel* stanModel, bool isI stanModel->item(row-1,2)->setData(endSec, Qt::UserRole); if(isInterrupt && (stanModel->item(row,1)->data(Qt::UserRole).toInt() != endSec + 1)) { - QMessageBox::information(this,tr("提示"),tr("行: %1 与行:%2 时间段不连续!") - .arg(endIndex.row()+1).arg(endIndex.row()+2),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("行: %1 与行:%2 时间段不连续!") + .arg(endIndex.row()+1).arg(endIndex.row()+2),N_MessageBox::Ok); return false; } @@ -593,7 +614,7 @@ bool CPlanCurvesConfigure::checkDaysData(QStandardItemModel* stanModel, bool isI } if(isInterrupt && (stanModel->item(0,0)->text().isEmpty() || stanModel->item(rowCount-1,0)->text().isEmpty())) { - QMessageBox::information(this,tr("提示"),tr("名称不能为空!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("名称不能为空!"),N_MessageBox::Ok); return false; } stanModel->item(0,1)->setText(secToStr(0)); @@ -611,7 +632,7 @@ bool CPlanCurvesConfigure::checkWeekData() { if(m_dbInterface->readWeekIdUsed(ui->weekPlanTyleComb->currentData().toInt())) { - QMessageBox::information(this,tr("提示"),tr("周时段配置被使用,无法保存!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("周时段配置被使用,无法保存!"),N_MessageBox::Ok); return false; } return true; @@ -626,7 +647,7 @@ bool CPlanCurvesConfigure::checkWeekData() int week = ui->weekTable->model()->data(index, Qt::UserRole).toInt(); if(name.isEmpty()) { - QMessageBox::information(this,tr("提示"),tr("名称不能为空!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("名称不能为空!"),N_MessageBox::Ok); return false; } if(weekList.indexOf(week) != -1) @@ -637,7 +658,7 @@ bool CPlanCurvesConfigure::checkWeekData() } if(weekList.length() != 7) { - QMessageBox::information(this, tr("提示"), tr("周时段配置需覆盖一整周"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("周时段配置需覆盖一整周"), N_MessageBox::Ok); return false; } return true; @@ -674,19 +695,19 @@ bool CPlanCurvesConfigure::checkYearData() QString name = item->data(desc).toString(); if(name.isEmpty()) { - QMessageBox::information(this,tr("提示"),tr("名称不能为空!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("名称不能为空!"),N_MessageBox::Ok); return false; } if(monthBeg > monthEnd) { - QMessageBox::information(this,tr("提示"),QString(tr("%1 : 开始月不能大于结束月!")).arg(name), QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),QString(tr("%1 : 开始月不能大于结束月!")).arg(name), N_MessageBox::Ok); return false; } else if(monthBeg == monthEnd) { if(daysBeg > daysEnd) { - QMessageBox::information(this,tr("提示"),QString(tr("%1 : 开始日不能大于结束日!")).arg(name), QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),QString(tr("%1 : 开始日不能大于结束日!")).arg(name), N_MessageBox::Ok); return false; } } @@ -713,7 +734,7 @@ bool CPlanCurvesConfigure::checkIsAllYear(const QList& noExcptList) { if(noExcptList.isEmpty()) { - QMessageBox::information(this,tr("提示"),tr("年配置需要覆盖全年!"), QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("年配置需要覆盖全年!"), N_MessageBox::Ok); return false; } int len = noExcptList.length(); @@ -725,7 +746,7 @@ bool CPlanCurvesConfigure::checkIsAllYear(const QList& noExcptList) int oneDay = item->data(oneDayIndex).toInt(); if(oneMonth!=1 || oneDay!=1) { - QMessageBox::information(this,tr("提示"),tr("请从1月1日开始配置!"), QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("请从1月1日开始配置!"), N_MessageBox::Ok); return false; } @@ -744,7 +765,7 @@ bool CPlanCurvesConfigure::checkIsAllYear(const QList& noExcptList) getDateAddOne(monthEnd, daysEnd); if(monthBeg!=monthEnd || daysBeg!=daysEnd) { - QMessageBox::information(this,tr("提示"),tr("年配置需要覆盖全年!"), QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("年配置需要覆盖全年!"), N_MessageBox::Ok); return false; } } @@ -755,7 +776,7 @@ bool CPlanCurvesConfigure::checkIsAllYear(const QList& noExcptList) int lastDay = item->data(lastDayIndex).toInt(); if(lastMonth!=12 || lastDay!=31) { - QMessageBox::information(this,tr("提示"),tr("请配置到12月31日!"), QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("请配置到12月31日!"), N_MessageBox::Ok); return false; } return true; @@ -838,15 +859,19 @@ void CPlanCurvesConfigure::addDayData(const SApcCurveDayValue &day) QStandardItem *end_minute = new QStandardItem(secToStr(day.end_sec)); end_minute->setData(day.end_sec, Qt::UserRole); QStandardItem *value = new QStandardItem(QString::number(day.value)); + QStandardItem *unit = new QStandardItem(day.unit); + QList list; description->setTextAlignment(Qt::AlignCenter); start_minute->setTextAlignment(Qt::AlignCenter); end_minute->setTextAlignment(Qt::AlignCenter); value->setTextAlignment(Qt::AlignCenter); + unit->setTextAlignment(Qt::AlignCenter); list.append(description); list.append(start_minute); list.append(end_minute); list.append(value); + list.append(unit); m_dayModel->appendRow(list); } @@ -1011,6 +1036,7 @@ void CPlanCurvesConfigure::slot_newDaysValue() QStandardItem *end = new QStandardItem(); QStandardItem *des = new QStandardItem(""); QStandardItem *value = new QStandardItem("0"); + QStandardItem *unit = new QStandardItem(getSeldCurveUnit()); des->setData(INSERT_CURVE, Qt::UserRole); value->setData(0, Qt::UserRole); @@ -1032,10 +1058,12 @@ void CPlanCurvesConfigure::slot_newDaysValue() start->setTextAlignment(Qt::AlignCenter); end->setTextAlignment(Qt::AlignCenter); value->setTextAlignment(Qt::AlignCenter); + unit->setTextAlignment(Qt::AlignCenter); list.append(des); list.append(start); list.append(end); list.append(value); + list.append(unit); if(insert) { @@ -1049,7 +1077,8 @@ void CPlanCurvesConfigure::slot_newDaysValue() void CPlanCurvesConfigure::slot_newPlanCurve() { - KbdSelectPointDlg dlg; + KbdSelectPointDlg dlg(this); + dlg.setWindowTitle(tr("新建计划曲线")); QStringList list; list << QString("sql@SELECT * FROM SYS_MODEL_LOCATION_INFO;LOCATION_ID:DESCRIPTION") <typeTable->item(row, 1)->text(); if(m_dbInterface->readTypeIdUsed(id)) { - QMessageBox::information(this, tr("提示"), QString("%1 被使用, 无法删除!").arg(desc), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), QString("%1 被使用, 无法删除!").arg(desc), N_MessageBox::Ok); return; } ui->typeTable->hideRow(row); @@ -1144,7 +1173,7 @@ void CPlanCurvesConfigure::slot_delYearConfig() { if(m_dbInterface->readYearIdUsed(m_yearModel->data(idIndex).toInt(), ui->yearPlanTyleComb->currentData().toInt())) { - QMessageBox::information(this, tr("提示"), QString("%1 被使用, 无法删除!").arg(m_yearModel->data(descIndex).toString()), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), QString("%1 被使用, 无法删除!").arg(m_yearModel->data(descIndex).toString()), N_MessageBox::Ok); return; } } @@ -1198,19 +1227,19 @@ void CPlanCurvesConfigure::slot_delPlanCurve() return; } - int ret = QMessageBox::information(this, tr("提示"), QString(tr("是否删除曲线'%1'?")).arg(ui->planCurveTable->item(row,1)->text()), QMessageBox::Ok|QMessageBox::Cancel); - if(ret == QMessageBox::Cancel) + int ret = N_MessageBox::information(this, tr("提示"), QString(tr("是否删除曲线'%1'?")).arg(ui->planCurveTable->item(row,1)->text()), N_MessageBox::Ok|N_MessageBox::Cancel); + if(ret == N_MessageBox::Cancel) return; if(m_dbInterface->delApcCurve(ui->planCurveTable->item(row,0)->text())) { ui->planCurveTable->removeRow(row); emit ui->planConfigType->currentRowChanged(4); - QMessageBox::information(this, tr("提示"), tr("删除成功!"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("删除成功!"), N_MessageBox::Ok); } else { - QMessageBox::information(this, tr("提示"), tr("删除失败!"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("删除失败!"), N_MessageBox::Ok); } } @@ -1228,7 +1257,7 @@ void CPlanCurvesConfigure::slot_saveYearConfg() { if(ui->yearPlanTyleComb->currentIndex() < 0) { - QMessageBox::information(this,tr("提示"),tr("计划类型为空,请检查类型配置!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("计划类型为空,请检查类型配置!"),N_MessageBox::Ok); return; } @@ -1276,18 +1305,18 @@ void CPlanCurvesConfigure::slot_saveYearConfg() // else // item->setData(typeIndex, NORMAL_CURVE, Qt::UserRole); // } - QMessageBox::information(this,tr("提示"),tr("保存成功!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存成功!"),N_MessageBox::Ok); emit ui->yearPlanTyleComb->currentIndexChanged(ui->yearPlanTyleComb->currentIndex()); } else - QMessageBox::information(this,tr("提示"),tr("保存失败!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存失败!"),N_MessageBox::Ok); } void CPlanCurvesConfigure::slot_saveWeekConfg() { if(ui->weekPlanTyleComb->currentIndex() < 0) { - QMessageBox::information(this,tr("提示"),tr("计划类型为空,请检查类型配置!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("计划类型为空,请检查类型配置!"),N_MessageBox::Ok); return; } @@ -1336,7 +1365,7 @@ void CPlanCurvesConfigure::slot_saveWeekConfg() { if(m_dbInterface->readWeekIdUsed(ui->weekPlanTyleComb->currentData().toInt())) { - QMessageBox::information(this,tr("提示"),tr("周时段配置被使用,无法保存!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("周时段配置被使用,无法保存!"),N_MessageBox::Ok); return; } success = m_dbInterface->updateApcCurveWeek(typeId, weekList); @@ -1357,12 +1386,12 @@ void CPlanCurvesConfigure::slot_saveWeekConfg() if(success) { - QMessageBox::information(this,tr("提示"),tr("保存成功!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存成功!"),N_MessageBox::Ok); emit ui->weekPlanTyleComb->currentIndexChanged(ui->weekPlanTyleComb->currentIndex()); } else { - QMessageBox::information(this,tr("提示"),tr("保存失败!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存失败!"),N_MessageBox::Ok); } } @@ -1370,7 +1399,7 @@ void CPlanCurvesConfigure::slot_saveDaysConfg() { if(ui->dayTmplTyleComb->currentIndex() < 0) { - QMessageBox::information(this,tr("提示"),tr("日模板类型为空,请检查类型配置!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("日模板类型为空,请检查类型配置!"),N_MessageBox::Ok); return; } @@ -1402,18 +1431,18 @@ void CPlanCurvesConfigure::slot_saveDaysConfg() if(m_dbInterface->updateTmplSection(id, dayList, m_delDayList)) { - QMessageBox::information(this,tr("提示"),tr("保存成功!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存成功!"),N_MessageBox::Ok); emit ui->dayTmplTyleComb->currentIndexChanged(ui->dayTmplTyleComb->currentIndex()); return; } - QMessageBox::information(this,tr("提示"),tr("保存失败!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存失败!"),N_MessageBox::Ok); } void CPlanCurvesConfigure::slot_saveDaysValue() { if(!ui->timeCofigTableView->currentIndex().isValid()) { - QMessageBox::information(this, tr("提示"), tr("请选择一条时段曲线!"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("请选择一条时段曲线!"), N_MessageBox::Ok); return; } if(!checkDaysData(m_dayModel,true)) @@ -1426,18 +1455,18 @@ void CPlanCurvesConfigure::slot_saveDaysValue() getDayValueList(dayList, m_valResult.valueId, false); if(m_dbInterface->updateDayValue(m_valResult.valueId, dayList, m_delDayList)) { - QMessageBox::information(this,tr("提示"),tr("保存成功!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存成功!"),N_MessageBox::Ok); emit ui->timeCofigTableView->clicked(ui->timeCofigTableView->currentIndex()); return; } - QMessageBox::information(this,tr("提示"), tr("保存失败!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"), tr("保存失败!"),N_MessageBox::Ok); } void CPlanCurvesConfigure::slot_savePlanCurve() { if(ui->curvePlanTypeComb->currentIndex() < 0) { - QMessageBox::information(this,tr("提示"),tr("计划类型为空,请检查类型配置!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("计划类型为空,请检查类型配置!"),N_MessageBox::Ok); return; } @@ -1473,11 +1502,11 @@ void CPlanCurvesConfigure::slot_savePlanCurve() { ui->planCurveTable->item(row,1)->setData(Qt::UserRole, NORMAL_CURVE); } - QMessageBox::information(this,tr("提示"),tr("保存成功!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存成功!"),N_MessageBox::Ok); } else { - QMessageBox::information(this,tr("提示"),tr("保存失败!"),QMessageBox::Ok); + N_MessageBox::information(this,tr("提示"),tr("保存失败!"),N_MessageBox::Ok); emit ui->planConfigType->currentRowChanged(4); } } @@ -1638,9 +1667,11 @@ void CPlanCurvesConfigure::slot_updateDayTable(QModelIndex index) m_valResult.keyIdTag = keyId; m_dayModel->setRowCount(0); + QString strUnit = getSeldCurveUnit(); for(int i=0;idaySetBtn->click(); @@ -1652,7 +1683,7 @@ void CPlanCurvesConfigure::slot_importTmplValue() QModelIndexList indexList = ui->timeCofigTableView->selectionModel()->selectedIndexes(); if(indexList.isEmpty()) { - QMessageBox::information(this, tr("提示"), tr("请选择一条时段曲线!"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("请选择一条时段曲线!"), N_MessageBox::Ok); return; } @@ -1665,11 +1696,11 @@ void CPlanCurvesConfigure::slot_importTmplValue() } if(!m_dbInterface->updateDayValue(temp)) { - QMessageBox::information(this, tr("提示"), tr("导入失败"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("导入失败"), N_MessageBox::Ok); } else { - QMessageBox::information(this, tr("提示"), tr("导入成功"), QMessageBox::Ok); + N_MessageBox::information(this, tr("提示"), tr("导入成功"), N_MessageBox::Ok); emit ui->timeCofigTableView->clicked(ui->timeCofigTableView->currentIndex()); } } diff --git a/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.cpp b/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.cpp index b96a3ea1..a40b039e 100644 --- a/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.cpp +++ b/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.cpp @@ -1,6 +1,9 @@ #include #include "CPlanCurvesConfigurePluginWidget.h" #include "CPlanCurvesConfigure.h" +#include "pub_widget/PubWidgetInit.h" +#include +#include "../model_common/common.h" CPlanCurvesConfigurePluginWidget::CPlanCurvesConfigurePluginWidget(QObject *parent): QObject(parent) { @@ -17,6 +20,12 @@ bool CPlanCurvesConfigurePluginWidget::createWidget(QWidget *parent, bool editMo bool hideNavBar = true; if(ptrVec.size() > 0) hideNavBar = ((QVariant*)ptrVec.first())->toBool(); + + QTranslator * qtTranslator = new QTranslator; + qtTranslator->load(Common::getTranslatePath("model_plan_curve_EN.qm")); + qApp->installTranslator(qtTranslator); + iot_public::installTranslator(Common::getLanguage().toStdString()); + CPlanCurvesConfigure *pWidget = new CPlanCurvesConfigure(parent,hideNavBar,editMode); *widget = (QWidget *)pWidget; *reportWidget = (IPluginWidget *)pWidget; diff --git a/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.h b/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.h index fb999ce3..5af55f16 100644 --- a/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.h +++ b/product/src/tools/model_plugin/model_plan_curve/CPlanCurvesConfigurePluginWidget.h @@ -7,7 +7,7 @@ class CPlanCurvesConfigurePluginWidget: public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/model_plugin/model_plan_curve/PlanCurvesConfigure.ui b/product/src/tools/model_plugin/model_plan_curve/PlanCurvesConfigure.ui index fe1f5b39..117fbf7d 100644 --- a/product/src/tools/model_plugin/model_plan_curve/PlanCurvesConfigure.ui +++ b/product/src/tools/model_plugin/model_plan_curve/PlanCurvesConfigure.ui @@ -13,862 +13,128 @@ CPlanCurvesConfigure - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 0 - 16777215 - - - - -1 + + + + + 6 - - 类型配置 - + - - 年时段配置 - - - - - 周时段配置 - - - - - 日时段模板配置 - - - - - 计划曲线配置 - - - - - - - - QFrame::Box - - - QFrame::Sunken - - - 4 - - - - - 3 - - - 3 - - - 3 - - - 3 - + - 3 + 0 - - + + + + + 0 + 16777215 + + + + -1 + + + + 类型配置 + + + + + 年时段配置 + + + + + 周时段配置 + + + + + 日时段模板配置 + + + + + 计划曲线配置 + + + + + + QFrame::Box QFrame::Sunken - - - 3 - - - 3 - - - 3 - - - 4 - - - 3 - - - - - - - 新建类型 - - - - - - - 保存 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 计划类型 - - - - - - - 删除 - - - - - - - - - - - - - - 新建模板类型 - - - - - - - 保存 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 日时段模板类型 - - - - - - - 删除 - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - QFrame::Box - - - QFrame::Sunken - - - - 3 - - - 3 - - - 3 - - - 4 - - - 3 - - - - - QAbstractItemView::SingleSelection - - - - - - - 3 - - - - - 新建年时段配置 - - - - - - - 保存 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 计划类型 - - - - - - - 删除 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 281 - - - - - - - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Qt::Vertical - - - - 20 - 202 - - - - - - - - QFrame::Box - - - QFrame::Sunken - - - - 3 - - - 3 - - - 3 - - - 4 - - - 3 - - - - - 3 - - - - - 保存 - - - - - - - 删除 - - - - - - - 计划类型 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 新建周时段配置 - - - - - - - - - QAbstractItemView::SingleSelection - - - - - - - - - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - QFrame::Box - - - QFrame::Sunken - - - - 3 - - - 3 - - - 3 - - - 4 - - - 3 - - - - - 3 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 新建日时段配置 - - - - - - - 删除 - - - - - - - 保存 - - - - - - - 日模板类型 - - - - - - - - - - - - QAbstractItemView::SingleSelection - - - - - - - - - - Qt::Vertical - - - - 20 - 202 - - - - - - - - - - 3 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - Qt::Vertical - - + 0 - - - - 2 + + + + 3 - - - - 3 - - - - - 计划类型 - - - - - - - - - - Qt::Horizontal - - - - 419 - 20 - - - - - - - - 新建计划曲线 - - - - - - - 删除 - - - - - - - 保存 - - - - - - - - - - 0 - 0 - - - - QAbstractItemView::SelectRows - - - 150 - - - - 关联标签 - - - - - 计划曲线名称 - - - - - 类型ID - - - - - 所属位置 - - - - - 所属专业 - - - - - 单位 - - - - - - - - - - 2 + + 3 - - - - 3 + + 3 + + + 3 + + + 3 + + + + + QFrame::Box - - - - - 0 - 20 - - - - - 10 - 50 - false - - - - 时段曲线配置 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal + + QFrame::Sunken - - 3 - - - - Qt::CustomContextMenu + + + 3 - - QAbstractItemView::NoEditTriggers + + 3 - - QAbstractItemView::ExtendedSelection + + 3 - - QAbstractItemView::SelectRows + + 4 - - - - Qt::Vertical + + 3 - - 0 - - - - - 100 - 150 - - - - - - QAbstractItemView::SingleSelection - - - - - - 3 - - - - - Qt::Vertical - - - + + - + - 导入模板 + 新建类型 - - - 新建 - - - - - - - 预览 - - - - - - - 日模板类型 - - - - - - - 删除 - - - - - + 保存 - - - - 150 - 0 - - - - - - + Qt::Horizontal @@ -880,8 +146,744 @@ + + + + 计划类型 + + + + + + + 删除 + + + - + + + + + + + + + + 新建模板类型 + + + + + + + 保存 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 日时段模板类型 + + + + + + + 删除 + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + QFrame::Box + + + QFrame::Sunken + + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + + + QAbstractItemView::SingleSelection + + + + + + + 3 + + + + + 新建年时段配置 + + + + + + + 保存 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 计划类型 + + + + + + + 删除 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 281 + + + + + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + Qt::Vertical + + + + 20 + 202 + + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + + + 3 + + + + + 保存 + + + + + + + 删除 + + + + + + + 计划类型 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 新建周时段配置 + + + + + + + + + QAbstractItemView::SingleSelection + + + + + + + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + QFrame::Box + + + QFrame::Sunken + + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + + + 3 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 新建日时段配置 + + + + + + + 删除 + + + + + + + 保存 + + + + + + + 日模板类型 + + + + + + + + + + + + QAbstractItemView::SingleSelection + + + + + + + + + + Qt::Vertical + + + + 20 + 202 + + + + + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + Qt::Vertical + + + 0 + + + + + 2 + + + + + 3 + + + + + 计划类型 + + + + + + + + + + Qt::Horizontal + + + + 419 + 20 + + + + + + + + 新建计划曲线 + + + + + + + 删除 + + + + + + + 保存 + + + + + + + + + + 0 + 0 + + + + QAbstractItemView::SelectRows + + + 150 + + + + 关联标签 + + + + + 计划曲线名称 + + + + + 类型ID + + + + + 所属位置 + + + + + 所属专业 + + + + + 单位 + + + + + + + + + + 2 + + + + + 3 + + + + + + 0 + 20 + + + + + 10 + 50 + false + + + + 时段曲线配置 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + 3 + + + + Qt::CustomContextMenu + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + + + Qt::Vertical + + + 0 + + + + + 100 + 150 + + + + + + QAbstractItemView::SingleSelection + + + + + + 3 + + + + + Qt::Vertical + + + + + + + 导入模板 + + + + + + + 新建 + + + + + + + 预览 + + + + + + + 日模板类型 + + + + + + + 删除 + + + + + + + 保存 + + + + + + + + 150 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + @@ -890,8 +892,8 @@ - - + + diff --git a/product/src/tools/model_plugin/model_plan_curve/model_plan_curve.pro b/product/src/tools/model_plugin/model_plan_curve/model_plan_curve.pro index 1a47509e..89bf8b26 100644 --- a/product/src/tools/model_plugin/model_plan_curve/model_plan_curve.pro +++ b/product/src/tools/model_plugin/model_plan_curve/model_plan_curve.pro @@ -65,4 +65,6 @@ RESOURCES += \ LIBS += -ldb_base_api -ldb_api_ex -ldb_sysinfo_api -lmodel_table -lmodel_common -lmodel_excel LIBS += -lnet_msg_bus_api -lperm_mng_api -llog4cplus -lpub_logger_api -lpub_utility_api +LIBS += -lpub_widget +TRANSLATIONS = $$PWD/model_plan_curve_EN.ts diff --git a/product/src/tools/model_plugin/model_plugin.pro b/product/src/tools/model_plugin/model_plugin.pro index 810dd586..74a23097 100644 --- a/product/src/tools/model_plugin/model_plugin.pro +++ b/product/src/tools/model_plugin/model_plugin.pro @@ -9,7 +9,7 @@ SUBDIRS += \ model_plan_curve \ ExpressionWidget \ StaticsWidget \ - iec61850InstWizard \ +# iec61850InstWizard \ PCPMS_IP_Setting \ PCPMS_Screen_Brightness_Setting diff --git a/product/src/tools/model_plugin/model_sequence/model_sequence.pro b/product/src/tools/model_plugin/model_sequence/model_sequence.pro index 398d49a8..49438c3d 100644 --- a/product/src/tools/model_plugin/model_sequence/model_sequence.pro +++ b/product/src/tools/model_plugin/model_sequence/model_sequence.pro @@ -30,6 +30,7 @@ LIBS += -lmodel_excel LIBS += -lpub_logger_api LIBS += -llog4cplus -lpub_utility_api +LIBS += -lpub_widget #DEFINES += SEQORDERCTRL_LIBRARY diff --git a/product/src/tools/model_plugin/model_sequence/model_sequence_EN.ts b/product/src/tools/model_plugin/model_sequence/model_sequence_EN.ts index e0d2f7e1..b99c57c7 100644 --- a/product/src/tools/model_plugin/model_sequence/model_sequence_EN.ts +++ b/product/src/tools/model_plugin/model_sequence/model_sequence_EN.ts @@ -4,221 +4,225 @@ QObject - + 顺控动作 - Sequential action + Sequential action - + 顺控功能 - Sequence control function + Sequence control function - + 顺控定义 - Sequence definition + Sequence definition - - - 添加 - Add - - - - - 修改 - Modify - - - + + 添加 + Add + + + + + 修改 + Modify + + + + 删除 - Delete + Delete - + 保存 - Save + Save - + 所有 - All + All - + 所属位置: - Location: + Location: - - - + + 搜索描述 - Search description + Search description - + 功能名称: - function name: + function name: - + + 请输入描述关键字 + Please enter a descriptive keyword + + + 功能描述: - Function description: + Function description: - + 此功能所包含的动作列表 - List of actions included in this function + List of actions included in this function + + + + + 添加记录 + Add record - - 添加记录 - Add record - - - - + 修改记录 - Modify record + Modify record - + 删除记录 - Delete Record + Delete Record - + 顺控列表 - Sequence List + Sequence List - + 此顺控所包含的功能列表 - List of actions included in this function + List of actions included in this function SeqOrderCtrl - + 添加成功 - Added successfully + Added successfully - + 以下功能使用了该动作,请先修改对应功能设置! - The following functions use this action,please modify the corresponding function settings first! + The following functions use this action,please modify the corresponding function settings first! - + 删除失败! - failed to delete! + failed to delete! - - - - - + + + + + 删除成功! - successfully deleted! + successfully deleted! - - + + 以下顺控使用了该功能,请先修改对应顺控设置! - The following sequencer uses this function, please modify the corresponding sequencer setting first! + The following sequencer uses this function, please modify the corresponding sequencer setting first! - + 请选中要修改的功能 - Please select the function to be modified + Please select the function to be modified - + 名称和描述都不允许为空 - Neither the name nor the description is allowed to be empty + Neither the name nor the description is allowed to be empty - + 功能名称重复 - Duplicate feature name + Duplicate feature name - + 修改成功 - Successfully modified + Successfully modified - + 获取车站信息失败 - Failed to obtain station information + Failed to obtain station information - + 保存失败 - Save failed + Save failed - - - - + + + + 添加成功! - Added successfully + Added successfully - - - - + + + + 修改成功! - Successfully modified + Successfully modified - - - - + + + + 请先保存修改 - Please save the changes first + Please save the changes first - - + + 请在左侧选中要添加的功能 - Please select the function you want to add on the left + Please select the function you want to add on the left - - - + + + 请选中要修改的行 - Please select the row to be modified + Please select the row to be modified - + 请选中要添加的顺控 - Please select the sequence to add + Please select the sequence to add + + + + + + 消息 + Message - - - 消息 - Message - - - 提交事务失败,已回滚 - Failed to commit transaction and rolled back + Failed to commit transaction and rolled back diff --git a/product/src/tools/model_plugin/model_sequence/seqorderctrl.cpp b/product/src/tools/model_plugin/model_sequence/seqorderctrl.cpp index ffa52d69..6dd985d1 100644 --- a/product/src/tools/model_plugin/model_sequence/seqorderctrl.cpp +++ b/product/src/tools/model_plugin/model_sequence/seqorderctrl.cpp @@ -14,7 +14,7 @@ #include "kbdtabledatamgr.h" #include #include -#include +#include "pub_widget/MessageBox.h" #include #include "kbdpropertydlg.h" #include @@ -28,6 +28,7 @@ #include #include #include +#include "pub_widget/PubWidgetInit.h" class SeqOrderCtrlPrivate { @@ -212,7 +213,7 @@ private: hSplittter->addWidget(initFuncLeftList(hSplittter)); QWidget *widget = new QWidget(hSplittter); - QGridLayout *grid = new QGridLayout; + QHBoxLayout *funcLayout = new QHBoxLayout; QLabel *label1 = new QLabel(QObject::tr("功能名称:"),widget); QLabel *label2 = new QLabel(QObject::tr("功能描述:"),widget); @@ -222,16 +223,22 @@ private: labelFuncDesc = new QLabel("xxxx",widget); labelFuncName->setObjectName("labelFuncName"); labelFuncDesc->setObjectName("labelFuncDesc"); - grid->addWidget(label1,0,0); - grid->addWidget(label2,1,0); - grid->addWidget(labelFuncName,0,1); - grid->addWidget(labelFuncDesc,1,1); labelFuncName->setFrameStyle(QFrame::Panel|QFrame::Sunken); labelFuncDesc->setFrameStyle(QFrame::Panel|QFrame::Sunken); - grid->setAlignment(Qt::AlignCenter); + funcLayout->addWidget(label1); + funcLayout->addSpacing(5); + funcLayout->addWidget(labelFuncName); + funcLayout->addSpacing(50); + + funcLayout->addWidget(label2,0); + funcLayout->addSpacing(5); + funcLayout->addWidget(labelFuncDesc); + funcLayout->addStretch(); + funcLayout->setSpacing(0); + QVBoxLayout *vLayout = new QVBoxLayout; - vLayout->addLayout(grid); + vLayout->addLayout(funcLayout); vLayout->setSpacing(20); QGroupBox * box = new QGroupBox(QObject::tr("此功能所包含的动作列表"),widget); @@ -240,10 +247,13 @@ private: QToolBar *bar = new QToolBar(widget); tableFunc = new KbdTable(widget); tableFunc->setObjectName("tableFunc"); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),QObject::tr("添加记录"),q,SLOT(onAddActionToFunc())); - bar->addAction(QIcon(":/icons/icons/modify.png"),QObject::tr("修改记录"),q,SLOT(onModifyActionOfFunc())); - bar->addAction(QIcon(":/icons/icons/delete.png"),QObject::tr("删除记录"),q,SLOT(onRemoveActionOfFunc())); + QAction* act = nullptr; + act = bar->addAction(QObject::tr("添加记录"),q,SLOT(onAddActionToFunc())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyActionOfFunc())); + bar->widgetForAction(act)->setObjectName("icon_edit"); + act = bar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveActionOfFunc())); + bar->widgetForAction(act)->setObjectName("icon_delete"); vLayoutBox->addWidget(bar); vLayoutBox->addWidget(tableFunc); @@ -306,23 +316,24 @@ private: leSearchOrder = new QLineEdit(boxTop); leSearchOrder->setObjectName("leSearchOrder"); leSearchOrder->setPlaceholderText(QObject::tr("搜索描述")); - hLayoutSearch->addWidget(leSearchOrder); - vLayoutTopLeft->addLayout(hLayoutSearch); tableSetting = new KbdTable(boxTop); vLayoutTopLeft->addWidget(tableSetting); - QVBoxLayout *vLayoutTopRight = new QVBoxLayout; - QPushButton *btAdd = new QPushButton(QObject::tr("添加"),boxTop); - QPushButton *btModify = new QPushButton(QObject::tr("修改"),boxTop); - QPushButton *btRemove = new QPushButton(QObject::tr("删除"),boxTop); - vLayoutTopRight->addWidget(btAdd); - vLayoutTopRight->addWidget(btModify); - vLayoutTopRight->addWidget(btRemove); + QToolBar *topBar = new QToolBar(boxTop); //顺控列表中的工具栏 + QAction* act = nullptr; + act = topBar->addAction(QObject::tr("添加记录"),q,SLOT(onAddSeqSetting())); + topBar->widgetForAction(act)->setObjectName("icon_add"); + act = topBar->addAction(QObject::tr("修改记录"),q,SLOT(onModifySeqSetting())); + topBar->widgetForAction(act)->setObjectName("icon_edit"); + act = topBar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveSeqSetting())); + topBar->widgetForAction(act)->setObjectName("icon_delete"); + + hLayoutSearch->addWidget(topBar); + hLayoutSearch->addWidget(leSearchOrder); QHBoxLayout *hLayoutTop = new QHBoxLayout; hLayoutTop->addLayout(vLayoutTopLeft); - hLayoutTop->addLayout(vLayoutTopRight); boxTop->setLayout(hLayoutTop); QGroupBox * boxButtom = new QGroupBox(QObject::tr("此顺控所包含的功能列表"),vSplitter); @@ -330,10 +341,12 @@ private: QVBoxLayout *vLayoutBoxButtom = new QVBoxLayout; QToolBar *bar = new QToolBar(boxButtom); tableDefine = new KbdTable(boxButtom); - bar->setIconSize(QSize(24,24)); - bar->addAction(QIcon(":/icons/icons/new.png"),QObject::tr("添加记录"),q,SLOT(onAddFuncToSeq())); - bar->addAction(QIcon(":/icons/icons/modify.png"),QObject::tr("修改记录"),q,SLOT(onModifyFuncOfSeq())); - bar->addAction(QIcon(":/icons/icons/delete.png"),QObject::tr("删除记录"),q,SLOT(onRemoveFuncOfSeq())); + act = bar->addAction(QObject::tr("添加记录"),q,SLOT(onAddFuncToSeq())); + bar->widgetForAction(act)->setObjectName("icon_add"); + act = bar->addAction(QObject::tr("修改记录"),q,SLOT(onModifyFuncOfSeq())); + bar->widgetForAction(act)->setObjectName("icon_edit"); + act = bar->addAction(QObject::tr("删除记录"),q,SLOT(onRemoveFuncOfSeq())); + bar->widgetForAction(act)->setObjectName("icon_delete"); vLayoutBoxButtom->addWidget(bar); vLayoutBoxButtom->addWidget(tableDefine); @@ -353,10 +366,6 @@ private: tableDefine->setShowCol(showCols); } - QObject::connect(btAdd,SIGNAL(clicked(bool)),q,SLOT(onAddSeqSetting())); - QObject::connect(btModify,SIGNAL(clicked(bool)),q,SLOT(onModifySeqSetting())); - QObject::connect(btRemove,SIGNAL(clicked(bool)),q,SLOT(onRemoveSeqSetting())); - QObject::connect(tableSetting,SIGNAL(doubleClicked(const QModelIndex &)),q,SLOT(onModifySeqSetting())); QObject::connect(tableSetting,SIGNAL(clicked(const QModelIndex &)),q,SLOT(onClickedSetting(const QModelIndex &))); QObject::connect(leSearchOrder,SIGNAL(textChanged(const QString &)),q,SLOT(onSearchSeq())); @@ -368,6 +377,7 @@ private: m_translates = new QTranslator; m_translates->load(Common::getTranslatePath("model_sequence_EN.qm")); qApp->installTranslator(m_translates); + iot_public::installTranslator(Common::getLanguage().toStdString()); } void removeTranslate(){ qApp->removeTranslator(m_translates); @@ -415,6 +425,7 @@ void SeqOrderCtrl::addFunc() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("新增顺控功能")); dlg.panel()->setDisplayRow(model,model->rowCount()); dlg.panel()->setPropertyValue(CN_ACTION_NO,"1"); dlg.panel()->setPropertyEditable(CN_ACTION_NAME,true); @@ -575,6 +586,7 @@ void SeqOrderCtrl::modifyFunc() QString newName; QString newDesc; KbdPropertyDlg dlg(false,this); + dlg.setWindowTitle(tr("修改顺控功能")); QList cols; cols << modelFuncCols.findCol(CN_NAME) << modelFuncCols.findCol(CN_DESC); dlg.panel()->setDisplayRow(modelFunc,modelFunc->rowCount(), modelFuncCols.getGroup(),cols); @@ -1027,6 +1039,7 @@ void SeqOrderCtrl::onAddActionToFunc() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("添加顺控动作")); dlg.panel()->setDisplayRow(model,model->rowCount()); dlg.panel()->setPropertyValue(CN_NAME,index.data(Qt::UserRole).toString()); dlg.panel()->setPropertyValue(CN_DESC,index.data().toString()); @@ -1144,6 +1157,7 @@ void SeqOrderCtrl::onModifyActionOfFunc() showCols.removeAll(modelFuncCols.findCol(CN_DESC)); showCols.removeAll(modelFuncCols.findCol(CN_TIMEFLAG)); KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("修改顺控动作")); dlg.panel()->setDisplayRow(modelFunc,index.row(), modelFuncCols.getGroup(),showCols); if(dlg.exec()) { @@ -1173,6 +1187,7 @@ void SeqOrderCtrl::onAddSeqSetting() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("新增顺控")); dlg.panel()->setDisplayRow(modelSeqSetting,modelSeqSetting->rowCount()); if(dlg.exec()) { @@ -1211,6 +1226,7 @@ void SeqOrderCtrl::onModifySeqSetting() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("修改顺控")); dlg.panel()->setDisplayRow(modelSeqSetting,index.row()); if(dlg.exec()) { @@ -1296,6 +1312,7 @@ void SeqOrderCtrl::onAddFuncToSeq() if(retStr.isEmpty()) { KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("添加顺控功能")); const ColMgrDataList& modelSettingCols = modelSetting->getHeadCols(); dlg.panel()->setDisplayRow(modelDefine,modelDefine->rowCount()); dlg.panel()->setPropertyEditable(CN_FUNC_NAME,true); @@ -1386,6 +1403,7 @@ void SeqOrderCtrl::onModifyFuncOfSeq() showCols.removeAll(modelDefineCols.findCol(CN_SEQ_NAME)); showCols.removeAll(modelDefineCols.findCol(CN_TIMEFLAG)); KbdPropertyDlg dlg(true,this); + dlg.setWindowTitle(tr("修改顺控功能")); dlg.panel()->setDisplayRow(modelDefine,index.row(), modelDefineCols.getGroup(),showCols); if(dlg.exec()) { @@ -1405,17 +1423,17 @@ void SeqOrderCtrl::onModifyFuncOfSeq() void SeqOrderCtrl::onStartTransactionError(const QString&erroStr) { - QMessageBox::information(this,tr("消息"),erroStr); + N_MessageBox::information(this,tr("消息"),erroStr); } void SeqOrderCtrl::onCommitError() { - QMessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); + N_MessageBox::information(this,tr("消息"),tr("提交事务失败,已回滚")); } void SeqOrderCtrl::onMsg(const QString &msg) { - QMessageBox::information(this,tr("消息"),msg); + N_MessageBox::information(this,tr("消息"),msg); } diff --git a/product/src/tools/model_plugin/model_sequence/sequencepluginwidget.h b/product/src/tools/model_plugin/model_sequence/sequencepluginwidget.h index 48126b90..5c24f43c 100644 --- a/product/src/tools/model_plugin/model_sequence/sequencepluginwidget.h +++ b/product/src/tools/model_plugin/model_sequence/sequencepluginwidget.h @@ -7,7 +7,7 @@ class SequencePluginWidget : public QObject, public CPluginWidgetInterface { Q_OBJECT - Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0") + Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID) Q_INTERFACES(CPluginWidgetInterface) public: diff --git a/product/src/tools/setup/setup_installer/res/原背景.png b/product/src/tools/setup/setup_installer/res/原背景.png new file mode 100644 index 00000000..b36f800a Binary files /dev/null and b/product/src/tools/setup/setup_installer/res/原背景.png differ diff --git a/product/src/tools/setup_install_helper/SetupWidget.cpp b/product/src/tools/setup_install_helper/SetupWidget.cpp index c66f8991..9928dcc4 100644 --- a/product/src/tools/setup_install_helper/SetupWidget.cpp +++ b/product/src/tools/setup_install_helper/SetupWidget.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -11,6 +12,11 @@ #include #include "installer_common.h" +#include "db_manager_api/db_opt_mysql.h" +#include "db_manager_api/db_opt_kingbase.h" +#include "db_manager_api/db_opt_opengauss.h" +#include "tsdb_api/TsdbApi.h" + #ifdef OS_WINDOWS #include "windows.h" @@ -18,6 +24,9 @@ #pragma comment(lib,"user32.lib") #endif +#define DB_TYPE_MYSQL "mysql" +#define DB_TYPE_OPENGAUSS "opengauss" +#define DB_TYPE_KINGBASE "kingbase" bool isKylin() { @@ -162,9 +171,11 @@ void SetupWidget::install() } } - registerKeepalivedSrv(); - statusInstall(tr("注册keepalived服务完成")); - + if(m_isWebInstalled) + { + registerKeepalivedSrv(); + statusInstall(tr("注册keepalived服务完成")); + } exit(EXIT_SUCCESS); } @@ -353,7 +364,17 @@ bool SetupWidget::installRd() return false; #endif if(!installRdService()) + { return false; + } + + QThread::msleep(5000); + if(!modifyDBPassword()) //创建或者修改用户名密码 + { + return false; + } + + QThread::msleep(1000); return true; } @@ -404,6 +425,33 @@ bool SetupWidget::copyMySQL() } #endif +#ifdef OS_LINUX +bool SetupWidget::relpaceInfluxDBConfig(const QString &cfgFile) +{ + if( !QFile::remove("/etc/influxdb/influxdb.conf") ) + { + errorInstall(tr("安装InfluxDB过程中无法移除配置文件")); + return false; + } + if( !QFile::copy(this->m_mainProgramPath + + QDir::separator() + "product" + + QDir::separator() + "common" + + QDir::separator() + "sysconfig" + + QDir::separator() + "setup" + + QDir::separator() + cfgFile + ,"/etc/influxdb/influxdb.conf") ) + { + errorInstall(tr("安装InfluxDB过程中无法更换配置文件")); + return false; + } + system("systemctl enable influxdb"); + system("systemctl restart influxdb"); + QThread::msleep(3000); + + return true; +} +#endif + bool SetupWidget::installInfluxDBService() { #ifdef OS_WINDOWS @@ -426,27 +474,78 @@ bool SetupWidget::installInfluxDBService() #endif #ifdef OS_LINUX - if( !QFile::remove("/etc/influxdb/influxdb.conf") ) + //先禁用权限认证,用来创建用户 + if(!relpaceInfluxDBConfig("influxdb_without_auth.conf")) { - errorInstall(tr("安装InfluxDB过程中无法移除配置文件")); - return false; - } - if( !QFile::copy(this->m_mainProgramPath - + QDir::separator() + "product" - + QDir::separator() + "common" - + QDir::separator() + "sysconfig" - + QDir::separator() + "setup" - + QDir::separator() + "influxdb.conf" - ,"/etc/influxdb/influxdb.conf") ) - { - errorInstall(tr("安装InfluxDB过程中无法更换配置文件")); return false; } - system("systemctl enable influxdb"); - system("systemctl restart influxdb"); #endif - return true; + // 创建用户 + if (!iot_dbms::initTsdbApi()) + { + errorInstall(tr("influxdb连接初始化失败")); + } + + /* 为以后搜索方便,保留此注释 EMS_DEFAULT_DATABASE + * 时序库的参数用数据库的参数,用户名用的数据库名 + */ + iot_dbms::CTsdbConnPtr ptrConn; + ptrConn.reset(new iot_dbms::CTsdbConn("127.0.0.1", -1, this->m_db_name.toStdString().c_str(), + this->m_db_name.toStdString().c_str(), + this->m_db_password.toStdString().c_str())); + + bool bPingOk = false; + for(int i = 0;i < 3;++i) + { + if (!(bPingOk = ptrConn->pingServer(1000))) + { + errorInstall(tr("influxdb连接失败...重试")); + QThread::msleep(1000); + continue; + } + else { + break; + } + } + + if(!bPingOk) + { + errorInstall(tr("influxdb连接失败")); + return false; + } + + std::string strResult; + QString strUserSQL = QString("drop user \"%1\"").arg(this->m_db_name); + if ( !ptrConn->doQuery(strUserSQL.toStdString().c_str(), &strResult )) + { + errorInstall(tr("influxdb删除用户失败")); + return false; + } + + strUserSQL = QString("create user \"%1\" with password '%2' with all privileges").arg(this->m_db_name).arg(this->m_db_password); + if ( !ptrConn->doQuery(strUserSQL.toStdString().c_str(), &strResult )) + { + errorInstall(tr("influxdb创建用户失败")); + return false; + } + + ptrConn.reset(); + + if (!iot_dbms::releaseTsdbApi()) + { + errorInstall(tr("influxdb环境退出失败")); + } + +#ifdef OS_LINUX + //创建完用户后,启用权限认证 + if(!relpaceInfluxDBConfig("influxdb.conf")) + { + return false; + } +#endif + + return true; } bool SetupWidget::installRdService() @@ -469,7 +568,6 @@ bool SetupWidget::installRdService() errorInstall(tr("安装MySQL过程中不能切换工作目录")); return false; } - #endif #ifdef OS_LINUX @@ -513,6 +611,7 @@ bool SetupWidget::installWeb() statusInstall(tr("开始安装jdk")); if(isJdkExist()) { + statusInstall(tr("系统中已经安装JDK1.8,跳过")); return true; } if(!installJdk()) @@ -646,7 +745,8 @@ bool SetupWidget::isJdkExist() QStringList list_=list.at(0).split(" "); //取第一行 if(list_.size() == 2) { - if(list_.at(1) == "1.8.0_171") + QString strJavaVersion = list_.at(1); + if(strJavaVersion.startsWith("1.8.")) { return true; } @@ -715,7 +815,161 @@ void SetupWidget::setDbPath(QString dbPath) this->m_db_path = dbPath; } - - #endif +bool SetupWidget::modifyDBPassword() +{ + //根据安装界面输入的用户名和密码修改相应的用户名和密码 + if(m_db_type == DB_TYPE_MYSQL) + { + return modifyMySQLPassword(); + } + else if(m_db_type == DB_TYPE_KINGBASE || m_db_type== DB_TYPE_OPENGAUSS) + { + return modifyKingbasePassword(); + } + + return true; +} + +bool SetupWidget::modifyMySQLPassword() +{ + db_opt_mysql dbOpt; + QStringList listDefaultPassword = {EMS_DEFAULT_PASSWD,"ems@byd23",m_db_password}; + + bool bConnected = false; + for(int i = 0;i < listDefaultPassword.size();i++) + { + const QString &strPassword = listDefaultPassword.at(i); + bConnected = dbOpt.openDatabase(m_db_ip,m_db_port.toInt(),"root",strPassword,""); + if(bConnected) + { + break; + } + } + + if(!bConnected) + { + errorInstall(tr("连接数据库失败")); + return false; + } + + /* + create user 'root'@'%' identified by 'ems@byd23'; + grant all privileges on *.* to 'root'@'%'; + FLUSH PRIVILEGES; + */ + QString strError = ""; + QString strSQL = QString("SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user='%1');").arg(m_db_username); + QSqlQuery query; + if(!dbOpt.executeSql(strSQL,query,strError)) + { + errorInstall(tr("查询数据库用户信息失败.原因:") + strError); + return false; + } + + int nUserExist = 0; + if(query.isActive() && query.next()) + { + nUserExist = query.value(0).toInt(); + } + + if(nUserExist == 0) + { + //0表示用户不存在,不存在则创建 + statusInstall(tr("开始创建数据库用户")); + strSQL = QString("create user '%1'@'%' identified by '%2';create user '%1'@'localhost' identified by '%2';").arg(m_db_username).arg(m_db_password); + if(!dbOpt.executeSql(strSQL,strError)) + { + errorInstall(tr("创建数据库用户失败.原因:") + strError); + return false; + } + + strSQL = QString("grant all privileges on *.* to '%1'@'%';grant all privileges on *.* to '%1'@'localhost';").arg(m_db_username); + if(!dbOpt.executeSql(strSQL,strError)) + { + errorInstall(tr("授予数据库用户权限失败.原因:") + strError); + return false; + } + } + else + { + strSQL = QString("update mysql.user set password=password('%1') where user='%2';").arg(m_db_password).arg(m_db_username); + if(!dbOpt.executeSql(strSQL,strError)) + { + errorInstall(tr("修改数据库用户密码失败.原因:") + strError); + return false; + } + } + + strSQL = QString("FLUSH PRIVILEGES;"); + if(!dbOpt.executeSql(strSQL,strError)) + { + errorInstall(tr("授予数据库用户权限失败.原因:") + strError); + return false; + } + + statusInstall(tr("修改数据库用户名密码成功")); + return true; +} + +bool SetupWidget::modifyKingbasePassword() +{ + db_opt_kingbase dbOpt; + QStringList listDefaultPassword = {EMS_DEFAULT_PASSWD,"ems@byd23",m_db_password}; + + bool bConnected = false; + for(int i = 0;i < listDefaultPassword.size();i++) + { + const QString &strPassword = listDefaultPassword.at(i); + bConnected = dbOpt.openDatabase(m_db_ip,m_db_port.toInt(),"system",strPassword,""); + if(bConnected) + { + break; + } + } + + if(!bConnected) + { + errorInstall(tr("连接数据库失败")); + return false; + } + + QString strError = ""; + QString strSQL = QString("SELECT 1 FROM pg_catalog.pg_user WHERE usename = '%1';").arg(m_db_username); + QSqlQuery query; + if(!dbOpt.executeSql(strSQL,query,strError)) + { + errorInstall(tr("查询数据库用户信息失败.原因:") + strError); + return false; + } + + int nUserExist = 0; + if(query.isActive() && query.next()) + { + nUserExist = query.value(0).toInt(); + } + + if(nUserExist == 0) + { + statusInstall(tr("开始创建数据库用户")); + strSQL = QString("CREATE ROLE \"%1\" SUPERUSER CREATEDB CREATEROLE LOGIN REPLICATION BYPASSRLS PASSWORD '%2';").arg(m_db_username).arg(m_db_password); + if(!dbOpt.executeSql(strSQL,strError)) + { + errorInstall(tr("创建数据库用户失败.原因:") + strError); + return false; + } + } + else + { + strSQL = QString("ALTER USER \"%1\" WITH PASSWORD '%2';").arg(m_db_username).arg(m_db_password); + if(!dbOpt.executeSql(strSQL,strError)) + { + errorInstall(tr("修改数据库用户密码失败.原因:") + strError); + return false; + } + } + + statusInstall(tr("修改数据库用户名密码成功")); + return true; +} diff --git a/product/src/tools/setup_install_helper/SetupWidget.h b/product/src/tools/setup_install_helper/SetupWidget.h index 73fca928..2bb14968 100644 --- a/product/src/tools/setup_install_helper/SetupWidget.h +++ b/product/src/tools/setup_install_helper/SetupWidget.h @@ -93,6 +93,13 @@ private: int system_hidden(const char *cmdArgs); #endif +#ifdef OS_LINUX + bool relpaceInfluxDBConfig(const QString &cfgFile); +#endif + + bool modifyDBPassword(); + bool modifyMySQLPassword(); + bool modifyKingbasePassword(); }; #endif // SETUPWIDGET_H diff --git a/product/src/tools/setup_install_helper/installer_common.h b/product/src/tools/setup_install_helper/installer_common.h index d4d98e70..77488394 100644 --- a/product/src/tools/setup_install_helper/installer_common.h +++ b/product/src/tools/setup_install_helper/installer_common.h @@ -1,4 +1,4 @@ -#ifndef INSTALLER_COMMON_H +#ifndef INSTALLER_COMMON_H #define LANG_CONFIG_NAME "language.xml" @@ -15,11 +15,7 @@ #define MYSQL_REINSTALL_CMD "register-service.bat" #define MYSQL_REMOVE_CMD "uninstall.bat" #define MYSQL_ZIP_FILENAME "mysql.zip" - - -#define MYSQL_DEFAULT_PORT 3306 -#define MYSQL_DEFAULT_DATABASE_NAME "iscs6000" -#define MYSQL_DEFAULT_USERNAME "root" +#define MYSQL_INIT_USER_SQL "sql.txt" #ifdef OS_WINDOWS #define WEB_INSTALL_SCRIPT_NAME "install.bat" diff --git a/product/src/tools/setup_install_helper/main.cpp b/product/src/tools/setup_install_helper/main.cpp index 1619c3a5..1d64f571 100644 --- a/product/src/tools/setup_install_helper/main.cpp +++ b/product/src/tools/setup_install_helper/main.cpp @@ -16,8 +16,8 @@ --ip=127.0.0.1 --port=3306 --username=root ---password=kbdct ---dbname=iscs6000 +--password=ems +--dbname=xxxx --dbtype=mysql/opengauss/oracle **/ @@ -58,12 +58,12 @@ CommandLineParseResult parseCommandline(QApplication& app,SetupWidget &w) parser.addOption(project); - // --dbpath(Windows版,Linux无此项目) D:\iscs6000\database + // --dbpath(Windows版,Linux无此项目) D:\xxxx\database // --ip=127.0.0.1 // --port=3306 // --username=root - // --password=kbdct - // --dbname=iscs6000 + // --password=ems + // --dbname=xxxx #ifdef OS_WINDOWS QCommandLineOption dbpath(QStringList() << "dbpath","database path","dbpath"); parser.addOption(dbpath); diff --git a/product/src/tools/setup_install_helper/setup_install_helper.pro b/product/src/tools/setup_install_helper/setup_install_helper.pro index 4234075c..1a1d2c08 100644 --- a/product/src/tools/setup_install_helper/setup_install_helper.pro +++ b/product/src/tools/setup_install_helper/setup_install_helper.pro @@ -30,8 +30,12 @@ DEFINES += QT_DEPRECATED_WARNINGS ISCS6000_OS = $$(ISCS6000_OS) isEmpty(ISCS6000_OS) { - error("Error, ISCS6000_OS is empty!") + ISCS6000_OS = $$(RQEH6000_OS) + isEmpty(ISCS6000_OS) { + error("Error, ISCS6000_OS is empty!") + } } + DEFINES += ISCS6000_OS=\\\"$$(ISCS6000_OS)\\\" SOURCES += \ @@ -44,7 +48,7 @@ HEADERS += \ TRANSLATIONS = $$PWD/en.ts -LIBS += -lpub_utility_api -ldb_manager_api -lyaml-cpp +LIBS += -lpub_utility_api -ldb_manager_api -ltsdb_api win32-msvc* { LIBS += -ladvapi32 diff --git a/product/src/tools/tools.pro b/product/src/tools/tools.pro index f50c4a48..ccd20bb9 100644 --- a/product/src/tools/tools.pro +++ b/product/src/tools/tools.pro @@ -6,18 +6,24 @@ SUBDIRS += \ # kbd61850dbinterface \ #提至一级目录src.pro编译 # calc_lua_api \ #提至一级目录src.pro编译 model_plugin \ - debug_tool \ + #debug_tool \ + debug_tool_v2 \ his_event_del \ fbd_designer \ WaveAnalyze \ camera_statistics\ setup_install_helper \ file_sync_tool \ - svn_file_sync_tool \ - opc_tool \ +# svn_file_sync_tool \ + #opc_tool \ upgrade_install_helper \ ReportEdit \ DevGroupLockWidget \ NetMonite \ - upgrade - + upgrade \ + db_installer \ + net_msg_tool \ + workBench \ + style_tool \ + link_seq_tool\ + mqtt_tool