00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00034 #ifndef __vtkQtTableModelAdapter_h
00035 #define __vtkQtTableModelAdapter_h
00036
00037 #include "QVTKWin32Header.h"
00038 #include "vtkType.h"
00039
00040 #include "vtkQtAbstractModelAdapter.h"
00041
00042 #include "vtkSelection.h"
00043 #include <QHash>
00044
00045 class vtkTable;
00046
00047 class QVTK_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
00048 {
00049 Q_OBJECT
00050
00051 public:
00052 vtkQtTableModelAdapter(QObject *parent = 0);
00053 vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
00054 ~vtkQtTableModelAdapter();
00055
00056
00057 virtual void SetVTKDataObject(vtkDataObject *data);
00058 virtual vtkDataObject* GetVTKDataObject() const;
00059
00060 vtkIdType IdToPedigree(vtkIdType id) const;
00061 vtkIdType PedigreeToId(vtkIdType pedigree) const;
00062 QModelIndex PedigreeToQModelIndex(vtkIdType id) const;
00063 vtkIdType QModelIndexToPedigree(QModelIndex index) const;
00064
00065 virtual void SetKeyColumnName(const char* name);
00066
00067 void setTable(vtkTable* table);
00068 vtkTable* table() const { return this->Table; }
00069 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00070 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00071 Qt::ItemFlags flags(const QModelIndex &index) const;
00072 QVariant headerData(int section, Qt::Orientation orientation,
00073 int role = Qt::DisplayRole) const;
00074 QModelIndex index(int row, int column,
00075 const QModelIndex &parent = QModelIndex()) const;
00076 QModelIndex parent(const QModelIndex &index) const;
00077 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00078 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00079
00080 private:
00081 void GenerateHashMap();
00082 bool noTableCheck() const;
00083
00084 vtkTable* Table;
00085 QHash<vtkIdType, vtkIdType> IdToPedigreeHash;
00086 QHash<vtkIdType, QModelIndex> PedigreeToIndexHash;
00087 QHash<QModelIndex, vtkIdType> IndexToIdHash;
00088
00089 QHash<QModelIndex, QVariant> IndexToDecoration;
00090
00091 vtkQtTableModelAdapter(const vtkQtTableModelAdapter &);
00092 void operator=(const vtkQtTableModelAdapter&);
00093 };
00094
00095 #endif