2021-12-26 18:15:21 +08:00
|
|
|
#include "myfileselect.h"
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QLineEdit>
|
2022-04-19 16:13:38 +08:00
|
|
|
#include "filefilterproxymodelforbackup.h"
|
2021-12-26 18:15:21 +08:00
|
|
|
|
|
|
|
MyFileSelect::MyFileSelect(QWidget* parent) :
|
|
|
|
QFileDialog(parent)
|
|
|
|
{
|
2022-06-28 14:21:01 +08:00
|
|
|
this->setViewMode(QFileDialog::Detail);
|
2021-12-26 18:15:21 +08:00
|
|
|
this->setFileMode(QFileDialog::ExistingFiles);
|
|
|
|
this->setFilter(QDir::System | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
|
2022-04-19 16:13:38 +08:00
|
|
|
FileFilterProxyModeForBackup *proxy = new FileFilterProxyModeForBackup;
|
|
|
|
this->setProxyModel(proxy);
|
|
|
|
|
2021-12-26 18:15:21 +08:00
|
|
|
QDialogButtonBox* button = this->findChild<QDialogButtonBox*>("buttonBox");
|
|
|
|
disconnect(button, SIGNAL(accepted()), this, SLOT(accept()));
|
|
|
|
connect(button, SIGNAL(accepted()), this, SLOT(goAccept()));
|
|
|
|
|
|
|
|
QLineEdit *fileNameEdit = this->findChild<QLineEdit*>("fileNameEdit");
|
|
|
|
connect(this, &MyFileSelect::currentChanged, this, [=](const QString& path){
|
|
|
|
fileNameEdit->setText(path.section('/', -1));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFileSelect::goAccept()
|
|
|
|
{
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
2022-04-26 16:06:54 +08:00
|
|
|
|
|
|
|
MyFileSelect::~MyFileSelect()
|
|
|
|
{}
|