1 #include "FileDialog.h"
15 QFileDialog(parent), p_filterList(filterList), p_dir(directory) {
20 this->setOptions(QFileDialog::DontUseNativeDialog);
22 this->setWindowTitle(title);
23 this->setFileMode(QFileDialog::ExistingFiles);
25 parent->installEventFilter(
this);
26 p_appName = parent->windowTitle();
28 connect(
this, SIGNAL(accepted()),
this, SLOT(
sendSignal()));
31 this->setNameFilters(p_filterList);
33 this->setViewMode(QFileDialog::Detail);
34 if(directory.exists()) {
35 this->setDirectory(directory);
38 this->setDirectory(QDir::current());
41 p_comboBoxes = this->findChildren<QComboBox *>();
42 p_comboBoxes[0]->setEditable(
true);
43 p_comboBoxes[1]->setEditable(
true);
45 QLineEdit *lineEdit = p_comboBoxes[1]->lineEdit();
47 disconnect(lineEdit, 0, 0, 0);
48 connect(lineEdit, SIGNAL(textChanged(
const QString &)), p_comboBoxes[1],
49 SIGNAL(activated(
const QString &)));
50 connect(lineEdit, SIGNAL(editingFinished()),
this,
54 p_allPButtons = this->findChildren<QPushButton *>();
55 for(
int i = 0; i < p_allPButtons.size(); i++) {
57 disconnect(p_allPButtons[i], 0, 0, 0);
58 if(p_allPButtons[i]->text().contains(
"Open", Qt::CaseInsensitive)) {
59 connect(p_allPButtons[i], SIGNAL(clicked()),
this, SLOT(
done()));
61 if(p_allPButtons[i]->text().contains(
"Cancel", Qt::CaseInsensitive)) {
64 connect(p_allPButtons[i], SIGNAL(clicked()),
this, SLOT(
cancel()));
78 p_allPButtons[0]->setDefault(
false);
79 if(!p_filterList.contains(p_comboBoxes[1]->currentText())) {
80 p_filterList.insert(0, p_comboBoxes[1]->currentText());
81 this->setNameFilters(p_filterList);
93 p_dir = this->directory();
95 QStringList::const_iterator it = fileList.begin();
96 while(it != fileList.end()) {
97 if(!(*it).isEmpty()) {
98 emit fileSelected(*it);
132 QFileDialog::done(r);
142 p_dir = this->directory();
151 if(p_appName ==
"") {
152 p_appName = this->windowTitle();
155 QString instanceName = this->windowTitle();
157 Isis::FileName config(
"$HOME/.Isis/" + p_appName +
"/" + instanceName +
".config");
158 QSettings settings(config.
expanded(), QSettings::NativeFormat);
159 QPoint pos = settings.value(
"pos", QPoint(300, 100)).toPoint();
160 QSize size = settings.value(
"size", QSize(355, 350)).toSize();
174 if(!this->isVisible())
return;
176 if(p_appName ==
"") {
177 p_appName = this->windowTitle();
180 QString instanceName = this->windowTitle();
182 Isis::FileName config(
"$HOME/.Isis/" + p_appName +
"/" + instanceName +
".config");
183 QSettings settings(config.
expanded(), QSettings::NativeFormat);
184 settings.setValue(
"pos", pos());
185 settings.setValue(
"size", size());
203 case QEvent::Close: {