summaryrefslogtreecommitdiff
path: root/src/location/places/qplacecontent_p.h
diff options
context:
space:
mode:
authorabcd <qt-info@nokia.com>2011-08-22 14:39:26 +1000
committerabcd <qt_abcd1@ovi.com>2011-08-22 10:22:36 +0200
commit69d4a69261da1758b1a21c28a09fdd5006c51890 (patch)
treedaaac27f39281bd5ff98915f3753dae1aec93453 /src/location/places/qplacecontent_p.h
parent2c829671005e6572ae6e048aa337bb8b3ca639f9 (diff)
downloadqtlocation-69d4a69261da1758b1a21c28a09fdd5006c51890.tar.gz
Introduce Content class and rename PlaceMediaObject to PlaceImage
Paging is now implemented in terms of content objects, things like images, reviews etc should inherit off the QPlaceContent class. The main advantage of this change in C++ is that the paging code will not be duplicated for different content types, also we have less symbols which is good for plugin loading times. For now, in QML we still retain separate specialized models. In future it might be possible to just have a single model class to hold different content types. There will still however need to be separate model instances for say reviews and images. PlaceMediaObject has been renamed to PlaceImage because currently all we provide are images. It is anticipated that if there are new media types like video we would introduce QPlaceVideo and have it inherit off QPlaceContent. It is suboptimal to try define a generic media object right now when we do not have a clear idea about the use cases of each possible media type. A future change will have QPlaceReview inherit off QPlaceContent. Change-Id: Ia6cf5092e246374ed639694d7653e30429c94cc2 Reviewed-on: http://codereview.qt.nokia.com/3284 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com> Reviewed-by: abcd <qt_abcd1@ovi.com>
Diffstat (limited to 'src/location/places/qplacecontent_p.h')
-rw-r--r--src/location/places/qplacecontent_p.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/location/places/qplacecontent_p.h b/src/location/places/qplacecontent_p.h
new file mode 100644
index 00000000..d3b258d0
--- /dev/null
+++ b/src/location/places/qplacecontent_p.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by tOhe Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACECONTENT_P_H
+#define QPLACECONTENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qplacecontent.h"
+
+#include <QSharedData>
+#include <QString>
+
+
+QT_BEGIN_NAMESPACE
+
+
+#define Q_IMPLEMENT_CONTENT_D_FUNC(Class) \
+ Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
+ const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \
+
+#define Q_IMPLEMENT_CONTENT_COPY_CTOR(Class) \
+ Class::Class(const QPlaceContent& other) : QPlaceContent() { Class##Private::copyIfPossible(d_ptr, other); }
+
+#define Q_DEFINE_CONTENT_PRIVATE_HELPER(Class, ContentType) \
+ QPlaceContentPrivate* clone() const { return new Class##Private(*this); } \
+ virtual QPlaceContent::Type type() const {return ContentType;} \
+ static void copyIfPossible(QSharedDataPointer<QPlaceContentPrivate>& d_ptr, const QPlaceContent& other) \
+ { \
+ if (other.type() == ContentType) \
+ d_ptr = extract_d(other); \
+ else \
+ d_ptr = new Class##Private; \
+ }
+
+class QPlaceContentPrivate : public QSharedData
+{
+public:
+ QPlaceContentPrivate(){}
+ virtual ~QPlaceContentPrivate(){}
+
+ virtual bool compare(const QPlaceContentPrivate *other) const =0;
+ virtual QPlaceContentPrivate* clone() const = 0;
+ virtual QPlaceContent::Type type() const = 0;
+
+ /* Helper functions for C++ protection rules */
+ static const QSharedDataPointer<QPlaceContentPrivate>& extract_d(const QPlaceContent& other) {return other.d_ptr;}
+};
+
+#if defined(Q_CC_MWERKS)
+// This results in multiple symbol definition errors on all other compilers
+// but not having a definition here results in an attempt to use the unspecialized
+// clone (which fails because of the pure virtuals above)
+template<> QPlaceContentPrivate *QSharedDataPointer<QPlaceContentPrivate>::clone()
+{
+ return d->clone();
+}
+#else
+template<> QPlaceContentPrivate *QSharedDataPointer<QPlaceContentPrivate>::clone();
+#endif
+
+QT_END_NAMESPACE
+
+#endif
+