modeltest.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the test suite of the Qt Toolkit.
  8. **
  9. ** This file is free software: you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation, either version 3 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** $QT_BEGIN_LICENSE:LGPL$
  15. ** GNU Lesser General Public License Usage
  16. ** This file may be used under the terms of the GNU Lesser General Public
  17. ** License version 2.1 as published by the Free Software Foundation and
  18. ** appearing in the file LICENSE.LGPL included in the packaging of this
  19. ** file. Please review the following information to ensure the GNU Lesser
  20. ** General Public License version 2.1 requirements will be met:
  21. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  22. **
  23. ** In addition, as a special exception, Nokia gives you certain additional
  24. ** rights. These rights are described in the Nokia Qt LGPL Exception
  25. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  26. **
  27. ** GNU General Public License Usage
  28. ** Alternatively, this file may be used under the terms of the GNU General
  29. ** Public License version 3.0 as published by the Free Software Foundation
  30. ** and appearing in the file LICENSE.GPL included in the packaging of this
  31. ** file. Please review the following information to ensure the GNU General
  32. ** Public License version 3.0 requirements will be met:
  33. ** http://www.gnu.org/copyleft/gpl.html.
  34. **
  35. ** Other Usage
  36. ** Alternatively, this file may be used in accordance with the terms and
  37. ** conditions contained in a signed written agreement between you and Nokia.
  38. **
  39. **
  40. **
  41. **
  42. **
  43. ** $QT_END_LICENSE$
  44. **
  45. ****************************************************************************/
  46. #ifndef MODELTEST_H
  47. #define MODELTEST_H
  48. #include <QtCore/QAbstractItemModel>
  49. #include <QtCore/QObject>
  50. #include <QtCore/QStack>
  51. class ModelTest : public QObject
  52. {
  53. Q_OBJECT
  54. public:
  55. ModelTest( QAbstractItemModel *model, QObject *parent = 0 );
  56. private Q_SLOTS:
  57. void nonDestructiveBasicTest();
  58. void rowCount();
  59. void columnCount();
  60. void hasIndex();
  61. void index();
  62. void parent();
  63. void data();
  64. protected Q_SLOTS:
  65. void runAllTests();
  66. void layoutAboutToBeChanged();
  67. void layoutChanged();
  68. void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end );
  69. void rowsInserted( const QModelIndex &parent, int start, int end );
  70. void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end );
  71. void rowsRemoved( const QModelIndex &parent, int start, int end );
  72. private:
  73. void checkChildren( const QModelIndex &parent, int currentDepth = 0 );
  74. QAbstractItemModel *model;
  75. struct Changing
  76. {
  77. QModelIndex parent;
  78. int oldSize;
  79. QVariant last;
  80. QVariant next;
  81. };
  82. QStack<Changing> insert;
  83. QStack<Changing> remove;
  84. bool fetchingMore;
  85. QList<QPersistentModelIndex> changing;
  86. };
  87. #endif