summaryrefslogtreecommitdiff
path: root/plugins/autotest/testtreemodel.h
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@digia.com>2014-11-11 17:30:34 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2014-12-04 13:52:16 +0100
commit9a644d1257199a58cbb208c79c33831458d4aa01 (patch)
treea23d760226baa5b601f9e17bf58d3322db4d78db /plugins/autotest/testtreemodel.h
parent0357b0e98bf049ddb2e365a6ddcace67c2f0e836 (diff)
downloadqt-creator-9a644d1257199a58cbb208c79c33831458d4aa01.tar.gz
Support sorting of test tree
Additionally preparation of filtering has been done.
Diffstat (limited to 'plugins/autotest/testtreemodel.h')
-rw-r--r--plugins/autotest/testtreemodel.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h
index 72ecf88ff4..94cb874f8e 100644
--- a/plugins/autotest/testtreemodel.h
+++ b/plugins/autotest/testtreemodel.h
@@ -24,6 +24,7 @@
#include <cplusplus/CppDocument.h>
#include <QAbstractItemModel>
+#include <QSortFilterProxyModel>
namespace {
enum ItemRole {
@@ -71,7 +72,7 @@ public:
void removeQuickTestSubtreeByFilePath(const QString &file);
void addQuickTest(TestTreeItem *newItem);
void removeAllQuickTests();
- void removeUnnamedQuickTest(const QString &filePath);
+ bool removeUnnamedQuickTests(const QString &filePath);
signals:
void testTreeModelChanged();
@@ -89,6 +90,39 @@ private:
};
+class TestTreeSortFilterModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ enum SortMode {
+ Alphabetically,
+ Naturally
+ };
+
+ enum FilterMode {
+ Basic,
+ ShowInitAndCleanup = 0x01,
+ ShowTestData = 0x02,
+ ShowAll = ShowInitAndCleanup | ShowTestData
+ };
+
+ TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent = 0);
+ void setSortMode(SortMode sortMode);
+ void setFilterMode(FilterMode filterMode);
+ void toggleFilter(FilterMode filterMode);
+ static FilterMode toFilterMode(int f);
+
+protected:
+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+ bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+
+private:
+ TestTreeModel *m_sourceModel;
+ SortMode m_sortMode;
+ FilterMode m_filterMode;
+
+};
+
} // namespace Internal
} // namespace Autotest