Implemented a custom delegate that does the samework as the BaseTableModel class did.

While this might seem to duplicate behaviour I believe having this code in a delegate
is a better solution.
- the logic in BaseTableModel is view logic not model logic
- letting the custom delegate determine the formatting is much more efficient
  then letting the default delegate do many virtual calls to detemine how the
  model wants it formatted.
This commit is contained in:
eelke 2018-01-15 12:21:24 +01:00
parent 2ba27178a2
commit 3ac1d21728
2 changed files with 147 additions and 0 deletions

18
pglab/PgLabItemDelegate.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef PGLABITEMDELEGATE_H
#define PGLABITEMDELEGATE_H
#include <QStyledItemDelegate>
class PgLabItemDelegate : public QStyledItemDelegate
{
public:
PgLabItemDelegate(QObject *parent = nullptr);
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
protected:
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override;
};
#endif // PGLABITEMDELEGATE_H