| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include "CustomItemDelegate.h"
- #include "UserInterfaceUtility.h"
- #include <QPainter>
- #include <QEvent>
- class CustomItemDelegatePrivate
- {
- Q_DISABLE_COPY(CustomItemDelegatePrivate)
- public:
- explicit CustomItemDelegatePrivate(CustomItemDelegate* parent);
- ~CustomItemDelegatePrivate();
- private:
- friend class CustomItemDelegate;
- CustomItemDelegate* m_Parent;
- };
- CustomItemDelegate::CustomItemDelegate(QObject *parent)
- : QStyledItemDelegate(parent)
- , m_Private(new CustomItemDelegatePrivate(this))
- {
- }
- CustomItemDelegate::~CustomItemDelegate()
- {
- }
- void CustomItemDelegate::mousePressEvent(QMouseEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
- {
- Q_UNUSED(event);
- Q_UNUSED(model);
- Q_UNUSED(option);
- Q_UNUSED(index);
- }
- void CustomItemDelegate::mouseMoveEvent(QMouseEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
- {
- Q_UNUSED(event);
- Q_UNUSED(model);
- Q_UNUSED(option);
- Q_UNUSED(index);
- }
- void CustomItemDelegate::mouseReleaseEvent(QMouseEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
- {
- Q_UNUSED(event);
- Q_UNUSED(model);
- Q_UNUSED(option);
- Q_UNUSED(index);
- }
- bool CustomItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
- {
- switch (event->type()) {
- case QEvent::MouseButtonPress: {
- QMouseEvent* mouseEvent = reinterpret_cast<QMouseEvent*>(event);
- if (NULL != mouseEvent) {
- mousePressEvent(mouseEvent, model, option, index);
- }
- break;
- }
- case QEvent::MouseMove: {
- QMouseEvent* mouseEvent = reinterpret_cast<QMouseEvent*>(event);
- if (NULL != mouseEvent) {
- mouseMoveEvent(mouseEvent, model, option, index);
- }
- break;
- }
- case QEvent::MouseButtonRelease: {
- QMouseEvent* mouseEvent = reinterpret_cast<QMouseEvent*>(event);
- if (NULL != mouseEvent) {
- mouseReleaseEvent(mouseEvent, model, option, index);
- }
- break;
- }
- default: {
- break;
- }
- }
- return QStyledItemDelegate::editorEvent(event, model, option, index);
- }
- QWidget *CustomItemDelegate::createEditor(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
- {
- return QStyledItemDelegate::createEditor(editor, option, index);
- }
- void CustomItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
- {
- QStyledItemDelegate::updateEditorGeometry(editor, option, index);
- }
- QSize CustomItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
- {
- return QStyledItemDelegate::sizeHint(option, index);
- }
- void CustomItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
- {
- QStyledItemDelegate::setEditorData(editor, index);
- }
- void CustomItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
- {
- QStyledItemDelegate::setModelData(editor, model, index);
- }
- void CustomItemDelegate::onCurrentIndexChange(const QModelIndex &index)
- {
- Q_UNUSED(index);
- }
- void CustomItemDelegate::onPressIndexChanged(const QModelIndex &index)
- {
- Q_UNUSED(index);
- }
- void CustomItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
- {
- Q_UNUSED(painter);
- Q_UNUSED(option);
- Q_UNUSED(index);
- // QItemDelegate::paint(painter, option, index);
- }
- CustomItemDelegatePrivate::CustomItemDelegatePrivate(CustomItemDelegate *parent)
- : m_Parent(parent)
- {
- }
- CustomItemDelegatePrivate::~CustomItemDelegatePrivate()
- {
- }
|