VTK  9.3.20240327
vtkQtTableModelAdapter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
19 #ifndef vtkQtTableModelAdapter_h
20 #define vtkQtTableModelAdapter_h
21 
22 #include "vtkGUISupportQtModule.h" // For export macro
24 #include <QImage> // Needed for icon support
25 
26 class QMimeData;
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkSelection;
30 class vtkTable;
31 class vtkVariant;
32 
33 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
34 {
35  Q_OBJECT
36 
37 public:
38  vtkQtTableModelAdapter(QObject* parent = nullptr);
39  vtkQtTableModelAdapter(vtkTable* table, QObject* parent = nullptr);
41 
43 
47  vtkDataObject* GetVTKDataObject() const override;
49 
51 
54  vtkSelection* QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const override;
55  QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
57 
58  void SetKeyColumnName(const char* name) override;
59  void SetColorColumnName(const char* name) override;
60  void SetIconIndexColumnName(const char* name);
61 
62  enum
63  {
64  HEADER = 0,
65  ITEM = 1
66  };
67 
68  enum
69  {
70  COLORS = 0,
71  ICONS = 1,
72  NONE = 2
73  };
74 
79  void SetDecorationLocation(int s);
80 
85  void SetDecorationStrategy(int s);
86 
89 
91 
94  void setTable(vtkTable* table);
95  vtkTable* table() const { return this->Table; }
96  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
97  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
98  Qt::ItemFlags flags(const QModelIndex& index) const override;
99  QVariant headerData(
100  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
101  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
102  QModelIndex parent(const QModelIndex& index) const override;
103  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
104  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
106 
107  bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
108  const QModelIndex& parent) override;
109  QMimeData* mimeData(const QModelIndexList& indexes) const override;
110  QStringList mimeTypes() const override;
111  Qt::DropActions supportedDropActions() const override;
112 
113  void SetIconSheet(QImage sheet);
114  void SetIconSize(int w, int h);
115  void SetIconSheetSize(int w, int h);
116 
117 Q_SIGNALS:
119 
120 private:
121  void getValue(int row, int column, vtkVariant& retVal) const;
122  bool noTableCheck() const;
123  void updateModelColumnHashTables();
124  QVariant getColorIcon(int row) const;
125  QVariant getIcon(int row) const;
126 
127  bool SplitMultiComponentColumns;
128  vtkTable* Table;
129  int DecorationLocation;
130  int DecorationStrategy;
131  QImage IconSheet;
132  int IconSize[2];
133  int IconSheetSize[2];
134  int IconIndexColumn;
135 
136  class vtkInternal;
137  vtkInternal* Internal;
138 
140  void operator=(const vtkQtTableModelAdapter&) = delete;
141 };
142 
143 VTK_ABI_NAMESPACE_END
144 #endif
145 // VTK-HeaderTest-Exclude: vtkQtTableModelAdapter.h
general representation of visualization data
Superclass for Qt model adapters.
Adapts a table to a Qt item model.
void setTable(vtkTable *table)
Set up the model based on the current table.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Set up the model based on the current table.
vtkDataObject * GetVTKDataObject() const override
Set/Get the VTK data object as input to this adapter.
void SetIconIndexColumnName(const char *name)
~vtkQtTableModelAdapter() override
void selectionDropped(vtkSelection *)
void SetSplitMultiComponentColumns(bool value)
void SetDecorationLocation(int s)
Specify how to color rows if colors are provided by SetColorColumnName().
Qt::ItemFlags flags(const QModelIndex &index) const override
Set up the model based on the current table.
bool GetSplitMultiComponentColumns() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Set up the model based on the current table.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Set up the model based on the current table.
QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const override
Selection conversion from VTK land to Qt land.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Set up the model based on the current table.
vtkTable * table() const
Set up the model based on the current table.
void SetIconSheetSize(int w, int h)
void SetDecorationStrategy(int s)
Specify how to color rows if colors are provided by SetColorColumnName().
void SetVTKDataObject(vtkDataObject *data) override
Set/Get the VTK data object as input to this adapter.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
void SetKeyColumnName(const char *name) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Set up the model based on the current table.
QModelIndex parent(const QModelIndex &index) const override
Set up the model based on the current table.
Qt::DropActions supportedDropActions() const override
vtkSelection * QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const override
Selection conversion from VTK land to Qt land.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Set up the model based on the current table.
vtkQtTableModelAdapter(vtkTable *table, QObject *parent=nullptr)
QStringList mimeTypes() const override
void SetIconSheet(QImage sheet)
QMimeData * mimeData(const QModelIndexList &indexes) const override
void SetIconSize(int w, int h)
void SetColorColumnName(const char *name) override
vtkQtTableModelAdapter(QObject *parent=nullptr)
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:159
Computes the portion of a dataset which is inside a selection.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:168
A type representing the union of many types.
Definition: vtkVariant.h:162
@ orientation
Definition: vtkX3D.h:262
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
@ data
Definition: vtkX3D.h:315