Hide progress indication before showing cover/lyrics dialog

This commit is contained in:
Martchus 2019-09-25 18:18:06 +02:00
parent dc4a6b2ee9
commit d92814187a
3 changed files with 35 additions and 35 deletions

View File

@ -358,18 +358,26 @@ void HttpResultsModel::handleCoverReplyFinished(QNetworkReply *reply, const QStr
if (!data.isEmpty()) {
parseCoverResults(albumId, row, data);
}
if (!m_resultsAvailable) {
setResultsAvailable(true);
}
}
void HttpResultsModel::parseCoverResults(const QString &albumId, int row, const QByteArray &data)
{
setFetchingCover(false);
// add cover -> determine album ID and row
if (albumId.isEmpty() || row >= m_results.size()) {
m_errorList << tr("Internal error: context for cover reply invalid");
setResultsAvailable(true);
return;
}
if (!data.isEmpty()) {
if (data.isEmpty()) {
return;
}
// cache the fetched cover
const auto currentCachedCoverCount = s_coverData.size();
s_coverData[albumId] = data;
@ -388,10 +396,9 @@ void HttpResultsModel::parseCoverResults(const QString &albumId, int row, const
// add the cover to the results
m_results[row].cover = data;
setResultsAvailable(true);
emit coverAvailable(index(row, 0));
}
setFetchingCover(false);
}
} // namespace QtGui

View File

@ -313,8 +313,10 @@ void LyricsWikiaResultsModel::handleLyricsReplyFinished(QNetworkReply *reply, in
if (!data.isEmpty()) {
parseLyricsResults(row, data);
}
if (!m_resultsAvailable) {
setResultsAvailable(true);
}
}
void LyricsWikiaResultsModel::parseLyricsResults(int row, const QByteArray &data)
{
@ -341,6 +343,7 @@ void LyricsWikiaResultsModel::parseLyricsResults(int row, const QByteArray &data
textDoc.setHtml(html.mid(lyricsStart, (lyricsEnd > lyricsStart) ? (lyricsEnd - lyricsStart) : -1));
assocDesc.lyrics = textDoc.toPlainText();
setResultsAvailable(true);
emit lyricsAvailable(index(row, 0));
}

View File

@ -603,13 +603,8 @@ void DbQueryWidget::fetchAndShowCoverForSelection()
return;
}
if (const QByteArray *const cover = m_model->cover(selectedIndex)) {
showCover(*cover);
return;
}
if (m_model->fetchCover(selectedIndex)) {
if (const QByteArray *const cover = m_model->cover(selectedIndex)) {
if (const auto *const cover = m_model->cover(selectedIndex)) {
showCover(*cover);
} else {
// cover couldn't be fetched, error tracked via resultsAvailable() signal so nothing to do
@ -632,14 +627,9 @@ void DbQueryWidget::fetchAndShowLyricsForSelection()
return;
}
if (const QString *const lyrics = m_model->lyrics(selectedIndex)) {
showLyrics(*lyrics);
return;
}
if (m_model->fetchLyrics(selectedIndex)) {
if (const QByteArray *cover = m_model->cover(selectedIndex)) {
showLyrics(*cover);
if (const auto *const lyrics = m_model->lyrics(selectedIndex)) {
showLyrics(*lyrics);
} else {
// lyrics couldn't be fetched, error tracked via resultsAvailable() signal so nothing to do
}