Qt IVI Generator Addressbook Example

/**************************************************************************** ** Generated from 'Example.IVI.AddressBook.qface' ** ** Created by: The QFace generator (QtAS 5.12.8) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/
#include "addressbook.h" #include "addressbook_p.h" #include "addressbookbackendinterface.h" #include <QQmlEngine> #include <QIviServiceObject> #include <QIviProxyServiceObject> /*! \class AddressBook \inmodule Example.IVI.AddressBook */ /*! \qmltype UiAddressBook \instantiates AddressBook \inherits AbstractFeature */ /*! \internal */ AddressBookPrivate::AddressBookPrivate(const QString &interface, AddressBook *parent) : QIviAbstractFeaturePrivate(interface, parent) , q_ptr(parent) , m_contacts(nullptr) { m_supportsPropertyOverriding = true; } /*! \internal */ AddressBookPrivate *AddressBookPrivate::get(AddressBook *v) { return reinterpret_cast<AddressBookPrivate *>(v->d_ptr.data()); } /*! \internal */ const AddressBookPrivate *AddressBookPrivate::get(const AddressBook *v) { return reinterpret_cast<const AddressBookPrivate *>(v->d_ptr.data()); } /*! \internal */ AddressBook *AddressBookPrivate::getParent() { return q_ptr; } /*! \internal */ void AddressBookPrivate::clearToDefaults() { if (m_contacts) { delete m_contacts->serviceObject(); delete m_contacts; } m_contacts = nullptr; } /*! \internal */ void AddressBookPrivate::onContactsChanged(QIviPagingModelInterface *contacts) { QIviPagingModel * old = m_contacts; if (contacts) { auto model = new QIviPagingModel(); model->setServiceObject(new QIviProxyServiceObject({ {QIviPagingModel_iid, contacts } })); m_contacts = model; auto q = getParent(); emit q->contactsChanged(model); } else { m_contacts = nullptr; auto q = getParent(); emit q->contactsChanged(nullptr); } if (old) { delete old->serviceObject(); delete old; } } bool AddressBookPrivate::notify(const QByteArray &propertyName, const QVariant &value) { auto q = getParent(); if (propertyName == QByteArray("contacts")) { emit q->contactsChanged(value.value<QIviPagingModel *>()); return true; } return QIviAbstractFeaturePrivate::notify(propertyName, value); } /*! Default constructs an instance of AddressBook. */ AddressBook::AddressBook(QObject *parent) : QIviAbstractFeature(*new AddressBookPrivate(QLatin1String(AddressBook_AddressBook_iid), this), parent) { } /*! \internal */ AddressBook::~AddressBook() { } /*! \internal */ void AddressBook::registerQmlTypes(const QString& uri, int majorVersion, int minorVersion) { qmlRegisterType<AddressBook>(uri.toLatin1(), majorVersion, minorVersion, "UiAddressBook"); } /*! \property AddressBook::contacts */ /*! \qmlproperty QIviPagingModel * UiAddressBook::contacts */ QIviPagingModel * AddressBook::contacts() const { const auto d = AddressBookPrivate::get(this); if (Q_UNLIKELY(d->m_propertyOverride)) return d->m_propertyOverride->property(metaObject()->indexOfProperty("contacts")).value<QIviPagingModel *>(); return d->m_contacts; } /*! \qmlmethod UiAddressBook::insertContact(int index, const Contact &contact) */ /*! */ QIviPendingReply<void> AddressBook::insertContact(int index, const Contact &contact) { if (AddressBookBackendInterface *backend = addressbookBackend()) return backend->insertContact(index, contact); return QIviPendingReply<void>::createFailedReply(); } /*! \internal */ void AddressBook::connectToServiceObject(QIviServiceObject *serviceObject) { auto d = AddressBookPrivate::get(this); auto *backend = addressbookBackend(); if (!backend) return; QObjectPrivate::connect(backend, &AddressBookBackendInterface::contactsChanged, d, &AddressBookPrivate::onContactsChanged); QIviAbstractFeature::connectToServiceObject(serviceObject); } /*! \internal */ void AddressBook::clearServiceObject() { auto d = AddressBookPrivate::get(this); d->clearToDefaults(); } /*! \internal */ AddressBookBackendInterface *AddressBook::addressbookBackend() const { if (QIviServiceObject *so = serviceObject()) return so->interfaceInstance<AddressBookBackendInterface*>(interfaceName()); return nullptr; } #include "moc_addressbook.cpp"