Move the viewOptions code back to public implementation
The code generating the QStyleOptionViewItem has been moved back to the public implementation and the private QAbstractItemView::viewOptions calling it (like the Qt 4 implementation does). This makes the item views behave properly again e.g. QListView drag & drop in Icon mode gets the correct options to draw the moving items Task-number: QTBUG-1180 Change-Id: I068861e1485252f12d73f9acaf12933d0ec84e2c Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>bb10
parent
c3bf3bd8b7
commit
b329c8ffb9
|
|
@ -3600,45 +3600,45 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions)
|
|||
QStyleOptionViewItem QAbstractItemView::viewOptions() const
|
||||
{
|
||||
Q_D(const QAbstractItemView);
|
||||
return d->viewOptions();
|
||||
}
|
||||
|
||||
QStyleOptionViewItem QAbstractItemViewPrivate::viewOptions() const
|
||||
{
|
||||
Q_Q(const QAbstractItemView);
|
||||
QStyleOptionViewItem option;
|
||||
option.init(q);
|
||||
option.init(this);
|
||||
option.state &= ~QStyle::State_MouseOver;
|
||||
option.font = q->font();
|
||||
option.font = font();
|
||||
|
||||
#ifndef Q_WS_MAC
|
||||
// On mac the focus appearance follows window activation
|
||||
// not widget activation
|
||||
if (!q->hasFocus())
|
||||
if (!hasFocus())
|
||||
option.state &= ~QStyle::State_Active;
|
||||
#endif
|
||||
|
||||
option.state &= ~QStyle::State_HasFocus;
|
||||
if (iconSize.isValid()) {
|
||||
option.decorationSize = iconSize;
|
||||
if (d->iconSize.isValid()) {
|
||||
option.decorationSize = d->iconSize;
|
||||
} else {
|
||||
int pm = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
|
||||
int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
|
||||
option.decorationSize = QSize(pm, pm);
|
||||
}
|
||||
option.decorationPosition = QStyleOptionViewItem::Left;
|
||||
option.decorationAlignment = Qt::AlignCenter;
|
||||
option.displayAlignment = Qt::AlignLeft|Qt::AlignVCenter;
|
||||
option.textElideMode = textElideMode;
|
||||
option.textElideMode = d->textElideMode;
|
||||
option.rect = QRect();
|
||||
option.showDecorationSelected = q->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, q);
|
||||
if (wrapItemText)
|
||||
option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, this);
|
||||
if (d->wrapItemText)
|
||||
option.features = QStyleOptionViewItem::WrapText;
|
||||
option.locale = q->locale();
|
||||
option.locale = locale();
|
||||
option.locale.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
option.widget = q;
|
||||
option.widget = this;
|
||||
return option;
|
||||
}
|
||||
|
||||
QStyleOptionViewItem QAbstractItemViewPrivate::viewOptions() const
|
||||
{
|
||||
Q_Q(const QAbstractItemView);
|
||||
return q->viewOptions();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the item view's state.
|
||||
|
||||
|
|
|
|||
|
|
@ -901,20 +901,14 @@ void QListView::startDrag(Qt::DropActions supportedActions)
|
|||
QStyleOptionViewItem QListView::viewOptions() const
|
||||
{
|
||||
Q_D(const QListView);
|
||||
return d->viewOptions();
|
||||
}
|
||||
|
||||
QStyleOptionViewItem QListViewPrivate::viewOptions() const
|
||||
{
|
||||
Q_Q(const QListView);
|
||||
QStyleOptionViewItem option = QAbstractItemViewPrivate::viewOptions();
|
||||
if (!iconSize.isValid()) { // otherwise it was already set in abstractitemview
|
||||
int pm = (viewMode == QListView::ListMode
|
||||
? q->style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, q)
|
||||
: q->style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, q));
|
||||
QStyleOptionViewItem option = QAbstractItemView::viewOptions();
|
||||
if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview
|
||||
int pm = (d->viewMode == QListView::ListMode
|
||||
? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this)
|
||||
: style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this));
|
||||
option.decorationSize = QSize(pm, pm);
|
||||
}
|
||||
if (viewMode == QListView::IconMode) {
|
||||
if (d->viewMode == QListView::IconMode) {
|
||||
option.showDecorationSelected = false;
|
||||
option.decorationPosition = QStyleOptionViewItem::Top;
|
||||
option.displayAlignment = Qt::AlignCenter;
|
||||
|
|
|
|||
|
|
@ -391,8 +391,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
QStyleOptionViewItem viewOptions() const;
|
||||
|
||||
void scrollElasticBandBy(int dx, int dy);
|
||||
|
||||
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
|
||||
|
|
|
|||
|
|
@ -1346,20 +1346,14 @@ void QTableView::scrollContentsBy(int dx, int dy)
|
|||
}
|
||||
}
|
||||
|
||||
QStyleOptionViewItem QTableViewPrivate::viewOptions() const
|
||||
{
|
||||
QStyleOptionViewItem option = QAbstractItemViewPrivate::viewOptions();
|
||||
option.showDecorationSelected = true;
|
||||
return option;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QStyleOptionViewItem QTableView::viewOptions() const
|
||||
{
|
||||
Q_D(const QTableView);
|
||||
return d->viewOptions();
|
||||
QStyleOptionViewItem option = QAbstractItemView::viewOptions();
|
||||
option.showDecorationSelected = true;
|
||||
return option;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -150,8 +150,6 @@ public:
|
|||
void init();
|
||||
void trimHiddenSelections(QItemSelectionRange *range) const;
|
||||
|
||||
QStyleOptionViewItem viewOptions() const;
|
||||
|
||||
inline bool isHidden(int row, int col) const {
|
||||
return verticalHeader->isSectionHidden(row)
|
||||
|| horizontalHeader->isSectionHidden(col);
|
||||
|
|
|
|||
Loading…
Reference in New Issue