2022-07-30 11:50:01 +08:00

75 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Reportform.h"
#include "ui_Reportform.h"
#include <QFileDialog>
#include <QDebug>
ReportForm::ReportForm(QWidget *parent) :
BaseWgt(parent),
ui(new Ui::ReportForm)
{
ui->setupUi(m_pMainWgt);
resize(700,650);
setWindowTitle("诊断报告");
m_strReportName = "";
m_filePath = "";
connect(ui->ChoosePath_Btn, SIGNAL(clicked()), this, SLOT(ChoosePath()));
connect(ui->PDF_radioButton, SIGNAL(toggled(bool)),this,SLOT(ChoosePDF(bool)));
connect(ui->Word_radioButton, SIGNAL(toggled(bool)),this,SLOT(ChooseWord(bool)));
connect(ui->Report_Btn, SIGNAL(clicked()),this,SLOT(Report()));
ui->Result_Edit->setPlaceholderText("请输入...");
}
ReportForm::~ReportForm()
{
delete ui;
}
void ReportForm::InitReport(QString path,QStringList& strImagePathList,QString ReportName,REPORT_INFO& reportInfo)
{
_reportInfo = reportInfo;
ui->ReportPath_Edit->setText(path);
m_strReportName = ReportName;
m_filePath = path;
strImagePath = strImagePathList;
}
void ReportForm::ChoosePath()
{
QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly);
if(dirpath.isEmpty()) dirpath = QDir::currentPath();
ui->ReportPath_Edit->setText(dirpath + "/" + m_strReportName);
m_filePath = dirpath + "\\" + m_strReportName;
}
void ReportForm::ChoosePDF(bool flag)
{
if(flag){
ui->Result_Edit->setVisible(true);
ui->label_2->setText("诊断结果及建议:");
}
}
void ReportForm::ChooseWord(bool flag)
{
if(flag){
ui->Result_Edit->setVisible(false);
ui->label_2->setText("提示请在Word中输入诊断建议");
}
}
void ReportForm::Report()
{
QString strResult =ui->Result_Edit->document()->toPlainText();
qDebug() << "Report:" << strResult;
QStringList strResultList = strResult.split(QRegExp("[\n]"),QString::SkipEmptyParts);
if(ui->PDF_radioButton->isChecked())
{
emit ReportPDF(strResultList,m_filePath);
}else{
cp.GetReport(_reportInfo,strImagePath);
}
}