QPlace QPlaceManagerEngineJsonDb::compatiblePlace(const QPlace &original) const
{
    QPlace place;
    place.setName(original.name());

    QGeoLocation location = original.location();
    QGeoCoordinate coord = original.location().coordinate();
    coord.setAltitude(qQNaN());
    location.setCoordinate(coord);
    location.setBoundingBox(QGeoRectangle());
    place.setLocation(location);

    QList<QPlaceContactDetail> details;
    foreach (const QString &contactType, original.contactTypes())
        place.setContactDetails(contactType, original.contactDetails(contactType));

    place.setVisibility(QLocation::UnspecifiedVisibility);

    QStringList attributeTypes = original.extendedAttributeTypes();
    foreach (const QString &attributeType, attributeTypes)
        place.setExtendedAttribute(attributeType, original.extendedAttribute(attributeType));

    QString provider = original.extendedAttribute(QLatin1String("x_provider")).text();
    if (!provider.isEmpty()) {
        QPlaceAttribute alternativeId;
        alternativeId.setText(original.placeId());
        place.setExtendedAttribute(QString::fromLatin1("x_id_") + provider,
                                   alternativeId);

        if (provider == QLatin1String("nokia") || provider == QLatin1String("nokia_mos")) {
            QStringList nokiaCategoryIds;
            foreach (const QPlaceCategory &cat, original.categories()) {
                if (!cat.categoryId().isEmpty())
                    nokiaCategoryIds.append(cat.categoryId());
            }

            if (!nokiaCategoryIds.isEmpty()) {
                QPlaceAttribute nokiaCatIds;
                nokiaCatIds.setText(nokiaCategoryIds.join(QLatin1String(",")));
                place.setExtendedAttribute(QString::fromLatin1("x_nokia_category_ids"), nokiaCatIds);
            }
        }
예제 #2
0
/*!
    \qmlproperty QPlace Place::place

    For details on how to use this property to interface between C++ and QML see
    "\l {location-cpp-qml.html#place} {Interfaces between C++ and QML Code}".
*/
void QDeclarativePlace::setPlace(const QPlace &src)
{
    QPlace previous = m_src;
    m_src = src;

    if (previous.categories() != m_src.categories()) {
        synchronizeCategories();
        emit categoriesChanged();
    }

    if (m_location && m_location->parent() == this) {
        m_location->setLocation(m_src.location());
    } else if (!m_location || m_location->parent() != this) {
        m_location = new QDeclarativeGeoLocation(m_src.location(), this);
        emit locationChanged();
    }

    if (m_ratings && m_ratings->parent() == this) {
        m_ratings->setRatings(m_src.ratings());
    } else if (!m_ratings || m_ratings->parent() != this) {
        m_ratings = new QDeclarativeRatings(m_src.ratings(), this);
        emit ratingsChanged();
    }

    if (m_supplier && m_supplier->parent() == this) {
        m_supplier->setSupplier(m_src.supplier(), m_plugin);
    } else if (!m_supplier || m_supplier->parent() != this) {
        m_supplier = new QDeclarativeSupplier(m_src.supplier(), m_plugin, this);
        emit supplierChanged();
    }

    if (m_icon && m_icon->parent() == this) {
        m_icon->setPlugin(m_plugin);
        m_icon->setIcon(m_src.icon());
    } else if (!m_icon || m_icon->parent() != this) {
        m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
        emit iconChanged();
    }

    if (previous.name() != m_src.name()) {
        emit nameChanged();
    }
    if (previous.placeId() != m_src.placeId()) {
        emit placeIdChanged();
    }
    if (previous.attribution() != m_src.attribution()) {
        emit attributionChanged();
    }
    if (previous.detailsFetched() != m_src.detailsFetched()) {
        emit detailsFetchedChanged();
    }
    if (previous.primaryPhone() != m_src.primaryPhone()) {
        emit primaryPhoneChanged();
    }
    if (previous.primaryFax() != m_src.primaryFax()) {
        emit primaryFaxChanged();
    }
    if (previous.primaryEmail() != m_src.primaryEmail()) {
        emit primaryEmailChanged();
    }
    if (previous.primaryWebsite() != m_src.primaryWebsite()) {
        emit primaryWebsiteChanged();
    }

    if (m_reviewModel && m_src.totalContentCount(QPlaceContent::ReviewType) >= 0) {
        m_reviewModel->initializeCollection(m_src.totalContentCount(QPlaceContent::ReviewType),
                                            m_src.content(QPlaceContent::ReviewType));
    }
    if (m_imageModel && m_src.totalContentCount(QPlaceContent::ImageType) >= 0) {
        m_imageModel->initializeCollection(m_src.totalContentCount(QPlaceContent::ImageType),
                                           m_src.content(QPlaceContent::ImageType));
    }
    if (m_editorialModel && m_src.totalContentCount(QPlaceContent::EditorialType) >= 0) {
        m_editorialModel->initializeCollection(m_src.totalContentCount(QPlaceContent::EditorialType),
                                               m_src.content(QPlaceContent::EditorialType));
    }

    synchronizeExtendedAttributes();
    synchronizeContacts();
}