|
|
|
|
|
#include "lpReport.h"
|
|
|
|
|
|
#include "qtimedlg.h"
|
|
|
|
|
|
#include <QSqlQuery>
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
|
#include "QProgressDialog"
|
|
|
|
|
|
#include "qsavecsvthread.h"
|
|
|
|
|
|
#include "checkthread.h"
|
|
|
|
|
|
#include "QCompleter"
|
|
|
|
|
|
#include "qreportwidget.h"
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
#include "ModelDB.h"
|
|
|
|
|
|
|
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
#define _QSQLITE_WHEELHUBWF_NAME "wheelhubwf.db"
|
|
|
|
|
|
#define WHEEL_DB_FILE "\\pattern\\modelTemplate.db"
|
|
|
|
|
|
|
|
|
|
|
|
lpReport::lpReport(QWidget *parent)
|
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
//加载语言设置
|
|
|
|
|
|
QSettings languageSetting("hubdetect.ini", QSettings::IniFormat);
|
|
|
|
|
|
QString strLanguage = languageSetting.value("language", "Chinese").toString();
|
|
|
|
|
|
SetLanguage(strLanguage);
|
|
|
|
|
|
|
|
|
|
|
|
qRegisterMetaType<QSqlQuery>("QSqlQuery");
|
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
//历史数据初始化
|
|
|
|
|
|
QString strDbPath = QApplication::applicationDirPath() + "\\" + _QSQLITE_WHEELHUBWF_NAME;
|
|
|
|
|
|
m_pDb = new DetectDataDB(strDbPath);
|
|
|
|
|
|
m_pDb->InitDatabase();
|
|
|
|
|
|
m_pDb->ReadOutTimeData(m_Totaltime);
|
|
|
|
|
|
//模板型号列表数据库初始化 获取所有的型号列表
|
|
|
|
|
|
QString strModelPath = QApplication::applicationDirPath() + "\\" + WHEEL_DB_FILE;
|
|
|
|
|
|
m_pModeDB = new ModelDB(strModelPath);
|
|
|
|
|
|
m_pModeDB->InitDatabase();
|
|
|
|
|
|
m_strListModelName = m_pModeDB->ReadAllModes();
|
|
|
|
|
|
|
|
|
|
|
|
setWindowTitle(tr("数据记录查看"));
|
|
|
|
|
|
setWindowIcon(QIcon(":/lpReport/Resources/Log.png"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int nItenCount = ui.check_listWidget->count();
|
|
|
|
|
|
for (int nIndex = 0; nIndex < nItenCount; nIndex++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QListWidgetItem *itenn = ui.check_listWidget->item(nIndex);
|
|
|
|
|
|
QSize s = itenn->sizeHint();
|
|
|
|
|
|
itenn->setSizeHint(QSize(s.width(), 45));
|
|
|
|
|
|
}
|
|
|
|
|
|
connect(ui.check_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(onSetCurrentIndex(int)));
|
|
|
|
|
|
connect(this, SIGNAL(sgSetCurrentIndex(int)), ui.stackedWidget, SLOT(setCurrentIndex(int)));
|
|
|
|
|
|
m_pModeCheckUI = new ModeCheckDlg();
|
|
|
|
|
|
m_pModeCountUI = new ModeCountDlg();
|
|
|
|
|
|
m_pValueUI = new ValueCheckDlg();
|
|
|
|
|
|
ui.stackedWidget->insertWidget(0, m_pModeCheckUI);
|
|
|
|
|
|
ui.stackedWidget->insertWidget(1, m_pModeCountUI);
|
|
|
|
|
|
ui.stackedWidget->insertWidget(2, m_pValueUI);
|
|
|
|
|
|
|
|
|
|
|
|
if (m_pModeCheckUI)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pModeCheckUI->setDBPtr(m_pDb);
|
|
|
|
|
|
m_pModeCheckUI->initParam(m_Totaltime, m_strListModelName);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pModeCountUI)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pModeCountUI->setDBPtr(m_pDb);
|
|
|
|
|
|
m_pModeCountUI->initParam(m_Totaltime, m_strListModelName);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pValueUI)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pValueUI->setDBPtr(m_pDb);
|
|
|
|
|
|
m_pValueUI->initParam(m_Totaltime, m_strListModelName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lpReport::~lpReport()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pModeCheckUI)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_pModeCheckUI;
|
|
|
|
|
|
m_pModeCheckUI = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pModeCountUI)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_pModeCountUI;
|
|
|
|
|
|
m_pModeCountUI = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pValueUI)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_pValueUI;
|
|
|
|
|
|
m_pValueUI = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pModeDB)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_pModeDB;
|
|
|
|
|
|
m_pModeDB = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pDb)
|
|
|
|
|
|
{
|
|
|
|
|
|
delete m_pDb;
|
|
|
|
|
|
m_pDb = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lpReport::timerEvent(QTimerEvent *event)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpReport::onSetCurrentIndex(int nIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui.label_Title->setText(ui.check_listWidget->item(nIndex)->data(0).toString());
|
|
|
|
|
|
emit(sgSetCurrentIndex(nIndex));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lpReport::SetLanguage(QString strLanguage)
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strDirPath = QString(QCoreApplication::applicationDirPath() + "/language/");
|
|
|
|
|
|
QString translatorFileName = strLanguage;
|
|
|
|
|
|
if (!translatorFileName.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_VecTranPtr.size() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
while (m_VecTranPtr.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
QTranslator *pVa = m_VecTranPtr.takeFirst();
|
|
|
|
|
|
qApp->removeTranslator(pVa);
|
|
|
|
|
|
delete pVa;
|
|
|
|
|
|
pVa = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//if (strLangage == "Chinese")
|
|
|
|
|
|
// return;
|
|
|
|
|
|
QLocale::setDefault(QLocale(translatorFileName));
|
|
|
|
|
|
|
|
|
|
|
|
QString transDir = strDirPath + translatorFileName;
|
|
|
|
|
|
SearchQmFile(transDir);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lpReport::SearchQmFile(const QString & strDir)
|
|
|
|
|
|
{
|
|
|
|
|
|
QDir dir(strDir);
|
|
|
|
|
|
if (!dir.exists())
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
|
|
dir.setSorting(QDir::DirsFirst); // 文件夹优先
|
|
|
|
|
|
// 转换成一个List
|
|
|
|
|
|
QFileInfoList list = dir.entryInfoList();
|
|
|
|
|
|
if (list.size() < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
QFileInfo fileInfo = list.at(i);
|
|
|
|
|
|
QString tt = fileInfo.fileName();
|
|
|
|
|
|
// 如果是文件夹
|
|
|
|
|
|
bool bisDir = fileInfo.isDir();
|
|
|
|
|
|
if (bisDir)
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchQmFile(fileInfo.filePath());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
bool bQm = fileInfo.fileName().endsWith(".qm");
|
|
|
|
|
|
SetTranslator(fileInfo.filePath());
|
|
|
|
|
|
}
|
|
|
|
|
|
i++;
|
|
|
|
|
|
} while (i < list.size());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lpReport::SetTranslator(const QString strPath)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (strPath.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
QTranslator *pTrans = new QTranslator;
|
|
|
|
|
|
if (pTrans->load(strPath)) // 如果加载成功
|
|
|
|
|
|
{
|
|
|
|
|
|
qApp->installTranslator(pTrans);
|
|
|
|
|
|
m_VecTranPtr.append(pTrans);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
delete pTrans;
|
|
|
|
|
|
pTrans = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|