Remove deprecated QStyleOption::init()
Even it was not marked as deprecated the replacement function initFrom() is available since Qt4 times (and init() is deprecated since then) Change-Id: I09a4ebbf66b01fbe7aec67691dc68d2e42d1cd78 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
b1433a6988
commit
26a2266304
@ -3694,7 +3694,7 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const
|
||||
{
|
||||
Q_D(const QAbstractItemView);
|
||||
QStyleOptionViewItem option;
|
||||
option.init(this);
|
||||
option.initFrom(this);
|
||||
option.state &= ~QStyle::State_MouseOver;
|
||||
option.font = font();
|
||||
|
||||
|
@ -198,7 +198,7 @@ public:
|
||||
#endif
|
||||
) {
|
||||
QStyleOption opt;
|
||||
opt.init(q_func());
|
||||
opt.initFrom(q_func());
|
||||
opt.rect = dropIndicatorRect;
|
||||
q_func()->style()->drawPrimitive(QStyle::PE_IndicatorItemViewItemDrop, &opt, painter, q_func());
|
||||
}
|
||||
|
@ -2478,7 +2478,7 @@ void QHeaderView::paintEvent(QPaintEvent *e)
|
||||
}
|
||||
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
// Paint the area beyond where there are indexes
|
||||
if (d->reverse()) {
|
||||
opt.state |= QStyle::State_Horizontal;
|
||||
|
@ -589,7 +589,7 @@ public:
|
||||
QTableCornerButton(QWidget *parent) : QAbstractButton(parent) {}
|
||||
void paintEvent(QPaintEvent*) override {
|
||||
QStyleOptionHeader opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
QStyle::State state = QStyle::State_None;
|
||||
if (isEnabled())
|
||||
state |= QStyle::State_Enabled;
|
||||
|
@ -242,7 +242,7 @@ void QTipLabel::paintEvent(QPaintEvent *ev)
|
||||
{
|
||||
QStylePainter p(this);
|
||||
QStyleOptionFrame opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
|
||||
p.end();
|
||||
|
||||
@ -253,7 +253,7 @@ void QTipLabel::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QStyleHintReturnMask frameMask;
|
||||
QStyleOption option;
|
||||
option.init(this);
|
||||
option.initFrom(this);
|
||||
if (style()->styleHint(QStyle::SH_ToolTip_Mask, &option, this, &frameMask))
|
||||
setMask(frameMask.region);
|
||||
|
||||
|
@ -176,13 +176,7 @@ QStyleOption::~QStyleOption()
|
||||
\sa QWidget::layoutDirection(), QWidget::rect(),
|
||||
QWidget::palette(), QWidget::fontMetrics()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use initFrom(\a widget) instead.
|
||||
*/
|
||||
void QStyleOption::init(const QWidget *widget)
|
||||
void QStyleOption::initFrom(const QWidget *widget)
|
||||
{
|
||||
QWidget *window = widget->window();
|
||||
state = QStyle::State_None;
|
||||
|
@ -103,8 +103,7 @@ public:
|
||||
QStyleOption(const QStyleOption &other);
|
||||
~QStyleOption();
|
||||
|
||||
void init(const QWidget *w);
|
||||
inline void initFrom(const QWidget *w) { init(w); }
|
||||
void initFrom(const QWidget *w);
|
||||
QStyleOption &operator=(const QStyleOption &other);
|
||||
};
|
||||
|
||||
|
@ -340,7 +340,7 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol
|
||||
&& vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty())));
|
||||
|
||||
QStyleOption opt(0);
|
||||
opt.init(q);
|
||||
opt.initFrom(q);
|
||||
|
||||
const int hscrollOverlap = hbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, hbar);
|
||||
const int vscrollOverlap = vbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, vbar);
|
||||
|
@ -190,7 +190,7 @@ protected:
|
||||
void paintEvent(QPaintEvent *) override {
|
||||
QPainter p(this);
|
||||
QStyleOptionMenuItem menuOpt;
|
||||
menuOpt.init(this);
|
||||
menuOpt.initFrom(this);
|
||||
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
|
||||
menuOpt.menuRect = rect();
|
||||
menuOpt.maxIconWidth = 0;
|
||||
|
@ -2374,7 +2374,7 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
|
||||
|
||||
QStyleOptionComboBox optCombo;
|
||||
|
||||
optCombo.init(this);
|
||||
optCombo.initFrom(this);
|
||||
optCombo.editable = true;
|
||||
optCombo.frame = opt.frame;
|
||||
optCombo.subControls = opt.subControls;
|
||||
@ -2522,7 +2522,7 @@ QStyle::SubControl QDateTimeEditPrivate::newHoverControl(const QPoint &pos)
|
||||
Q_Q(QDateTimeEdit);
|
||||
|
||||
QStyleOptionComboBox optCombo;
|
||||
optCombo.init(q);
|
||||
optCombo.initFrom(q);
|
||||
optCombo.editable = true;
|
||||
optCombo.subControls = QStyle::SC_All;
|
||||
hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &optCombo, pos, q);
|
||||
@ -2539,7 +2539,7 @@ void QDateTimeEditPrivate::updateEditFieldGeometry()
|
||||
Q_Q(QDateTimeEdit);
|
||||
|
||||
QStyleOptionComboBox optCombo;
|
||||
optCombo.init(q);
|
||||
optCombo.initFrom(q);
|
||||
optCombo.editable = true;
|
||||
optCombo.subControls = QStyle::SC_ComboBoxEditField;
|
||||
edit->setGeometry(q->style()->subControlRect(QStyle::CC_ComboBox, &optCombo,
|
||||
@ -2707,7 +2707,7 @@ void QCalendarPopup::mousePressEvent(QMouseEvent *event)
|
||||
QDateTimeEdit *dateTime = qobject_cast<QDateTimeEdit *>(parentWidget());
|
||||
if (dateTime) {
|
||||
QStyleOptionComboBox opt;
|
||||
opt.init(dateTime);
|
||||
opt.initFrom(dateTime);
|
||||
QRect arrowRect = dateTime->style()->subControlRect(QStyle::CC_ComboBox, &opt,
|
||||
QStyle::SC_ComboBoxArrow, dateTime);
|
||||
arrowRect.moveTo(dateTime->mapToGlobal(arrowRect .topLeft()));
|
||||
|
@ -222,7 +222,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
|
||||
QPainter p(this);
|
||||
|
||||
QStyleOptionToolButton opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
opt.state |= QStyle::State_AutoRaise;
|
||||
|
||||
if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, nullptr, this))
|
||||
@ -1480,7 +1480,7 @@ void QDockWidget::paintEvent(QPaintEvent *event)
|
||||
// when not floating.
|
||||
if (isFloating()) {
|
||||
QStyleOptionFrame framOpt;
|
||||
framOpt.init(this);
|
||||
framOpt.initFrom(this);
|
||||
p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ void QDockWidgetGroupWindow::paintEvent(QPaintEvent *)
|
||||
|
||||
if (!nativeDeco) {
|
||||
QStyleOptionFrame framOpt;
|
||||
framOpt.init(this);
|
||||
framOpt.initFrom(this);
|
||||
QStylePainter p(this);
|
||||
p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu
|
||||
item->setIcon(action->icon());
|
||||
if (QWidget *w = action->parentWidget()) {
|
||||
QStyleOption opt;
|
||||
opt.init(w);
|
||||
opt.initFrom(w);
|
||||
item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
|
||||
} else {
|
||||
QStyleOption opt;
|
||||
@ -379,7 +379,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
|
||||
|
||||
QStyle *style = q->style();
|
||||
QStyleOption opt;
|
||||
opt.init(q);
|
||||
opt.initFrom(q);
|
||||
const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),
|
||||
vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),
|
||||
icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
|
||||
@ -1007,7 +1007,7 @@ QRect QMenuPrivate::rect() const
|
||||
Q_Q(const QMenu);
|
||||
QStyle *style = q->style();
|
||||
QStyleOption opt(0);
|
||||
opt.init(q);
|
||||
opt.initFrom(q);
|
||||
const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q);
|
||||
const int vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q);
|
||||
const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
|
||||
@ -1306,7 +1306,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
|
||||
|
||||
QStyle *style = q->style();
|
||||
QStyleOption opt(0);
|
||||
opt.init(q);
|
||||
opt.initFrom(q);
|
||||
const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q);
|
||||
const int vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q);
|
||||
const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
|
||||
@ -2339,7 +2339,7 @@ QSize QMenu::sizeHint() const
|
||||
// the top and left margins, so we only need to add margins for
|
||||
// the bottom and right.
|
||||
QStyleOption opt(0);
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this);
|
||||
s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin;
|
||||
s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin;
|
||||
|
@ -1737,7 +1737,7 @@ int QMenuBar::heightForWidth(int) const
|
||||
height = qMax(d->rightWidget->sizeHint().height() + margin, height);
|
||||
if(as_gui_menubar) {
|
||||
QStyleOptionMenuItem opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
opt.menuRect = rect();
|
||||
opt.state = QStyle::State_None;
|
||||
opt.menuItemType = QStyleOptionMenuItem::Normal;
|
||||
|
@ -228,7 +228,7 @@ QSizeGrip::~QSizeGrip()
|
||||
QSize QSizeGrip::sizeHint() const
|
||||
{
|
||||
QStyleOption opt(0);
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
return style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this);
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ void QSizeGrip::paintEvent(QPaintEvent *event)
|
||||
Q_D(QSizeGrip);
|
||||
QPainter painter(this);
|
||||
QStyleOptionSizeGrip opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
opt.corner = d->m_corner;
|
||||
style()->drawControl(QStyle::CE_SizeGrip, &opt, &painter, this);
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ QSize QSplitterHandle::sizeHint() const
|
||||
Q_D(const QSplitterHandle);
|
||||
int hw = d->s->handleWidth();
|
||||
QStyleOption opt(0);
|
||||
opt.init(d->s);
|
||||
opt.initFrom(d->s);
|
||||
opt.state = QStyle::State_None;
|
||||
return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s);
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ void QTabBarPrivate::layoutTabs()
|
||||
|
||||
Q_Q(QTabBar);
|
||||
QStyleOption opt;
|
||||
opt.init(q);
|
||||
opt.initFrom(q);
|
||||
QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);
|
||||
QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);
|
||||
int scrollButtonWidth = q->style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, &opt, q);
|
||||
@ -2120,7 +2120,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
if (d->validIndex(d->pressedIndex)) {
|
||||
QStyleOptionTabBarBase optTabBase;
|
||||
optTabBase.init(this);
|
||||
optTabBase.initFrom(this);
|
||||
optTabBase.documentMode = d->documentMode;
|
||||
if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this))
|
||||
setCurrentIndex(d->pressedIndex);
|
||||
@ -2820,7 +2820,7 @@ void CloseButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter p(this);
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
opt.state |= QStyle::State_AutoRaise;
|
||||
if (isEnabled() && underMouse() && !isChecked() && !isDown())
|
||||
opt.state |= QStyle::State_Raised;
|
||||
|
@ -241,7 +241,7 @@ public:
|
||||
tabOverlap.shape = tabbar->shape();
|
||||
int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
|
||||
QWidget *theParent = tabbar->parentWidget();
|
||||
optTabBase->init(tabbar);
|
||||
optTabBase->initFrom(tabbar);
|
||||
optTabBase->shape = tabbar->shape();
|
||||
optTabBase->documentMode = tabbar->documentMode();
|
||||
if (theParent && overlap > 0) {
|
||||
|
@ -59,7 +59,7 @@ QToolBarExtension::QToolBarExtension(QWidget *parent)
|
||||
void QToolBarExtension::setOrientation(Qt::Orientation o)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
if (o == Qt::Horizontal) {
|
||||
setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, &opt));
|
||||
} else {
|
||||
|
@ -3327,7 +3327,7 @@ void tst_QTreeWidget::task239150_editorWidth()
|
||||
QTreeWidget tree;
|
||||
|
||||
QStyleOptionFrame opt;
|
||||
opt.init(&tree);
|
||||
opt.initFrom(&tree);
|
||||
const int minWidth = tree.style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(0, 0)
|
||||
, nullptr).width();
|
||||
|
||||
|
@ -190,7 +190,7 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
|
||||
{
|
||||
QStyleOption opt;
|
||||
QWidget testWidget;
|
||||
opt.init(&testWidget);
|
||||
opt.initFrom(&testWidget);
|
||||
|
||||
testWidget.setStyle(style);
|
||||
|
||||
@ -218,24 +218,24 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
|
||||
QPixmap surface(QSize(200, 200));
|
||||
QPainter painter(&surface);
|
||||
QStyleOptionComboBox copt1;
|
||||
copt1.init(&testWidget);
|
||||
copt1.initFrom(&testWidget);
|
||||
|
||||
QStyleOptionGroupBox copt2;
|
||||
copt2.init(&testWidget);
|
||||
copt2.initFrom(&testWidget);
|
||||
QStyleOptionSizeGrip copt3;
|
||||
copt3.init(&testWidget);
|
||||
copt3.initFrom(&testWidget);
|
||||
QStyleOptionSlider copt4;
|
||||
copt4.init(&testWidget);
|
||||
copt4.initFrom(&testWidget);
|
||||
copt4.minimum = 0;
|
||||
copt4.maximum = 100;
|
||||
copt4.tickInterval = 25;
|
||||
copt4.sliderValue = 50;
|
||||
QStyleOptionSpinBox copt5;
|
||||
copt5.init(&testWidget);
|
||||
copt5.initFrom(&testWidget);
|
||||
QStyleOptionTitleBar copt6;
|
||||
copt6.init(&testWidget);
|
||||
copt6.initFrom(&testWidget);
|
||||
QStyleOptionToolButton copt7;
|
||||
copt7.init(&testWidget);
|
||||
copt7.initFrom(&testWidget);
|
||||
QStyleOptionComplex copt9;
|
||||
copt9.initFrom(&testWidget);
|
||||
|
||||
@ -538,7 +538,7 @@ void tst_QStyle::testProxyCalled()
|
||||
QToolButton b;
|
||||
b.setArrowType(Qt::DownArrow);
|
||||
QStyleOptionToolButton opt;
|
||||
opt.init(&b);
|
||||
opt.initFrom(&b);
|
||||
opt.features |= QStyleOptionToolButton::Arrow;
|
||||
QPixmap surface(QSize(200, 200));
|
||||
QPainter painter(&surface);
|
||||
|
@ -1918,7 +1918,7 @@ void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget()
|
||||
void paintEvent(QPaintEvent *) override
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, nullptr);
|
||||
style()->drawPrimitive(QStyle::PE_Frame, &opt, &p, nullptr);
|
||||
|
@ -1818,7 +1818,7 @@ void tst_QAbstractSlider::sliderPressedReleased()
|
||||
slider->activateWindow();
|
||||
|
||||
QStyleOptionSlider option;
|
||||
option.init(slider);
|
||||
option.initFrom(slider);
|
||||
option.upsideDown = control == QStyle::CC_Slider ? !slider->invertedAppearance()
|
||||
: slider->invertedAppearance();
|
||||
option.subControls = QStyle::SC_None;
|
||||
|
Loading…
Reference in New Issue
Block a user