parent
55474fa8d6
commit
b45305da38
@ -1,34 +0,0 @@ |
||||
|
||||
#include <QApplication> |
||||
#include <QStyleOptionButton> |
||||
#include <QStyledItemDelegate> |
||||
#include <QStyleOptionViewItem> |
||||
#include <QPainter> |
||||
#include <QModelIndex> |
||||
#include "UBTGWidgetTreeDelegate.h" |
||||
|
||||
UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) : |
||||
QStyledItemDelegate(parent) |
||||
{ |
||||
//NOOP
|
||||
} |
||||
|
||||
void UBTGWidgetTreeDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const |
||||
{ |
||||
if(index.data(Qt::UserRole) != eUBTGAddSubItemWidgetType_None){ |
||||
painter->setBackgroundMode(Qt::OpaqueMode); |
||||
painter->setBackground(QBrush(QColor(Qt::red))); |
||||
QStyleOptionButton styleButton; |
||||
styleButton.text = "pipo"; |
||||
styleButton.rect = option.rect; |
||||
QApplication::style()->drawControl(QStyle::CE_PushButtonLabel,&styleButton,painter); |
||||
} |
||||
else |
||||
QStyledItemDelegate::paint(painter,option,index); |
||||
} |
||||
|
||||
QSize UBTGWidgetTreeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const |
||||
{ |
||||
QSize size = QStyledItemDelegate::sizeHint(option,index); |
||||
return size; |
||||
} |
@ -1,35 +0,0 @@ |
||||
#ifndef UBTGWIDGETTREEDELEGATE_H |
||||
#define UBTGWIDGETTREEDELEGATE_H |
||||
|
||||
class QPainter; |
||||
class QStyleOptionViewItem; |
||||
class QModelIndex; |
||||
|
||||
#include <QStyledItemDelegate> |
||||
|
||||
|
||||
typedef enum |
||||
{ |
||||
eUBTGAddSubItemWidgetType_None, |
||||
eUBTGAddSubItemWidgetType_Action , |
||||
eUBTGAddSubItemWidgetType_Media, |
||||
eUBTGAddSubItemWidgetType_Url |
||||
}eUBTGAddSubItemWidgetType; |
||||
|
||||
|
||||
class UBTGWidgetTreeDelegate : public QStyledItemDelegate |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit UBTGWidgetTreeDelegate(QObject *parent = 0); |
||||
|
||||
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; |
||||
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||||
|
||||
signals: |
||||
|
||||
public slots: |
||||
|
||||
}; |
||||
|
||||
#endif // UBTGWIDGETTREEDELEGATE_H
|
Loading…
Reference in new issue