File indexing completed on 2024-05-12 05:10:03

0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2016 The Qt Company Ltd.
0004 ** Contact: https://www.qt.io/licensing/
0005 **
0006 ** This file is part of the test suite of the Qt Toolkit.
0007 **
0008 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
0009 ** Commercial License Usage
0010 ** Licensees holding valid commercial Qt licenses may use this file in
0011 ** accordance with the commercial license agreement provided with the
0012 ** Software or, alternatively, in accordance with the terms contained in
0013 ** a written agreement between you and The Qt Company. For licensing terms
0014 ** and conditions see https://www.qt.io/terms-conditions. For further
0015 ** information use the contact form at https://www.qt.io/contact-us.
0016 **
0017 ** GNU General Public License Usage
0018 ** Alternatively, this file may be used under the terms of the GNU
0019 ** General Public License version 3 as published by the Free Software
0020 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
0021 ** included in the packaging of this file. Please review the following
0022 ** information to ensure the GNU General Public License requirements will
0023 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
0024 **
0025 ** $QT_END_LICENSE$
0026 **
0027 ****************************************************************************/
0028 
0029 
0030 #ifndef MODELTEST_H
0031 #define MODELTEST_H
0032 
0033 #include <QtCore/QObject>
0034 #include <QtCore/QAbstractItemModel>
0035 #include <QtCore/QStack>
0036 
0037 class ModelTest : public QObject
0038 {
0039   Q_OBJECT
0040 
0041 public:
0042   ModelTest( QAbstractItemModel *model, QObject *parent = nullptr );
0043 
0044 private Q_SLOTS:
0045   void nonDestructiveBasicTest();
0046   void rowCount();
0047   void columnCount();
0048   void hasIndex();
0049   void index();
0050   void parent();
0051   void data();
0052 
0053 protected Q_SLOTS:
0054   void runAllTests();
0055   void layoutAboutToBeChanged();
0056   void layoutChanged();
0057   void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end );
0058   void rowsInserted( const QModelIndex & parent, int start, int end );
0059   void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end );
0060   void rowsRemoved( const QModelIndex & parent, int start, int end );
0061   void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
0062   void headerDataChanged(Qt::Orientation orientation, int start, int end);
0063 
0064 private:
0065   void checkChildren( const QModelIndex &parent, int currentDepth = 0 );
0066 
0067   QAbstractItemModel *model;
0068 
0069   struct Changing {
0070     QModelIndex parent;
0071     int oldSize;
0072     QVariant last;
0073     QVariant next;
0074   };
0075   QStack<Changing> insert;
0076   QStack<Changing> remove;
0077 
0078   bool fetchingMore;
0079 
0080   QList<QPersistentModelIndex> changing;
0081 };
0082 
0083 #endif