File indexing completed on 2024-04-14 15:51:35

0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2007 Trolltech ASA. All rights reserved.
0004 **
0005 ** This file is part of the Qt Concurrent project on Trolltech Labs.
0006 **
0007 ** This file may be used under the terms of the GNU General Public
0008 ** License version 2.0 as published by the Free Software Foundation
0009 ** and appearing in the file LICENSE.GPL included in the packaging of
0010 ** this file.  Please review the following information to ensure GNU
0011 ** General Public Licensing requirements will be met:
0012 ** http://www.trolltech.com/products/qt/opensource.html
0013 **
0014 ** If you are unsure which license is appropriate for your use, please
0015 ** review the following information:
0016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
0017 ** sales department at sales@trolltech.com.
0018 **
0019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
0020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
0021 **
0022 ****************************************************************************/
0023 
0024 #ifndef MODELTEST_H
0025 #define MODELTEST_H
0026 
0027 #include <QObject>
0028 #include <QAbstractItemModel>
0029 #include <QStack>
0030 
0031 class ModelTest : public QObject
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     explicit ModelTest(QAbstractItemModel *model, QObject *parent = 0);
0037 
0038 private Q_SLOTS:
0039     void nonDestructiveBasicTest();
0040     void rowCount();
0041     void columnCount();
0042     void hasIndex();
0043     void index();
0044     void parent();
0045     void data();
0046 
0047 protected Q_SLOTS:
0048     void runAllTests();
0049     void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
0050     void rowsInserted(const QModelIndex &parent, int start, int end);
0051     void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
0052     void rowsRemoved(const QModelIndex &parent, int start, int end);
0053 
0054 private:
0055     void checkChildren(const QModelIndex &parent, int currentDepth = 0);
0056 
0057     QAbstractItemModel *model;
0058 
0059     struct Changing {
0060         QModelIndex parent;
0061         int oldSize;
0062         QVariant last;
0063         QVariant next;
0064     };
0065     QStack<Changing> insert;
0066     QStack<Changing> remove;
0067 
0068     bool fetchingMore;
0069 };
0070 
0071 #endif