修复了因为字段名称错误,导致查询失败

LAMPCAE-dev
chenzenghui 2025-06-27 01:34:48 +08:00
parent f7d36e4309
commit 99cf0b548e
8 changed files with 253 additions and 122 deletions

View File

@ -101,8 +101,10 @@ QString csvpath=QFileDialog::getSaveFileName(nullptr,u8"导出为csv",
return this->saveCSVFilePath(this->csvPath);
}
void QueryDataTableModel::ClearTableSet() {
this->clear();
}
void QueryDataTableModel::saveCSVFilePath(QString csvpath)

View File

@ -47,6 +47,7 @@ public:
void saveFilePath();
void ClearTableSet();
public:

View File

@ -16,8 +16,8 @@ namespace RCSDBManagerTool {
RCSDBManagerClass *RCSDBManagerClass::_ins = nullptr;
RCSDBManagerClass::RCSDBManagerClass(const std::string &dbPath) : _db(nullptr), _dbPath(dbPath) {
qDebug() << u8"database file " << QString::fromStdString(dbPath);
this->initializeDatabase(dbPath);
qDebug() << u8"Create database file " << QString::fromStdString(dbPath);
this->initialize();
}
@ -201,7 +201,7 @@ namespace RCSDBManagerTool {
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
if (strcmp(colName, "projectID") == 0) record.projectID = atoi(colValue);
if (strcmp(colName, "ProjectID") == 0) record.projectID = atoi(colValue);
else if (strcmp(colName, "fileType") == 0) record.fileType = colValue;
else if (strcmp(colName, "fileFormat") == 0) record.fileFormat = colValue;
else if (strcmp(colName, "source") == 0) record.source = colValue;
@ -211,21 +211,21 @@ namespace RCSDBManagerTool {
else if (strcmp(colName, "phiStr") == 0) record.phiStr = colValue;
else if (strcmp(colName, "frequencyStr") == 0) record.frequencyStr = colValue;
else if (strcmp(colName, "radius") == 0) record.radius = atof(colValue);
else if (strcmp(colName, "theta") == 0) record.theta = atof(colValue);
else if (strcmp(colName, "phi") == 0) record.phi = atof(colValue);
else if (strcmp(colName, "inc") == 0) record.theta = atof(colValue);
else if (strcmp(colName, "az") == 0) record.phi = atof(colValue);
else if (strcmp(colName, "reEr") == 0) record.reEr = atof(colValue);
else if (strcmp(colName, "imEr") == 0) record.imEr = atof(colValue);
else if (strcmp(colName, "reEtheta") == 0) record.reEtheta = atof(colValue);
else if (strcmp(colName, "imEtheta") == 0) record.imEtheta = atof(colValue);
else if (strcmp(colName, "reEphi") == 0) record.reEphi = atof(colValue);
else if (strcmp(colName, "imEphi") == 0) record.imEphi = atof(colValue);
else if (strcmp(colName, "RCS_Theta") == 0) record.RCS_Theta = atof(colValue);
else if (strcmp(colName, "RCS_Phi") == 0) record.RCS_Phi = atof(colValue);
else if (strcmp(colName, "E_V_real") == 0) record.reEtheta = atof(colValue);
else if (strcmp(colName, "E_V_imag") == 0) record.imEtheta = atof(colValue);
else if (strcmp(colName, "E_H_real") == 0) record.reEphi = atof(colValue);
else if (strcmp(colName, "E_H_imag") == 0) record.imEphi = atof(colValue);
else if (strcmp(colName, "RCS_V") == 0) record.RCS_Theta = atof(colValue);
else if (strcmp(colName, "RCS_H") == 0) record.RCS_Phi = atof(colValue);
else if (strcmp(colName, "RCS_Tatol") == 0) record.RCS_Tatol = atof(colValue);
else if (strcmp(colName, "TransPolar") == 0) record.TransPolar = atof(colValue);
else if (strcmp(colName, "Transpolar") == 0) record.TransPolar = atof(colValue);
else if (strcmp(colName, "configurationName") == 0) record.configurationName = colValue;
else if (strcmp(colName, "requestName") == 0) record.requestName = colValue;
else if (strcmp(colName, "frequency") == 0) record.frequency = atof(colValue);
else if (strcmp(colName, "freq") == 0) record.frequency = atof(colValue);
else if (strcmp(colName, "coordinateSystem") == 0) record.coordinateSystem = colValue;
else if (strcmp(colName, "numRadiusSamples") == 0) record.numRadiusSamples = atoi(colValue);
else if (strcmp(colName, "numThetaSamples") == 0) record.numThetaSamples = atoi(colValue);
@ -245,8 +245,8 @@ namespace RCSDBManagerTool {
std::vector<ProjectDesc> result;
// SQL 查询语句基于项目ID查询 ProjectDesc 数据
const std::string sql = "SELECT projectID, projectName, projectDesc, projectFolder "
"FROM Projects WHERE projectname = ?";
const std::string sql = "SELECT ProjectID, projectname, desc, projectFolder "
"FROM RCSProjectFolderTable WHERE projectname like ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(_db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
@ -254,7 +254,7 @@ namespace RCSDBManagerTool {
return result;
}
sqlite3_bind_text(stmt, 1, pronamestr.c_str(),-1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 1, pronamestr.c_str(), -1, SQLITE_TRANSIENT);
while (sqlite3_step(stmt) == SQLITE_ROW) {
ProjectDesc record;
@ -265,12 +265,20 @@ namespace RCSDBManagerTool {
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
if (strcmp(colName, "projectID") == 0) record.projectID = atoi(colValue);
else if (strcmp(colName, "projectName") == 0) record.projectName = colValue;
else if (strcmp(colName, "projectFolder") == 0) record.projectFolder = colValue;
else if (strcmp(colName, "projectDesc") == 0) record.projectDesc = colValue;
qDebug()<<colName<<" "<<colValue;
if (strcmp(colName, "ProjectID") == 0) {
qDebug()<<"parse "<<colName<<" "<<colValue <<" "<<atoi(colValue)<<" "<<QString(colValue).toInt()<<" "<<sqlite3_column_int(stmt, i);
record.projectID = QString::fromStdString(colValue).toInt();
}
else if (strcmp(colName, "projectname") == 0){record.projectName = colValue;}
else if (strcmp(colName, "projectFolder") == 0){record.projectFolder = colValue;}
else if (strcmp(colName, "desc") == 0){ record.projectDesc = colValue; }
}
}
qDebug()<<"record.projectID"<<" "<<record.projectID;
qDebug()<<"record.projectName"<<" "<<record.projectName;
qDebug()<<"record.projectFolder"<<" "<<record.projectFolder;
qDebug()<<"record.projectDesc"<<" "<<record.projectDesc;
result.push_back(record);
}
@ -282,8 +290,8 @@ namespace RCSDBManagerTool {
std::vector<ProjectDesc> result;
// SQL 查询语句基于项目ID查询 ProjectDesc 数据
const std::string sql = "SELECT projectID, projectName, projectDesc, projectFolder "
"FROM Projects WHERE projectID = ?";
const std::string sql = "SELECT projectID, projectname, desc, projectFolder "
"FROM RCSProjectFolderTable WHERE projectID = ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(_db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
@ -302,10 +310,13 @@ namespace RCSDBManagerTool {
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
if (strcmp(colName, "projectID") == 0) record.projectID = atoi(colValue);
else if (strcmp(colName, "projectName") == 0) record.projectName = colValue;
if (strcmp(colName, "ProjectID") == 0) {
qDebug()<<"parse "<<colName<<" "<<colValue <<" "<<atoi(colValue)<<" "<<QString(colValue).toInt()<<" "<<sqlite3_column_int(stmt, i);
record.projectID = QString::fromStdString(colValue).toInt();
}
else if (strcmp(colName, "projectname") == 0) record.projectName = colValue;
else if (strcmp(colName, "projectFolder") == 0) record.projectFolder = colValue;
else if (strcmp(colName, "projectDesc") == 0) record.projectDesc = colValue;
else if (strcmp(colName, "desc") == 0) record.projectDesc = colValue;
}
}
result.push_back(record);
@ -315,48 +326,124 @@ namespace RCSDBManagerTool {
return result;
}
std::vector<ProjectDesc> RCSDBManagerClass::getAllProjectRecords() {
std::vector<ProjectDesc> result;
std::vector<RCSRecord> RCSDBManagerClass::queryRCSDataRecordsByProjectID(int projectID) {
std::vector<RCSRecord> results(0);
const std::string sql = "SELECT projectID, projectName, projectDesc, projectFolder FROM Projects";
std::string sql = "SELECT * FROM RCSDataTable WHERE 1=1";
if (projectID != -1) sql += " AND ProjectID = ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(_db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
qDebug() << u8"准备SQL语句失败: " << sqlite3_errmsg(_db);
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(_db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
qDebug() << u8"准备SQL语句失败: " << sqlite3_errmsg(_db);
return results;
}
int paramIndex = 1;
if (projectID != -1) sqlite3_bind_int(stmt, paramIndex++, projectID);
while (sqlite3_step(stmt) == SQLITE_ROW) {
RCSRecord record;
int colCount = sqlite3_column_count(stmt);
for (int i = 0; i < colCount; i++) {
const char *colName = sqlite3_column_name(stmt, i);
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
// qDebug()<<colName<<" "<<colValue;
if (strcmp(colName, "ProjectID") == 0) record.projectID = atoi(colValue);
else if (strcmp(colName, "fileType") == 0) record.fileType = colValue;
else if (strcmp(colName, "fileFormat") == 0) record.fileFormat = colValue;
else if (strcmp(colName, "source") == 0) record.source = colValue;
else if (strcmp(colName, "date") == 0) record.date = colValue;
else if (strcmp(colName, "radiusStr") == 0) record.radiusStr = colValue;
else if (strcmp(colName, "thetaStr") == 0) record.thetaStr = colValue;
else if (strcmp(colName, "phiStr") == 0) record.phiStr = colValue;
else if (strcmp(colName, "frequencyStr") == 0) record.frequencyStr = colValue;
else if (strcmp(colName, "radius") == 0) record.radius = atof(colValue);
else if (strcmp(colName, "inc") == 0) record.theta = atof(colValue);
else if (strcmp(colName, "az") == 0) record.phi = atof(colValue);
else if (strcmp(colName, "reEr") == 0) record.reEr = atof(colValue);
else if (strcmp(colName, "imEr") == 0) record.imEr = atof(colValue);
else if (strcmp(colName, "E_V_real") == 0) record.reEtheta = atof(colValue);
else if (strcmp(colName, "E_V_imag") == 0) record.imEtheta = atof(colValue);
else if (strcmp(colName, "E_H_real") == 0) record.reEphi = atof(colValue);
else if (strcmp(colName, "E_H_imag") == 0) record.imEphi = atof(colValue);
else if (strcmp(colName, "RCS_V") == 0) record.RCS_Theta = atof(colValue);
else if (strcmp(colName, "RCS_H") == 0) record.RCS_Phi = atof(colValue);
else if (strcmp(colName, "RCS_Tatol") == 0) record.RCS_Tatol = atof(colValue);
else if (strcmp(colName, "Transpolar") == 0) record.TransPolar = atof(colValue);
else if (strcmp(colName, "configurationName") == 0) record.configurationName = colValue;
else if (strcmp(colName, "requestName") == 0) record.requestName = colValue;
else if (strcmp(colName, "freq") == 0) record.frequency = atof(colValue);
else if (strcmp(colName, "coordinateSystem") == 0) record.coordinateSystem = colValue;
else if (strcmp(colName, "numRadiusSamples") == 0) record.numRadiusSamples = atoi(colValue);
else if (strcmp(colName, "numThetaSamples") == 0) record.numThetaSamples = atoi(colValue);
else if (strcmp(colName, "numPhiSamples") == 0) record.numPhiSamples = atoi(colValue);
else if (strcmp(colName, "resultType") == 0) record.resultType = colValue;
else if (strcmp(colName, "numHeaderLines") == 0) record.numHeaderLines = atoi(colValue);
}
}
results.push_back(record);
}
sqlite3_finalize(stmt);
return results;
}
std::vector<ProjectDesc> RCSDBManagerClass::getAllProjectRecords() {
qDebug()<<u8"全局查询 RCSProjectFolderTable";
std::vector<ProjectDesc> result;
const std::string sql = "SELECT projectID, projectname, desc, projectFolder FROM RCSProjectFolderTable";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(_db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
qDebug() << u8"准备SQL语句失败: " << sqlite3_errmsg(_db);
return result;
}
while (sqlite3_step(stmt) == SQLITE_ROW) {
ProjectDesc record;
int colCount = sqlite3_column_count(stmt);
for (int i = 0; i < colCount; i++) {
const char *colName = sqlite3_column_name(stmt, i);
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
qDebug()<<colName<<" "<<colValue;
if (strcmp(colName, "ProjectID") == 0) {
record.projectID = QString::fromStdString(colValue).toInt();
qDebug()<<"parse "<<colName<<" "<<colValue <<" "<<atoi(colValue)<<" "<<QString(colValue).toInt()<<" "<<sqlite3_column_int(stmt, i);
}
else if (strcmp(colName, "projectname") == 0) { record.projectName = colValue; }
else if ( strcmp(colName, "projectFolder") == 0) { record.projectFolder = colValue; }
else if (strcmp(colName, "desc") == 0) { record.projectDesc = colValue; }
}
}
// 打印查询结果
qDebug()<<"record.projectID"<<" "<<record.projectID;
qDebug()<<"record.projectName"<<" "<<record.projectName;
qDebug()<<"record.projectFolder"<<" "<<record.projectFolder;
qDebug()<<"record.projectDesc"<<" "<<record.projectDesc;
result.push_back(record);
}
sqlite3_finalize(stmt);
return result;
}
while (sqlite3_step(stmt) == SQLITE_ROW) {
ProjectDesc record;
int colCount = sqlite3_column_count(stmt);
for (int i = 0; i < colCount; i++) {
const char *colName = sqlite3_column_name(stmt, i);
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
if (strcmp(colName, "projectID") == 0) record.projectID = atoi(colValue);
else if (strcmp(colName, "projectName") == 0) record.projectName = colValue;
else if (strcmp(colName, "projectFolder") == 0) record.projectFolder = colValue;
else if (strcmp(colName, "projectDesc") == 0) record.projectDesc = colValue;
}
}
result.push_back(record);
bool RCSDBManagerClass::executeSQL(const std::string &sql) {
return false;
}
sqlite3_finalize(stmt);
return result;
}
bool RCSDBManagerClass::executeSQL(const std::string &sql) {
bool RCSDBManagerClass::executeSQLWithParams(const std::string &sql,
const std::vector<std::pair<int, std::string> > &params) {
return false;
}
bool RCSDBManagerClass::executeSQLWithParams(const std::string &sql,
const std::vector<std::pair<int, std::string> > &params) {
return false;
}
void RCSDBManagerClass::closeDatabase() {
@ -367,7 +454,8 @@ bool RCSDBManagerClass::executeSQLWithParams(const std::string &sql,
}
bool RCSDBManagerClass::initializeDatabase(const std::string &dbFilePath) {
// 检查数据库文件是否存在
FILE *file = fopen(dbFilePath.c_str(), "r");
bool dbExists = (file != nullptr);
if (file) fclose(file);
@ -441,8 +529,10 @@ bool RCSDBManagerClass::executeSQLWithParams(const std::string &sql,
if (_ins == nullptr) {
// 这里需要替换为获取数据库路径的实际方法
const char *datastr = Setting::BusAPI::instance()->getRcsdbFilePath().toUtf8().constData();
qDebug() << u8"数据库地址:" << QString::fromStdString(datastr);
std::string sqldbpath(datastr);
std::string sqldbpath=datastr;
qDebug() << u8"数据库地址 instance " << QString::fromStdString(datastr);
qDebug() << u8"数据库地址 instance stdstring" << QString::fromStdString(sqldbpath);
_ins = new RCSDBManagerClass(sqldbpath);
}
return _ins;
@ -509,7 +599,7 @@ bool RCSDBManagerClass::executeSQLWithParams(const std::string &sql,
const char *colValue = reinterpret_cast<const char *>(sqlite3_column_text(stmt, i));
if (colName && colValue) {
if (strcmp(colName, "projectID") == 0) record.projectID = atoi(colValue);
if (strcmp(colName, "ProjectID") == 0) record.projectID = atoi(colValue);
else if (strcmp(colName, "fileType") == 0) record.fileType = colValue;
else if (strcmp(colName, "fileFormat") == 0) record.fileFormat = colValue;
else if (strcmp(colName, "source") == 0) record.source = colValue;
@ -519,21 +609,21 @@ bool RCSDBManagerClass::executeSQLWithParams(const std::string &sql,
else if (strcmp(colName, "phiStr") == 0) record.phiStr = colValue;
else if (strcmp(colName, "frequencyStr") == 0) record.frequencyStr = colValue;
else if (strcmp(colName, "radius") == 0) record.radius = atof(colValue);
else if (strcmp(colName, "theta") == 0) record.theta = atof(colValue);
else if (strcmp(colName, "phi") == 0) record.phi = atof(colValue);
else if (strcmp(colName, "inc") == 0) record.theta = atof(colValue);
else if (strcmp(colName, "az") == 0) record.phi = atof(colValue);
else if (strcmp(colName, "reEr") == 0) record.reEr = atof(colValue);
else if (strcmp(colName, "imEr") == 0) record.imEr = atof(colValue);
else if (strcmp(colName, "reEtheta") == 0) record.reEtheta = atof(colValue);
else if (strcmp(colName, "imEtheta") == 0) record.imEtheta = atof(colValue);
else if (strcmp(colName, "reEphi") == 0) record.reEphi = atof(colValue);
else if (strcmp(colName, "imEphi") == 0) record.imEphi = atof(colValue);
else if (strcmp(colName, "RCS_Theta") == 0) record.RCS_Theta = atof(colValue);
else if (strcmp(colName, "RCS_Phi") == 0) record.RCS_Phi = atof(colValue);
else if (strcmp(colName, "E_V_real") == 0) record.reEtheta = atof(colValue);
else if (strcmp(colName, "E_V_imag") == 0) record.imEtheta = atof(colValue);
else if (strcmp(colName, "E_H_real") == 0) record.reEphi = atof(colValue);
else if (strcmp(colName, "E_H_imag") == 0) record.imEphi = atof(colValue);
else if (strcmp(colName, "RCS_V") == 0) record.RCS_Theta = atof(colValue);
else if (strcmp(colName, "RCS_H") == 0) record.RCS_Phi = atof(colValue);
else if (strcmp(colName, "RCS_Tatol") == 0) record.RCS_Tatol = atof(colValue);
else if (strcmp(colName, "TransPolar") == 0) record.TransPolar = atof(colValue);
else if (strcmp(colName, "Transpolar") == 0) record.TransPolar = atof(colValue);
else if (strcmp(colName, "configurationName") == 0) record.configurationName = colValue;
else if (strcmp(colName, "requestName") == 0) record.requestName = colValue;
else if (strcmp(colName, "frequency") == 0) record.frequency = atof(colValue);
else if (strcmp(colName, "freq") == 0) record.frequency = atof(colValue);
else if (strcmp(colName, "coordinateSystem") == 0) record.coordinateSystem = colValue;
else if (strcmp(colName, "numRadiusSamples") == 0) record.numRadiusSamples = atoi(colValue);
else if (strcmp(colName, "numThetaSamples") == 0) record.numThetaSamples = atoi(colValue);

View File

@ -95,6 +95,9 @@ namespace RCSDBManagerTool {
std::vector<ProjectDesc> queryPRrojectDescByProjectName(std::string pronamestr);
std::vector<ProjectDesc> queryPRrojectDescByProjectID(int projectID);
std::vector<RCSRecord> queryRCSDataRecordsByProjectID(int projectID);
std::vector<ProjectDesc> getAllProjectRecords();
void closeDatabase();

View File

@ -5,7 +5,7 @@
#include <QMenuBar>
#include <QMenu>
#include "RCSImportDialog.h"
#include "RCSDBQueryDialog.h"
GUI::MainWindow* RCSDBManagerTool::RCSDBManagerPlugin::_mainwindow = nullptr;
@ -42,7 +42,8 @@ void RCSDBManagerTool::RCSDBManagerPlugin::onShowRCSDBTableSlot() {
}
void RCSDBManagerTool::RCSDBManagerPlugin::onQueryRCSDBTableSlot() {
RCSDBQueryDialog* dialog=new RCSDBQueryDialog(_mainwindow);
dialog->show();
}
namespace RCSDBManagerTool{

View File

@ -14,19 +14,7 @@
namespace RCSDBManagerTool {
RCSDBQueryDialog::RCSDBQueryDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RCSDBQueryDialog),
tableModel(new QStandardItemModel(this)) {
RCSDBQueryDialog::RCSDBQueryDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RCSDBQueryDialog) {
ui->setupUi(this);
this->init();
}
@ -36,29 +24,86 @@ namespace RCSDBManagerTool {
}
void RCSDBQueryDialog::init() {
this->projDescTable=new QueryDataTableModel(this);
this->RCSDBTable=new QueryDataTableModel(this);
QObject::connect(ui->pushButtonQuery, SIGNAL(clicked()), this, SLOT(OnQueryData()));
QObject::connect(ui->pushButtonExportCSV, SIGNAL(clicked()), this, SLOT(OnExportCSV()));
QObject::connect(ui->comboBoxQueryField, SIGNAL(currentIndexChanged(int)), this, SLOT(onFieldChanged(int)));
RCSDBManagerClass *db = RCSDBManagerClass::instance();
this->ui->comboBoxQueryField->setCurrentIndex(1);
}
void RCSDBQueryDialog::OnExportCSV() {
}
void RCSDBQueryDialog::OnQueryData() {
if (this->ui->comboBoxQueryField->currentIndex()==0) { // ProjectID
this->onQueryProjectID();
}else if (this->ui->comboBoxQueryField->currentIndex()==1) { // ProjectName
this->onQueryProjectName();
}else{}
}
void RCSDBQueryDialog::onQueryProjectID() {
int32_t id=this->ui->comboBoxQueryValue->currentText().toInt();
// 查询
RCSDBManagerClass *db = RCSDBManagerClass::instance();
std::vector<ProjectDesc> project_descs=db->queryPRrojectDescByProjectID(id);
std::vector<RCSRecord> RCSRecord=db->queryRCSDataRecordsByProjectID(id);
this->projDescTable->clear();
this->RCSDBTable->clear();
this->projDescTable->loadProjectDescDataSet(project_descs);
this->RCSDBTable->loadRCSRecordDataSet(RCSRecord);
this->ui->tableViewProjectRecord->setModel(this->projDescTable);
this->ui->SqltabletableView->setModel(this->RCSDBTable);
}
void RCSDBQueryDialog::onQueryProjectName() {
QString Projectname=this->ui->comboBoxQueryValue->currentText();
RCSDBManagerClass *db = RCSDBManagerClass::instance();
std::vector<ProjectDesc> project_descs=db->queryPRrojectDescByProjectName(Projectname.toUtf8().constData());
std::vector<RCSRecord> RCSRecords(0);
for (int32_t i=0;i<project_descs.size();i++) {
qDebug()<<"ProjectID:"<<project_descs[i].projectID<<"ProjectName:"<<project_descs[i].projectName;
std::vector<RCSRecord> RCSRecordTemp=db->queryRCSDataRecordsByProjectID(project_descs[i].projectID);
for (int32_t j=0;j<RCSRecordTemp.size();j++) {
RCSRecords.push_back(RCSRecordTemp[j]);
}
}
this->projDescTable->clear();
this->RCSDBTable->clear();
this->projDescTable->loadProjectDescDataSet(project_descs);
this->RCSDBTable->loadRCSRecordDataSet(RCSRecords);
this->ui->tableViewProjectRecord->setModel(this->projDescTable);
this->ui->SqltabletableView->setModel(this->RCSDBTable);
}
void RCSDBQueryDialog::onFieldChanged(int indx) {
if (this->ui->comboBoxQueryField->currentIndex()==0) {
RCSDBManagerClass *db = RCSDBManagerClass::instance();
std::vector<ProjectDesc> projectlist=db->getAllProjectRecords();
this->ui->comboBoxQueryValue->clear();
for (int32_t i=0;i<projectlist.size();i++) {
this->ui->comboBoxQueryValue->addItem(QString::number(projectlist[i].projectID));
}
}else if (ui->comboBoxQueryField->currentIndex()==1) {
RCSDBManagerClass *db = RCSDBManagerClass::instance();
std::vector<ProjectDesc> projectlist=db->getAllProjectRecords();
this->ui->comboBoxQueryValue->clear();
for (int32_t i=0;i<projectlist.size();i++) {
this->ui->comboBoxQueryValue->addItem(projectlist[i].projectName);
}
}else{}
}
} // RCSDBManagerTool

View File

@ -15,6 +15,8 @@
#include <QStringList>
#include <QVector>
#include "RCSDBManagerClass.h"
#include "QueryDataTableModel.h"
namespace RCSDBManagerTool {
QT_BEGIN_NAMESPACE
@ -25,22 +27,6 @@ namespace RCSDBManagerTool {
QT_END_NAMESPACE
class PLUGINRCSDBMANAGERAPI RCSDBQueryDialog : public QDialog {
Q_OBJECT
@ -54,10 +40,13 @@ namespace RCSDBManagerTool {
void OnExportCSV();
void OnQueryData();
void onQueryProjectID();
void onQueryProjectName();
void onFieldChanged(int indx);
private:
Ui::RCSDBQueryDialog *ui;
QStandardItemModel* tableModel;
QueryDataTableModel* projDescTable;
QueryDataTableModel* RCSDBTable;

View File

@ -113,10 +113,10 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -130,7 +130,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QTableWidget" name="tableWidgetProjectRecord"/>
<widget class="QTableView" name="tableViewProjectRecord"/>
</item>
</layout>
</widget>
@ -149,7 +149,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTableWidget" name="SqltableWidget"/>
<widget class="QTableView" name="SqltabletableView"/>
</item>
</layout>
</widget>