summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-09-22 16:52:30 +0200
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-09-22 17:10:47 +0200
commite60db8098c2505f6dd6a4313d2551c470bcf3dcf (patch)
tree0a2cf67298821787f8a9604f8e3e5e9bcc59a858
parentd85132fc4bb728fdcce929ce96e206110f76c139 (diff)
Removed dependency on private headers.
Reviewed-by: Frederik Gladhorn
-rw-r--r--qdeclarativegesturearea.cpp31
-rw-r--r--qdeclarativegesturearea_p.h3
-rw-r--r--qdeclarativegesturehandler.cpp38
-rw-r--r--qdeclarativegesturehandler_p.h4
4 files changed, 41 insertions, 35 deletions
diff --git a/qdeclarativegesturearea.cpp b/qdeclarativegesturearea.cpp
index c5f621f..298b0e7 100644
--- a/qdeclarativegesturearea.cpp
+++ b/qdeclarativegesturearea.cpp
@@ -45,18 +45,12 @@
#include <qdeclarativecontext.h>
#include <qdeclarativeinfo.h>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativeitem_p.h>
-#include <private/qdeclarativebinding_p.h>
-
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
#include <QtGui/qevent.h>
#include <QtGui/qgesture.h>
-#include <private/qobject_p.h>
-
#include "qdeclarativegesturehandler_p.h"
#include "gestureareaplugin_p.h"
@@ -64,11 +58,16 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeGestureAreaPrivate : public QDeclarativeItemPrivate
+// remove me and search-n-replace GESTUREHANDLER_D to Q_D
+// when put this plugin back to the Qt source tree
+#define GESTUREHANDLER_D(x) x##Private *d = d_ptr
+
+class QDeclarativeGestureAreaPrivate
{
- Q_DECLARE_PUBLIC(QDeclarativeGestureArea)
public:
- QDeclarativeGestureAreaPrivate() : defaultHandler(0) { }
+ QDeclarativeGestureAreaPrivate(QDeclarativeGestureArea *q) : q_ptr(q), defaultHandler(0) { }
+
+ QDeclarativeGestureArea *q_ptr;
typedef QMap<Qt::GestureType, QObject *> Handlers;
Handlers handlers;
@@ -76,7 +75,7 @@ public:
static void handlers_append(QDeclarativeListProperty<QObject> *prop, QObject *handler) {
QDeclarativeGestureAreaPrivate *d = static_cast<QDeclarativeGestureAreaPrivate *>(prop->data);
- QDeclarativeGestureArea *q = d->q_func();
+ QDeclarativeGestureArea *q = d->q_ptr;
handler->setParent(q);
int type = handler->property("gestureType").toInt();
// check that all needed properties exist
@@ -193,19 +192,21 @@ public:
*/
QDeclarativeGestureArea::QDeclarativeGestureArea(QDeclarativeItem *parent) :
- QDeclarativeItem(*(new QDeclarativeGestureAreaPrivate), parent)
+ QDeclarativeItem(parent)
{
+ d_ptr = new QDeclarativeGestureAreaPrivate(this);
setAcceptedMouseButtons(Qt::LeftButton);
setAcceptTouchEvents(true);
}
QDeclarativeGestureArea::~QDeclarativeGestureArea()
{
+ delete d_ptr; d_ptr = 0;
}
QDeclarativeListProperty<QObject> QDeclarativeGestureArea::handlers()
{
- Q_D(QDeclarativeGestureArea);
+ GESTUREHANDLER_D(QDeclarativeGestureArea);
return QDeclarativeListProperty<QObject>(this, d, QDeclarativeGestureAreaPrivate::handlers_append,
QDeclarativeGestureAreaPrivate::handlers_count, QDeclarativeGestureAreaPrivate::handlers_at,
QDeclarativeGestureAreaPrivate::handlers_clear);
@@ -213,7 +214,7 @@ QDeclarativeListProperty<QObject> QDeclarativeGestureArea::handlers()
bool QDeclarativeGestureArea::sceneEvent(QEvent *event)
{
- Q_D(QDeclarativeGestureArea);
+ GESTUREHANDLER_D(QDeclarativeGestureArea);
switch (event->type()) {
case QEvent::GraphicsSceneMousePress:
case QEvent::MouseButtonPress:
@@ -236,7 +237,7 @@ void QDeclarativeGestureAreaPrivate::evaluate(QGestureEvent *event, QGesture *ge
QDeclarativeExpression expr(when.context(), when.scopeObject(), when.script());
QVariant result = expr.evaluate();
if (expr.hasError()) {
- qmlInfo(q_func()) << expr.error();
+ qmlInfo(q_ptr) << expr.error();
return;
}
if (!result.toBool())
@@ -250,7 +251,7 @@ void QDeclarativeGestureAreaPrivate::evaluate(QGestureEvent *event, QGesture *ge
QDeclarativeExpression expr(script.context(), script.scopeObject(), script.script());
expr.evaluate();
if (expr.hasError())
- qmlInfo(q_func()) << expr.error();
+ qmlInfo(q_ptr) << expr.error();
}
event->accept(gesture);
handler->setProperty("gesture", QVariant());
diff --git a/qdeclarativegesturearea_p.h b/qdeclarativegesturearea_p.h
index d91d695..0eab504 100644
--- a/qdeclarativegesturearea_p.h
+++ b/qdeclarativegesturearea_p.h
@@ -44,7 +44,6 @@
#include <qdeclarativeitem.h>
#include <qdeclarativescriptstring.h>
-#include <private/qdeclarativecustomparser_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
@@ -80,6 +79,8 @@ protected:
bool sceneEvent(QEvent *event);
private:
+ QDeclarativeGestureAreaPrivate *d_ptr;
+
Q_DISABLE_COPY(QDeclarativeGestureArea)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGestureArea)
};
diff --git a/qdeclarativegesturehandler.cpp b/qdeclarativegesturehandler.cpp
index 05e13d7..b6d49c9 100644
--- a/qdeclarativegesturehandler.cpp
+++ b/qdeclarativegesturehandler.cpp
@@ -46,14 +46,11 @@
#include <QtGui/qevent.h>
-#include <private/qobject_p.h>
-#include <private/qdeclarativebinding_p.h>
-
#ifndef QT_NO_GESTURES
QT_BEGIN_NAMESPACE
-class QDeclarativeGestureHandlerPrivate : public QObjectPrivate
+class QDeclarativeGestureHandlerPrivate
{
public:
QDeclarativeGestureHandlerPrivate()
@@ -68,79 +65,84 @@ public:
QObject *gesture;
};
+// remove me and search-n-replace GESTUREHANDLER_D to Q_D
+// when put this plugin back to the Qt source tree
+#define GESTUREHANDLER_D(x) x##Private *d = d_ptr
+
QDeclarativeGestureHandler::QDeclarativeGestureHandler(QObject *parent)
- : QObject(*new QDeclarativeGestureHandlerPrivate, parent)
+ : QObject(parent)
{
+ d_ptr = new QDeclarativeGestureHandlerPrivate;
}
-QDeclarativeGestureHandler::QDeclarativeGestureHandler(QDeclarativeGestureHandlerPrivate &dd, QObject *parent)
- : QObject(dd, parent)
+QDeclarativeGestureHandler::~QDeclarativeGestureHandler()
{
+ delete d_ptr; d_ptr = 0;
}
bool QDeclarativeGestureHandler::isWhenKnown() const
{
- Q_D(const QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(const QDeclarativeGestureHandler);
return !d->when.script().isEmpty();
}
QDeclarativeScriptString QDeclarativeGestureHandler::when() const
{
- Q_D(const QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(const QDeclarativeGestureHandler);
return d->when;
}
void QDeclarativeGestureHandler::setWhen(const QDeclarativeScriptString &when)
{
- Q_D(QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(QDeclarativeGestureHandler);
d->when = when;
}
QDeclarativeScriptString QDeclarativeGestureHandler::onStarted() const
{
- Q_D(const QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(const QDeclarativeGestureHandler);
return d->onStarted;
}
void QDeclarativeGestureHandler::setOnStarted(const QDeclarativeScriptString &script)
{
- Q_D(QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(QDeclarativeGestureHandler);
d->onStarted = script;
}
QDeclarativeScriptString QDeclarativeGestureHandler::onUpdated() const
{
- Q_D(const QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(const QDeclarativeGestureHandler);
return d->onUpdated;
}
void QDeclarativeGestureHandler::setOnUpdated(const QDeclarativeScriptString &script)
{
- Q_D(QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(QDeclarativeGestureHandler);
d->onUpdated = script;
}
QDeclarativeScriptString QDeclarativeGestureHandler::onFinished() const
{
- Q_D(const QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(const QDeclarativeGestureHandler);
return d->onFinished;
}
void QDeclarativeGestureHandler::setOnFinished(const QDeclarativeScriptString &script)
{
- Q_D(QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(QDeclarativeGestureHandler);
d->onFinished = script;
}
QDeclarativeScriptString QDeclarativeGestureHandler::onCanceled() const
{
- Q_D(const QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(const QDeclarativeGestureHandler);
return d->onCanceled;
}
void QDeclarativeGestureHandler::setOnCanceled(const QDeclarativeScriptString &script)
{
- Q_D(QDeclarativeGestureHandler);
+ GESTUREHANDLER_D(QDeclarativeGestureHandler);
d->onCanceled = script;
}
diff --git a/qdeclarativegesturehandler_p.h b/qdeclarativegesturehandler_p.h
index 0e9aa38..9e5a87e 100644
--- a/qdeclarativegesturehandler_p.h
+++ b/qdeclarativegesturehandler_p.h
@@ -98,11 +98,13 @@ Q_SIGNALS:
protected:
QDeclarativeGestureHandler(QObject *parent = 0);
- QDeclarativeGestureHandler(QDeclarativeGestureHandlerPrivate &dd, QObject *parent = 0);
+ ~QDeclarativeGestureHandler();
void setGestureType(int type);
private:
+ QDeclarativeGestureHandlerPrivate *d_ptr;
+
friend class QDeclarativeGestureArea;
Q_DISABLE_COPY(QDeclarativeGestureHandler)
Q_DECLARE_PRIVATE(QDeclarativeGestureHandler)