Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
36class vtkMRMLNode;
38class QAction;
39
40class qMRMLTableModelPrivate;
41
42//------------------------------------------------------------------------------
43class 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
50public:
51 typedef QAbstractItemModel Superclass;
52 qMRMLTableModel(QObject *parent=nullptr);
53 ~qMRMLTableModel() override;
54
56 SortRole = Qt::UserRole + 1
57 };
58
61
65 bool transposed()const;
66
68 void updateMRMLFromModel(QStandardItem* item);
69
72
74 int mrmlTableRowIndex(QModelIndex modelIndex)const;
75
77 int mrmlTableColumnIndex(QModelIndex modelIndex)const;
78
83 int removeSelectionFromMRML(QModelIndexList selection, bool removeModelRow);
84
85protected slots:
86 void onMRMLTableNodeModified(vtkObject* node);
87 void onItemChanged(QStandardItem * item);
88
89protected:
90
91 qMRMLTableModel(qMRMLTableModelPrivate* pimpl, QObject *parent=nullptr);
92
93 static void onMRMLNodeEvent(vtkObject* vtk_obj, unsigned long event,
94 void* client_data, void* call_data);
95protected:
96 QScopedPointer<qMRMLTableModelPrivate> d_ptr;
97
98private:
99 Q_DECLARE_PRIVATE(qMRMLTableModel);
100 Q_DISABLE_COPY(qMRMLTableModel);
101};
102
103#endif
int mrmlTableRowIndex(QModelIndex modelIndex) const
Get MRML table index from model index.
vtkMRMLTableNode * mrmlTableNode() const
QVTK_OBJECTbool transposed
void updateMRMLFromModel(QStandardItem *item)
Return the VTK table cell associated to the node index.
void setMRMLTableNode(vtkMRMLTableNode *node)
void updateModelFromMRML()
Update the entire table from the MRML node.
qMRMLTableModel(qMRMLTableModelPrivate *pimpl, QObject *parent=nullptr)
void setTransposed(bool transposed)
void onMRMLTableNodeModified(vtkObject *node)
QAbstractItemModel Superclass
qMRMLTableModel(QObject *parent=nullptr)
int removeSelectionFromMRML(QModelIndexList selection, bool removeModelRow)
void onItemChanged(QStandardItem *item)
bool transposed() const
QScopedPointer< qMRMLTableModelPrivate > d_ptr
static void onMRMLNodeEvent(vtkObject *vtk_obj, unsigned long event, void *client_data, void *call_data)
int mrmlTableColumnIndex(QModelIndex modelIndex) const
Get MRML table index from model index.
Abstract Superclass for all specific types of MRML nodes.
MRML node to represent a table object.