Changeset View
Changeset View
Standalone View
Standalone View
keduvocdocument/readerwriters/keduvockvtml2reader.cpp
Show All 17 Lines | |||||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "keduvockvtml2reader.h" | 20 | #include "keduvockvtml2reader.h" | ||
21 | 21 | | |||
22 | #include <klocalizedstring.h> | 22 | #include <klocalizedstring.h> | ||
23 | #include <QTextStream> | 23 | #include <QTextStream> | ||
24 | #include <QList> | 24 | #include <QList> | ||
25 | #include <QIODevice> | 25 | #include <QIODevice> | ||
26 | #include <QDir> | ||||
26 | 27 | | |||
27 | #include "keduvocdocument.h" | 28 | #include "keduvocdocument.h" | ||
28 | #include "keduvoclesson.h" | 29 | #include "keduvoclesson.h" | ||
29 | #include "keduvocleitnerbox.h" | 30 | #include "keduvocleitnerbox.h" | ||
30 | #include "keduvocwordtype.h" | 31 | #include "keduvocwordtype.h" | ||
31 | #include "kvtml2defs.h" | 32 | #include "kvtml2defs.h" | ||
32 | #include "keduvockvtmlreader.h" | 33 | #include "keduvockvtmlreader.h" | ||
33 | #include "keduvoccommon_p.h" | 34 | #include "keduvoccommon_p.h" | ||
▲ Show 20 Lines • Show All 328 Lines • ▼ Show 20 Line(s) | 343 | { | |||
362 | currentElement = translationElement.firstChildElement( KVTML_MULTIPLECHOICE ); | 363 | currentElement = translationElement.firstChildElement( KVTML_MULTIPLECHOICE ); | ||
363 | if ( !currentElement.isNull() ) { | 364 | if ( !currentElement.isNull() ) { | ||
364 | readMultipleChoice( currentElement, expr->translation(index) ); | 365 | readMultipleChoice( currentElement, expr->translation(index) ); | ||
365 | } | 366 | } | ||
366 | 367 | | |||
367 | // image | 368 | // image | ||
368 | currentElement = translationElement.firstChildElement( KVTML_IMAGE ); | 369 | currentElement = translationElement.firstChildElement( KVTML_IMAGE ); | ||
369 | if ( !currentElement.isNull() ) { | 370 | if ( !currentElement.isNull() ) { | ||
370 | if (QUrl::fromLocalFile(currentElement.text()).isRelative()) | 371 | QUrl imageUrl(currentElement.text()); | ||
371 | expr->translation(index)->setImageUrl( QUrl (m_doc->url().toString(QUrl::RemoveFilename) + '/' + currentElement.text() ) ); | 372 | if (imageUrl.isLocalFile() && QDir::isRelativePath(imageUrl.toLocalFile())) { | ||
372 | else | 373 | imageUrl = QUrl(m_doc->url().toString(QUrl::RemoveFilename) + imageUrl.toLocalFile()); | ||
373 | expr->translation(index)->setImageUrl( QUrl (currentElement.text() ) ); | 374 | } | ||
375 | expr->translation(index)->setImageUrl(imageUrl); | ||||
374 | } | 376 | } | ||
375 | 377 | | |||
376 | // sound | 378 | // sound | ||
377 | currentElement = translationElement.firstChildElement( KVTML_SOUND ); | 379 | currentElement = translationElement.firstChildElement( KVTML_SOUND ); | ||
378 | if ( !currentElement.isNull() ) { | 380 | if ( !currentElement.isNull() ) { | ||
379 | if (QUrl::fromLocalFile(currentElement.text()).isRelative()) | 381 | QUrl soundUrl(currentElement.text()); | ||
380 | expr->translation(index)->setSoundUrl( QUrl( m_doc->url().toString(QUrl::RemoveFilename) + '/' + currentElement.text() ) ); | 382 | if (soundUrl.isLocalFile() && QDir::isRelativePath(soundUrl.toLocalFile())) { | ||
381 | else | 383 | soundUrl = QUrl(m_doc->url().toString(QUrl::RemoveFilename) + soundUrl.toLocalFile()); | ||
382 | expr->translation(index)->setSoundUrl( QUrl( currentElement.text() ) ); | 384 | } | ||
385 | expr->translation(index)->setSoundUrl(soundUrl); | ||||
383 | } | 386 | } | ||
384 | 387 | | |||
385 | return true; | 388 | return true; | ||
386 | } | 389 | } | ||
387 | 390 | | |||
388 | bool KEduVocKvtml2Reader::readChildLessons( KEduVocLesson* parentLesson, QDomElement &lessonElement ) | 391 | bool KEduVocKvtml2Reader::readChildLessons( KEduVocLesson* parentLesson, QDomElement &lessonElement ) | ||
389 | { | 392 | { | ||
390 | QDomElement currentElement = lessonElement.firstChildElement( KVTML_CONTAINER ); | 393 | QDomElement currentElement = lessonElement.firstChildElement( KVTML_CONTAINER ); | ||
▲ Show 20 Lines • Show All 366 Lines • Show Last 20 Lines |