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

Jean-Yves Avenard jyavenard at gmail.com
Thu Dec 22 06:01:51 UTC 2016



		_____________________________
From: David Hampton <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>


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. 

	
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20161222/f8fbc9c0/attachment.html>


More information about the mythtv-dev mailing list