summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2010-06-23 18:22:55 +1000
committerAndrew den Exter <andrew.den-exter@nokia.com>2010-06-23 18:22:55 +1000
commita0cce86d911858eb2481d2569a310eaba270d09d (patch)
treeb05465a4363c38fbc58ede1a440edf81e668cc16 /examples
parente955f8208223bedb3c83b75318a2278a748b925f (diff)
parent0786e8f3d652273ae7b404e66d5e7b447b3e88d8 (diff)
Merge branch '1.0' of scm.dev.nokia.troll.no:qtmobility/qtmobility into 1.0
Diffstat (limited to 'examples')
-rw-r--r--examples/flickrdemo/flickrdemo.cpp6
-rw-r--r--examples/flickrdemo/main.cpp2
-rw-r--r--examples/keepintouch/addressfinder.h2
-rw-r--r--examples/lightmaps/lightmaps.cpp4
-rw-r--r--examples/logfilepositionsource/main.cpp2
-rw-r--r--examples/qmlcontacts/ScrollBar.qml4
-rw-r--r--examples/qmlcontacts/com/nokia/mobility/qmldir1
-rw-r--r--examples/qmlcontacts/contents/MediaButton.qml4
-rw-r--r--examples/qmlcontacts/example.qml60
-rw-r--r--examples/qmlcontacts/imageprovider.cpp111
-rw-r--r--examples/qmlcontacts/imageprovider.h65
-rw-r--r--examples/qmlcontacts/plugin.cpp77
-rw-r--r--examples/qmlcontacts/qmlcontact.cpp124
-rw-r--r--examples/qmlcontacts/qmlcontact.h67
-rw-r--r--examples/qmlcontacts/qmlcontactdetail.cpp111
-rw-r--r--examples/qmlcontacts/qmlcontactdetail.h77
-rw-r--r--examples/qmlcontacts/qmlcontactdetailfield.cpp (renamed from examples/qmlcontacts/main.cpp)58
-rw-r--r--examples/qmlcontacts/qmlcontactdetailfield.h72
-rw-r--r--examples/qmlcontacts/qmlcontactmodel.cpp58
-rw-r--r--examples/qmlcontacts/qmlcontactmodel.h13
-rw-r--r--examples/qmlcontacts/qmlcontacts.pro44
-rw-r--r--examples/qmlcontacts/qmlcontacts.qrc11
-rw-r--r--examples/satellitedialog/satellitedialog.cpp2
-rw-r--r--examples/sensors/orientation/main.cpp11
-rw-r--r--examples/sensors/orientation/orientation.qml9
-rw-r--r--examples/sensors/small_screen_sensors/small_screen_sensors.pro2
-rw-r--r--examples/servicebrowser/servicebrowser.cpp2
-rw-r--r--examples/servicebrowser/servicebrowser.pro2
-rw-r--r--examples/sfw-notes/sfw-notes.pro2
-rw-r--r--examples/sfw-notes/sfwnotes.cpp2
-rw-r--r--examples/sysinfo/sysinfo.pro2
-rw-r--r--examples/weatherinfo/weatherinfo.cpp6
-rw-r--r--examples/writemessage/messagesender.h2
33 files changed, 908 insertions, 107 deletions
diff --git a/examples/flickrdemo/flickrdemo.cpp b/examples/flickrdemo/flickrdemo.cpp
index 3ba014d631..15f5b634cd 100644
--- a/examples/flickrdemo/flickrdemo.cpp
+++ b/examples/flickrdemo/flickrdemo.cpp
@@ -212,13 +212,13 @@ void FlickrDemo::networkSessionOpened()
void FlickrDemo::createMenus()
{
m_downloadAct = new QAction(tr("Download Picture List"), this);
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
menuBar()->addAction(m_downloadAct);
#endif
connect(m_downloadAct, SIGNAL(triggered()), this, SLOT(downloadButtonClicked()));
QAction* exitAct = new QAction(tr("Exit"), this);
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
menuBar()->addAction(exitAct);
#endif
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
@@ -564,7 +564,7 @@ void FlickrDemo::clearPictureRequest()
void FlickrDemo::displayImage(const QPixmap &pixmap)
{
PictureDialog dialog(pixmap, listWidget->currentItem()->text(), this);
-#if defined(Q_OS_SYMBIAN) || defined (Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
dialog.showMaximized();
#endif
dialog.exec();
diff --git a/examples/flickrdemo/main.cpp b/examples/flickrdemo/main.cpp
index 9dc3621c02..152541b1a1 100644
--- a/examples/flickrdemo/main.cpp
+++ b/examples/flickrdemo/main.cpp
@@ -45,7 +45,7 @@ int main(int argc, char* argv[])
{
QApplication app(argc, argv);
FlickrDemo flickrDemo;
-#ifdef Q_OS_SYMBIAN
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
flickrDemo.showMaximized();
#else
flickrDemo.show();
diff --git a/examples/keepintouch/addressfinder.h b/examples/keepintouch/addressfinder.h
index e002a9ba3d..ee80965eab 100644
--- a/examples/keepintouch/addressfinder.h
+++ b/examples/keepintouch/addressfinder.h
@@ -40,7 +40,7 @@
#ifndef ADDRESSFINDER_H
#define ADDRESSFINDER_H
-#include "qtmessaging.h"
+#include "qmessageservice.h"
#include <QMap>
#include <QObject>
diff --git a/examples/lightmaps/lightmaps.cpp b/examples/lightmaps/lightmaps.cpp
index 44f5c0cb6b..c600cd68fe 100644
--- a/examples/lightmaps/lightmaps.cpp
+++ b/examples/lightmaps/lightmaps.cpp
@@ -723,7 +723,7 @@ public:
connect(nightModeAction, SIGNAL(triggered()), map, SLOT(toggleNightMode()));
connect(osmAction, SIGNAL(triggered()), SLOT(aboutOsm()));
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
menuBar()->addAction(gpsAction);
menuBar()->addAction(osloAction);
menuBar()->addAction(berlinAction);
@@ -787,7 +787,7 @@ int main(int argc, char **argv)
MapZoom w;
w.setWindowTitle("OpenStreetMap");
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
w.showMaximized();
#else
w.resize(600, 450);
diff --git a/examples/logfilepositionsource/main.cpp b/examples/logfilepositionsource/main.cpp
index 77f3395b29..fd77f0b7b0 100644
--- a/examples/logfilepositionsource/main.cpp
+++ b/examples/logfilepositionsource/main.cpp
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
ClientApplication client;
-#ifdef Q_OS_SYMBIAN
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
client.showMaximized();
#else
client.show();
diff --git a/examples/qmlcontacts/ScrollBar.qml b/examples/qmlcontacts/ScrollBar.qml
index e53b625ba9..1858059bb1 100644
--- a/examples/qmlcontacts/ScrollBar.qml
+++ b/examples/qmlcontacts/ScrollBar.qml
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import Qt 4.6
+import Qt 4.7
Item {
id: scrollBar
@@ -49,7 +49,7 @@ Item {
// orientation can be either 'Vertical' or 'Horizontal'
property real position
property real pageSize
- property var orientation : "Vertical"
+ property string orientation : "Vertical"
property alias bgColor: background.color
property alias fgColor: thumb.color
diff --git a/examples/qmlcontacts/com/nokia/mobility/qmldir b/examples/qmlcontacts/com/nokia/mobility/qmldir
new file mode 100644
index 0000000000..7443f071c8
--- /dev/null
+++ b/examples/qmlcontacts/com/nokia/mobility/qmldir
@@ -0,0 +1 @@
+plugin qcontactqmlplugin
diff --git a/examples/qmlcontacts/contents/MediaButton.qml b/examples/qmlcontacts/contents/MediaButton.qml
index a07079cd4c..76a972bf82 100644
--- a/examples/qmlcontacts/contents/MediaButton.qml
+++ b/examples/qmlcontacts/contents/MediaButton.qml
@@ -38,10 +38,10 @@
**
****************************************************************************/
-import Qt 4.6
+import Qt 4.7
Item {
- property var text
+ property string text
signal clicked
id: container
diff --git a/examples/qmlcontacts/example.qml b/examples/qmlcontacts/example.qml
index a6819bd028..6db131fc25 100644
--- a/examples/qmlcontacts/example.qml
+++ b/examples/qmlcontacts/example.qml
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QmlContactModel 1.0
-import Qt 4.6
+import Qt 4.7
+import com.nokia.mobility 1.0
import "contents"
Rectangle {
@@ -52,7 +52,7 @@ Rectangle {
color: "#080808";
QmlContactModel {
- id: "myModel"
+ id: contactModel
manager: "memory"
}
@@ -127,6 +127,7 @@ Rectangle {
opacity: wrapper.detailsOpacity
height: childrenRect.height + 6;
width: childrenRect.width;
+
Column {
Text {
text: model.interestLabel + ": " + model.interest
@@ -136,12 +137,61 @@ Rectangle {
text: model.presenceAvailable ? model.presenceText + " [" + model.presenceMessage + "]" : " ";
color: details.textColor;
}
+ ListView {
+ width: details.width;
+ highlightFollowsCurrentItem: false
+ focus: true
+ //anchors.fill: parent
+ keyNavigationWraps: true
+
+ model:contactModel.details(contactId)
+ delegate: Component {
+ Item {
+ width: details.width;
+ property QtObject contactDetail : model.modelData;
+ Column {
+ Text {
+ width: details.width;
+ height: 20;
+ text: contactDetail.name;
+ color:details.textColor;
+ }
+ ListView {
+ width: details.width;
+ model:contactDetail.fields();
+ delegate: Component {
+ Item {
+ property QtObject field: model.modelData;
+ Row {
+ Text {
+ text:field.key;
+ color:details.textColor;
+ width: details.width;
+ height: 20;
+ }
+ TextInput {
+ width: details.width;
+ height: 20;
+ text:field.value;
+ color:details.textColor;
+ }
+ }
+ }
+ }//delegate
+
+ }//detail fields view
+
+ }
+ }
+
+ }//delegate
+ }//detail list view
}
}
}
Item {
- id: "buttonBox"
+ id: buttonBox
x: wrapper.width - 6 - childrenRect.width;
y: 4;
height:childrenRect.height
@@ -267,7 +317,7 @@ Rectangle {
ListView {
id: mainList
- model: myModel
+ model: contactModel
width: parent.width; height: parent.height
delegate: listdelegate
highlightFollowsCurrentItem: false
diff --git a/examples/qmlcontacts/imageprovider.cpp b/examples/qmlcontacts/imageprovider.cpp
new file mode 100644
index 0000000000..1712df97dc
--- /dev/null
+++ b/examples/qmlcontacts/imageprovider.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <qdeclarativeextensionplugin.h>
+
+#include <qdeclarativeengine.h>
+#include <qdeclarative.h>
+#include <qcontactmanager.h>
+#include <qcontactdetails.h>
+#include "imageprovider.h"
+
+
+QTM_USE_NAMESPACE
+
+// This is run in a low priority thread.
+QImage ContactThumbnailImageProvider::request(const QString &id, QSize *size, const QSize &req_size)
+{
+ if (m_thumbnails.contains(id)) {
+ if (size)
+ *size = req_size;
+ return m_thumbnails.value(id).scaled(req_size);
+ }
+
+ /* url format:
+ image://thumbnail/{manager.contactid}
+ */
+
+ QString managerName = id.split('.').first();
+ QString localId = id.split('.').last();
+
+ QContactManager* manager = 0;
+ if (m_managers.contains(managerName)) {
+ manager = m_managers.value(managerName);
+ } else {
+ manager = new QContactManager(managerName);
+ m_managers.insert(managerName, manager);
+ }
+
+ QContact c = manager->contact(localId.toInt());
+
+ QImage image(
+ req_size.width() > 0 ? req_size.width() : 100,
+ req_size.height() > 0 ? req_size.height() : 50,
+ QImage::Format_RGB32);
+
+ QContactThumbnail t = c.detail<QContactThumbnail>();
+ if (!t.thumbnail().isNull()) {
+ image = t.thumbnail().scaled(image.size());
+ } else {
+ QContactAvatar a = c.detail<QContactAvatar>();
+ QString imageUrl = a.imageUrl().isEmpty()? QString::fromLatin1("contents/default.svg") : a.imageUrl().toString();
+ image.load(imageUrl);
+ }
+
+ if (size)
+ *size = image.size();
+
+ m_thumbnails.insert(id, image);
+
+ return image;
+}
+
+ContactThumbnailImageProvider::~ContactThumbnailImageProvider()
+{
+ foreach(const QString& name, m_managers.keys()) {
+ delete m_managers.value(name);
+ }
+
+ m_managers.clear();
+}
+
+
diff --git a/examples/qmlcontacts/imageprovider.h b/examples/qmlcontacts/imageprovider.h
new file mode 100644
index 0000000000..be6418986f
--- /dev/null
+++ b/examples/qmlcontacts/imageprovider.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <qdeclarativeimageprovider.h>
+#include <QMap>
+#include "qcontactmanager.h"
+
+
+
+
+QTM_USE_NAMESPACE;
+
+
+class ContactThumbnailImageProvider : public QDeclarativeImageProvider
+{
+public:
+ // This is run in a low priority thread.
+ QImage request(const QString &id, QSize *size, const QSize &req_size);
+
+ ~ContactThumbnailImageProvider();
+
+private:
+ QMap<QString, QContactManager*> m_managers;
+ QMap<QString, QImage> m_thumbnails;
+};
+
diff --git a/examples/qmlcontacts/plugin.cpp b/examples/qmlcontacts/plugin.cpp
new file mode 100644
index 0000000000..d3c30c5fd6
--- /dev/null
+++ b/examples/qmlcontacts/plugin.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QApplication>
+#include <QtDeclarative>
+#include <QDeclarativeExtensionPlugin>
+#include <QDebug>
+#include "qmlcontactmodel.h"
+#include "qmlcontact.h"
+#include "qmlcontactdetail.h"
+#include "qmlcontactdetailfield.h"
+#include "imageprovider.h"
+
+QT_USE_NAMESPACE
+
+
+class QContactQmlPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(uri == QLatin1String("com.nokia.mobility"));
+ qmlRegisterType<QMLContactModel>(uri, 1, 0, "QmlContactModel");
+ qmlRegisterType<QMLContact>(uri, 1, 0, "QmlContact");
+ qmlRegisterType<QMLContactDetail>(uri, 1, 0, "QmlContactDetail");
+ qmlRegisterType<QMLContactDetailField>(uri, 1, 0, "QmlContactDetailField");
+ }
+
+ void initializeEngine(QDeclarativeEngine *engine, const char *uri) {
+ Q_UNUSED(uri);
+ engine->addImageProvider("thumbnail", new ContactThumbnailImageProvider);
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qcontactqmlplugin, QContactQmlPlugin);
+
diff --git a/examples/qmlcontacts/qmlcontact.cpp b/examples/qmlcontacts/qmlcontact.cpp
new file mode 100644
index 0000000000..23c6118d60
--- /dev/null
+++ b/examples/qmlcontacts/qmlcontact.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qcontactdetails.h>
+#include "qmlcontact.h"
+#include "qmlcontactdetail.h"
+#include <QDebug>
+
+static QString normalizePropertyName(const QString& name)
+{
+ if (!name.isEmpty())
+ return name.mid(1).prepend(name[0].toLower());
+ return QString();
+}
+
+
+QMLContact::QMLContact(QObject *parent)
+ :QObject(parent),
+ m_contactMap(0)
+{
+
+}
+
+void QMLContact::setContact(const QContact& c)
+{
+ m_contact = c;
+
+ if (m_contactMap) {
+ delete m_contactMap;
+ m_detailMaps.clear();
+ }
+
+ foreach (QObject* detail, m_details) {
+ delete detail;
+ }
+ m_details.clear();
+
+ m_contactMap = new QDeclarativePropertyMap(this);
+
+
+ QList<QContactDetail> details = m_contact.details();
+ foreach (const QContactDetail& detail, details) {
+ QMLContactDetail* qd = new QMLContactDetail(this);
+
+ QDeclarativePropertyMap* dm = new QDeclarativePropertyMap(m_contactMap);
+
+ connect(dm, SIGNAL(valueChanged(QString,QVariant)), qd, SLOT(detailChanged(QString,QVariant)));
+
+
+ QVariantMap values = detail.variantValues();
+ foreach (const QString& key, values.keys()) {
+ dm->insert(normalizePropertyName(key), values.value(key));
+ }
+ qd->setName(normalizePropertyName(detail.definitionName()));
+ m_details.append(qd);
+ qd->setDetailPropertyMap(dm);
+ m_detailMaps.append(dm);;
+ m_contactMap->insert(normalizePropertyName(detail.definitionName()), QVariant::fromValue(static_cast<QObject*>(dm)));
+ }
+}
+
+QContact QMLContact::contact() const
+{
+ QContact c(m_contact);
+ foreach (QObject* o, m_details) {
+ QMLContactDetail* d = qobject_cast<QMLContactDetail*>(o);
+ if (d && d->isDetailChanged()) {
+ QContactDetail detail = d->detail();
+ c.saveDetail(&detail);
+ }
+ }
+
+ return c;
+}
+
+QList<QObject*> QMLContact::details() const
+{
+ return m_details;
+}
+
+QVariant QMLContact::contactMap() const
+{
+ if (m_contactMap)
+ return QVariant::fromValue(static_cast<QObject*>(m_contactMap));
+ return QVariant();
+}
+
diff --git a/examples/qmlcontacts/qmlcontact.h b/examples/qmlcontacts/qmlcontact.h
new file mode 100644
index 0000000000..1a2f82f651
--- /dev/null
+++ b/examples/qmlcontacts/qmlcontact.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLCONTACT_H
+#define QMLCONTACT_H
+
+#include <QDeclarativePropertyMap>
+#include "qcontact.h"
+
+QTM_USE_NAMESPACE;
+
+class QMLContact : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QMLContact(QObject *parent = 0);
+ void setContact(const QContact& c);
+ QContact contact() const;
+ QVariant contactMap() const;
+ Q_INVOKABLE QList<QObject*> details() const;
+
+private:
+
+ QContact m_contact;
+ QDeclarativePropertyMap* m_contactMap;
+ QList<QDeclarativePropertyMap*> m_detailMaps;
+ QList<QObject*> m_details;
+};
+
+#endif // QMLCONTACT_H
diff --git a/examples/qmlcontacts/qmlcontactdetail.cpp b/examples/qmlcontacts/qmlcontactdetail.cpp
new file mode 100644
index 0000000000..238c1c923c
--- /dev/null
+++ b/examples/qmlcontacts/qmlcontactdetail.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlcontactdetail.h"
+#include "qmlcontactdetailfield.h"
+#include <QDebug>
+
+
+static QString ToContactDetailName(const QString& name)
+{
+ if (!name.isEmpty())
+ return name.mid(1).prepend(name[0].toUpper());
+ return QString();
+}
+
+
+QMLContactDetail::QMLContactDetail(QObject* parent)
+ :QObject(parent),
+ m_contactChanged(false)
+{
+
+}
+
+QDeclarativePropertyMap* QMLContactDetail::propertyMap() const
+{
+ return m_map;
+}
+void QMLContactDetail::setDetailPropertyMap(QDeclarativePropertyMap* map)
+{
+ m_map = map;
+ qWarning() << "detail:" << m_detailName << " has " << m_map->count() << " fields.";
+ foreach (const QString& key, m_map->keys()) {
+ QMLContactDetailField* field = new QMLContactDetailField(this);
+ field->setDetailPropertyMap(m_map);
+ field->setKey(key);
+ m_fields.append(field);
+ qWarning() << " detail field:" << key << "='" << m_map->value(key) << "'";
+ }
+}
+
+QList<QObject*> QMLContactDetail::fields() const
+{
+ return m_fields;
+}
+
+QString QMLContactDetail::name() const
+{
+ return m_detailName;
+}
+
+void QMLContactDetail::setName(const QString& name)
+{
+ m_detailName = name;
+}
+
+bool QMLContactDetail::isDetailChanged() const
+{
+ return m_contactChanged;
+}
+
+QContactDetail QMLContactDetail::detail() const
+{
+ QContactDetail d(ToContactDetailName(name()));
+ foreach (const QString& key, m_map->keys()) {
+ d.setValue(ToContactDetailName(key), m_map->value(key));
+ }
+ return d;
+}
+
+void QMLContactDetail::detailChanged(const QString &key, const QVariant &value)
+{
+ qWarning() << "detailChanged field:" << key << " value:" << value;
+ m_contactChanged = true;
+}
diff --git a/examples/qmlcontacts/qmlcontactdetail.h b/examples/qmlcontacts/qmlcontactdetail.h
new file mode 100644
index 0000000000..f902a9d2e8
--- /dev/null
+++ b/examples/qmlcontacts/qmlcontactdetail.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLCONTACTDETAIL_H
+#define QMLCONTACTDETAIL_H
+
+#include <QDeclarativePropertyMap>
+#include "qcontact.h"
+#include "qcontactdetail.h"
+
+QTM_USE_NAMESPACE;
+
+class QMLContactDetail : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
+
+ explicit QMLContactDetail(QObject* parent = 0);
+ void setDetailPropertyMap(QDeclarativePropertyMap* map);
+ QDeclarativePropertyMap* propertyMap() const;
+ Q_INVOKABLE QList<QObject*> fields() const;
+ Q_INVOKABLE bool isDetailChanged() const;
+ QContactDetail detail() const;
+ QString name() const;
+ void setName(const QString& name);
+
+signals:
+ void nameChanged();
+private slots:
+ void detailChanged(const QString &key, const QVariant &value);
+
+private:
+ bool m_contactChanged;
+ QDeclarativePropertyMap* m_map;
+ QString m_detailName;
+ QList<QObject*> m_fields;
+};
+
+#endif // QMLCONTACTDETAIL_H
diff --git a/examples/qmlcontacts/main.cpp b/examples/qmlcontacts/qmlcontactdetailfield.cpp
index 7c133e9336..8df78fa923 100644
--- a/examples/qmlcontacts/main.cpp
+++ b/examples/qmlcontacts/qmlcontactdetailfield.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -38,38 +38,44 @@
**
****************************************************************************/
-#include <QApplication>
-#include <QtGui>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <QDeclarativeView>
-#include <qcontactmanager.h>
-#include "qmlcontactmodel.h"
-QT_USE_NAMESPACE
-QTM_USE_NAMESPACE
+#include "qmlcontactdetailfield.h"
+#include <QDebug>
-int main(int argc, char ** argv)
+QMLContactDetailField::QMLContactDetailField(QObject* parent)
+ :QObject(parent),
+ m_map(0)
{
- QApplication app(argc, argv);
+}
- QDeclarativeEngine engine;
+void QMLContactDetailField::setDetailPropertyMap(QDeclarativePropertyMap* map)
+{
+ m_map = map;
+}
- qmlRegisterType<QMLContactModel>("QmlContactModel", 1, 0, "QmlContactModel");
+void QMLContactDetailField::setKey(const QString& key)
+{
+ m_key = key;
+}
- QWidget *b = new QWidget();
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->setMargin(0);
+QString QMLContactDetailField::key() const
+{
+ return m_key;
+}
- QDeclarativeView *view = new QDeclarativeView(b);
- view->setFocusPolicy(Qt::StrongFocus);
- view->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- view->setSource(QUrl("qrc:/example.qml"));
- vbox->addWidget(view);
- b->setLayout(vbox);
- b->show();
+QVariant QMLContactDetailField::value() const
+{
+ if (m_map) {
+ qWarning() << "key:" << m_key << "value:" << m_map->value(m_key);
+ return m_map->value(m_key);
+ }
+ return QVariant();
+}
- return app.exec();
+void QMLContactDetailField::setValue(const QVariant& value)
+{
+ if (m_map && m_map->contains(m_key)) {
+ (*m_map)[m_key] = value;
+ }
}
diff --git a/examples/qmlcontacts/qmlcontactdetailfield.h b/examples/qmlcontacts/qmlcontactdetailfield.h
new file mode 100644
index 0000000000..bf4cc81e30
--- /dev/null
+++ b/examples/qmlcontacts/qmlcontactdetailfield.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLCONTACTDETAILFIELD_H
+#define QMLCONTACTDETAILFIELD_H
+
+#include <QDeclarativePropertyMap>
+
+
+
+class QMLContactDetailField : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(QString key READ key NOTIFY keyChanged)
+ Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+ QMLContactDetailField(QObject* parent = 0);
+
+ void setDetailPropertyMap(QDeclarativePropertyMap* map);
+
+ void setKey(const QString& key);
+ QString key() const;
+
+ QVariant value() const;
+ void setValue(const QVariant& value);
+signals:
+ void keyChanged();
+ void valueChanged();
+private:
+ QDeclarativePropertyMap* m_map;
+ QString m_key;
+};
+
+
+#endif // QMLCONTACTDETAILFIELD_H
diff --git a/examples/qmlcontacts/qmlcontactmodel.cpp b/examples/qmlcontacts/qmlcontactmodel.cpp
index 4927dc6fd6..ad36200da8 100644
--- a/examples/qmlcontacts/qmlcontactmodel.cpp
+++ b/examples/qmlcontacts/qmlcontactmodel.cpp
@@ -45,13 +45,13 @@
#include "qcontactdetailfilter.h"
#include "qversitreader.h"
#include "qversitcontactimporter.h"
-
#include <QColor>
#include <QHash>
#include <QDebug>
#include <QPixmap>
#include <QFile>
+
QMLContactModel::QMLContactModel(QObject *parent) :
QAbstractListModel(parent),
m_manager(0)
@@ -60,6 +60,8 @@ QMLContactModel::QMLContactModel(QObject *parent) :
roleNames = QAbstractItemModel::roleNames();
roleNames.insert(InterestLabelRole, "interestLabel");
roleNames.insert(InterestRole, "interest");
+ roleNames.insert(ContactRole, "contact");
+ roleNames.insert(ContactIdRole, "contactId");
roleNames.insert(AvatarRole, "avatar");
roleNames.insert(PresenceAvailableRole, "presenceSupported");
roleNames.insert(PresenceTextRole, "presenceText");
@@ -97,15 +99,33 @@ QStringList QMLContactModel::availableManagers() const
return QContactManager::availableManagers();
}
-QString QMLContactModel::manager()
+QString QMLContactModel::manager() const
{
return m_manager->managerName();
}
+QList<QObject*> QMLContactModel::details(int id) const
+{
+ if (m_contactMap.contains(id))
+ return m_contactMap.value(id)->details();
+ return QList<QObject*>();
+}
+void QMLContactModel::exposeContactsToQML()
+{
+ foreach (const QContact& c, m_contacts) {
+ if (!m_contactMap.contains(c.localId())) {
+ QMLContact* qc = new QMLContact(this);
+ qc->setContact(c);
+ m_contactMap.insert(c.localId(), qc);
+ } else {
+ m_contactMap.value(c.localId())->setContact(c);
+ }
+ }
+}
void QMLContactModel::fillContactsIntoMemoryEngine(QContactManager* manager)
{
QVersitReader reader;
- QFile file(":/contents/example.vcf");
+ QFile file("contents/example.vcf");
bool ok = file.open(QIODevice::ReadOnly);
if (ok) {
reader.setDevice(&file);
@@ -126,7 +146,14 @@ int QMLContactModel::rowCount(const QModelIndex &parent) const
void QMLContactModel::setManager(const QString& managerName)
{
- delete m_manager;
+ if (m_manager)
+ delete m_manager;
+
+ foreach (const QContactLocalId& id, m_contactMap.keys()) {
+ delete m_contactMap.value(id);
+ }
+ m_contactMap.clear();
+
m_manager = new QContactManager(managerName);
if (managerName == "memory" && m_manager->contactIds().isEmpty()) {
@@ -142,6 +169,7 @@ void QMLContactModel::setManager(const QString& managerName)
void QMLContactModel::resultsReceived()
{
int oldCount = m_contacts.count();
+
int newCount = m_contactsRequest.contacts().count();
if (newCount > oldCount) {
// Assuming the order is the same
@@ -155,6 +183,8 @@ void QMLContactModel::resultsReceived()
m_contacts = m_contactsRequest.contacts();
endInsertRows();
}
+
+ exposeContactsToQML();
}
void QMLContactModel::fetchAgain()
@@ -184,6 +214,8 @@ QPair<QString, QString> QMLContactModel::interestingDetail(const QContact&c) con
return qMakePair(QString(), QString());
}
+
+
QVariant QMLContactModel::data(const QModelIndex &index, int role) const
{
QContact c = m_contacts.value(index.row());
@@ -194,17 +226,15 @@ QVariant QMLContactModel::data(const QModelIndex &index, int role) const
return interestingDetail(c).first;
case InterestRole:
return interestingDetail(c).second;
+ case ContactRole:
+ if (m_contactMap.contains(c.localId())) {
+ return m_contactMap.value(c.localId())->contactMap();
+ }
+ case ContactIdRole:
+ return c.localId();
case AvatarRole:
- if (c.detail<QContactThumbnail>().isEmpty()) {
- QContactAvatar a = c.detail<QContactAvatar>();
- if (!a.imageUrl().isEmpty())
- return a.imageUrl();
- else
- return QString("qrc:/default.svg");
- } else {
- // We have a thumbnail, so return empty
- return QString("");
- }
+ //Just let the imager provider deal with it
+ return QString("image://thumbnail/%1.%2").arg(manager()).arg(c.localId());
case Qt::DecorationRole:
{
QContactThumbnail t = c.detail<QContactThumbnail>();
diff --git a/examples/qmlcontacts/qmlcontactmodel.h b/examples/qmlcontacts/qmlcontactmodel.h
index c91625c09d..506d6a7699 100644
--- a/examples/qmlcontacts/qmlcontactmodel.h
+++ b/examples/qmlcontacts/qmlcontactmodel.h
@@ -42,9 +42,11 @@
#define QMLCONTACTMODEL_H
#include <QAbstractListModel>
+#include <QDeclarativePropertyMap>
#include "qcontact.h"
#include "qcontactmanager.h"
#include "qcontactfetchrequest.h"
+#include "qmlcontact.h"
QTM_USE_NAMESPACE;
class QMLContactModel : public QAbstractListModel
@@ -58,6 +60,9 @@ public:
enum {
InterestRole = Qt::UserRole + 500,
InterestLabelRole,
+ ContactRole,
+ ContactIdRole,
+ DetailsRole,
AvatarRole,
PresenceAvailableRole,
PresenceTextRole,
@@ -67,11 +72,13 @@ public:
QStringList availableManagers() const;
- QString manager();
+ QString manager() const;
void setManager(const QString& manager);
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
+
+ Q_INVOKABLE QList<QObject*> details(int id) const;
signals:
public slots:
@@ -82,9 +89,11 @@ private slots:
private:
QPair<QString, QString> interestingDetail(const QContact&c) const;
-
+ void exposeContactsToQML();
void fillContactsIntoMemoryEngine(QContactManager* manager);
+
+ QMap<QContactLocalId, QMLContact*> m_contactMap;
QList<QContact> m_contacts;
QContactManager* m_manager;
QContactFetchHint m_fetchHint;
diff --git a/examples/qmlcontacts/qmlcontacts.pro b/examples/qmlcontacts/qmlcontacts.pro
index 74d495d0cd..f1567fae7c 100644
--- a/examples/qmlcontacts/qmlcontacts.pro
+++ b/examples/qmlcontacts/qmlcontacts.pro
@@ -1,8 +1,14 @@
-TEMPLATE = app
-TARGET = qmlcontacts
-CONFIG += mobility
+TEMPLATE = lib
+DESTDIR = com/nokia/mobility
+TARGET = qcontactqmlplugin
+
+CONFIG += qt plugin mobility
+QT += declarative
+
MOBILITY = contacts \
versit
+
+
DEPENDPATH += .
INCLUDEPATH += . \
../../include \
@@ -11,20 +17,34 @@ INCLUDEPATH += . \
../../src/contacts/details \
../../src/contacts/filters \
../../src/versit
-QT += declarative
-QT += script
# Input
-SOURCES += main.cpp \
- qmlcontactmodel.cpp
+HEADERS += qmlcontactmodel.h \
+ imageprovider.h \
+ qmlcontact.h \
+ qmlcontactdetail.h \
+ qmlcontactdetailfield.h
-HEADERS += qmlcontactmodel.h
+SOURCES += plugin.cpp \
+ qmlcontactmodel.cpp \
+ imageprovider.cpp \
+ qmlcontact.cpp \
+ qmlcontactdetail.cpp \
+ qmlcontactdetailfield.cpp
-RESOURCES += qmlcontacts.qrc
OTHER_FILES += example.qml \
contents/example.vcf \
contents/MediaButton.qml \
- ScrollBar.qml
-symbian::TARGET.CAPABILITY = ReadUserData \
- WriteUserData
+ ScrollBar.qml \
+ com/nokia/mobility/qmldir
+
+symbian:{
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY = ReadUserData \
+ WriteUserData \
+ ReadDeviceData \
+ WriteDeviceData \
+ SwEvent
+}
+
include(../examples.pri)
diff --git a/examples/qmlcontacts/qmlcontacts.qrc b/examples/qmlcontacts/qmlcontacts.qrc
deleted file mode 100644
index edab4f43c7..0000000000
--- a/examples/qmlcontacts/qmlcontacts.qrc
+++ /dev/null
@@ -1,11 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>example.qml</file>
- <file>contents/MediaButton.qml</file>
- <file>ScrollBar.qml</file>
- <file>contents/example.vcf</file>
- <file alias="default.svg">contents/default.svg</file>
- <file>contents/pics/button-pressed.png</file>
- <file>contents/pics/button.png</file>
- </qresource>
-</RCC>
diff --git a/examples/satellitedialog/satellitedialog.cpp b/examples/satellitedialog/satellitedialog.cpp
index 8cd0e30d72..9a52c7db7c 100644
--- a/examples/satellitedialog/satellitedialog.cpp
+++ b/examples/satellitedialog/satellitedialog.cpp
@@ -366,7 +366,7 @@ SatelliteDialog::SatelliteDialog(QWidget *parent,
mainLayout->addWidget(titleLabel);
mainLayout->addWidget(satelliteWidget);
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
QAction *switchAction = new QAction(tr("Switch"), this);
switchAction->setSoftKeyRole(QAction::PositiveSoftKey);
diff --git a/examples/sensors/orientation/main.cpp b/examples/sensors/orientation/main.cpp
index 2c5bd6537a..7bf4741b93 100644
--- a/examples/sensors/orientation/main.cpp
+++ b/examples/sensors/orientation/main.cpp
@@ -46,14 +46,6 @@
QTM_USE_NAMESPACE
-QML_DECLARE_TYPE(QOrientationSensor)
-
-QML_DECLARE_TYPE(QSensorReading)
-
-QML_DECLARE_TYPE(QOrientationReading)
-//### while we don't want to explicitly create this type in QML, we need to define it so
-// we can specify enum values like OrientationReading.LeftUp
-
class MainWidget : public QWidget
{
Q_OBJECT
@@ -80,9 +72,6 @@ MainWidget::MainWidget()
int main(int argc, char *argv[])
{
- qmlRegisterType<QOrientationReading>("Qt", 4, 6, "OrientationReading");
- qmlRegisterType<QOrientationSensor>("Qt", 4, 6, "OrientationSensor");
-
QApplication app(argc, argv);
MainWidget mainWidget;
diff --git a/examples/sensors/orientation/orientation.qml b/examples/sensors/orientation/orientation.qml
index 54faca3765..9f11d89648 100644
--- a/examples/sensors/orientation/orientation.qml
+++ b/examples/sensors/orientation/orientation.qml
@@ -38,7 +38,8 @@
**
****************************************************************************/
-import Qt 4.6
+import Qt 4.7
+import QtMobility.sensors 1.0
Rectangle {
width: 800
@@ -69,7 +70,6 @@ Rectangle {
Item {
id: content
- transformOrigin: Item.Center
anchors.centerIn: parent
Text {
id: text
@@ -122,9 +122,8 @@ Rectangle {
]
transitions: Transition {
- NumberAnimation { matchProperties: "rotation"; easing: "InOutQuad"; duration: 400 }
+ NumberAnimation { properties: "rotation"; easing.type: Easing.OutBounce; duration: 400 }
}
}
-
-
}
+
diff --git a/examples/sensors/small_screen_sensors/small_screen_sensors.pro b/examples/sensors/small_screen_sensors/small_screen_sensors.pro
index f13a3c0c27..feadc6f965 100644
--- a/examples/sensors/small_screen_sensors/small_screen_sensors.pro
+++ b/examples/sensors/small_screen_sensors/small_screen_sensors.pro
@@ -1,4 +1,4 @@
-TARGET = SmallSensors
+TARGET = smallsensors
TEMPLATE = app
include(../../examples.pri)
diff --git a/examples/servicebrowser/servicebrowser.cpp b/examples/servicebrowser/servicebrowser.cpp
index a8836c7c62..8c876159da 100644
--- a/examples/servicebrowser/servicebrowser.cpp
+++ b/examples/servicebrowser/servicebrowser.cpp
@@ -192,7 +192,7 @@ void ServiceBrowser::registerExampleServices()
QStringList exampleXmlFiles;
exampleXmlFiles << "filemanagerservice.xml" << "bluetoothtransferservice.xml";
foreach (const QString &fileName, exampleXmlFiles) {
- QString path = QCoreApplication::applicationDirPath() + "/xmldata/" + fileName;
+ const QString path = QCoreApplication::applicationDirPath() + "/xmldata/" + fileName;
serviceManager->addService(path);
}
}
diff --git a/examples/servicebrowser/servicebrowser.pro b/examples/servicebrowser/servicebrowser.pro
index bf199d10d4..b03447246f 100644
--- a/examples/servicebrowser/servicebrowser.pro
+++ b/examples/servicebrowser/servicebrowser.pro
@@ -14,6 +14,8 @@ SOURCES += servicebrowser.cpp \
CONFIG += mobility
MOBILITY = serviceframework
+mac:CONFIG -= app_bundle
+
symbian {
addFiles.sources = ../filemanagerplugin/filemanagerservice.xml
addFiles.sources += ../bluetoothtransferplugin/bluetoothtransferservice.xml
diff --git a/examples/sfw-notes/sfw-notes.pro b/examples/sfw-notes/sfw-notes.pro
index 359f663559..4513a64bc8 100644
--- a/examples/sfw-notes/sfw-notes.pro
+++ b/examples/sfw-notes/sfw-notes.pro
@@ -30,6 +30,8 @@ unix: {
}
}
+mac:CONFIG -= app_bundle
+
symbian {
#addFiles.sources = ../../notesmanagerplugin/notesmanagerservice.xml
#addFiles.path = xmldata
diff --git a/examples/sfw-notes/sfwnotes.cpp b/examples/sfw-notes/sfwnotes.cpp
index 1bd4c0edf0..4081237efb 100644
--- a/examples/sfw-notes/sfwnotes.cpp
+++ b/examples/sfw-notes/sfwnotes.cpp
@@ -116,7 +116,7 @@ void ToDoTool::registerExampleServices()
QStringList exampleXmlFiles;
exampleXmlFiles << "notesmanagerservice.xml";
foreach (const QString &fileName, exampleXmlFiles) {
- QString path = QCoreApplication::applicationDirPath() + "/xmldata/" + fileName;
+ const QString path = QCoreApplication::applicationDirPath() + "/xmldata/" + fileName;
serviceManager->addService(path);
}
}
diff --git a/examples/sysinfo/sysinfo.pro b/examples/sysinfo/sysinfo.pro
index 5ca26c8e0d..e50fd2048f 100644
--- a/examples/sysinfo/sysinfo.pro
+++ b/examples/sysinfo/sysinfo.pro
@@ -1,6 +1,6 @@
QT += network
-TARGET = sysinfo
+TARGET = qsysinfo
TEMPLATE = app
diff --git a/examples/weatherinfo/weatherinfo.cpp b/examples/weatherinfo/weatherinfo.cpp
index e26f246ffc..407b00a2bf 100644
--- a/examples/weatherinfo/weatherinfo.cpp
+++ b/examples/weatherinfo/weatherinfo.cpp
@@ -103,7 +103,7 @@ public:
QAction *your = new QAction("Your weather", this);
connect(your, SIGNAL(triggered()), SLOT(yourWeather()));
addAction(your);
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
menuBar()->addAction(your);
#endif
@@ -117,7 +117,7 @@ public:
QAction *action = new QAction(cities[i], this);
connect(action, SIGNAL(triggered()), SLOT(chooseCity()));
addAction(action);
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
menuBar()->addAction(action);
#endif
}
@@ -669,7 +669,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
WeatherInfo w;
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
w.showMaximized();
#else
w.resize(520, 288);
diff --git a/examples/writemessage/messagesender.h b/examples/writemessage/messagesender.h
index 668de0126a..39d45ad947 100644
--- a/examples/writemessage/messagesender.h
+++ b/examples/writemessage/messagesender.h
@@ -41,7 +41,7 @@
#ifndef MESSAGESENDER_H
#define MESSAGESENDER_H
-#include "qtmessaging.h"
+#include "qmessageservice.h"
#include <QMap>
#include <QWidget>