@ -75,18 +75,18 @@ namespace Amarok
{
{
TQString escapeHTML ( const TQString & s )
TQString escapeHTML ( const TQString & s )
{
{
return TQString ( s ) . tq replace( " & " , " & ; " ). tq replace( " < " , " & lt ; " ). tq replace( " > " , " & gt ; " );
return TQString ( s ) . replace( " & " , " & ; " ). replace( " < " , " & lt ; " ). replace( " > " , " & gt ; " );
// . tq replace( "%", "%25" ) has to be the first(!) one, otherwise we would do things like converting spaces into %20 and then convert them into %25%20
// . replace( "%", "%25" ) has to be the first(!) one, otherwise we would do things like converting spaces into %20 and then convert them into %25%20
}
}
TQString escapeHTMLAttr ( const TQString & s )
TQString escapeHTMLAttr ( const TQString & s )
{
{
return TQString ( s ) . tq replace( " % " , " %25 " ) . tq replace( " ' " , " %27 " ) . tq replace( " \" " , " %22 " ) . tq replace( " # " , " %23 " ) . tq replace( " ? " , " %3F " ) ;
return TQString ( s ) . replace( " % " , " %25 " ) . replace( " ' " , " %27 " ) . replace( " \" " , " %22 " ) . replace( " # " , " %23 " ) . replace( " ? " , " %3F " ) ;
}
}
TQString unescapeHTMLAttr ( const TQString & s )
TQString unescapeHTMLAttr ( const TQString & s )
{
{
return TQString ( s ) . tq replace( " %3F " , " ? " ) . tq replace( " %23 " , " # " ) . tq replace( " %22 " , " \" " ) . tq replace( " %27 " , " ' " ) . tq replace( " %25 " , " % " ) ;
return TQString ( s ) . replace( " %3F " , " ? " ) . replace( " %23 " , " # " ) . replace( " %22 " , " \" " ) . replace( " %27 " , " ' " ) . replace( " %25 " , " % " ) ;
}
}
TQString verboseTimeSince ( const TQDateTime & datetime )
TQString verboseTimeSince ( const TQDateTime & datetime )
@ -146,7 +146,7 @@ namespace Amarok
*/
*/
void albumArtistTrackFromUrl ( TQString url , TQString & artist , TQString & album , TQString & detail )
void albumArtistTrackFromUrl ( TQString url , TQString & artist , TQString & album , TQString & detail )
{
{
if ( ! url . tq contains( " @@@ " ) ) return ;
if ( ! url . contains( " @@@ " ) ) return ;
//KHTML removes the trailing space!
//KHTML removes the trailing space!
if ( url . endsWith ( " @@@ " ) )
if ( url . endsWith ( " @@@ " ) )
url + = ' ' ;
url + = ' ' ;
@ -443,9 +443,9 @@ void ContextBrowser::openURLRequest( const KURL &url )
}
}
else if ( url . protocol ( ) = = " show " )
else if ( url . protocol ( ) = = " show " )
{
{
if ( url . path ( ) . tq contains( " suggestLyric- " ) )
if ( url . path ( ) . contains( " suggestLyric- " ) )
{
{
TQString _url = url . url ( ) . mid ( url . url ( ) . tq find( TQString ( " - " ) ) + 1 ) ;
TQString _url = url . url ( ) . mid ( url . url ( ) . find( TQString ( " - " ) ) + 1 ) ;
debug ( ) < < " Clicked lyrics URL: " < < _url < < endl ;
debug ( ) < < " Clicked lyrics URL: " < < _url < < endl ;
m_dirtyLyricsPage = true ;
m_dirtyLyricsPage = true ;
showLyrics ( _url ) ;
showLyrics ( _url ) ;
@ -503,7 +503,7 @@ void ContextBrowser::openURLRequest( const KURL &url )
}
}
else if ( url . protocol ( ) = = " externalurl " )
else if ( url . protocol ( ) = = " externalurl " )
Amarok : : invokeBrowser ( url . url ( ) . tq replace( TQRegExp ( " ^externalurl: " ) , " http: " ) ) ;
Amarok : : invokeBrowser ( url . url ( ) . replace( TQRegExp ( " ^externalurl: " ) , " http: " ) ) ;
else if ( url . protocol ( ) = = " lastfm " )
else if ( url . protocol ( ) = = " lastfm " )
{
{
@ -547,7 +547,7 @@ void ContextBrowser::openURLRequest( const KURL &url )
else if ( url . protocol ( ) = = " ggartist " )
else if ( url . protocol ( ) = = " ggartist " )
{
{
const TQString url2 = TQString ( " http://www.google.com/musicsearch?q=%1&res=artist " )
const TQString url2 = TQString ( " http://www.google.com/musicsearch?q=%1&res=artist " )
. tqarg ( KURL : : encode_string_no_slash ( unescapeHTMLAttr ( url . path ( ) ) . tq replace( " " , " + " ) , 106 /*utf-8*/ ) ) ;
. tqarg ( KURL : : encode_string_no_slash ( unescapeHTMLAttr ( url . path ( ) ) . replace( " " , " + " ) , 106 /*utf-8*/ ) ) ;
Amarok : : invokeBrowser ( url2 ) ;
Amarok : : invokeBrowser ( url2 ) ;
}
}
@ -558,7 +558,7 @@ void ContextBrowser::openURLRequest( const KURL &url )
else if ( url . protocol ( ) = = " stream " )
else if ( url . protocol ( ) = = " stream " )
{
{
Playlist : : instance ( ) - > insertMedia ( KURL : : fromPathOrURL ( url . url ( ) . tq replace( TQRegExp ( " ^stream: " ) , " http: " ) ) , Playlist : : DefaultOptions ) ;
Playlist : : instance ( ) - > insertMedia ( KURL : : fromPathOrURL ( url . url ( ) . replace( TQRegExp ( " ^stream: " ) , " http: " ) ) , Playlist : : DefaultOptions ) ;
}
}
else if ( url . protocol ( ) = = " compilationdisc " | | url . protocol ( ) = = " albumdisc " )
else if ( url . protocol ( ) = = " compilationdisc " | | url . protocol ( ) = = " albumdisc " )
@ -639,10 +639,10 @@ void ContextBrowser::engineNewMetaData( const MetaBundle& bundle, bool trackChan
if ( MetaBundle ( m_currentURL ) . artist ( ) ! = bundle . artist ( ) )
if ( MetaBundle ( m_currentURL ) . artist ( ) ! = bundle . artist ( ) )
m_dirtyWikiPage = true ;
m_dirtyWikiPage = true ;
// Prepend stream metadata history item to list
// Prepend stream metadata history item to list
if ( ! m_metadataHistory . first ( ) . tq contains( bundle . prettyTitle ( ) ) )
if ( ! m_metadataHistory . first ( ) . contains( bundle . prettyTitle ( ) ) )
{
{
newMetaData = true ;
newMetaData = true ;
const TQString timeString = KGlobal : : locale ( ) - > formatTime ( TQTime : : currentTime ( ) ) . tq replace( " " , " " ) ; // don't break over lines
const TQString timeString = KGlobal : : locale ( ) - > formatTime ( TQTime : : currentTime ( ) ) . replace( " " , " " ) ; // don't break over lines
m_metadataHistory . prepend ( TQString ( " <td valign='top'> " + timeString + " </td><td align='left'> " + escapeHTML ( bundle . prettyTitle ( ) ) + " </td> " ) ) ;
m_metadataHistory . prepend ( TQString ( " <td valign='top'> " + timeString + " </td><td align='left'> " + escapeHTML ( bundle . prettyTitle ( ) ) + " </td> " ) ) ;
}
}
@ -676,7 +676,7 @@ void ContextBrowser::engineNewMetaData( const MetaBundle& bundle, bool trackChan
// look for the cue file that matches the media file played first
// look for the cue file that matches the media file played first
TQString path = bundle . url ( ) . path ( ) ;
TQString path = bundle . url ( ) . path ( ) ;
TQString cueFile = path . left ( path . tq findRev( ' . ' ) ) + " .cue " ;
TQString cueFile = path . left ( path . findRev( ' . ' ) ) + " .cue " ;
m_cuefile - > setCueFileName ( cueFile ) ;
m_cuefile - > setCueFileName ( cueFile ) ;
@ -713,7 +713,7 @@ void ContextBrowser::engineNewMetaData( const MetaBundle& bundle, bool trackChan
{
{
line = line . mid ( 5 ) . remove ( ' " ' ) ;
line = line . mid ( 5 ) . remove ( ' " ' ) ;
if ( line . tq contains( bundle . filename ( ) , false ) )
if ( line . contains( bundle . filename ( ) , false ) )
{
{
cueFile = dir . filePath ( * it ) ;
cueFile = dir . filePath ( * it ) ;
foundCueFile = true ;
foundCueFile = true ;
@ -799,7 +799,7 @@ void ContextBrowser::saveHtmlData()
TQTextStream stream ( & exportedDocument ) ;
TQTextStream stream ( & exportedDocument ) ;
stream . setEncoding ( TQTextStream : : UnicodeUTF8 ) ;
stream . setEncoding ( TQTextStream : : UnicodeUTF8 ) ;
stream < < m_HTMLSource // the pure html data..
stream < < m_HTMLSource // the pure html data..
. tq replace( " <html> " ,
. replace( " <html> " ,
TQString ( " <html><head><style type= \" text/css \" > "
TQString ( " <html><head><style type= \" text/css \" > "
" %1</style></head> " )
" %1</style></head> " )
. tqarg ( HTMLView : : loadStyleSheet ( ) ) ) ; // and the
. tqarg ( HTMLView : : loadStyleSheet ( ) ) ) ; // and the
@ -931,7 +931,7 @@ void ContextBrowser::slotContextMenu( const TQString& urlString, const TQPoint&
}
}
else if ( url . protocol ( ) = = " stream " )
else if ( url . protocol ( ) = = " stream " )
{
{
url = KURL : : fromPathOrURL ( url . url ( ) . tq replace( TQRegExp ( " ^stream: " ) , " http: " ) ) ;
url = KURL : : fromPathOrURL ( url . url ( ) . replace( TQRegExp ( " ^stream: " ) , " http: " ) ) ;
urls = KURL : : List ( url ) ;
urls = KURL : : List ( url ) ;
menu . insertTitle ( i18n ( " Podcast " ) , TITLE ) ;
menu . insertTitle ( i18n ( " Podcast " ) , TITLE ) ;
menu . insertItem ( SmallIconSet ( Amarok : : icon ( " files " ) ) , i18n ( " &Load " ) , MAKE ) ;
menu . insertItem ( SmallIconSet ( Amarok : : icon ( " files " ) ) , i18n ( " &Load " ) , MAKE ) ;
@ -1601,13 +1601,13 @@ CurrentTrackJob::showHomeByAlbums()
" <div class='album-body' style='display:%9;' id='IDP%10'> \n " )
" <div class='album-body' style='display:%9;' id='IDP%10'> \n " )
. args ( TQStringList ( )
. args ( TQStringList ( )
< < TQString : : number ( i )
< < TQString : : number ( i )
< < pcb . link ( ) . url ( ) . tq replace( TQRegExp ( " ^http: " ) , " externalurl: " )
< < pcb . link ( ) . url ( ) . replace( TQRegExp ( " ^http: " ) , " externalurl: " )
< < escapeHTMLAttr ( imageAttr )
< < escapeHTMLAttr ( imageAttr )
< < escapeHTMLAttr ( image )
< < escapeHTMLAttr ( image )
< < escapeHTML ( ep . duration ( ) ? MetaBundle : : prettyTime ( ep . duration ( ) ) : TQString ( " " ) )
< < escapeHTML ( ep . duration ( ) ? MetaBundle : : prettyTime ( ep . duration ( ) ) : TQString ( " " ) )
< < ( ep . localUrl ( ) . isValid ( )
< < ( ep . localUrl ( ) . isValid ( )
? ep . localUrl ( ) . url ( )
? ep . localUrl ( ) . url ( )
: ep . url ( ) . url ( ) . tq replace( TQRegExp ( " ^http: " ) , " stream: " ) )
: ep . url ( ) . url ( ) . replace( TQRegExp ( " ^http: " ) , " stream: " ) )
< < escapeHTML ( pcb . title ( ) + " : " + ep . title ( ) )
< < escapeHTML ( pcb . title ( ) + " : " + ep . title ( ) )
< < escapeHTML ( date )
< < escapeHTML ( date )
< < " none "
< < " none "
@ -1772,7 +1772,7 @@ void CurrentTrackJob::showLastFm( const MetaBundle ¤tTrack )
newUrls . append ( & titleUrl ) ;
newUrls . append ( & titleUrl ) ;
for ( TQString * url = newUrls . first ( ) ; url ; url = newUrls . next ( ) )
for ( TQString * url = newUrls . first ( ) ; url ; url = newUrls . next ( ) )
url - > tq replace( TQRegExp ( " ^http: " ) , " externalurl: " ) ;
url - > replace( TQRegExp ( " ^http: " ) , " externalurl: " ) ;
const TQString skipIcon = KGlobal : : iconLoader ( ) - > iconPath ( Amarok : : icon ( " next " ) , - KIcon : : SizeSmallMedium ) ;
const TQString skipIcon = KGlobal : : iconLoader ( ) - > iconPath ( Amarok : : icon ( " next " ) , - KIcon : : SizeSmallMedium ) ;
const TQString loveIcon = KGlobal : : iconLoader ( ) - > iconPath ( Amarok : : icon ( " love " ) , - KIcon : : SizeSmallMedium ) ;
const TQString loveIcon = KGlobal : : iconLoader ( ) - > iconPath ( Amarok : : icon ( " love " ) , - KIcon : : SizeSmallMedium ) ;
@ -1988,7 +1988,7 @@ void CurrentTrackJob::showPodcast( const MetaBundle ¤tTrack )
< < escapeHTML ( pcb . title ( ) )
< < escapeHTML ( pcb . title ( ) )
< < escapeHTML ( peb . title ( ) )
< < escapeHTML ( peb . title ( ) )
< < ( pcb . link ( ) . isValid ( )
< < ( pcb . link ( ) . isValid ( )
? pcb . link ( ) . url ( ) . tq replace( TQRegExp ( " ^http: " ) , " externalurl: " )
? pcb . link ( ) . url ( ) . replace( TQRegExp ( " ^http: " ) , " externalurl: " )
: " current://track " )
: " current://track " )
< < image
< < image
< < imageAttr
< < imageAttr
@ -2064,7 +2064,7 @@ void CurrentTrackJob::showPodcast( const MetaBundle ¤tTrack )
< < escapeHTML ( ep . duration ( ) ? MetaBundle : : prettyTime ( ep . duration ( ) ) : TQString ( " " ) )
< < escapeHTML ( ep . duration ( ) ? MetaBundle : : prettyTime ( ep . duration ( ) ) : TQString ( " " ) )
< < ( ep . localUrl ( ) . isValid ( )
< < ( ep . localUrl ( ) . isValid ( )
? ep . localUrl ( ) . url ( )
? ep . localUrl ( ) . url ( )
: ep . url ( ) . url ( ) . tq replace( TQRegExp ( " ^http: " ) , " stream: " ) )
: ep . url ( ) . url ( ) . replace( TQRegExp ( " ^http: " ) , " stream: " ) )
< < escapeHTML ( ep . title ( ) )
< < escapeHTML ( ep . title ( ) )
< < escapeHTML ( date )
< < escapeHTML ( date )
< < ( peb . url ( ) = = ep . url ( ) ? " block " : " none " )
< < ( peb . url ( ) = = ep . url ( ) ? " block " : " none " )
@ -3256,9 +3256,9 @@ void ContextBrowser::showLyrics( const TQString &url )
TQString title = EngineController : : instance ( ) - > bundle ( ) . title ( ) ;
TQString title = EngineController : : instance ( ) - > bundle ( ) . title ( ) ;
TQString artist = EngineController : : instance ( ) - > bundle ( ) . artist ( ) ;
TQString artist = EngineController : : instance ( ) - > bundle ( ) . artist ( ) ;
if ( title . tq contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
if ( title . contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
title = title . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
title = title . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
if ( artist . tq contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
if ( artist . contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
artist = artist . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
artist = artist . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
if ( title . isEmpty ( ) ) {
if ( title . isEmpty ( ) ) {
@ -3266,15 +3266,15 @@ void ContextBrowser::showLyrics( const TQString &url )
The fact that it often ( but not always ) has artist name together , can be bad ,
The fact that it often ( but not always ) has artist name together , can be bad ,
but at least the user will hopefully get nice suggestions . */
but at least the user will hopefully get nice suggestions . */
TQString prettyTitle = EngineController : : instance ( ) - > bundle ( ) . prettyTitle ( ) ;
TQString prettyTitle = EngineController : : instance ( ) - > bundle ( ) . prettyTitle ( ) ;
int h = prettyTitle . tq find( ' - ' ) ;
int h = prettyTitle . find( ' - ' ) ;
if ( h ! = - 1 )
if ( h ! = - 1 )
{
{
title = prettyTitle . mid ( h + 1 ) . stripWhiteSpace ( ) ;
title = prettyTitle . mid ( h + 1 ) . stripWhiteSpace ( ) ;
if ( title . tq contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
if ( title . contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
title = title . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
title = title . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
if ( artist . isEmpty ( ) ) {
if ( artist . isEmpty ( ) ) {
artist = prettyTitle . mid ( 0 , h ) . stripWhiteSpace ( ) ;
artist = prettyTitle . mid ( 0 , h ) . stripWhiteSpace ( ) ;
if ( artist . tq contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
if ( artist . contains( " PREVIEW: buy it at www.magnatune.com " , true ) > = 1 )
artist = artist . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
artist = artist . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
}
}
@ -3399,10 +3399,10 @@ ContextBrowser::lyricsResult( TQCString cXmlDoc, bool cached ) //SLOT
if ( el . attribute ( " add_url " ) . isEmpty ( ) )
if ( el . attribute ( " add_url " ) . isEmpty ( ) )
{
{
m_lyricAddUrl = spec . readPathEntry ( " add_url " ) ;
m_lyricAddUrl = spec . readPathEntry ( " add_url " ) ;
m_lyricAddUrl . tq replace( " MAGIC_ARTIST " , KURL : : encode_string_no_slash ( EngineController : : instance ( ) - > bundle ( ) . artist ( ) ) ) ;
m_lyricAddUrl . replace( " MAGIC_ARTIST " , KURL : : encode_string_no_slash ( EngineController : : instance ( ) - > bundle ( ) . artist ( ) ) ) ;
m_lyricAddUrl . tq replace( " MAGIC_TITLE " , KURL : : encode_string_no_slash ( EngineController : : instance ( ) - > bundle ( ) . title ( ) ) ) ;
m_lyricAddUrl . replace( " MAGIC_TITLE " , KURL : : encode_string_no_slash ( EngineController : : instance ( ) - > bundle ( ) . title ( ) ) ) ;
m_lyricAddUrl . tq replace( " MAGIC_ALBUM " , KURL : : encode_string_no_slash ( EngineController : : instance ( ) - > bundle ( ) . album ( ) ) ) ;
m_lyricAddUrl . replace( " MAGIC_ALBUM " , KURL : : encode_string_no_slash ( EngineController : : instance ( ) - > bundle ( ) . album ( ) ) ) ;
m_lyricAddUrl . tq replace( " MAGIC_YEAR " , KURL : : encode_string_no_slash ( TQString : : number ( EngineController : : instance ( ) - > bundle ( ) . year ( ) ) ) ) ;
m_lyricAddUrl . replace( " MAGIC_YEAR " , KURL : : encode_string_no_slash ( TQString : : number ( EngineController : : instance ( ) - > bundle ( ) . year ( ) ) ) ) ;
}
}
else
else
m_lyricAddUrl = el . attribute ( " add_url " ) ;
m_lyricAddUrl = el . attribute ( " add_url " ) ;
@ -3430,11 +3430,11 @@ ContextBrowser::lyricsResult( TQCString cXmlDoc, bool cached ) //SLOT
}
}
}
}
lyrics + = i18n ( " <p>You can <a href= \" %1 \" >search for the lyrics</a> on the Web.</p> " )
lyrics + = i18n ( " <p>You can <a href= \" %1 \" >search for the lyrics</a> on the Web.</p> " )
. tqarg ( TQString ( m_lyricSearchUrl ) . tq replace( TQRegExp ( " ^http: " ) , " externalurl: " ) ) ;
. tqarg ( TQString ( m_lyricSearchUrl ) . replace( TQRegExp ( " ^http: " ) , " externalurl: " ) ) ;
}
}
else {
else {
lyrics = el . text ( ) ;
lyrics = el . text ( ) ;
lyrics . tq replace( " \n " , " <br/> \n " ) ; // Plaintext -> HTML
lyrics . replace( " \n " , " <br/> \n " ) ; // Plaintext -> HTML
const TQString title = el . attribute ( " title " ) ;
const TQString title = el . attribute ( " title " ) ;
const TQString artist = el . attribute ( " artist " ) ;
const TQString artist = el . attribute ( " artist " ) ;
@ -3740,7 +3740,7 @@ TQString
ContextBrowser : : wikiURL ( const TQString & item )
ContextBrowser : : wikiURL ( const TQString & item )
{
{
// add any special characters to be replaced here
// add any special characters to be replaced here
TQString wStr = TQString ( item ) . tq replace( " / " , " " ) ;
TQString wStr = TQString ( item ) . replace( " / " , " " ) ;
return TQString ( " http://%1.wikipedia.org/wiki/ " ) . tqarg ( wikiLocale ( ) )
return TQString ( " http://%1.wikipedia.org/wiki/ " ) . tqarg ( wikiLocale ( ) )
+ KURL : : encode_string_no_slash ( wStr , 106 /*utf-8*/ ) ;
+ KURL : : encode_string_no_slash ( wStr , 106 /*utf-8*/ ) ;
@ -3789,7 +3789,7 @@ ContextBrowser::showLabelsDialog()
foreach ( allLabels )
foreach ( allLabels )
{
{
TQCheckListItem * item = new TQCheckListItem ( m_labelListView , * it , TQCheckListItem : : CheckBox ) ;
TQCheckListItem * item = new TQCheckListItem ( m_labelListView , * it , TQCheckListItem : : CheckBox ) ;
item - > setOn ( trackLabels . tq contains( * it ) ) ;
item - > setOn ( trackLabels . contains( * it ) ) ;
}
}
if ( dialog - > exec ( ) = = TQDialog : : Accepted )
if ( dialog - > exec ( ) = = TQDialog : : Accepted )
{
{
@ -3936,9 +3936,9 @@ void ContextBrowser::showWikipedia( const TQString &url, bool fromHistory, bool
}
}
//Hack to make wiki searches work with magnatune preview tracks
//Hack to make wiki searches work with magnatune preview tracks
if ( tmpWikiStr . tq contains( " PREVIEW: buy it at www.magnatune.com " ) > = 1 ) {
if ( tmpWikiStr . contains( " PREVIEW: buy it at www.magnatune.com " ) > = 1 ) {
tmpWikiStr = tmpWikiStr . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
tmpWikiStr = tmpWikiStr . remove ( " (PREVIEW: buy it at www.magnatune.com) " ) ;
int index = tmpWikiStr . tq find( ' - ' ) ;
int index = tmpWikiStr . find( ' - ' ) ;
if ( index ! = - 1 ) {
if ( index ! = - 1 ) {
tmpWikiStr = tmpWikiStr . left ( index - 1 ) ;
tmpWikiStr = tmpWikiStr . left ( index - 1 ) ;
}
}
@ -3988,7 +3988,7 @@ void ContextBrowser::showWikipedia( const TQString &url, bool fromHistory, bool
m_wikiToolBar - > setItemEnabled ( WIKI_BACK , m_wikiBackHistory . size ( ) > 1 ) ;
m_wikiToolBar - > setItemEnabled ( WIKI_BACK , m_wikiBackHistory . size ( ) > 1 ) ;
m_wikiToolBar - > setItemEnabled ( WIKI_FORWARD , m_wikiForwardHistory . size ( ) > 0 ) ;
m_wikiToolBar - > setItemEnabled ( WIKI_FORWARD , m_wikiForwardHistory . size ( ) > 0 ) ;
m_wikiBaseUrl = m_wikiCurrentUrl . mid ( 0 , m_wikiCurrentUrl . tq find( " wiki/ " ) ) ;
m_wikiBaseUrl = m_wikiCurrentUrl . mid ( 0 , m_wikiCurrentUrl . find( " wiki/ " ) ) ;
m_wikiJob = KIO : : storedGet ( m_wikiCurrentUrl , false , false ) ;
m_wikiJob = KIO : : storedGet ( m_wikiCurrentUrl , false , false ) ;
Amarok : : StatusBar : : instance ( ) - > newProgressOperation ( m_wikiJob )
Amarok : : StatusBar : : instance ( ) - > newProgressOperation ( m_wikiJob )
@ -4136,11 +4136,11 @@ ContextBrowser::wikiResult( KIO::Job* job ) //SLOT
m_wikiToolBar - > setItemEnabled ( WIKI_BROWSER , true ) ;
m_wikiToolBar - > setItemEnabled ( WIKI_BROWSER , true ) ;
// FIXME: Get a safer Regexp here, to match only inside of <head> </head> at least.
// FIXME: Get a safer Regexp here, to match only inside of <head> </head> at least.
if ( m_wiki . tq contains( " charset=utf-8 " ) ) {
if ( m_wiki . contains( " charset=utf-8 " ) ) {
m_wiki = TQString : : fromUtf8 ( storedJob - > data ( ) . data ( ) , storedJob - > data ( ) . size ( ) ) ;
m_wiki = TQString : : fromUtf8 ( storedJob - > data ( ) . data ( ) , storedJob - > data ( ) . size ( ) ) ;
}
}
if ( m_wiki . tq find( " var wgArticleId = 0 " ) ! = - 1 )
if ( m_wiki . find( " var wgArticleId = 0 " ) ! = - 1 )
{
{
debug ( ) < < " Article not found. " < < endl ;
debug ( ) < < " Article not found. " < < endl ;
@ -4166,65 +4166,65 @@ ContextBrowser::wikiResult( KIO::Job* job ) //SLOT
}
}
//remove the new-lines and tabs(replace with spaces IS needed).
//remove the new-lines and tabs(replace with spaces IS needed).
m_wiki . tq replace( " \n " , " " ) ;
m_wiki . replace( " \n " , " " ) ;
m_wiki . tq replace( " \t " , " " ) ;
m_wiki . replace( " \t " , " " ) ;
m_wikiLanguages = TQString ( ) ;
m_wikiLanguages = TQString ( ) ;
// Get the available language list
// Get the available language list
if ( m_wiki . tq find( " <div id= \" p-lang \" class= \" portlet \" > " ) ! = - 1 )
if ( m_wiki . find( " <div id= \" p-lang \" class= \" portlet \" > " ) ! = - 1 )
{
{
m_wikiLanguages = m_wiki . mid ( m_wiki . tq find( " <div id= \" p-lang \" class= \" portlet \" > " ) ) ;
m_wikiLanguages = m_wiki . mid ( m_wiki . find( " <div id= \" p-lang \" class= \" portlet \" > " ) ) ;
m_wikiLanguages = m_wikiLanguages . mid ( m_wikiLanguages . tq find( " <ul> " ) ) ;
m_wikiLanguages = m_wikiLanguages . mid ( m_wikiLanguages . find( " <ul> " ) ) ;
m_wikiLanguages = m_wikiLanguages . mid ( 0 , m_wikiLanguages . tq find( " </div> " ) ) ;
m_wikiLanguages = m_wikiLanguages . mid ( 0 , m_wikiLanguages . find( " </div> " ) ) ;
}
}
TQString copyright ;
TQString copyright ;
TQString copyrightMark = " <li id= \" f-copyright \" > " ;
TQString copyrightMark = " <li id= \" f-copyright \" > " ;
if ( m_wiki . tq find( copyrightMark ) ! = - 1 )
if ( m_wiki . find( copyrightMark ) ! = - 1 )
{
{
copyright = m_wiki . mid ( m_wiki . tq find( copyrightMark ) + copyrightMark . length ( ) ) ;
copyright = m_wiki . mid ( m_wiki . find( copyrightMark ) + copyrightMark . length ( ) ) ;
copyright = copyright . mid ( 0 , copyright . tq find( " </li> " ) ) ;
copyright = copyright . mid ( 0 , copyright . find( " </li> " ) ) ;
copyright . tq replace( " <br /> " , TQString ( ) ) ;
copyright . replace( " <br /> " , TQString ( ) ) ;
//only one br at the beginning
//only one br at the beginning
copyright . prepend ( " <br /> " ) ;
copyright . prepend ( " <br /> " ) ;
}
}
// Ok lets remove the top and bottom parts of the page
// Ok lets remove the top and bottom parts of the page
m_wiki = m_wiki . mid ( m_wiki . tq find( " <h1 id= \" firstHeading \" class= \" firstHeading \" > " ) ) ;
m_wiki = m_wiki . mid ( m_wiki . find( " <h1 id= \" firstHeading \" class= \" firstHeading \" > " ) ) ;
m_wiki = m_wiki . mid ( 0 , m_wiki . tq find( " <div class= \" printfooter \" > " ) ) ;
m_wiki = m_wiki . mid ( 0 , m_wiki . find( " <div class= \" printfooter \" > " ) ) ;
// Adding back license information
// Adding back license information
m_wiki + = copyright ;
m_wiki + = copyright ;
m_wiki . append ( " </div> " ) ;
m_wiki . append ( " </div> " ) ;
m_wiki . tq replace( TQRegExp ( " <h3 id= \" siteSub \" >[^<]*</h3> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <h3 id= \" siteSub \" >[^<]*</h3> " ) , TQString ( ) ) ;
m_wiki . tq replace( TQRegExp ( " <span class= \" editsection \" [^>]*>[^<]*<[^>]*>[^<]*<[^>]*>[^<]*</span> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <span class= \" editsection \" [^>]*>[^<]*<[^>]*>[^<]*<[^>]*>[^<]*</span> " ) , TQString ( ) ) ;
m_wiki . tq replace( TQRegExp ( " <a href= \" [^ \" ]* \" class= \" new \" [^>]*>([^<]*)</a> " ) , " \\ 1 " ) ;
m_wiki . replace( TQRegExp ( " <a href= \" [^ \" ]* \" class= \" new \" [^>]*>([^<]*)</a> " ) , " \\ 1 " ) ;
// Remove anything inside of a class called urlexpansion, as it's pointless for us
// Remove anything inside of a class called urlexpansion, as it's pointless for us
m_wiki . tq replace( TQRegExp ( " <span class= *'urlexpansion'>[^(]*[(][^)]*[)]</span> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <span class= *'urlexpansion'>[^(]*[(][^)]*[)]</span> " ) , TQString ( ) ) ;
// Remove hidden table rows as well
// Remove hidden table rows as well
TQRegExp hidden ( " <tr *class= *[ \" \' ]hiddenStructure[ \" \' ]>.*</tr> " , false ) ;
TQRegExp hidden ( " <tr *class= *[ \" \' ]hiddenStructure[ \" \' ]>.*</tr> " , false ) ;
hidden . setMinimal ( true ) ; //greedy behaviour wouldn't be any good!
hidden . setMinimal ( true ) ; //greedy behaviour wouldn't be any good!
m_wiki . tq replace( hidden , TQString ( ) ) ;
m_wiki . replace( hidden , TQString ( ) ) ;
// we want to keep our own style (we need to modify the stylesheet a bit to handle things nicely)
// we want to keep our own style (we need to modify the stylesheet a bit to handle things nicely)
m_wiki . tq replace( TQRegExp ( " style= * \" [^ \" ]* \" " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " style= * \" [^ \" ]* \" " ) , TQString ( ) ) ;
m_wiki . tq replace( TQRegExp ( " class= * \" [^ \" ]* \" " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " class= * \" [^ \" ]* \" " ) , TQString ( ) ) ;
// let's remove the form elements, we don't want them.
// let's remove the form elements, we don't want them.
m_wiki . tq replace( TQRegExp ( " <input[^>]*> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <input[^>]*> " ) , TQString ( ) ) ;
m_wiki . tq replace( TQRegExp ( " <select[^>]*> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <select[^>]*> " ) , TQString ( ) ) ;
m_wiki . tq replace( " </select> \n " , TQString ( ) ) ;
m_wiki . replace( " </select> \n " , TQString ( ) ) ;
m_wiki . tq replace( TQRegExp ( " <option[^>]*> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <option[^>]*> " ) , TQString ( ) ) ;
m_wiki . tq replace( " </option> \n " , TQString ( ) ) ;
m_wiki . replace( " </option> \n " , TQString ( ) ) ;
m_wiki . tq replace( TQRegExp ( " <textarea[^>]*> " ) , TQString ( ) ) ;
m_wiki . replace( TQRegExp ( " <textarea[^>]*> " ) , TQString ( ) ) ;
m_wiki . tq replace( " </textarea> " , TQString ( ) ) ;
m_wiki . replace( " </textarea> " , TQString ( ) ) ;
//first we convert all the links with protocol to external, as they should all be External Links.
//first we convert all the links with protocol to external, as they should all be External Links.
m_wiki . tq replace( TQRegExp ( " href= * \" http: " ) , " href= \" externalurl: " ) ;
m_wiki . replace( TQRegExp ( " href= * \" http: " ) , " href= \" externalurl: " ) ;
m_wiki . tq replace( TQRegExp ( " href= * \" / " ) , " href= \" " + m_wikiBaseUrl ) ;
m_wiki . replace( TQRegExp ( " href= * \" / " ) , " href= \" " + m_wikiBaseUrl ) ;
m_wiki . tq replace( TQRegExp ( " href= * \" # " ) , " href= \" " + m_wikiCurrentUrl + ' # ' ) ;
m_wiki . replace( TQRegExp ( " href= * \" # " ) , " href= \" " + m_wikiCurrentUrl + ' # ' ) ;
m_HTMLSource = " <html><body> \n " ;
m_HTMLSource = " <html><body> \n " ;
m_HTMLSource . append (
m_HTMLSource . append (
@ -4271,7 +4271,7 @@ ContextBrowser::coverFetched( const TQString &artist, const TQString &album ) //
! m_browseArtists )
! m_browseArtists )
{
{
m_dirtyCurrentTrackPage = true ;
m_dirtyCurrentTrackPage = true ;
if ( m_shownAlbums . tq contains( album ) )
if ( m_shownAlbums . contains( album ) )
showCurrentTrack ( ) ;
showCurrentTrack ( ) ;
return ;
return ;
}
}
@ -4297,7 +4297,7 @@ ContextBrowser::coverRemoved( const TQString &artist, const TQString &album ) //
! m_browseArtists )
! m_browseArtists )
{
{
m_dirtyCurrentTrackPage = true ;
m_dirtyCurrentTrackPage = true ;
if ( m_shownAlbums . tq contains( album ) )
if ( m_shownAlbums . contains( album ) )
showCurrentTrack ( ) ;
showCurrentTrack ( ) ;
return ;
return ;
}
}
@ -4363,7 +4363,7 @@ void ContextBrowser::tagsChanged( const MetaBundle &bundle ) //SLOT
{
{
const MetaBundle & currentTrack = EngineController : : instance ( ) - > bundle ( ) ;
const MetaBundle & currentTrack = EngineController : : instance ( ) - > bundle ( ) ;
if ( ! m_shownAlbums . tq contains( bundle . album ( ) ) & & m_artist ! = bundle . artist ( ) )
if ( ! m_shownAlbums . contains( bundle . album ( ) ) & & m_artist ! = bundle . artist ( ) )
{
{
if ( currentTrack . artist ( ) . isEmpty ( ) & & currentTrack . album ( ) . isEmpty ( ) )
if ( currentTrack . artist ( ) . isEmpty ( ) & & currentTrack . album ( ) . isEmpty ( ) )
return ;
return ;
@ -4379,7 +4379,7 @@ void ContextBrowser::tagsChanged( const TQString &oldArtist, const TQString &old
{
{
const MetaBundle & currentTrack = EngineController : : instance ( ) - > bundle ( ) ;
const MetaBundle & currentTrack = EngineController : : instance ( ) - > bundle ( ) ;
if ( ! m_shownAlbums . tq contains( oldAlbum ) & & m_artist ! = oldArtist )
if ( ! m_shownAlbums . contains( oldAlbum ) & & m_artist ! = oldArtist )
{
{
if ( currentTrack . artist ( ) . isEmpty ( ) & & currentTrack . album ( ) . isEmpty ( ) )
if ( currentTrack . artist ( ) . isEmpty ( ) & & currentTrack . album ( ) . isEmpty ( ) )
return ;
return ;
@ -4492,7 +4492,7 @@ ContextBrowser::expandURL( const KURL &url )
}
}
else if ( protocol = = " stream " ) {
else if ( protocol = = " stream " ) {
urls + = KURL : : fromPathOrURL ( url . url ( ) . tq replace( TQRegExp ( " ^stream: " ) , " http: " ) ) ;
urls + = KURL : : fromPathOrURL ( url . url ( ) . replace( TQRegExp ( " ^stream: " ) , " http: " ) ) ;
}
}
return urls ;
return urls ;