void Session::persistSession(const QString &sessionId, const QVariant &data) const { const QString &sessionFile = SessionPrivate::filePath(sessionId); const QVariantHash &hash = data.toHash(); if (hash.isEmpty()) { qCDebug(C_SESSION) << "Clearing session values on" << sessionFile; bool ret = QFile::remove(sessionFile); if (!ret) { QSettings settings(sessionFile, QSettings::IniFormat); settings.clear(); } } else { qCDebug(C_SESSION) << "Persisting session values to" << sessionFile; QSettings settings(sessionFile, QSettings::IniFormat); settings.beginGroup(QLatin1String("Data")); QVariantHash::ConstIterator it = hash.constBegin(); while (it != hash.constEnd()) { if (it.value().isNull()) { settings.remove(it.key()); } else { settings.setValue(it.key(), it.value()); } ++it; } settings.endGroup(); } }
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map) { arg.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>()); QVariantHash::ConstIterator it = map.constBegin(); QVariantHash::ConstIterator end = map.constEnd(); for ( ; it != end; ++it) { arg.beginMapEntry(); arg << it.key() << QDBusVariant(it.value()); arg.endMapEntry(); } arg.endMap(); return arg; }
QScriptValue MoreItemsRequest::toScriptValue( QScriptEngine *engine ) const { Q_ASSERT( m_request ); QScriptValue value = m_request->toScriptValue( engine ); QScriptValue data = engine->newObject(); for ( QVariantHash::ConstIterator it = m_requestData.constBegin(); it != m_requestData.constEnd(); ++it ) { data.setProperty( it.key(), engine->toScriptValue(it.value()) ); } value.setProperty( QLatin1String("requestData"), data ); //engine->toScriptValue(requestData) ); value.setProperty( QLatin1String("moreItemsDirection"), m_direction ); return value; }