Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qMRMLTableModel.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Portions (c) Copyright 2015 Brigham and Women's Hospital (BWH) All Rights Reserved.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Andras Lasso (PerkLab, Queen's
17  University) and Kevin Wang (Princess Margaret Hospital, Toronto) and was
18  supported through OCAIRO and the Applied Cancer Research Unit program of
19  Cancer Care Ontario.
20 
21 ==============================================================================*/
22 
23 #ifndef __qMRMLTableModel_h
24 #define __qMRMLTableModel_h
25 
26 // Qt includes
27 #include <QStandardItemModel>
28 
29 // CTK includes
30 #include <ctkPimpl.h>
31 #include <ctkVTKObject.h>
32 
33 // qMRML includes
34 #include "qMRMLWidgetsExport.h"
35 
36 class vtkMRMLNode;
37 class vtkMRMLTableNode;
38 class QAction;
39 
40 class qMRMLTableModelPrivate;
41 
42 //------------------------------------------------------------------------------
43 class QMRML_WIDGETS_EXPORT qMRMLTableModel : public QStandardItemModel
44 {
45  Q_OBJECT
46  QVTK_OBJECT
47  Q_ENUMS(ItemDataRole)
48  Q_PROPERTY(bool transposed READ transposed WRITE setTransposed)
49 
50 public:
51  typedef QAbstractItemModel Superclass;
52  qMRMLTableModel(QObject *parent=0);
53  virtual ~qMRMLTableModel();
54 
56  SortRole = Qt::UserRole + 1
57  };
58 
59  void setMRMLTableNode(vtkMRMLTableNode* node);
60  vtkMRMLTableNode* mrmlTableNode()const;
61 
64  void setTransposed(bool transposed);
65  bool transposed()const;
66 
68  void updateMRMLFromModel(QStandardItem* item);
69 
71  void updateModelFromMRML();
72 
74  int mrmlTableRowIndex(QModelIndex modelIndex)const;
75 
77  int mrmlTableColumnIndex(QModelIndex modelIndex)const;
78 
83  int removeSelectionFromMRML(QModelIndexList selection, bool removeModelRow);
84 
85 protected slots:
86  void onMRMLTableNodeModified(vtkObject* node);
87  void onItemChanged(QStandardItem * item);
88 
89 protected:
90 
91  qMRMLTableModel(qMRMLTableModelPrivate* pimpl, QObject *parent=0);
92 
93  static void onMRMLNodeEvent(vtkObject* vtk_obj, unsigned long event,
94  void* client_data, void* call_data);
95 protected:
96  QScopedPointer<qMRMLTableModelPrivate> d_ptr;
97 
98 private:
99  Q_DECLARE_PRIVATE(qMRMLTableModel);
100  Q_DISABLE_COPY(qMRMLTableModel);
101 };
102 
103 #endif
QAbstractItemModel Superclass
QScopedPointer< qMRMLTableModelPrivate > d_ptr
MRML node to represent a table object.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135