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 <QImage> // Needed for icon support
40 
41 class vtkSelection;
42 class vtkTable;
43 class vtkVariant;
44 
45 class QMimeData;
46 
48 {
49  Q_OBJECT
50 
51 public:
52  vtkQtTableModelAdapter(QObject *parent = 0);
53  vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
55 
57 
58  virtual void SetVTKDataObject(vtkDataObject *data);
59  virtual vtkDataObject* GetVTKDataObject() const;
61 
63 
65  const QModelIndexList qmil) const;
66  virtual QItemSelection VTKIndexSelectionToQItemSelection(
67  vtkSelection *vtksel) const;
69 
70  virtual void SetKeyColumnName(const char* name);
71  virtual void SetColorColumnName(const char* name);
72  void SetIconIndexColumnName(const char* name);
73 
74  enum
75  {
76  HEADER = 0,
77  ITEM = 1
78  };
79 
80  enum
81  {
82  COLORS = 0,
83  ICONS = 1,
84  NONE = 2
85  };
86 
89  void SetDecorationLocation(int s);
90 
93  void SetDecorationStrategy(int s);
94 
95  bool GetSplitMultiComponentColumns() const;
96  void SetSplitMultiComponentColumns(bool value);
97 
99 
100  void setTable(vtkTable* table);
101  vtkTable* table() const { return this->Table; }
102  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
103  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
104  Qt::ItemFlags flags(const QModelIndex &index) const;
105  QVariant headerData(int section, Qt::Orientation orientation,
106  int role = Qt::DisplayRole) const;
107  QModelIndex index(int row, int column,
108  const QModelIndex &parent = QModelIndex()) const;
109  QModelIndex parent(const QModelIndex &index) const;
110  int rowCount(const QModelIndex &parent = QModelIndex()) const;
111  int columnCount(const QModelIndex &parent = QModelIndex()) const;
113 
114  virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ;
115  virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
116  virtual QStringList mimeTypes () const ;
117  Qt::DropActions supportedDropActions() const;
118 
119  void SetIconSheet(QImage sheet);
120  void SetIconSize(int w, int h);
121  void SetIconSheetSize(int w, int h);
122 
123 signals:
124  void selectionDropped(vtkSelection*);
125 
126 private:
127 
128  void getValue(int row, int column, vtkVariant& retVal) const;
129  bool noTableCheck() const;
130  void updateModelColumnHashTables();
131  QVariant getColorIcon(int row) const;
132  QVariant getIcon(int row) const;
133 
134  bool SplitMultiComponentColumns;
135  vtkTable* Table;
136  int DecorationLocation;
137  int DecorationStrategy;
138  QImage IconSheet;
139  int IconSize[2];
140  int IconSheetSize[2];
141  int IconIndexColumn;
142 
143  class vtkInternal;
144  vtkInternal* Internal;
145 
146  vtkQtTableModelAdapter(const vtkQtTableModelAdapter &); // Not implemented
147  void operator=(const vtkQtTableModelAdapter&); // Not implemented.
148 };
149 
150 #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
#define VTKGUISUPPORTQT_EXPORT
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