modified listwgt
This commit is contained in:
commit
87091abf12
@ -936,6 +936,26 @@
|
|||||||
<source>Add Table Data File</source>
|
<source>Add Table Data File</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="81"/>
|
||||||
|
<source>Basic Information</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="110"/>
|
||||||
|
<source>Table Name:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="103"/>
|
||||||
|
<source>Enter table name...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="117"/>
|
||||||
|
<source>Time Parameter:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="20"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="20"/>
|
||||||
<source>File Selection</source>
|
<source>File Selection</source>
|
||||||
@ -947,7 +967,7 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="33"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="36"/>
|
||||||
<source>Select table data file...</source>
|
<source>Select table data file...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -973,100 +993,137 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="81"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="193"/>
|
||||||
<source>Table Parameters</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="87"/>
|
|
||||||
<source>Separator:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="95"/>
|
|
||||||
<source>Comma (,)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="100"/>
|
|
||||||
<source>Tab</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="105"/>
|
|
||||||
<source>Space</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="110"/>
|
|
||||||
<source>Semicolon (;)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="118"/>
|
|
||||||
<source>Encoding:</source>
|
<source>Encoding:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="126"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="201"/>
|
||||||
<source>UTF-8</source>
|
<source>UTF-8</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="131"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="206"/>
|
||||||
<source>GBK</source>
|
<source>GBK</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="136"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="211"/>
|
||||||
<source>ASCII</source>
|
<source>ASCII</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="141"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="216"/>
|
||||||
<source>ISO-8859-1</source>
|
<source>ISO-8859-1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="149"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="176"/>
|
||||||
<source>Skip Rows:</source>
|
<source>Skip Rows:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="169"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="133"/>
|
||||||
<source>File has header row</source>
|
<source>File has header row</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="179"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="127"/>
|
||||||
|
<source>Table Headers Configuration</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="143"/>
|
||||||
|
<source>Headers (comma-separated):</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="150"/>
|
||||||
|
<source>e.g., Time, Value1, Value2, Value3...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="160"/>
|
||||||
|
<source>Tip: Headers will be auto-detected if file has header row</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="170"/>
|
||||||
|
<source>Parsing Parameters</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="183"/>
|
||||||
<source>Auto-detect parameters</source>
|
<source>Auto-detect parameters</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="192"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="240"/>
|
||||||
<source>Preview</source>
|
<source>Preview</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="223"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="296"/>
|
||||||
<source>Description (Optional)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="235"/>
|
|
||||||
<source>Enter file description...</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="273"/>
|
|
||||||
<source>Add File</source>
|
<source>Add File</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="283"/>
|
<location filename="../ui/WorkSpace/AddTableFileDlg.ui" line="306"/>
|
||||||
<source>Cancel</source>
|
<source>Cancel</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="118"/>
|
||||||
|
<source>Warning</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="118"/>
|
||||||
|
<source>Please enter a table name.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="126"/>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="151"/>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="176"/>
|
||||||
|
<source>Error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="126"/>
|
||||||
|
<source>Failed to create table file entry.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="151"/>
|
||||||
|
<source>Unable to get current workspace</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="161"/>
|
||||||
|
<source>Table file count has reached the limit</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="164"/>
|
||||||
|
<source>File already exists</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="167"/>
|
||||||
|
<source>File copy failed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="170"/>
|
||||||
|
<source>Invalid file</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/AddTableFileDlg.cpp" line="173"/>
|
||||||
|
<source>Failed to add file</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ChartPlotMenuClass</name>
|
<name>ChartPlotMenuClass</name>
|
||||||
|
|||||||
@ -48,6 +48,10 @@ void CurvePanel::RefreshPanel()
|
|||||||
// Implement curve-specific refresh logic here
|
// Implement curve-specific refresh logic here
|
||||||
DataPanel::RefreshPanel();
|
DataPanel::RefreshPanel();
|
||||||
|
|
||||||
|
if (auto fileEntry = std::dynamic_pointer_cast<FileEntryCurve>(fileEntry_)) {
|
||||||
|
OnDataPanelUpdated(fileEntry.get());
|
||||||
|
}
|
||||||
|
|
||||||
if (hasChartData_) {
|
if (hasChartData_) {
|
||||||
UpdateCurveDisplay();
|
UpdateCurveDisplay();
|
||||||
}
|
}
|
||||||
@ -349,3 +353,7 @@ void CurvePanel::initQChartView() {
|
|||||||
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
||||||
pLayout->addWidget(curveChartView);
|
pLayout->addWidget(curveChartView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CurvePanel::OnDataPanelUpdated(FileEntryCurve* fileEntry) {
|
||||||
|
int a = 0;
|
||||||
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "DataPanel.h"
|
#include "DataPanel.h"
|
||||||
#include "workspace/ChartData.h"
|
#include "workspace/ChartData.h"
|
||||||
|
#include "workspace/FileEntry.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "ui/chartPlot/FitCurveChartView.h"
|
#include "ui/chartPlot/FitCurveChartView.h"
|
||||||
|
|
||||||
@ -79,8 +80,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
QString GetTypeDisplayName() const override;
|
QString GetTypeDisplayName() const override;
|
||||||
|
|
||||||
|
|
||||||
void initQChartView();
|
void initQChartView();
|
||||||
|
|
||||||
|
void OnDataPanelUpdated(FileEntryCurve* fileEntry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Update curve display based on chart data
|
* @brief Update curve display based on chart data
|
||||||
|
|||||||
@ -40,6 +40,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
int GetIndex() const { return index_; }
|
int GetIndex() const { return index_; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set associated file entry
|
||||||
|
* @param fileEntry Shared pointer to FileEntry
|
||||||
|
*/
|
||||||
|
void SetFileEntry(std::shared_ptr<FileEntry> fileEntry) { fileEntry_ = fileEntry; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get file type (virtual function, implemented by derived classes)
|
* @brief Get file type (virtual function, implemented by derived classes)
|
||||||
* @return File type
|
* @return File type
|
||||||
@ -111,4 +117,6 @@ protected:
|
|||||||
QString filePath_; // Associated file path
|
QString filePath_; // Associated file path
|
||||||
QString title_; // Panel title
|
QString title_; // Panel title
|
||||||
DockWidget* dockWidget_; // Dock widget reference
|
DockWidget* dockWidget_; // Dock widget reference
|
||||||
|
|
||||||
|
std::shared_ptr<FileEntry> fileEntry_; // Associated file entry
|
||||||
};
|
};
|
||||||
@ -193,7 +193,12 @@ DataPanel* DataPanelManager::CreateDataPanel(FileEntryType fileType, const QStri
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
panel->InitUI();
|
//panel->InitUI();
|
||||||
|
|
||||||
|
auto fileEntries = currentWorkspace_->GetFileEntries(fileType);
|
||||||
|
if (index < fileEntries.size()) {
|
||||||
|
panel->SetFileEntry(fileEntries[index]);
|
||||||
|
}
|
||||||
|
|
||||||
dockWidget->setWidget(panel);
|
dockWidget->setWidget(panel);
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "workspace/WorkSpace.h"
|
||||||
|
|
||||||
#include "ui_AddTableFileDlg.h"
|
#include "ui_AddTableFileDlg.h"
|
||||||
|
|
||||||
@ -14,7 +16,7 @@ AddTableFileDlg::AddTableFileDlg(QWidget* parent)
|
|||||||
: BaseAddFileDlg(FileEntryType::Table, parent)
|
: BaseAddFileDlg(FileEntryType::Table, parent)
|
||||||
, ui(new Ui::AddTableFileDlg) {
|
, ui(new Ui::AddTableFileDlg) {
|
||||||
|
|
||||||
ui->setupUi(this);
|
SetupUI(ui);
|
||||||
SetTitle(getDialogTitle());
|
SetTitle(getDialogTitle());
|
||||||
setupConnections();
|
setupConnections();
|
||||||
}
|
}
|
||||||
@ -27,8 +29,7 @@ void AddTableFileDlg::setupConnections() {
|
|||||||
// Connect file selection
|
// Connect file selection
|
||||||
connect(ui->selectFileBtn, &QToolButton::clicked, this, &AddTableFileDlg::onSelectFileClicked);
|
connect(ui->selectFileBtn, &QToolButton::clicked, this, &AddTableFileDlg::onSelectFileClicked);
|
||||||
connect(ui->filePathEdit, &QLineEdit::textChanged, this, &AddTableFileDlg::onFilePathChanged);
|
connect(ui->filePathEdit, &QLineEdit::textChanged, this, &AddTableFileDlg::onFilePathChanged);
|
||||||
connect(ui->separatorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
||||||
this, &AddTableFileDlg::onDelimiterChanged);
|
|
||||||
connect(ui->hasHeaderCheckBox, &QCheckBox::toggled, this, &AddTableFileDlg::onHeaderToggled);
|
connect(ui->hasHeaderCheckBox, &QCheckBox::toggled, this, &AddTableFileDlg::onHeaderToggled);
|
||||||
connect(ui->addBtn, &QPushButton::clicked, this, [this]() { OnSure(); });
|
connect(ui->addBtn, &QPushButton::clicked, this, [this]() { OnSure(); });
|
||||||
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||||
@ -105,26 +106,77 @@ QString AddTableFileDlg::getSelectedFilePath() const {
|
|||||||
return ui->filePathEdit->text();
|
return ui->filePathEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AddTableFileDlg::getDescription() const {
|
void AddTableFileDlg::accept()
|
||||||
return ui->descriptionEdit->toPlainText().trimmed();
|
{
|
||||||
}
|
// Validate parameters
|
||||||
|
if (!validateSpecificParams()) {
|
||||||
AddTableFileDlg::TableParams AddTableFileDlg::getTableParams() const {
|
return;
|
||||||
TableParams params;
|
|
||||||
|
|
||||||
// Get delimiter from combo box
|
|
||||||
int index = ui->separatorComboBox->currentIndex();
|
|
||||||
switch (index) {
|
|
||||||
case 0: params.delimiter = ","; break;
|
|
||||||
case 1: params.delimiter = "\t"; break;
|
|
||||||
case 2: params.delimiter = " "; break;
|
|
||||||
case 3: params.delimiter = ";"; break;
|
|
||||||
default: params.delimiter = ","; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
params.hasHeader = ui->hasHeaderCheckBox->isChecked();
|
// Validate table-specific parameters
|
||||||
params.xColumn = 1; // Default values
|
if (ui->tableNameEdit->text().isEmpty()) {
|
||||||
params.yColumn = 2;
|
QMessageBox::warning(this, tr("Warning"), tr("Please enter a table name."));
|
||||||
params.description = ui->descriptionEdit->toPlainText().trimmed();
|
return;
|
||||||
return params;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Create FileEntryTable using factory function
|
||||||
|
auto fileEntry = CreateFileEntryTable(getSelectedFilePath());
|
||||||
|
if (!fileEntry) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Failed to create table file entry."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set table headers if provided
|
||||||
|
QString headersText = ui->headersEdit->text().trimmed();
|
||||||
|
if (!headersText.isEmpty()) {
|
||||||
|
QStringList headers = headersText.split(',', Qt::SkipEmptyParts);
|
||||||
|
for (QString& header : headers) {
|
||||||
|
header = header.trimmed();
|
||||||
|
}
|
||||||
|
fileEntry->SetTableHeaders(headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set chart properties
|
||||||
|
FileEntryTable::ChartProperties chartProps;
|
||||||
|
chartProps.timeParam = ui->timeParamSpinBox->value();
|
||||||
|
fileEntry->SetChartProperties(chartProps);
|
||||||
|
|
||||||
|
// Set description (using table name as description for now)
|
||||||
|
fileEntry->SetDescription(ui->tableNameEdit->text());
|
||||||
|
|
||||||
|
// Add to workspace
|
||||||
|
WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent();
|
||||||
|
if (!workspace) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Unable to get current workspace"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add FileEntryTable to workspace using SetFileEntry method
|
||||||
|
auto result = workspace->SetFileEntry(fileEntry);
|
||||||
|
if (result != WorkSpace::FileEntryResult::Ok) {
|
||||||
|
QString errorMsg;
|
||||||
|
switch (result) {
|
||||||
|
case WorkSpace::FileEntryResult::LimitExceeded:
|
||||||
|
errorMsg = tr("Table file count has reached the limit");
|
||||||
|
break;
|
||||||
|
case WorkSpace::FileEntryResult::Duplicate:
|
||||||
|
errorMsg = tr("File already exists");
|
||||||
|
break;
|
||||||
|
case WorkSpace::FileEntryResult::CopyFailed:
|
||||||
|
errorMsg = tr("File copy failed");
|
||||||
|
break;
|
||||||
|
case WorkSpace::FileEntryResult::InvalidFile:
|
||||||
|
errorMsg = tr("Invalid file");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errorMsg = tr("Failed to add file");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
QMessageBox::warning(this, tr("Error"), errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("Added table file to workspace: {}", getSelectedFilePath().toUtf8().constData());
|
||||||
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
@ -21,9 +21,7 @@ public:
|
|||||||
explicit AddTableFileDlg(QWidget* parent = nullptr);
|
explicit AddTableFileDlg(QWidget* parent = nullptr);
|
||||||
~AddTableFileDlg() override;
|
~AddTableFileDlg() override;
|
||||||
|
|
||||||
TableParams getTableParams() const;
|
|
||||||
QString getSelectedFilePath() const;
|
QString getSelectedFilePath() const;
|
||||||
QString getDescription() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getFileFilter() const override;
|
QString getFileFilter() const override;
|
||||||
@ -36,6 +34,9 @@ private slots:
|
|||||||
void onDelimiterChanged();
|
void onDelimiterChanged();
|
||||||
void onHeaderToggled(bool hasHeader);
|
void onHeaderToggled(bool hasHeader);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupConnections();
|
void setupConnections();
|
||||||
void updateFileInfo(const QString& filePath);
|
void updateFileInfo(const QString& filePath);
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>480</width>
|
<width>676</width>
|
||||||
<height>450</height>
|
<height>683</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -29,12 +29,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="filePathEdit">
|
<widget class="QLineEdit" name="filePathEdit">
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Select table data file...</string>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Select table data file...</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
@ -76,50 +76,125 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="paramsGroupBox">
|
<widget class="QGroupBox" name="basicInfoGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Table Parameters</string>
|
<string>Basic Information</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="paramsGridLayout">
|
<layout class="QGridLayout" name="basicInfoGridLayout">
|
||||||
<item row="0" column="0">
|
<item row="1" column="1" colspan="2">
|
||||||
<widget class="QLabel" name="separatorLabel">
|
<widget class="QDoubleSpinBox" name="timeParamSpinBox">
|
||||||
<property name="text">
|
<property name="decimals">
|
||||||
<string>Separator:</string>
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1" colspan="2">
|
||||||
<widget class="QComboBox" name="separatorComboBox">
|
<widget class="QLineEdit" name="tableNameEdit">
|
||||||
<item>
|
<property name="placeholderText">
|
||||||
<property name="text">
|
<string>Enter table name...</string>
|
||||||
<string>Comma (,)</string>
|
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="tableNameLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Tab</string>
|
<string>Table Name:</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Space</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Semicolon (;)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="timeParamLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Time Parameter:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="headersGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Table Headers Configuration</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="headersVerticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="hasHeaderCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>File has header row</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="headersLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Headers (comma-separated):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="headersEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>e.g., Time, Value1, Value2, Value3...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="headersHintLabel">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color: gray; font-size: 11px;</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tip: Headers will be auto-detected if file has header row</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="paramsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Parsing Parameters</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="paramsGridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="skipRowsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Skip Rows:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="autoDetectCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto-detect parameters</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="encodingLabel">
|
<widget class="QLabel" name="encodingLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Encoding:</string>
|
<string>Encoding:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="encodingComboBox">
|
<widget class="QComboBox" name="encodingComboBox">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -143,14 +218,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="skipRowsLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Skip Rows:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QSpinBox" name="skipRowsSpinBox">
|
<widget class="QSpinBox" name="skipRowsSpinBox">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -163,26 +231,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="hasHeaderCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>File has header row</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="autoDetectCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto-detect parameters</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -212,46 +260,21 @@
|
|||||||
<property name="columnCount">
|
<property name="columnCount">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
|
<row/>
|
||||||
|
<row/>
|
||||||
|
<row/>
|
||||||
|
<row/>
|
||||||
|
<row/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="descGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Description (Optional)</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="descVerticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="descriptionEdit">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>60</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Enter file description...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="buttonLayout">
|
<layout class="QHBoxLayout" name="buttonLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@ -59,14 +59,17 @@ std::shared_ptr<FileEntry> CreateFileEntrySurface(const QString& filePath) {
|
|||||||
return fileEntry;
|
return fileEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<FileEntry> CreateFileEntryTable(const QString& filePath) {
|
std::shared_ptr<FileEntryTable> CreateFileEntryTable(const QString& filePath) {
|
||||||
auto fileEntry = std::make_shared<FileEntry>();
|
QFileInfo fileInfo(filePath);
|
||||||
fileEntry->SetType(FileEntryType::Table);
|
if (!filePath.isEmpty() && !fileInfo.exists()) {
|
||||||
|
LOG_ERROR("File does not exist: {}", filePath.toUtf8().constData());
|
||||||
if (!filePath.isEmpty()) {
|
return nullptr;
|
||||||
fileEntry->SetPath(filePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto fileEntry = std::make_shared<FileEntryTable>();
|
||||||
|
fileEntry->SetPath(filePath);
|
||||||
|
fileEntry->SetName(fileInfo.baseName()); // Use base name as default display name
|
||||||
|
|
||||||
return fileEntry;
|
return fileEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,3 +127,60 @@ void FileEntrySurface::SetDescription(const QString& description) {
|
|||||||
const QString& FileEntrySurface::GetDescription() const {
|
const QString& FileEntrySurface::GetDescription() const {
|
||||||
return description_;
|
return description_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileEntryTable method implementations
|
||||||
|
void FileEntryTable::SetChartProperties(const ChartProperties& properties) {
|
||||||
|
chartProperties_ = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FileEntryTable::ChartProperties& FileEntryTable::GetChartProperties() const {
|
||||||
|
return chartProperties_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTable::AddTableProperty(const TableProperty& table) {
|
||||||
|
tableProperties_.append(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTable::RemoveTableProperty(int index) {
|
||||||
|
if (index >= 0 && index < tableProperties_.size()) {
|
||||||
|
tableProperties_.removeAt(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTable::SetTableProperty(int index, const TableProperty& table) {
|
||||||
|
if (index >= 0 && index < tableProperties_.size()) {
|
||||||
|
tableProperties_[index] = table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const FileEntryTable::TableProperties& FileEntryTable::GetTableProperties() const {
|
||||||
|
return tableProperties_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTable::SetTableHeaders(const QStringList& headers) {
|
||||||
|
tableHeaders_ = headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTable::SetTableHeaders(const QString& headerString) {
|
||||||
|
tableHeaders_ = headerString.split(',', Qt::SkipEmptyParts);
|
||||||
|
// Trim whitespace from each header
|
||||||
|
for (QString& header : tableHeaders_) {
|
||||||
|
header = header.trimmed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList& FileEntryTable::GetTableHeaders() const {
|
||||||
|
return tableHeaders_;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileEntryTable* FileEntryTable::AsTable() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileEntryTable::SetDescription(const QString& description) {
|
||||||
|
description_ = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& FileEntryTable::GetDescription() const {
|
||||||
|
return description_;
|
||||||
|
}
|
||||||
@ -32,6 +32,7 @@ inline bool FileEntryTypeFromString(const char* s, FileEntryType& out) {
|
|||||||
class FileEntryCurve;
|
class FileEntryCurve;
|
||||||
class FileEntryLight;
|
class FileEntryLight;
|
||||||
class FileEntrySurface;
|
class FileEntrySurface;
|
||||||
|
class FileEntryTable;
|
||||||
|
|
||||||
class FileEntry {
|
class FileEntry {
|
||||||
public:
|
public:
|
||||||
@ -52,6 +53,7 @@ public:
|
|||||||
virtual FileEntryCurve* AsCurve() { return nullptr; }
|
virtual FileEntryCurve* AsCurve() { return nullptr; }
|
||||||
virtual FileEntryLight* AsLight() { return nullptr; }
|
virtual FileEntryLight* AsLight() { return nullptr; }
|
||||||
virtual FileEntrySurface* AsSurface() { return nullptr; }
|
virtual FileEntrySurface* AsSurface() { return nullptr; }
|
||||||
|
virtual FileEntryTable* AsTable() { return nullptr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileEntryType type_;
|
FileEntryType type_;
|
||||||
@ -64,7 +66,7 @@ protected:
|
|||||||
std::shared_ptr<FileEntry> CreateFileEntry(FileEntryType type, const QString& filePath);
|
std::shared_ptr<FileEntry> CreateFileEntry(FileEntryType type, const QString& filePath);
|
||||||
std::shared_ptr<FileEntryCurve> CreateFileEntryCurve(const QString& filePath);
|
std::shared_ptr<FileEntryCurve> CreateFileEntryCurve(const QString& filePath);
|
||||||
std::shared_ptr<FileEntry> CreateFileEntrySurface(const QString& filePath);
|
std::shared_ptr<FileEntry> CreateFileEntrySurface(const QString& filePath);
|
||||||
std::shared_ptr<FileEntry> CreateFileEntryTable(const QString& filePath);
|
std::shared_ptr<FileEntryTable> CreateFileEntryTable(const QString& filePath);
|
||||||
std::shared_ptr<FileEntryLight> CreateFileEntryLight(const QString& filePath);
|
std::shared_ptr<FileEntryLight> CreateFileEntryLight(const QString& filePath);
|
||||||
|
|
||||||
|
|
||||||
@ -163,6 +165,54 @@ private:
|
|||||||
QString description_;
|
QString description_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FileEntryTable : public FileEntry {
|
||||||
|
public:
|
||||||
|
struct ChartProperties {
|
||||||
|
QString name;
|
||||||
|
QString path;
|
||||||
|
double timeParam;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TableProperty {
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
QList<int> datas;
|
||||||
|
};
|
||||||
|
|
||||||
|
using TableProperties = QList<TableProperty>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FileEntryTable() { type_ = FileEntryType::Table; }
|
||||||
|
|
||||||
|
// Chart properties management
|
||||||
|
void SetChartProperties(const ChartProperties& properties);
|
||||||
|
const ChartProperties& GetChartProperties() const;
|
||||||
|
|
||||||
|
// Table properties management
|
||||||
|
void AddTableProperty(const TableProperty& table);
|
||||||
|
void RemoveTableProperty(int index);
|
||||||
|
void SetTableProperty(int index, const TableProperty& table);
|
||||||
|
const TableProperties& GetTableProperties() const;
|
||||||
|
|
||||||
|
// Table headers management
|
||||||
|
void SetTableHeaders(const QStringList& headers);
|
||||||
|
void SetTableHeaders(const QString& headerString); // Parse from comma-separated string
|
||||||
|
const QStringList& GetTableHeaders() const;
|
||||||
|
|
||||||
|
// Type conversion
|
||||||
|
FileEntryTable* AsTable() override;
|
||||||
|
|
||||||
|
// Description management
|
||||||
|
void SetDescription(const QString& description);
|
||||||
|
const QString& GetDescription() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChartProperties chartProperties_;
|
||||||
|
QStringList tableHeaders_;
|
||||||
|
TableProperties tableProperties_;
|
||||||
|
QString description_;
|
||||||
|
};
|
||||||
|
|
||||||
class FileEntryLight : public FileEntry {
|
class FileEntryLight : public FileEntry {
|
||||||
public:
|
public:
|
||||||
struct ColorProperties {
|
struct ColorProperties {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user