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

David Hampton mythtv at dhampton.net
Wed Dec 21 17:32:08 UTC 2016


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();


More information about the mythtv-dev mailing list