File indexing completed on 2024-04-28 13:44:25
0001 // SPDX-License-Identifier: GPL-2.0-only 0002 // SPDX-FileCopyrightText: 2007 Trolltech ASA 0003 0004 #ifndef MODELTEST_H 0005 #define MODELTEST_H 0006 0007 #include <QObject> 0008 #include <QAbstractItemModel> 0009 #include <QStack> 0010 0011 class ModelTest : public QObject 0012 { 0013 Q_OBJECT 0014 0015 public: 0016 explicit ModelTest(QAbstractItemModel *model, QObject *parent = nullptr); 0017 0018 private Q_SLOTS: 0019 void nonDestructiveBasicTest(); 0020 void rowCount(); 0021 void columnCount(); 0022 void hasIndex(); 0023 void index(); 0024 void parent(); 0025 void data(); 0026 0027 protected Q_SLOTS: 0028 void runAllTests(); 0029 void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); 0030 void rowsInserted(const QModelIndex &parent, int start, int end); 0031 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); 0032 void rowsRemoved(const QModelIndex &parent, int start, int end); 0033 0034 private: 0035 void checkChildren(const QModelIndex &parent, int currentDepth = 0); 0036 0037 QAbstractItemModel *model; 0038 0039 struct Changing { 0040 QModelIndex parent; 0041 int oldSize; 0042 QVariant last; 0043 QVariant next; 0044 }; 0045 QStack<Changing> insert; 0046 QStack<Changing> remove; 0047 0048 bool fetchingMore; 0049 }; 0050 0051 #endif