Пример #1
0
void AssetRatingsJob::Private::parseRatings(const QVariantMap &result)
{
    QVariantList ratingsList = result[QLatin1String("ratings")].toList();
    QVariantList::const_iterator itr;
    for (itr = ratingsList.constBegin(); itr != ratingsList.constEnd(); ++itr) {
        AssetRatings info;
        QVariantMap attribute = itr->toMap();
        info.attributeId = attribute[QLatin1String("attribute")].toString();
        info.attributeName = attribute[QLatin1String("attributename")].toString();
        info.personId = attribute[QLatin1String("person")].toString();
        info.personName = attribute[QLatin1String("name")].toString();
        info.rated = QDateTime::fromTime_t(attribute[QLatin1String("rated")].toLongLong());
        QVariantList l = attribute[QLatin1String("ratings")].toList();
        QVariantList::const_iterator it;
        for (it = l.constBegin(); it != l.constEnd(); ++it) {
            Rating r;
            QVariantMap data = it->toMap();
            r.attributeId = data[QLatin1String("attribute")].toString();
            r.attributeName = data[QLatin1String("name")].toString();
            r.rating = data[QLatin1String("rating")].toString();
            info.ratings.append(r);
        }
        ratings.append(info);
    }
}
Пример #2
0
void
RuleConditionNFC::setUidsQml(const QVariantList &uids) {
    QSet<QByteArray> uidsSet;
    for (QVariantList::const_iterator i = uids.constBegin(); i != uids.constEnd(); ++i) {
        uidsSet << QByteArray::fromHex(i->toByteArray());
    }
    setUids(uidsSet);
}
Пример #3
0
QString MailAddress::prettyList(const QVariantList &list, FormattingMode mode)
{
    QStringList buf;
    for (QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) {
        Q_ASSERT(it->type() == QVariant::StringList);
        QStringList item = it->toStringList();
        Q_ASSERT(item.size() == 4);
        MailAddress a(item[0], item[1], item[2], item[3]);
        buf << a.prettyName(mode);
    }
    return buf.join(QLatin1String(", "));
}
Пример #4
0
void SimpleClient::load(const QVariant& settings)
{
    const QVariantMap map = settings.toMap();

    if (map.contains("dialogs"))
    {
        const QVariantList list = map.value("dialogs").toList();

        for (QVariantList::const_iterator it = list.begin();
                it != list.end(); ++it)
        {
            const QVariantMap map = it->toMap();
            const QString operation = map["operation"].toString();

            if (!operation.isEmpty() && map.contains("value"))
            {
                // find the index
                unsigned int i = 0;
                const unsigned int count =
                    m_objref->interface()->operation_count();

                for (; i < count; i++)
                {
                    const char * current =
                            m_objref->interface()->get_reflective_by_index(
                                    i)->get_name();

                    if (operation == current) break;
                }

                // load its saved value
                if (i < count)
                {
                    getRequestDialog(i)->load(map.value("value"));
                }
            }
        }
    }

    if (map.contains("filtered_log"))
    {
        m_filteredLog->load(map["filtered_log"]);
    }

    if (map.contains("operations"))
    {
        // ensure created
        showOperationSequenceTool();

        m_seqTool->load(map["operations"]);
    }
}
Пример #5
0
void FilterModel::load(const QVariant& settings)
{
    const QVariantList list = settings.toList();

    for (QVariantList::const_iterator it = list.begin(); 
            it != list.end(); ++it) 
    {
        const QVariantMap map = it->toMap();

        if (!map.contains("instance") || !map.contains("operations"))
            continue;

        // Name to ID conversion
        const QString instance = map["instance"].toString();

        if (instance.isEmpty()) continue;

        Objref_ptr objref = m_instances.find(instance);

        if (!objref) continue;

        FirstLevelItems_t::iterator fit =  m_items.find(objref->id());

        if (fit == m_items.end()) continue;

        // End Name to ID conversion
        
        const QVariantMap operations = map["operations"].toMap();

        for (unsigned int j = 0; 
                j < objref->interface()->operation_count(); j++) 
        {
            OperationDescriptor_ptr op = 
                objref->interface()->get_reflective_by_index(j);
            tag_t tag = op->get_tag();

            OperationsMap_t::iterator opit = 
                fit.value().operations.find(tag);

            if(operations.contains(op->get_name()) && 
                    opit != fit.value().operations.end())
            {
                bool state = operations[op->get_name()].toBool();

                opit.value()->setCheckState((state)?
                        Qt::Checked: Qt::Unchecked);
            }
        }
    }
}
void ClientIrcListHelper::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels) {
  QVariantList::const_iterator iter = channels.constBegin();
  QVariantList::const_iterator iterEnd = channels.constEnd();

  QList<ChannelDescription> channelList;
  while(iter != iterEnd) {
    QVariantList channelVar = iter->toList();
    ChannelDescription channelDescription(channelVar[0].toString(), channelVar[1].toUInt(), channelVar[2].toString());
    channelList << channelDescription;
    iter++;
  }

  emit channelListReceived(netId, channelFilters, channelList);
}
Пример #7
0
QList<Notification> parseNotificationJson(const QVariantList &json)
{
    QList<Notification> item_list;

    for(QVariantList::const_iterator it = json.begin(); it != json.end(); ++it)
    {
        QVariantMap notification = it->toMap();
        Notification notif;
        notif.contentID = notification["contentId"].toString();
        notif.status = notification["status"].toString();
        item_list.append(notif);
    }

    return item_list;
}
Пример #8
0
QVariant QgsListWidgetWrapper::value() const
{
  QVariant::Type type = field().type();
  if ( !mWidget ) return QVariant( type );
  if ( type == QVariant::StringList )
  {
    QStringList result;
    const QVariantList list = mWidget->list();
    for ( QVariantList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
      result.append( it->toString() );
    return result;
  }
  else
    return QVariant( mWidget->list() );
}
Пример #9
0
void ChannelsJob::Private::parseChannels(const QVariantMap &result)
{
    QVariantList channelsLst = result[QLatin1String("channels")].toList();
    QVariantList::const_iterator itr;
    for (itr = channelsLst.constBegin(); itr != channelsLst.constEnd(); ++itr) {
        ChannelInfo info;
        QVariantMap channel = itr->toMap();
        info.id = channel[QLatin1String("id")].toString();
        info.name = channel[QLatin1String("name")].toString();
        info.description = channel[QLatin1String("description")].toString();
        info.images = q->session()->urlsForImage(
                          channel[QLatin1String("image")].toString());
        info.assetCount = channel[QLatin1String("assetcount")].toInt();
        channels.append(info);
    }
}
Пример #10
0
void collectionListAssetsJob::Private::parseAssets(const QVariantMap &result)
{
    QVariantList assetsLst = result[QLatin1String("assets")].toList();
    QVariantList::const_iterator itr;
    for (itr = assetsLst.constBegin(); itr != assetsLst.constEnd(); ++itr) {
        AssetInfo info;
        QVariantMap asset = itr->toMap();
        info.id = asset[QLatin1String("id")].toString();
        info.license = asset[QLatin1String("license")].toString();
        info.partnerId = asset[QLatin1String("partnerid")].toString();
        info.partnerName = asset[QLatin1String("partnername")].toString();
        info.name = asset[QLatin1String("name")].toString();
        info.version = asset[QLatin1String("version")].toString();
        info.images = q->session()->urlsForImage(
            asset[QLatin1String("image")].toString());
        info.description = asset[QLatin1String("description")].toString();
        info.points = asset[QLatin1String("points")].toInt();
        assets.append(info);
    }
}
Пример #11
0
void FSTReader::writeVariant(QBuffer& buffer, QVariantHash::const_iterator& it) {
    QByteArray key = it.key().toUtf8() + " = ";
    QVariantHash hashValue = it.value().toHash();
    if (hashValue.isEmpty()) {
        buffer.write(key + it.value().toByteArray() + "\n");
        return;
    }
    for (QVariantHash::const_iterator second = hashValue.constBegin(); second != hashValue.constEnd(); second++) {
        QByteArray extendedKey = key + second.key().toUtf8();
        QVariantList listValue = second.value().toList();
        if (listValue.isEmpty()) {
            buffer.write(extendedKey + " = " + second.value().toByteArray() + "\n");
            continue;
        }
        buffer.write(extendedKey);
        for (QVariantList::const_iterator third = listValue.constBegin(); third != listValue.constEnd(); third++) {
            buffer.write(" = " + third->toByteArray());
        }
        buffer.write("\n");
    }
}
Пример #12
0
QString QgsListFieldFormatter::representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const
{
  Q_UNUSED( layer );
  Q_UNUSED( fieldIndex );
  Q_UNUSED( config );
  Q_UNUSED( cache );

  if ( value.isNull() )
  {
    QSettings settings;
    return QgsApplication::nullRepresentation();
  }

  QString result;
  const QVariantList list = value.toList();
  for ( QVariantList::const_iterator i = list.constBegin(); i != list.constEnd(); ++i )
  {
    if ( !result.isEmpty() ) result.append( ", " );
    result.append( i->toString() );
  }
  return result;
}
Пример #13
0
QString QgsListWidgetFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const
{
  Q_UNUSED( vl );
  Q_UNUSED( fieldIdx );
  Q_UNUSED( config );
  Q_UNUSED( cache );

  if ( value.isNull() )
  {
    QSettings settings;
    return settings.value( "qgis/nullValue", "NULL" ).toString();
  }

  QString result;
  const QVariantList list = value.toList();
  for ( QVariantList::const_iterator i = list.constBegin(); i != list.constEnd(); ++i )
  {
    if ( !result.isEmpty() ) result.append( ", " );
    result.append( i->toString() );
  }
  return result;
}
Пример #14
0
QList<TitleInfo> parsePsnJson(const QVariantMap &json)
{
    QList<TitleInfo> item_list;

    bool ok = false;
    int total_results = json["total_results"].toInt(&ok);
    if(!ok) {
        return item_list;
    }

    qDebug() << "Total entitlements: " << total_results;
    QVariantList entitlements = json["entitlements"].toList();

    for(QVariantList::const_iterator it = entitlements.begin(); it != entitlements.end(); ++it)
    {
        QVariantMap entitlement = it->toMap();

        QString contentId;
        QString game_name;
        qlonglong package_size;
        QString package_url;
        ConsoleType console;
        int plus;

        if(entitlement["entitlement_type"].toInt() == 2) // PSP/PS3/VITA
        {
            contentId = entitlement["product_id"].toString();

            if(!entitlement.contains("drm_def"))
                continue;

            QMap<QString,QVariant> drm_def = entitlement["drm_def"].toMap();
            QVariantList drmContents = drm_def["drmContents"].toList();
            QMap<QString,QVariant> drmContent = drmContents[0].toMap();

            if(drm_def.contains("contentName"))
                game_name = drm_def["contentName"].toString();
            else
                game_name = drmContent["titleName"].toString();

            package_size = drmContent["contentSize"].toLongLong();
            package_url = drmContent["contentUrl"].toString();
            qlonglong platformIds = drmContent["platformIds"].toLongLong();
            plus = drmContent["gracePeriod"].toInt() > 0;

            switch(platformIds)
            {
            case 0x80000000: // ps3 game
            case 0x80800000: // ps3 addon
                console = PS3;
                break;
            case 0x08000000: // psm assistant and soul sacrifice demo
            case 0x88000000: // ps vita game
            case 0xFE100000:
                console = PSVITA;
                break;
            case 0xF8100000: // psp game
            case 0xF0100000: // demo
                console = PSP;
                break;
            default:
                console = UNKNOWN;
                break;
            }
        }
        else if(entitlement["entitlement_type"].toInt() == 5) // PS4
        {
            QMap<QString,QVariant> game_meta = entitlement["game_meta"].toMap();
            contentId = entitlement["product_id"].toString();
            game_name = game_meta["name"].toString();
            plus = entitlement.contains("inactive_date");
            QVariantList entitlement_attributes = entitlement["entitlement_attributes"].toList();
            QMap<QString,QVariant> entitlement_attribute = entitlement_attributes[0].toMap();
            package_size = entitlement_attribute["package_file_size"].toLongLong();
            package_url = entitlement_attribute["reference_package_url"].toString();
            console = PS4;
        }
        else // 1 or 3
        {
            continue;
        }

        TitleInfo item(contentId, game_name, package_size, package_url, console, plus);
        item_list << item;
    }

    qSort(item_list.begin(), item_list.end(), TitleInfo::lessThan);

    return item_list;
}