File indexing completed on 2024-04-28 17:02:21

0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2010 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 ** No Commercial Usage
0011 ** This file contains pre-release code and may not be distributed.
0012 ** You may use this file in accordance with the terms and conditions
0013 ** contained in the Technology Preview License Agreement accompanying
0014 ** this package.
0015 **
0016 ** GNU Lesser General Public License Usage
0017 ** Alternatively, this file may be used under the terms of the GNU Lesser
0018 ** General Public License version 2.1 as published by the Free Software
0019 ** Foundation and appearing in the file LICENSE.LGPL included in the
0020 ** packaging of this file.  Please review the following information to
0021 ** ensure the GNU Lesser General Public License version 2.1 requirements
0022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
0023 **
0024 ** In addition, as a special exception, Nokia gives you certain additional
0025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
0026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
0027 **
0028 ** If you have questions regarding the use of this file, please contact
0029 ** Nokia at qt-info@nokia.com.
0030 **
0031 **
0032 **
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 = 0 );
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