QDomElement MusicAbstractXml::writeDomElement(QDomElement &element, const QString &node,
                                              const QString &key, const QVariant &value)
{
    QDomElement domElement = writeDom(element, node);
    writeAttribute(domElement, key, value);
    return domElement;
}
QDomElement MusicAbstractXml::writeDomText(QDomElement &element, const QString &node,
                                           const QString &text)
{
    QDomElement domElement = writeDom(element, node);
    QDomText domText = m_ddom->createTextNode( text );
    domElement.appendChild( domText );
    return domElement;
}
void MusicDownloadRecordConfigManager::writeDownloadConfig(const MusicDownloadRecords &records)
{
    if(!writeConfig(mappingFilePathFromEnum()))
    {
        return;
    }
    ///////////////////////////////////////////////////////
    createProcessingInstruction();
    QDomElement musicPlayer = createRoot(APPNAME);
    QDomElement download = writeDom(musicPlayer, "download");

    foreach(const MusicDownloadRecord &record, records)
    {
        writeDomElementMutilText(download, "value", MusicXmlAttributes() << MusicXmlAttribute("name", record.m_name)
                                                 << MusicXmlAttribute("size", record.m_size)
                                                 << MusicXmlAttribute("time", record.m_time), record.m_path);
    }
void DownloadBreakPointConfigManager::writeBreakPointConfig(const DownloadBreakPointItems &records)
{
    ///////////////////////////////////////////////////////
    createProcessingInstruction();
    QDomElement player = createRoot(APPNAME);
    QDomElement download = writeDom(player, "breakPoint");

    if(!records.isEmpty())
    {
        writeDomText(download, "url", records.first().m_url);
    }

    foreach(const DownloadBreakPointItem &record, records)
    {
        writeDomElementMutil(download, "value", DownloadXmlAttributes() <<
                                                DownloadXmlAttribute("start", record.m_start) <<
                                                DownloadXmlAttribute("end", record.m_end) <<
                                                DownloadXmlAttribute("ready", record.m_ready) );
    }
void MusicMyDownloadRecordConfigManager::writeDownloadConfig(const MusicDownloadRecord &record)
{
    if( !writeConfig( DOWNLOADINFO_FULL ) )
    {
        return;
    }
    ///////////////////////////////////////////////////////
    createProcessingInstruction();
    QDomElement musicPlayer = createRoot("TTKMusicPlayer");
    QDomElement download = writeDom(musicPlayer, "download");

    for(int i=0; i<record.m_names.count(); ++i)
    {
        writeDomElementMutilText(download, "value", QStringList()<<"name"<<"size",
                                 QList<QVariant>()<<record.m_names[i]<<record.m_sizes[i],
                                 record.m_paths[i]);
    }
    //Write to file
    QTextStream out(m_file);
    m_ddom->save(out, 4);
}
void MusicLocalSongSearchRecordObject::writeSearchConfig(const MusicSearchRecord &record)
{
    if( !writeConfig( MUSICSEARCH_AL ) )
    {
        return;
    }

    ///////////////////////////////////////////////////////
    createProcessingInstruction();
    QDomElement musicPlayer = createRoot("QMusicPlayer");
    QDomElement download = writeDom(musicPlayer, "searchRecord");

    for(int i=0; i<record.m_names.count(); ++i)
    {
        writeDomElementText(download, "value", "name",
                            record.m_names[i], record.m_times[i]);
    }

    //Write to file
    QTextStream out(m_file);
    m_ddom->save(out, 4);
}