Commit efe69043 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

Merge branch 'release/19.12'

parents 8db29172 8e1967d7
......@@ -19,6 +19,7 @@
<name xml:lang="fr">Elisa</name>
<name xml:lang="gl">Elisa</name>
<name xml:lang="hu">Elisa</name>
<name xml:lang="ia">Elisa</name>
<name xml:lang="id">Elisa</name>
<name xml:lang="it">Elisa</name>
<name xml:lang="ko">Elisa</name>
......@@ -52,6 +53,7 @@
<summary xml:lang="fr">Lecteur de musique simple</summary>
<summary xml:lang="gl">Reprodutor de música simple</summary>
<summary xml:lang="hu">Egyszerű zenelejátszó</summary>
<summary xml:lang="ia">Simple Reproductor de musica</summary>
<summary xml:lang="id">Pemutar Musik yang Sederhana</summary>
<summary xml:lang="it">Semplice lettore musicale</summary>
<summary xml:lang="ko">간편한 음악 재생기</summary>
......@@ -86,6 +88,7 @@
<p xml:lang="fr">Un lecteur de musique simple qui se veut facile à utiliser. Il ne requiert aucune configuration pour pouvoir être utilisé.</p>
<p xml:lang="gl">Un reprodutor de música simple e fácil de usar. Non require ningún tipo de configuración inicial.</p>
<p xml:lang="hu">Egy egyszerű zenelejátszó, amely könnyen használható. Nem igényel semmilyen beállítást használat előtt.</p>
<p xml:lang="ia">Un simple reproductor de musica que deberea esser facile de usar. Illo non require ulle configuration ante que un pote usar lo.</p>
<p xml:lang="id">Sebuah pemutar musik sederhana yang seharusnya mudah digunakan. Yang tidak memerlukan konfigurasi apa pun sebelum seseorang bisa menggunakannya.</p>
<p xml:lang="it">Un semplice lettore musicale che dovrebbe essere semplice da usare. Non richiede alcuna configurazione per iniziare a usarlo.</p>
<p xml:lang="ko">사용하기 쉬운 간편한 음악 재생기. 먼저 설정하지 않아도 사용할 수 있습니다.</p>
......@@ -126,6 +129,7 @@
<caption xml:lang="fr">Le lecteur de musique Elisa</caption>
<caption xml:lang="gl">O reprodutor de música Elisa.</caption>
<caption xml:lang="hu">Elisa zenelejátszó</caption>
<caption xml:lang="ia">Le reproductor de music Elisa</caption>
<caption xml:lang="id">Elisa si pemutar musik</caption>
<caption xml:lang="it">Il lettore musicale Elisa</caption>
<caption xml:lang="ko">Elisa 음악 재생기</caption>
......
......@@ -47,6 +47,7 @@ public:
mSelectTrackQuery(mTracksDatabase), mSelectAlbumIdFromTitleQuery(mTracksDatabase),
mInsertAlbumQuery(mTracksDatabase), mSelectTrackIdFromTitleAlbumIdArtistQuery(mTracksDatabase),
mInsertTrackQuery(mTracksDatabase), mSelectTracksFromArtist(mTracksDatabase),
mSelectTracksFromGenre(mTracksDatabase),
mSelectTrackFromIdQuery(mTracksDatabase), mSelectRadioFromIdQuery(mTracksDatabase),
mSelectCountAlbumsForArtistQuery(mTracksDatabase),
mSelectTrackIdFromTitleArtistAlbumTrackDiscNumberQuery(mTracksDatabase),
......@@ -110,6 +111,8 @@ public:
QSqlQuery mSelectTracksFromArtist;
QSqlQuery mSelectTracksFromGenre;
QSqlQuery mSelectTrackFromIdQuery;
QSqlQuery mSelectRadioFromIdQuery;
......@@ -728,6 +731,24 @@ DataTypes::ListTrackDataType DatabaseInterface::tracksDataFromAuthor(const QStri
return allTracks;
}
DataTypes::ListTrackDataType DatabaseInterface::tracksDataFromGenre(const QString &genre)
{
auto allTracks = DataTypes::ListTrackDataType{};
auto transactionResult = startTransaction();
if (!transactionResult) {
return allTracks;
}
allTracks = internalTracksFromGenre(genre);
transactionResult = finishTransaction();
if (!transactionResult) {
return allTracks;
}
return allTracks;
}
DataTypes::TrackDataType DatabaseInterface::trackDataFromDatabaseId(qulonglong id)
{
auto result = DataTypes::TrackDataType();
......@@ -5977,6 +5998,135 @@ void DatabaseInterface::initRequest()
}
}
{
auto selectTracksFromGenreQueryText = QStringLiteral("SELECT "
"tracks.`ID`, "
"tracks.`Title`, "
"album.`ID`, "
"tracks.`ArtistName`, "
"( "
"SELECT "
"COUNT(DISTINCT tracksFromAlbum1.`ArtistName`) "
"FROM "
"`Tracks` tracksFromAlbum1 "
"WHERE "
"tracksFromAlbum1.`AlbumTitle` = album.`Title` AND "
"(tracksFromAlbum1.`AlbumArtistName` = album.`ArtistName` OR "
"(tracksFromAlbum1.`AlbumArtistName` IS NULL AND "
"album.`ArtistName` IS NULL "
") "
") AND "
"tracksFromAlbum1.`AlbumPath` = album.`AlbumPath` "
") AS ArtistsCount, "
"( "
"SELECT "
"GROUP_CONCAT(tracksFromAlbum2.`ArtistName`) "
"FROM "
"`Tracks` tracksFromAlbum2 "
"WHERE "
"tracksFromAlbum2.`AlbumTitle` = album.`Title` AND "
"(tracksFromAlbum2.`AlbumArtistName` = album.`ArtistName` OR "
"(tracksFromAlbum2.`AlbumArtistName` IS NULL AND "
"album.`ArtistName` IS NULL "
") "
") AND "
"tracksFromAlbum2.`AlbumPath` = album.`AlbumPath` "
") AS AllArtists, "
"tracks.`AlbumArtistName`, "
"tracksMapping.`FileName`, "
"tracksMapping.`FileModifiedTime`, "
"tracks.`TrackNumber`, "
"tracks.`DiscNumber`, "
"tracks.`Duration`, "
"tracks.`AlbumTitle`, "
"tracks.`Rating`, "
"album.`CoverFileName`, "
"("
"SELECT "
"COUNT(DISTINCT tracks2.DiscNumber) <= 1 "
"FROM "
"`Tracks` tracks2 "
"WHERE "
"tracks2.`AlbumTitle` = album.`Title` AND "
"(tracks2.`AlbumArtistName` = album.`ArtistName` OR "
"(tracks2.`AlbumArtistName` IS NULL AND "
"album.`ArtistName` IS NULL"
")"
") AND "
"tracks2.`AlbumPath` = album.`AlbumPath` "
") as `IsSingleDiscAlbum`, "
"trackGenre.`Name`, "
"trackComposer.`Name`, "
"trackLyricist.`Name`, "
"tracks.`Comment`, "
"tracks.`Year`, "
"tracks.`Channels`, "
"tracks.`BitRate`, "
"tracks.`SampleRate`, "
"tracks.`HasEmbeddedCover`, "
"tracksMapping.`ImportDate`, "
"tracksMapping.`FirstPlayDate`, "
"tracksMapping.`LastPlayDate`, "
"tracksMapping.`PlayCounter`, "
"tracksMapping.`PlayCounter` / (strftime('%s', 'now') - tracksMapping.`FirstPlayDate`) as PlayFrequency, "
"( "
"SELECT tracksCover.`FileName` "
"FROM "
"`Tracks` tracksCover "
"WHERE "
"tracksCover.`HasEmbeddedCover` = 1 AND "
"tracksCover.`AlbumTitle` = album.`Title` AND "
"(tracksCover.`AlbumArtistName` = album.`ArtistName` OR "
"(tracksCover.`AlbumArtistName` IS NULL AND "
"album.`ArtistName` IS NULL "
") "
") AND "
"tracksCover.`AlbumPath` = album.`AlbumPath` "
") as EmbeddedCover "
"FROM "
"`Tracks` tracks, "
"`TracksData` tracksMapping "
"LEFT JOIN "
"`Albums` album "
"ON "
"tracks.`AlbumTitle` = album.`Title` AND "
"(tracks.`AlbumArtistName` = album.`ArtistName` OR tracks.`AlbumArtistName` IS NULL ) AND "
"tracks.`AlbumPath` = album.`AlbumPath` "
"LEFT JOIN `Composer` trackComposer ON trackComposer.`Name` = tracks.`Composer` "
"LEFT JOIN `Lyricist` trackLyricist ON trackLyricist.`Name` = tracks.`Lyricist` "
"LEFT JOIN `Genre` trackGenre ON trackGenre.`Name` = tracks.`Genre` "
"WHERE "
"tracks.`Genre` = :genre AND "
"tracksMapping.`FileName` = tracks.`FileName` AND "
"tracks.`Priority` = ("
" SELECT "
" MIN(`Priority`) "
" FROM "
" `Tracks` tracks2 "
" WHERE "
" tracks.`Title` = tracks2.`Title` AND "
" (tracks.`ArtistName` IS NULL OR tracks.`ArtistName` = tracks2.`ArtistName`) AND "
" (tracks.`AlbumTitle` IS NULL OR tracks.`AlbumTitle` = tracks2.`AlbumTitle`) AND "
" (tracks.`AlbumArtistName` IS NULL OR tracks.`AlbumArtistName` = tracks2.`AlbumArtistName`) AND "
" (tracks.`AlbumPath` IS NULL OR tracks.`AlbumPath` = tracks2.`AlbumPath`)"
")"
"ORDER BY "
"album.`Title` ASC, "
"tracks.`DiscNumber` ASC, "
"tracks.`TrackNumber` ASC, "
"tracks.`Title` ASC"
"");
auto result = prepareQuery(d->mSelectTracksFromGenre, selectTracksFromGenreQueryText);
if (!result) {
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::initRequest" << d->mSelectTracksFromGenre.lastQuery();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::initRequest" << d->mSelectTracksFromGenre.lastError();
Q_EMIT databaseError();
}
}
{
auto selectAlbumIdsFromArtistQueryText = QStringLiteral("SELECT "
"album.`ID` "
......@@ -7759,6 +7909,36 @@ DataTypes::ListTrackDataType DatabaseInterface::internalTracksFromAuthor(const Q
return allTracks;
}
DataTypes::ListTrackDataType DatabaseInterface::internalTracksFromGenre(const QString &genre)
{
auto allTracks = DataTypes::ListTrackDataType{};
d->mSelectTracksFromGenre.bindValue(QStringLiteral(":genre"), genre);
auto result = execQuery(d->mSelectTracksFromGenre);
if (!result || !d->mSelectTracksFromGenre.isSelect() || !d->mSelectTracksFromGenre.isActive()) {
Q_EMIT databaseError();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::tracksFromGenre" << d->mSelectTracksFromGenre.lastQuery();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::tracksFromGenre" << d->mSelectTracksFromGenre.boundValues();
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::tracksFromGenre" << d->mSelectTracksFromGenre.lastError();
return allTracks;
}
while (d->mSelectTracksFromGenre.next()) {
const auto &currentRecord = d->mSelectTracksFromGenre.record();
allTracks.push_back(buildTrackDataFromDatabaseRecord(currentRecord));
}
d->mSelectTracksFromGenre.finish();
return allTracks;
}
QList<qulonglong> DatabaseInterface::internalAlbumIdsFromAuthor(const QString &ArtistName)
{
auto allAlbumIds = QList<qulonglong>();
......
......@@ -89,6 +89,8 @@ public:
DataTypes::ListTrackDataType tracksDataFromAuthor(const QString &artistName);
DataTypes::ListTrackDataType tracksDataFromGenre(const QString &genre);
DataTypes::TrackDataType trackDataFromDatabaseId(qulonglong id);
DataTypes::TrackDataType trackDataFromDatabaseIdAndUrl(qulonglong id, const QUrl &trackUrl);
......@@ -199,6 +201,8 @@ private:
DataTypes::ListTrackDataType internalTracksFromAuthor(const QString &artistName);
DataTypes::ListTrackDataType internalTracksFromGenre(const QString &genre);
QList<qulonglong> internalAlbumIdsFromAuthor(const QString &artistName);
void initDatabase();
......
......@@ -60,6 +60,10 @@ ListView {
anchors.fill: playListView
}
/* currently disabled animations due to display corruption
because of https://bugreports.qt.io/browse/QTBUG-49868
causing https://bugs.kde.org/show_bug.cgi?id=406524
and https://bugs.kde.org/show_bug.cgi?id=398093
add: Transition {
NumberAnimation {
property: "opacity";
......@@ -90,6 +94,7 @@ ListView {
duration: 100;
easing.type: Easing.InOutQuad}
}
*/
model: DelegateModel {
id: playListModelDelegate
......
......@@ -228,9 +228,11 @@ void TracksListener::newEntryInList(qulonglong newDatabaseId,
case ElisaUtils::Album:
newAlbumInList(newDatabaseId, entryTitle);
break;
case ElisaUtils::Genre:
newGenreInList(newDatabaseId, entryTitle);
break;
case ElisaUtils::Lyricist:
case ElisaUtils::Composer:
case ElisaUtils::Genre:
case ElisaUtils::Unknown:
break;
}
......@@ -300,4 +302,19 @@ void TracksListener::newArtistInList(qulonglong newDatabaseId, const QString &ar
Q_EMIT tracksListAdded(newDatabaseId, artist, ElisaUtils::Artist, newTracks);
}
void TracksListener::newGenreInList(qulonglong newDatabaseId, const QString &entryTitle)
{
auto newTracks = d->mDatabase->tracksDataFromGenre(entryTitle);
if (newTracks.isEmpty()) {
return;
}
for (const auto &oneTrack : newTracks) {
d->mTracksByIdSet.insert(oneTrack.databaseId());
}
Q_EMIT tracksListAdded(newDatabaseId, entryTitle, ElisaUtils::Genre, newTracks);
}
#include "moc_trackslistener.cpp"
......@@ -78,6 +78,8 @@ private:
void newArtistInList(qulonglong newDatabaseId, const QString &artist);
void newGenreInList(qulonglong newDatabaseId, const QString &entryTitle);
void newAlbumInList(qulonglong newDatabaseId,
const QString &entryTitle);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment