modeltest.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2015 The Qt Company Ltd.
  4. ** Contact: http://www.qt.io/licensing/
  5. **
  6. ** This file is part of the test suite of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL21$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see http://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at http://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 2.1 or version 3 as published by the Free
  20. ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
  21. ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
  22. ** following information to ensure the GNU Lesser General Public License
  23. ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
  24. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  25. **
  26. ** As a special exception, The Qt Company gives you certain additional
  27. ** rights. These rights are described in The Qt Company LGPL Exception
  28. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  29. **
  30. ** $QT_END_LICENSE$
  31. **
  32. ****************************************************************************/
  33. #ifndef MODELTEST_H
  34. #define MODELTEST_H
  35. #include <QObject>
  36. #include <QAbstractItemModel>
  37. #include <QStack>
  38. class ModelTest : public QObject
  39. {
  40. Q_OBJECT
  41. public:
  42. ModelTest( QAbstractItemModel *model, QObject *parent = 0 );
  43. private slots:
  44. void nonDestructiveBasicTest();
  45. void rowCount();
  46. void columnCount();
  47. void hasIndex();
  48. void index();
  49. void parent();
  50. void data();
  51. protected slots:
  52. void runAllTests();
  53. void layoutAboutToBeChanged();
  54. void layoutChanged();
  55. void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end );
  56. void rowsInserted( const QModelIndex & parent, int start, int end );
  57. void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end );
  58. void rowsRemoved( const QModelIndex & parent, int start, int end );
  59. void rowsAboutToBeMoved ( const QModelIndex &srcParent, int start, int end, const QModelIndex &destParent, int destinationRow );
  60. void rowsMoved ( const QModelIndex &srcParent, int start, int end, const QModelIndex &destParent, int destinationRow );
  61. void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
  62. void headerDataChanged(Qt::Orientation orientation, int start, int end);
  63. private:
  64. void checkChildren( const QModelIndex &parent, int currentDepth = 0 );
  65. QAbstractItemModel *model;
  66. struct Changing {
  67. QModelIndex parent;
  68. int oldSize;
  69. QVariant last;
  70. QVariant next;
  71. };
  72. QStack<Changing> insert;
  73. QStack<Changing> remove;
  74. bool fetchingMore;
  75. QList<QPersistentModelIndex> changing;
  76. };
  77. #endif