File indexing completed on 2024-11-24 04:53:08

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 <QtCore/QObject>
0028 #include <QtCore/QAbstractItemModel>
0029 #include <QtCore/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 layoutAboutToBeChanged();
0050     void layoutChanged();
0051     void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
0052     void rowsInserted(const QModelIndex & parent, int start, int end);
0053     void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
0054     void rowsRemoved(const QModelIndex & parent, int start, int end);
0055 
0056 private:
0057     void checkChildren(const QModelIndex &parent, int currentDepth = 0);
0058 
0059     QAbstractItemModel *model;
0060 
0061     struct Changing
0062     {
0063         QModelIndex parent;
0064         int oldSize;
0065         QVariant last;
0066         QVariant next;
0067     };
0068     QStack<Changing> insert;
0069     QStack<Changing> remove;
0070 
0071     bool fetchingMore;
0072 
0073     QList<QPersistentModelIndex> changing;
0074 };
0075 
0076 #endif