HAL
grouping_color_delegate.cpp
Go to the documentation of this file.
3 #include <QTableView>
4 #include <QBrush>
5 #include <QPainter>
6 #include <QRect>
7 
8 namespace hal {
9 
11  {
12  const QTableView* tv = static_cast<const QTableView*>(parent());
13  if (!tv) return;
14  const GroupingTableModel* gtm = static_cast<const GroupingTableModel*>(tv->model());
15  if (!gtm) return;
16  QRect ro = option.rect;
17  int w10 = ro.width()/10;
18  int h10 = ro.height()/10;
19  QRect rb(ro.topLeft() + QPoint(w10,h10), QSize(ro.width()-2*w10,ro.height()-2*h10));
20  painter->fillRect(rb,Qt::black);
21  QColor color = gtm->data(index,Qt::BackgroundRole).value<QColor>();
22  QRect rc(ro.topLeft() + QPoint(2*w10,2*h10), QSize(ro.width()-4*w10,ro.height()-4*h10));
23  painter->fillRect(rc, color);
24  }
25 
27  {
28  Q_UNUSED(index);
29  return option.rect.size();
30  }
31 }
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Table that holds information about all groupings.
QVariant data(const QModelIndex &index, int role) const override
option(PL_GUI "PL_GUI" ON) if(PL_GUI OR BUILD_ALL_PLUGINS) cmake_minimum_required(VERSION 3.1.0) if(APPLE AND CMAKE_HOST_APPLE AND NOT Qt5_DIR) set(Qt5_DIR "/usr/local/opt/qt@5/lib/cmake") endif(APPLE AND CMAKE_HOST_APPLE AND NOT Qt5_DIR) find_package(Qt5 COMPONENTS Core REQUIRED) find_package(Qt5 COMPONENTS Widgets REQUIRED) if(Qt5Widgets_FOUND) message(VERBOSE "Qt5Widgets_INCLUDE_DIRS
Definition: CMakeLists.txt:1
QAbstractItemModel * model() const const
QObject * parent() const const
void fillRect(const QRectF &rectangle, const QBrush &brush)
int height() const const
QPoint topLeft() const const
int width() const const
BackgroundRole
T value() const const