1
0
Fork 0
forked from len0rd/rockbox

regtools/qeditor: replace deprecated QStyleOptionViewItemV4

...by QStyleOptionViewItem. Yes Qt got it right, in 5.7 they deprecated
QStyleOptionViewItemV4 and recommend using QStyleOptionViewItem which contains
less fields except on newer Qt where it contains all fields. Hopefully it still
works on Qt>4.x for a large enough value of x.

Change-Id: I013c383d2424b04c1c0745f0d7b1d5e62a29d324
This commit is contained in:
Amaury Pouly 2017-01-27 18:21:04 +01:00
parent 2a3a6bb4b3
commit 2ea0ccb6c5
2 changed files with 5 additions and 5 deletions

View file

@ -1042,7 +1042,7 @@ void YRegDisplayItemEditor::paintEvent(QPaintEvent *event)
Q_UNUSED(event); Q_UNUSED(event);
QPainter painter(this); QPainter painter(this);
/* reuse delegate code to paint */ /* reuse delegate code to paint */
QStyleOptionViewItemV4 opt = m_display->viewOptions(); QStyleOptionViewItem opt = m_display->viewOptions();
opt.state |= QStyle::State_HasFocus | QStyle::State_Selected | QStyle::State_Active; opt.state |= QStyle::State_HasFocus | QStyle::State_Selected | QStyle::State_Active;
opt.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter; opt.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
opt.rect = rect(); opt.rect = rect();
@ -1060,9 +1060,9 @@ YRegDisplayItemDelegate::YRegDisplayItemDelegate(QObject *parent)
{ {
} }
void YRegDisplayItemDelegate::MyPaint(QPainter *painter, const QStyleOptionViewItemV4& option) const void YRegDisplayItemDelegate::MyPaint(QPainter *painter, const QStyleOptionViewItem& option) const
{ {
QStyleOptionViewItemV4 opt = option; QStyleOptionViewItem opt = option;
painter->save(); painter->save();
// draw everything rotated, requires careful manipulation of the // draw everything rotated, requires careful manipulation of the
// rects involved // rects involved
@ -1077,7 +1077,7 @@ void YRegDisplayItemDelegate::MyPaint(QPainter *painter, const QStyleOptionViewI
void YRegDisplayItemDelegate::paint(QPainter *painter, void YRegDisplayItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem& option, const QModelIndex& index) const const QStyleOptionViewItem& option, const QModelIndex& index) const
{ {
QStyleOptionViewItemV4 opt = option; QStyleOptionViewItem opt = option;
// default alignment is centered unless specified // default alignment is centered unless specified
opt.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter; opt.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
initStyleOption(&opt, index); initStyleOption(&opt, index);

View file

@ -443,7 +443,7 @@ public:
YRegDisplayItemDelegate(QObject *parent = 0); YRegDisplayItemDelegate(QObject *parent = 0);
virtual void paint(QPainter *painter, const QStyleOptionViewItem& option, virtual void paint(QPainter *painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const; const QModelIndex& index) const;
virtual void MyPaint(QPainter *painter, const QStyleOptionViewItemV4& option) const; virtual void MyPaint(QPainter *painter, const QStyleOptionViewItem& option) const;
virtual QSize sizeHint(const QStyleOptionViewItem& option, virtual QSize sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const; const QModelIndex& index) const;
/* don't bother using the item factory and such, we only use this delegate /* don't bother using the item factory and such, we only use this delegate