VTK  9.3.1
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);
40  ~vtkQtTableModelAdapter() override;
41 
43 
46  void SetVTKDataObject(vtkDataObject* data) override;
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 
87  bool GetSplitMultiComponentColumns() const;
88  void SetSplitMultiComponentColumns(bool value);
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:
118  void selectionDropped(vtkSelection*);
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
Adapts a table to a Qt item model.
virtual vtkSelection * QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const =0
Selection conversion from VTK land to Qt land.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:49
A type representing the union of many types.
Definition: vtkVariant.h:52
vtkTable * table() const
Set up the model based on the current table.
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =0
Set/Get the VTK data object as input to this adapter.
Superclass for Qt model adapters.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:58
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
Set/Get the VTK data object as input to this adapter.
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
Selection conversion from VTK land to Qt land.
general representation of visualization data
Definition: vtkDataObject.h:54