VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQtTableModelAdapter.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00034 #ifndef __vtkQtTableModelAdapter_h 00035 #define __vtkQtTableModelAdapter_h 00036 00037 #include "vtkQtAbstractModelAdapter.h" 00038 #include <QMimeData> 00039 #include <QImage> 00040 00041 class vtkSelection; 00042 class vtkTable; 00043 class vtkVariant; 00044 00045 class QVTK_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter 00046 { 00047 Q_OBJECT 00048 00049 public: 00050 vtkQtTableModelAdapter(QObject *parent = 0); 00051 vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0); 00052 ~vtkQtTableModelAdapter(); 00053 00055 00056 virtual void SetVTKDataObject(vtkDataObject *data); 00057 virtual vtkDataObject* GetVTKDataObject() const; 00059 00061 00062 virtual vtkSelection* QModelIndexListToVTKIndexSelection( 00063 const QModelIndexList qmil) const; 00064 virtual QItemSelection VTKIndexSelectionToQItemSelection( 00065 vtkSelection *vtksel) const; 00067 00068 virtual void SetKeyColumnName(const char* name); 00069 virtual void SetColorColumnName(const char* name); 00070 void SetIconIndexColumnName(const char* name); 00071 00072 //BTX 00073 enum 00074 { 00075 HEADER = 0, 00076 ITEM = 1 00077 }; 00078 //ETX 00079 00080 //BTX 00081 enum 00082 { 00083 COLORS = 0, 00084 ICONS = 1, 00085 NONE = 2 00086 }; 00087 //ETX 00088 00091 void SetDecorationLocation(int s); 00092 00095 void SetDecorationStrategy(int s); 00096 00097 bool GetSplitMultiComponentColumns() const; 00098 void SetSplitMultiComponentColumns(bool value); 00099 00101 00102 void setTable(vtkTable* table); 00103 vtkTable* table() const { return this->Table; } 00104 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00105 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 00106 Qt::ItemFlags flags(const QModelIndex &index) const; 00107 QVariant headerData(int section, Qt::Orientation orientation, 00108 int role = Qt::DisplayRole) const; 00109 QModelIndex index(int row, int column, 00110 const QModelIndex &parent = QModelIndex()) const; 00111 QModelIndex parent(const QModelIndex &index) const; 00112 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00113 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00115 00116 virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ; 00117 virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; 00118 virtual QStringList mimeTypes () const ; 00119 Qt::DropActions supportedDropActions() const; 00120 00121 void SetIconSheet(QImage sheet); 00122 void SetIconSize(int w, int h); 00123 void SetIconSheetSize(int w, int h); 00124 00125 signals: 00126 void selectionDropped(vtkSelection*); 00127 00128 private: 00129 00130 void getValue(int row, int column, vtkVariant& retVal) const; 00131 bool noTableCheck() const; 00132 void updateModelColumnHashTables(); 00133 QVariant getColorIcon(int row) const; 00134 QVariant getIcon(int row) const; 00135 00136 bool SplitMultiComponentColumns; 00137 vtkTable* Table; 00138 int DecorationLocation; 00139 int DecorationStrategy; 00140 QImage IconSheet; 00141 int IconSize[2]; 00142 int IconSheetSize[2]; 00143 int IconIndexColumn; 00144 00145 class vtkInternal; 00146 vtkInternal* Internal; 00147 00148 vtkQtTableModelAdapter(const vtkQtTableModelAdapter &); // Not implemented 00149 void operator=(const vtkQtTableModelAdapter&); // Not implemented. 00150 }; 00151 00152 #endif