예제 #1
0
/**
\todo document this function
*/
QDomElement GCF::UpdateInfo::toDomElement(QDomDocument doc, bool forThisSystem) const
{
    QDomElement updateE = doc.createElement("Update");

    QDomElement nameE = doc.createElement("Name");
    nameE.appendChild( doc.createTextNode(d->name) );
    updateE.appendChild(nameE);

    QDomElement titleE = doc.createElement("Title");
    titleE.appendChild( doc.createTextNode(d->title) );
    updateE.appendChild(titleE);

    QDomElement sourceE = doc.createElement("Source");
    sourceE.appendChild( doc.createTextNode(d->source) );
    updateE.appendChild(sourceE);

    QDomElement iconE = doc.createElement("Icon");
    iconE.appendChild( doc.createTextNode(d->iconUrl.toString()) );
    updateE.appendChild(iconE);

    QDomElement typeE = doc.createElement("Type");
    typeE.appendChild( doc.createTextNode(d->type) );
    updateE.appendChild(typeE);

    QDomElement forceInstallE = doc.createElement("ForceInstall");
    forceInstallE.appendChild( doc.createTextNode( QVariant(d->forceInstall).toString() ) );
    updateE.appendChild(forceInstallE);

    QDomElement descE = doc.createElement("Description");
    descE.appendChild( doc.createCDATASection(d->description) );
    updateE.appendChild(descE);

    QDomElement releaseE = doc.createElement("Release");
    releaseE.appendChild( doc.createTextNode(d->release.toString()) );
    updateE.appendChild(releaseE);

    QDomElement versionE = doc.createElement("Version");
    versionE.appendChild( doc.createTextNode(d->version) );
    updateE.appendChild(versionE);

    QList<UpdateFileInfo> ufiList;
    if( forThisSystem )
    {
        UpdateFileInfo fileInfo = updateFileForThisSystem();
        ufiList.append(fileInfo);
    }
    else
        ufiList = d->updateFiles;

    for(int j=0; j<ufiList.count(); j++)
    {
        UpdateFileInfo ufi = ufiList[j];
        QDomElement updateFileE = doc.createElement("UpdateFile");
        updateE.appendChild(updateFileE);

        updateFileE.setAttribute("OS", ufi.OS);
        updateFileE.setAttribute("Arch", ufi.Arch);
        updateFileE.appendChild( doc.createTextNode(ufi.UpdateFileURL.toString()) );
    }

    const QList<UpdateInfo>& deps = d->dependencies;
    for(int j=0; j<deps.count(); j++)
    {
        UpdateInfo dep = deps[j];
        QString depStr = QString("%1 [%2]").arg( dep.name() ).arg( dep.version() );

        QDomElement dependsOnE = doc.createElement("DependsOn");
        dependsOnE.appendChild( doc.createTextNode(depStr) );
        updateE.appendChild(dependsOnE);
    }

    return updateE;
}