summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2012-08-24 17:27:52 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-31 18:56:35 +0200
commitdd299a568b2cf5ee335fcb01020da9032a57f01e (patch)
tree118ed3ae1269589686e5062015645c68f35c573f /src/widgets
parent531b96f42ef225f6f680f6049ab718b0f6729a3d (diff)
QStyle: make standardIcon() & layoutSpacing() virtual
Removes standardIconImplementation() and layoutSpacingImplementation() that were added in Qt 4 as a workaround for binary compatibility reasons. Change-Id: I45292dc6802310d6cda4f443bb7484b061af0138 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qstyle.cpp114
-rw-r--r--src/widgets/styles/qstyle.h19
2 files changed, 14 insertions, 119 deletions
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index da8d374538..8d8ba9c45b 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -2021,7 +2021,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
Developers calling standardPixmap() should instead call standardIcon()
Developers who re-implemented standardPixmap() should instead re-implement
- the slot standardIconImplementation().
+ standardIcon().
\sa standardIcon()
*/
@@ -2213,64 +2213,25 @@ QPalette QStyle::standardPalette() const
/*!
\since 4.1
- Returns an icon for the given \a standardIcon.
-
- The \a standardIcon is a standard pixmap which can follow some
- existing GUI style or guideline. The \a option argument can be
- used to pass extra information required when defining the
- appropriate icon. The \a widget argument is optional and can also
- be used to aid the determination of the icon.
-
- \warning Because of binary compatibility constraints, this
- function is not virtual. If you want to provide your own icons in
- a QStyle subclass, reimplement the standardIconImplementation()
- slot in your subclass instead. The standardIcon() function will
- dynamically detect the slot and call it.
-
- \sa standardIconImplementation()
-*/
-QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget) const
-{
- QIcon result;
- // ### Qt 4.1: invokeMethod should accept const functions, to avoid this dirty cast
- QMetaObject::invokeMethod(const_cast<QStyle*>(this),
- "standardIconImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(QIcon, result),
- Q_ARG(StandardPixmap, standardIcon),
- Q_ARG(const QStyleOption*, option),
- Q_ARG(const QWidget*, widget));
- return result;
-}
-
-/*!
- \since 4.1
+ \fn QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const = 0;
Returns an icon for the given \a standardIcon.
- Reimplement this slot to provide your own icons in a QStyle
- subclass; because of binary compatibility constraints, the
- standardIcon() function (introduced in Qt 4.1) is not
- virtual. Instead, standardIcon() will dynamically detect and call
- \e this slot.
-
The \a standardIcon is a standard pixmap which can follow some
existing GUI style or guideline. The \a option argument can be
used to pass extra information required when defining the
appropriate icon. The \a widget argument is optional and can also
be used to aid the determination of the icon.
-
- \sa standardIcon()
*/
-QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget) const
-{
- return QIcon(standardPixmap(standardIcon, option, widget));
-}
/*!
\since 4.3
+ \fn int QStyle::layoutSpacing(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2, Qt::Orientation orientation,
+ const QStyleOption *option = 0, const QWidget *widget = 0) const
+
Returns the spacing that should be used between \a control1 and
\a control2 in a layout. \a orientation specifies whether the
controls are laid out side by side or stacked vertically. The \a
@@ -2282,35 +2243,8 @@ QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QSty
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
negative value.
- For binary compatibility reasons, this function is not virtual.
- If you want to specify custom layout spacings in a QStyle
- subclass, implement a slot called layoutSpacingImplementation().
- QStyle will discover the slot at run-time (using Qt's
- \l{meta-object system}) and direct all calls to layoutSpacing()
- to layoutSpacingImplementation().
-
- \sa combinedLayoutSpacing(), layoutSpacingImplementation()
+ \sa combinedLayoutSpacing()
*/
-int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QStyle);
- if (d->layoutSpacingIndex == -1) {
- d->layoutSpacingIndex = metaObject()->indexOfMethod(
- "layoutSpacingImplementation(QSizePolicy::ControlType,QSizePolicy::ControlType,"
- "Qt::Orientation,const QStyleOption*,const QWidget*)"
- );
- }
- if (d->layoutSpacingIndex < 0)
- return -1;
- int result = -1;
- void *param[] = {&result, &control1, &control2, &orientation, &option, &widget};
-
- const_cast<QStyle *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
- d->layoutSpacingIndex, param);
- return result;
-}
/*!
\since 4.3
@@ -2329,7 +2263,7 @@ int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::Contro
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
negative value.
- \sa layoutSpacing(), layoutSpacingImplementation()
+ \sa layoutSpacing()
*/
int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
@@ -2350,36 +2284,6 @@ int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
return result;
}
-/*!
- \since 4.3
-
- This slot is called by layoutSpacing() to determine the spacing
- that should be used between \a control1 and \a control2 in a
- layout. \a orientation specifies whether the controls are laid
- out side by side or stacked vertically. The \a option parameter
- can be used to pass extra information about the parent widget.
- The \a widget parameter is optional and can also be used if \a
- option is 0.
-
- If you want to provide custom layout spacings in a QStyle
- subclass, implement a slot called layoutSpacingImplementation()
- in your subclass. Be aware that this slot will only be called if
- PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
- negative value.
-
- The default implementation returns -1.
-
- \sa layoutSpacing(), combinedLayoutSpacing()
-*/
-int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */,
- QSizePolicy::ControlType /* control2 */,
- Qt::Orientation /*orientation*/,
- const QStyleOption * /* option */,
- const QWidget * /* widget */) const
-{
- return -1;
-}
-
QT_BEGIN_INCLUDE_NAMESPACE
#include <QDebug>
QT_END_INCLUDE_NAMESPACE
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 9be063ca03..3194845954 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -784,8 +784,8 @@ public:
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
const QWidget *widget = 0) const = 0;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
+ virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const = 0;
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const = 0;
@@ -802,24 +802,15 @@ public:
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment,
const QSize &size, const QRect &rectangle);
- int layoutSpacing(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2, Qt::Orientation orientation,
- const QStyleOption *option = 0, const QWidget *widget = 0) const;
+ virtual int layoutSpacing(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2, Qt::Orientation orientation,
+ const QStyleOption *option = 0, const QWidget *widget = 0) const = 0;
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
QStyleOption *option = 0, QWidget *widget = 0) const;
const QStyle * proxy() const;
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
- int layoutSpacingImplementation(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation,
- const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
private:
Q_DISABLE_COPY(QStyle)
friend class QWidget;