diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2010-11-23 14:31:12 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-11-23 14:31:32 (GMT) |
commit | 88dd7568fff419510a7c26ffb93d93cc276d7b3b (patch) | |
tree | b0839add85cec60827890fd5e72e253d438e2912 /tests | |
parent | ea84d7431810951aff2d6f85dca5f4ae4aeb4490 (diff) | |
download | Qt-88dd7568fff419510a7c26ffb93d93cc276d7b3b.zip Qt-88dd7568fff419510a7c26ffb93d93cc276d7b3b.tar.gz Qt-88dd7568fff419510a7c26ffb93d93cc276d7b3b.tar.bz2 |
Fix filtering of columns in QSFPM.
Fixes a crash introduced in 315c09c3873f7c5d8b785443372bf975bae47ee7
Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Reviewed-by: Olivier
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro | 5 | ||||
-rw-r--r-- | tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp | 39 |
2 files changed, 42 insertions, 2 deletions
diff --git a/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro b/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro index d2c1147..7edd4a5 100644 --- a/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro +++ b/tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro @@ -1,6 +1,7 @@ load(qttest_p4) -SOURCES += tst_qsortfilterproxymodel.cpp - +INCLUDEPATH += $$PWD/../modeltest +SOURCES += tst_qsortfilterproxymodel.cpp ../modeltest/dynamictreemodel.cpp ../modeltest/modeltest.cpp +HEADERS += ../modeltest/dynamictreemodel.h ../modeltest/modeltest.h diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 66caf4a..93b9d30 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -43,6 +43,9 @@ #include <QtTest/QtTest> #include "../../shared/util.h" +#include "dynamictreemodel.h" +#include "modeltest.h" + #include <QtCore> #include <QtGui> @@ -144,6 +147,7 @@ private slots: void testMultipleProxiesWithSelection(); void mapSelectionFromSource(); + void filteredColumns(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -3174,5 +3178,40 @@ void tst_QSortFilterProxyModel::taskQTBUG_10287_unnecessaryMapCreation() // No assert failure, it passes. } +class FilteredColumnProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + FilteredColumnProxyModel(QObject *parent = 0) + : QSortFilterProxyModel(parent) + { + + } + +protected: + bool filterAcceptsColumn(int column, const QModelIndex &source_parent) const + { + return column % 2 != 0; + } +}; + +void tst_QSortFilterProxyModel::filteredColumns() +{ + DynamicTreeModel *model = new DynamicTreeModel(this); + + FilteredColumnProxyModel *proxy = new FilteredColumnProxyModel(this); + proxy->setSourceModel(model); + + new ModelTest(proxy, this); + + ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this); + insertCommand->setNumCols(2); + insertCommand->setStartRow(0); + insertCommand->setEndRow(0); + // Parent is QModelIndex() + insertCommand->doCommand(); + +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" |