File indexing completed on 2024-05-12 16:42:19
0001 /* 0002 SPDX-FileCopyrightText: 2012 Nokia Corporation and /or its subsidiary(-ies). 0003 Contact: https://www.qt.io/developers/ 0004 0005 This file is part of the test suite of the Qt Toolkit. 0006 0007 $QT_BEGIN_LICENSE:LGPL$ 0008 GNU Lesser General Public License Usage 0009 This file may be used under the terms of the GNU Lesser General Public 0010 License version 2.1 as published by the Free Software Foundation and 0011 appearing in the file LICENSE.LGPL included in the packaging of this 0012 file. Please review the following information to ensure the GNU Lesser 0013 General Public License version 2.1 requirements will be met: 0014 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 0015 0016 In addition, as a special exception, Nokia gives you certain additional 0017 rights. These rights are described in the Nokia Qt LGPL Exception 0018 version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 0019 0020 GNU General Public License Usage 0021 Alternatively, this file may be used under the terms of the GNU General 0022 Public License version 3.0 as published by the Free Software Foundation 0023 and appearing in the file LICENSE.GPL included in the packaging of this 0024 file. Please review the following information to ensure the GNU General 0025 Public License version 3.0 requirements will be met: 0026 https://www.gnu.org/copyleft/gpl.html. 0027 0028 Other Usage 0029 Alternatively, this file may be used in accordance with the terms and 0030 conditions contained in a signed written agreement between you and Nokia. 0031 0032 0033 0034 0035 0036 0037 $QT_END_LICENSE$ 0038 0039 */ 0040 0041 0042 #ifndef MODELTEST_H 0043 #define MODELTEST_H 0044 0045 #include <QObject> 0046 #include <QAbstractItemModel> 0047 #include <QStack> 0048 0049 class ModelTest : public QObject 0050 { 0051 Q_OBJECT 0052 0053 public: 0054 explicit ModelTest( QAbstractItemModel *model, QObject *parent = 0 ); 0055 0056 private Q_SLOTS: 0057 void nonDestructiveBasicTest(); 0058 void rowCount(); 0059 void columnCount(); 0060 void hasIndex(); 0061 void index(); 0062 void parent(); 0063 void data(); 0064 0065 protected Q_SLOTS: 0066 void runAllTests(); 0067 void layoutAboutToBeChanged(); 0068 void layoutChanged(); 0069 void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end ); 0070 void rowsInserted( const QModelIndex & parent, int start, int end ); 0071 void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end ); 0072 void rowsRemoved( const QModelIndex & parent, int start, int end ); 0073 0074 private: 0075 void checkChildren( const QModelIndex &parent, int currentDepth = 0 ); 0076 0077 QAbstractItemModel *model; 0078 0079 struct Changing { 0080 QModelIndex parent; 0081 int oldSize; 0082 QVariant last; 0083 QVariant next; 0084 }; 0085 QStack<Changing> insert; 0086 QStack<Changing> remove; 0087 0088 bool fetchingMore; 0089 0090 QList<QPersistentModelIndex> changing; 0091 }; 0092 0093 #endif