QtWidgets: remove use of obsolete QStyleOption*V<N>
They are obsolete since Qt 5.0. Change-Id: I3a1ee314126bd245a3c788ac7af49905ab50945f Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
5c57c66d98
commit
765362db78
|
|
@ -507,7 +507,7 @@ void QDockWidgetLayout::setGeometry(const QRect &geometry)
|
|||
if (QLayoutItem *item = item_list[TitleBar]) {
|
||||
item->setGeometry(_titleArea);
|
||||
} else {
|
||||
QStyleOptionDockWidgetV2 opt;
|
||||
QStyleOptionDockWidget opt;
|
||||
q->initStyleOption(&opt);
|
||||
|
||||
if (QLayoutItem *item = item_list[CloseButton]) {
|
||||
|
|
@ -650,10 +650,7 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
|
|||
option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable);
|
||||
|
||||
QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout());
|
||||
QStyleOptionDockWidgetV2 *v2
|
||||
= qstyleoption_cast<QStyleOptionDockWidgetV2*>(option);
|
||||
if (v2 != 0)
|
||||
v2->verticalTitleBar = l->verticalTitleBar;
|
||||
option->verticalTitleBar = l->verticalTitleBar;
|
||||
}
|
||||
|
||||
void QDockWidgetPrivate::_q_toggleView(bool b)
|
||||
|
|
@ -1437,7 +1434,7 @@ void QDockWidget::paintEvent(QPaintEvent *event)
|
|||
|
||||
// Title must be painted after the frame, since the areas overlap, and
|
||||
// the title may wish to extend out to all sides (eg. XP style)
|
||||
QStyleOptionDockWidgetV2 titleOpt;
|
||||
QStyleOptionDockWidget titleOpt;
|
||||
initStyleOption(&titleOpt);
|
||||
p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,10 +107,8 @@ void QProgressBarPrivate::resetLayoutItemMargins()
|
|||
|
||||
/*!
|
||||
Initialize \a option with the values from this QProgressBar. This method is useful
|
||||
for subclasses when they need a QStyleOptionProgressBar or QStyleOptionProgressBarV2,
|
||||
but don't want to fill in all the information themselves. This function will check the version
|
||||
of the QStyleOptionProgressBar and fill in the additional values for a
|
||||
QStyleOptionProgressBarV2.
|
||||
for subclasses when they need a QStyleOptionProgressBar,
|
||||
but don't want to fill in all the information themselves.
|
||||
|
||||
\sa QStyleOption::initFrom()
|
||||
*/
|
||||
|
|
@ -129,13 +127,9 @@ void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const
|
|||
option->textAlignment = d->alignment;
|
||||
option->textVisible = d->textVisible;
|
||||
option->text = text();
|
||||
|
||||
if (QStyleOptionProgressBarV2 *optionV2
|
||||
= qstyleoption_cast<QStyleOptionProgressBarV2 *>(option)) {
|
||||
optionV2->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBarV2
|
||||
optionV2->invertedAppearance = d->invertedAppearance;
|
||||
optionV2->bottomToTop = (d->textDirection == QProgressBar::BottomToTop);
|
||||
}
|
||||
option->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBar
|
||||
option->invertedAppearance = d->invertedAppearance;
|
||||
option->bottomToTop = d->textDirection == QProgressBar::BottomToTop;
|
||||
}
|
||||
|
||||
bool QProgressBarPrivate::repaintRequired() const
|
||||
|
|
@ -158,7 +152,7 @@ bool QProgressBarPrivate::repaintRequired() const
|
|||
}
|
||||
|
||||
// Check if the bar needs to be repainted
|
||||
QStyleOptionProgressBarV2 opt;
|
||||
QStyleOptionProgressBar opt;
|
||||
q->initStyleOption(&opt);
|
||||
int cw = q->style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, q);
|
||||
QRect groove = q->style()->subElementRect(QStyle::SE_ProgressBarGroove, &opt, q);
|
||||
|
|
@ -410,7 +404,7 @@ Qt::Alignment QProgressBar::alignment() const
|
|||
void QProgressBar::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStylePainter paint(this);
|
||||
QStyleOptionProgressBarV2 opt;
|
||||
QStyleOptionProgressBar opt;
|
||||
initStyleOption(&opt);
|
||||
paint.drawControl(QStyle::CE_ProgressBar, opt);
|
||||
d_func()->lastPaintedValue = d_func()->value;
|
||||
|
|
@ -423,7 +417,7 @@ QSize QProgressBar::sizeHint() const
|
|||
{
|
||||
ensurePolished();
|
||||
QFontMetrics fm = fontMetrics();
|
||||
QStyleOptionProgressBarV2 opt;
|
||||
QStyleOptionProgressBar opt;
|
||||
initStyleOption(&opt);
|
||||
int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);
|
||||
QSize size = QSize(qMax(9, cw) * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);
|
||||
|
|
|
|||
|
|
@ -118,10 +118,8 @@ void QTabBarPrivate::updateMacBorderMetrics()
|
|||
|
||||
/*!
|
||||
Initialize \a option with the values from the tab at \a tabIndex. This method
|
||||
is useful for subclasses when they need a QStyleOptionTab, QStyleOptionTabV2,
|
||||
or QStyleOptionTabV3 but don't want to fill in all the information themselves.
|
||||
This function will check the version of the QStyleOptionTab and fill in the
|
||||
additional values for a QStyleOptionTabV2 and QStyleOptionTabV3.
|
||||
is useful for subclasses when they need a QStyleOptionTab,
|
||||
but don't want to fill in all the information themselves.
|
||||
|
||||
\sa QStyleOption::initFrom(), QTabWidget::initStyleOption()
|
||||
*/
|
||||
|
|
@ -158,14 +156,11 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
|
|||
option->palette.setColor(foregroundRole(), tab.textColor);
|
||||
|
||||
option->icon = tab.icon;
|
||||
if (QStyleOptionTabV2 *optionV2 = qstyleoption_cast<QStyleOptionTabV2 *>(option))
|
||||
optionV2->iconSize = iconSize(); // Will get the default value then.
|
||||
option->iconSize = iconSize(); // Will get the default value then.
|
||||
|
||||
if (QStyleOptionTabV3 *optionV3 = qstyleoption_cast<QStyleOptionTabV3 *>(option)) {
|
||||
optionV3->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize();
|
||||
optionV3->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize();
|
||||
optionV3->documentMode = d->documentMode;
|
||||
}
|
||||
option->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize();
|
||||
option->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize();
|
||||
option->documentMode = d->documentMode;
|
||||
|
||||
if (tabIndex > 0 && tabIndex - 1 == d->currentIndex)
|
||||
option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
|
||||
|
|
@ -600,7 +595,7 @@ void QTabBarPrivate::layoutTab(int index)
|
|||
if (!(tab.leftWidget || tab.rightWidget))
|
||||
return;
|
||||
|
||||
QStyleOptionTabV3 opt;
|
||||
QStyleOptionTab opt;
|
||||
q->initStyleOption(&opt, index);
|
||||
if (tab.leftWidget) {
|
||||
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
|
||||
|
|
@ -778,7 +773,7 @@ void QTabBar::setShape(Shape shape)
|
|||
If true then QTabBar draws a base in relation to the styles overlab.
|
||||
Otherwise only the tabs are drawn.
|
||||
|
||||
\sa QStyle::pixelMetric(), QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBaseV2
|
||||
\sa QStyle::pixelMetric(), QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBase
|
||||
*/
|
||||
|
||||
void QTabBar::setDrawBase(bool drawBase)
|
||||
|
|
@ -857,7 +852,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
|
|||
++d->currentIndex;
|
||||
|
||||
if (d->closeButtonOnTabs) {
|
||||
QStyleOptionTabV3 opt;
|
||||
QStyleOptionTab opt;
|
||||
initStyleOption(&opt, index);
|
||||
ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);
|
||||
QAbstractButton *closeButton = new CloseButton(this);
|
||||
|
|
@ -1363,7 +1358,7 @@ QSize QTabBar::tabSizeHint(int index) const
|
|||
//Note: this must match with the computations in QCommonStylePrivate::tabLayout
|
||||
Q_D(const QTabBar);
|
||||
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
|
||||
QStyleOptionTabV3 opt;
|
||||
QStyleOptionTab opt;
|
||||
initStyleOption(&opt, index);
|
||||
opt.text = d->tabList.at(index).text;
|
||||
QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
|
||||
|
|
@ -1571,7 +1566,7 @@ void QTabBar::paintEvent(QPaintEvent *)
|
|||
{
|
||||
Q_D(QTabBar);
|
||||
|
||||
QStyleOptionTabBarBaseV2 optTabBase;
|
||||
QStyleOptionTabBarBase optTabBase;
|
||||
QTabBarPrivate::initStyleBaseOption(&optTabBase, this, size());
|
||||
|
||||
QStylePainter p(this);
|
||||
|
|
@ -1593,7 +1588,7 @@ void QTabBar::paintEvent(QPaintEvent *)
|
|||
p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
|
||||
|
||||
for (int i = 0; i < d->tabList.count(); ++i) {
|
||||
QStyleOptionTabV3 tab;
|
||||
QStyleOptionTab tab;
|
||||
initStyleOption(&tab, i);
|
||||
if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) {
|
||||
if (vertical) {
|
||||
|
|
@ -1626,7 +1621,7 @@ void QTabBar::paintEvent(QPaintEvent *)
|
|||
|
||||
// Draw the selected tab last to get it "on top"
|
||||
if (selected >= 0) {
|
||||
QStyleOptionTabV3 tab;
|
||||
QStyleOptionTab tab;
|
||||
initStyleOption(&tab, selected);
|
||||
if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) {
|
||||
if (vertical)
|
||||
|
|
@ -1806,7 +1801,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event)
|
|||
d->previousPressedIndex = d->pressedIndex;
|
||||
#endif
|
||||
if (d->validIndex(d->pressedIndex)) {
|
||||
QStyleOptionTabBarBaseV2 optTabBase;
|
||||
QStyleOptionTabBarBase optTabBase;
|
||||
optTabBase.init(this);
|
||||
optTabBase.documentMode = d->documentMode;
|
||||
if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this))
|
||||
|
|
@ -1902,7 +1897,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
|
|||
event->ignore();
|
||||
return;
|
||||
}
|
||||
QStyleOptionTabBarBaseV2 optTabBase;
|
||||
QStyleOptionTabBarBase optTabBase;
|
||||
optTabBase.init(this);
|
||||
optTabBase.documentMode = d->documentMode;
|
||||
}
|
||||
|
|
@ -1922,7 +1917,7 @@ void QTabBarPrivate::setupMovableTab()
|
|||
QStylePainter p(&grabImage, q);
|
||||
p.initFrom(q);
|
||||
|
||||
QStyleOptionTabV3 tab;
|
||||
QStyleOptionTab tab;
|
||||
q->initStyleOption(&tab, pressedIndex);
|
||||
tab.rect.moveTopLeft(QPoint(taboverlap, 0));
|
||||
p.drawControl(QStyle::CE_TabBarTab, tab);
|
||||
|
|
@ -2006,7 +2001,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
|
|||
|
||||
int i = d->indexAtPos(event->pos()) == d->pressedIndex ? d->pressedIndex : -1;
|
||||
d->pressedIndex = -1;
|
||||
QStyleOptionTabBarBaseV2 optTabBase;
|
||||
QStyleOptionTabBarBase optTabBase;
|
||||
optTabBase.initFrom(this);
|
||||
optTabBase.documentMode = d->documentMode;
|
||||
if (style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this) == QEvent::MouseButtonRelease)
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public:
|
|||
int previousPressedIndex;
|
||||
#endif
|
||||
// shared by tabwidget and qtabbar
|
||||
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
|
||||
static void initStyleBaseOption(QStyleOptionTabBarBase *optTabBase, QTabBar *tabbar, QSize size)
|
||||
{
|
||||
QStyleOptionTab tabOverlap;
|
||||
tabOverlap.shape = tabbar->shape();
|
||||
|
|
|
|||
|
|
@ -331,13 +331,11 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const
|
|||
|
||||
option->tabBarSize = t;
|
||||
|
||||
if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)) {
|
||||
QRect tbRect = tabBar()->geometry();
|
||||
QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());
|
||||
tabframe->tabBarRect = tbRect;
|
||||
selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft());
|
||||
tabframe->selectedTabRect = selectedTabRect;
|
||||
}
|
||||
QRect tbRect = tabBar()->geometry();
|
||||
QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());
|
||||
option->tabBarRect = tbRect;
|
||||
selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft());
|
||||
option->selectedTabRect = selectedTabRect;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -768,7 +766,7 @@ void QTabWidget::setUpLayout(bool onlyCheck)
|
|||
if (onlyCheck && !d->dirty)
|
||||
return; // nothing to do
|
||||
|
||||
QStyleOptionTabWidgetFrameV2 option;
|
||||
QStyleOptionTabWidgetFrame option;
|
||||
initStyleOption(&option);
|
||||
|
||||
// this must be done immediately, because QWidgetItem relies on it (even if !isVisible())
|
||||
|
|
@ -817,7 +815,7 @@ QSize QTabWidget::sizeHint() const
|
|||
{
|
||||
Q_D(const QTabWidget);
|
||||
QSize lc(0, 0), rc(0, 0);
|
||||
QStyleOptionTabWidgetFrameV2 opt;
|
||||
QStyleOptionTabWidgetFrame opt;
|
||||
initStyleOption(&opt);
|
||||
opt.state = QStyle::State_None;
|
||||
|
||||
|
|
@ -866,7 +864,7 @@ QSize QTabWidget::minimumSizeHint() const
|
|||
|
||||
QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
|
||||
|
||||
QStyleOptionTabWidgetFrameV2 opt;
|
||||
QStyleOptionTabWidgetFrame opt;
|
||||
initStyleOption(&opt);
|
||||
opt.palette = palette();
|
||||
opt.state = QStyle::State_None;
|
||||
|
|
@ -880,7 +878,7 @@ QSize QTabWidget::minimumSizeHint() const
|
|||
int QTabWidget::heightForWidth(int width) const
|
||||
{
|
||||
Q_D(const QTabWidget);
|
||||
QStyleOptionTabWidgetFrameV2 opt;
|
||||
QStyleOptionTabWidgetFrame opt;
|
||||
initStyleOption(&opt);
|
||||
opt.state = QStyle::State_None;
|
||||
|
||||
|
|
@ -1226,14 +1224,14 @@ void QTabWidget::paintEvent(QPaintEvent *)
|
|||
if (documentMode()) {
|
||||
QStylePainter p(this, tabBar());
|
||||
if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) {
|
||||
QStyleOptionTabBarBaseV2 opt;
|
||||
QStyleOptionTabBarBase opt;
|
||||
QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size());
|
||||
opt.rect.moveLeft(w->x() + opt.rect.x());
|
||||
opt.rect.moveTop(w->y() + opt.rect.y());
|
||||
p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);
|
||||
}
|
||||
if (QWidget *w = cornerWidget(Qt::TopRightCorner)) {
|
||||
QStyleOptionTabBarBaseV2 opt;
|
||||
QStyleOptionTabBarBase opt;
|
||||
QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size());
|
||||
opt.rect.moveLeft(w->x() + opt.rect.x());
|
||||
opt.rect.moveTop(w->y() + opt.rect.y());
|
||||
|
|
@ -1243,7 +1241,7 @@ void QTabWidget::paintEvent(QPaintEvent *)
|
|||
}
|
||||
QStylePainter p(this);
|
||||
|
||||
QStyleOptionTabWidgetFrameV2 opt;
|
||||
QStyleOptionTabWidgetFrame opt;
|
||||
initStyleOption(&opt);
|
||||
opt.rect = d->panelRect;
|
||||
p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);
|
||||
|
|
|
|||
|
|
@ -206,26 +206,24 @@ void QToolBoxButton::initStyleOption(QStyleOptionToolBox *option) const
|
|||
option->text = text();
|
||||
option->icon = icon();
|
||||
|
||||
if (QStyleOptionToolBoxV2 *optionV2 = qstyleoption_cast<QStyleOptionToolBoxV2 *>(option)) {
|
||||
QToolBox *toolBox = static_cast<QToolBox *>(parentWidget()); // I know I'm in a tool box.
|
||||
int widgetCount = toolBox->count();
|
||||
int currIndex = toolBox->currentIndex();
|
||||
if (widgetCount == 1) {
|
||||
optionV2->position = QStyleOptionToolBoxV2::OnlyOneTab;
|
||||
} else if (indexInPage == 0) {
|
||||
optionV2->position = QStyleOptionToolBoxV2::Beginning;
|
||||
} else if (indexInPage == widgetCount - 1) {
|
||||
optionV2->position = QStyleOptionToolBoxV2::End;
|
||||
} else {
|
||||
optionV2->position = QStyleOptionToolBoxV2::Middle;
|
||||
}
|
||||
if (currIndex == indexInPage - 1) {
|
||||
optionV2->selectedPosition = QStyleOptionToolBoxV2::PreviousIsSelected;
|
||||
} else if (currIndex == indexInPage + 1) {
|
||||
optionV2->selectedPosition = QStyleOptionToolBoxV2::NextIsSelected;
|
||||
} else {
|
||||
optionV2->selectedPosition = QStyleOptionToolBoxV2::NotAdjacent;
|
||||
}
|
||||
QToolBox *toolBox = static_cast<QToolBox *>(parentWidget()); // I know I'm in a tool box.
|
||||
const int widgetCount = toolBox->count();
|
||||
const int currIndex = toolBox->currentIndex();
|
||||
if (widgetCount == 1) {
|
||||
option->position = QStyleOptionToolBox::OnlyOneTab;
|
||||
} else if (indexInPage == 0) {
|
||||
option->position = QStyleOptionToolBox::Beginning;
|
||||
} else if (indexInPage == widgetCount - 1) {
|
||||
option->position = QStyleOptionToolBox::End;
|
||||
} else {
|
||||
option->position = QStyleOptionToolBox::Middle;
|
||||
}
|
||||
if (currIndex == indexInPage - 1) {
|
||||
option->selectedPosition = QStyleOptionToolBox::PreviousIsSelected;
|
||||
} else if (currIndex == indexInPage + 1) {
|
||||
option->selectedPosition = QStyleOptionToolBox::NextIsSelected;
|
||||
} else {
|
||||
option->selectedPosition = QStyleOptionToolBox::NotAdjacent;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +231,7 @@ void QToolBoxButton::paintEvent(QPaintEvent *)
|
|||
{
|
||||
QPainter paint(this);
|
||||
QPainter *p = &paint;
|
||||
QStyleOptionToolBoxV2 opt;
|
||||
QStyleOptionToolBox opt;
|
||||
initStyleOption(&opt);
|
||||
style()->drawControl(QStyle::CE_ToolBoxTab, &opt, p, parentWidget());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue