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 
44 class VTKGUISUPPORTQT_EXPORT QVTKTableModelAdapter : public QObject
45 {
46  Q_OBJECT
47 public:
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 
65  vtkTable* GetTable() const;
66 
67 Q_SIGNALS:
72  void tableChanged();
73 
74 protected:
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 
106 protected 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.
QPointer< QAbstractItemModel > ItemModel
Abstract superclass for all arrays.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:73