#include "CustomItemDelegate.h" #include "UserInterfaceUtility.h" #include #include 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(event); if (NULL != mouseEvent) { mousePressEvent(mouseEvent, model, option, index); } break; } case QEvent::MouseMove: { QMouseEvent* mouseEvent = reinterpret_cast(event); if (NULL != mouseEvent) { mouseMoveEvent(mouseEvent, model, option, index); } break; } case QEvent::MouseButtonRelease: { QMouseEvent* mouseEvent = reinterpret_cast(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() { }