VTK
dox/GUISupport/Qt/vtkQtTableModelAdapter.h
Go to the documentation of this file.
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 "vtkGUISupportQtModule.h" // For export macro
00038 #include "vtkQtAbstractModelAdapter.h"
00039 #include <QMimeData>
00040 #include <QImage>
00041 
00042 class vtkSelection;
00043 class vtkTable;
00044 class vtkVariant;
00045 
00046 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051   vtkQtTableModelAdapter(QObject *parent = 0);
00052   vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
00053   ~vtkQtTableModelAdapter();
00054 
00056 
00057   virtual void SetVTKDataObject(vtkDataObject *data);
00058   virtual vtkDataObject* GetVTKDataObject() const;
00060 
00062 
00063   virtual vtkSelection* QModelIndexListToVTKIndexSelection(
00064     const QModelIndexList qmil) const;
00065   virtual QItemSelection VTKIndexSelectionToQItemSelection(
00066     vtkSelection *vtksel) const;
00068 
00069   virtual void SetKeyColumnName(const char* name);
00070   virtual void SetColorColumnName(const char* name);
00071   void SetIconIndexColumnName(const char* name);
00072 
00073   enum
00074   {
00075     HEADER = 0,
00076     ITEM = 1
00077   };
00078 
00079   enum
00080   {
00081     COLORS = 0,
00082     ICONS = 1,
00083     NONE = 2
00084   };
00085 
00088   void SetDecorationLocation(int s);
00089 
00092   void SetDecorationStrategy(int s);
00093 
00094   bool GetSplitMultiComponentColumns() const;
00095   void SetSplitMultiComponentColumns(bool value);
00096 
00098 
00099   void setTable(vtkTable* table);
00100   vtkTable* table() const { return this->Table; }
00101   QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00102   bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00103   Qt::ItemFlags flags(const QModelIndex &index) const;
00104   QVariant headerData(int section, Qt::Orientation orientation,
00105                       int role = Qt::DisplayRole) const;
00106   QModelIndex index(int row, int column,
00107                     const QModelIndex &parent = QModelIndex()) const;
00108   QModelIndex parent(const QModelIndex &index) const;
00109   int rowCount(const QModelIndex &parent = QModelIndex()) const;
00110   int columnCount(const QModelIndex &parent = QModelIndex()) const;
00112 
00113   virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ;
00114   virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
00115   virtual QStringList mimeTypes () const ;
00116   Qt::DropActions supportedDropActions() const;
00117 
00118   void SetIconSheet(QImage sheet);
00119   void SetIconSize(int w, int h);
00120   void SetIconSheetSize(int w, int h);
00121 
00122 signals:
00123   void selectionDropped(vtkSelection*);
00124 
00125 private:
00126 
00127   void getValue(int row, int column, vtkVariant& retVal) const;
00128   bool noTableCheck() const;
00129   void updateModelColumnHashTables();
00130   QVariant getColorIcon(int row) const;
00131   QVariant getIcon(int row) const;
00132 
00133   bool        SplitMultiComponentColumns;
00134   vtkTable*   Table;
00135   int         DecorationLocation;
00136   int         DecorationStrategy;
00137   QImage      IconSheet;
00138   int         IconSize[2];
00139   int         IconSheetSize[2];
00140   int         IconIndexColumn;
00141 
00142   class vtkInternal;
00143   vtkInternal* Internal;
00144 
00145   vtkQtTableModelAdapter(const vtkQtTableModelAdapter &);  // Not implemented
00146   void operator=(const vtkQtTableModelAdapter&);  // Not implemented.
00147 };
00148 
00149 #endif