Index: mythmusic/mythmusic/music-ui.xml =================================================================== --- mythmusic/mythmusic/music-ui.xml (revision 13368) +++ mythmusic/mythmusic/music-ui.xml (working copy) @@ -496,64 +496,71 @@ Artist: - + + @@ -785,7 +797,7 @@ --> - 20,540 + 20,550 display @@ -793,7 +805,7 @@ - 190,540 + 190,550 display @@ -801,7 +813,7 @@ - 630,540 + 630,550 display Index: mythmusic/mythmusic/metaioflacvorbiscomment.cpp =================================================================== --- mythmusic/mythmusic/metaioflacvorbiscomment.cpp (revision 13368) +++ mythmusic/mythmusic/metaioflacvorbiscomment.cpp (working copy) @@ -134,7 +134,7 @@ */ Metadata* MetaIOFLACVorbisComment::read(QString filename) { - QString artist = "", compilation_artist = "", album = "", title = "", genre = ""; + QString artist = "", sort_artist = "", compilation_artist = "", album = "", title = "", genre = ""; int year = 0, tracknum = 0, length = 0; bool compilation = false; @@ -184,6 +184,7 @@ else { artist = getComment(block, MYTH_VORBISCOMMENT_ARTIST); + sort_artist = getComment(block, MYTH_VORBISCOMMENT_ARTIST); compilation_artist = getComment(block, MYTH_VORBISCOMMENT_COMPILATIONARTIST); album = getComment(block, MYTH_VORBISCOMMENT_ALBUM); @@ -200,7 +201,7 @@ FLAC__metadata_chain_delete(chain); FLAC__metadata_iterator_delete(iterator); - Metadata *retdata = new Metadata(filename, artist, compilation_artist, album, + Metadata *retdata = new Metadata(filename, artist, sort_artist, compilation_artist, album, title, genre, year, tracknum, length); retdata->setCompilation(compilation); Index: mythmusic/mythmusic/metadata.cpp =================================================================== --- mythmusic/mythmusic/metadata.cpp (revision 13368) +++ mythmusic/mythmusic/metadata.cpp (working copy) @@ -32,6 +32,7 @@ Metadata& Metadata::operator=(Metadata *rhs) { m_artist = rhs->m_artist; + m_sort_artist = rhs->m_sort_artist; m_compilation_artist = rhs->m_compilation_artist; m_album = rhs->m_album; m_title = rhs->m_title; @@ -110,6 +111,7 @@ MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT music_artists.artist_name, " + "music_artists.artist_sortkey, " "music_comp_artists.artist_name AS compilation_artist, " "music_albums.album_name, music_songs.name, music_genres.genre, " "music_songs.year, music_songs.track, music_songs.length, " @@ -133,19 +135,20 @@ query.next(); m_artist = QString::fromUtf8(query.value(0).toString()); - m_compilation_artist = QString::fromUtf8(query.value(1).toString()); - m_album = QString::fromUtf8(query.value(2).toString()); - m_title = QString::fromUtf8(query.value(3).toString()); - m_genre = QString::fromUtf8(query.value(4).toString()); - m_year = query.value(5).toInt(); - m_tracknum = query.value(6).toInt(); - m_length = query.value(7).toInt(); - m_id = query.value(8).toUInt(); - m_rating = query.value(9).toInt(); - m_playcount = query.value(10).toInt(); - m_lastplay = query.value(11).toString(); - m_compilation = (query.value(12).toInt() > 0); - m_format = query.value(13).toString(); + m_sort_artist = QString::fromUtf8(query.value(1).toString()); + m_compilation_artist = QString::fromUtf8(query.value(2).toString()); + m_album = QString::fromUtf8(query.value(3).toString()); + m_title = QString::fromUtf8(query.value(4).toString()); + m_genre = QString::fromUtf8(query.value(5).toString()); + m_year = query.value(6).toInt(); + m_tracknum = query.value(7).toInt(); + m_length = query.value(8).toInt(); + m_id = query.value(9).toUInt(); + m_rating = query.value(10).toInt(); + m_playcount = query.value(11).toInt(); + m_lastplay = query.value(12).toString(); + m_compilation = (query.value(13).toInt() > 0); + m_format = query.value(14).toString(); retval = true; } @@ -216,11 +219,23 @@ if (query.next()) { m_artistid = query.value(0).toInt(); + + query.prepare("UPDATE music_artists SET artist_sortkey = :SORTARTIST " + "WHERE artist_id = :ARTISTID ;"); + query.bindValue(":SORTARTIST", m_sort_artist.utf8()); + query.bindValue(":ARTISTID", m_artist.utf8()); + if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0) + { + MythContext::DBError("music update sortartist", query); + return; + } } else { - query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);"); + query.prepare("INSERT INTO music_artists (artist_name,artist_sortkey) " + "VALUES (:ARTIST, :SORTARTIST);"); query.bindValue(":ARTIST", m_artist.utf8()); + query.bindValue(":SORTARTIST", m_sort_artist.utf8()); if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0) { @@ -432,6 +447,7 @@ QString Metadata::m_formatnormalfiletrack = "TITLE"; QString Metadata::m_formatnormalcdartist = "ARTIST"; QString Metadata::m_formatnormalcdtrack = "TITLE"; +QString Metadata::m_formatnormalsortartist = "ARTIST"; QString Metadata::m_formatcompilationfileartist = "COMPARTIST"; QString Metadata::m_formatcompilationfiletrack = "TITLE (ARTIST)"; QString Metadata::m_formatcompilationcdartist = "COMPARTIST"; @@ -456,6 +472,10 @@ tmp = gContext->GetSetting("MusicFormatNormalCDTrack"); if (!tmp.isEmpty()) m_formatnormalcdtrack = tmp; + + tmp = gContext->GetSetting("MusicFormatNormalSortArtist"); + if (!tmp.isEmpty()) + m_formatnormalsortartist = tmp; tmp = gContext->GetSetting("MusicFormatCompilationFileArtist"); if (!tmp.isEmpty()) @@ -489,6 +509,7 @@ QString rv = format; rv.replace("COMPARTIST", m_compilation_artist); rv.replace("ARTIST", m_artist); + rv.replace("SORTARTIST", m_sort_artist); rv.replace("TITLE", m_title); rv.replace("TRACK", QString("%1").arg(m_tracknum, 2)); return rv; @@ -498,6 +519,8 @@ { if (m_artist == "") m_artist = QObject::tr("Unknown Artist"); + if (m_sort_artist == "") + m_sort_artist = m_artist; // same as artist, if not specified if (m_compilation_artist == "") m_compilation_artist = m_artist; // This should be the same as Artist if blank. if (m_album == "") @@ -576,6 +599,10 @@ // completeness. else if (field == "compilation_artist") m_compilation_artist = data; + // turbo@talstar.com: Likewise, I've added sortartist stuff here for + // completeness. + else if (field == "sort_artist") + m_sort_artist = data; else if (field == "album") m_album = data; else if (field == "title") @@ -821,7 +848,7 @@ { m_done_loading = false; - QString aquery = "SELECT music_songs.song_id, music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, " + QString aquery = "SELECT music_songs.song_id, music_artists.artist_name, music_artists.artist_sortkey, music_comp_artists.artist_name AS compilation_artist, " "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, " "music_songs.track, music_songs.length, CONCAT_WS('/', " "music_directories.path, music_songs.filename) AS filename, " @@ -835,7 +862,7 @@ "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id " "ORDER BY music_songs.song_id;"; - QString filename, artist, album, title; + QString filename, artist, sortartist, album, title; MSqlQuery query(MSqlQuery::InitCon()); query.exec(aquery); @@ -850,7 +877,7 @@ { while (query.next()) { - filename = QString::fromUtf8(query.value(9).toString()); + filename = QString::fromUtf8(query.value(10).toString()); if (!filename.contains("://")) filename = m_startdir + filename; @@ -858,30 +885,35 @@ if (artist.isEmpty()) artist = QObject::tr("Unknown Artist"); - album = QString::fromUtf8(query.value(3).toString()); + sortartist = QString::fromUtf8(query.value(2).toString()); + if (sortartist.isEmpty()) + sortartist = artist; + + album = QString::fromUtf8(query.value(4).toString()); if (album.isEmpty()) album = QObject::tr("Unknown Album"); - title = QString::fromUtf8(query.value(4).toString()); + title = QString::fromUtf8(query.value(5).toString()); if (title.isEmpty()) title = QObject::tr("Unknown Title"); Metadata *temp = new Metadata( filename, artist, - QString::fromUtf8(query.value(2).toString()), + sortartist, + QString::fromUtf8(query.value(3).toString()), album, title, - QString::fromUtf8(query.value(5).toString()), - query.value(6).toInt(), + QString::fromUtf8(query.value(6).toString()), query.value(7).toInt(), query.value(8).toInt(), + query.value(9).toInt(), query.value(0).toInt(), - query.value(10).toInt(), //rating - query.value(11).toInt(), //playcount - query.value(12).toString(), //lastplay - (query.value(13).toInt() > 0), //compilation - query.value(14).toString()); //format + query.value(11).toInt(), //rating + query.value(12).toInt(), //playcount + query.value(13).toString(), //lastplay + (query.value(14).toInt() > 0), //compilation + query.value(15).toString()); //format // Don't delete temp, as PtrList now owns it m_all_music.append(temp); Index: mythmusic/mythmusic/metadata.h =================================================================== --- mythmusic/mythmusic/metadata.h (revision 13368) +++ mythmusic/mythmusic/metadata.h (working copy) @@ -42,12 +42,14 @@ class Metadata { public: - Metadata(QString lfilename = "", QString lartist = "", QString lcompilation_artist = "", + Metadata(QString lfilename = "", QString lartist = "", QString lsortartist = "", + QString lcompilation_artist = "", QString lalbum = "", QString ltitle = "", QString lgenre = "", int lyear = 0, int ltracknum = 0, int llength = 0, int lid = 0, int lrating = 0, int lplaycount = 0, QString llastplay = "", bool lcompilation = false, QString lformat="") : m_artist(lartist), + m_sort_artist(lsortartist), m_compilation_artist(lcompilation_artist), m_album(lalbum), m_title(ltitle), @@ -90,6 +92,9 @@ m_artist = lartist; m_formattedartist = m_formattedtitle = ""; } + QString SortArtist() { return m_sort_artist; } + void setSortArtist(const QString &lsortartist) { m_sort_artist = lsortartist; m_formattedartist = m_formattedtitle = ""; } + QString CompilationArtist() const { return m_compilation_artist; } void setCompilationArtist(const QString &lcompilation_artist) { @@ -192,6 +197,7 @@ void checkEmptyFields(void); QString m_artist; + QString m_sort_artist; QString m_compilation_artist; QString m_album; QString m_title; @@ -227,6 +233,8 @@ static QString m_formatnormalcdartist; static QString m_formatnormalcdtrack; + static QString m_formatnormalsortartist; + static QString m_formatcompilationfileartist; static QString m_formatcompilationfiletrack; static QString m_formatcompilationcdartist; Index: mythmusic/mythmusic/editmetadata.cpp =================================================================== --- mythmusic/mythmusic/editmetadata.cpp (revision 13368) +++ mythmusic/mythmusic/editmetadata.cpp (working copy) @@ -42,6 +42,11 @@ artist_edit->setText(m_metadata->Artist()); } + if (sort_artist_edit) + { + sort_artist_edit->setText(m_metadata->SortArtist()); + } + if (compilation_artist_edit) { compilation_artist_edit->setText(m_metadata->CompilationArtist()); @@ -304,6 +309,13 @@ connect(compilation_artist_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus())); } + sort_artist_edit = getUIRemoteEditType("sort_artist_edit"); + if (sort_artist_edit) + { + sort_artist_edit->createEdit(this); + connect(sort_artist_edit, SIGNAL(loosingFocus()), this, SLOT(editLostFocus())); + } + album_edit = getUIRemoteEditType("album_edit"); if (album_edit) { @@ -460,6 +472,10 @@ { m_metadata->setArtist(artist_edit->getText()); } + else if (whichEditor == sort_artist_edit) + { + m_metadata->setSortArtist(sort_artist_edit->getText()); + } else if (whichEditor == compilation_artist_edit) { m_metadata->setCompilationArtist(compilation_artist_edit->getText()); Index: mythmusic/mythmusic/metaioavfcomment.cpp =================================================================== --- mythmusic/mythmusic/metaioavfcomment.cpp (revision 13368) +++ mythmusic/mythmusic/metaioavfcomment.cpp (working copy) @@ -51,7 +51,7 @@ */ Metadata* MetaIOAVFComment::read(QString filename) { - QString artist = "", compilation_artist = "", album = "", title = "", genre = ""; + QString artist = "", sort_artist = "", compilation_artist = "", album = "", title = "", genre = ""; int year = 0, tracknum = 0, length = 0; AVFormatContext* p_context = NULL; @@ -76,6 +76,7 @@ else { artist += (char *)p_context->author; + sort_artist += (char *)p_context->author; // compilation_artist??? album += (char *)p_context->album; genre += (char *)p_context->genre; @@ -85,7 +86,7 @@ length = getTrackLength(p_context); - Metadata *retdata = new Metadata(filename, artist, compilation_artist, album, + Metadata *retdata = new Metadata(filename, artist, sort_artist, compilation_artist, album, title, genre, year, tracknum, length); retdata->determineIfCompilation(); Index: mythmusic/mythmusic/editmetadata.h =================================================================== --- mythmusic/mythmusic/editmetadata.h (revision 13368) +++ mythmusic/mythmusic/editmetadata.h (working copy) @@ -66,6 +66,7 @@ // GUI stuff // UIRemoteEditType *artist_edit; + UIRemoteEditType *sort_artist_edit; UIRemoteEditType *compilation_artist_edit; UIRemoteEditType *album_edit; UIRemoteEditType *title_edit; Index: mythmusic/mythmusic/metaiotaglib.cpp =================================================================== --- mythmusic/mythmusic/metaiotaglib.cpp (revision 13368) +++ mythmusic/mythmusic/metaiotaglib.cpp (working copy) @@ -98,7 +98,7 @@ */ Metadata* MetaIOTagLib::read(QString filename) { - QString artist = "", compilation_artist = "", album = "", title = "", + QString artist = "", sort_artist = "", compilation_artist = "", album = "", title = "", genre = ""; int year = 0, tracknum = 0, length = 0, playcount = 0, rating = 0, id = 0; bool compilation = false; @@ -185,7 +185,8 @@ return NULL; } - Metadata *retdata = new Metadata(filename, artist, compilation_artist, album, + Metadata *retdata = new Metadata(filename, artist, sort_artist, + compilation_artist, album, title, genre, year, tracknum, length, id, rating, playcount); Index: mythmusic/mythmusic/cddecoder.cpp =================================================================== --- mythmusic/mythmusic/cddecoder.cpp (revision 13368) +++ mythmusic/mythmusic/cddecoder.cpp (working copy) @@ -332,7 +332,7 @@ Metadata *CdDecoder::getMetadata() { - QString artist = "", album = "", compilation_artist = "", title = "", genre = ""; + QString artist = "", sort_artist = "", album = "", compilation_artist = "", title = "", genre = ""; int year = 0, tracknum = 0, length = 0; int cd = cd_init_device((char *)devicename.ascii()); @@ -426,7 +426,7 @@ length = length < 0 ? 0 : length; length *= 1000; - Metadata *retdata = new Metadata(filename, artist, compilation_artist, + Metadata *retdata = new Metadata(filename, artist, sort_artist, compilation_artist, album, title, genre, year, tracknum, length); retdata->determineIfCompilation(true); @@ -484,6 +484,8 @@ if (mdata->Artist() != discdata.data_artist) strncpy(discdata.data_artist, mdata->Artist().utf8(), 256); } + if (mdata->SortArtist() != discdata.data_artist) + strncpy(discdata.data_artist, mdata->SortArtist().utf8(), 256); if (mdata->Album() != discdata.data_title) strncpy(discdata.data_title, mdata->Album().utf8(), 256); if (mdata->Title() != discdata.data_track[tracknum - 1].track_name) Index: mythmusic/mythmusic/metaiooggvorbiscomment.cpp =================================================================== --- mythmusic/mythmusic/metaiooggvorbiscomment.cpp (revision 13368) +++ mythmusic/mythmusic/metaiooggvorbiscomment.cpp (working copy) @@ -275,7 +275,7 @@ */ Metadata* MetaIOOggVorbisComment::read(QString filename) { - QString artist = "", compilation_artist = "", album = "", title = "", genre = ""; + QString artist = "", sort_artist = "", compilation_artist = "", album = "", title = "", genre = ""; int year = 0, tracknum = 0, length = 0; bool compilation = false; @@ -302,6 +302,7 @@ // artist = getComment(comment, MYTH_VORBISCOMMENT_ARTIST); + sort_artist = getComment(comment, MYTH_VORBISCOMMENT_ARTIST); compilation_artist = getComment(comment, MYTH_VORBISCOMMENT_COMPILATIONARTIST); album = getComment(comment, MYTH_VORBISCOMMENT_ALBUM); title = getComment(comment, MYTH_VORBISCOMMENT_TITLE); @@ -330,7 +331,7 @@ readFromFilename(filename, artist, album, title, genre, tracknum); } - Metadata *retdata = new Metadata(filename, artist, compilation_artist, album, + Metadata *retdata = new Metadata(filename, artist, sort_artist, compilation_artist, album, title, genre, year, tracknum, length); retdata->setCompilation(compilation);