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