yhkylin-backup-tools/kybackup/component/myfileselect.cpp

33 lines
1008 B
C++
Raw Normal View History

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)
{
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();
}
MyFileSelect::~MyFileSelect()
{}