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