scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

TableItemDelegate.cpp
Go to the documentation of this file.
1 
11 
30 #include <QPainter>
31 #include <QModelIndex>
32 #include "TableItemDelegate.h"
33 #include "TableModel.h"
34 
36  : QItemDelegate(parent)
37 {
38  d_masking_color = QColor(0xff,0,0);
39 }
40 
41 void TableItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
42  const QModelIndex &index) const
43 {
44  QItemDelegate::paint(painter, option, index);
45  if (!index.data(TableModel::MaskingRole).toBool())
46  return;
47  painter->save();
48  // masked cells are displayed as hatched
49  painter->fillRect(option.rect, QBrush(d_masking_color, Qt::BDiagPattern));
50  painter->restore();
51 }
52 
53 void TableItemDelegate::setModelData ( QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const
54 {
55  model->setData(index, editor->metaObject()->userProperty().read(editor), Qt::EditRole);
56 }
57 
58 void TableItemDelegate::setEditorData ( QWidget * editor, const QModelIndex & index ) const
59 {
60  editor->metaObject()->userProperty().write(editor, index.data(Qt::EditRole));
61 }
62 
TableItemDelegate::paint
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Custom cell painting.
Definition: TableItemDelegate.cpp:41
TableItemDelegate::setModelData
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Definition: TableItemDelegate.cpp:53
TableItemDelegate::TableItemDelegate
TableItemDelegate(QObject *parent=0)
Standard constructor.
Definition: TableItemDelegate.cpp:35
TableModel.h
TableItemDelegate::setEditorData
void setEditorData(QWidget *editor, const QModelIndex &index) const
Definition: TableItemDelegate.cpp:58
TableItemDelegate::d_masking_color
QColor d_masking_color
The color for masked cells.
Definition: TableItemDelegate.h:54
TableModel::MaskingRole
@ MaskingRole
bool determining whether the cell is masked
Definition: TableModel.h:65
TableItemDelegate.h