|
@@ -6,6 +6,9 @@
|
|
|
#include "ui_MatrixPanelWidget.h"
|
|
|
|
|
|
#include <xlsxdocument.h>
|
|
|
+#include <QDebug>
|
|
|
+#include <QMessageBox>
|
|
|
+#include <QFileDialog>
|
|
|
|
|
|
MatrixPanelWidget::MatrixPanelWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MatrixPanelWidget)
|
|
|
{
|
|
@@ -60,10 +63,10 @@ MatrixPanelWidget::~MatrixPanelWidget()
|
|
|
|
|
|
void MatrixPanelWidget::init(const QStringList indexsRef, const QStringList indexs)
|
|
|
{
|
|
|
- qDebug() << "MatrixPanelWidget---init" << endl;
|
|
|
+ qDebug() << "MatrixPanelWidget---init";
|
|
|
indexsRefClassifiedNodes = nullptr;
|
|
|
if (!indexsRef.isEmpty()) {
|
|
|
- MindNodeManager *indexsRefNodes = new MindNodeManager(); //是否参考指标体系
|
|
|
+ MindNodeManager *indexsRefNodes = new MindNodeManager(); // 是否参考指标体系
|
|
|
getMindNodes(indexsRefNodes, indexsRef);
|
|
|
indexsRefClassifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
|
|
|
sortMindNodes(*indexsRefNodes, indexsRefClassifiedNodes);
|
|
@@ -107,7 +110,7 @@ void MatrixPanelWidget::initImportData(const QStringList indexsRef, const QStrin
|
|
|
// qDebug() << "MatrixPanelWidget---initImportData" << endl;
|
|
|
indexsRefClassifiedNodes = nullptr;
|
|
|
if (!indexsRef.isEmpty()) {
|
|
|
- MindNodeManager *indexsRefNodes = new MindNodeManager(); //是否参考指标体系
|
|
|
+ MindNodeManager *indexsRefNodes = new MindNodeManager(); // 是否参考指标体系
|
|
|
getMindNodes(indexsRefNodes, indexsRef);
|
|
|
indexsRefClassifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
|
|
|
sortMindNodes(*indexsRefNodes, indexsRefClassifiedNodes);
|
|
@@ -128,7 +131,7 @@ void MatrixPanelWidget::initImportData(const QStringList indexsRef, const QStrin
|
|
|
ui->currPageLabel->setText(QString("当前第0页"));
|
|
|
if (!indexsRef.isEmpty()) {
|
|
|
currentTab = "技术措施重要度评估对象";
|
|
|
- qDebug() << "MatrixPanelWidget---init" << currentTab << endl;
|
|
|
+ qDebug() << "MatrixPanelWidget---init" << currentTab;
|
|
|
initPlainTechMeasuresWidget(nodeValueInfoList);
|
|
|
setPage(1);
|
|
|
return;
|
|
@@ -174,17 +177,17 @@ void MatrixPanelWidget::getMindNodes(MindNodeManager *manager, QStringList listN
|
|
|
}
|
|
|
}
|
|
|
tempSpace /= 4;
|
|
|
- if (tempSpace == 1) { //一级
|
|
|
+ if (tempSpace == 1) { // 一级
|
|
|
spaceNum = tempSpace;
|
|
|
level = 0;
|
|
|
sn[level]++;
|
|
|
memset((void *)&sn[1], 0, sizeof(int) * 15);
|
|
|
} else {
|
|
|
- if (spaceNum < tempSpace) { //空格增加
|
|
|
+ if (spaceNum < tempSpace) { // 空格增加
|
|
|
spaceNum = tempSpace;
|
|
|
level++;
|
|
|
sn[level]++;
|
|
|
- } else if (spaceNum == tempSpace) { //同一级
|
|
|
+ } else if (spaceNum == tempSpace) { // 同一级
|
|
|
sn[level]++;
|
|
|
} else {
|
|
|
memset((void *)&sn[tempSpace], 0, sizeof(int) * (16 - tempSpace));
|
|
@@ -297,7 +300,7 @@ void MatrixPanelWidget::setPage(int page)
|
|
|
paintPlainWidget();
|
|
|
}
|
|
|
|
|
|
-//能力重要度评估指标体系初始化
|
|
|
+// 能力重要度评估指标体系初始化
|
|
|
void MatrixPanelWidget::initPlainWidget(QList<NodeMatrixInfo *> nodeValueInfoList)
|
|
|
{
|
|
|
qDeleteAll(modelList);
|
|
@@ -310,7 +313,7 @@ void MatrixPanelWidget::initPlainWidget(QList<NodeMatrixInfo *> nodeValueInfoLis
|
|
|
ui->exportBtn->setDisabled(false);
|
|
|
isAutoSave = true;
|
|
|
}
|
|
|
- //准备第一页,非tab的
|
|
|
+ // 准备第一页,非tab的
|
|
|
MatrixTableWidget *table = new MatrixTableWidget((indexsRefClassifiedNodes == nullptr), nullptr);
|
|
|
table->setCurrentPage(1);
|
|
|
table->setMsgName("总体");
|
|
@@ -338,7 +341,7 @@ void MatrixPanelWidget::initPlainWidget(QList<NodeMatrixInfo *> nodeValueInfoLis
|
|
|
qDeleteAll(nodeValueInfoList);
|
|
|
nodeValueInfoList.clear();
|
|
|
|
|
|
- //准备第二页,tab组合的
|
|
|
+ // 准备第二页,tab组合的
|
|
|
for (int p = 1; p < getPages(); ++p) {
|
|
|
QTabWidget *tab = new QTabWidget;
|
|
|
tab->setTabPosition(QTabWidget::South);
|
|
@@ -407,7 +410,7 @@ void MatrixPanelWidget::initPlainTechMeasuresWidget(QList<NodeMatrixInfo *> node
|
|
|
ui->saveBtn->setDisabled(false);
|
|
|
ui->exportBtn->setDisabled(false);
|
|
|
}
|
|
|
- //准备第一页,非tab的
|
|
|
+ // 准备第一页,非tab的
|
|
|
MatrixTableTechMeasuresWidget *table = new MatrixTableTechMeasuresWidget(nullptr);
|
|
|
connect(table, &MatrixTableTechMeasuresWidget::dataReady, this, &MatrixPanelWidget::oneTechMeasureTableDataReady);
|
|
|
connect(table, &MatrixTableTechMeasuresWidget::returnModel, this, &MatrixPanelWidget::getTableModel);
|
|
@@ -436,7 +439,7 @@ void MatrixPanelWidget::initPlainTechMeasuresWidget(QList<NodeMatrixInfo *> node
|
|
|
firstLayout->addWidget(table);
|
|
|
qDeleteAll(nodeValueInfoList);
|
|
|
nodeValueInfoList.clear();
|
|
|
- //准备第二页,tab组合的
|
|
|
+ // 准备第二页,tab组合的
|
|
|
for (int p = 1; p < getPages(); ++p) {
|
|
|
QTabWidget *tab = new QTabWidget;
|
|
|
tab->setTabPosition(QTabWidget::South);
|
|
@@ -572,7 +575,7 @@ void MatrixPanelWidget::setTableMsg(QString tableMsg)
|
|
|
{
|
|
|
m_table_msg = tableMsg;
|
|
|
}
|
|
|
-//采集完成保存
|
|
|
+// 采集完成保存
|
|
|
void MatrixPanelWidget::on_saveBtn_clicked()
|
|
|
{
|
|
|
bool saveFlag = true;
|
|
@@ -582,7 +585,7 @@ void MatrixPanelWidget::on_saveBtn_clicked()
|
|
|
if (currentPage == 1) {
|
|
|
MatrixTableTechMeasuresWidget *first =
|
|
|
qobject_cast<MatrixTableTechMeasuresWidget *>(firstLayout->itemAt(0)->widget());
|
|
|
- //保存第一页数据
|
|
|
+ // 保存第一页数据
|
|
|
for (MatrixDataSource s : first->getSource()) {
|
|
|
NodeMatrixInfo *t = new NodeMatrixInfo();
|
|
|
t->abscissa = s.abscissa;
|
|
@@ -604,8 +607,8 @@ void MatrixPanelWidget::on_saveBtn_clicked()
|
|
|
} else {
|
|
|
QTabWidget *currTab = qobject_cast<QTabWidget *>(secondLayout->itemAt(0)->widget());
|
|
|
tabIndex = currTab->currentIndex();
|
|
|
- //保存第二页数据,如果有
|
|
|
- // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
+ // 保存第二页数据,如果有
|
|
|
+ // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
for (int ta = 0; ta < tabWidgets.count(); ta++) {
|
|
|
if (ta + 2 == currentPage) {
|
|
|
for (int i = 0; i < tabWidgets[ta]->count(); ++i) {
|
|
@@ -634,10 +637,10 @@ void MatrixPanelWidget::on_saveBtn_clicked()
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- //能力重要度
|
|
|
+ // 能力重要度
|
|
|
if (currentPage == 1) {
|
|
|
MatrixTableWidget *first = qobject_cast<MatrixTableWidget *>(firstLayout->itemAt(0)->widget());
|
|
|
- //保存第一页数据
|
|
|
+ // 保存第一页数据
|
|
|
for (MatrixDataSource s : first->getSource()) {
|
|
|
NodeMatrixInfo *t = new NodeMatrixInfo();
|
|
|
t->abscissa = s.abscissa;
|
|
@@ -660,8 +663,8 @@ void MatrixPanelWidget::on_saveBtn_clicked()
|
|
|
qDebug() << "currentPage--------" << currentPage;
|
|
|
QTabWidget *currTab = qobject_cast<QTabWidget *>(secondLayout->itemAt(0)->widget());
|
|
|
tabIndex = currTab->currentIndex();
|
|
|
- //保存第二页数据,如果有
|
|
|
- // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
+ // 保存第二页数据,如果有
|
|
|
+ // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
for (int ta = 0; ta < tabWidgets.count(); ta++) {
|
|
|
if (ta + 2 == currentPage) {
|
|
|
qDebug() << "----" << tabWidgets[ta]->count();
|
|
@@ -716,7 +719,7 @@ void MatrixPanelWidget::saveNodes()
|
|
|
QList<NodeMatrixInfo *> nodeInfoList;
|
|
|
MatrixTableTechMeasuresWidget *first =
|
|
|
qobject_cast<MatrixTableTechMeasuresWidget *>(firstLayout->itemAt(0)->widget());
|
|
|
- //保存第一页数据
|
|
|
+ // 保存第一页数据
|
|
|
for (MatrixDataSource s : first->getSource()) {
|
|
|
NodeMatrixInfo *t = new NodeMatrixInfo();
|
|
|
t->abscissa = s.abscissa;
|
|
@@ -741,8 +744,8 @@ void MatrixPanelWidget::saveNodes()
|
|
|
NodeMatrixService().AddNodeMatrixInfoList2(nodeInfoList);
|
|
|
}
|
|
|
|
|
|
- //保存第二页数据,如果有
|
|
|
- // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
+ // 保存第二页数据,如果有
|
|
|
+ // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
for (int ta = 0; ta < tabWidgets.count(); ta++) {
|
|
|
|
|
|
for (int i = 0; i < tabWidgets[ta]->count(); i++) {
|
|
@@ -780,7 +783,7 @@ void MatrixPanelWidget::saveNodes()
|
|
|
} else {
|
|
|
QList<NodeMatrixInfo *> nodeInfoList;
|
|
|
MatrixTableWidget *first = qobject_cast<MatrixTableWidget *>(firstLayout->itemAt(0)->widget());
|
|
|
- //保存第一页数据
|
|
|
+ // 保存第一页数据
|
|
|
int tabIndex = 0;
|
|
|
for (MatrixDataSource s : first->getSource()) {
|
|
|
NodeMatrixInfo *t = new NodeMatrixInfo();
|
|
@@ -806,8 +809,8 @@ void MatrixPanelWidget::saveNodes()
|
|
|
NodeMatrixService().AddNodeMatrixInfoList2(nodeInfoList);
|
|
|
}
|
|
|
qDeleteAll(nodeInfoList);
|
|
|
- //保存第二页数据,如果有
|
|
|
- // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
+ // 保存第二页数据,如果有
|
|
|
+ // for (QTabWidget *tabWidget : tabWidgets) {
|
|
|
for (int ta = 0; ta < tabWidgets.count(); ta++) {
|
|
|
|
|
|
for (int i = 0; i < tabWidgets[ta]->count(); i++) {
|
|
@@ -920,14 +923,14 @@ void MatrixPanelWidget::getTableModelName(QString itemName)
|
|
|
qDebug() << "-----tabeName----" << itemName;
|
|
|
modelName.append(itemName);
|
|
|
}
|
|
|
-//导出table数据
|
|
|
+// 导出table数据
|
|
|
void MatrixPanelWidget::on_exportBtn_clicked()
|
|
|
{
|
|
|
if (!checkTableDateReady()) {
|
|
|
QMessageBox::warning(this, "警告", "请确保xlsx数据的完整性!");
|
|
|
return;
|
|
|
}
|
|
|
- //文件夹路径
|
|
|
+ // 文件夹路径
|
|
|
QFileDialog::Options options;
|
|
|
options |= QFileDialog::DontUseNativeDialog;
|
|
|
QString filePath = QFileDialog::getExistingDirectory(nullptr, "导出资源包", "/", options);
|
|
@@ -950,35 +953,35 @@ void MatrixPanelWidget::on_exportBtn_clicked()
|
|
|
file.remove();
|
|
|
}
|
|
|
QXlsx::Format format;
|
|
|
- format.setFontSize(12); //字体大小
|
|
|
+ format.setFontSize(12); // 字体大小
|
|
|
// format.setFontBold(true); //加粗
|
|
|
// format.setFontColor(QColor(73, 88, 233)); //颜色
|
|
|
// 可以用rgb,也可以用系统自带 QColor(Qt::red)
|
|
|
- format.setHorizontalAlignment(QXlsx::Format::AlignHCenter); //水平居中
|
|
|
- format.setVerticalAlignment(QXlsx::Format::AlignVCenter); //垂直居中
|
|
|
+ format.setHorizontalAlignment(QXlsx::Format::AlignHCenter); // 水平居中
|
|
|
+ format.setVerticalAlignment(QXlsx::Format::AlignVCenter); // 垂直居中
|
|
|
QXlsx::Document exprot;
|
|
|
- //判断是否需要多sheet页
|
|
|
- // QList<QString> strList;
|
|
|
- // qDebug() << "modelListSize-----------------" << modelList.size();
|
|
|
- // if (modelList.size() > 1) {
|
|
|
- // QStandardItemModel *model = modelList.at(0);
|
|
|
- // for (int c = 0; c < model->columnCount(); c++) {
|
|
|
- // QStandardItem *head = model->horizontalHeaderItem(c);
|
|
|
- // if (head != nullptr) {
|
|
|
- // strList.append(head->text() == "" ? "总体" : head->text());
|
|
|
- // qDebug() << "modelListSize-----------------" << head->text();
|
|
|
- // }
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // strList.append("总体");
|
|
|
- // }
|
|
|
+ // 判断是否需要多sheet页
|
|
|
+ // QList<QString> strList;
|
|
|
+ // qDebug() << "modelListSize-----------------" << modelList.size();
|
|
|
+ // if (modelList.size() > 1) {
|
|
|
+ // QStandardItemModel *model = modelList.at(0);
|
|
|
+ // for (int c = 0; c < model->columnCount(); c++) {
|
|
|
+ // QStandardItem *head = model->horizontalHeaderItem(c);
|
|
|
+ // if (head != nullptr) {
|
|
|
+ // strList.append(head->text() == "" ? "总体" : head->text());
|
|
|
+ // qDebug() << "modelListSize-----------------" << head->text();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // strList.append("总体");
|
|
|
+ // }
|
|
|
for (int i = 0; i < modelList.size(); i++) {
|
|
|
QStandardItemModel *model = modelList.at(i);
|
|
|
// qDebug() << strList.at(i);
|
|
|
exprot.addSheet(modelName.at(i));
|
|
|
int row = model->rowCount();
|
|
|
int col = model->columnCount();
|
|
|
- //先把表头获取到添加
|
|
|
+ // 先把表头获取到添加
|
|
|
for (int c = 1; c < col + 1; c++) {
|
|
|
QStandardItem *head = model->horizontalHeaderItem(c - 1);
|
|
|
exprot.write(1, c, head->text(), format);
|
|
@@ -991,7 +994,7 @@ void MatrixPanelWidget::on_exportBtn_clicked()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //添加专家基本信息
|
|
|
+ // 添加专家基本信息
|
|
|
exprot.addSheet("专家信息");
|
|
|
exprot.write(1, 1, "ID", format);
|
|
|
exprot.write(1, 2, "账号", format);
|
|
@@ -1015,10 +1018,10 @@ void MatrixPanelWidget::on_exportBtn_clicked()
|
|
|
saveNodes();
|
|
|
}
|
|
|
|
|
|
-//导入数据
|
|
|
+// 导入数据
|
|
|
void MatrixPanelWidget::on_importBtn_clicked()
|
|
|
{
|
|
|
- //打开文件
|
|
|
+ // 打开文件
|
|
|
QDir dir;
|
|
|
QFileDialog::Options options;
|
|
|
options |= QFileDialog::DontUseNativeDialog;
|
|
@@ -1027,14 +1030,14 @@ void MatrixPanelWidget::on_importBtn_clicked()
|
|
|
QFileDialog::getOpenFileName(this, "选择Excel文件", "", "Excel (*.xls *.xlsx)", &selectedFilter, options);
|
|
|
if (fileName.isEmpty())
|
|
|
return;
|
|
|
- //获取node节点
|
|
|
+ // 获取node节点
|
|
|
QList<NodeMatrixInfo *> nodeValueInfoList;
|
|
|
NodeMatrixService().QueryNodeMatrixListByExpertNameAndEngineerId(&nodeValueInfoList, m_professor.name,
|
|
|
m_professor.engineer.engineerId);
|
|
|
- //读取文件内容
|
|
|
+ // 读取文件内容
|
|
|
QXlsx::Document xlsxR(fileName);
|
|
|
QStringList str = xlsxR.sheetNames();
|
|
|
- //遍历sheet页
|
|
|
+ // 遍历sheet页
|
|
|
for (int i = 0; i < str.size(); i++) {
|
|
|
xlsxR.selectSheet(str.at(i));
|
|
|
if (xlsxR.load()) {
|