summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2010-06-25 10:35:24 +1000
committerMichael Goddard <michael.goddard@nokia.com>2010-06-25 10:35:24 +1000
commitfd576b411f0a56019f393130ac657bd9f6a5b701 (patch)
tree32803b3b89cfd0dc96f135ed370c06facad1c16f /examples
parentb2fb0b479eed0fd84f9cc7f900ad9c92d25ca1fd (diff)
parent27a9a996375a635dc08bfcda126032ab8cffe472 (diff)
Merge branch '1.0' of scm.dev.nokia.troll.no:qtmobility/qtm-contacts into main1.0
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/qmlcontacts/com/nokia/mobility/qmldir1
-rw-r--r--examples/qmlcontacts/contacts.qml (renamed from examples/qmlcontacts/example.qml)8
-rw-r--r--examples/qmlcontacts/contents/ScrollBar.qml (renamed from examples/qmlcontacts/ScrollBar.qml)0
-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.cpp81
-rw-r--r--examples/qmlcontacts/qmlcontactdetailfield.h72
-rw-r--r--examples/qmlcontacts/qmlcontactmodel.cpp256
-rw-r--r--examples/qmlcontacts/qmlcontactmodel.h104
-rw-r--r--examples/qmlcontacts/qmlcontacts.pro50
-rw-r--r--examples/qmlcontacts/qmlcontacts.qmlproject16
17 files changed, 23 insertions, 1199 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index fa4fc2f601..edbd0db7f8 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -43,7 +43,7 @@ contains(mobility_modules,location) {
contains(mobility_modules,contacts) {
SUBDIRS += samplephonebook
contains(mobility_modules,versit):contains(QT_CONFIG, declarative) {
- SUBDIRS += qmlcontacts
+ sources.files += qmlcontacts
}
}
diff --git a/examples/qmlcontacts/com/nokia/mobility/qmldir b/examples/qmlcontacts/com/nokia/mobility/qmldir
deleted file mode 100644
index 7443f071c8..0000000000
--- a/examples/qmlcontacts/com/nokia/mobility/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-plugin qcontactqmlplugin
diff --git a/examples/qmlcontacts/example.qml b/examples/qmlcontacts/contacts.qml
index 6db131fc25..d6cafdf38b 100644
--- a/examples/qmlcontacts/example.qml
+++ b/examples/qmlcontacts/contacts.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import Qt 4.7
-import com.nokia.mobility 1.0
+import QtMobility.contacts 1.0
import "contents"
Rectangle {
@@ -54,10 +54,14 @@ Rectangle {
QmlContactModel {
id: contactModel
manager: "memory"
+ Component.onCompleted : {
+ contactModel.importContacts("contents/example.vcf");
+ }
}
Component {
- id: listdelegate
+ id: listdelegate
+
Rectangle {
id: wrapper
border.width: 2
diff --git a/examples/qmlcontacts/ScrollBar.qml b/examples/qmlcontacts/contents/ScrollBar.qml
index 1858059bb1..1858059bb1 100644
--- a/examples/qmlcontacts/ScrollBar.qml
+++ b/examples/qmlcontacts/contents/ScrollBar.qml
diff --git a/examples/qmlcontacts/imageprovider.cpp b/examples/qmlcontacts/imageprovider.cpp
deleted file mode 100644
index 1712df97dc..0000000000
--- a/examples/qmlcontacts/imageprovider.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index be6418986f..0000000000
--- a/examples/qmlcontacts/imageprovider.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index d3c30c5fd6..0000000000
--- a/examples/qmlcontacts/plugin.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index 23c6118d60..0000000000
--- a/examples/qmlcontacts/qmlcontact.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index 1a2f82f651..0000000000
--- a/examples/qmlcontacts/qmlcontact.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index 238c1c923c..0000000000
--- a/examples/qmlcontacts/qmlcontactdetail.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index f902a9d2e8..0000000000
--- a/examples/qmlcontacts/qmlcontactdetail.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** 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/qmlcontactdetailfield.cpp b/examples/qmlcontacts/qmlcontactdetailfield.cpp
deleted file mode 100644
index 8df78fa923..0000000000
--- a/examples/qmlcontacts/qmlcontactdetailfield.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** 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 "qmlcontactdetailfield.h"
-#include <QDebug>
-
-QMLContactDetailField::QMLContactDetailField(QObject* parent)
- :QObject(parent),
- m_map(0)
-{
-
-}
-
-void QMLContactDetailField::setDetailPropertyMap(QDeclarativePropertyMap* map)
-{
- m_map = map;
-}
-
-void QMLContactDetailField::setKey(const QString& key)
-{
- m_key = key;
-}
-
-QString QMLContactDetailField::key() const
-{
- return m_key;
-}
-
-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();
-}
-
-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
deleted file mode 100644
index bf4cc81e30..0000000000
--- a/examples/qmlcontacts/qmlcontactdetailfield.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** 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
deleted file mode 100644
index ad36200da8..0000000000
--- a/examples/qmlcontacts/qmlcontactmodel.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/****************************************************************************
-**
-** 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 "qmlcontactmodel.h"
-#include "qcontactmanager.h"
-#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)
-{
- QHash<int, QByteArray> roleNames;
- 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");
- roleNames.insert(PresenceStateRole, "presenceState");
- roleNames.insert(PresenceMessageRole, "presenceMessage");
- setRoleNames(roleNames);
-
- m_fetchHint.setOptimizationHints(QContactFetchHint::NoActionPreferences | QContactFetchHint::NoRelationships);
- m_fetchHint.setDetailDefinitionsHint(QStringList()
- << QContactPhoneNumber::DefinitionName
- << QContactEmailAddress::DefinitionName
- << QContactThumbnail::DefinitionName
- << QContactAvatar::DefinitionName
- << QContactGlobalPresence::DefinitionName
- << QContactDisplayLabel::DefinitionName
- << QContactOnlineAccount::DefinitionName);
- m_sortOrder.setDetailDefinitionName(QContactDisplayLabel::DefinitionName, QContactDisplayLabel::FieldLabel);
- m_sortOrder.setCaseSensitivity(Qt::CaseSensitive);
-
- connect(&m_contactsRequest, SIGNAL(resultsAvailable()), this, SLOT(resultsReceived()));
- m_contactsRequest.setFetchHint(m_fetchHint);
- m_contactsRequest.setSorting(m_sortOrder);
-
- QContactDetailFilter d;
- d.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
- d.setValue(QContactType::TypeContact);
-
- m_contactsRequest.setFilter(d);
-
- setManager(QString());
-}
-
-QStringList QMLContactModel::availableManagers() const
-{
- return QContactManager::availableManagers();
-}
-
-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");
- bool ok = file.open(QIODevice::ReadOnly);
- if (ok) {
- reader.setDevice(&file);
- if (reader.startReading() && reader.waitForFinished()) {
- QVersitContactImporter importer;
- importer.importDocuments(reader.results());
- QList<QContact> contacts = importer.contacts();
- manager->saveContacts(&contacts, 0);
- }
- }
-}
-
-int QMLContactModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return m_contacts.count();
-}
-
-void QMLContactModel::setManager(const QString& managerName)
-{
- 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()) {
- fillContactsIntoMemoryEngine(m_manager);
- }
-
- qWarning() << "Changed backend to: " << managerName;
- m_contactsRequest.setManager(m_manager);
- connect(m_manager, SIGNAL(dataChanged()), this, SLOT(fetchAgain()));
- fetchAgain();
-}
-
-void QMLContactModel::resultsReceived()
-{
- int oldCount = m_contacts.count();
-
- int newCount = m_contactsRequest.contacts().count();
- if (newCount > oldCount) {
- // Assuming the order is the same
- beginInsertRows(QModelIndex(), newCount - oldCount, newCount);
- m_contacts = m_contactsRequest.contacts();
- endInsertRows();
- } else {
- // Hmm, shouldn't happen
- reset();
- beginInsertRows(QModelIndex(), 0, m_contactsRequest.contacts().count());
- m_contacts = m_contactsRequest.contacts();
- endInsertRows();
- }
-
- exposeContactsToQML();
-}
-
-void QMLContactModel::fetchAgain()
-{
- m_contacts.clear();
- reset();
- m_contactsRequest.start();
-}
-
-QPair<QString, QString> QMLContactModel::interestingDetail(const QContact&c) const
-{
- // Try a phone number, then email, then online account
- // This does only check the first detail of each type
- QContactDetail p = c.details<QContactPhoneNumber>().value(0);
- if (!p.isEmpty())
- return qMakePair(tr("Phone"), p.value(QContactPhoneNumber::FieldNumber));
-
- p = c.details<QContactEmailAddress>().value(0);
- if (!p.isEmpty())
- return qMakePair(tr("Email"), p.value(QContactEmailAddress::FieldEmailAddress));
-
- p = c.details<QContactOnlineAccount>().value(0);
- if (!p.isEmpty())
- return qMakePair(p.value(QContactOnlineAccount::FieldServiceProvider), p.value(QContactOnlineAccount::FieldAccountUri));
-
- // Well, don't know.
- return qMakePair(QString(), QString());
-}
-
-
-
-QVariant QMLContactModel::data(const QModelIndex &index, int role) const
-{
- QContact c = m_contacts.value(index.row());
- switch(role) {
- case Qt::DisplayRole:
- return c.displayLabel();
- case InterestLabelRole:
- 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:
- //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>();
- if (!t.thumbnail().isNull())
- return QPixmap::fromImage(t.thumbnail());
- }
- return QPixmap();
- case PresenceAvailableRole:
- return !c.detail<QContactGlobalPresence>().isEmpty();
- case PresenceMessageRole:
- return c.detail<QContactGlobalPresence>().customMessage();
- case PresenceTextRole:
- return c.detail<QContactGlobalPresence>().presenceStateText();
- case PresenceStateRole:
- return c.detail<QContactGlobalPresence>().presenceState();
- }
- return QVariant();
-}
-
diff --git a/examples/qmlcontacts/qmlcontactmodel.h b/examples/qmlcontacts/qmlcontactmodel.h
deleted file mode 100644
index 506d6a7699..0000000000
--- a/examples/qmlcontacts/qmlcontactmodel.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** 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 QMLCONTACTMODEL_H
-#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
-{
-Q_OBJECT
-Q_PROPERTY(QStringList availableManagers READ availableManagers)
-Q_PROPERTY(QString manager READ manager WRITE setManager)
-public:
- explicit QMLContactModel(QObject *parent = 0);
-
- enum {
- InterestRole = Qt::UserRole + 500,
- InterestLabelRole,
- ContactRole,
- ContactIdRole,
- DetailsRole,
- AvatarRole,
- PresenceAvailableRole,
- PresenceTextRole,
- PresenceStateRole,
- PresenceMessageRole
- };
-
- QStringList availableManagers() const;
-
- 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:
-
-private slots:
- void resultsReceived();
- void fetchAgain();
-
-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;
- QContactSortOrder m_sortOrder;
- QContactFetchRequest m_contactsRequest;
-};
-
-#endif // QMLCONTACTMODEL_H
diff --git a/examples/qmlcontacts/qmlcontacts.pro b/examples/qmlcontacts/qmlcontacts.pro
deleted file mode 100644
index f1567fae7c..0000000000
--- a/examples/qmlcontacts/qmlcontacts.pro
+++ /dev/null
@@ -1,50 +0,0 @@
-TEMPLATE = lib
-DESTDIR = com/nokia/mobility
-TARGET = qcontactqmlplugin
-
-CONFIG += qt plugin mobility
-QT += declarative
-
-MOBILITY = contacts \
- versit
-
-
-DEPENDPATH += .
-INCLUDEPATH += . \
- ../../include \
- ../../src/contacts \
- ../../src/contacts/requests \
- ../../src/contacts/details \
- ../../src/contacts/filters \
- ../../src/versit
-
-# Input
-HEADERS += qmlcontactmodel.h \
- imageprovider.h \
- qmlcontact.h \
- qmlcontactdetail.h \
- qmlcontactdetailfield.h
-
-SOURCES += plugin.cpp \
- qmlcontactmodel.cpp \
- imageprovider.cpp \
- qmlcontact.cpp \
- qmlcontactdetail.cpp \
- qmlcontactdetailfield.cpp
-
-OTHER_FILES += example.qml \
- contents/example.vcf \
- contents/MediaButton.qml \
- 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.qmlproject b/examples/qmlcontacts/qmlcontacts.qmlproject
new file mode 100644
index 0000000000..d4909f8685
--- /dev/null
+++ b/examples/qmlcontacts/qmlcontacts.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}