#include "KJ135WBJYAlgWidgetComponet.h" #include FileSelectWidget::FileSelectWidget( ComponentType paramtype, QWidget* parent) : QWidget(parent), paramType(paramtype) { this->m_pFileSelectButton = new QToolButton(this); this->m_pFileSelectButton->setText("Select File"); QObject::connect(m_pFileSelectButton, SIGNAL(clicked()), this, SLOT(onSelectFile())); m_pFileNameEdit = new QLineEdit(this); this->m_pFileNameLabel = new QLabel("Selected File:", this); QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(m_pFileNameLabel); layout->addWidget(m_pFileNameEdit); layout->addWidget(m_pFileSelectButton); setLayout(layout); } FileSelectWidget::~FileSelectWidget() { // Destructor implementation } void FileSelectWidget::setFileName(const QString& fileName) { this->m_pFileNameEdit->setText(fileName); } QString FileSelectWidget::getFileName() const { return this->m_pFileNameEdit->text(); } void FileSelectWidget::setLabelText(const QString& text) { this->m_pFileNameLabel->setText(text); } void FileSelectWidget::setDataTypeStr(const QString& str) { this->DataTypeStr = str; } void FileSelectWidget::onSelectFile() { if (this->paramType == ComponentType::FolderSelect) { QString folderName = QFileDialog::getExistingDirectory(this, u8"Select Folder", ""); if (!folderName.isEmpty()) { this->m_pFileNameEdit->setText(folderName); emit fileSelected(folderName); } return; } else if (this->paramType == ComponentType::FileSelect) { QString fileName = QFileDialog::getOpenFileName(this, u8"Select File", "", QString("All Files (*);;%1(*.%1)").arg(this->DataTypeStr)); if (!fileName.isEmpty()) { this->m_pFileNameEdit->setText(fileName); emit fileSelected(fileName); } return; } else {} } /*************** 复选框 **************************/ ComboxSelectWidget::ComboxSelectWidget(QWidget* parent) { } ComboxSelectWidget::~ComboxSelectWidget() { } void ComboxSelectWidget::setLabelText(const QString& text) { } void ComboxSelectWidget::setDataTypeStr(const QString& str) { } void ComboxSelectWidget::addItem(const QString& item) { } void ComboxSelectWidget::setCurrentIndex(int index) { } void ComboxSelectWidget::setCurrentText(const QString& text) { } QString ComboxSelectWidget::getCurrentText() const { return QString(); } /*************** 整数输入 **************************/ IntInputWidget::IntInputWidget(QWidget* parent) { } IntInputWidget::~IntInputWidget() { } void IntInputWidget::setLabelText(const QString& text) { } void IntInputWidget::setDataTypeStr(const QString& str) { } void IntInputWidget::setValue(int value) { } int IntInputWidget::getValue() const { return 0; } /*************** 浮点数输入 **************************/ DoubleInputWidget::DoubleInputWidget(QWidget* parent) { } DoubleInputWidget::~DoubleInputWidget() { } void DoubleInputWidget::setLabelText(const QString& text) { } void DoubleInputWidget::setDataTypeStr(const QString& str) { } void DoubleInputWidget::setValue(double value) { } double DoubleInputWidget::getValue() const { return 0.0; }