Exemplo n.º 1
0
Arquivo: xbel.cpp Projeto: maxxant/qt
void XbelReader::readTitle(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("title"));
    parent->title = readElementText();
}
Exemplo n.º 2
0
Arquivo: xbel.cpp Projeto: maxxant/qt
void XbelReader::readDescription(BookmarkNode *parent)
{
    Q_ASSERT(isStartElement() && name() == QLatin1String("desc"));
    parent->desc = readElementText();
}
Exemplo n.º 3
0
bool TSReader::read(Translator &translator)
{
    STRING(byte);
    STRING(catalog);
    STRING(comment);
    STRING(context);
    STRING(defaultcodec);
    STRING(dependencies);
    STRING(dependency);
    STRING(extracomment);
    STRING(filename);
    STRING(id);
    STRING(language);
    STRING(line);
    STRING(location);
    STRING(message);
    STRING(name);
    STRING(numerus);
    STRING(numerusform);
    STRING(obsolete);
    STRING(oldcomment);
    STRING(oldsource);
    STRING(source);
    STRING(sourcelanguage);
    STRING(translation);
    STRING(translatorcomment);
    STRING(TS);
    STRING(type);
    STRING(unfinished);
    STRING(userdata);
    STRING(value);
    STRING(vanished);
    //STRING(version);
    STRING(yes);

    static const QString strextrans(QLatin1String("extra-"));
    static const QString strUtf8(QLatin1String("UTF-8"));

    while (!atEnd()) {
        readNext();
        if (isStartDocument()) {
            // <!DOCTYPE TS>
            //qDebug() << attributes();
        } else if (isEndDocument()) {
            // <!DOCTYPE TS>
            //qDebug() << attributes();
        } else if (isDTD()) {
            // <!DOCTYPE TS>
            //qDebug() << tokenString();
        } else if (elementStarts(strTS)) {
            // <TS>
            //qDebug() << "TS " << attributes();
            QHash<QString, int> currentLine;
            QString currentFile;
            bool maybeRelative = false, maybeAbsolute = false;

            QXmlStreamAttributes atts = attributes();
            //QString version = atts.value(strversion).toString();
            translator.setLanguageCode(atts.value(strlanguage).toString());
            translator.setSourceLanguageCode(atts.value(strsourcelanguage).toString());
            while (!atEnd()) {
                readNext();
                if (isEndElement()) {
                    // </TS> found, finish local loop
                    break;
                } else if (isWhiteSpace()) {
                    // ignore these, just whitespace
                } else if (elementStarts(strdefaultcodec)) {
                    // <defaultcodec>
                    readElementText();
                    m_cd.appendError(QString::fromLatin1("Warning: ignoring <defaultcodec> element"));
                    // </defaultcodec>
                } else if (isStartElement()
                        && name().toString().startsWith(strextrans)) {
                    // <extra-...>
                    QString tag = name().toString();
                    translator.setExtra(tag.mid(6), readContents());
                    // </extra-...>
                } else if (elementStarts(strdependencies)) {
                    /*
                     * <dependencies>
                     *   <dependency catalog="qtsystems_no"/>
                     *   <dependency catalog="qtbase_no"/>
                     * </dependencies>
                     **/
                    QStringList dependencies;
                    while (!atEnd()) {
                        readNext();
                        if (isEndElement()) {
                            // </dependencies> found, finish local loop
                            break;
                        } else if (elementStarts(strdependency)) {
                            // <dependency>
                            QXmlStreamAttributes atts = attributes();
                            dependencies.append(atts.value(strcatalog).toString());
                            while (!atEnd()) {
                                readNext();
                                if (isEndElement()) {
                                    // </dependency> found, finish local loop
                                    break;
                                }
                            }
                        }
                    }
                    translator.setDependencies(dependencies);
                } else if (elementStarts(strcontext)) {
                    // <context>
                    QString context;
                    while (!atEnd()) {
                        readNext();
                        if (isEndElement()) {
                            // </context> found, finish local loop
                            break;
                        } else if (isWhiteSpace()) {
                            // ignore these, just whitespace
                        } else if (elementStarts(strname)) {
                            // <name>
                            context = readElementText();
                            // </name>
                        } else if (elementStarts(strmessage)) {
                            // <message>
                            TranslatorMessage::References refs;
                            QString currentMsgFile = currentFile;

                            TranslatorMessage msg;
                            msg.setId(attributes().value(strid).toString());
                            msg.setContext(context);
                            msg.setType(TranslatorMessage::Finished);
                            msg.setPlural(attributes().value(strnumerus) == stryes);
                            while (!atEnd()) {
                                readNext();
                                if (isEndElement()) {
                                    // </message> found, finish local loop
                                    msg.setReferences(refs);
                                    translator.append(msg);
                                    break;
                                } else if (isWhiteSpace()) {
                                    // ignore these, just whitespace
                                } else if (elementStarts(strsource)) {
                                    // <source>...</source>
                                    msg.setSourceText(readContents());
                                } else if (elementStarts(stroldsource)) {
                                    // <oldsource>...</oldsource>
                                    msg.setOldSourceText(readContents());
                                } else if (elementStarts(stroldcomment)) {
                                    // <oldcomment>...</oldcomment>
                                    msg.setOldComment(readContents());
                                } else if (elementStarts(strextracomment)) {
                                    // <extracomment>...</extracomment>
                                    msg.setExtraComment(readContents());
                                } else if (elementStarts(strtranslatorcomment)) {
                                    // <translatorcomment>...</translatorcomment>
                                    msg.setTranslatorComment(readContents());
                                } else if (elementStarts(strlocation)) {
                                    // <location/>
                                    maybeAbsolute = true;
                                    QXmlStreamAttributes atts = attributes();
                                    QString fileName = atts.value(strfilename).toString();
                                    if (fileName.isEmpty()) {
                                        fileName = currentMsgFile;
                                        maybeRelative = true;
                                    } else {
                                        if (refs.isEmpty())
                                            currentFile = fileName;
                                        currentMsgFile = fileName;
                                    }
                                    const QString lin = atts.value(strline).toString();
                                    if (lin.isEmpty()) {
                                        refs.append(TranslatorMessage::Reference(fileName, -1));
                                    } else {
                                        bool bOK;
                                        int lineNo = lin.toInt(&bOK);
                                        if (bOK) {
                                            if (lin.startsWith(QLatin1Char('+')) || lin.startsWith(QLatin1Char('-'))) {
                                                lineNo = (currentLine[fileName] += lineNo);
                                                maybeRelative = true;
                                            }
                                            refs.append(TranslatorMessage::Reference(fileName, lineNo));
                                        }
                                    }
                                    readContents();
                                } else if (elementStarts(strcomment)) {
                                    // <comment>...</comment>
                                    msg.setComment(readContents());
                                } else if (elementStarts(struserdata)) {
                                    // <userdata>...</userdata>
                                    msg.setUserData(readContents());
                                } else if (elementStarts(strtranslation)) {
                                    // <translation>
                                    QXmlStreamAttributes atts = attributes();
                                    QStringRef type = atts.value(strtype);
                                    if (type == strunfinished)
                                        msg.setType(TranslatorMessage::Unfinished);
                                    else if (type == strvanished)
                                        msg.setType(TranslatorMessage::Vanished);
                                    else if (type == strobsolete)
                                        msg.setType(TranslatorMessage::Obsolete);
                                    if (msg.isPlural()) {
                                        QStringList translations;
                                        while (!atEnd()) {
                                            readNext();
                                            if (isEndElement()) {
                                                break;
                                            } else if (isWhiteSpace()) {
                                                // ignore these, just whitespace
                                            } else if (elementStarts(strnumerusform)) {
                                                translations.append(readTransContents());
                                            } else {
                                                handleError();
                                                break;
                                            }
                                        }
                                        msg.setTranslations(translations);
                                    } else {
                                        msg.setTranslation(readTransContents());
                                    }
                                    // </translation>
                                } else if (isStartElement()
                                        && name().toString().startsWith(strextrans)) {
                                    // <extra-...>
                                    QString tag = name().toString();
                                    msg.setExtra(tag.mid(6), readContents());
                                    // </extra-...>
                                } else {
                                    handleError();
                                }
                            }
                            // </message>
                        } else {
                            handleError();
                        }
                    }
                    // </context>
                } else {
                    handleError();
                }
                translator.setLocationsType(maybeRelative ? Translator::RelativeLocations :
                                            maybeAbsolute ? Translator::AbsoluteLocations :
                                                            Translator::NoLocations);
            } // </TS>
        } else {
            handleError();
        }
    }
    if (hasError()) {
        m_cd.appendError(errorString());
        return false;
    }
    return true;
}
Exemplo n.º 4
0
 bool elementStarts(const QString &str) const
 {
     return isStartElement() && name() == str;
 }
Exemplo n.º 5
0
OpenSearchEngine *OpenSearchReader::read()
{
    OpenSearchEngine *engine = new OpenSearchEngine();

    while (!isStartElement() && !atEnd())
        readNext();

    if (name() != QLatin1String("OpenSearchDescription")
        || namespaceUri() != QLatin1String("http://a9.com/-/spec/opensearch/1.1/")) {
        raiseError(QObject::tr("The file is not an OpenSearch 1.1 file."));
        return engine;
    }

    while (!atEnd()) {
        readNext();

        if (!isStartElement())
            continue;

        if (name() == QLatin1String("ShortName")) {
            engine->setName(readElementText());
        } else if (name() == QLatin1String("Description")) {
            engine->setDescription(readElementText());
        } else if (name() == QLatin1String("Url")) {

            QString type = attributes().value(QLatin1String("type")).toString();
            QString url = attributes().value(QLatin1String("template")).toString();

            if (type == QLatin1String("application/x-suggestions+json")
                && !engine->suggestionsUrlTemplate().isEmpty())
                continue;

            if ((type.isEmpty()
                || type == QLatin1String("text/html")
                || type == QLatin1String("application/xhtml+xml"))
                && !engine->searchUrlTemplate().isEmpty())
                continue;

            if (url.isEmpty())
                continue;

            QList<OpenSearchEngine::Parameter> parameters;

            readNext();

            while (!(isEndElement() && name() == QLatin1String("Url"))) {
                if (!isStartElement() || (name() != QLatin1String("Param") && name() != QLatin1String("Parameter"))) {
                    readNext();
                    continue;
                }

                QString key = attributes().value(QLatin1String("name")).toString();
                QString value = attributes().value(QLatin1String("value")).toString();

                if (!key.isEmpty() && !value.isEmpty())
                    parameters.append(OpenSearchEngine::Parameter(key, value));

                while (!isEndElement())
                    readNext();
            }

            if (type == QLatin1String("application/x-suggestions+json")) {
                engine->setSuggestionsUrlTemplate(url);
                engine->setSuggestionsParameters(parameters);
            } else if (type.isEmpty() || type == QLatin1String("text/html") || type == QLatin1String("application/xhtml+xml")) {
                engine->setSearchUrlTemplate(url);
                engine->setSearchParameters(parameters);
            }

        } else if (name() == QLatin1String("Image")) {
             engine->setImageUrl(readElementText());
        }

        if (!engine->name().isEmpty()
            && !engine->description().isEmpty()
            && !engine->suggestionsUrlTemplate().isEmpty()
            && !engine->searchUrlTemplate().isEmpty()
            && !engine->imageUrl().isEmpty())
            break;
    }

    return engine;
}
Exemplo n.º 6
0
OpenSearchEngine* OpenSearchReader::read()
{
    OpenSearchEngine* engine = new OpenSearchEngine();
    m_searchXml = device()->peek(1024 * 5);

    while (!isStartElement() && !atEnd()) {
        readNext();
    }

    if (!m_searchXml.contains(QLatin1String("http://a9.com/-/spec/opensearch/1.1/")) &&
            !m_searchXml.contains(QLatin1String("http://www.mozilla.org/2006/browser/search/"))) {
        raiseError(QObject::tr("The file is not an OpenSearch 1.1 file."));
        return engine;
    }

    while (!atEnd()) {
        readNext();

        if (!isStartElement()) {
            continue;
        }

        if (name() == QLatin1String("ShortName") || name() == QLatin1String("os:ShortName")) {
            engine->setName(readElementText());
        }
        else if (name() == QLatin1String("Description") || name() == QLatin1String("os:Description")) {
            engine->setDescription(readElementText());
        }
        else if (name() == QLatin1String("Url") || name() == QLatin1String("os:Url")) {
            QString type = attributes().value(QLatin1String("type")).toString();
            QString url = attributes().value(QLatin1String("template")).toString();
            QString method = attributes().value(QLatin1String("method")).toString();

            if (type == QLatin1String("application/x-suggestions+json")
                    && !engine->suggestionsUrlTemplate().isEmpty()) {
                continue;
            }

            if ((type.isEmpty()
                    || type == QLatin1String("text/html")
                    || type == QLatin1String("application/xhtml+xml"))
                    && !engine->searchUrlTemplate().isEmpty()) {
                continue;
            }

            if (url.isEmpty()) {
                continue;
            }

            QList<OpenSearchEngine::Parameter> parameters;

            readNext();

            while (!isEndElement() || (name() != QLatin1String("Url") && name() != QLatin1String("os:Url"))) {
                if (!isStartElement() || (name() != QLatin1String("Param") && name() != QLatin1String("Parameter")
                                          && name() != QLatin1String("os:Param") && name() != QLatin1String("os:Parameter"))) {
                    readNext();
                    continue;
                }

                QString key = attributes().value(QLatin1String("name")).toString();
                QString value = attributes().value(QLatin1String("value")).toString();

                if (!key.isEmpty() && !value.isEmpty()) {
                    parameters.append(OpenSearchEngine::Parameter(key, value));
                }

                while (!isEndElement()) {
                    readNext();
                }
            }

            if (type == QLatin1String("application/x-suggestions+json")) {
                engine->setSuggestionsUrlTemplate(url);
                engine->setSuggestionsParameters(parameters);
                engine->setSuggestionsMethod(method);
            }
            else if (type.isEmpty() || type == QLatin1String("text/html") || type == QLatin1String("application/xhtml+xml")) {
                engine->setSearchUrlTemplate(url);
                engine->setSearchParameters(parameters);
                engine->setSearchMethod(method);
            }

        }
        else if (name() == QLatin1String("Image") || name() == QLatin1String("os:Image")) {
            engine->setImageUrl(readElementText());
        }

        if (!engine->name().isEmpty()
                && !engine->description().isEmpty()
                && !engine->suggestionsUrlTemplate().isEmpty()
                && !engine->searchUrlTemplate().isEmpty()
                && !engine->imageUrl().isEmpty()) {
            break;
        }
    }

    return engine;
}
void
ITunesImporterWorker::readTrackElement()
{
    QString title, artist, album, url;
    int year = -1, bpm = -1, playcount = -1, rating = -1;
    QDateTime lastplayed;
    
    while( !( isEndElement() && name() == "dict" ) )
    {
        readNext();
        QString text = readElementText();
        if( name() == "key" && text == "Name" )
        {
            readNext(); // skip past the </key> and to the data tag
            QString text = readElementText();
            title = text;
        } else if( name() == "key" && text == "Artist" )
        {
            readNext(); // skip past the </key> and to the data tag
            artist = readElementText();
        } else if( isStartElement() && name() == "key" && text == "Album" )
        {
            readNext(); // skip past the </key> and to the data tag
            album = readElementText();
        } else if( name() == "key" && text == "Year" )
        {
            readNext(); // skip past the </key> and to the data tag
            year = readElementText().toInt();
        } else if( name() == "key" && text == "BPM" )
        {
            readNext(); // skip past the </key> and to the data tag
            bpm = readElementText().toInt();
        } else if( name() == "key" && text == "Play Count" )
        { 
            readNext(); // skip past the </key> and to the data tag
            playcount = readElementText().toInt();
        } else if( name() == "key" && text == "Rating" )
          { 
            readNext(); // skip past the </key> and to the data tag
            rating = readElementText().toInt() / 10; // itunes rates 0-100
        } else if( name() == "key" && text == "Play Date" )
        { 
            readNext(); // skip past the </key> and to the data tag
            lastplayed = QDateTime::fromTime_t(readElementText().toInt());
        } else if( name() == "key" && text == "Location" )
        {
            readNext(); // skip past the </key> and to the data tag
            url = readElementText();
        }
    }
    
    //split the file://localhost/path/to/track   to just file:///path/to/track
    if( url.indexOf( "file://localhost" ) == 0 )
        url = url.remove( 7, 9 );
    
    debug() << "got track info:" << title << artist << album << year << bpm << url;
    
    Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( KUrl( url ) );
    if( track )
    {
        Meta::StatisticsPtr statistics = track->statistics();
        statistics->beginUpdate();
        if( rating != -1 )
            statistics->setRating( rating );
        if( lastplayed.isValid() )
            statistics->setLastPlayed( lastplayed );
        if( playcount != -1 )
            statistics->setPlayCount( playcount );
        statistics->endUpdate();

        if( !track->inCollection() )
        {
            m_tracksForInsert.insert( track, track->playableUrl().url() );
            debug() << " inserting track:" << track->playableUrl();
        }
        else {
            Collections::Collection* collection = track->collection();
            if (collection)
                debug() << "track in collection (" << collection->location()->prettyLocation() << "):" << track->playableUrl();
        }

        emit trackAdded( track );
    }
}
void
ITunesImporterWorker::run()
{
    DEBUG_BLOCK
    debug() << "file:" << m_databaseLocation;
    QFile* file = new QFile( m_databaseLocation );
    if( !file->exists() )
    {
        debug() << "COULDN'T FIND DB FILE!";
        emit importError( "" );
        m_failed = true;
        return;
    }
    if ( !file->open( QIODevice::ReadOnly ) )
    {
        debug() << "COULDN'T OPEN DB FILE!";
        emit importError( "" );
        m_failed = true;
        return;
    }
    setDevice( file );

    //debug() << "got element:" << name().toString();

    while( !atEnd() )
    {
        if( m_aborted )
            return;

        readNext();

        if ( name() == "key" && readElementText() == "Tracks" ) // ok, we're at the start
        {
            readNext();
            readNext();
            readNext(); // this skips the first all-encompassing <dict> tag 
            debug() << "got start of tracks";
            while( !atEnd() && !( isEndElement() && name() == "dict" ) )
            {
                if( m_aborted )
                    return;

                //debug() << "reading element name:" << name().toString();
                if( isStartElement() && name() == "dict") // this is a track item!
                {
                    readTrackElement();
                }
                readNext();
            }
        }
    }

    if( m_tracksForInsert.size() > 0 )
    {
        Collections::CollectionLocation *location = CollectionManager::instance()->primaryCollection()->location();

        QMapIterator<Meta::TrackPtr, QString> j(m_tracksForInsert);
        while (j.hasNext()) {
            j.next();
            location->insert( j.key(), j.value() );
        }
    }

    debug() << "done importing xml file";
}
Exemplo n.º 9
0
void ConfigurationParser::readFiles(DataLayer *layer)
{
    Q_ASSERT(isStartElement()
             && name() == "files");
    
    QDateTime startDate;
    int start = 0;
    QDateTime endDate;
    int end = 0;
    int digits = 0;
    QString scheme;
    int skip = 0;
    
    while(!atEnd()) {
        readNext();
        
        if(isEndElement()) {
            break;
        }
        
        if(isStartElement()) {
            if(name() == "start") {
                QXmlStreamAttributes att = attributes();
                startDate.setTime(QTime::fromString(att.value("time").toString(), Qt::ISODate));
                startDate.setDate(QDate::fromString(att.value("date").toString(), Qt::ISODate));
                start = readCharacters().toInt();
            }
            else if(name() == "end") {
                QXmlStreamAttributes att = attributes();
                endDate.setTime(QTime::fromString(att.value("time").toString(), Qt::ISODate));
                endDate.setDate(QDate::fromString(att.value("date").toString(), Qt::ISODate));
                end = readCharacters().toInt();
            }
            else if(name() == "scheme") {
                QXmlStreamAttributes att = attributes();
                digits = att.value("digits").toString().toInt();
                if(att.hasAttribute("skip")) {
                    skip = att.value("skip").toString().toInt();
                }
                scheme = readCharacters();
            }
            else {
                readUnknownElement();
            }
        }
    }
    
    if(startDate.isValid() && endDate.isValid()) {
        qint64 spanMSecs = endDate.toMSecsSinceEpoch() - startDate.toMSecsSinceEpoch();
        int count = end - start;
        qint64 diffMSecs = spanMSecs / count;
        
        for(int i = start; i < end; i += 1 + skip) {
            QDateTime fileTime = startDate.addMSecs(diffMSecs * (i - start));
            qDebug() << "Time [" << i << "]:" << fileTime.toString();
            QString fileName = scheme.arg(i, digits, 10, QChar('0'));
            
            layer->setFileName(fileTime, fileName);
        }
    }
}
Exemplo n.º 10
0
DataLayer *ConfigurationParser::readLayer()
{
    Q_ASSERT(isStartElement()
              && name() == "layer");

    DataLayer *layer = new DataLayer();
    ColorMap colorMap;
    
    QColor c;
    c.setHsv(240, 255, 189, 255);
    colorMap.addColor(c);
    c.setHsv(240, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(224, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(208, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(195, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(180, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(159, 189, 255, 255);
    colorMap.addColor(c);
    c.setHsv(120, 123, 255, 255);
    colorMap.addColor(c);
    c.setHsv(80, 189, 255, 255);
    colorMap.addColor(c);
    c.setHsv(60, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(44, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(15, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(0, 255, 255, 255);
    colorMap.addColor(c);
    c.setHsv(0, 255, 189, 255);
    colorMap.addColor(c);
    c.setHsv(0, 255, 132, 255);
    colorMap.addColor(c);
    colorMap.setInterpolationSpec(QColor::Hsv);

    while(!atEnd()) {
        readNext();

        if(isEndElement())
            break;

        if(isStartElement()) {
            if(name() == "file") {
                QXmlStreamAttributes att = attributes();
                QDateTime dateTime;
                dateTime.setTime(QTime::fromString(att.value("time").toString(), Qt::ISODate));
                dateTime.setDate(QDate::fromString(att.value("date").toString(), Qt::ISODate));
                layer->setFileName(dateTime, readCharacters());
                qDebug() << "Added file for time:" << dateTime;
            }
            else if(name() == "files") {
                readFiles(layer);
            }
            else if(name() == "name") {
                layer->setName(readCharacters());
                qDebug() << "Name:" << layer->name();
            }
            else if(name() == "geometry") {
                QString geometryName = readCharacters();
                
                QHash<QString,MapGeometry>::iterator it = m_geometries.find(geometryName);
                if(it != m_geometries.end()) {
                    layer->setGeometry(it.value());
                }
                else {
                    delete layer;
                    qDebug() << "Geometry not found.";
                    return 0;
                }
            }
            else if(name() == "scaleMin") {
                layer->setScaleMin(readCharacters().toDouble());
            }
            else if(name() == "scaleMax") {
                layer->setScaleMax(readCharacters().toDouble());
            }
            else if(name() == "defaultColorMap") {
                QString colorMapString = readCharacters();
                if(m_colorMaps.contains(colorMapString)) {
                    colorMap = m_colorMaps.value(colorMapString);
                }
            }
            else {
                readUnknownElement();
            }
        }
    }

    layer->setDefaultColorMap(colorMap);
    return layer;
}
Exemplo n.º 11
0
void TcxReader::readTrackpoint(CTrack *track, int lap)
{
    Q_ASSERT(isStartElement() && name() == "Trackpoint");

    CTrack::pt_t *pt = new CTrack::pt_t();
    pt->lat = pold.lat;
    pt->lon = pold.lon;
    pt->ele = pold.ele;
    pt->distance = pold.distance;
    pt->heartReateBpm = pold.heartReateBpm;

    while (!atEnd())
    {
        readNext();

        if (isEndElement())
            break;

        if (isStartElement())
        {
            if (name() == "Time")
            {
                QDateTime time(QDateTime::fromString(readElementText(),
                    Qt::ISODate));
                time.setTimeSpec(Qt::UTC);
                pt->timestamp = time.toTime_t();
            }
            else if (name() == "AltitudeMeters")
            {
                pt->ele = readElementText().toDouble();
                pold.ele = pt->ele;
            }
            else if (name() == "DistanceMeters")
            {
                pt->distance = readElementText().toDouble();
                pold.distance = pt->distance;
            }
            else if (name() == "Position")
            {
                readPosition(pt);
                pold.lat = pt->lat;
                pold.lon = pt->lon;
                firstPositionFound = true;
            }
            else if (name() == "HeartRateBpm")
            {
                readHeartRateBpm(pt);
                pold.heartReateBpm  = pt->heartReateBpm;
            }
            else if (name() == "Cadence")
            {
                //readCadenceRpm(pt);
                pt->cadenceRpm = readElementText().toInt();
                pold.cadenceRpm  = pt->cadenceRpm;
            }
            else
                readUnknownElement();
        }
    }
    pt->_lat=pt->lat;
    pt->_lon=pt->lon;
    pt->_ele=pt->ele;
    if (firstPositionFound)
    {
        *track << *pt;
    }
}