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
qSlicerTerminologyItemDelegate.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6 Queen's University, Kingston, ON, Canada. All Rights Reserved.
7
8 See COPYRIGHT.txt
9 or http://www.slicer.org/copyright/copyright.txt for details.
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18 and was supported through the Applied Cancer Research Unit program of Cancer Care
19 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20
21==============================================================================*/
22
23#ifndef __qSlicerTerminologyItemDelegate_h
24#define __qSlicerTerminologyItemDelegate_h
25
26// Qt includes
27#include <QStyledItemDelegate>
28#include <QModelIndex>
29
30#include "qSlicerTerminologiesModuleWidgetsExport.h"
31
32// \brief Delegate for displaying terminology selector
33class Q_SLICER_MODULE_TERMINOLOGIES_WIDGETS_EXPORT qSlicerTerminologyItemDelegate : public QStyledItemDelegate
34{
35 Q_OBJECT
36
37public:
39
40 qSlicerTerminologyItemDelegate(QObject *parent = nullptr);
41
60
61 QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
62
63 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
64 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
65
66 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
67
69 void setUseTerminologySelectorCallback(std::function<bool()> callback);
70
72 void setUserSetCustomNameOrColorCallback(std::function<bool()> callback);
73
75
76public slots:
78
79protected slots:
82 void close();
84
85protected:
87 std::function<bool()> UseTerminologySelectorCallback;
88 std::function<bool()> UserSetCustomNameOrColorCallback;
89
92 bool UseDecorationRole{ true };
93};
94
95#endif
void setEditorData(QWidget *editor, const QModelIndex &index) const override
@ TerminologyRole
Serialized terminology entry.
@ ColorRole
Color of the segment. We do not want to show color in the name cell so we need a custom role.
@ NameRole
Name of the segment (either custom or auto-generated)
@ NameAutoGeneratedRole
Flag indicating whether the selected name is auto-generated form terminology.
@ GeneratedColorRole
Auto-generated color that is used if the selected terminology contains no recommended color.
@ DefaultTerminologyRole
Serialized default terminology entry, which is used to initialize the terminology selector if the seg...
void setUseTerminologySelectorCallback(std::function< bool()> callback)
This method allow setting a callback function that takes a void* argument and returns bool.
std::function< bool()> UserSetCustomNameOrColorCallback
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
void setUseDecorationRole(bool useDecorationRole)
void setUserSetCustomNameOrColorCallback(std::function< bool()> callback)
This can be used for asking the user if he wants to switch to using simple name&color selector.
std::function< bool()> UseTerminologySelectorCallback
The settings key used to specify whether standard terminologies are used for name column.
qSlicerTerminologyItemDelegate(QObject *parent=nullptr)
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override