VTK  9.2.6
QVTKTableModelAdapterTestClass.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: TestQtTableModelAdapter.cxx
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #ifndef QVTKTableModelAdapterTestClass_h
17 #define QVTKTableModelAdapterTestClass_h
18 
25 #include "QVTKTableModelAdapter.h"
26 
27 #include <QAbstractTableModel>
28 #include <QStringList>
29 #include <QVector>
30 
31 class QVTKTableModelAdapterTestClass : public QAbstractTableModel
32 {
33  Q_OBJECT
34 
35 public:
36  QVTKTableModelAdapterTestClass(QObject* parent = nullptr);
37 
38  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
39  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
40 
41  virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
42  virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
43 
44  virtual bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
45  virtual bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
46 
47  virtual QVariant data(const QModelIndex& index, int role) const;
48  virtual bool setData(const QModelIndex& index, const QVariant& value, int role);
49  virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
50 
51 public Q_SLOTS:
52  void runTests();
53 
54 protected:
55  int Errors;
56 
57  QVector<QVector<double>> ColumnData;
58  QStringList ColumnNames;
59 
61 
62  void processEvents();
63  void testClearTable();
64  void testChangeHeader(int column, const QString& name);
65  void testColumnInsertion(int column, const QStringList& names);
66  void testColumnRemoval(int column, int n);
67  void testRowInsertion(int row, int n);
68  void testRowRemoval(int row, int n);
69 
71  void testInsertRemoveRows();
72 };
73 
74 #endif
An adapter to create a vtkTable from an QAbstractItemModel.
virtual bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
void testRowInsertion(int row, int n)
virtual bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
void testColumnRemoval(int column, int n)
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Class required by TestQVTKTableModelAdapter to run Qt tests involving event loop. ...
void testColumnInsertion(int column, const QStringList &names)
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual QVariant data(const QModelIndex &index, int role) const
void testRowRemoval(int row, int n)
void testChangeHeader(int column, const QString &name)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
QVTKTableModelAdapterTestClass(QObject *parent=nullptr)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const