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