204 lines
6.1 KiB
C++
204 lines
6.1 KiB
C++
#ifndef KBDPSC3000DLG_H
|
|
#define KBDPSC3000DLG_H
|
|
|
|
#include <QWizard>
|
|
#include <QStyledItemDelegate>
|
|
#include <QListWidget>
|
|
#include <QStandardItemModel>
|
|
#include "xlsxdocument.h"
|
|
class QListWidget;
|
|
class QTableView;
|
|
class QListWidgetItem;
|
|
class MyDistributeListWidget;
|
|
class MyPSC3000DevModel;
|
|
class MyPluginModel;
|
|
class QCheckBox;
|
|
class KbdTable;
|
|
|
|
class KbdPsc3000Dlg : public QWizard
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit KbdPsc3000Dlg(const QString & rtuTag, QWidget *parent = nullptr);
|
|
enum DataRole
|
|
{
|
|
PLUGIN_TAG_ROLE = Qt::UserRole,
|
|
DEV_START_ROLE = Qt::UserRole + 1
|
|
};
|
|
|
|
QString openPsc3000File(const QString &csvFile);
|
|
QString openPsc3000XlsxFile(const QString &xlsxFile);
|
|
void accept() override;
|
|
void reject() override;
|
|
bool validateCurrentPage();
|
|
private:
|
|
//用于规则1的结构体
|
|
struct S_TEMP_TO_DEVID
|
|
{
|
|
QString matchFesDevTemp;
|
|
int matchIndex;
|
|
QString matchFesDevId;
|
|
QString matchFesDevDesc;
|
|
bool operator ==(const S_TEMP_TO_DEVID &r){
|
|
if(this->matchFesDevTemp == r.matchFesDevTemp)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
};
|
|
struct S_Rule1
|
|
{
|
|
QString prefix;
|
|
QList<S_TEMP_TO_DEVID> tempToDevId;
|
|
|
|
bool operator ==(const S_Rule1 &r){
|
|
if(this->prefix == r.prefix)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
};
|
|
|
|
QWizardPage *initPsc3000Page();
|
|
QWizardPage *initRegionPage();
|
|
void initData();
|
|
|
|
QString readXlsx(const QString &xlsxPath);
|
|
QString writeXlsx(const QString &xlsxPath);
|
|
QModelIndex getMergeIndex(QTableView *view, const QModelIndex &index);//获取index单元格的合并单元格
|
|
|
|
bool check();
|
|
bool checkPage0();
|
|
bool checkPage1();
|
|
|
|
void autoPlugin();//自动生成套件
|
|
/*
|
|
* 贪婪模式版本
|
|
*/
|
|
/*
|
|
void rule1(const QString &pluginName,const QString &pluginDesc,
|
|
const QStringList &fesDevTempTags,const QStringList &fesDevTempDescs,
|
|
const QStringList &allFesDevIds,const QStringList &allFesDevDescs);
|
|
void rule2(const QString &pluginName,const QString &pluginDesc,
|
|
const QString &fesDevTempTag,const QString &fesDevTempDesc,
|
|
const QStringList &allFesDevIds,const QStringList &allFesDevDescs);
|
|
*/
|
|
|
|
//非贪婪
|
|
void rule1(const QString &pluginName,const QString &pluginDesc,
|
|
const QStringList &fesDevTempTags,const QStringList &fesDevTempDescs,
|
|
QStringList &allFesDevIds, QStringList &allFesDevDescs);
|
|
void rule2(const QString &pluginName,const QString &pluginDesc,
|
|
const QString &fesDevTempTag,const QString &fesDevTempDesc,
|
|
QStringList &allFesDevIds, QStringList &allFesDevDescs);
|
|
void removeAllPlugin();
|
|
QStringList getDevIdDisrtibuteList();
|
|
bool checkHasDisrt(QModelIndexList& visibleList);
|
|
QMap<int, QStringList> getAllPointList(QXlsx::Document& xlsx);//移除没有数据点的前置设备
|
|
void getChanTagName();
|
|
void getAllRtuInChannel(QStringList &rtuList);
|
|
bool updateDevGrpMsg(QString locationTag);
|
|
|
|
private slots:
|
|
void onAddPlugiin();
|
|
void onRemovePlugin();
|
|
|
|
void onPluginTableItemChanged(const QModelIndex &indexPos);
|
|
void onCheckBoxCheck(bool bCheck);
|
|
void onAutoPlugin();//自动生成套件
|
|
|
|
void onDropFromPsc3000Dev(const QModelIndex &indexPos);
|
|
void dropPsc3000DevToPlugin(const QModelIndex &indexPos,const QString &fesDevId,const QString &fesDevDesc);
|
|
void onClearDistributeDev();
|
|
|
|
void onDistributeToGeneral();
|
|
void onDistributeToDefine();
|
|
|
|
void onAddReg();
|
|
void onSaveReg();
|
|
|
|
void onMsg(const QString &msg);
|
|
private:
|
|
QTableView *m_tablePlugin;
|
|
MyPluginModel *m_modelPlugin;
|
|
QTableView *m_tablePsc3000Dev;
|
|
MyPSC3000DevModel *m_modelPsc3000Dev;
|
|
QCheckBox *m_checkBoxHideDistri;
|
|
QCheckBox *m_checkBoxHideImport;
|
|
KbdTable *m_tableReg;
|
|
|
|
QString m_xlsxFile;
|
|
QString m_rtuTag;
|
|
QString m_chanTag;
|
|
QMenu *m_menuPlugin;
|
|
|
|
QStringList m_hasImportDevIds;//已导入列表
|
|
|
|
};
|
|
|
|
class KbdPluginDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit KbdPluginDelegate(QObject *parent = 0);
|
|
|
|
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
|
// void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
|
|
|
signals:
|
|
void sigChangePlugin(const QModelIndex &indexPos ) const;
|
|
private:
|
|
QStringList m_pluginDescList;
|
|
QStringList m_pluginTagList;
|
|
};
|
|
|
|
|
|
class MyPSC3000DevModel:public QStandardItemModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MyPSC3000DevModel(QObject *parent = nullptr):QStandardItemModel(parent){}
|
|
|
|
QStringList mimeTypes() const;
|
|
bool canDropMimeData(const QMimeData *data,
|
|
Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
|
|
|
|
bool dropMimeData(const QMimeData *data,
|
|
Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
|
|
|
Qt::DropActions supportedDropActions() const;
|
|
|
|
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
|
|
|
signals:
|
|
void sigDropDataFromList(const QModelIndex &indexPos);
|
|
|
|
};
|
|
|
|
class MyPluginModel:public QStandardItemModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MyPluginModel(QObject *parent = nullptr):QStandardItemModel(parent){}
|
|
|
|
QStringList mimeTypes() const;
|
|
bool canDropMimeData(const QMimeData *data,
|
|
Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
|
|
|
|
bool dropMimeData(const QMimeData *data,
|
|
Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
|
|
|
Qt::DropActions supportedDropActions() const;
|
|
|
|
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
|
|
|
signals:
|
|
void sigDropDataFromPsc3000(const QModelIndex &indexPos);
|
|
|
|
};
|
|
|
|
|
|
#endif // KBDPSC3000DLG_H
|