VTK  9.0.1
vtkQtTableModelAdapter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtTableModelAdapter.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 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
32 #ifndef vtkQtTableModelAdapter_h
33 #define vtkQtTableModelAdapter_h
34 
35 #include "vtkConfigure.h"
36 #include "vtkGUISupportQtModule.h" // For export macro
38 #include <QImage> // Needed for icon support
39 
40 class vtkSelection;
41 class vtkTable;
42 class vtkVariant;
43 
44 class QMimeData;
45 
46 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
47 {
48  Q_OBJECT
49 
50 public:
51  vtkQtTableModelAdapter(QObject* parent = nullptr);
52  vtkQtTableModelAdapter(vtkTable* table, QObject* parent = nullptr);
53  ~vtkQtTableModelAdapter() override;
54 
56 
59  void SetVTKDataObject(vtkDataObject* data) override;
60  vtkDataObject* GetVTKDataObject() const override;
62 
64 
67  vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override;
68  QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
70 
71  void SetKeyColumnName(const char* name) override;
72  void SetColorColumnName(const char* name) override;
73  void SetIconIndexColumnName(const char* name);
74 
75  enum
76  {
77  HEADER = 0,
78  ITEM = 1
79  };
80 
81  enum
82  {
83  COLORS = 0,
84  ICONS = 1,
85  NONE = 2
86  };
87 
92  void SetDecorationLocation(int s);
93 
98  void SetDecorationStrategy(int s);
99 
100  bool GetSplitMultiComponentColumns() const;
101  void SetSplitMultiComponentColumns(bool value);
102 
104 
107  void setTable(vtkTable* table);
108  vtkTable* table() const { return this->Table; }
109  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
110  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
111  Qt::ItemFlags flags(const QModelIndex& index) const override;
112  QVariant headerData(
113  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
114  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
115  QModelIndex parent(const QModelIndex& index) const override;
116  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
117  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
119 
120  bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
121  const QModelIndex& parent) override;
122  QMimeData* mimeData(const QModelIndexList& indexes) const override;
123  QStringList mimeTypes() const override;
124  Qt::DropActions supportedDropActions() const override;
125 
126  void SetIconSheet(QImage sheet);
127  void SetIconSize(int w, int h);
128  void SetIconSheetSize(int w, int h);
129 
130 signals:
131  void selectionDropped(vtkSelection*);
132 
133 private:
134  void getValue(int row, int column, vtkVariant& retVal) const;
135  bool noTableCheck() const;
136  void updateModelColumnHashTables();
137  QVariant getColorIcon(int row) const;
138  QVariant getIcon(int row) const;
139 
140  bool SplitMultiComponentColumns;
141  vtkTable* Table;
142  int DecorationLocation;
143  int DecorationStrategy;
144  QImage IconSheet;
145  int IconSize[2];
146  int IconSheetSize[2];
147  int IconIndexColumn;
148 
149  class vtkInternal;
150  vtkInternal* Internal;
151 
153  void operator=(const vtkQtTableModelAdapter&) = delete;
154 };
155 
156 #endif
157 // VTK-HeaderTest-Exclude: vtkQtTableModelAdapter.h
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
vtkQtAbstractModelAdapter::SetKeyColumnName
virtual void SetKeyColumnName(const char *name)=0
vtkSelection
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:57
vtkQtAbstractModelAdapter::SetColorColumnName
virtual void SetColorColumnName(const char *name)=0
vtkQtAbstractModelAdapter.h
vtkQtAbstractModelAdapter::QModelIndexListToVTKIndexSelection
virtual vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const =0
Selection conversion from VTK land to Qt land.
vtkQtAbstractModelAdapter
Superclass for Qt model adapters.
Definition: vtkQtAbstractModelAdapter.h:45
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:65
vtkQtTableModelAdapter::table
vtkTable * table() const
Definition: vtkQtTableModelAdapter.h:108
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkQtAbstractModelAdapter::SetVTKDataObject
virtual void SetVTKDataObject(vtkDataObject *data)=0
Set/Get the VTK data object as input to this adapter.
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:268
vtkQtAbstractModelAdapter::GetVTKDataObject
virtual vtkDataObject * GetVTKDataObject() const =0
vtkQtTableModelAdapter
Adapts a table to a Qt item model.
Definition: vtkQtTableModelAdapter.h:46
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkQtAbstractModelAdapter::VTKIndexSelectionToQItemSelection
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
h