OGS
modeltest.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 Trolltech ASA. All rights reserved.
4 **
5 ** This file is part of the Qt Concurrent project on Trolltech Labs.
6 **
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
13 **
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ****************************************************************************/
23 
24 #pragma once
25 
26 #include <QtCore/QAbstractItemModel>
27 #include <QtCore/QObject>
28 #include <QtCore/QStack>
29 
30 class ModelTest : public QObject
31 {
32  Q_OBJECT
33 
34 public:
35  ModelTest(QAbstractItemModel* model, QObject* parent = 0);
36 
37 private Q_SLOTS:
39  void rowCount();
40  void columnCount();
41  void hasIndex();
42  void index();
43  void parent();
44  void data();
45 
46 protected Q_SLOTS:
47  void runAllTests();
49  void layoutChanged();
50  void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
51  void rowsInserted(const QModelIndex & parent, int start, int end);
52  void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
53  void rowsRemoved(const QModelIndex & parent, int start, int end);
54 
55 private:
56  void checkChildren(const QModelIndex &parent, int currentDepth = 0);
57 
58  QAbstractItemModel* model;
59 
60  struct Changing
61  {
62  QModelIndex parent;
63  int oldSize;
64  QVariant last;
65  QVariant next;
66  };
67  QStack<Changing> insert;
68  QStack<Changing> remove;
69 
71 
72  QList<QPersistentModelIndex> changing;
73 };
void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
Definition: modeltest.cpp:477
void hasIndex()
Definition: modeltest.cpp:183
void parent()
Definition: modeltest.cpp:236
bool fetchingMore
Definition: modeltest.h:70
void nonDestructiveBasicTest()
Definition: modeltest.cpp:100
QAbstractItemModel * model
Definition: modeltest.h:58
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: modeltest.cpp:532
void index()
Definition: modeltest.cpp:207
void layoutChanged()
Definition: modeltest.cpp:517
void layoutAboutToBeChanged()
Definition: modeltest.cpp:511
void checkChildren(const QModelIndex &parent, int currentDepth=0)
Definition: modeltest.cpp:293
void runAllTests()
Definition: modeltest.cpp:82
void data()
Definition: modeltest.cpp:400
QList< QPersistentModelIndex > changing
Definition: modeltest.h:72
void rowsRemoved(const QModelIndex &parent, int start, int end)
Definition: modeltest.cpp:548
void rowCount()
Definition: modeltest.cpp:139
ModelTest(QAbstractItemModel *model, QObject *parent=0)
Definition: modeltest.cpp:34
QStack< Changing > remove
Definition: modeltest.h:68
QStack< Changing > insert
Definition: modeltest.h:67
void columnCount()
Definition: modeltest.cpp:165
void rowsInserted(const QModelIndex &parent, int start, int end)
Definition: modeltest.cpp:494
QModelIndex parent
Definition: modeltest.h:62