{
setupUi(this);
// Disable relative buttons
loadButton->setEnabled(false);
//connect signals and slots
connect(browseButton,SIGNAL(clicked()),this,SLOT(browse()));
connect(selectButton,SIGNAL(clicked()),this,SLOT(select()));
// connect(loadButton,SIGNAL(clicked()),this,SLOT(load()));
// connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(deleteInDir()));
connect(fileTypeComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
connect(deletedDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
connect(sourceDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
}
// if all the file input directory have been configured, enable OK and button.
void FileFilter::textChanged()
{
buttonBox
->button
(QDialogButtonBox::Ok)->setEnabled
((!(sourceDirComboBox
->currentText
()).
isEmpty())&&(!(deletedDirComboBox
->currentText
()).
isEmpty())&&(!(fileTypeComboBox
->currentText
()).
isEmpty()));
loadButton->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
}
void FileFilter::browse()
{
tr
("Select a directory"),
QDir::currentPath());
if (!directory.isEmpty())
{
sourceDirComboBox
->addItem
(QDir::toNativeSeparators(directory
));
sourceDirComboBox->setCurrentIndex(sourceDirComboBox->count() - 1);
}
}
// select a dir to delete files from it
void FileFilter::select()
{
tr
("Select directory"),
QDir::currentPath());
if (!directory.isEmpty())
{
deletedDirComboBox
->addItem
(QDir::toNativeSeparators(directory
));
deletedDirComboBox->setCurrentIndex(deletedDirComboBox->count() - 1);
}
}
FileFilter::FileFilter(QWidget *parent):QDialog(parent)
{
setupUi(this);
// Disable relative buttons
loadButton->setEnabled(false);
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
//connect signals and slots
connect(browseButton,SIGNAL(clicked()),this,SLOT(browse()));
connect(selectButton,SIGNAL(clicked()),this,SLOT(select()));
// connect(loadButton,SIGNAL(clicked()),this,SLOT(load()));
// connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(deleteInDir()));
connect(fileTypeComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
connect(deletedDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
connect(sourceDirComboBox,SIGNAL(currentIndexChanged(int index)), this, SLOT(textChanged()));
}
// if all the file input directory have been configured, enable OK and button.
void FileFilter::textChanged()
{
buttonBox->button(QDialogButtonBox::Ok)->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
loadButton->setEnabled((!(sourceDirComboBox->currentText()).isEmpty())&&(!(deletedDirComboBox->currentText()).isEmpty())&&(!(fileTypeComboBox->currentText()).isEmpty()));
}
void FileFilter::browse()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Select a directory"), QDir::currentPath());
if (!directory.isEmpty())
{
sourceDirComboBox->addItem(QDir::toNativeSeparators(directory));
sourceDirComboBox->setCurrentIndex(sourceDirComboBox->count() - 1);
}
}
// select a dir to delete files from it
void FileFilter::select()
{
QString directory = QFileDialog::getExistingDirectory(this,
tr("Select directory"), QDir::currentPath());
if (!directory.isEmpty())
{
deletedDirComboBox->addItem(QDir::toNativeSeparators(directory));
deletedDirComboBox->setCurrentIndex(deletedDirComboBox->count() - 1);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks