00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00034 #ifndef __vtkQtAbstractModelAdapter_h
00035 #define __vtkQtAbstractModelAdapter_h
00036 
00037 #include "QVTKWin32Header.h"
00038 #include "vtkType.h"
00039 #include "vtkSelection.h"
00040 class vtkDataObject;
00041 
00042 #include <QAbstractItemModel>
00043 
00044 class QModelIndex;
00045 
00046 class QVTK_EXPORT vtkQtAbstractModelAdapter : public QAbstractItemModel
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051 
00052   
00053   enum {
00054     FULL_VIEW,
00055     DATA_VIEW,
00056     METADATA_VIEW
00057   };
00058 
00059   vtkQtAbstractModelAdapter(QObject* p) : 
00060     QAbstractItemModel(p), 
00061     ViewType(FULL_VIEW),
00062     KeyColumn(-1),
00063     DataStartColumn(-1),
00064     DataEndColumn(-1),
00065     ViewRows(true)
00066     { }
00067 
00069 
00070   virtual void SetVTKDataObject(vtkDataObject *data) = 0;
00071   virtual vtkDataObject* GetVTKDataObject() const = 0;
00073   
00075 
00076   virtual vtkIdType IdToPedigree(vtkIdType id) const = 0;
00077   virtual vtkIdType PedigreeToId(vtkIdType pedigree) const = 0;
00078   virtual QModelIndex PedigreeToQModelIndex(vtkIdType id) const = 0;
00079   virtual vtkIdType QModelIndexToPedigree(QModelIndex index) const = 0;
00081 
00083 
00087   virtual void SetViewType(int type) { this->ViewType = type; }
00088   virtual int GetViewType() { return this->ViewType; }
00090 
00092 
00095   virtual void SetKeyColumn(int col) { this->KeyColumn = col; }
00096   virtual int GetKeyColumn() { return this->KeyColumn; }
00097   virtual void SetKeyColumnName(const char* name) = 0;
00099 
00101 
00104   virtual void SetDataColumnRange(int c1, int c2)
00105     { this->DataStartColumn = c1; this->DataEndColumn = c2; }
00107 
00108   virtual bool GetViewRows()
00109     { return this->ViewRows; }
00110 
00111   
00112   
00113   
00114   void reset() { QAbstractItemModel::reset(); }
00115 
00116 public slots:
00118 
00122   void SetViewRows(bool b)
00123     { this->ViewRows = b; this->reset(); emit this->modelChanged(); }
00125 
00126 signals:
00127   void modelChanged();
00128   
00129 protected:
00130   virtual int ModelColumnToFieldDataColumn(int col) const;
00131 
00132   int ViewType;
00133   int KeyColumn;
00134   int DataStartColumn;
00135   int DataEndColumn;
00136   bool ViewRows;
00137 };
00138 
00139 #endif