VTK  9.2.6
QVTKTableModelAdapter.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: QVTKTableModelAdapter.h
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=========================================================================*/
32#ifndef QVTKTableModelAdapter_h
33#define QVTKTableModelAdapter_h
34
35#include "vtkGUISupportQtModule.h" // For export macro
36
37#include <QAbstractItemModel>
38#include <QObject>
39#include <QPointer>
40
41#include "vtkNew.h" // For vtkNew
42#include "vtkTable.h" // For vtkTable
43
44class VTKGUISUPPORTQT_EXPORT QVTKTableModelAdapter : public QObject
45{
46 Q_OBJECT
47public:
48 QVTKTableModelAdapter(QObject* parent = nullptr);
49 QVTKTableModelAdapter(QAbstractItemModel* model, QObject* parent = nullptr);
50
52
57 virtual void SetItemModel(QAbstractItemModel* model);
58 QAbstractItemModel* GetItemModel() const;
60
66
67Q_SIGNALS:
73
74protected:
78 virtual QVariant modelData(int row, int col);
79
85 virtual vtkAbstractArray* NewArray(const QVariant& type);
86
90 virtual bool HasCorrectColumnArrays();
91
95 virtual void SetCellValue(int row, int column, const QVariant& data);
96
101 virtual void UpdateTable(int row0, int column0, int row1, int column1);
102
103 QPointer<QAbstractItemModel> ItemModel;
105
106protected Q_SLOTS:
107 virtual void onModified();
108 virtual void onModelReset();
109 virtual void onDataChanged(
110 const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
111 virtual void onHeaderDataChanged(Qt::Orientation orientation, int first, int last);
112 virtual void onLayoutChanged(
113 const QList<QPersistentModelIndex>& parents, QAbstractItemModel::LayoutChangeHint hint);
114 virtual void onRowsInserted(const QModelIndex& parent, int first, int last);
115 virtual void onRowsRemoved(const QModelIndex& parent, int first, int last);
116 virtual void onRowsMoved(
117 const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row);
118 virtual void onColumnsInserted(const QModelIndex& parent, int first, int last);
119 virtual void onColumnsRemoved(const QModelIndex& parent, int first, int last);
120 virtual void onColumnsMoved(
121 const QModelIndex& parent, int start, int end, const QModelIndex& destination, int column);
122};
123
124#endif
An adapter to create a vtkTable from an QAbstractItemModel.
virtual void onColumnsInserted(const QModelIndex &parent, int first, int last)
void tableChanged()
Signal emitted when the internal vtkTable has changed.
QVTKTableModelAdapter(QObject *parent=nullptr)
virtual void onColumnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
virtual void SetCellValue(int row, int column, const QVariant &data)
Sets the value of the cell given by row, column using the adequate QVariant type conversion.
virtual void onColumnsRemoved(const QModelIndex &parent, int first, int last)
virtual void onHeaderDataChanged(Qt::Orientation orientation, int first, int last)
QAbstractItemModel * GetItemModel() const
Get/set the Qt table model.
virtual void onModelReset()
virtual void UpdateTable(int row0, int column0, int row1, int column1)
Update the internal table from row0 to inclusive row1, and from column0 to inclusive column1 so it re...
virtual void SetItemModel(QAbstractItemModel *model)
Get/set the Qt table model.
virtual QVariant modelData(int row, int col)
The default method for retrieving data for a tabel entry from the item model.
virtual void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
QVTKTableModelAdapter(QAbstractItemModel *model, QObject *parent=nullptr)
virtual void onRowsRemoved(const QModelIndex &parent, int first, int last)
vtkTable * GetTable() const
Access to the vtkTable.
virtual bool HasCorrectColumnArrays()
Check that the correct array types are set for the columns.
virtual void onRowsInserted(const QModelIndex &parent, int first, int last)
virtual void onLayoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
virtual void onModified()
virtual void onRowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
virtual vtkAbstractArray * NewArray(const QVariant &type)
Return a suitable vtk array for the QVariant type.
QPointer< QAbstractItemModel > ItemModel
Abstract superclass for all arrays.
Allocate and hold a VTK object.
Definition: vtkNew.h:62
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:74