diff --git a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp index 9de4f0b4c8..0abfd3973f 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp +++ b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp @@ -1,94 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkDoseVisualStyleDelegate.h" #include #include #include #include #include static QRect CheckBoxRect(const QStyleOptionViewItem &view_item_style_options) { QStyleOptionButton check_box_style_option; QRect check_box_rect = QApplication::style()->subElementRect( QStyle::SE_CheckBoxIndicator, &check_box_style_option); QPoint check_box_point(view_item_style_options.rect.x() + view_item_style_options.rect.width() / 2 - check_box_rect.width() / 2, view_item_style_options.rect.y() + view_item_style_options.rect.height() / 2 - check_box_rect.height() / 2); return QRect(check_box_point, check_box_rect.size()); } QmitkDoseVisualStyleDelegate::QmitkDoseVisualStyleDelegate(QObject * /*parent*/) { } void QmitkDoseVisualStyleDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { bool checkValue = index.data(Qt::DisplayRole).toBool(); QStyleOptionButton BtnStyle; BtnStyle.state = QStyle::State_Enabled; if(checkValue) { BtnStyle.state |= QStyle::State_On; } else { BtnStyle.state |= QStyle::State_Off; } BtnStyle.direction = QApplication::layoutDirection(); BtnStyle.rect = CheckBoxRect(option); QApplication::style()->drawControl(QStyle::CE_CheckBox,&BtnStyle,painter ); } -bool QmitkDoseVisualStyleDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, +bool QmitkDoseVisualStyleDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &, const QModelIndex &index) { Q_ASSERT(event); Q_ASSERT(model); // make sure that the item is checkable Qt::ItemFlags flags = model->flags(index); if (!(flags & Qt::ItemIsEditable) || !(flags & Qt::ItemIsEnabled)) { return false; } // make sure that we have the right event type QMouseEvent* mouseEvent = dynamic_cast(event); if (!mouseEvent) { return false; } else { if (mouseEvent->type() != QEvent::MouseButtonRelease || mouseEvent->button() != Qt::LeftButton) { return false; } } bool newState = !(index.data(Qt::EditRole).toBool()); return model->setData(index, QVariant(newState), Qt::EditRole); };