VTK
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 -------------------------------------------------------------------------*/
34 #ifndef vtkQtTableModelAdapter_h
35 #define vtkQtTableModelAdapter_h
36 
37 #include "vtkGUISupportQtModule.h" // For export macro
39 #include <QMimeData>
40 #include <QImage>
41 
42 class vtkSelection;
43 class vtkTable;
44 class vtkVariant;
45 
46 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
47 {
48  Q_OBJECT
49 
50 public:
51  vtkQtTableModelAdapter(QObject *parent = 0);
52  vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
54 
56 
57  virtual void SetVTKDataObject(vtkDataObject *data);
58  virtual vtkDataObject* GetVTKDataObject() const;
60 
62 
64  const QModelIndexList qmil) const;
65  virtual QItemSelection VTKIndexSelectionToQItemSelection(
66  vtkSelection *vtksel) const;
68 
69  virtual void SetKeyColumnName(const char* name);
70  virtual void SetColorColumnName(const char* name);
71  void SetIconIndexColumnName(const char* name);
72 
73  enum
74  {
75  HEADER = 0,
76  ITEM = 1
77  };
78 
79  enum
80  {
81  COLORS = 0,
82  ICONS = 1,
83  NONE = 2
84  };
85 
88  void SetDecorationLocation(int s);
89 
92  void SetDecorationStrategy(int s);
93 
94  bool GetSplitMultiComponentColumns() const;
95  void SetSplitMultiComponentColumns(bool value);
96 
98 
99  void setTable(vtkTable* table);
100  vtkTable* table() const { return this->Table; }
101  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
102  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
103  Qt::ItemFlags flags(const QModelIndex &index) const;
104  QVariant headerData(int section, Qt::Orientation orientation,
105  int role = Qt::DisplayRole) const;
106  QModelIndex index(int row, int column,
107  const QModelIndex &parent = QModelIndex()) const;
108  QModelIndex parent(const QModelIndex &index) const;
109  int rowCount(const QModelIndex &parent = QModelIndex()) const;
110  int columnCount(const QModelIndex &parent = QModelIndex()) const;
112 
113  virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ;
114  virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
115  virtual QStringList mimeTypes () const ;
116  Qt::DropActions supportedDropActions() const;
117 
118  void SetIconSheet(QImage sheet);
119  void SetIconSize(int w, int h);
120  void SetIconSheetSize(int w, int h);
121 
122 signals:
123  void selectionDropped(vtkSelection*);
124 
125 private:
126 
127  void getValue(int row, int column, vtkVariant& retVal) const;
128  bool noTableCheck() const;
129  void updateModelColumnHashTables();
130  QVariant getColorIcon(int row) const;
131  QVariant getIcon(int row) const;
132 
133  bool SplitMultiComponentColumns;
134  vtkTable* Table;
135  int DecorationLocation;
136  int DecorationStrategy;
137  QImage IconSheet;
138  int IconSize[2];
139  int IconSheetSize[2];
140  int IconIndexColumn;
141 
142  class vtkInternal;
143  vtkInternal* Internal;
144 
145  vtkQtTableModelAdapter(const vtkQtTableModelAdapter &); // Not implemented
146  void operator=(const vtkQtTableModelAdapter&); // Not implemented.
147 };
148 
149 #endif
Adapts a table to a Qt item model.
A node in a selection tree. Used to store selection results.
Definition: vtkSelection.h:44
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
virtual vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const =0
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =0
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
Superclass for Qt model adapters.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:67
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
general representation of visualization data
Definition: vtkDataObject.h:64