VTK  9.4.20250210
QVTKTableModelAdapter.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
20#ifndef QVTKTableModelAdapter_h
21#define QVTKTableModelAdapter_h
22
23#include "vtkGUISupportQtModule.h" // For export macro
24
25#include <QAbstractItemModel>
26#include <QObject>
27#include <QPointer>
28
29#include "vtkNew.h" // For vtkNew
30#include "vtkTable.h" // For vtkTable
31
32VTK_ABI_NAMESPACE_BEGIN
33class VTKGUISUPPORTQT_EXPORT QVTKTableModelAdapter : public QObject
34{
35 Q_OBJECT
36public:
37 QVTKTableModelAdapter(QObject* parent = nullptr);
38 QVTKTableModelAdapter(QAbstractItemModel* model, QObject* parent = nullptr);
39
41
46 virtual void SetItemModel(QAbstractItemModel* model);
47 QAbstractItemModel* GetItemModel() const;
49
55
56Q_SIGNALS:
62
63protected:
67 virtual QVariant modelData(int row, int col);
68
74 virtual vtkAbstractArray* NewArray(const QVariant& type);
75
79 virtual bool HasCorrectColumnArrays();
80
84 virtual void SetCellValue(int row, int column, const QVariant& data);
85
90 virtual void UpdateTable(int row0, int column0, int row1, int column1);
91
92 QPointer<QAbstractItemModel> ItemModel;
94
95protected Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
96 virtual void onModified();
97 virtual void onModelReset();
98 virtual void onDataChanged(
99 const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
100 virtual void onHeaderDataChanged(Qt::Orientation orientation, int first, int last);
101 virtual void onLayoutChanged(
102 const QList<QPersistentModelIndex>& parents, QAbstractItemModel::LayoutChangeHint hint);
103 virtual void onRowsInserted(const QModelIndex& parent, int first, int last);
104 virtual void onRowsRemoved(const QModelIndex& parent, int first, int last);
105 virtual void onRowsMoved(
106 const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row);
107 virtual void onColumnsInserted(const QModelIndex& parent, int first, int last);
108 virtual void onColumnsRemoved(const QModelIndex& parent, int first, int last);
109 virtual void onColumnsMoved(
110 const QModelIndex& parent, int start, int end, const QModelIndex& destination, int column);
111};
112
113VTK_ABI_NAMESPACE_END
114#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 table 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:167
A table, which contains similar-typed columns of data.
Definition vtkTable.h:169