Fix save image/sound files to relative path in kvtml2writer

Review Request #129992 - Created March 6, 2017 and submitted

Information
Xin Huang
libkeduvocdocument
master
Reviewers
kdeedu

bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEduVocTranslation* translation )
{
    // ...
    // sound
    if ( !translation->soundUrl().isEmpty() ) {
        QString urlString;
        qDebug() << "soundUrl" << translation->soundUrl();
        if ( KIO::upUrl(m_doc->url().adjusted(QUrl::RemoveFilename)).isParentOf( translation->soundUrl()) ) {
            // try to save as relative url
            urlString = m_doc->url().toString(QUrl::RemoveFilename) + '/' + translation->soundUrl().toString();     // <------------ HERE
        } else {
            urlString =  translation->soundUrl().url();
        }
        qDebug() << "urlString" << urlString;
        translationElement.appendChild( newTextElement( KVTML_SOUND, urlString ) );
    }

Notice the line marked: The soundUrl of a translation parley passed in is "file:///path/to/kvtml/kvtmlfilename_files/File:En-us-Word.ogg", and the m_doc->url() is "file:///path/to/kvtml/kvtmlfilename.kvtml". By the old logic saving as relative url, the result will be "file:///path/to/kvtml/file:///path/to/kvtml/kvtmlfilename_files/Files:En-us-word.ogg".


  

Issues

  • 0
  • 1
  • 0
  • 1
Description From Last Updated
Xin Huang
Albert Astals Cid
Xin Huang
Xin Huang
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit c70c1433528bc75e934960dd114dd8beae626656 by Albert Astals Cid on behalf of Xin Huang to branch Applications/17.04.
Loading...