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