summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfiledialog
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@trolltech.com>2009-04-03 11:49:13 (GMT)
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-03 11:53:36 (GMT)
commit10f0b31dd1b3193bf4c068edde5979881c82ece7 (patch)
treee1953ca88f33e6cfdc78d599b12ba102194f4d62 /tests/auto/qfiledialog
parented9fe24ecce5a21f93c88c08d2034bf175808fa3 (diff)
downloadQt-10f0b31dd1b3193bf4c068edde5979881c82ece7.zip
Qt-10f0b31dd1b3193bf4c068edde5979881c82ece7.tar.gz
Qt-10f0b31dd1b3193bf4c068edde5979881c82ece7.tar.bz2
Fix a crash in QFileDialog with a proxy on it.
The main problem is that enterDirectory received a QModelIndex that can be a proxy index and not a source index if there is a proxy set on the QFileDialog. This fix basically discover some other crashes in the completer. The problem was that we didn't apply the proxy to the completer too. So we basically messed up source and proxy indexes. Both have a proxy set now and convert the model indexes if needed. Task-number:250194 Reviewed-by:jasplin
Diffstat (limited to 'tests/auto/qfiledialog')
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index b03d459..bade586 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -1526,6 +1526,42 @@ private:
};
+class sortProxy : public QSortFilterProxyModel
+{
+public:
+ sortProxy(QObject *parent) : QSortFilterProxyModel(parent)
+ {
+ }
+protected:
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
+ {
+ QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
+ const QFileInfo leftInfo(model->fileInfo(left));
+ const QFileInfo rightInfo(model->fileInfo(right));
+
+ if (leftInfo.isDir() == rightInfo.isDir())
+ return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0);
+ else if (leftInfo.isDir())
+ return(false);
+ else
+ return(true);
+ }
+};
+
+class CrashDialog : public QNonNativeFileDialog
+{
+ Q_OBJECT
+
+public:
+ CrashDialog(QWidget *parent, const QString &caption, const
+QString &dir, const QString &filter)
+ : QNonNativeFileDialog(parent, caption, dir, filter)
+ {
+ sortProxy *proxyModel = new sortProxy(this);
+ setProxyModel(proxyModel);
+ }
+};
+
void tst_QFiledialog::task227304_proxyOnFileDialog()
{
QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
@@ -1537,6 +1573,17 @@ void tst_QFiledialog::task227304_proxyOnFileDialog()
QTest::keyClick(edit, Qt::Key_S);
QTest::qWait(200);
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+
+ CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
+ dialog->setFileMode(QFileDialog::ExistingFile);
+ dialog->show();
+
+ QListView *list = qFindChild<QListView*>(dialog, "listView");
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+
}
void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior()