void TasXmlWriter::openElement(const QString& name, QMap<QString,QString> attributes)
{
    mXmlStream << "<" << name << " ";

    QMap<QString, QString>::const_iterator i;

    for (i = attributes.constBegin(); i != attributes.constEnd(); ++i)
        mXmlStream << i.key() << "=\"" << i.value() << "\" ";
        
    mXmlStream << ">";
}
Example #2
0
QString QMacPasteboardMimeQt3Any::mimeFor(QString flav)
{
    loadMimeRegistry();
    const int os_flav = UTGetOSTypeFromString(UTTypeCopyPreferredTagWithClass(QCFString(flav), kUTTagClassOSType));
    for(QMap<QString, int>::const_iterator it = mime_registry.constBegin();
        it != mime_registry.constEnd(); ++it) {
        if(it.value() == os_flav)
            return QString::fromLatin1(it.key().toLatin1());
    }
    return QString();
}
//! populate two lists (ks, vs) from map - in reverse order
template <class Key, class T> void mapToReversedLists( const QMap< Key, T > &map, QList<Key> &ks, QList<T> &vs )
{
  ks.reserve( map.size() );
  vs.reserve( map.size() );
  typename QMap<Key, T>::const_iterator i = map.constEnd();
  while ( i-- != map.constBegin() )
  {
    ks.append( i.key() );
    vs.append( i.value() );
  }
}
Example #4
0
AlbumScanner::AlbumScanner(const QMap<int, QString> &files)
    : proc(0)
{
    QMap<int, QString>::ConstIterator it=files.constBegin();
    QMap<int, QString>::ConstIterator end=files.constEnd();

    for (int i=0; it!=end; ++it, ++i) {
        fileNames.append(it.value());
        trackIndexMap[i]=it.key();
    }
}
Example #5
0
int DocumentsHandler::setEntry(const Akonadi::Item &item, QString &newId, QString &errorMessage)
{
    if (!item.hasPayload<SugarDocument>()) {
        qCCritical(FATCRM_SUGARCRMRESOURCE_LOG) << "item (id=" << item.id() << ", remoteId=" << item.remoteId()
                 << ", mime=" << item.mimeType() << ") is missing Document payload";
        return SugarJob::InvalidContextError;
    }

    QList<KDSoapGenerated::TNS__Name_value> itemList;

    // if there is an id add it, otherwise skip this field
    // no id will result in the email being added
    if (!item.remoteId().isEmpty()) {
        KDSoapGenerated::TNS__Name_value field;
        field.setName(QStringLiteral("id"));
        field.setValue(item.remoteId());

        itemList << field;
    }

    const SugarDocument document = item.payload<SugarDocument>();
    const SugarDocument::AccessorHash accessors = SugarDocument::accessorHash();
    SugarDocument::AccessorHash::const_iterator it    = accessors.constBegin();
    SugarDocument::AccessorHash::const_iterator endIt = accessors.constEnd();
    for (; it != endIt; ++it) {
        // check if this is a read-only field
        if (it.key() == QLatin1String("id")) {
            continue;
        }

        const SugarDocument::valueGetter getter = (*it).getter;
        KDSoapGenerated::TNS__Name_value field;
        field.setName(sugarFieldFromCrmField(it.key()));
        field.setValue(KDCRMUtils::encodeXML((document.*getter)()));

        itemList << field;
    }

    // plus custom fields
    QMap<QString, QString> customFields = document.customFields();
    QMap<QString, QString>::const_iterator cit = customFields.constBegin();
    const QMap<QString, QString>::const_iterator end = customFields.constEnd();
    for ( ; cit != end ; ++cit ) {
        KDSoapGenerated::TNS__Name_value field;
        field.setName(customSugarFieldFromCrmField(cit.key()));
        field.setValue(KDCRMUtils::encodeXML(cit.value()));
        itemList << field;
    }

    KDSoapGenerated::TNS__Name_value_list valueList;
    valueList.setItems(itemList);

    return mSession->protocol()->setEntry(module(), valueList, newId, errorMessage);
}
Example #6
0
static void printOptions(QTextStream& s, const QMap<QString, QString>& options) {
    QMap<QString, QString>::const_iterator it = options.constBegin();
    s.setFieldAlignment(QTextStream::AlignLeft);
    for (; it != options.constEnd(); ++it) {
        s << "  --";
        s.setFieldWidth(38);
        s << it.key() << it.value();
        s.setFieldWidth(0);
        s << endl;
    }
}
Example #7
0
void SubpanelDesignDialog::loadProcessingSystems()
{
	ui->base_panel->addItem("<select>");

	QMap<QString, QString> systems = NGSD().getProcessingSystems(true, true);
	auto it = systems.constBegin();
	while (it != systems.constEnd())
	{
		ui->base_panel->addItem(it.key(), it.value());
		++it;
	}
}
Example #8
0
void ThesaurusDatabaseType::saveUser(){
	if (userFileName.isEmpty() || userWords.isEmpty()) return;
	QFile f(userFileName);
	if (!f.open(QFile::WriteOnly)) return;
	QTextStream s(&f);
	s.setCodec(QTextCodec::codecForMib(MIB_UTF8));
	for (QMap<QString, QStringList>::const_iterator it = userWords.constBegin(), end = userWords.constEnd(); it != end; ++it ) {
		if (it.value().size() < 2) continue;
		s << it.value().join("|") << "\n";
	}
	//userFileName.clear(); why was it there? save only once?
}
Example #9
0
void ArchiveOrg::slotShowResults(KJob* job)
{
    if (job->error() != 0 ) return;
    m_listWidget->blockSignals(true);
    KIO::StoredTransferJob* storedQueryJob = static_cast<KIO::StoredTransferJob*>( job );
    QJsonParseError jsonError;
    QJsonDocument doc = QJsonDocument::fromJson(storedQueryJob->data(), &jsonError);
    if (jsonError.error != QJsonParseError::NoError) {
        // There was an error parsing data
        KMessageBox::sorry(m_listWidget, jsonError.errorString(), i18n("Error Loading Data"));
    }
    QVariant data = doc.toVariant();
    
    QVariant sounds;
    if (data.canConvert(QVariant::Map)) {
        QMap <QString, QVariant> map = data.toMap();
        QMap<QString, QVariant>::const_iterator i = map.constBegin();
        while (i != map.constEnd()) {
            if (i.key() == QLatin1String("response")) {
                sounds = i.value();
                if (sounds.canConvert(QVariant::Map)) {
                    QMap <QString, QVariant> soundsList = sounds.toMap();
                    if (soundsList.contains(QStringLiteral("numFound"))) emit searchInfo(i18np("Found %1 result", "Found %1 results", soundsList.value("numFound").toInt()));
                    QList <QVariant> resultsList;
                    if (soundsList.contains(QStringLiteral("docs"))) {
                        resultsList = soundsList.value(QStringLiteral("docs")).toList();
                    }
                    
                    for (int j = 0; j < resultsList.count(); ++j) {
                        if (resultsList.at(j).canConvert(QVariant::Map)) {
                            QMap <QString, QVariant> soundmap = resultsList.at(j).toMap();
                            if (soundmap.contains(QStringLiteral("title"))) {
                                QListWidgetItem *item = new   QListWidgetItem(soundmap.value(QStringLiteral("title")).toString(), m_listWidget);
                                item->setData(descriptionRole, soundmap.value(QStringLiteral("description")).toString());
                                item->setData(idRole, soundmap.value(QStringLiteral("identifier")).toString());
                                QString author = soundmap.value(QStringLiteral("creator")).toString();
                                item->setData(authorRole, author);
                                if (author.startsWith(QLatin1String("http"))) item->setData(authorUrl, author);
                                item->setData(infoUrl, "http://archive.org/details/" + soundmap.value(QStringLiteral("identifier")).toString());
                                item->setData(downloadRole, "http://archive.org/download/" + soundmap.value(QStringLiteral("identifier")).toString());
                                item->setData(licenseRole, soundmap.value(QStringLiteral("licenseurl")).toString());                        
                            }
                        }
                    }
                }
            }
            ++i;
        }
    }
    m_listWidget->blockSignals(false);
    m_listWidget->setCurrentRow(0);
    emit searchDone();
}
Example #10
0
void FaceDb::updateIdentity(const Identity& p)
{
    d->db->execSql(QString::fromLatin1("DELETE FROM IdentityAttributes WHERE id=?;"), p.id());
    const QMap<QString, QString> map = p.attributesMap();
    QMap<QString, QString>::const_iterator it;

    for (it = map.constBegin(); it != map.constEnd(); ++it)
    {
        d->db->execSql(QString::fromLatin1("INSERT INTO IdentityAttributes (id, attribute, value) VALUES (?, ?,?);"),
                       p.id(), it.key(), it.value());
    }
}
void AnnotationOutput::writeAnnotations(const QString &fileName, const QMap<uint, QPair<QString, QString> > &a_annotations)
{
  m_annotatedFileItems.clear();
  m_fileNames.clear();
  m_lines.clear();
  m_yourFileItems.clear();
  m_yourFileNames.clear();
  m_yourLines.clear();

  bool modified = false;
  QMap<uint, QPair<QString, QString> > annotations = a_annotations;
  QDomDocument *dom = Project::ref()->dom();
  QDomElement annotationElement = dom->firstChild().firstChild().namedItem("annotations").toElement();
  if (annotationElement.isNull())
  {
    annotationElement = dom->createElement("annotations");
    dom->firstChild().firstChild().appendChild(annotationElement);
  }
  QDomNode n = annotationElement.firstChild();
  while ( !n.isNull() ) 
  {
    QDomElement el = n.toElement();
    QString fName = el.attribute("url");
    QDomNode n2 = n.nextSibling();
    if (fileName == fName)    
    {
      QString text = el.attribute("text");
      bool ok;
      int line = el.attribute("line").toInt(&ok, 10);
      if (!annotations.contains(line) || (annotations[line].first != text))
      {
        n.parentNode().removeChild(n);
        modified = true;
      } else
        annotations.remove(line);
    }
    n = n2;
  }
  for (QMap<uint, QPair<QString, QString> >::ConstIterator it = annotations.constBegin(); it != annotations.constEnd(); ++it)
  {
    QDomElement el = dom->createElement("annotation");
    el.setAttribute("url", fileName);
    el.setAttribute("line", it.key());
    el.setAttribute("text", it.data().first);
    el.setAttribute("receiver", it.data().second.lower());
    annotationElement.appendChild(el);
    modified = true;
  }
  if (modified)
    Project::ref()->setModified(true);
  if (m_allAnnotations->isVisible() || m_yourAnnotations->isVisible())
    readAnnotations();
}
Example #12
0
double SGMResolutionOptimization::collapser(QMap<double, double> optCurve){
	QMap<double, double>::const_iterator i;
	i = optCurve.constBegin();
	double tmpMin = i.value();
	++i;
	while(i != optCurve.constEnd()){
		if(i.value() < tmpMin)
			tmpMin = i.value();
		++i;
	}
	return tmpMin;
}
Example #13
0
void SoundThemeManager::applyTheme(const QString &themeName)
{
	MyThemes->setTheme(themeName);
	QMap<QString, QString> entries = MyThemes->getEntries();
	QMap<QString, QString>::const_iterator i = entries.constBegin();

	while (i != entries.constEnd())
	{
		config_file.writeEntry("Sounds", i.key() + "_sound", MyThemes->themePath() + i.value());
		++i;
	}
}
Example #14
0
static QMap<QString, QString>::const_iterator findKey(const QMap<QString, QString> &input,
                                                      Utils::OsType osType,
                                                      const QString &key)
{
    const Qt::CaseSensitivity casing
            = (osType == Utils::OsTypeWindows) ? Qt::CaseInsensitive : Qt::CaseSensitive;
    for (auto it = input.constBegin(); it != input.constEnd(); ++it) {
        if (key.compare(it.key(), casing) == 0)
            return it;
    }
    return input.constEnd();
}
Example #15
0
void HelpBrowser::showHelpForKeyword(const QString &id)
{
    if (m_helpEngine) {
        QMap<QString, QUrl> links = m_helpEngine->linksForIdentifier(id);
        qDebug()<<m_helpEngine->collectionFile();
        qDebug()<<m_helpEngine->filterAttributes();
        qDebug()<<id<<links.count();
        if (links.count()){
            qDebug()<<links.constBegin().value();
            setSource(links.constBegin().value());
    }
    }
}
Example #16
0
    KDataPrivate(const Quantity *qty, const QMap<QString, qreal> & items, KData::ContentTypes t)
        : _quantity(qty)
    {
        Q_ASSERT(_quantity != 0);
        _types |= (KData::Array | t);

        QMap<QString, qreal>::const_iterator it = items.constBegin();
        QMap<QString, qreal>::const_iterator end = items.constEnd();
        while (it != end) {
            _items.append(KDataItem(it.key(), it.value(), t));
            it++;
        }
    }
Example #17
0
static QByteArray serializeResponse(const QMap<QByteArray, QByteArray> &AResponse)
{
	QByteArray response;
	for (QMap<QByteArray, QByteArray>::const_iterator it=AResponse.constBegin(); it!=AResponse.constEnd(); ++it)
	{
		QByteArray value = it.value();
		value.replace("\\", "\\\\");
		value.replace("\"", "\\\"");
		response.append(it.key() + "=\"" + value + "\",");
	}
	response.chop(1);
	return response;
}
Example #18
0
void printRequestParameters( const QMap< QString, QString>& parameterMap, int logLevel )
{
  if ( logLevel > 0 )
  {
    return;
  }

  QMap< QString, QString>::const_iterator pIt = parameterMap.constBegin();
  for ( ; pIt != parameterMap.constEnd(); ++pIt )
  {
    QgsMessageLog::logMessage( pIt.key() + ":" + pIt.value(), "Server", QgsMessageLog::INFO );
  }
}
QVariantMap CTransaction::toVariantMap(QMap<QString, QString> t_data)
{
    if(t_data.isEmpty())
        return QVariantMap();
    QVariantMap dataMap;
    QMap<QString, QString>::const_iterator i = t_data.constBegin();
    while (i != t_data.constEnd()) {
        dataMap.insert(i.key(), i.value());
        ++i;
    }

    return dataMap;
}
Example #20
0
bool
TableModel::setItemData(const QModelIndex &index,
                        const QMap<int, QVariant> &roles)
{
    if ( !index.isValid() ) {
        return false;
    }

    TableView *view = qobject_cast<TableView*>( QObject::parent() );
    TableItem *itm = item(index);
    if (itm) {
        itm->view = 0; // prohibits item from calling itemChanged()
        bool changed = false;
        for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) {
            if ( itm->data( it.key() ) != it.value() ) {
                itm->setData( it.key(), it.value() );
                changed = true;
            }
        }
        itm->view = view;
        if (changed) {
            itemChanged(itm);
        }

        return true;
    }

    if (!view) {
        return false;
    }

    itm = createItem();
    for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) {
        itm->setData( it.key(), it.value() );
    }
    view->setItem(index.row(), index.column(), itm);

    return true;
}
void ChoiceSearchModel::setChoice(const QMap<int, QString>& data)
{
    if (m_entries.size())
    {
        m_entries.clear();
        reset();
    }

    for (QMap<int, QString>::const_iterator it = data.constBegin(); it != data.constEnd(); ++it)
    {
        m_entries << Entry(it.key(), it.value());
    }
}
Example #22
0
void TimelineDocker::setMainWindow(KisViewManager *view)
{
    KisActionManager *actionManager = view->actionManager();

    QMap<QString, KisAction*> actions = m_d->view->globalActions();

    QMap<QString, KisAction*>::const_iterator it = actions.constBegin();
    QMap<QString, KisAction*>::const_iterator end = actions.constEnd();

    for (; it != end; ++it) {
        actionManager->addAction(it.key(), it.value());
    }
}
Example #23
0
bool frmPriceImport::mergePrices(const historicalPricesMap &newPriceMap_, bool dryRun_)
{
    foreach(const historicalPrices &newPrices, newPriceMap_.getHistoricalPrices())
    {
        QMap<int, double> prices = newPrices.values(historicalPrices::type_price);
        QMap<int, double> dividends = newPrices.values(historicalPrices::type_dividend);
        QMap<int, double> splits = newPrices.values(historicalPrices::type_split);

        if (dryRun_)
        {
            // check for duplicates
            bool askAgain = true;
            if (!duplicatePriceCheck(newPrices.symbol(), historicalPrices::type_price, prices, askAgain))
                return false;
            if (!askAgain)
                return true;
            if (!duplicatePriceCheck(newPrices.symbol(), historicalPrices::type_dividend, dividends, askAgain))
                return false;
            if (!askAgain)
                return true;
            if (!duplicatePriceCheck(newPrices.symbol(), historicalPrices::type_split, splits, askAgain))
                return false;
            if (!askAgain)
                return true;

            continue;
        }

        // insert prices
        for(QMap<int, double>::const_iterator i = prices.constBegin(); i != prices.constEnd(); ++i)
            m_pricesMap.getHistoricalPrice(newPrices.symbol()).insert(i.key(), i.value(), historicalPrices::type_price);
        for(QMap<int, double>::const_iterator i = dividends.constBegin(); i != dividends.constEnd(); ++i)
            m_pricesMap.getHistoricalPrice(newPrices.symbol()).insert(i.key(), i.value(), historicalPrices::type_dividend);
        for(QMap<int, double>::const_iterator i = splits.constBegin(); i != splits.constEnd(); ++i)
            m_pricesMap.getHistoricalPrice(newPrices.symbol()).insert(i.key(), i.value(), historicalPrices::type_split);
    }

    return true;
}
Example #24
0
void RosterReplacer::performRenames(const QMap<Buddy, Contact> &contactsToRename)
{
	BuddyList buddiesToRemove;
	for (QMap<Buddy, Contact>::const_iterator i = contactsToRename.constBegin(); i != contactsToRename.constEnd(); i++)
	{
		// do not remove now as theoretically it could be used in next loop run
		buddiesToRemove.append(i.value().ownerBuddy());
		i.value().setOwnerBuddy(i.key());
	}

	for (auto &&buddy : buddiesToRemove)
		m_buddyManager->removeBuddyIfEmpty(buddy, true);
}
Example #25
0
void QgisAppStyleSheet::saveToSettings( const QMap<QString, QVariant>& opts )
{
  QSettings settings;
  settings.beginGroup( "qgis/stylesheet" );

  QMap<QString, QVariant>::const_iterator opt = opts.constBegin();
  while ( opt != opts.constEnd() )
  {
    settings.setValue( QString( opt.key() ), opt.value() );
    ++opt;
  }
  settings.endGroup(); // "qgis/stylesheet"
}
Example #26
0
Tile Tile::createRandom(const QMap<Tile::Type, double>& probDist)
{
    double probSum = 0.0;
    auto i = probDist.constBegin();
    for (; i != probDist.constEnd(); i++) {
        probSum += i.value();
    }

    // randomize a value and compare it to a cumulative random distribution.
    double rnd = probSum * double(qrand())/RAND_MAX;
    double probAccum = 0.0;
    for (i = probDist.constBegin(); i != probDist.constEnd(); i++) {
        probAccum += i.value();
        if (rnd < probAccum) {
            return i.key(); // returns the randomized tile.
        }
    }

    // actually this should never happen as
    // the assertion rnd < probSum should always be true
    return Tile::NONE_TILE;
}
Example #27
0
void QgsServer::printRequestParameters( const QMap< QString, QString> &parameterMap, Qgis::MessageLevel logLevel )
{
  if ( logLevel > Qgis::Info )
  {
    return;
  }

  QMap< QString, QString>::const_iterator pIt = parameterMap.constBegin();
  for ( ; pIt != parameterMap.constEnd(); ++pIt )
  {
    QgsMessageLog::logMessage( pIt.key() + ":" + pIt.value(), QStringLiteral( "Server" ), Qgis::Info );
  }
}
static PyObject *convertFrom_QMap_1800_0100QVariant(void *sipCppV,PyObject *sipTransferObj)
{
   QMap<int,QVariant> *sipCpp = reinterpret_cast<QMap<int,QVariant> *>(sipCppV);

#line 153 "/home/tsheasha/GUC/Bachelors/android-python27/python-build/PyQt-x11-gpl-4.8/sip/QtCore/qmap.sip"
    // Create the dictionary.
    PyObject *d = PyDict_New();

    if (!d)
        return NULL;

    // Set the dictionary elements.
    QMap<int, QVariant>::const_iterator i = sipCpp->constBegin();

    while (i != sipCpp->constEnd())
    {
        QVariant *t = new QVariant(i.value());

        PyObject *kobj = SIPLong_FromLong(i.key());
        PyObject *tobj = sipConvertFromNewType(t, sipType_QVariant, sipTransferObj);

        if (kobj == NULL || tobj == NULL || PyDict_SetItem(d, kobj, tobj) < 0)
        {
            Py_DECREF(d);

            if (kobj)
            {
                Py_DECREF(kobj);
            }

            if (tobj)
            {
                Py_DECREF(tobj);
            }
            else
            {
                delete t;
            }

            return NULL;
        }

        Py_DECREF(kobj);
        Py_DECREF(tobj);

        ++i;
    }

    return d;
#line 180 "sipQtCoreQMap18000100QVariant.cpp"
}
Example #29
0
void QKineticScroller::resetScrollMetrics()
{
    static QMap<ScrollMetric, QVariant> metrics;

#ifdef Q_WS_MAEMO_5
    metrics.insert(DragVelocitySmoothingFactor, qreal(0.15));
    metrics.insert(ExponentialDecelerationBase, qreal(0.38)); // 0.85^20
    metrics.insert(LinearDecelerationFactor, qreal(0));
    metrics.insert(OvershootSpringConstant, qreal(80.56));
    metrics.insert(OvershootDragResistanceFactor, qreal(1));
    metrics.insert(OvershootMaximumDistance, QPointF(qreal(15.0 / 1000), qreal(15.0 / 1000)));
    metrics.insert(DragStartDistance, qreal(2.5 / 1000));
    metrics.insert(DragStartDirectionErrorMargin, qreal(1.0 / 1000));
    metrics.insert(MaximumVelocity, qreal(6.84));
    metrics.insert(MinimumVelocity, qreal(0.0195));
    metrics.insert(MaximumNonAcceleratedVelocity, qreal(5.6));
    metrics.insert(MaximumClickThroughVelocity, qreal(0.0684));
    metrics.insert(AxisLockThreshold, qreal(0));
    metrics.insert(FastSwipeBaseVelocity, qreal(5.6 * 27));
    metrics.insert(FastSwipeMinimumVelocity, qreal(0.078));
    metrics.insert(FastSwipeMaximumTime, qreal(0.125));
    metrics.insert(FramesPerSecond, qreal(20));
#else
    metrics.insert(DragVelocitySmoothingFactor, qreal(0.02));
    metrics.insert(ExponentialDecelerationBase, qreal(1));
    metrics.insert(LinearDecelerationFactor, qreal(0.38));
    metrics.insert(OvershootSpringConstant, qreal(15.0));
    metrics.insert(OvershootDragResistanceFactor, qreal(0.5));
    metrics.insert(OvershootMaximumDistance, QPointF(0,0)); // QPointF(qreal(14.25 / 1000), qreal(14.25 / 1000)));
    metrics.insert(DragStartDistance, qreal(2.5 / 1000));
    metrics.insert(DragStartDirectionErrorMargin, qreal(1.0 / 1000));
    metrics.insert(MaximumVelocity, qreal(6650.0 / 1000));
    metrics.insert(MinimumVelocity, qreal(30.0 / 1000));
    metrics.insert(MaximumNonAcceleratedVelocity, qreal(532.0 / 1000));
    metrics.insert(MaximumClickThroughVelocity, qreal(66.5 / 1000));
    metrics.insert(AxisLockThreshold, qreal(0));
    metrics.insert(FastSwipeBaseVelocity, qreal(51.3 / 1000));
    metrics.insert(FastSwipeMinimumVelocity, qreal(76.0 / 1000));
    metrics.insert(FastSwipeMaximumTime, qreal(0.125));
    metrics.insert(FramesPerSecond, qreal(60));
#endif

    if (!metrics.isEmpty()) {
        for (QMap<ScrollMetric, QVariant>::const_iterator it = metrics.constBegin(); it != metrics.constEnd(); ++it)
            setScrollMetric(it.key(), it.value());
        if (metrics.count() != ScrollMetricCount)
            qWarning("QKineticScroller::resetAllMetrics(): scroll metrics parameter set did not contain all metrics.");
    } else {
        qWarning("QKineticScroller::resetAllMetrics(): no platform default parameter set available.");
    }
}
Example #30
0
void mos_config_save(const QMap<QString, color_range> &ranges, const QMap<QString, QList<QRgb> > &palettes)
{
	QSettings s;
	int j;

	s.beginWriteArray("color_ranges");
	j = 0;
	for(QMap<QString, color_range>::const_iterator i = ranges.constBegin();
		i != ranges.constEnd(); ++i, ++j)
	{
		s.setArrayIndex(j);
		s.setValue("id", i.key());
		s.setValue("avg", i.value().mid());
		s.setValue("max", i.value().max());
		s.setValue("min", i.value().min());
	}
	s.endArray();

	s.beginWriteArray("palettes");
	j = 0;
	for(QMap<QString, QList<QRgb> >::const_iterator i = palettes.constBegin();
		i != palettes.constEnd(); ++i, ++j)
	{
		s.setArrayIndex(j);
		s.setValue("id", i.key());

		QString csv;

		for(QRgb v : i.value()) {
			if(!csv.isEmpty())
				csv += ',';
			csv += QString::number(v);
		}

		s.setValue("values", csv);
	}
	s.endArray();
}