File indexing completed on 2025-01-05 03:58:15
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2011 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 ** GNU Lesser General Public License Usage 0011 ** This file may be used under the terms of the GNU Lesser General Public 0012 ** License version 2.1 as published by the Free Software Foundation and 0013 ** appearing in the file LICENSE.LGPL included in the packaging of this 0014 ** file. Please review the following information to ensure the GNU Lesser 0015 ** General Public License version 2.1 requirements will be met: 0016 ** https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 0017 ** 0018 ** In addition, as a special exception, Nokia gives you certain additional 0019 ** rights. These rights are described in the Nokia Qt LGPL Exception 0020 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 0021 ** 0022 ** GNU General Public License Usage 0023 ** Alternatively, this file may be used under the terms of the GNU General 0024 ** Public License version 3.0 as published by the Free Software Foundation 0025 ** and appearing in the file LICENSE.GPL included in the packaging of this 0026 ** file. Please review the following information to ensure the GNU General 0027 ** Public License version 3.0 requirements will be met: 0028 ** https://www.gnu.org/copyleft/gpl.html. 0029 ** 0030 ** Other Usage 0031 ** Alternatively, this file may be used in accordance with the terms and 0032 ** conditions contained in a signed written agreement between you and Nokia. 0033 ** 0034 ** 0035 ** 0036 ** 0037 ** 0038 ** $QT_END_LICENSE$ 0039 ** 0040 ****************************************************************************/ 0041 0042 #ifndef DIGIKAM_MODEL_TEST_H 0043 #define DIGIKAM_MODEL_TEST_H 0044 0045 // Q tincludes 0046 0047 #include <QObject> 0048 #include <QAbstractItemModel> 0049 #include <QStack> 0050 0051 class ModelTest : public QObject 0052 { 0053 Q_OBJECT 0054 0055 public: 0056 0057 explicit ModelTest(QAbstractItemModel* const model, QObject* const parent = nullptr); 0058 0059 private Q_SLOTS: 0060 0061 void nonDestructiveBasicTest(); 0062 void rowCount(); 0063 void columnCount(); 0064 void hasIndex(); 0065 void index(); 0066 void parent(); 0067 void data(); 0068 0069 protected Q_SLOTS: 0070 0071 void runAllTests(); 0072 void layoutAboutToBeChanged(); 0073 void layoutChanged(); 0074 void rowsAboutToBeInserted(const QModelIndex& parent, int start, int end); 0075 void rowsInserted(const QModelIndex& parent, int start, int end); 0076 void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); 0077 void rowsRemoved(const QModelIndex& parent, int start, int end); 0078 0079 private: 0080 0081 void checkChildren(const QModelIndex& parent, int currentDepth = 0); 0082 0083 private: 0084 0085 struct Changing 0086 { 0087 QModelIndex parent; 0088 int oldSize; 0089 QVariant last; 0090 QVariant next; 0091 }; 0092 0093 private: 0094 0095 QAbstractItemModel* model; 0096 0097 QStack<Changing> insert; 0098 QStack<Changing> remove; 0099 0100 bool fetchingMore; 0101 0102 QList<QPersistentModelIndex> changing; 0103 }; 0104 0105 #endif // DIGIKAM_MODEL_TEST_H