[Kst] branches/work/kst/portto4/kst/src/widgets
Mike Fenton
mike at staikos.net
Tue Dec 2 18:41:37 CET 2008
SVN commit 891706 by fenton:
Add DataSource validation to DataSourceSelectorDialog.
M +24 -16 datasourceselectordialog.cpp
M +0 -1 datasourceselectordialog.h
--- branches/work/kst/portto4/kst/src/widgets/datasourceselectordialog.cpp #891705:891706
@@ -11,6 +11,8 @@
#include "datasourceselectordialog.h"
+#include "datasource.h"
+
#include <QMessageBox>
#include <QDebug>
@@ -21,8 +23,8 @@
setFileMode(QFileDialog::Directory);
selectFile(file);
+ currentChanged(file);
- connect(this, SIGNAL(directoryEntered(const QString &)), this, SLOT(directoryChanged()));
connect(this, SIGNAL(currentChanged(const QString &)), this, SLOT(currentChanged(const QString &)));
}
@@ -36,25 +38,31 @@
}
-void DataSourceSelectorDialog::directoryChanged() {
-// qDebug() << "directory changed" << directory();
-}
-
-
void DataSourceSelectorDialog::currentChanged(const QString ¤t) {
// qDebug() << "currentChanged" << current;
- QFileInfo fileInfo(current);
- if (fileInfo.isDir()) {
-// qDebug() << "Directory Selected";
- if (fileMode() != QFileDialog::Directory) {
- setFileMode(QFileDialog::Directory);
+ if (current.isEmpty()) {
+ setFileMode(QFileDialog::Directory);
+ } else {
+ QFileInfo fileInfo(current);
+ if (fileInfo.isDir()) {
+// qDebug() << "Directory Selected - valid?" << DataSource::validSource(current);
+ if (DataSource::validSource(current)) {
+ setFileMode(QFileDialog::Directory);
+ } else {
+ setFileMode(QFileDialog::ExistingFile);
+ }
+ } else if (fileInfo.exists()) {
+// qDebug() << "File Selected - valid?" << DataSource::validSource(current);
+ if (DataSource::validSource(current)) {
+ setFileMode(QFileDialog::ExistingFile);
+ } else {
+ setFileMode(QFileDialog::Directory);
+ }
}
- } else if (fileInfo.exists()) {
-// qDebug() << "File Selected";
- if (fileMode() != QFileDialog::ExistingFile) {
- setFileMode(QFileDialog::ExistingFile);
- }
}
+ QStringList filters;
+ filters << "Any files (*)";
+ setNameFilters(filters);
}
--- branches/work/kst/portto4/kst/src/widgets/datasourceselectordialog.h #891705:891706
@@ -27,7 +27,6 @@
QString selectedDataSource();
public Q_SLOTS:
- void directoryChanged();
void currentChanged(const QString ¤t);
protected:
More information about the Kst
mailing list