Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkTableItemThumbnailDelegate.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 // semantic relations UI module
15 
16 // qt
17 #include <QApplication>
18 #include <QPainter>
19 #include <QStyle>
20 
22  : QStyledItemDelegate(parent)
23 {
24  // nothing here
25 }
26 
27 void QmitkTableItemThumbnailDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
28 {
29  QPixmap pixmap = index.data(Qt::DecorationRole).value<QPixmap>();
30  QPoint point = option.rect.center() - pixmap.rect().center();
31  painter->save();
32 
33  if (option.state & QStyle::State_Selected)
34  {
35  painter->setBrush(option.palette.highlightedText());
36  const QWidget* widget = option.widget;
37  QStyle* style = widget ? widget->style() : QApplication::style();
38  style->drawControl(QStyle::CE_ItemViewItem, &option, painter, widget);
39  }
40  painter->drawPixmap(point, pixmap);
41  painter->restore();
42 }
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QmitkTableItemThumbnailDelegate(QObject *parent=nullptr)