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 enum 00073 { 00074 HEADER = 0, 00075 ITEM = 1 00076 }; 00077 00078 enum 00079 { 00080 COLORS = 0, 00081 ICONS = 1, 00082 NONE = 2 00083 }; 00084 00087 void SetDecorationLocation(int s); 00088 00091 void SetDecorationStrategy(int s); 00092 00093 bool GetSplitMultiComponentColumns() const; 00094 void SetSplitMultiComponentColumns(bool value); 00095 00097 00098 void setTable(vtkTable* table); 00099 vtkTable* table() const { return this->Table; } 00100 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00101 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 00102 Qt::ItemFlags flags(const QModelIndex &index) const; 00103 QVariant headerData(int section, Qt::Orientation orientation, 00104 int role = Qt::DisplayRole) const; 00105 QModelIndex index(int row, int column, 00106 const QModelIndex &parent = QModelIndex()) const; 00107 QModelIndex parent(const QModelIndex &index) const; 00108 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00109 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00111 00112 virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ; 00113 virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; 00114 virtual QStringList mimeTypes () const ; 00115 Qt::DropActions supportedDropActions() const; 00116 00117 void SetIconSheet(QImage sheet); 00118 void SetIconSize(int w, int h); 00119 void SetIconSheetSize(int w, int h); 00120 00121 signals: 00122 void selectionDropped(vtkSelection*); 00123 00124 private: 00125 00126 void getValue(int row, int column, vtkVariant& retVal) const; 00127 bool noTableCheck() const; 00128 void updateModelColumnHashTables(); 00129 QVariant getColorIcon(int row) const; 00130 QVariant getIcon(int row) const; 00131 00132 bool SplitMultiComponentColumns; 00133 vtkTable* Table; 00134 int DecorationLocation; 00135 int DecorationStrategy; 00136 QImage IconSheet; 00137 int IconSize[2]; 00138 int IconSheetSize[2]; 00139 int IconIndexColumn; 00140 00141 class vtkInternal; 00142 vtkInternal* Internal; 00143 00144 vtkQtTableModelAdapter(const vtkQtTableModelAdapter &); // Not implemented 00145 void operator=(const vtkQtTableModelAdapter&); // Not implemented. 00146 }; 00147 00148 #endif