Add a private class, since we now can.

This was a XXX Qt5 thing for binary compatibility. We could also
now use QObjectPrivate if we wanted to.

Change-Id: I7d95e3adf7b0725e91e1e229646a453863e989ed
Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
Michael Goddard
2011-11-01 11:19:22 +10:00
committed by Qt by Nokia
parent 6703ebf362
commit 6a3a442ea6
2 changed files with 42 additions and 37 deletions

View File

@@ -52,6 +52,23 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_METATYPE(QVideoSurfaceFormat) Q_DECLARE_METATYPE(QVideoSurfaceFormat)
Q_DECLARE_METATYPE(QAbstractVideoSurface::Error) Q_DECLARE_METATYPE(QAbstractVideoSurface::Error)
class QAbstractVideoSurfacePrivate {
public:
QAbstractVideoSurfacePrivate()
: error(QAbstractVideoSurface::NoError),
active(false)
{
}
public:
QVideoSurfaceFormat surfaceFormat;
QAbstractVideoSurface::Error error;
QSize nativeResolution;
bool active;
};
/*! /*!
\class QAbstractVideoSurface \class QAbstractVideoSurface
\brief The QAbstractVideoSurface class is a base class for video presentation surfaces. \brief The QAbstractVideoSurface class is a base class for video presentation surfaces.
@@ -93,26 +110,8 @@ Q_DECLARE_METATYPE(QAbstractVideoSurface::Error)
Constructs a video surface with the given \a parent. Constructs a video surface with the given \a parent.
*/ */
QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent)
: QObject(parent) : QObject(parent),
{ d_ptr(new QAbstractVideoSurfacePrivate)
setProperty("_q_surfaceFormat", QVariant::fromValue(QVideoSurfaceFormat()));
setProperty("_q_active", false);
setProperty("_q_error", QVariant::fromValue(QAbstractVideoSurface::NoError));
setProperty("_q_nativeResolution", QSize());
}
// XXX Qt5
/*!
\internal
This is deprecated.
Since we need to build without access to Qt's private headers we can't reliably inherit
from QObjectPrivate. Binary compatibility means we can't remove this constructor or
add a d pointer to QAbstractVideoSurface.
*/
QAbstractVideoSurface::QAbstractVideoSurface(QAbstractVideoSurfacePrivate &, QObject *parent)
: QObject(parent)
{ {
} }
@@ -181,7 +180,8 @@ QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat(const QVideoSurfaceForm
*/ */
QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const
{ {
return property("_q_format").value<QVideoSurfaceFormat>(); Q_D(const QAbstractVideoSurface);
return d->surfaceFormat;
} }
/*! /*!
@@ -203,11 +203,12 @@ QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const
*/ */
bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format)
{ {
bool wasActive = property("_q_active").toBool(); Q_D(QAbstractVideoSurface);
bool wasActive = d->active;
setProperty("_q_active", true); d->active = true;
setProperty("_q_format", QVariant::fromValue(format)); d->surfaceFormat = format;
setProperty("_q_error", QVariant::fromValue(NoError)); d->error = NoError;
emit surfaceFormatChanged(format); emit surfaceFormatChanged(format);
@@ -225,9 +226,10 @@ bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format)
*/ */
void QAbstractVideoSurface::stop() void QAbstractVideoSurface::stop()
{ {
if (property("_q_active").toBool()) { Q_D(QAbstractVideoSurface);
setProperty("_q_format", QVariant::fromValue(QVideoSurfaceFormat())); if (d->active) {
setProperty("_q_active", false); d->surfaceFormat = QVideoSurfaceFormat();
d->active = false;
emit activeChanged(false); emit activeChanged(false);
emit surfaceFormatChanged(surfaceFormat()); emit surfaceFormatChanged(surfaceFormat());
@@ -242,7 +244,8 @@ void QAbstractVideoSurface::stop()
*/ */
bool QAbstractVideoSurface::isActive() const bool QAbstractVideoSurface::isActive() const
{ {
return property("_q_active").toBool(); Q_D(const QAbstractVideoSurface);
return d->active;
} }
/*! /*!
@@ -286,7 +289,8 @@ bool QAbstractVideoSurface::isActive() const
QAbstractVideoSurface::Error QAbstractVideoSurface::error() const QAbstractVideoSurface::Error QAbstractVideoSurface::error() const
{ {
return property("_q_error").value<QAbstractVideoSurface::Error>(); Q_D(const QAbstractVideoSurface);
return d->error;
} }
/*! /*!
@@ -295,7 +299,8 @@ QAbstractVideoSurface::Error QAbstractVideoSurface::error() const
*/ */
void QAbstractVideoSurface::setError(Error error) void QAbstractVideoSurface::setError(Error error)
{ {
setProperty("_q_error", QVariant::fromValue(error)); Q_D(QAbstractVideoSurface);
d->error = error;
} }
/*! /*!
@@ -310,7 +315,8 @@ void QAbstractVideoSurface::setError(Error error)
*/ */
QSize QAbstractVideoSurface::nativeResolution() const QSize QAbstractVideoSurface::nativeResolution() const
{ {
return property("_q_nativeResolution").toSize(); Q_D(const QAbstractVideoSurface);
return d->nativeResolution;
} }
/*! /*!
@@ -319,10 +325,10 @@ QSize QAbstractVideoSurface::nativeResolution() const
*/ */
void QAbstractVideoSurface::setNativeResolution(const QSize &resolution) void QAbstractVideoSurface::setNativeResolution(const QSize &resolution)
{ {
const QSize nativeResolution = property("_q_nativeResolution").toSize(); Q_D(QAbstractVideoSurface);
if (nativeResolution != resolution) { if (d->nativeResolution != resolution) {
setProperty("_q_nativeResolution", resolution); d->nativeResolution = resolution;
emit nativeResolutionChanged(resolution); emit nativeResolutionChanged(resolution);
} }

View File

@@ -99,13 +99,12 @@ Q_SIGNALS:
void nativeResolutionChanged(const QSize &); void nativeResolutionChanged(const QSize &);
protected: protected:
QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent);
void setError(Error error); void setError(Error error);
void setNativeResolution(const QSize &resolution); void setNativeResolution(const QSize &resolution);
private: private:
Q_DECLARE_PRIVATE(QAbstractVideoSurface) Q_DECLARE_PRIVATE(QAbstractVideoSurface)
QScopedPointer<QAbstractVideoSurfacePrivate> d_ptr;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE