~macslow/unity8/fix-1475678

« back to all changes in this revision

Viewing changes to tests/plugins/Utils/modeltest.h

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
** The full license is below, this is here to make licensecheck happy
 
3
**
 
4
** This program is free software; you can redistribute it and/or modify
 
5
** it under the terms of the GNU Lesser General Public License as published by
 
6
** the Free Software Foundation; version 2.1.
 
7
**
 
8
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 
9
** Contact: http://www.qt-project.org/legal
 
10
**
 
11
** This file is part of the test suite of the Qt Toolkit.
 
12
**
 
13
** $QT_BEGIN_LICENSE:LGPL$
 
14
** Commercial License Usage
 
15
** Licensees holding valid commercial Qt licenses may use this file in
 
16
** accordance with the commercial license agreement provided with the
 
17
** Software or, alternatively, in accordance with the terms contained in
 
18
** a written agreement between you and Digia.  For licensing terms and
 
19
** conditions see http://qt.digia.com/licensing.  For further information
 
20
** use the contact form at http://qt.digia.com/contact-us.
 
21
**
 
22
** GNU Lesser General Public License Usage
 
23
** Alternatively, this file may be used under the terms of the GNU Lesser
 
24
** General Public License version 2.1 as published by the Free Software
 
25
** Foundation and appearing in the file LICENSE.LGPL included in the
 
26
** packaging of this file.  Please review the following information to
 
27
** ensure the GNU Lesser General Public License version 2.1 requirements
 
28
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
29
**
 
30
** In addition, as a special exception, Digia gives you certain additional
 
31
** rights.  These rights are described in the Digia Qt LGPL Exception
 
32
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
33
**
 
34
** GNU General Public License Usage
 
35
** Alternatively, this file may be used under the terms of the GNU
 
36
** General Public License version 3.0 as published by the Free Software
 
37
** Foundation and appearing in the file LICENSE.GPL included in the
 
38
** packaging of this file.  Please review the following information to
 
39
** ensure the GNU General Public License version 3.0 requirements will be
 
40
** met: http://www.gnu.org/copyleft/gpl.html.
 
41
**
 
42
**
 
43
** $QT_END_LICENSE$
 
44
**
 
45
****************************************************************************/
 
46
 
 
47
 
 
48
#ifndef MODELTEST_H
 
49
#define MODELTEST_H
 
50
 
 
51
#include <QtCore/QObject>
 
52
#include <QtCore/QAbstractItemModel>
 
53
#include <QtCore/QStack>
 
54
 
 
55
class ModelTest : public QObject
 
56
{
 
57
  Q_OBJECT
 
58
 
 
59
public:
 
60
  ModelTest( QAbstractItemModel *model, QObject *parent = 0 );
 
61
 
 
62
private Q_SLOTS:
 
63
  void nonDestructiveBasicTest();
 
64
  void rowCount();
 
65
  void columnCount();
 
66
  void hasIndex();
 
67
  void index();
 
68
  void parent();
 
69
  void data();
 
70
 
 
71
protected Q_SLOTS:
 
72
  void runAllTests();
 
73
  void layoutAboutToBeChanged();
 
74
  void layoutChanged();
 
75
  void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end );
 
76
  void rowsInserted( const QModelIndex & parent, int start, int end );
 
77
  void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end );
 
78
  void rowsRemoved( const QModelIndex & parent, int start, int end );
 
79
  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
80
  void headerDataChanged(Qt::Orientation orientation, int start, int end);
 
81
 
 
82
private:
 
83
  void checkChildren( const QModelIndex &parent, int currentDepth = 0 );
 
84
 
 
85
  QAbstractItemModel *model;
 
86
 
 
87
  struct Changing {
 
88
    QModelIndex parent;
 
89
    int oldSize;
 
90
    QVariant last;
 
91
    QVariant next;
 
92
  };
 
93
  QStack<Changing> insert;
 
94
  QStack<Changing> remove;
 
95
 
 
96
  bool fetchingMore;
 
97
 
 
98
  QList<QPersistentModelIndex> changing;
 
99
};
 
100
 
 
101
#endif