1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
--- ./src/gui/itemviews/qsortfilterproxymodel.cpp.orig 2010-11-20 17:54:23.000000000 -0600
+++ ./src/gui/itemviews/qsortfilterproxymodel.cpp 2011-01-07 00:40:04.000000000 -0600
@@ -782,14 +782,14 @@
if (orthogonal_source_to_proxy.isEmpty()) {
const int ortho_end = (orient == Qt::Horizontal) ? model->rowCount(source_parent) : model->columnCount(source_parent);
+ orthogonal_source_to_proxy.resize(ortho_end);
+
for (int ortho_item = 0; ortho_item < ortho_end; ++ortho_item) {
if ((orient == Qt::Horizontal) ? q->filterAcceptsRow(ortho_item, source_parent)
: q->filterAcceptsColumn(ortho_item, source_parent)) {
orthogonal_proxy_to_source.append(ortho_item);
}
}
- orthogonal_source_to_proxy.resize(orthogonal_proxy_to_source.size());
-
if (orient == Qt::Horizontal) {
// We're reacting to columnsInserted, but we've just inserted new rows. Sort them.
sort_source_rows(orthogonal_proxy_to_source, source_parent);
--- ./tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro.orig 2010-11-20 17:54:28.000000000 -0600
+++ ./tests/auto/qsortfilterproxymodel/qsortfilterproxymodel.pro 2011-01-07 00:40:04.000000000 -0600
@@ -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
--- ./tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp.orig 2010-11-20 17:54:28.000000000 -0600
+++ ./tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp 2011-01-07 00:41:02.000000000 -0600
@@ -43,6 +43,9 @@
#include <QtTest/QtTest>
#include "../../shared/util.h"
+#include "dynamictreemodel.h"
+#include "modeltest.h"
+
#include <QtCore>
#include <QtGui>
@@ -143,6 +146,7 @@
void taskQTBUG_10287_unnecessaryMapCreation();
void testMultipleProxiesWithSelection();
+ void filteredColumns();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -3135,5 +3139,40 @@
// 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"
|