[mythtv] Ignore 'The|A|An' prefixes when sorting video directories

Stuart Auchterlonie stuarta at squashedfrog.net
Thu Dec 22 11:23:21 UTC 2016


On 22/12/16 06:01, Jean-Yves Avenard wrote:
> 
> _____________________________
> From: David Hampton <mythtv at dhampton.net <mailto:mythtv at dhampton.net>>
> Sent: Thursday, December 22, 2016 4:32 am
> Subject: [mythtv] Ignore 'The|A|An' prefixes when sorting video directories
> To: <mythtv-dev at mythtv.org <mailto:mythtv-dev at mythtv.org>>
> 
> 
> Hi,
> 
> I'm a longtime (10+ year) user of MythTv, but I think this is my first
> attempt at submitting a patch. The video library code currently ignores
> the 'The|A|An' prefixes when sorting video names, but it doesn't do so
> when sorting directory names. This is most noticeable for me in the TV
> section of my video library where the files are all grouped into
> folders by show name and season. I have a couple of line patch to 0.28
> that adds support for ignoring common prefixes on directories. I wanted
> to run it past this list to see if its acceptable before creating a
> Trac entry. Thanks.
> 
> David
> 
> 
> diff --git a/mythtv/programs/mythfrontend/videolist.cpp
> b/mythtv/programs/mythfrontend/videolist.cpp
> index 7bcbda0..926c0a8 100644
> --- a/mythtv/programs/mythfrontend/videolist.cpp
> +++ b/mythtv/programs/mythfrontend/videolist.cpp
> @@ -195,8 +195,9 @@ struct metadata_path_sort
>  
>      bool sort(const QString &lhs, const QString &rhs)
>      {
> -        QString lhs_comp(lhs);
> -        QString rhs_comp(rhs);
> +        const QRegExp prefixes = QRegExp(QObject::tr("^(The |A |An
> )"));
> +        QString lhs_comp = QString(lhs).remove(prefixes);
> +        QString rhs_comp = QString(rhs).remove(prefixes);
>          if (m_ignore_case)
>          {
>              lhs_comp = lhs_comp.toLower();
> _______________________________________________
> 
> The issue with your patch is that it will only work if you use A or An.
> Any capitalisations will cause it to not work (eg an allied directory)
> You need to remove the strings after performing the comp.to.lower
> operation. 
> 
> 

There is a modifier you can pass to the QRegExp to make it do
case insensitive regexp's which will solve this issue.


Regards
Stuart



More information about the mythtv-dev mailing list