/*! \reimp */ void IdentifiableContentItemInterface::emitPropertyChangeSignals(const QVariantMap &oldData, const QVariantMap &newData) { Q_D(IdentifiableContentItemInterface); // most derived types will do: // { // foreach (key, propKeys) { // if (newData.value(key) != oldData.value(key)) { // emit thatPropertyChanged(); // } // } // SuperClass::emitPropertyChangeSignals(oldData, newData); // } // But this one is a bit special, since if the id changed, it's a terrible error. // check identifier - NOTE: derived types MUST fill out this field before calling this class' implementation of emitPropertyChangeSignals. QString oldId = oldData.value(NEMOQMLPLUGINS_SOCIAL_CONTENTITEMID).toString(); QString newId = newData.value(NEMOQMLPLUGINS_SOCIAL_CONTENTITEMID).toString(); if (newId.isEmpty() && oldId.isEmpty()) { // this will fall through to being reported as an error due to identifier change (to empty) below. qWarning() << Q_FUNC_INFO << "ERROR: derived types MUST set the NEMOQMLPLUGINS_SOCIAL_CONTENTITEMID field appropriately prior to calling the superclass emitPropertyChangeSignals() function!"; } if (oldId.isEmpty()) oldId = d->identifier; // might have been set directly by client via icii.setIdentifier() which sets dd->identifier. if (oldId.isEmpty() && !newId.isEmpty()) { // this must be a new object created by the model. We now have an identifier; set it and update. d->identifier = newId; emit identifierChanged(); } else if (newId.isEmpty() || oldId != newId) { // the identifier changed. This shouldn't happen in real life. Must be an error. d->status = SocialNetworkInterface::Invalid; d->error = SocialNetworkInterface::DataUpdateError; d->errorMessage = QString(QLatin1String("identifier changed during data update from %1 to %2")).arg(oldId).arg(newId); d->s = 0; emit statusChanged(); emit errorChanged(); emit errorMessageChanged(); emit socialNetworkChanged(); } // finally, as all derived classes must do, call super class implementation. ContentItemInterface::emitPropertyChangeSignals(oldData, newData); }
void ContentItemInterface::setSocialNetwork(SocialNetworkInterface *socialNetwork) { Q_D(ContentItemInterface); if (d->isInitialized) { qWarning() << Q_FUNC_INFO << "Can't change social network after content item has been initialized!"; return; } if (d->socialNetworkInterface != socialNetwork) { if (d->socialNetworkInterface) disconnect(d->socialNetworkInterface); if (socialNetwork && !socialNetwork->isInitialized()) { connect(socialNetwork, SIGNAL(initializedChanged()), this, SLOT(socialNetworkInitializedChangedHandler())); } d->socialNetworkInterface = socialNetwork; emit socialNetworkChanged(); } }