Ticket #4105: albumfix2.patch

File albumfix2.patch, 3.4 KB (added by Paul Lambert <paul at planar.id.au>, 16 years ago)
  • mythmusic/mythmusic/playlist.cpp

     
    963963                        else if (tmpdata->LastPlay() > lastplayMax) { lastplayMax = tmpdata->LastPlay(); }
    964964                    }
    965965                }
     966                // pre-fill the album-map with the album name.  This allows us to do album mode in album order
     967                album = tmpdata->Artist() + "~" + tmpdata->Album();
     968                if ((Ialbum = album_map.find(album)) == album_map.end())
     969                {
     970                    album_map.insert(AlbumMap::value_type(album,0));
     971                }
    966972               
    967973                // pre-fill the artist map with the artist name and song title
    968974                artist = tmpdata->Artist() + "~" + tmpdata->Title();
    969975                if ((Iartist = artist_map.find(artist)) == artist_map.end())
    970976                {
    971                   artist_map.insert(ArtistMap::value_type(artist,
    972                                                         0));
    973                 }
     977                  artist_map.insert(ArtistMap::value_type(artist,0));
     978                }               
    974979            }
    975980        }
    976981    }
     982    // populate the sort id into the album map
     983    uint32_t album_count = 1;
     984    for( Ialbum = album_map.begin(); Ialbum != album_map.end(); Ialbum++ )
     985    {
     986        Ialbum->second = album_count;
     987        album_count++;
     988    }   
    977989
    978990    // populate the sort id into the artist map
    979991    uint32_t count = 1;
     
    10331045                    added_node->setAttribute(3, integer_rating); //  "intelligent" order
    10341046
    10351047                    // "intellegent/album" order
     1048                    uint32_t album_order;
    10361049                    album = tmpdata->Artist() + "~" + tmpdata->Album();
    1037                     if ((Ialbum = album_map.find(album)) == album_map.end()) {
    1038                       // Add room for 100 albums with 100 tracks.
    1039                       integer_rating *= 10000;
    1040                       integer_rating += (a_counter * 100);
    1041 
    1042                       album_map.insert(AlbumMap::value_type(album,
    1043                                                             integer_rating));
    1044 
    1045                       integer_rating += tmpdata->Track();
    1046                       added_node->setAttribute(4, integer_rating);
     1050                    if ((Ialbum = album_map.find(album)) == album_map.end())
     1051                    {
     1052                        // we didn't find this album in the map, yet we pre-loaded them all
     1053                        // we are broken, but we just set the track order to 1, since there
     1054                        // is no real point in reporting an error
     1055                        album_order = 1;
    10471056                    }
    1048                     else {
    1049                       integer_rating = Ialbum->second;
    1050                       integer_rating += tmpdata->Track();
    1051                       added_node->setAttribute(4, integer_rating);
     1057                    else
     1058                    {
     1059                        album_order = Ialbum->second * 100;
    10521060                    }
     1061                    album_order += tmpdata->Track();
     1062                    added_node->setAttribute(4, album_order);
    10531063                   
    10541064                    // "artist" order, sorts by artist name then track title
    10551065                    // uses the pre-prepared artist map to do this