MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUSZoneManagementColorDialogDelegate.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
13
14#include <QEvent>
15#include <QColorDialog>
16
18 : QStyledItemDelegate(parent)
19{
20}
21
25
26bool QmitkUSZoneManagementColorDialogDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem& option, const QModelIndex &index)
27{
28 if( event->type() == QEvent::MouseButtonDblClick )
29 {
30 // open the color dialog with the value currently in the cell
31 QString value = index.model()->data(index, Qt::EditRole).toString();
32 QColor color = QColorDialog::getColor(QColor(value));
33 if (color.isValid()) { model->setData(index, QVariant(color)); }
34
35 return true;
36 }
37 else
38 {
39 return QStyledItemDelegate::editorEvent(event, model, option, index);
40 }
41}
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
A QColorDialog is opened on double click events.