Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Multimedia
Elisa
Commits
1b5e83e1
Commit
1b5e83e1
authored
Jun 22, 2020
by
Matthieu Gallien
🎵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add year data to the albums
necessary to be able to sort albums by year
parent
df7d96dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
src/databaseinterface.cpp
src/databaseinterface.cpp
+18
-8
src/models/datamodel.cpp
src/models/datamodel.cpp
+1
-0
No files found.
src/databaseinterface.cpp
View file @
1b5e83e1
...
...
@@ -3571,6 +3571,7 @@ void DatabaseInterface::initRequest()
"album.`ArtistName` as SecondaryText, "
"album.`CoverFileName`, "
"album.`ArtistName`, "
"GROUP_CONCAT(tracks.`Year`, ', ') as Year, "
"COUNT(DISTINCT tracks.`ArtistName`) as ArtistsCount, "
"GROUP_CONCAT(tracks.`ArtistName`, ', ') as AllArtists, "
"MAX(tracks.`Rating`) as HighestRating, "
...
...
@@ -3635,6 +3636,7 @@ void DatabaseInterface::initRequest()
"album.`ArtistName` as SecondaryText, "
"album.`CoverFileName`, "
"album.`ArtistName`, "
"GROUP_CONCAT(tracks.`Year`, ', ') as Year, "
"COUNT(DISTINCT tracks.`ArtistName`) as ArtistsCount, "
"GROUP_CONCAT(tracks.`ArtistName`, ', ') as AllArtists, "
"MAX(tracks.`Rating`) as HighestRating, "
...
...
@@ -3715,6 +3717,7 @@ void DatabaseInterface::initRequest()
"album.`ArtistName` as SecondaryText, "
"album.`CoverFileName`, "
"album.`ArtistName`, "
"GROUP_CONCAT(tracks.`Year`, ', ') as Year, "
"COUNT(DISTINCT tracks.`ArtistName`) as ArtistsCount, "
"GROUP_CONCAT(tracks.`ArtistName`, ', ') as AllArtists, "
"MAX(tracks.`Rating`) as HighestRating, "
...
...
@@ -7979,10 +7982,10 @@ DataTypes::ListAlbumDataType DatabaseInterface::internalAllAlbumsPartialData(QSq
newData
[
DataTypes
::
TitleRole
]
=
currentRecord
.
value
(
1
);
if
(
!
currentRecord
.
value
(
3
).
toString
().
isEmpty
())
{
newData
[
DataTypes
::
ImageUrlRole
]
=
currentRecord
.
value
(
3
);
}
else
if
(
!
currentRecord
.
value
(
1
0
).
toString
().
isEmpty
())
{
newData
[
DataTypes
::
ImageUrlRole
]
=
QVariant
{
QLatin1String
(
"image://cover/"
)
+
currentRecord
.
value
(
1
0
).
toUrl
().
toLocalFile
()};
}
else
if
(
!
currentRecord
.
value
(
1
1
).
toString
().
isEmpty
())
{
newData
[
DataTypes
::
ImageUrlRole
]
=
QVariant
{
QLatin1String
(
"image://cover/"
)
+
currentRecord
.
value
(
1
1
).
toUrl
().
toLocalFile
()};
}
auto
allArtists
=
currentRecord
.
value
(
6
).
toString
().
split
(
QStringLiteral
(
", "
));
auto
allArtists
=
currentRecord
.
value
(
7
).
toString
().
split
(
QStringLiteral
(
", "
));
allArtists
.
removeDuplicates
();
newData
[
DataTypes
::
AllArtistsRole
]
=
QVariant
::
fromValue
(
allArtists
);
if
(
!
currentRecord
.
value
(
4
).
isNull
())
{
...
...
@@ -7990,16 +7993,23 @@ DataTypes::ListAlbumDataType DatabaseInterface::internalAllAlbumsPartialData(QSq
newData
[
DataTypes
::
SecondaryTextRole
]
=
currentRecord
.
value
(
4
);
}
else
{
newData
[
DataTypes
::
IsValidAlbumArtistRole
]
=
false
;
if
(
currentRecord
.
value
(
5
).
toInt
()
==
1
)
{
if
(
currentRecord
.
value
(
6
).
toInt
()
==
1
)
{
newData
[
DataTypes
::
SecondaryTextRole
]
=
allArtists
.
first
();
}
else
if
(
currentRecord
.
value
(
5
).
toInt
()
>
1
)
{
}
else
if
(
currentRecord
.
value
(
6
).
toInt
()
>
1
)
{
newData
[
DataTypes
::
SecondaryTextRole
]
=
i18n
(
"Various Artists"
);
}
}
newData
[
DataTypes
::
ArtistRole
]
=
newData
[
DataTypes
::
SecondaryTextRole
];
newData
[
DataTypes
::
HighestTrackRating
]
=
currentRecord
.
value
(
7
);
newData
[
DataTypes
::
IsSingleDiscAlbumRole
]
=
currentRecord
.
value
(
9
);
newData
[
DataTypes
::
GenreRole
]
=
QVariant
::
fromValue
(
currentRecord
.
value
(
8
).
toString
().
split
(
QStringLiteral
(
", "
)));
newData
[
DataTypes
::
HighestTrackRating
]
=
currentRecord
.
value
(
8
);
newData
[
DataTypes
::
IsSingleDiscAlbumRole
]
=
currentRecord
.
value
(
10
);
newData
[
DataTypes
::
GenreRole
]
=
QVariant
::
fromValue
(
currentRecord
.
value
(
9
).
toString
().
split
(
QStringLiteral
(
", "
)));
auto
allYears
=
currentRecord
.
value
(
5
).
toString
().
split
(
QStringLiteral
(
", "
));
allYears
.
removeDuplicates
();
if
(
allYears
.
size
()
==
1
)
{
newData
[
DataTypes
::
YearRole
]
=
allYears
.
at
(
0
).
toInt
();
}
else
{
newData
[
DataTypes
::
YearRole
]
=
0
;
}
newData
[
DataTypes
::
ElementTypeRole
]
=
ElisaUtils
::
Album
;
result
.
push_back
(
newData
);
...
...
src/models/datamodel.cpp
View file @
1b5e83e1
...
...
@@ -91,6 +91,7 @@ QHash<int, QByteArray> DataModel::roleNames() const
roles
[
static_cast
<
int
>
(
DataTypes
::
ColumnsRoles
::
TrackNumberRole
)]
=
"trackNumber"
;
roles
[
static_cast
<
int
>
(
DataTypes
::
ColumnsRoles
::
DiscNumberRole
)]
=
"discNumber"
;
roles
[
static_cast
<
int
>
(
DataTypes
::
ColumnsRoles
::
RatingRole
)]
=
"rating"
;
roles
[
static_cast
<
int
>
(
DataTypes
::
ColumnsRoles
::
YearRole
)]
=
"year"
;
roles
[
static_cast
<
int
>
(
DataTypes
::
ColumnsRoles
::
IsSingleDiscAlbumRole
)]
=
"isSingleDiscAlbum"
;
roles
[
static_cast
<
int
>
(
DataTypes
::
ColumnsRoles
::
FullDataRole
)]
=
"fullData"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment