VTK  9.3.1
QVTKTableModelAdapterTestClass.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef QVTKTableModelAdapterTestClass_h
5 #define QVTKTableModelAdapterTestClass_h
6 
13 #include "QVTKTableModelAdapter.h"
14 
15 #include <QAbstractTableModel>
16 #include <QStringList>
17 #include <QVector>
18 
19 class QVTKTableModelAdapterTestClass : public QAbstractTableModel
20 {
21  Q_OBJECT
22 
23 public:
24  QVTKTableModelAdapterTestClass(QObject* parent = nullptr);
25 
26  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
27  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
28 
29  bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
30  bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
31 
32  bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
33  bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
34 
35  QVariant data(const QModelIndex& index, int role) const override;
36  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
37  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
38 
39 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
40  void runTests();
41 
42 protected:
43  int Errors;
44 
45  QVector<QVector<double>> ColumnData;
46  QStringList ColumnNames;
47 
49 
50  void processEvents();
51  void testClearTable();
52  void testChangeHeader(int column, const QString& name);
53  void testColumnInsertion(int column, const QStringList& names);
54  void testColumnRemoval(int column, int n);
55  void testRowInsertion(int row, int n);
56  void testRowRemoval(int row, int n);
57 
59  void testInsertRemoveRows();
60 };
61 
62 #endif
An adapter to create a vtkTable from an QAbstractItemModel.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
void testRowInsertion(int row, int n)
QVariant data(const QModelIndex &index, int role) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
void testColumnRemoval(int column, int n)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Class required by TestQVTKTableModelAdapter to run Qt tests involving event loop. ...
void testColumnInsertion(int column, const QStringList &names)
bool setData(const QModelIndex &index, const QVariant &value, int role) override
void testRowRemoval(int row, int n)
void testChangeHeader(int column, const QString &name)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
QVTKTableModelAdapterTestClass(QObject *parent=nullptr)
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override