[prev in list] [next in list] [prev in thread] [next in thread] 

List:       amarok
Subject:    Re: Patch for Bug #177403: "Amarok does not remove leading blanks
From:       Nicholas Sinlock <isolatedincident () gmail ! com>
Date:       2009-01-12 1:30:25
Message-ID: 496A9D31.7060707 () gmail ! com
[Download RAW message or body]

Lydia Pintscher wrote:
>> I do not have an svn account.  Will you be committing the patch, or do I
>> need to reformat the patch first?
>> Thanks for your help.
>>     
>
> Please reformat the patch and send it to this mailinglist again. Then
> one of the devs will apply it.
> Thanks for working on this :)
>
> Cheers
> Lydia
>
>   
I haven't gotten around to getting an svn account yet, I will shortly.   
However, here's the reformatted patch.diff.  
Lemme know if I missed any rules with it and I'll go fix them.

*Side Note*
By the way, I read the article on formatting and it suggested looking to 
the code for anything that I wasn't sure of.
The problem I ran into was that even in a single file the code can be 
inconsistent.  So I was wondering how I could
find out what is the preferred way?

["patch.diff" (text/plain)]

Index: browsers/playlistbrowser/PodcastModel.cpp
===================================================================
--- browsers/playlistbrowser/PodcastModel.cpp	(revision 906274)
+++ browsers/playlistbrowser/PodcastModel.cpp	(working copy)
@@ -60,9 +60,10 @@
     Meta::PodcastMetaCommon* pmc = static_cast<Meta::PodcastMetaCommon *>( \
index.internalPointer() );  
     bool isChannel = false;
-    QString title;
+    QString title, chTitle;
     QString description;
     KIcon icon;
+    int length;
     bool isOnDisk = false;
     if ( pmc->podcastType() == Meta::ChannelType )
     {
@@ -75,7 +76,34 @@
     else if ( pmc->podcastType() == Meta::EpisodeType )
     {
         Meta::PodcastEpisode *episode = static_cast<Meta::PodcastEpisode *>( \
                index.internalPointer() );
-        title = episode->title();
+	Meta::PodcastChannelPtr ptr = episode->channel();
+	title = episode->title();
+        chTitle = ptr->title();
+	if( !chTitle.isEmpty() )   // ensure that there is a channel title
+	{
+	    if( title.startsWith( chTitle, Qt::CaseInsensitive ) )   // if the episode \
title begins with the channel title... +	        title = title.right( title.length() \
- ( chTitle.length() ) );   // ...remove the channel title from the episode title +	  \
else   // otherwise search for any phrases which are common among the channel title \
and episode title and remove them from the episode title +	    {
+                for( length = chTitle.length()  - 1; length > 0; length-- )
+                {
+                    if( chTitle[length].isSpace() && title.startsWith( chTitle.left( \
length ), Qt::CaseInsensitive ) ) +		    {
+	                title = title.right( title.length() - length ).trimmed();
+			break;
+	            }
+                }
+	    }
+	}
+ 
+	for( length = 0; length < title.length(); length++ ) // remove any extraneous \
characters from the beginning of the episode title such as extra punctuation symbols \
+	{ +	    if( title[length].isLetterOrNumber() )
+	    {
+	        title = title.right( title.length() - ( length - 1 ) );
+		break;
+	    }
+	}
         description = episode->description();
         isChannel = false;
         isOnDisk = !episode->localUrl().isEmpty();
Index: podcasts/PodcastReader.cpp
===================================================================
--- podcasts/PodcastReader.cpp	(revision 906274)
+++ podcasts/PodcastReader.cpp	(working copy)
@@ -220,7 +220,7 @@
                 }
                 else if( QXmlStreamReader::name() == "title")
                 {
-                    m_current->setTitle( m_titleString );
+		    m_current->setTitle( m_titleString.trimmed() );
                     m_titleString.clear();
                 }
                 else if( QXmlStreamReader::name() == "description" )



_______________________________________________
Amarok mailing list
Amarok@kde.org
https://mail.kde.org/mailman/listinfo/amarok


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic