| Summary: | current.xml title parsing problem | ||
|---|---|---|---|
| Product: | [Applications] amarok | Reporter: | Cariad Ilmara <cariad> |
| Component: | general | Assignee: | Amarok Bugs <amarok-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Gentoo Packages | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Cariad Ilmara
2004-04-11 19:01:12 UTC
CVS commit by karchebny: * Proper saving of current.xml * Formatting cleanup. CCMAIL: 79436-done@bugs.kde.org M +23 -24 playlistwidget.cpp 1.166 M +1 -1 playlistwidget.h 1.69 --- kdeextragear-1/amarok/amarok/playlistwidget.cpp #1.165:1.166 @@ -277,5 +277,4 @@ void PlaylistWidget::handleOrder( Reques { item = (PlaylistItem *)itemAtIndex( KApplication::random() % count ); - kdDebug() << "[DBG] pick[2] item " << item << endl; } } @@ -323,9 +322,6 @@ void PlaylistWidget::saveXML( const QStr { //TODO save nextTrack queue - //TODO do the write in one go rather than gradually? - // <berkus>: you can generate dom tree and then let it write down - // (also saves you from making stupid mistakes with raw xml =) - QFile file( path ); + QDomDocument newdoc; if( !file.open( IO_WriteOnly ) ) return; @@ -330,29 +326,34 @@ void PlaylistWidget::saveXML( const QStr if( !file.open( IO_WriteOnly ) ) return; - QTextStream stream( &file ); - const QString body = "<%1>%2</%1>\n"; - const QString open1 = "<item url=\"", open2 = "\">\n"; - const QString close = "</item>\n"; + stream.setEncoding(QTextStream::UnicodeUTF8); stream << "<?xml version=\"1.0\" encoding=\"utf8\"?>\n"; - stream << "<playlist product=\"amaroK\" version=\"1\">\n"; + + QDomElement playlist = newdoc.createElement("playlist"); + playlist.setAttribute("product", "amaroK"); + playlist.setAttribute("version", "1"); + newdoc.appendChild(playlist); for( const PlaylistItem *item = firstChild(); item; item = item->nextSibling() ) { - stream << open1 << item->url().url() << open2; - - //TODO speed up, cache columnNames (if would help), etc. - //NOTE we don't bother storing TrackName as this is based on the URL anyway + QDomElement i = newdoc.createElement("item"); + i.setAttribute("url", item->url().url()); for( int x = 1; x < columns(); ++x ) { if( !item->exactText(x).isEmpty() ) - stream << body.arg( columnText(x), item->exactText(x).replace( '&', "&" ).replace( '<', "<" ) ); + { + QDomElement attr = newdoc.createElement( columnText(x) ); + QDomText t = newdoc.createTextNode( item->exactText(x) ); + attr.appendChild( t ); + i.appendChild( attr ); } - stream << close; } - stream << "</playlist>\n"; + playlist.appendChild(i); + } + + stream << newdoc.toString(); file.close(); } @@ -610,6 +611,4 @@ void PlaylistWidget::activate( QListView m_cachedTrack = item; - kdDebug() << "[DBG] item=" << item << endl; - //tell the engine to play the new track EngineController::instance()->play( item->metaBundle() ); |