VTK  9.3.1
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 
32 VTK_ABI_NAMESPACE_BEGIN
33 class VTKGUISUPPORTQT_EXPORT QVTKTableModelAdapter : public QObject
34 {
35  Q_OBJECT
36 public:
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 
54  vtkTable* GetTable() const;
55 
56 Q_SIGNALS:
61  void tableChanged();
62 
63 protected:
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 
95 protected 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 
113 VTK_ABI_NAMESPACE_END
114 #endif
An adapter to create a vtkTable from an QAbstractItemModel.
QPointer< QAbstractItemModel > ItemModel
Abstract superclass for all arrays.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:58
vtkNew< vtkTable > Table