Merge branch 'new_osg' of http://brigecode.icu:16623/PM/DYTSrouce into new_osg
This commit is contained in:
commit
bbb9323e09
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
#include "ui/MainFrame.h"
|
#include "ui/MainFrame.h"
|
||||||
#include "ui/WorkSpace/WorkSpaceDlg.h"
|
#include "ui/WorkSpace/WorkSpaceDlg.h"
|
||||||
#include "ui/WorkSpace/AddFileDlg.h"
|
#include "ui/WorkSpace/AddFileDialogFactory.h"
|
||||||
|
#include "ui/WorkSpace/BaseAddFileDlg.h"
|
||||||
|
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
@ -81,28 +82,29 @@ void FileManagerMenu::SaveWorkSpace() {
|
|||||||
LOG_INFO("save workspace: {}", fileName.toLocal8Bit().constData());
|
LOG_INFO("save workspace: {}", fileName.toLocal8Bit().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManagerMenu::AddFile() {
|
// Removed old AddFile method - replaced by specific type methods
|
||||||
|
|
||||||
|
void FileManagerMenu::AddWaveFile() {
|
||||||
auto current = WorkSpaceManager::Get().GetCurrent();
|
auto current = WorkSpaceManager::Get().GetCurrent();
|
||||||
if (nullptr == current) {
|
if (nullptr == current) {
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("please create workspace first"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("please create workspace first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show file addition dialog
|
// Show curve file addition dialog
|
||||||
AddFileDlg dlg(&MainFrame::Get());
|
auto dialog = AddFileDialogFactory::createDialog(FileEntryType::Curve, &MainFrame::Get());
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dialog && dialog->exec() == QDialog::Accepted) {
|
||||||
FileEntryType selectedType = dlg.getSelectedFileType();
|
QString selectedPath = dialog->getSelectedFilePath();
|
||||||
QString selectedPath = dlg.getSelectedFilePath();
|
|
||||||
|
|
||||||
// Create file entry
|
// Create file entry
|
||||||
switch (current->CreateFileEntry(selectedType)) {
|
switch (current->CreateFileEntry(FileEntryType::Curve)) {
|
||||||
case WorkSpace::FileEntryResult::Ok: {
|
case WorkSpace::FileEntryResult::Ok: {
|
||||||
// Get the index of the newly created file entry
|
// Get the index of the newly created file entry
|
||||||
auto entries = current->GetFileEntries(selectedType);
|
auto entries = current->GetFileEntries(FileEntryType::Curve);
|
||||||
int newIndex = static_cast<int>(entries.size()) - 1;
|
int newIndex = static_cast<int>(entries.size()) - 1;
|
||||||
|
|
||||||
// Set file path
|
// Set file path
|
||||||
if (!current->SetFileEntryPath(selectedType, newIndex, selectedPath)) {
|
if (!current->SetFileEntryPath(FileEntryType::Curve, newIndex, selectedPath)) {
|
||||||
QMessageBox::warning(&MainFrame::Get(), QObject::tr("Error"),
|
QMessageBox::warning(&MainFrame::Get(), QObject::tr("Error"),
|
||||||
QObject::tr("Failed to set file path"));
|
QObject::tr("Failed to set file path"));
|
||||||
}
|
}
|
||||||
@ -124,28 +126,6 @@ void FileManagerMenu::AddFile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManagerMenu::AddWaveFile() {
|
|
||||||
auto current = WorkSpaceManager::Get().GetCurrent();
|
|
||||||
if (nullptr == current) {
|
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("please create workspace first"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (current->CreateFileEntry(FileEntryType::Curve)) {
|
|
||||||
case WorkSpace::FileEntryResult::Ok:
|
|
||||||
break;
|
|
||||||
case WorkSpace::FileEntryResult::LimitExceeded:
|
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("up to 9 files allowed for this type"));
|
|
||||||
break;
|
|
||||||
case WorkSpace::FileEntryResult::Duplicate:
|
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("file already added for this type"));
|
|
||||||
break;
|
|
||||||
case WorkSpace::FileEntryResult::CopyFailed:
|
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("copy file failed"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileManagerMenu::AddSurfaceFile() {
|
void FileManagerMenu::AddSurfaceFile() {
|
||||||
auto current = WorkSpaceManager::Get().GetCurrent();
|
auto current = WorkSpaceManager::Get().GetCurrent();
|
||||||
if (nullptr == current) {
|
if (nullptr == current) {
|
||||||
@ -153,19 +133,39 @@ void FileManagerMenu::AddSurfaceFile() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show surface file addition dialog
|
||||||
|
auto dialog = AddFileDialogFactory::createDialog(FileEntryType::Surface, &MainFrame::Get());
|
||||||
|
if (dialog && dialog->exec() == QDialog::Accepted) {
|
||||||
|
QString selectedPath = dialog->getSelectedFilePath();
|
||||||
|
|
||||||
|
// Create file entry
|
||||||
switch (current->CreateFileEntry(FileEntryType::Surface)) {
|
switch (current->CreateFileEntry(FileEntryType::Surface)) {
|
||||||
case WorkSpace::FileEntryResult::Ok:
|
case WorkSpace::FileEntryResult::Ok: {
|
||||||
|
// Get the index of the newly created file entry
|
||||||
|
auto entries = current->GetFileEntries(FileEntryType::Surface);
|
||||||
|
int newIndex = static_cast<int>(entries.size()) - 1;
|
||||||
|
|
||||||
|
// Set file path
|
||||||
|
if (!current->SetFileEntryPath(FileEntryType::Surface, newIndex, selectedPath)) {
|
||||||
|
QMessageBox::warning(&MainFrame::Get(), QObject::tr("Error"),
|
||||||
|
QObject::tr("Failed to set file path"));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WorkSpace::FileEntryResult::LimitExceeded:
|
case WorkSpace::FileEntryResult::LimitExceeded:
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("up to 9 files allowed for this type"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("up to 9 files allowed for this type"));
|
||||||
break;
|
break;
|
||||||
case WorkSpace::FileEntryResult::Duplicate:
|
case WorkSpace::FileEntryResult::Duplicate:
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("file already added for this type"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("file already added for this type"));
|
||||||
break;
|
break;
|
||||||
case WorkSpace::FileEntryResult::CopyFailed:
|
case WorkSpace::FileEntryResult::CopyFailed:
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("copy file failed"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("copy file failed"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManagerMenu::AddTableFile() {
|
void FileManagerMenu::AddTableFile() {
|
||||||
@ -174,19 +174,40 @@ void FileManagerMenu::AddTableFile() {
|
|||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("please create workspace first"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("please create workspace first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show table file addition dialog
|
||||||
|
auto dialog = AddFileDialogFactory::createDialog(FileEntryType::Table, &MainFrame::Get());
|
||||||
|
if (dialog && dialog->exec() == QDialog::Accepted) {
|
||||||
|
QString selectedPath = dialog->getSelectedFilePath();
|
||||||
|
|
||||||
|
// Create file entry
|
||||||
switch (current->CreateFileEntry(FileEntryType::Table)) {
|
switch (current->CreateFileEntry(FileEntryType::Table)) {
|
||||||
case WorkSpace::FileEntryResult::Ok:
|
case WorkSpace::FileEntryResult::Ok: {
|
||||||
|
// Get the index of the newly created file entry
|
||||||
|
auto entries = current->GetFileEntries(FileEntryType::Table);
|
||||||
|
int newIndex = static_cast<int>(entries.size()) - 1;
|
||||||
|
|
||||||
|
// Set file path
|
||||||
|
if (!current->SetFileEntryPath(FileEntryType::Table, newIndex, selectedPath)) {
|
||||||
|
QMessageBox::warning(&MainFrame::Get(), QObject::tr("Error"),
|
||||||
|
QObject::tr("Failed to set file path"));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WorkSpace::FileEntryResult::LimitExceeded:
|
case WorkSpace::FileEntryResult::LimitExceeded:
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("up to 9 files allowed for this type"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("up to 9 files allowed for this type"));
|
||||||
break;
|
break;
|
||||||
case WorkSpace::FileEntryResult::Duplicate:
|
case WorkSpace::FileEntryResult::Duplicate:
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("file already added for this type"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("file already added for this type"));
|
||||||
break;
|
break;
|
||||||
case WorkSpace::FileEntryResult::CopyFailed:
|
case WorkSpace::FileEntryResult::CopyFailed:
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("copy file failed"));
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("copy file failed"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManagerMenu::AddLightFile() {
|
void FileManagerMenu::AddLightFile() {
|
||||||
@ -196,17 +217,37 @@ void FileManagerMenu::AddLightFile() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show light file addition dialog
|
||||||
|
auto dialog = AddFileDialogFactory::createDialog(FileEntryType::Light, &MainFrame::Get());
|
||||||
|
if (dialog && dialog->exec() == QDialog::Accepted) {
|
||||||
|
QString selectedPath = dialog->getSelectedFilePath();
|
||||||
|
|
||||||
|
// Create file entry
|
||||||
switch (current->CreateFileEntry(FileEntryType::Light)) {
|
switch (current->CreateFileEntry(FileEntryType::Light)) {
|
||||||
case WorkSpace::FileEntryResult::Ok:
|
case WorkSpace::FileEntryResult::Ok: {
|
||||||
break;
|
// Get the index of the newly created file entry
|
||||||
case WorkSpace::FileEntryResult::LimitExceeded:
|
auto entries = current->GetFileEntries(FileEntryType::Light);
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("up to 9 files allowed for this type"));
|
int newIndex = static_cast<int>(entries.size()) - 1;
|
||||||
break;
|
|
||||||
case WorkSpace::FileEntryResult::Duplicate:
|
// Set file path
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("file already added for this type"));
|
if (!current->SetFileEntryPath(FileEntryType::Light, newIndex, selectedPath)) {
|
||||||
break;
|
QMessageBox::warning(&MainFrame::Get(), QObject::tr("Error"),
|
||||||
case WorkSpace::FileEntryResult::CopyFailed:
|
QObject::tr("Failed to set file path"));
|
||||||
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"), QObject::tr("copy file failed"));
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case WorkSpace::FileEntryResult::LimitExceeded:
|
||||||
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("up to 9 files allowed for this type"));
|
||||||
|
break;
|
||||||
|
case WorkSpace::FileEntryResult::Duplicate:
|
||||||
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("file already added for this type"));
|
||||||
|
break;
|
||||||
|
case WorkSpace::FileEntryResult::CopyFailed:
|
||||||
|
QMessageBox::information(&MainFrame::Get(), QObject::tr("prompt"),
|
||||||
|
QObject::tr("copy file failed"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,10 +20,7 @@ protected:
|
|||||||
void OpenWorkSpace();
|
void OpenWorkSpace();
|
||||||
void SaveWorkSpace();
|
void SaveWorkSpace();
|
||||||
|
|
||||||
// New unified file addition method
|
// Type-specific file addition methods
|
||||||
void AddFile();
|
|
||||||
|
|
||||||
// Keep original methods for backward compatibility
|
|
||||||
void AddWaveFile();
|
void AddWaveFile();
|
||||||
void AddSurfaceFile();
|
void AddSurfaceFile();
|
||||||
void AddTableFile();
|
void AddTableFile();
|
||||||
|
|||||||
552
src/ui/WorkSpace/AddCurveFileDlg.cpp
Normal file
552
src/ui/WorkSpace/AddCurveFileDlg.cpp
Normal file
@ -0,0 +1,552 @@
|
|||||||
|
#include "AddCurveFileDlg.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
#include "ui_AddCurveFileDlg.h"
|
||||||
|
|
||||||
|
AddCurveFileDlg::AddCurveFileDlg(QWidget* parent)
|
||||||
|
: BaseAddFileDlg(FileEntryType::Curve, parent)
|
||||||
|
, ui(new Ui::AddCurveFileDlg)
|
||||||
|
, currentCurveIndex_(-1)
|
||||||
|
, selectedColor_(255, 0, 0) { // Default to red color
|
||||||
|
|
||||||
|
SetupUI(ui);
|
||||||
|
SetTitle(getDialogTitle());
|
||||||
|
setupSpecificUI();
|
||||||
|
setupConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddCurveFileDlg::~AddCurveFileDlg() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::setupSpecificUI() {
|
||||||
|
// Initialize curve properties group as disabled
|
||||||
|
enableCurveProperties(false);
|
||||||
|
|
||||||
|
// Initialize color preview
|
||||||
|
updateColorPreview(selectedColor_);
|
||||||
|
|
||||||
|
// Add a default curve
|
||||||
|
CurveProperties defaultCurve;
|
||||||
|
defaultCurve.name = generateCurveName();
|
||||||
|
defaultCurve.color = generateCurveColor();
|
||||||
|
defaultCurve.start = 1;
|
||||||
|
defaultCurve.stop = 241;
|
||||||
|
|
||||||
|
curves_.append(defaultCurve);
|
||||||
|
addCurveToList(defaultCurve);
|
||||||
|
|
||||||
|
// Select the first curve
|
||||||
|
if (ui->curveListWidget->count() > 0) {
|
||||||
|
ui->curveListWidget->setCurrentRow(0);
|
||||||
|
onCurveSelectionChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::setupConnections() {
|
||||||
|
// File selection connections
|
||||||
|
connect(ui->selectFileBtn, &QToolButton::clicked, this, &AddCurveFileDlg::onSelectFileClicked);
|
||||||
|
connect(ui->filePathEdit, &QLineEdit::textChanged, this, &AddCurveFileDlg::onFilePathChanged);
|
||||||
|
|
||||||
|
// Data format connections
|
||||||
|
connect(ui->separatorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, &AddCurveFileDlg::onDelimiterChanged);
|
||||||
|
connect(ui->hasHeaderCheckBox, &QCheckBox::toggled, this, &AddCurveFileDlg::onHeaderToggled);
|
||||||
|
|
||||||
|
// Curve management connections
|
||||||
|
connect(ui->addCurveBtn, &QPushButton::clicked, this, &AddCurveFileDlg::onAddCurveClicked);
|
||||||
|
connect(ui->removeCurveBtn, &QPushButton::clicked, this, &AddCurveFileDlg::onRemoveCurveClicked);
|
||||||
|
connect(ui->curveListWidget, &QListWidget::currentRowChanged, this, &AddCurveFileDlg::onCurveSelectionChanged);
|
||||||
|
|
||||||
|
// Curve properties connections
|
||||||
|
connect(ui->colorButton, &QPushButton::clicked, this, &AddCurveFileDlg::onColorButtonClicked);
|
||||||
|
connect(ui->curveNameEdit, &QLineEdit::textChanged, this, &AddCurveFileDlg::onCurveNameChanged);
|
||||||
|
connect(ui->dataStartSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddCurveFileDlg::onCurveDataChanged);
|
||||||
|
connect(ui->dataStopSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddCurveFileDlg::onCurveDataChanged);
|
||||||
|
|
||||||
|
// Dialog buttons
|
||||||
|
connect(ui->addBtn, &QPushButton::clicked, this, &AddCurveFileDlg::onSure);
|
||||||
|
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onSelectFileClicked() {
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
getDialogTitle(),
|
||||||
|
QString(),
|
||||||
|
getFileFilter()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
ui->filePathEdit->setText(fileName);
|
||||||
|
updateFileInfo(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::updateFileInfo(const QString& filePath) {
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
if (fileInfo.exists()) {
|
||||||
|
ui->fileNameValue->setText(fileInfo.fileName());
|
||||||
|
ui->fileSizeValue->setText(QString::number(fileInfo.size()) + " bytes");
|
||||||
|
} else {
|
||||||
|
ui->fileNameValue->setText("-");
|
||||||
|
ui->fileSizeValue->setText("-");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onFilePathChanged() {
|
||||||
|
QString filePath = ui->filePathEdit->text();
|
||||||
|
if (!filePath.isEmpty()) {
|
||||||
|
updateFileInfo(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onAddCurveClicked() {
|
||||||
|
// Save current curve properties if any curve is selected
|
||||||
|
if (currentCurveIndex_ >= 0) {
|
||||||
|
saveCurveProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new curve with default properties
|
||||||
|
CurveProperties newCurve;
|
||||||
|
newCurve.name = generateCurveName();
|
||||||
|
newCurve.color = generateCurveColor();
|
||||||
|
newCurve.start = 1;
|
||||||
|
newCurve.stop = 241;
|
||||||
|
|
||||||
|
// Add to curves list and UI
|
||||||
|
curves_.append(newCurve);
|
||||||
|
addCurveToList(newCurve);
|
||||||
|
|
||||||
|
// Select the new curve
|
||||||
|
ui->curveListWidget->setCurrentRow(curves_.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onRemoveCurveClicked() {
|
||||||
|
int currentRow = ui->curveListWidget->currentRow();
|
||||||
|
if (currentRow < 0 || currentRow >= curves_.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't allow removing the last curve
|
||||||
|
if (curves_.size() <= 1) {
|
||||||
|
QMessageBox::information(this, "Information", "At least one curve must remain.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove from curves list and UI
|
||||||
|
curves_.removeAt(currentRow);
|
||||||
|
delete ui->curveListWidget->takeItem(currentRow);
|
||||||
|
|
||||||
|
// Update current index
|
||||||
|
if (currentRow >= curves_.size()) {
|
||||||
|
currentRow = curves_.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentRow >= 0) {
|
||||||
|
ui->curveListWidget->setCurrentRow(currentRow);
|
||||||
|
} else {
|
||||||
|
currentCurveIndex_ = -1;
|
||||||
|
clearCurveProperties();
|
||||||
|
enableCurveProperties(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onCurveSelectionChanged() {
|
||||||
|
int currentRow = ui->curveListWidget->currentRow();
|
||||||
|
|
||||||
|
// Save previous curve properties
|
||||||
|
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
|
||||||
|
saveCurveProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentCurveIndex_ = currentRow;
|
||||||
|
|
||||||
|
if (currentRow >= 0 && currentRow < curves_.size()) {
|
||||||
|
// Load selected curve properties
|
||||||
|
updateCurveProperties();
|
||||||
|
enableCurveProperties(true);
|
||||||
|
} else {
|
||||||
|
clearCurveProperties();
|
||||||
|
enableCurveProperties(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onCurveNameChanged() {
|
||||||
|
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
|
||||||
|
QString newName = ui->curveNameEdit->text();
|
||||||
|
curves_[currentCurveIndex_].name = newName;
|
||||||
|
|
||||||
|
// Update list item text
|
||||||
|
QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
|
||||||
|
if (item) {
|
||||||
|
item->setText(QString("%1 [%2,%3] (%4,%5,%6)")
|
||||||
|
.arg(newName)
|
||||||
|
.arg(curves_[currentCurveIndex_].start)
|
||||||
|
.arg(curves_[currentCurveIndex_].stop)
|
||||||
|
.arg(curves_[currentCurveIndex_].color.red())
|
||||||
|
.arg(curves_[currentCurveIndex_].color.green())
|
||||||
|
.arg(curves_[currentCurveIndex_].color.blue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onCurveDataChanged() {
|
||||||
|
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
|
||||||
|
curves_[currentCurveIndex_].start = ui->dataStartSpinBox->value();
|
||||||
|
curves_[currentCurveIndex_].stop = ui->dataStopSpinBox->value();
|
||||||
|
|
||||||
|
// Update list item text
|
||||||
|
QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
|
||||||
|
if (item) {
|
||||||
|
item->setText(QString("%1 [%2,%3] (%4,%5,%6)")
|
||||||
|
.arg(curves_[currentCurveIndex_].name)
|
||||||
|
.arg(curves_[currentCurveIndex_].start)
|
||||||
|
.arg(curves_[currentCurveIndex_].stop)
|
||||||
|
.arg(curves_[currentCurveIndex_].color.red())
|
||||||
|
.arg(curves_[currentCurveIndex_].color.green())
|
||||||
|
.arg(curves_[currentCurveIndex_].color.blue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onColorButtonClicked() {
|
||||||
|
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
|
||||||
|
QColor color = QColorDialog::getColor(curves_[currentCurveIndex_].color, this, "Select Curve Color");
|
||||||
|
if (color.isValid()) {
|
||||||
|
curves_[currentCurveIndex_].color = color;
|
||||||
|
selectedColor_ = color;
|
||||||
|
updateColorPreview(color);
|
||||||
|
|
||||||
|
// Update list item text
|
||||||
|
QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
|
||||||
|
if (item) {
|
||||||
|
item->setText(QString("%1 [%2,%3] (%4,%5,%6)")
|
||||||
|
.arg(curves_[currentCurveIndex_].name)
|
||||||
|
.arg(curves_[currentCurveIndex_].start)
|
||||||
|
.arg(curves_[currentCurveIndex_].stop)
|
||||||
|
.arg(color.red())
|
||||||
|
.arg(color.green())
|
||||||
|
.arg(color.blue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::addCurveToList(const CurveProperties& curve) {
|
||||||
|
QString itemText = QString("%1 [%2,%3] (%4,%5,%6)")
|
||||||
|
.arg(curve.name)
|
||||||
|
.arg(curve.start)
|
||||||
|
.arg(curve.stop)
|
||||||
|
.arg(curve.color.red())
|
||||||
|
.arg(curve.color.green())
|
||||||
|
.arg(curve.color.blue());
|
||||||
|
|
||||||
|
ui->curveListWidget->addItem(itemText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::updateCurveProperties() {
|
||||||
|
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
|
||||||
|
const CurveProperties& curve = curves_[currentCurveIndex_];
|
||||||
|
|
||||||
|
ui->curveNameEdit->setText(curve.name);
|
||||||
|
ui->dataStartSpinBox->setValue(curve.start);
|
||||||
|
ui->dataStopSpinBox->setValue(curve.stop);
|
||||||
|
|
||||||
|
selectedColor_ = curve.color;
|
||||||
|
updateColorPreview(curve.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::saveCurveProperties() {
|
||||||
|
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
|
||||||
|
curves_[currentCurveIndex_].name = ui->curveNameEdit->text();
|
||||||
|
curves_[currentCurveIndex_].start = ui->dataStartSpinBox->value();
|
||||||
|
curves_[currentCurveIndex_].stop = ui->dataStopSpinBox->value();
|
||||||
|
curves_[currentCurveIndex_].color = selectedColor_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::clearCurveProperties() {
|
||||||
|
ui->curveNameEdit->clear();
|
||||||
|
ui->dataStartSpinBox->setValue(1);
|
||||||
|
ui->dataStopSpinBox->setValue(241);
|
||||||
|
selectedColor_ = QColor(255, 0, 0);
|
||||||
|
updateColorPreview(selectedColor_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::enableCurveProperties(bool enabled) {
|
||||||
|
ui->curvePropertiesGroupBox->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddCurveFileDlg::generateCurveName() {
|
||||||
|
return tr("Curve %1").arg(curves_.size() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor AddCurveFileDlg::generateCurveColor() const {
|
||||||
|
// Generate different colors for each curve
|
||||||
|
static const QColor colors[] = {
|
||||||
|
QColor(255, 0, 0), // Red
|
||||||
|
QColor(0, 255, 0), // Green
|
||||||
|
QColor(0, 0, 255), // Blue
|
||||||
|
QColor(255, 255, 0), // Yellow
|
||||||
|
QColor(255, 0, 255), // Magenta
|
||||||
|
QColor(0, 255, 255), // Cyan
|
||||||
|
QColor(255, 128, 0), // Orange
|
||||||
|
QColor(128, 0, 255), // Purple
|
||||||
|
};
|
||||||
|
|
||||||
|
int colorIndex = curves_.size() % (sizeof(colors) / sizeof(colors[0]));
|
||||||
|
return colors[colorIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::updateColorPreview(const QColor& color) {
|
||||||
|
QString styleSheet = QString("background-color: rgb(%1, %2, %3); border: 1px solid black;")
|
||||||
|
.arg(color.red())
|
||||||
|
.arg(color.green())
|
||||||
|
.arg(color.blue());
|
||||||
|
ui->colorPreview->setStyleSheet(styleSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AddCurveFileDlg::validateSpecificParams() {
|
||||||
|
// File path validation
|
||||||
|
if (ui->filePathEdit->text().isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Please select a data file."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File existence validation
|
||||||
|
QFileInfo fileInfo(ui->filePathEdit->text());
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Selected file does not exist."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File readability validation
|
||||||
|
if (!fileInfo.isReadable()) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Selected file is not readable. Please check file permissions."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File size validation (avoid memory issues with large files)
|
||||||
|
if (fileInfo.size() > 100 * 1024 * 1024) { // 100MB limit
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("File is too large (over 100MB). Please select a smaller file."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Curve count validation
|
||||||
|
if (curves_.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("At least one curve must be defined."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save current curve properties
|
||||||
|
if (currentCurveIndex_ >= 0) {
|
||||||
|
saveCurveProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Curve name uniqueness validation
|
||||||
|
QStringList curveNames;
|
||||||
|
for (int i = 0; i < curves_.size(); ++i) {
|
||||||
|
const CurveProperties& curve = curves_[i];
|
||||||
|
|
||||||
|
if (curve.name.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve %1 name cannot be empty.").arg(i + 1));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curveNames.contains(curve.name)) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve name '%1' is duplicated. Please use different names.").arg(curve.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
curveNames.append(curve.name);
|
||||||
|
|
||||||
|
// Curve name length validation
|
||||||
|
if (curve.name.length() > 50) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve name '%1' is too long. Please limit to 50 characters.").arg(curve.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data range validation
|
||||||
|
if (curve.start < 1 || curve.stop < 1) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve '%1' start and stop values must be greater than 0.").arg(curve.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curve.start > curve.stop) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve '%1' start value cannot be greater than stop value.").arg(curve.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data range reasonableness validation
|
||||||
|
if (curve.stop - curve.start < 1) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve '%1' data range is too small. At least 2 data points are required.").arg(curve.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curve.stop > 1000000) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"),
|
||||||
|
tr("Curve '%1' stop value is too large. Please ensure it does not exceed 1000000.").arg(curve.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chart properties validation
|
||||||
|
if (ui->chartNameEdit->text().isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Chart name cannot be empty."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui->chartNameEdit->text().length() > 100) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Chart name is too long. Please limit to 100 characters."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Axis title validation
|
||||||
|
if (ui->xTitleEdit->text().length() > 50) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("X axis title is too long. Please limit to 50 characters."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui->yTitleEdit->text().length() > 50) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Y axis title is too long. Please limit to 50 characters."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Axis range validation
|
||||||
|
double xMin = ui->xMinSpinBox->value();
|
||||||
|
double xMax = ui->xMaxSpinBox->value();
|
||||||
|
double yMin = ui->yMinSpinBox->value();
|
||||||
|
double yMax = ui->yMaxSpinBox->value();
|
||||||
|
|
||||||
|
if (xMin >= xMax) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("X axis minimum value must be less than maximum value."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yMin >= yMax) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Y axis minimum value must be less than maximum value."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data column validation
|
||||||
|
int xColumn = ui->xColumnSpinBox->value();
|
||||||
|
int yColumn = ui->yColumnSpinBox->value();
|
||||||
|
|
||||||
|
if (xColumn == yColumn) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("X column and Y column cannot be the same."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xColumn < 1 || yColumn < 1) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Data column indices must be greater than 0."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Time parameter validation
|
||||||
|
double timeParam = ui->timeParamSpinBox->value();
|
||||||
|
if (timeParam < 0) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Time parameter cannot be negative."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// X axis tick count validation
|
||||||
|
int xTickCount = ui->xCountSpinBox->value();
|
||||||
|
if (xTickCount < 2) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("X axis tick count must be at least 2."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Description length validation
|
||||||
|
if (ui->descriptionEdit->toPlainText().length() > 500) {
|
||||||
|
QMessageBox::warning(this, tr("Validation Error"), tr("Description is too long. Please limit to 500 characters."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddCurveFileDlg::getFileFilter() const {
|
||||||
|
return "Data Files (*.txt *.csv *.dat);;All Files (*.*)";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddCurveFileDlg::getDialogTitle() const {
|
||||||
|
return "Add Curve Data File";
|
||||||
|
}
|
||||||
|
|
||||||
|
AddCurveFileDlg::CurveParams AddCurveFileDlg::getCurveParams() const {
|
||||||
|
CurveParams params;
|
||||||
|
params.chart = getChartProperties();
|
||||||
|
params.curves = getCurveProperties();
|
||||||
|
params.format = getDataFormatParams();
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddCurveFileDlg::ChartProperties AddCurveFileDlg::getChartProperties() const {
|
||||||
|
ChartProperties chart;
|
||||||
|
chart.name = ui->chartNameEdit->text();
|
||||||
|
chart.path = ui->filePathEdit->text();
|
||||||
|
chart.xTitle = ui->xTitleEdit->text();
|
||||||
|
chart.yTitle = ui->yTitleEdit->text();
|
||||||
|
chart.xMin = ui->xMinSpinBox->value();
|
||||||
|
chart.xMax = ui->xMaxSpinBox->value();
|
||||||
|
chart.xCount = ui->xCountSpinBox->value();
|
||||||
|
chart.yMin = ui->yMinSpinBox->value();
|
||||||
|
chart.yMax = ui->yMaxSpinBox->value();
|
||||||
|
chart.timeParam = ui->timeParamSpinBox->value();
|
||||||
|
return chart;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<AddCurveFileDlg::CurveProperties> AddCurveFileDlg::getCurveProperties() const {
|
||||||
|
return curves_;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddCurveFileDlg::DataFormatParams AddCurveFileDlg::getDataFormatParams() const {
|
||||||
|
DataFormatParams format;
|
||||||
|
|
||||||
|
// Get delimiter based on combo box selection
|
||||||
|
QString delimiterText = ui->separatorComboBox->currentText();
|
||||||
|
if (delimiterText.contains("Comma")) {
|
||||||
|
format.delimiter = ",";
|
||||||
|
} else if (delimiterText.contains("Tab")) {
|
||||||
|
format.delimiter = "\t";
|
||||||
|
} else if (delimiterText.contains("Space")) {
|
||||||
|
format.delimiter = " ";
|
||||||
|
} else if (delimiterText.contains("Semicolon")) {
|
||||||
|
format.delimiter = ";";
|
||||||
|
} else {
|
||||||
|
format.delimiter = ","; // Default
|
||||||
|
}
|
||||||
|
|
||||||
|
format.hasHeader = ui->hasHeaderCheckBox->isChecked();
|
||||||
|
format.xColumn = ui->xColumnSpinBox->value();
|
||||||
|
format.yColumn = ui->yColumnSpinBox->value();
|
||||||
|
format.description = ui->descriptionEdit->toPlainText();
|
||||||
|
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onDelimiterChanged() {
|
||||||
|
// This slot can be used for future delimiter-related logic
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onHeaderToggled(bool hasHeader) {
|
||||||
|
// This slot can be used for future header-related logic
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddCurveFileDlg::onSure() {
|
||||||
|
if (validateSpecificParams()) {
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
108
src/ui/WorkSpace/AddCurveFileDlg.h
Normal file
108
src/ui/WorkSpace/AddCurveFileDlg.h
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BaseAddFileDlg.h"
|
||||||
|
#include <QColor>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
class QCheckBox;
|
||||||
|
class QSpinBox;
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
class QComboBox;
|
||||||
|
class QTextEdit;
|
||||||
|
class QToolButton;
|
||||||
|
class QLabel;
|
||||||
|
class QPushButton;
|
||||||
|
class QListWidget;
|
||||||
|
class QListWidgetItem;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AddCurveFileDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddCurveFileDlg : public BaseAddFileDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Chart properties structure
|
||||||
|
struct ChartProperties {
|
||||||
|
QString name;
|
||||||
|
QString path;
|
||||||
|
QString xTitle;
|
||||||
|
QString yTitle;
|
||||||
|
double xMin;
|
||||||
|
double xMax;
|
||||||
|
int xCount;
|
||||||
|
double yMin;
|
||||||
|
double yMax;
|
||||||
|
double timeParam;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Curve properties structure
|
||||||
|
struct CurveProperties {
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
int start;
|
||||||
|
int stop;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Data format parameters structure
|
||||||
|
struct DataFormatParams {
|
||||||
|
QString delimiter;
|
||||||
|
bool hasHeader;
|
||||||
|
int xColumn;
|
||||||
|
int yColumn;
|
||||||
|
QString description;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Combined parameters structure
|
||||||
|
struct CurveParams {
|
||||||
|
ChartProperties chart;
|
||||||
|
QList<CurveProperties> curves; // Changed to support multiple curves
|
||||||
|
DataFormatParams format;
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit AddCurveFileDlg(QWidget* parent = nullptr);
|
||||||
|
~AddCurveFileDlg() override;
|
||||||
|
|
||||||
|
CurveParams getCurveParams() const;
|
||||||
|
ChartProperties getChartProperties() const;
|
||||||
|
QList<CurveProperties> getCurveProperties() const; // Changed to return list
|
||||||
|
DataFormatParams getDataFormatParams() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString getFileFilter() const override;
|
||||||
|
QString getDialogTitle() const override;
|
||||||
|
void setupSpecificUI() override;
|
||||||
|
bool validateSpecificParams() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDelimiterChanged();
|
||||||
|
void onHeaderToggled(bool hasHeader);
|
||||||
|
void onSelectFileClicked();
|
||||||
|
void onFilePathChanged();
|
||||||
|
void onColorButtonClicked();
|
||||||
|
void onAddCurveClicked();
|
||||||
|
void onRemoveCurveClicked();
|
||||||
|
void onCurveSelectionChanged();
|
||||||
|
void onCurveNameChanged();
|
||||||
|
void onCurveDataChanged();
|
||||||
|
void onSure();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupConnections();
|
||||||
|
void updateFileInfo(const QString& filePath);
|
||||||
|
void updateColorPreview(const QColor& color);
|
||||||
|
void addCurveToList(const CurveProperties& curve);
|
||||||
|
void updateCurveProperties();
|
||||||
|
void saveCurveProperties();
|
||||||
|
void clearCurveProperties();
|
||||||
|
void enableCurveProperties(bool enabled);
|
||||||
|
QString generateCurveName();
|
||||||
|
QColor generateCurveColor() const;
|
||||||
|
|
||||||
|
Ui::AddCurveFileDlg* ui;
|
||||||
|
QList<CurveProperties> curves_;
|
||||||
|
int currentCurveIndex_;
|
||||||
|
QColor selectedColor_;
|
||||||
|
};
|
||||||
615
src/ui/WorkSpace/AddCurveFileDlg.ui
Normal file
615
src/ui/WorkSpace/AddCurveFileDlg.ui
Normal file
@ -0,0 +1,615 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddCurveFileDlg</class>
|
||||||
|
<widget class="QWidget" name="AddCurveFileDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>600</width>
|
||||||
|
<height>700</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Add Curve Data File</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="fileGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>File Selection</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="fileGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="filePathLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Path:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="filePathEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Select curve data file...</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="selectFileBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="fileNameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileNameValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="fileSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileSizeValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="chartGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Chart Properties</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="chartGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="chartNameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Chart Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="chartNameEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Chart 1</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Enter chart name...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="xTitleLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Axis Title:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="xTitleEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Enter X axis title...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="yTitleLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Axis Title:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="yTitleEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Enter Y axis title...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="timeParamLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Time Parameter:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="timeParamSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="axisRangeGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Axis Range Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="axisRangeGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="xMinLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Min:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="xMinSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="xMaxLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Max:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QDoubleSpinBox" name="xMaxSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>250.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="yMinLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Min:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="yMinSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>-800.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLabel" name="yMaxLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Max:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QDoubleSpinBox" name="yMaxSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>800.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="xCountLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Tick Count:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="xCountSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="curveGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Curve Management</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="curveVerticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="curveButtonLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="curveListLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Curves:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="curveButtonSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addCurveBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add Curve</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="removeCurveBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="curveListWidget">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>120</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="curvePropertiesGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Selected Curve Properties</string>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="curvePropertiesGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="curveNameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Curve Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="curveNameEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Enter curve name...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="curveColorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Curve Color:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="colorLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="colorButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select Color</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="colorPreview">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string>background-color: rgb(255, 0, 0); border: 1px solid black;</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="colorSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="dataStartLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Data Start:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="dataStartSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="dataStopLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Data Stop:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QSpinBox" name="dataStopSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>241</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="paramsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Data Format Parameters</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="paramsGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="xColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="xColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="yColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="yColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="separatorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Separator:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="separatorComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Comma (,)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tab</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Space</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Semicolon (;)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</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>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</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>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="buttonLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add File</string>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancelBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
22
src/ui/WorkSpace/AddFileDialogFactory.cpp
Normal file
22
src/ui/WorkSpace/AddFileDialogFactory.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "AddFileDialogFactory.h"
|
||||||
|
|
||||||
|
#include "BaseAddFileDlg.h"
|
||||||
|
#include "AddCurveFileDlg.h"
|
||||||
|
#include "AddSurfaceFileDlg.h"
|
||||||
|
#include "AddTableFileDlg.h"
|
||||||
|
#include "AddLightFileDlg.h"
|
||||||
|
|
||||||
|
BaseAddFileDlg* AddFileDialogFactory::createDialog(FileEntryType type, QWidget* parent) {
|
||||||
|
switch (type) {
|
||||||
|
case FileEntryType::Curve:
|
||||||
|
return new AddCurveFileDlg(parent);
|
||||||
|
case FileEntryType::Surface:
|
||||||
|
return new AddSurfaceFileDlg(parent);
|
||||||
|
case FileEntryType::Table:
|
||||||
|
return new AddTableFileDlg(parent);
|
||||||
|
case FileEntryType::Light:
|
||||||
|
return new AddLightFileDlg(parent);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/ui/WorkSpace/AddFileDialogFactory.h
Normal file
15
src/ui/WorkSpace/AddFileDialogFactory.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "workspace/FileEntry.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class BaseAddFileDlg;
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
|
class AddFileDialogFactory {
|
||||||
|
public:
|
||||||
|
static BaseAddFileDlg* createDialog(FileEntryType fileType, QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AddFileDialogFactory() = default;
|
||||||
|
};
|
||||||
@ -1,125 +0,0 @@
|
|||||||
#include "AddFileDlg.h"
|
|
||||||
#include "ui_AddFileDlg.h"
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include "app/Application.h"
|
|
||||||
#include "common/SpdLogger.h"
|
|
||||||
|
|
||||||
AddFileDlg::AddFileDlg(QWidget* parent)
|
|
||||||
: Dialog(parent)
|
|
||||||
, ui(new Ui::AddFileDlg)
|
|
||||||
, selectedFileType_(FileEntryType::Curve) {
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
// 设置对话框标题
|
|
||||||
SetTitle(QStringLiteral("Add File to Workspace"));
|
|
||||||
|
|
||||||
InitConnect();
|
|
||||||
UpdateUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
AddFileDlg::~AddFileDlg() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFileDlg::InitConnect() {
|
|
||||||
connect(ui->tbSelectFile, &QToolButton::clicked, this, &AddFileDlg::OnSelectFile);
|
|
||||||
connect(ui->cbFileType, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
||||||
this, &AddFileDlg::OnFileTypeChanged);
|
|
||||||
connect(ui->pbAdd, &QPushButton::clicked, this, &AddFileDlg::OnSure);
|
|
||||||
connect(ui->pbCancel, &QPushButton::clicked, this, &AddFileDlg::reject);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFileDlg::OnSelectFile() {
|
|
||||||
const QString workspacePath = Application::GetWorkSpacePath();
|
|
||||||
QString filePath = QFileDialog::getOpenFileName(
|
|
||||||
this,
|
|
||||||
QStringLiteral("Select File"),
|
|
||||||
workspacePath,
|
|
||||||
QStringLiteral("Text Files (*.txt);;All Files (*.*)")
|
|
||||||
);
|
|
||||||
|
|
||||||
if (filePath.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedFilePath_ = filePath;
|
|
||||||
ui->leFilePath->setText(filePath);
|
|
||||||
|
|
||||||
QFileInfo fileInfo(filePath);
|
|
||||||
ui->lblFileName->setText(fileInfo.fileName());
|
|
||||||
|
|
||||||
qint64 size = fileInfo.size();
|
|
||||||
QString sizeText;
|
|
||||||
if (size < 1024) {
|
|
||||||
sizeText = QString("%1 B").arg(size);
|
|
||||||
} else if (size < 1024 * 1024) {
|
|
||||||
sizeText = QString("%1 KB").arg(size / 1024.0, 0, 'f', 1);
|
|
||||||
} else {
|
|
||||||
sizeText = QString("%1 MB").arg(size / (1024.0 * 1024.0), 0, 'f', 1);
|
|
||||||
}
|
|
||||||
ui->lblFileSize->setText(sizeText);
|
|
||||||
|
|
||||||
LOG_INFO("Selected file: {}", filePath.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFileDlg::OnFileTypeChanged() {
|
|
||||||
int index = ui->cbFileType->currentIndex();
|
|
||||||
switch (index) {
|
|
||||||
case 0: selectedFileType_ = FileEntryType::Curve; break;
|
|
||||||
case 1: selectedFileType_ = FileEntryType::Surface; break;
|
|
||||||
case 2: selectedFileType_ = FileEntryType::Table; break;
|
|
||||||
case 3: selectedFileType_ = FileEntryType::Light; break;
|
|
||||||
default: selectedFileType_ = FileEntryType::Curve; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO("File type changed to: {}", static_cast<int>(selectedFileType_));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFileDlg::OnSure() {
|
|
||||||
if (!ValidateInput()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddFileDlg::UpdateUI() {
|
|
||||||
ui->lblFileName->setText(QStringLiteral("-"));
|
|
||||||
ui->lblFileSize->setText(QStringLiteral("-"));
|
|
||||||
ui->cbFileType->setCurrentIndex(0);
|
|
||||||
selectedFileType_ = FileEntryType::Curve;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AddFileDlg::ValidateInput() {
|
|
||||||
if (selectedFilePath_.isEmpty()) {
|
|
||||||
QMessageBox::warning(this, QStringLiteral("Warning"),
|
|
||||||
QStringLiteral("Please select a file first."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFileInfo fileInfo(selectedFilePath_);
|
|
||||||
if (!fileInfo.exists()) {
|
|
||||||
QMessageBox::warning(this, QStringLiteral("Warning"),
|
|
||||||
QStringLiteral("Selected file does not exist."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileEntryType AddFileDlg::getSelectedFileType() const {
|
|
||||||
return selectedFileType_;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AddFileDlg::getSelectedFilePath() const {
|
|
||||||
return selectedFilePath_;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AddFileDlg::getDescription() const {
|
|
||||||
return ui->teDescription->toPlainText().trimmed();
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ui/Dialog.h"
|
|
||||||
#include "workspace/FileEntry.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class AddFileDlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AddFileDlg : public Dialog {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
AddFileDlg(QWidget* parent = nullptr);
|
|
||||||
~AddFileDlg() override;
|
|
||||||
|
|
||||||
FileEntryType getSelectedFileType() const;
|
|
||||||
|
|
||||||
QString getSelectedFilePath() const;
|
|
||||||
|
|
||||||
QString getDescription() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void InitConnect();
|
|
||||||
void OnSure();
|
|
||||||
void OnSelectFile();
|
|
||||||
void OnFileTypeChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void UpdateUI();
|
|
||||||
bool ValidateInput();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::AddFileDlg* ui;
|
|
||||||
QString selectedFilePath_;
|
|
||||||
FileEntryType selectedFileType_;
|
|
||||||
};
|
|
||||||
@ -1,266 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>AddFileDlg</class>
|
|
||||||
<widget class="QWidget" name="AddFileDlg">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>480</width>
|
|
||||||
<height>320</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Add File to Workspace</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_main">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_file">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_file">
|
|
||||||
<property name="text">
|
|
||||||
<string>File Path</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>80</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="leFilePath">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Select file to add...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="tbSelectFile">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>25</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_type">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_type">
|
|
||||||
<property name="text">
|
|
||||||
<string>File Type</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>80</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cbFileType">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Curve Data</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Surface Data</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Table Data</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Light Data</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_type">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_preview">
|
|
||||||
<property name="title">
|
|
||||||
<string>File Information</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_preview">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_info">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_fileName">
|
|
||||||
<property name="text">
|
|
||||||
<string>File Name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lblFileName">
|
|
||||||
<property name="text">
|
|
||||||
<string>-</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_info1">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_size">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_fileSize">
|
|
||||||
<property name="text">
|
|
||||||
<string>File Size:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lblFileSize">
|
|
||||||
<property name="text">
|
|
||||||
<string>-</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_info2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_desc">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_desc">
|
|
||||||
<property name="text">
|
|
||||||
<string>Description (Optional)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="teDescription">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>60</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Enter file description...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</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>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_buttons">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_buttons">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbAdd">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add File</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>80</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbCancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>80</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
70
src/ui/WorkSpace/AddLightFileDlg.cpp
Normal file
70
src/ui/WorkSpace/AddLightFileDlg.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include "AddLightFileDlg.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include "ui_AddLightFileDlg.h"
|
||||||
|
|
||||||
|
AddLightFileDlg::AddLightFileDlg(QWidget* parent)
|
||||||
|
: BaseAddFileDlg(FileEntryType::Light, parent)
|
||||||
|
, ui(new Ui::AddLightFileDlg) {
|
||||||
|
|
||||||
|
ui->setupUi(this);
|
||||||
|
SetTitle(getDialogTitle());
|
||||||
|
setupSpecificUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddLightFileDlg::~AddLightFileDlg() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddLightFileDlg::setupSpecificUI() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AddLightFileDlg::validateSpecificParams() {
|
||||||
|
LightParams params = getLightParams();
|
||||||
|
|
||||||
|
if (params.delimiter.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("Please specify a delimiter for light data."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddLightFileDlg::getFileFilter() const {
|
||||||
|
return QStringLiteral("Light Spectrum Files (*.txt *.csv *.dat *.spe *.asc);;All Files (*.*)");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddLightFileDlg::getDialogTitle() const {
|
||||||
|
return QStringLiteral("Add Light Spectrum File");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddLightFileDlg::onDelimiterChanged() {
|
||||||
|
// Handle delimiter change if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddLightFileDlg::onHeaderToggled(bool hasHeader) {
|
||||||
|
// Handle header toggle if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
AddLightFileDlg::LightParams AddLightFileDlg::getLightParams() const {
|
||||||
|
LightParams params;
|
||||||
|
params.wavelengthColumn = ui->wavelengthColumnSpinBox->value();
|
||||||
|
params.intensityColumn = ui->intensityColumnSpinBox->value();
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
params.description = ui->descriptionEdit->toPlainText().trimmed();
|
||||||
|
return params;
|
||||||
|
}
|
||||||
39
src/ui/WorkSpace/AddLightFileDlg.h
Normal file
39
src/ui/WorkSpace/AddLightFileDlg.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AddLightFileDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "BaseAddFileDlg.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AddLightFileDlg : public BaseAddFileDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct LightParams {
|
||||||
|
QString delimiter;
|
||||||
|
bool hasHeader;
|
||||||
|
int wavelengthColumn;
|
||||||
|
int intensityColumn;
|
||||||
|
QString description;
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit AddLightFileDlg(QWidget* parent = nullptr);
|
||||||
|
~AddLightFileDlg() override;
|
||||||
|
|
||||||
|
LightParams getLightParams() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString getFileFilter() const override;
|
||||||
|
QString getDialogTitle() const override;
|
||||||
|
void setupSpecificUI() override;
|
||||||
|
bool validateSpecificParams() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDelimiterChanged();
|
||||||
|
void onHeaderToggled(bool hasHeader);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AddLightFileDlg* ui;
|
||||||
|
};
|
||||||
372
src/ui/WorkSpace/AddLightFileDlg.ui
Normal file
372
src/ui/WorkSpace/AddLightFileDlg.ui
Normal file
@ -0,0 +1,372 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddLightFileDlg</class>
|
||||||
|
<widget class="QWidget" name="AddLightFileDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>500</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Add Light Spectrum File</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="fileGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>File Selection</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="fileGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="filePathLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Path:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="filePathEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Select light spectrum file...</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="selectFileBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="fileNameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileNameValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="fileSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileSizeValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="paramsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Spectrum Parameters</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="paramsGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="wavelengthColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Wavelength Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="wavelengthColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="intensityColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Intensity Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="intensityColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="separatorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Separator:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="separatorComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Comma (,)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tab</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Space</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Semicolon (;)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="wavelengthUnitLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Wavelength Unit:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="wavelengthUnitComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>nm (nanometer)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>μm (micrometer)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>cm⁻¹ (wavenumber)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>eV (electron volt)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="intensityUnitLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Intensity Unit:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="intensityUnitComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Arbitrary Units</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Counts</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>W/m²/nm</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>μW/cm²/nm</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" 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="6" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="normalizeCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Normalize intensity values</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="rangeGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Wavelength Range (Optional)</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="rangeGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="minWavelengthLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Min Wavelength:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="minWavelengthSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>10000.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>380.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="maxWavelengthLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Max Wavelength:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="maxWavelengthSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>10000.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>780.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="enableRangeCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable wavelength range filtering</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</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>
|
||||||
|
<layout class="QHBoxLayout" name="buttonLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add File</string>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancelBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
140
src/ui/WorkSpace/AddSurfaceFileDlg.cpp
Normal file
140
src/ui/WorkSpace/AddSurfaceFileDlg.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
#include "AddSurfaceFileDlg.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include "app/Application.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
|
#include "ui_AddSurfaceFileDlg.h"
|
||||||
|
|
||||||
|
AddSurfaceFileDlg::AddSurfaceFileDlg(QWidget* parent)
|
||||||
|
: BaseAddFileDlg(FileEntryType::Surface, parent)
|
||||||
|
, ui_(new Ui::AddSurfaceFileDlg) {
|
||||||
|
|
||||||
|
ui_->setupUi(this);
|
||||||
|
SetTitle(getDialogTitle());
|
||||||
|
setupSpecificUI();
|
||||||
|
setupConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSurfaceFileDlg::~AddSurfaceFileDlg() {
|
||||||
|
delete ui_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSurfaceFileDlg::setupSpecificUI() {
|
||||||
|
// UI is already set up in constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSurfaceFileDlg::setupConnections() {
|
||||||
|
connect(ui_->selectFileBtn, &QToolButton::clicked, this, &AddSurfaceFileDlg::onSelectFileClicked);
|
||||||
|
connect(ui_->filePathEdit, &QLineEdit::textChanged, this, &AddSurfaceFileDlg::onFilePathChanged);
|
||||||
|
connect(ui_->addBtn, &QPushButton::clicked, this, [this]() { OnSure(); });
|
||||||
|
connect(ui_->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSurfaceFileDlg::onSelectFileClicked() {
|
||||||
|
const QString workspacePath = Application::GetWorkSpacePath();
|
||||||
|
QString filePath = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
QStringLiteral("Select Surface Data File"),
|
||||||
|
workspacePath,
|
||||||
|
getFileFilter()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (filePath.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_->filePathEdit->setText(filePath);
|
||||||
|
updateFileInfo(filePath);
|
||||||
|
|
||||||
|
LOG_INFO("Selected surface file: {}", filePath.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSurfaceFileDlg::onFilePathChanged() {
|
||||||
|
QString filePath = ui_->filePathEdit->text();
|
||||||
|
if (!filePath.isEmpty()) {
|
||||||
|
updateFileInfo(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSurfaceFileDlg::updateFileInfo(const QString& filePath) {
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
ui_->fileNameValue->setText(fileInfo.fileName());
|
||||||
|
|
||||||
|
qint64 size = fileInfo.size();
|
||||||
|
QString sizeText;
|
||||||
|
if (size < 1024) {
|
||||||
|
sizeText = QString("%1 B").arg(size);
|
||||||
|
} else if (size < 1024 * 1024) {
|
||||||
|
sizeText = QString("%1 KB").arg(size / 1024.0, 0, 'f', 1);
|
||||||
|
} else {
|
||||||
|
sizeText = QString("%1 MB").arg(size / (1024.0 * 1024.0), 0, 'f', 1);
|
||||||
|
}
|
||||||
|
ui_->fileSizeValue->setText(sizeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AddSurfaceFileDlg::validateSpecificParams() {
|
||||||
|
if (ui_->filePathEdit->text().isEmpty()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("Please select a surface data file."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo fileInfo(ui_->filePathEdit->text());
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("The selected file does not exist."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui_->xColumnSpinBox->value() == ui_->yColumnSpinBox->value() ||
|
||||||
|
ui_->xColumnSpinBox->value() == ui_->zColumnSpinBox->value() ||
|
||||||
|
ui_->yColumnSpinBox->value() == ui_->zColumnSpinBox->value()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("X, Y, and Z columns must be different."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddSurfaceFileDlg::getFileFilter() const {
|
||||||
|
return QStringLiteral("Surface Data Files (*.txt *.csv *.dat *.xyz);;All Files (*.*)");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddSurfaceFileDlg::getDialogTitle() const {
|
||||||
|
return QStringLiteral("Add Surface Data File");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddSurfaceFileDlg::getSelectedFilePath() const {
|
||||||
|
return ui_->filePathEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddSurfaceFileDlg::getDescription() const {
|
||||||
|
return ui_->descriptionEdit->toPlainText().trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSurfaceFileDlg::SurfaceParams AddSurfaceFileDlg::getSurfaceParams() const {
|
||||||
|
SurfaceParams params;
|
||||||
|
params.xColumn = ui_->xColumnSpinBox->value();
|
||||||
|
params.yColumn = ui_->yColumnSpinBox->value();
|
||||||
|
params.zColumn = ui_->zColumnSpinBox->value();
|
||||||
|
params.xGridSize = ui_->xGridSizeSpinBox->value();
|
||||||
|
params.yGridSize = ui_->yGridSizeSpinBox->value();
|
||||||
|
params.hasHeader = ui_->hasHeaderCheckBox->isChecked();
|
||||||
|
params.description = ui_->descriptionEdit->toPlainText().trimmed();
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
57
src/ui/WorkSpace/AddSurfaceFileDlg.h
Normal file
57
src/ui/WorkSpace/AddSurfaceFileDlg.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BaseAddFileDlg.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QLineEdit;
|
||||||
|
class QCheckBox;
|
||||||
|
class QSpinBox;
|
||||||
|
class QComboBox;
|
||||||
|
class QTextEdit;
|
||||||
|
class QToolButton;
|
||||||
|
class QLabel;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AddSurfaceFileDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddSurfaceFileDlg : public BaseAddFileDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct SurfaceParams {
|
||||||
|
QString delimiter;
|
||||||
|
bool hasHeader;
|
||||||
|
int xColumn;
|
||||||
|
int yColumn;
|
||||||
|
int zColumn;
|
||||||
|
int xGridSize;
|
||||||
|
int yGridSize;
|
||||||
|
QString description;
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit AddSurfaceFileDlg(QWidget* parent = nullptr);
|
||||||
|
~AddSurfaceFileDlg() override;
|
||||||
|
|
||||||
|
SurfaceParams getSurfaceParams() const;
|
||||||
|
QString getSelectedFilePath() const;
|
||||||
|
QString getDescription() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString getFileFilter() const override;
|
||||||
|
QString getDialogTitle() const override;
|
||||||
|
void setupSpecificUI() override;
|
||||||
|
bool validateSpecificParams() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onSelectFileClicked();
|
||||||
|
void onFilePathChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupConnections();
|
||||||
|
void updateFileInfo(const QString& filePath);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AddSurfaceFileDlg* ui_;
|
||||||
|
};
|
||||||
301
src/ui/WorkSpace/AddSurfaceFileDlg.ui
Normal file
301
src/ui/WorkSpace/AddSurfaceFileDlg.ui
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddSurfaceFileDlg</class>
|
||||||
|
<widget class="QWidget" name="AddSurfaceFileDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>500</width>
|
||||||
|
<height>520</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Add Surface Data File</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="fileGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>File Selection</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="fileGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="filePathLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Path:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="filePathEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Select surface data file...</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="selectFileBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="fileNameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileNameValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="fileSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileSizeValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="paramsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Surface Parameters</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="paramsGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="xColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="xColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="yColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="yColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="zColumnLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Z Column:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="zColumnSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="separatorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Separator:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="separatorComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Comma (,)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tab</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Space</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Semicolon (;)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="xGridSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>X Grid Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QSpinBox" name="xGridSizeSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>10000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="yGridSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Grid Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QSpinBox" name="yGridSizeSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>10000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" 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>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</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>80</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>
|
||||||
|
<layout class="QHBoxLayout" name="buttonLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add File</string>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancelBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
135
src/ui/WorkSpace/AddTableFileDlg.cpp
Normal file
135
src/ui/WorkSpace/AddTableFileDlg.cpp
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
#include "AddTableFileDlg.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "app/Application.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
|
#include "ui_AddTableFileDlg.h"
|
||||||
|
|
||||||
|
|
||||||
|
AddTableFileDlg::AddTableFileDlg(QWidget* parent)
|
||||||
|
: BaseAddFileDlg(FileEntryType::Table, parent)
|
||||||
|
, ui(new Ui::AddTableFileDlg) {
|
||||||
|
|
||||||
|
ui->setupUi(this);
|
||||||
|
SetTitle(getDialogTitle());
|
||||||
|
setupSpecificUI();
|
||||||
|
setupConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTableFileDlg::~AddTableFileDlg() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::setupSpecificUI() {
|
||||||
|
// UI is already set up in constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::setupConnections() {
|
||||||
|
// Connect file selection
|
||||||
|
connect(ui->selectFileBtn, &QToolButton::clicked, this, &AddTableFileDlg::onSelectFileClicked);
|
||||||
|
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->addBtn, &QPushButton::clicked, this, [this]() { OnSure(); });
|
||||||
|
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::onSelectFileClicked() {
|
||||||
|
const QString workspacePath = Application::GetWorkSpacePath();
|
||||||
|
QString filePath = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
QStringLiteral("Select Table File"),
|
||||||
|
workspacePath,
|
||||||
|
getFileFilter()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!filePath.isEmpty()) {
|
||||||
|
ui->filePathEdit->setText(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::onFilePathChanged(const QString& filePath) {
|
||||||
|
updateFileInfo(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::updateFileInfo(const QString& filePath) {
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
ui->fileNameValue->setText(fileInfo.fileName());
|
||||||
|
|
||||||
|
qint64 size = fileInfo.size();
|
||||||
|
QString sizeText;
|
||||||
|
if (size < 1024) {
|
||||||
|
sizeText = QString("%1 B").arg(size);
|
||||||
|
} else if (size < 1024 * 1024) {
|
||||||
|
sizeText = QString("%1 KB").arg(size / 1024.0, 0, 'f', 1);
|
||||||
|
} else {
|
||||||
|
sizeText = QString("%1 MB").arg(size / (1024.0 * 1024.0), 0, 'f', 1);
|
||||||
|
}
|
||||||
|
ui->fileSizeValue->setText(sizeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::onDelimiterChanged() {
|
||||||
|
// Handle delimiter change if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTableFileDlg::onHeaderToggled(bool hasHeader) {
|
||||||
|
// Handle header toggle if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AddTableFileDlg::validateSpecificParams() {
|
||||||
|
if (ui->filePathEdit->text().isEmpty()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("Please select a table file first."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo fileInfo(ui->filePathEdit->text());
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("Selected file does not exist."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddTableFileDlg::getFileFilter() const {
|
||||||
|
return QStringLiteral("Table Files (*.txt *.csv *.tsv *.dat);;All Files (*.*)");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddTableFileDlg::getDialogTitle() const {
|
||||||
|
return QStringLiteral("Add Table Data File");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddTableFileDlg::getSelectedFilePath() const {
|
||||||
|
return ui->filePathEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddTableFileDlg::getDescription() const {
|
||||||
|
return ui->descriptionEdit->toPlainText().trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddTableFileDlg::TableParams AddTableFileDlg::getTableParams() const {
|
||||||
|
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();
|
||||||
|
params.xColumn = 1; // Default values
|
||||||
|
params.yColumn = 2;
|
||||||
|
params.description = ui->descriptionEdit->toPlainText().trimmed();
|
||||||
|
return params;
|
||||||
|
}
|
||||||
45
src/ui/WorkSpace/AddTableFileDlg.h
Normal file
45
src/ui/WorkSpace/AddTableFileDlg.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AddTableFileDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "BaseAddFileDlg.h"
|
||||||
|
|
||||||
|
class AddTableFileDlg : public BaseAddFileDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct TableParams {
|
||||||
|
QString delimiter;
|
||||||
|
bool hasHeader;
|
||||||
|
int xColumn;
|
||||||
|
int yColumn;
|
||||||
|
QString description;
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit AddTableFileDlg(QWidget* parent = nullptr);
|
||||||
|
~AddTableFileDlg() override;
|
||||||
|
|
||||||
|
TableParams getTableParams() const;
|
||||||
|
QString getSelectedFilePath() const;
|
||||||
|
QString getDescription() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString getFileFilter() const override;
|
||||||
|
QString getDialogTitle() const override;
|
||||||
|
void setupSpecificUI() override;
|
||||||
|
bool validateSpecificParams() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onSelectFileClicked();
|
||||||
|
void onFilePathChanged(const QString& filePath);
|
||||||
|
void onDelimiterChanged();
|
||||||
|
void onHeaderToggled(bool hasHeader);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupConnections();
|
||||||
|
void updateFileInfo(const QString& filePath);
|
||||||
|
|
||||||
|
Ui::AddTableFileDlg* ui;
|
||||||
|
};
|
||||||
293
src/ui/WorkSpace/AddTableFileDlg.ui
Normal file
293
src/ui/WorkSpace/AddTableFileDlg.ui
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AddTableFileDlg</class>
|
||||||
|
<widget class="QWidget" name="AddTableFileDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>480</width>
|
||||||
|
<height>450</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Add Table Data File</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="fileGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>File Selection</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="fileGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="filePathLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Path:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="filePathEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Select table data file...</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="selectFileBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="fileNameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileNameValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="fileSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="fileSizeValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="paramsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Table Parameters</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="paramsGridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="separatorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Separator:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="separatorComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Comma (,)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tab</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Space</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Semicolon (;)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="encodingLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Encoding:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="encodingComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>UTF-8</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>GBK</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>ASCII</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>ISO-8859-1</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<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">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</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>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="previewGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Preview</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="previewVerticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableWidget" name="previewTable">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>120</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="rowCount">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</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>
|
||||||
|
<layout class="QHBoxLayout" name="buttonLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add File</string>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancelBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
161
src/ui/WorkSpace/BaseAddFileDlg.cpp
Normal file
161
src/ui/WorkSpace/BaseAddFileDlg.cpp
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
#include "BaseAddFileDlg.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "app/Application.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
|
BaseAddFileDlg::BaseAddFileDlg(FileEntryType fileType, QWidget* parent)
|
||||||
|
: Dialog(parent)
|
||||||
|
, fileType_(fileType)
|
||||||
|
, leFilePath_(nullptr)
|
||||||
|
, tbSelectFile_(nullptr)
|
||||||
|
, lblFileName_(nullptr)
|
||||||
|
, lblFileSize_(nullptr)
|
||||||
|
, teDescription_(nullptr) {
|
||||||
|
|
||||||
|
//setupBaseUI();
|
||||||
|
initBaseConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseAddFileDlg::~BaseAddFileDlg() {
|
||||||
|
}
|
||||||
|
|
||||||
|
FileEntryType BaseAddFileDlg::getSelectedFileType() const {
|
||||||
|
return fileType_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BaseAddFileDlg::getSelectedFilePath() const {
|
||||||
|
return selectedFilePath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BaseAddFileDlg::getDescription() const {
|
||||||
|
return teDescription_->toPlainText().trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseAddFileDlg::setupBaseUI() {
|
||||||
|
setFixedSize(500, 400);
|
||||||
|
|
||||||
|
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||||
|
mainLayout->setContentsMargins(20, 20, 20, 20);
|
||||||
|
mainLayout->setSpacing(15);
|
||||||
|
|
||||||
|
QGroupBox* fileGroup = new QGroupBox(QStringLiteral("File Selection"), this);
|
||||||
|
QGridLayout* fileLayout = new QGridLayout(fileGroup);
|
||||||
|
|
||||||
|
QLabel* pathLabel = new QLabel(QStringLiteral("File Path:"), this);
|
||||||
|
leFilePath_ = new QLineEdit(this);
|
||||||
|
leFilePath_->setReadOnly(true);
|
||||||
|
tbSelectFile_ = new QToolButton(this);
|
||||||
|
tbSelectFile_->setText(QStringLiteral("..."));
|
||||||
|
tbSelectFile_->setFixedSize(30, 25);
|
||||||
|
|
||||||
|
fileLayout->addWidget(pathLabel, 0, 0);
|
||||||
|
fileLayout->addWidget(leFilePath_, 0, 1);
|
||||||
|
fileLayout->addWidget(tbSelectFile_, 0, 2);
|
||||||
|
|
||||||
|
mainLayout->addWidget(fileGroup);
|
||||||
|
|
||||||
|
QGroupBox* infoGroup = new QGroupBox(QStringLiteral("File Information"), this);
|
||||||
|
QGridLayout* infoLayout = new QGridLayout(infoGroup);
|
||||||
|
|
||||||
|
QLabel* nameLabel = new QLabel(QStringLiteral("File Name:"), this);
|
||||||
|
lblFileName_ = new QLabel(QStringLiteral("No file selected"), this);
|
||||||
|
QLabel* sizeLabel = new QLabel(QStringLiteral("File Size:"), this);
|
||||||
|
lblFileSize_ = new QLabel(QStringLiteral("0 bytes"), this);
|
||||||
|
|
||||||
|
infoLayout->addWidget(nameLabel, 0, 0);
|
||||||
|
infoLayout->addWidget(lblFileName_, 0, 1);
|
||||||
|
infoLayout->addWidget(sizeLabel, 1, 0);
|
||||||
|
infoLayout->addWidget(lblFileSize_, 1, 1);
|
||||||
|
|
||||||
|
mainLayout->addWidget(infoGroup);
|
||||||
|
|
||||||
|
QGroupBox* descGroup = new QGroupBox(QStringLiteral("Description"), this);
|
||||||
|
QVBoxLayout* descLayout = new QVBoxLayout(descGroup);
|
||||||
|
teDescription_ = new QTextEdit(this);
|
||||||
|
teDescription_->setMaximumHeight(80);
|
||||||
|
descLayout->addWidget(teDescription_);
|
||||||
|
mainLayout->addWidget(descGroup);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseAddFileDlg::initBaseConnect() {
|
||||||
|
connect(tbSelectFile_, &QToolButton::clicked, this, &BaseAddFileDlg::OnSelectFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseAddFileDlg::OnSelectFile() {
|
||||||
|
const QString workspacePath = Application::GetWorkSpacePath();
|
||||||
|
QString filePath = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
QStringLiteral("Select File"),
|
||||||
|
workspacePath,
|
||||||
|
getFileFilter()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (filePath.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedFilePath_ = filePath;
|
||||||
|
leFilePath_->setText(filePath);
|
||||||
|
updateFileInfo(filePath);
|
||||||
|
|
||||||
|
LOG_INFO("Selected file: {}", filePath.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseAddFileDlg::OnSure() {
|
||||||
|
if (!validateBaseInput() || !validateSpecificParams()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseAddFileDlg::updateFileInfo(const QString& filePath) {
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
lblFileName_->setText(fileInfo.fileName());
|
||||||
|
|
||||||
|
qint64 size = fileInfo.size();
|
||||||
|
QString sizeText;
|
||||||
|
if (size < 1024) {
|
||||||
|
sizeText = QString("%1 B").arg(size);
|
||||||
|
} else if (size < 1024 * 1024) {
|
||||||
|
sizeText = QString("%1 KB").arg(size / 1024.0, 0, 'f', 1);
|
||||||
|
} else {
|
||||||
|
sizeText = QString("%1 MB").arg(size / (1024.0 * 1024.0), 0, 'f', 1);
|
||||||
|
}
|
||||||
|
lblFileSize_->setText(sizeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseAddFileDlg::validateBaseInput() {
|
||||||
|
if (selectedFilePath_.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("Please select a file first."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo fileInfo(selectedFilePath_);
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||||
|
QStringLiteral("Selected file does not exist."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseAddFileDlg::SetTitle(const QString& title) {
|
||||||
|
Dialog::SetTitle(title);
|
||||||
|
}
|
||||||
52
src/ui/WorkSpace/BaseAddFileDlg.h
Normal file
52
src/ui/WorkSpace/BaseAddFileDlg.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui/Dialog.h"
|
||||||
|
#include "workspace/FileEntry.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
class QLabel;
|
||||||
|
class QTextEdit;
|
||||||
|
class QToolButton;
|
||||||
|
|
||||||
|
class BaseAddFileDlg : public Dialog {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit BaseAddFileDlg(FileEntryType fileType, QWidget* parent = nullptr);
|
||||||
|
virtual ~BaseAddFileDlg();
|
||||||
|
|
||||||
|
FileEntryType getSelectedFileType() const;
|
||||||
|
QString getSelectedFilePath() const;
|
||||||
|
QString getDescription() const;
|
||||||
|
|
||||||
|
virtual bool validateSpecificParams() = 0;
|
||||||
|
virtual QString getFileFilter() const = 0;
|
||||||
|
virtual QString getDialogTitle() const = 0;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void OnSelectFile();
|
||||||
|
void OnSure();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QLineEdit* leFilePath_;
|
||||||
|
QToolButton* tbSelectFile_;
|
||||||
|
QLabel* lblFileName_;
|
||||||
|
QLabel* lblFileSize_;
|
||||||
|
QTextEdit* teDescription_;
|
||||||
|
|
||||||
|
void setupBaseUI();
|
||||||
|
void initBaseConnect();
|
||||||
|
void updateFileInfo(const QString& filePath);
|
||||||
|
bool validateBaseInput();
|
||||||
|
void SetTitle(const QString& title);
|
||||||
|
|
||||||
|
virtual void setupSpecificUI() = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FileEntryType fileType_;
|
||||||
|
QString selectedFilePath_;
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user