Replace QStyleOptionViewItemV? with QStyleOptionViewItem
The former are a typedef for the latter in Qt 5. This only touches internal implementation, as the API was migrated long ago. Change-Id: Ided73021ebecc00508e6325c3d988b6c6ad336cd Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
5ad378859a
commit
f4a8383a9a
@ -1663,7 +1663,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
|
||||
case QEvent::WhatsThis: {
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
const QModelIndex index = indexAt(he->pos());
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
option.rect = visualRect(index);
|
||||
option.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
|
||||
|
||||
@ -1863,7 +1863,7 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
|
||||
emit clicked(index);
|
||||
if (edited)
|
||||
return;
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
if (d->pressedAlreadySelected)
|
||||
option.state |= QStyle::State_Selected;
|
||||
if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this))
|
||||
@ -2654,7 +2654,7 @@ void QAbstractItemView::updateEditorGeometries()
|
||||
Q_D(QAbstractItemView);
|
||||
if(d->editorIndexHash.isEmpty())
|
||||
return;
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
QEditorIndexHash::iterator it = d->editorIndexHash.begin();
|
||||
QWidgetList editorsToRelease;
|
||||
QWidgetList editorsToHide;
|
||||
@ -2997,7 +2997,7 @@ QSize QAbstractItemView::sizeHintForIndex(const QModelIndex &index) const
|
||||
Q_D(const QAbstractItemView);
|
||||
if (!d->isIndexValid(index) || !d->itemDelegate)
|
||||
return QSize();
|
||||
return d->delegateForIndex(index)->sizeHint(d->viewOptionsV4(), index);
|
||||
return d->delegateForIndex(index)->sizeHint(d->viewOptions(), index);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3025,7 +3025,7 @@ int QAbstractItemView::sizeHintForRow(int row) const
|
||||
|
||||
ensurePolished();
|
||||
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
int height = 0;
|
||||
int colCount = d->model->columnCount(d->root);
|
||||
QModelIndex index;
|
||||
@ -3056,7 +3056,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const
|
||||
|
||||
ensurePolished();
|
||||
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
int width = 0;
|
||||
int rows = d->model->rowCount(d->root);
|
||||
QModelIndex index;
|
||||
@ -3079,7 +3079,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const
|
||||
void QAbstractItemView::openPersistentEditor(const QModelIndex &index)
|
||||
{
|
||||
Q_D(QAbstractItemView);
|
||||
QStyleOptionViewItemV4 options = d->viewOptionsV4();
|
||||
QStyleOptionViewItem options = d->viewOptions();
|
||||
options.rect = visualRect(index);
|
||||
options.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
|
||||
|
||||
@ -3617,13 +3617,13 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions)
|
||||
QStyleOptionViewItem QAbstractItemView::viewOptions() const
|
||||
{
|
||||
Q_D(const QAbstractItemView);
|
||||
return d->viewOptionsV4();
|
||||
return d->viewOptions();
|
||||
}
|
||||
|
||||
QStyleOptionViewItemV4 QAbstractItemViewPrivate::viewOptionsV4() const
|
||||
QStyleOptionViewItem QAbstractItemViewPrivate::viewOptions() const
|
||||
{
|
||||
Q_Q(const QAbstractItemView);
|
||||
QStyleOptionViewItemV4 option;
|
||||
QStyleOptionViewItem option;
|
||||
option.init(q);
|
||||
option.state &= ~QStyle::State_MouseOver;
|
||||
option.font = q->font();
|
||||
@ -3649,7 +3649,7 @@ QStyleOptionViewItemV4 QAbstractItemViewPrivate::viewOptionsV4() const
|
||||
option.rect = QRect();
|
||||
option.showDecorationSelected = q->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, q);
|
||||
if (wrapItemText)
|
||||
option.features = QStyleOptionViewItemV2::WrapText;
|
||||
option.features = QStyleOptionViewItem::WrapText;
|
||||
option.locale = q->locale();
|
||||
option.locale.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
option.widget = q;
|
||||
@ -4243,7 +4243,7 @@ bool QAbstractItemViewPrivate::sendDelegateEvent(const QModelIndex &index, QEven
|
||||
{
|
||||
Q_Q(const QAbstractItemView);
|
||||
QModelIndex buddy = model->buddy(index);
|
||||
QStyleOptionViewItemV4 options = viewOptionsV4();
|
||||
QStyleOptionViewItem options = viewOptions();
|
||||
options.rect = q->visualRect(buddy);
|
||||
options.state |= (buddy == q->currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
|
||||
QAbstractItemDelegate *delegate = delegateForIndex(index);
|
||||
@ -4255,7 +4255,7 @@ bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *even
|
||||
Q_Q(QAbstractItemView);
|
||||
|
||||
QModelIndex buddy = model->buddy(index);
|
||||
QStyleOptionViewItemV4 options = viewOptionsV4();
|
||||
QStyleOptionViewItem options = viewOptions();
|
||||
options.rect = q->visualRect(buddy);
|
||||
options.state |= (buddy == q->currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
|
||||
|
||||
@ -4307,7 +4307,7 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes,
|
||||
QPixmap pixmap(r->size());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
QStyleOptionViewItemV4 option = viewOptionsV4();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
option.state |= QStyle::State_Selected;
|
||||
for (int j = 0; j < paintPairs.count(); ++j) {
|
||||
option.rect = paintPairs.at(j).first.translated(-r->topLeft());
|
||||
|
@ -197,7 +197,7 @@ public:
|
||||
#endif
|
||||
virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
|
||||
// reimplemented in subclasses
|
||||
virtual void adjustViewOptionsForIndex(QStyleOptionViewItemV4*, const QModelIndex&) const {}
|
||||
virtual void adjustViewOptionsForIndex(QStyleOptionViewItem*, const QModelIndex&) const {}
|
||||
|
||||
inline void releaseEditor(QWidget *editor, const QModelIndex &index = QModelIndex()) const {
|
||||
if (editor) {
|
||||
@ -345,7 +345,7 @@ public:
|
||||
|
||||
QModelIndexList selectedDraggableIndexes() const;
|
||||
|
||||
QStyleOptionViewItemV4 viewOptionsV4() const;
|
||||
QStyleOptionViewItem viewOptions() const;
|
||||
|
||||
void doDelayedReset()
|
||||
{
|
||||
|
@ -1134,7 +1134,7 @@ void QColumnViewDelegate::paint(QPainter *painter,
|
||||
bool reverse = (option.direction == Qt::RightToLeft);
|
||||
int width = ((option.rect.height() * 2) / 3);
|
||||
// Modify the options to give us room to add an arrow
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
if (reverse)
|
||||
opt.rect.adjust(width,0,0,0);
|
||||
else
|
||||
|
@ -111,24 +111,21 @@ public:
|
||||
return text;
|
||||
}
|
||||
|
||||
static QString valueToText(const QVariant &value, const QStyleOptionViewItemV4 &option);
|
||||
static QString valueToText(const QVariant &value, const QStyleOptionViewItem &option);
|
||||
|
||||
void _q_commitDataAndCloseEditor(QWidget *editor);
|
||||
|
||||
QItemEditorFactory *f;
|
||||
bool clipPainting;
|
||||
|
||||
QRect textLayoutBounds(const QStyleOptionViewItemV2 &options) const;
|
||||
QRect textLayoutBounds(const QStyleOptionViewItem &options) const;
|
||||
QSizeF doTextLayout(int lineWidth) const;
|
||||
mutable QTextLayout textLayout;
|
||||
mutable QTextOption textOption;
|
||||
|
||||
const QWidget *widget(const QStyleOptionViewItem &option) const
|
||||
{
|
||||
if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option))
|
||||
return v3->widget;
|
||||
|
||||
return 0;
|
||||
return option.widget;
|
||||
}
|
||||
|
||||
// ### temporary hack until we have QStandardItemDelegate
|
||||
@ -146,10 +143,10 @@ void QItemDelegatePrivate::_q_commitDataAndCloseEditor(QWidget *editor)
|
||||
emit q->closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
|
||||
}
|
||||
|
||||
QRect QItemDelegatePrivate::textLayoutBounds(const QStyleOptionViewItemV2 &option) const
|
||||
QRect QItemDelegatePrivate::textLayoutBounds(const QStyleOptionViewItem &option) const
|
||||
{
|
||||
QRect rect = option.rect;
|
||||
const bool wrapText = option.features & QStyleOptionViewItemV2::WrapText;
|
||||
const bool wrapText = option.features & QStyleOptionViewItem::WrapText;
|
||||
switch (option.decorationPosition) {
|
||||
case QStyleOptionViewItem::Left:
|
||||
case QStyleOptionViewItem::Right:
|
||||
@ -353,7 +350,7 @@ void QItemDelegate::setClipping(bool clip)
|
||||
d->clipPainting = clip;
|
||||
}
|
||||
|
||||
QString QItemDelegatePrivate::valueToText(const QVariant &value, const QStyleOptionViewItemV4 &option)
|
||||
QString QItemDelegatePrivate::valueToText(const QVariant &value, const QStyleOptionViewItem &option)
|
||||
{
|
||||
QString text;
|
||||
switch (value.userType()) {
|
||||
@ -667,13 +664,13 @@ void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &o
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
const QStyleOptionViewItemV4 opt = option;
|
||||
const QStyleOptionViewItem opt = option;
|
||||
|
||||
const QWidget *widget = d->widget(option);
|
||||
QStyle *style = widget ? widget->style() : QApplication::style();
|
||||
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
|
||||
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
|
||||
const bool wrapText = opt.features & QStyleOptionViewItemV2::WrapText;
|
||||
const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;
|
||||
d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
|
||||
d->textOption.setTextDirection(option.direction);
|
||||
d->textOption.setAlignment(QStyle::visualAlignment(option.direction, option.displayAlignment));
|
||||
|
@ -926,7 +926,7 @@ void QListView::paintEvent(QPaintEvent *e)
|
||||
Q_D(QListView);
|
||||
if (!d->itemDelegate)
|
||||
return;
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
QPainter painter(d->viewport);
|
||||
|
||||
const QVector<QModelIndex> toBeRendered = d->intersectingSet(e->rect().translated(horizontalOffset(), verticalOffset()), false);
|
||||
@ -995,9 +995,9 @@ void QListView::paintEvent(QPaintEvent *e)
|
||||
}
|
||||
}
|
||||
if (alternateBase) {
|
||||
option.features |= QStyleOptionViewItemV2::Alternate;
|
||||
option.features |= QStyleOptionViewItem::Alternate;
|
||||
} else {
|
||||
option.features &= ~QStyleOptionViewItemV2::Alternate;
|
||||
option.features &= ~QStyleOptionViewItem::Alternate;
|
||||
}
|
||||
|
||||
// draw background of the item (only alternate row). rest of the background
|
||||
@ -1455,7 +1455,7 @@ void QListView::updateGeometries()
|
||||
verticalScrollBar()->setRange(0, 0);
|
||||
} else {
|
||||
QModelIndex index = d->model->index(0, d->column, d->root);
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
QSize step = d->itemSize(option, index);
|
||||
d->commonListView->updateHorizontalScrollBar(step);
|
||||
d->commonListView->updateVerticalScrollBar(step);
|
||||
@ -2262,7 +2262,7 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c
|
||||
0, segmentStartRows.count() - 1);
|
||||
|
||||
|
||||
QStyleOptionViewItemV4 options = viewOptions();
|
||||
QStyleOptionViewItem options = viewOptions();
|
||||
options.rect.setSize(contentsSize);
|
||||
QSize size = (uniformItemSizes() && cachedItemSize().isValid())
|
||||
? cachedItemSize() : itemSize(options, index);
|
||||
@ -2327,7 +2327,7 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)
|
||||
{
|
||||
const bool useItemSize = !info.grid.isValid();
|
||||
const QPoint topLeft = initStaticLayout(info);
|
||||
QStyleOptionViewItemV4 option = viewOptions();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
option.rect = info.bounds;
|
||||
option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing);
|
||||
|
||||
@ -2649,7 +2649,7 @@ void QIconModeViewBase::paintDragDrop(QPainter *painter)
|
||||
if (!draggedItems.isEmpty() && viewport()->rect().contains(draggedItemsPos)) {
|
||||
//we need to draw the items that arre dragged
|
||||
painter->translate(draggedItemsDelta());
|
||||
QStyleOptionViewItemV4 option = viewOptions();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
option.state &= ~QStyle::State_MouseOver;
|
||||
QVector<QModelIndex>::const_iterator it = draggedItems.constBegin();
|
||||
QListViewItem item = indexToListViewItem(*it);
|
||||
@ -2791,7 +2791,7 @@ void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
|
||||
void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||
{
|
||||
if (column() >= topLeft.column() && column() <= bottomRight.column()) {
|
||||
QStyleOptionViewItemV4 option = viewOptions();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
int bottom = qMin(items.count(), bottomRight.row() + 1);
|
||||
for (int row = topLeft.row(); row < bottom; ++row)
|
||||
items[row].resize(itemSize(option, modelIndex(row)));
|
||||
@ -2802,7 +2802,7 @@ bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int
|
||||
{
|
||||
if (info.last >= items.count()) {
|
||||
//first we create the items
|
||||
QStyleOptionViewItemV4 option = viewOptions();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
for (int row = items.count(); row <= info.last; ++row) {
|
||||
QSize size = itemSize(option, modelIndex(row));
|
||||
QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos
|
||||
|
@ -175,13 +175,13 @@ public:
|
||||
inline QModelIndex modelIndex(int row) const;
|
||||
inline int rowCount() const;
|
||||
|
||||
inline QStyleOptionViewItemV4 viewOptions() const;
|
||||
inline QStyleOptionViewItem viewOptions() const;
|
||||
inline QWidget *viewport() const;
|
||||
inline QRect clipRect() const;
|
||||
|
||||
inline QSize cachedItemSize() const;
|
||||
inline QRect viewItemRect(const QListViewItem &item) const;
|
||||
inline QSize itemSize(const QStyleOptionViewItemV2 &opt, const QModelIndex &idx) const;
|
||||
inline QSize itemSize(const QStyleOptionViewItem &opt, const QModelIndex &idx) const;
|
||||
inline QAbstractItemDelegate *delegate(const QModelIndex &idx) const;
|
||||
|
||||
inline bool isHidden(int row) const;
|
||||
@ -468,13 +468,13 @@ inline QModelIndex QCommonListViewBase::modelIndex(int row) const
|
||||
{ return dd->model->index(row, dd->column, dd->root); }
|
||||
inline int QCommonListViewBase::rowCount() const { return dd->model->rowCount(dd->root); }
|
||||
|
||||
inline QStyleOptionViewItemV4 QCommonListViewBase::viewOptions() const { return dd->viewOptionsV4(); }
|
||||
inline QStyleOptionViewItem QCommonListViewBase::viewOptions() const { return dd->viewOptions(); }
|
||||
inline QWidget *QCommonListViewBase::viewport() const { return dd->viewport; }
|
||||
inline QRect QCommonListViewBase::clipRect() const { return dd->clipRect(); }
|
||||
|
||||
inline QSize QCommonListViewBase::cachedItemSize() const { return dd->cachedItemSize; }
|
||||
inline QRect QCommonListViewBase::viewItemRect(const QListViewItem &item) const { return dd->viewItemRect(item); }
|
||||
inline QSize QCommonListViewBase::itemSize(const QStyleOptionViewItemV2 &opt, const QModelIndex &idx) const
|
||||
inline QSize QCommonListViewBase::itemSize(const QStyleOptionViewItem &opt, const QModelIndex &idx) const
|
||||
{ return dd->itemSize(opt, idx); }
|
||||
|
||||
inline QAbstractItemDelegate *QCommonListViewBase::delegate(const QModelIndex &idx) const
|
||||
|
@ -89,9 +89,7 @@ public:
|
||||
|
||||
static const QWidget *widget(const QStyleOptionViewItem &option)
|
||||
{
|
||||
if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option))
|
||||
return v3->widget;
|
||||
return 0;
|
||||
return option.widget;
|
||||
}
|
||||
|
||||
const QItemEditorFactory *editorFactory() const
|
||||
@ -315,9 +313,7 @@ QString QStyledItemDelegate::displayText(const QVariant &value, const QLocale& l
|
||||
/*!
|
||||
Initialize \a option with the values using the index \a index. This method
|
||||
is useful for subclasses when they need a QStyleOptionViewItem, but don't want
|
||||
to fill in all the information themselves. This function will check the version
|
||||
of the QStyleOptionViewItem and fill in the additional values for a
|
||||
QStyleOptionViewItemV2, QStyleOptionViewItemV3 and QStyleOptionViewItemV4.
|
||||
to fill in all the information themselves.
|
||||
|
||||
\sa QStyleOption::initFrom()
|
||||
*/
|
||||
@ -338,62 +334,60 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
|
||||
if (value.canConvert<QBrush>())
|
||||
option->palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
|
||||
|
||||
if (QStyleOptionViewItemV4 *v4 = qstyleoption_cast<QStyleOptionViewItemV4 *>(option)) {
|
||||
v4->index = index;
|
||||
QVariant value = index.data(Qt::CheckStateRole);
|
||||
if (value.isValid() && !value.isNull()) {
|
||||
v4->features |= QStyleOptionViewItemV2::HasCheckIndicator;
|
||||
v4->checkState = static_cast<Qt::CheckState>(value.toInt());
|
||||
}
|
||||
|
||||
value = index.data(Qt::DecorationRole);
|
||||
if (value.isValid() && !value.isNull()) {
|
||||
v4->features |= QStyleOptionViewItemV2::HasDecoration;
|
||||
switch (value.type()) {
|
||||
case QVariant::Icon: {
|
||||
v4->icon = qvariant_cast<QIcon>(value);
|
||||
QIcon::Mode mode;
|
||||
if (!(option->state & QStyle::State_Enabled))
|
||||
mode = QIcon::Disabled;
|
||||
else if (option->state & QStyle::State_Selected)
|
||||
mode = QIcon::Selected;
|
||||
else
|
||||
mode = QIcon::Normal;
|
||||
QIcon::State state = option->state & QStyle::State_Open ? QIcon::On : QIcon::Off;
|
||||
v4->decorationSize = v4->icon.actualSize(option->decorationSize, mode, state);
|
||||
break;
|
||||
}
|
||||
case QVariant::Color: {
|
||||
QPixmap pixmap(option->decorationSize);
|
||||
pixmap.fill(qvariant_cast<QColor>(value));
|
||||
v4->icon = QIcon(pixmap);
|
||||
break;
|
||||
}
|
||||
case QVariant::Image: {
|
||||
QImage image = qvariant_cast<QImage>(value);
|
||||
v4->icon = QIcon(QPixmap::fromImage(image));
|
||||
v4->decorationSize = image.size();
|
||||
break;
|
||||
}
|
||||
case QVariant::Pixmap: {
|
||||
QPixmap pixmap = qvariant_cast<QPixmap>(value);
|
||||
v4->icon = QIcon(pixmap);
|
||||
v4->decorationSize = pixmap.size();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
value = index.data(Qt::DisplayRole);
|
||||
if (value.isValid() && !value.isNull()) {
|
||||
v4->features |= QStyleOptionViewItemV2::HasDisplay;
|
||||
v4->text = displayText(value, v4->locale);
|
||||
}
|
||||
|
||||
v4->backgroundBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
|
||||
option->index = index;
|
||||
value = index.data(Qt::CheckStateRole);
|
||||
if (value.isValid() && !value.isNull()) {
|
||||
option->features |= QStyleOptionViewItem::HasCheckIndicator;
|
||||
option->checkState = static_cast<Qt::CheckState>(value.toInt());
|
||||
}
|
||||
|
||||
value = index.data(Qt::DecorationRole);
|
||||
if (value.isValid() && !value.isNull()) {
|
||||
option->features |= QStyleOptionViewItem::HasDecoration;
|
||||
switch (value.type()) {
|
||||
case QVariant::Icon: {
|
||||
option->icon = qvariant_cast<QIcon>(value);
|
||||
QIcon::Mode mode;
|
||||
if (!(option->state & QStyle::State_Enabled))
|
||||
mode = QIcon::Disabled;
|
||||
else if (option->state & QStyle::State_Selected)
|
||||
mode = QIcon::Selected;
|
||||
else
|
||||
mode = QIcon::Normal;
|
||||
QIcon::State state = option->state & QStyle::State_Open ? QIcon::On : QIcon::Off;
|
||||
option->decorationSize = option->icon.actualSize(option->decorationSize, mode, state);
|
||||
break;
|
||||
}
|
||||
case QVariant::Color: {
|
||||
QPixmap pixmap(option->decorationSize);
|
||||
pixmap.fill(qvariant_cast<QColor>(value));
|
||||
option->icon = QIcon(pixmap);
|
||||
break;
|
||||
}
|
||||
case QVariant::Image: {
|
||||
QImage image = qvariant_cast<QImage>(value);
|
||||
option->icon = QIcon(QPixmap::fromImage(image));
|
||||
option->decorationSize = image.size();
|
||||
break;
|
||||
}
|
||||
case QVariant::Pixmap: {
|
||||
QPixmap pixmap = qvariant_cast<QPixmap>(value);
|
||||
option->icon = QIcon(pixmap);
|
||||
option->decorationSize = pixmap.size();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
value = index.data(Qt::DisplayRole);
|
||||
if (value.isValid() && !value.isNull()) {
|
||||
option->features |= QStyleOptionViewItem::HasDisplay;
|
||||
option->text = displayText(value, option->locale);
|
||||
}
|
||||
|
||||
option->backgroundBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -404,9 +398,7 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
|
||||
|
||||
When reimplementing paint in a subclass. Use the initStyleOption()
|
||||
to set up the \a option in the same way as the
|
||||
QStyledItemDelegate; the option will always be an instance of
|
||||
QStyleOptionViewItemV4. Please see its class description for
|
||||
information on its contents.
|
||||
QStyledItemDelegate.
|
||||
|
||||
Whenever possible, use the \a option while painting.
|
||||
Especially its \l{QStyleOption::}{rect} variable to decide
|
||||
@ -425,7 +417,7 @@ void QStyledItemDelegate::paint(QPainter *painter,
|
||||
{
|
||||
Q_ASSERT(index.isValid());
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
|
||||
const QWidget *widget = QStyledItemDelegatePrivate::widget(option);
|
||||
@ -450,7 +442,7 @@ QSize QStyledItemDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
if (value.isValid())
|
||||
return qvariant_cast<QSize>(value);
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
const QWidget *widget = QStyledItemDelegatePrivate::widget(option);
|
||||
QStyle *style = widget ? widget->style() : QApplication::style();
|
||||
@ -544,7 +536,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,
|
||||
Q_ASSERT(index.isValid());
|
||||
const QWidget *widget = QStyledItemDelegatePrivate::widget(option);
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
// let the editor take up all available space
|
||||
//if the editor is not a QLineEdit
|
||||
@ -723,7 +715,7 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
|
||||
if ((event->type() == QEvent::MouseButtonRelease)
|
||||
|| (event->type() == QEvent::MouseButtonDblClick)
|
||||
|| (event->type() == QEvent::MouseButtonPress)) {
|
||||
QStyleOptionViewItemV4 viewOpt(option);
|
||||
QStyleOptionViewItem viewOpt(option);
|
||||
initStyleOption(&viewOpt, index);
|
||||
QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget);
|
||||
QMouseEvent *me = static_cast<QMouseEvent*>(event);
|
||||
|
@ -797,7 +797,7 @@ QRect QTableViewPrivate::visualSpanRect(const QSpanCollection::Span &span) const
|
||||
\a drawn is a QBitArray of visualRowCountxvisualCoulumnCount which say if particular cell has been drawn
|
||||
*/
|
||||
void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
|
||||
const QStyleOptionViewItemV4 &option, QBitArray *drawn,
|
||||
const QStyleOptionViewItem &option, QBitArray *drawn,
|
||||
int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn)
|
||||
{
|
||||
bool alternateBase = false;
|
||||
@ -828,13 +828,13 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
|
||||
rect.translate(scrollDelayOffset);
|
||||
if (!area.intersects(rect))
|
||||
continue;
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
opt.rect = rect;
|
||||
alternateBase = alternatingColors && (span->top() & 1);
|
||||
if (alternateBase)
|
||||
opt.features |= QStyleOptionViewItemV2::Alternate;
|
||||
opt.features |= QStyleOptionViewItem::Alternate;
|
||||
else
|
||||
opt.features &= ~QStyleOptionViewItemV2::Alternate;
|
||||
opt.features &= ~QStyleOptionViewItem::Alternate;
|
||||
drawCell(painter, opt, index);
|
||||
region -= rect;
|
||||
for (int r = span->top(); r <= span->bottom(); ++r) {
|
||||
@ -898,10 +898,10 @@ void QTableViewPrivate::_q_updateSpanRemovedColumns(const QModelIndex &parent, i
|
||||
\internal
|
||||
Draws a table cell.
|
||||
*/
|
||||
void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
|
||||
void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
{
|
||||
Q_Q(QTableView);
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
|
||||
if (selectionModel && selectionModel->isSelected(index))
|
||||
opt.state |= QStyle::State_Selected;
|
||||
@ -1307,7 +1307,7 @@ void QTableView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_D(QTableView);
|
||||
// setup temp variables for the painting
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
const QPoint offset = d->scrollDelayOffset;
|
||||
const bool showGrid = d->showGrid;
|
||||
const int gridSize = showGrid ? 1 : 0;
|
||||
@ -1423,9 +1423,9 @@ void QTableView::paintEvent(QPaintEvent *event)
|
||||
option.rect = QRect(colp + (showGrid && rightToLeft ? 1 : 0), rowY, colw, rowh);
|
||||
if (alternate) {
|
||||
if (alternateBase)
|
||||
option.features |= QStyleOptionViewItemV2::Alternate;
|
||||
option.features |= QStyleOptionViewItem::Alternate;
|
||||
else
|
||||
option.features &= ~QStyleOptionViewItemV2::Alternate;
|
||||
option.features &= ~QStyleOptionViewItem::Alternate;
|
||||
}
|
||||
d->drawCell(&painter, option, index);
|
||||
}
|
||||
@ -2177,7 +2177,7 @@ int QTableView::sizeHintForRow(int row) const
|
||||
if (right == -1) // the table don't have enough columns to fill the viewport
|
||||
right = d->model->columnCount(d->root) - 1;
|
||||
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
|
||||
int hint = 0;
|
||||
QModelIndex index;
|
||||
@ -2236,7 +2236,7 @@ int QTableView::sizeHintForColumn(int column) const
|
||||
if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport
|
||||
bottom = d->model->rowCount(d->root) - 1;
|
||||
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
|
||||
int hint = 0;
|
||||
QModelIndex index;
|
||||
|
@ -176,9 +176,9 @@ public:
|
||||
int sectionSpanSize(const QHeaderView *header, int logical, int span) const;
|
||||
bool spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const;
|
||||
void drawAndClipSpans(const QRegion &area, QPainter *painter,
|
||||
const QStyleOptionViewItemV4 &option, QBitArray *drawn,
|
||||
const QStyleOptionViewItem &option, QBitArray *drawn,
|
||||
int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn);
|
||||
void drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index);
|
||||
void drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index);
|
||||
|
||||
bool showGrid;
|
||||
Qt::PenStyle gridStyle;
|
||||
|
@ -1284,7 +1284,7 @@ void QTreeView::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const
|
||||
void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItem *option, int y, int bottom) const
|
||||
{
|
||||
Q_Q(const QTreeView);
|
||||
if (!alternatingColors || !q->style()->styleHint(QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea, option, q))
|
||||
@ -1298,9 +1298,9 @@ void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOption
|
||||
while (y <= bottom) {
|
||||
option->rect.setRect(0, y, viewport->width(), rowHeight);
|
||||
if (current & 1) {
|
||||
option->features |= QStyleOptionViewItemV2::Alternate;
|
||||
option->features |= QStyleOptionViewItem::Alternate;
|
||||
} else {
|
||||
option->features &= ~QStyleOptionViewItemV2::Alternate;
|
||||
option->features &= ~QStyleOptionViewItem::Alternate;
|
||||
}
|
||||
++current;
|
||||
q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q);
|
||||
@ -1360,7 +1360,7 @@ QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList
|
||||
return QAbstractItemViewPrivate::draggablePaintPairs(list, r);
|
||||
}
|
||||
|
||||
void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const
|
||||
void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex ¤t) const
|
||||
{
|
||||
const int row = viewIndex(current); // get the index in viewItems[]
|
||||
option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None)
|
||||
@ -1371,7 +1371,7 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option,
|
||||
|| option->showDecorationSelected;
|
||||
|
||||
QVector<int> logicalIndices; // index = visual index of visible columns only. data = logical index.
|
||||
QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only.
|
||||
QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only.
|
||||
const bool spanning = viewItems.at(row).spanning;
|
||||
const int left = (spanning ? header->visualIndex(0) : 0);
|
||||
const int right = (spanning ? header->visualIndex(0) : header->count() - 1 );
|
||||
@ -1401,7 +1401,7 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const
|
||||
Q_D(const QTreeView);
|
||||
const QVector<QTreeViewItem> viewItems = d->viewItems;
|
||||
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
const QStyle::State state = option.state;
|
||||
d->current = 0;
|
||||
|
||||
@ -1473,12 +1473,12 @@ static inline bool ancestorOf(QObject *widget, QObject *other)
|
||||
return false;
|
||||
}
|
||||
|
||||
void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions, int left, int right) const
|
||||
void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItem::ViewItemPosition> *itemPositions, int left, int right) const
|
||||
{
|
||||
const int columnCount = header->count();
|
||||
/* 'left' and 'right' are the left-most and right-most visible visual indices.
|
||||
Compute the first visible logical indices before and after the left and right.
|
||||
We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */
|
||||
We will use these values to determine the QStyleOptionViewItem::viewItemPosition. */
|
||||
int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1;
|
||||
for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) {
|
||||
int logicalIndex = header->logicalIndex(visualIndex);
|
||||
@ -1509,16 +1509,16 @@ void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<
|
||||
int prevLogicalSection = currentLogicalSection - 1 < 0
|
||||
? logicalIndexBeforeLeft
|
||||
: logicalIndices->at(currentLogicalSection - 1);
|
||||
QStyleOptionViewItemV4::ViewItemPosition pos;
|
||||
QStyleOptionViewItem::ViewItemPosition pos;
|
||||
if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1)
|
||||
|| (headerSection == 0 && nextLogicalSection == -1) || spanning)
|
||||
pos = QStyleOptionViewItemV4::OnlyOne;
|
||||
pos = QStyleOptionViewItem::OnlyOne;
|
||||
else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1))
|
||||
pos = QStyleOptionViewItemV4::Beginning;
|
||||
pos = QStyleOptionViewItem::Beginning;
|
||||
else if (nextLogicalSection == 0 || nextLogicalSection == -1)
|
||||
pos = QStyleOptionViewItemV4::End;
|
||||
pos = QStyleOptionViewItem::End;
|
||||
else
|
||||
pos = QStyleOptionViewItemV4::Middle;
|
||||
pos = QStyleOptionViewItem::Middle;
|
||||
(*itemPositions)[currentLogicalSection] = pos;
|
||||
}
|
||||
}
|
||||
@ -1535,7 +1535,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
Q_D(const QTreeView);
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
QStyleOptionViewItem opt = option;
|
||||
const QPoint offset = d->scrollDelayOffset;
|
||||
const int y = option.rect.y() + offset.y();
|
||||
const QModelIndex parent = index.parent();
|
||||
@ -1597,7 +1597,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
&& index.row() == hover.row();
|
||||
|
||||
QVector<int> logicalIndices;
|
||||
QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex
|
||||
QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex
|
||||
d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right);
|
||||
|
||||
for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) {
|
||||
@ -1655,9 +1655,9 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
|
||||
if (alternate) {
|
||||
if (d->current & 1) {
|
||||
opt.features |= QStyleOptionViewItemV2::Alternate;
|
||||
opt.features |= QStyleOptionViewItem::Alternate;
|
||||
} else {
|
||||
opt.features &= ~QStyleOptionViewItemV2::Alternate;
|
||||
opt.features &= ~QStyleOptionViewItem::Alternate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1746,7 +1746,7 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
|
||||
QModelIndex current = parent;
|
||||
QModelIndex ancestor = current.parent();
|
||||
|
||||
QStyleOptionViewItemV2 opt = viewOptions();
|
||||
QStyleOptionViewItem opt = viewOptions();
|
||||
QStyle::State extraFlags = QStyle::State_None;
|
||||
if (isEnabled())
|
||||
extraFlags |= QStyle::State_Enabled;
|
||||
@ -1758,9 +1758,9 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
|
||||
|
||||
if (d->alternatingColors) {
|
||||
if (d->current & 1) {
|
||||
opt.features |= QStyleOptionViewItemV2::Alternate;
|
||||
opt.features |= QStyleOptionViewItem::Alternate;
|
||||
} else {
|
||||
opt.features &= ~QStyleOptionViewItemV2::Alternate;
|
||||
opt.features &= ~QStyleOptionViewItem::Alternate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2732,7 +2732,7 @@ int QTreeView::sizeHintForColumn(int column) const
|
||||
return -1;
|
||||
ensurePolished();
|
||||
int w = 0;
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
const QVector<QTreeViewItem> viewItems = d->viewItems;
|
||||
|
||||
int start = 0;
|
||||
@ -2799,7 +2799,7 @@ int QTreeView::indexRowSizeHint(const QModelIndex &index) const
|
||||
qSwap(end, start);
|
||||
|
||||
int height = -1;
|
||||
QStyleOptionViewItemV4 option = d->viewOptionsV4();
|
||||
QStyleOptionViewItem option = d->viewOptions();
|
||||
// ### If we want word wrapping in the items,
|
||||
// ### we need to go through all the columns
|
||||
// ### and set the width of the column
|
||||
@ -3069,7 +3069,7 @@ QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) cons
|
||||
painter.end();
|
||||
|
||||
//and now let's render the editors the editors
|
||||
QStyleOptionViewItemV4 option = viewOptionsV4();
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
for (QEditorIndexHash::const_iterator it = editorIndexHash.constBegin(); it != editorIndexHash.constEnd(); ++it) {
|
||||
QWidget *editor = it.key();
|
||||
const QModelIndex &index = it.value();
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
void initialize();
|
||||
|
||||
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
|
||||
void adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const;
|
||||
void adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex ¤t) const;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
struct AnimatedOperation : public QVariantAnimation
|
||||
@ -166,11 +166,11 @@ public:
|
||||
|
||||
void updateChildCount(const int parentItem, const int delta);
|
||||
|
||||
void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const;
|
||||
void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItem *option, int y, int bottom) const;
|
||||
|
||||
// logicalIndices: vector of currently visibly logical indices
|
||||
// itemPositions: vector of view item positions (beginning/middle/end/onlyone)
|
||||
void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions, int left, int right) const;
|
||||
void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItem::ViewItemPosition> *itemPositions, int left, int right) const;
|
||||
|
||||
QHeaderView *header;
|
||||
int indent;
|
||||
|
@ -635,7 +635,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
||||
break; }
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case PE_PanelItemViewRow:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QPalette::ColorGroup cg = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled))
|
||||
? QPalette::Normal : QPalette::Disabled;
|
||||
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
|
||||
@ -643,12 +643,12 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
||||
|
||||
if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget))
|
||||
p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
|
||||
else if (vopt->features & QStyleOptionViewItemV2::Alternate)
|
||||
else if (vopt->features & QStyleOptionViewItem::Alternate)
|
||||
p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
|
||||
}
|
||||
break;
|
||||
case PE_PanelItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QPalette::ColorGroup cg = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled))
|
||||
? QPalette::Normal : QPalette::Disabled;
|
||||
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
|
||||
@ -712,24 +712,24 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
|
||||
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
|
||||
QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, int role) const
|
||||
QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int role) const
|
||||
{
|
||||
const QWidget *widget = option->widget;
|
||||
switch (role) {
|
||||
case Qt::CheckStateRole:
|
||||
if (option->features & QStyleOptionViewItemV2::HasCheckIndicator)
|
||||
if (option->features & QStyleOptionViewItem::HasCheckIndicator)
|
||||
return QSize(proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth, option, widget),
|
||||
proxyStyle->pixelMetric(QStyle::PM_IndicatorHeight, option, widget));
|
||||
break;
|
||||
case Qt::DisplayRole:
|
||||
if (option->features & QStyleOptionViewItemV2::HasDisplay) {
|
||||
if (option->features & QStyleOptionViewItem::HasDisplay) {
|
||||
QTextOption textOption;
|
||||
textOption.setWrapMode(QTextOption::WordWrap);
|
||||
QTextLayout textLayout;
|
||||
textLayout.setTextOption(textOption);
|
||||
textLayout.setFont(option->font);
|
||||
textLayout.setText(option->text);
|
||||
const bool wrapText = option->features & QStyleOptionViewItemV2::WrapText;
|
||||
const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
|
||||
const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, option, widget) + 1;
|
||||
QRect bounds = option->rect;
|
||||
switch (option->decorationPosition) {
|
||||
@ -762,7 +762,7 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, in
|
||||
}
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
if (option->features & QStyleOptionViewItemV2::HasDecoration) {
|
||||
if (option->features & QStyleOptionViewItem::HasDecoration) {
|
||||
return option->decorationSize;
|
||||
}
|
||||
break;
|
||||
@ -792,13 +792,13 @@ static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
|
||||
}
|
||||
|
||||
|
||||
void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItemV4 *option, const QRect &rect) const
|
||||
void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const
|
||||
{
|
||||
const QWidget *widget = option->widget;
|
||||
const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
|
||||
|
||||
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
|
||||
const bool wrapText = option->features & QStyleOptionViewItemV2::WrapText;
|
||||
const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
|
||||
QTextOption textOption;
|
||||
textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
|
||||
textOption.setTextDirection(option->direction);
|
||||
@ -870,7 +870,7 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt
|
||||
|
||||
Code duplicated in QItemDelegate::doLayout
|
||||
*/
|
||||
void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRect *checkRect,
|
||||
void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
|
||||
QRect *pixmapRect, QRect *textRect, bool sizehint) const
|
||||
{
|
||||
Q_ASSERT(checkRect && pixmapRect && textRect);
|
||||
@ -2025,7 +2025,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
||||
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case CE_ItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
p->save();
|
||||
p->setClipRect(opt->rect);
|
||||
|
||||
@ -2037,8 +2037,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
||||
proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p, widget);
|
||||
|
||||
// draw the check mark
|
||||
if (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) {
|
||||
QStyleOptionViewItemV4 option(*vopt);
|
||||
if (vopt->features & QStyleOptionViewItem::HasCheckIndicator) {
|
||||
QStyleOptionViewItem option(*vopt);
|
||||
option.rect = checkRect;
|
||||
option.state = option.state & ~QStyle::State_HasFocus;
|
||||
|
||||
@ -2866,21 +2866,21 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
|
||||
#endif
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case SE_ItemViewItemCheckIndicator:
|
||||
if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
r = subElementRect(SE_CheckBoxIndicator, opt, widget);
|
||||
break;
|
||||
}
|
||||
case SE_ItemViewItemDecoration:
|
||||
case SE_ItemViewItemText:
|
||||
case SE_ItemViewItemFocusRect:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
if (!d->isViewItemCached(*vopt)) {
|
||||
d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false);
|
||||
if (d->cachedOption) {
|
||||
delete d->cachedOption;
|
||||
d->cachedOption = 0;
|
||||
}
|
||||
d->cachedOption = new QStyleOptionViewItemV4(*vopt);
|
||||
d->cachedOption = new QStyleOptionViewItem(*vopt);
|
||||
}
|
||||
if (sr == SE_ViewItemCheckIndicator)
|
||||
r = d->checkRect;
|
||||
@ -4586,7 +4586,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
||||
break;
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case CT_ItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QRect decorationRect, displayRect, checkRect;
|
||||
d->viewItemLayout(vopt, &checkRect, &decorationRect, &displayRect, true);
|
||||
sz = (decorationRect|displayRect|checkRect).size();
|
||||
|
@ -78,14 +78,14 @@ public:
|
||||
{
|
||||
delete cachedOption;
|
||||
}
|
||||
void viewItemDrawText(QPainter *p, const QStyleOptionViewItemV4 *option, const QRect &rect) const;
|
||||
void viewItemLayout(const QStyleOptionViewItemV4 *opt, QRect *checkRect,
|
||||
void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const;
|
||||
void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
|
||||
QRect *pixmapRect, QRect *textRect, bool sizehint) const;
|
||||
QSize viewItemSize(const QStyleOptionViewItemV4 *option, int role) const;
|
||||
QSize viewItemSize(const QStyleOptionViewItem *option, int role) const;
|
||||
|
||||
mutable QRect decorationRect, displayRect, checkRect;
|
||||
mutable QStyleOptionViewItemV4 *cachedOption;
|
||||
bool isViewItemCached(const QStyleOptionViewItemV4 &option) const {
|
||||
mutable QStyleOptionViewItem *cachedOption;
|
||||
bool isViewItemCached(const QStyleOptionViewItem &option) const {
|
||||
return cachedOption && (option.rect == cachedOption->rect
|
||||
&& option.direction == cachedOption->direction
|
||||
&& option.state == cachedOption->state
|
||||
|
@ -857,7 +857,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
|
||||
} // fall through
|
||||
|
||||
case PE_PanelItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
|
||||
uint resolve_mask = vopt->palette.resolve();
|
||||
if (vopt->backgroundBrush.style() != Qt::NoBrush
|
||||
|| (resolve_mask & (1 << QPalette::Base)))
|
||||
@ -871,7 +871,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
|
||||
}
|
||||
if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) {
|
||||
const char *detail = "cell_even_ruled";
|
||||
if (vopt && vopt->features & QStyleOptionViewItemV2::Alternate)
|
||||
if (vopt && vopt->features & QStyleOptionViewItem::Alternate)
|
||||
detail = "cell_odd_ruled";
|
||||
bool isActive = option->state & State_Active;
|
||||
QString key;
|
||||
|
@ -4606,11 +4606,11 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
|
||||
|
||||
switch (sr) {
|
||||
case SE_ItemViewItemText:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
int fw = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget);
|
||||
// We add the focusframeargin between icon and text in commonstyle
|
||||
rect = QCommonStyle::subElementRect(sr, opt, widget);
|
||||
if (vopt->features & QStyleOptionViewItemV2::HasDecoration)
|
||||
if (vopt->features & QStyleOptionViewItem::HasDecoration)
|
||||
rect.adjust(-fw, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
@ -6319,7 +6319,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
||||
}
|
||||
break;
|
||||
case CT_ItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
sz = QCommonStyle::sizeFromContents(ct, vopt, csz, widget);
|
||||
sz.setHeight(sz.height() + 2);
|
||||
}
|
||||
|
@ -1990,19 +1990,18 @@ QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *o
|
||||
}
|
||||
#endif // QT_NO_DOCKWIDGET
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
else if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
|
||||
if (v2->features & QStyleOptionViewItemV2::Alternate)
|
||||
else if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
if (vopt->features & QStyleOptionViewItem::Alternate)
|
||||
extraClass |= PseudoClass_Alternate;
|
||||
if (const QStyleOptionViewItemV4 *v4 = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (v4->viewItemPosition == QStyleOptionViewItemV4::OnlyOne)
|
||||
extraClass |= PseudoClass_OnlyOne;
|
||||
else if (v4->viewItemPosition == QStyleOptionViewItemV4::Beginning)
|
||||
extraClass |= PseudoClass_First;
|
||||
else if (v4->viewItemPosition == QStyleOptionViewItemV4::End)
|
||||
extraClass |= PseudoClass_Last;
|
||||
else if (v4->viewItemPosition == QStyleOptionViewItemV4::Middle)
|
||||
extraClass |= PseudoClass_Middle;
|
||||
}
|
||||
if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne)
|
||||
extraClass |= PseudoClass_OnlyOne;
|
||||
else if (vopt->viewItemPosition == QStyleOptionViewItem::Beginning)
|
||||
extraClass |= PseudoClass_First;
|
||||
else if (vopt->viewItemPosition == QStyleOptionViewItem::End)
|
||||
extraClass |= PseudoClass_Last;
|
||||
else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
|
||||
extraClass |= PseudoClass_Middle;
|
||||
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_LINEEDIT
|
||||
@ -3974,15 +3973,15 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
||||
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case CE_ItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
|
||||
if (subRule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
|
||||
QStyleOptionViewItemV4 optCopy(*vopt);
|
||||
QStyleOptionViewItem optCopy(*vopt);
|
||||
subRule.configurePalette(&optCopy.palette, vopt->state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text,
|
||||
vopt->state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base);
|
||||
QWindowsStyle::drawControl(ce, &optCopy, p, w);
|
||||
} else {
|
||||
QStyleOptionViewItemV4 voptCopy(*vopt);
|
||||
QStyleOptionViewItem voptCopy(*vopt);
|
||||
subRule.configurePalette(&voptCopy.palette, QPalette::Text, QPalette::NoRole);
|
||||
baseStyle()->drawControl(ce, &voptCopy, p, w);
|
||||
}
|
||||
@ -4338,16 +4337,16 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
|
||||
break;
|
||||
|
||||
case PE_IndicatorBranch:
|
||||
if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch);
|
||||
if (subRule.hasDrawable()) {
|
||||
if ((v2->state & QStyle::State_Selected) && v2->showDecorationSelected)
|
||||
p->fillRect(v2->rect, v2->palette.highlight());
|
||||
else if (v2->features & QStyleOptionViewItemV2::Alternate)
|
||||
p->fillRect(v2->rect, v2->palette.alternateBase());
|
||||
if ((vopt->state & QStyle::State_Selected) && vopt->showDecorationSelected)
|
||||
p->fillRect(vopt->rect, vopt->palette.highlight());
|
||||
else if (vopt->features & QStyleOptionViewItem::Alternate)
|
||||
p->fillRect(vopt->rect, vopt->palette.alternateBase());
|
||||
subRule.drawRule(p, opt->rect);
|
||||
} else {
|
||||
baseStyle()->drawPrimitive(pe, v2, p, w);
|
||||
baseStyle()->drawPrimitive(pe, vopt, p, w);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -5642,27 +5641,27 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
|
||||
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case SE_ViewItemCheckIndicator:
|
||||
if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
return subElementRect(SE_CheckBoxIndicator, opt, w);
|
||||
}
|
||||
// intentionally falls through
|
||||
case SE_ItemViewItemText:
|
||||
case SE_ItemViewItemDecoration:
|
||||
case SE_ItemViewItemFocusRect:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
|
||||
QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
|
||||
PseudoElement pe = PseudoElement_None;
|
||||
if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect)
|
||||
pe = PseudoElement_ViewItemText;
|
||||
else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItemV2::HasDecoration)
|
||||
else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItem::HasDecoration)
|
||||
pe = PseudoElement_ViewItemIcon;
|
||||
else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)
|
||||
else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItem::HasCheckIndicator)
|
||||
pe = PseudoElement_ViewItemIndicator;
|
||||
else
|
||||
break;
|
||||
if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) {
|
||||
QRenderRule subRule2 = renderRule(w, opt, pe);
|
||||
QStyleOptionViewItemV4 optCopy(*vopt);
|
||||
QStyleOptionViewItem optCopy(*vopt);
|
||||
optCopy.rect = subRule.contentsRect(vopt->rect);
|
||||
QRect rect = ParentStyle::subElementRect(se, &optCopy, w);
|
||||
return positionRect(w, subRule2, pe, rect, opt->direction);
|
||||
|
@ -4211,7 +4211,7 @@ void QWindowsMobileStylePrivate::drawTabBarTab(QPainter *painter, const QStyleOp
|
||||
#endif //QT_NO_TABBAR
|
||||
}
|
||||
|
||||
void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItemV4 *option, QRect rect)
|
||||
void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItem *option, QRect rect)
|
||||
{
|
||||
#ifdef Q_OS_WINCE_WM
|
||||
if (wm65) {
|
||||
@ -4224,11 +4224,11 @@ void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, co
|
||||
|
||||
painter->setPen(QColor(Qt::lightGray));
|
||||
|
||||
if (option->viewItemPosition == QStyleOptionViewItemV4::Middle) {
|
||||
if (option->viewItemPosition == QStyleOptionViewItem::Middle) {
|
||||
painter->drawImage(r, imageListViewHighlightMiddle);
|
||||
} else if (option->viewItemPosition == QStyleOptionViewItemV4::Beginning) {
|
||||
} else if (option->viewItemPosition == QStyleOptionViewItem::Beginning) {
|
||||
painter->drawImage(r.adjusted(10, 0, 0, 0), imageListViewHighlightMiddle);
|
||||
} else if (option->viewItemPosition == QStyleOptionViewItemV4::End) {
|
||||
} else if (option->viewItemPosition == QStyleOptionViewItem::End) {
|
||||
painter->drawImage(r.adjusted(0, 0, -10, 0), imageListViewHighlightMiddle);
|
||||
} else {
|
||||
painter->drawImage(r.adjusted(10, 0, -10, 0), imageListViewHighlightMiddle);
|
||||
@ -4246,10 +4246,10 @@ void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, co
|
||||
cornerLeft = cornerLeft.scaled(width, r.height());
|
||||
cornerRight = cornerRight.scaled(width, r.height());
|
||||
|
||||
if ((option->viewItemPosition == QStyleOptionViewItemV4::Beginning) || (option->viewItemPosition == QStyleOptionViewItemV4::OnlyOne) || !option->viewItemPosition) {
|
||||
if ((option->viewItemPosition == QStyleOptionViewItem::Beginning) || (option->viewItemPosition == QStyleOptionViewItem::OnlyOne) || !option->viewItemPosition) {
|
||||
painter->drawImage(r.topLeft(), cornerLeft);
|
||||
}
|
||||
if ((option->viewItemPosition == QStyleOptionViewItemV4::End) || (option->viewItemPosition == QStyleOptionViewItemV4::OnlyOne) || !option->viewItemPosition) {
|
||||
if ((option->viewItemPosition == QStyleOptionViewItem::End) || (option->viewItemPosition == QStyleOptionViewItem::OnlyOne) || !option->viewItemPosition) {
|
||||
painter->drawImage(r.topRight() - QPoint(cornerRight.width(),0), cornerRight);
|
||||
}
|
||||
return;
|
||||
@ -5262,7 +5262,7 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
|
||||
#endif //QT_NO_TABBAR
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case PE_PanelItemViewRow:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
|
||||
QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
|
||||
? QPalette::Normal : QPalette::Disabled;
|
||||
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
|
||||
@ -5270,14 +5270,14 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
|
||||
|
||||
if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, option, widget))
|
||||
d->drawPanelItemViewSelected(painter, vopt);
|
||||
else if (vopt->features & QStyleOptionViewItemV2::Alternate)
|
||||
else if (vopt->features & QStyleOptionViewItem::Alternate)
|
||||
painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
|
||||
else if (!(vopt->state & QStyle::State_Enabled))
|
||||
painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Base));
|
||||
}
|
||||
break;
|
||||
case PE_PanelItemViewItem:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
|
||||
QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
|
||||
? QPalette::Normal : QPalette::Disabled;
|
||||
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
void drawScrollbarGroove(QPainter *p, const QStyleOptionSlider *opt);
|
||||
void drawScrollbarGrip(QPainter *p, QStyleOptionSlider *newScrollbar, const QStyleOptionComplex *option, bool drawCompleteFrame);
|
||||
void drawTabBarTab(QPainter *p, const QStyleOptionTab *tab);
|
||||
void drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItemV4 *option, QRect rect = QRect());
|
||||
void drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItem *option, QRect rect = QRect());
|
||||
|
||||
};
|
||||
|
||||
|
@ -747,19 +747,19 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
||||
|
||||
case PE_PanelItemViewItem:
|
||||
{
|
||||
const QStyleOptionViewItemV4 *vopt;
|
||||
const QStyleOptionViewItem *vopt;
|
||||
const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
|
||||
bool newStyle = true;
|
||||
|
||||
if (qobject_cast<const QTableView*>(widget))
|
||||
newStyle = false;
|
||||
|
||||
if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
|
||||
if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option))) {
|
||||
bool selected = vopt->state & QStyle::State_Selected;
|
||||
bool hover = vopt->state & QStyle::State_MouseOver;
|
||||
bool active = vopt->state & QStyle::State_Active;
|
||||
|
||||
if (vopt->features & QStyleOptionViewItemV2::Alternate)
|
||||
if (vopt->features & QStyleOptionViewItem::Alternate)
|
||||
painter->fillRect(vopt->rect, vopt->palette.alternateBase());
|
||||
|
||||
QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
|
||||
@ -823,10 +823,10 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
||||
QRect srcRect = QRect(0, 0, sectionSize.width(), sectionSize.height());
|
||||
QRect pixmapRect = vopt->rect;
|
||||
bool reverse = vopt->direction == Qt::RightToLeft;
|
||||
bool leftSection = vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning;
|
||||
bool rightSection = vopt->viewItemPosition == QStyleOptionViewItemV4::End;
|
||||
if (vopt->viewItemPosition == QStyleOptionViewItemV4::OnlyOne
|
||||
|| vopt->viewItemPosition == QStyleOptionViewItemV4::Invalid)
|
||||
bool leftSection = vopt->viewItemPosition == QStyleOptionViewItem::Beginning;
|
||||
bool rightSection = vopt->viewItemPosition == QStyleOptionViewItem::End;
|
||||
if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne
|
||||
|| vopt->viewItemPosition == QStyleOptionViewItem::Invalid)
|
||||
painter->drawPixmap(pixmapRect.topLeft(), pixmap);
|
||||
else if (reverse ? rightSection : leftSection){
|
||||
painter->drawPixmap(QRect(pixmapRect.topLeft(),
|
||||
@ -841,7 +841,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
||||
QSize(frame, pixmapRect.height())));
|
||||
painter->drawPixmap(pixmapRect.adjusted(0, 0, -frame, 0),
|
||||
pixmap, srcRect.adjusted(frame, 0, -frame, 0));
|
||||
} else if (vopt->viewItemPosition == QStyleOptionViewItemV4::Middle)
|
||||
} else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
|
||||
painter->drawPixmap(pixmapRect, pixmap,
|
||||
srcRect.adjusted(frame, 0, -frame, 0));
|
||||
} else {
|
||||
@ -1523,14 +1523,14 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
case CE_ItemViewItem:
|
||||
{
|
||||
const QStyleOptionViewItemV4 *vopt;
|
||||
const QStyleOptionViewItem *vopt;
|
||||
const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
|
||||
bool newStyle = true;
|
||||
|
||||
if (qobject_cast<const QTableView*>(widget))
|
||||
newStyle = false;
|
||||
|
||||
if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
|
||||
if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option))) {
|
||||
/*
|
||||
// We cannot currently get the correct selection color for "explorer style" views
|
||||
COLORREF cref = 0;
|
||||
@ -1542,7 +1542,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
||||
palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::Text));
|
||||
// Note that setting a saturated color here results in ugly XOR colors in the focus rect
|
||||
palette.setColor(QPalette::All, QPalette::Highlight, palette.base().color().darker(108));
|
||||
QStyleOptionViewItemV4 adjustedOption = *vopt;
|
||||
QStyleOptionViewItem adjustedOption = *vopt;
|
||||
adjustedOption.palette = palette;
|
||||
// We hide the focusrect in singleselection as it is not required
|
||||
if ((view->selectionMode() == QAbstractItemView::SingleSelection)
|
||||
@ -2114,11 +2114,11 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
|
||||
rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget);
|
||||
break;
|
||||
case SE_ItemViewItemDecoration:
|
||||
if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))
|
||||
if (qstyleoption_cast<const QStyleOptionViewItem *>(option))
|
||||
rect.adjust(-2, 0, 2, 0);
|
||||
break;
|
||||
case SE_ItemViewItemFocusRect:
|
||||
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
|
||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
|
||||
QRect textRect = subElementRect(QStyle::SE_ItemViewItemText, option, widget);
|
||||
QRect displayRect = subElementRect(QStyle::SE_ItemViewItemDecoration, option, widget);
|
||||
if (!vopt->icon.isNull())
|
||||
|
@ -1525,7 +1525,7 @@ public:
|
||||
|
||||
private:
|
||||
QCalendarWidgetPrivate *calendarWidgetPrivate;
|
||||
mutable QStyleOptionViewItemV4 storedOption;
|
||||
mutable QStyleOptionViewItem storedOption;
|
||||
};
|
||||
|
||||
//Private tool button class
|
||||
|
@ -310,9 +310,8 @@ protected:
|
||||
const QModelIndex &index) const {
|
||||
if (isSeparator(index)) {
|
||||
QRect rect = option.rect;
|
||||
if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3*>(&option))
|
||||
if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(v3->widget))
|
||||
rect.setWidth(view->viewport()->width());
|
||||
if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(option.widget))
|
||||
rect.setWidth(view->viewport()->width());
|
||||
QStyleOption opt;
|
||||
opt.rect = rect;
|
||||
mCombo->style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, painter, mCombo);
|
||||
|
Loading…
Reference in New Issue
Block a user