Someone produced a patch to ensure that the artists are sorted
regardless of case and ignoring any leading "The", which I found
really useful - Hate having all my music archived under the "T"
section!

Anyway in case anyone else prefers this format, I've re-attached the
patch, thanks to the original poster.
diff -Naur mythmusic/mythmusic/metadata.cpp mythmusic2/mythmusic/metadata.cpp
--- mythmusic/mythmusic/metadata.cpp	2005-02-10 07:20:39.000000000 +0000
+++ mythmusic2/mythmusic/metadata.cpp	2005-02-15 17:40:42.301763784 +0000
@@ -441,7 +441,15 @@
     else if (field == "splitartist")
     {
         bool set = false;
-        QString firstchar = FormatArtist().left(1).upper();
+        QString firstchar;
+        if (FormatArtist().left(4).lower() =="the ")
+        {
+            firstchar = FormatArtist().mid(4,1).upper();
+        }
+        else
+        {
+            firstchar = FormatArtist().left(1).upper();
+        }
         for (int i = 0; i < kSplitArray_Max; i++)
         {
             if (splitArray[i].testStr.contains(firstchar))
@@ -752,6 +760,8 @@
     root_node->sort();
 
     bool something_changed;
+    QString Title1;
+    QString Title2;
     
     //  sort top level nodes
     
@@ -765,7 +775,24 @@
         something_changed = false;
         for(uint i = 0; i < top_nodes.count() - 1;)
         {
-            if(qstrcmp(top_nodes.at(i)->getTitle(), top_nodes.at(i+1)->getTitle()) > 0)
+            Title1 = top_nodes.at(i)->getTitle();
+            Title2 = top_nodes.at(i+1)->getTitle();
+             
+            // Transform title, so we get case insensitive ordering of nodes:
+            Title1 = Title1.lower();
+            Title2 = Title2.lower();
+            // Remove any prepending "The ":
+            if (Title1.left(4)=="the ")
+            {
+                Title1 = Title1.mid(4);
+            }
+
+            if (Title2.left(4)=="the ")
+            {
+                Title2 = Title2.mid(4);
+            }
+
+            if(qstrcmp(Title1, Title2) > 0)
             {
                 something_changed = true;
                 MusicNode *temp = top_nodes.take(i + 1);
@@ -1190,6 +1217,8 @@
                                     Metadata *inserter, uint depth)
 {
     QString a_field = "";
+    QString a_lowercase_field = "";
+    QString a_title = "";
 
     //
     //  Search and create from my node downards
@@ -1203,11 +1232,28 @@
     else
     {
         inserter->getField(tree_levels, &a_field, m_paths, m_startdir, depth);
+
+        // Get field contents in lowercase without prepending "the ":
+        a_lowercase_field = a_field.lower();
+        if (a_lowercase_field.left(4) == "the ")
+        {
+            a_lowercase_field = a_lowercase_field.mid(4);
+        }
+        
         QPtrListIterator<MusicNode> iter(my_subnodes);
         MusicNode *search;
         while( (search = iter.current() ) != 0)
         {
-            if(a_field == search->getTitle())
+
+            // Find the correct node (we don't want to be case sensitive or look for any prepending "the "):
+            a_title = search->getTitle();
+            a_title = a_title.lower();
+            if (a_title.left(4) == "the ")
+            {
+                a_title = a_title.mid(4);
+            }
+            
+            if(a_lowercase_field == a_title)
             {
                 return( search->findRightNode(tree_levels, inserter, depth + 1) );
             }
@@ -1322,6 +1368,8 @@
 void MusicNode::sort()
 {
     bool something_changed;
+    QString Title1;
+    QString Title2;
 
     //  Sort any tracks
     
@@ -1361,7 +1409,23 @@
         something_changed = false;
         for(uint i = 0; i < my_subnodes.count() - 1;)
         {
-            if(qstrcmp(my_subnodes.at(i)->getTitle(), my_subnodes.at(i+1)->getTitle()) > 0)
+            Title1 = my_subnodes.at(i)->getTitle();
+            Title2 = my_subnodes.at(i+1)->getTitle();
+            
+            // Transform title, so we get case insensitive ordering of nodes:
+            Title1 = Title1.lower();
+            Title2 = Title2.lower();
+            // Remove any prepending "The ":
+            if (Title1.left(4)=="the ")
+            {
+                Title1 = Title1.mid(4);
+            }
+            if (Title2.left(4)=="the ")
+            {
+                Title2 = Title2.mid(4);
+            }
+
+            if(qstrcmp(Title1, Title2) > 0)
             {
                 something_changed = true;
                 MusicNode *temp = my_subnodes.take(i + 1);
_______________________________________________
mythtv-users mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Reply via email to