Hide progress indication before showing cover/lyrics dialog
This commit is contained in:
parent
dc4a6b2ee9
commit
d92814187a
|
@ -358,39 +358,46 @@ void HttpResultsModel::handleCoverReplyFinished(QNetworkReply *reply, const QStr
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
parseCoverResults(albumId, row, data);
|
parseCoverResults(albumId, row, data);
|
||||||
}
|
}
|
||||||
setResultsAvailable(true);
|
if (!m_resultsAvailable) {
|
||||||
|
setResultsAvailable(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpResultsModel::parseCoverResults(const QString &albumId, int row, const QByteArray &data)
|
void HttpResultsModel::parseCoverResults(const QString &albumId, int row, const QByteArray &data)
|
||||||
{
|
{
|
||||||
|
setFetchingCover(false);
|
||||||
|
|
||||||
// add cover -> determine album ID and row
|
// add cover -> determine album ID and row
|
||||||
if (albumId.isEmpty() || row >= m_results.size()) {
|
if (albumId.isEmpty() || row >= m_results.size()) {
|
||||||
m_errorList << tr("Internal error: context for cover reply invalid");
|
m_errorList << tr("Internal error: context for cover reply invalid");
|
||||||
setResultsAvailable(true);
|
setResultsAvailable(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!data.isEmpty()) {
|
|
||||||
// cache the fetched cover
|
|
||||||
const auto currentCachedCoverCount = s_coverData.size();
|
|
||||||
s_coverData[albumId] = data;
|
|
||||||
if (s_coverData.size() > currentCachedCoverCount) {
|
|
||||||
s_coverNames.emplace_back(albumId);
|
|
||||||
|
|
||||||
// keep only the last 20 cover images around
|
if (data.isEmpty()) {
|
||||||
while (s_coverNames.size() > 20) {
|
return;
|
||||||
s_coverData.erase(s_coverNames.front());
|
|
||||||
s_coverNames.pop_front();
|
|
||||||
}
|
|
||||||
} else if (s_coverNames.back() != albumId) {
|
|
||||||
s_coverNames.remove(albumId);
|
|
||||||
s_coverNames.emplace_back(albumId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the cover to the results
|
|
||||||
m_results[row].cover = data;
|
|
||||||
emit coverAvailable(index(row, 0));
|
|
||||||
}
|
}
|
||||||
setFetchingCover(false);
|
|
||||||
|
// cache the fetched cover
|
||||||
|
const auto currentCachedCoverCount = s_coverData.size();
|
||||||
|
s_coverData[albumId] = data;
|
||||||
|
if (s_coverData.size() > currentCachedCoverCount) {
|
||||||
|
s_coverNames.emplace_back(albumId);
|
||||||
|
|
||||||
|
// keep only the last 20 cover images around
|
||||||
|
while (s_coverNames.size() > 20) {
|
||||||
|
s_coverData.erase(s_coverNames.front());
|
||||||
|
s_coverNames.pop_front();
|
||||||
|
}
|
||||||
|
} else if (s_coverNames.back() != albumId) {
|
||||||
|
s_coverNames.remove(albumId);
|
||||||
|
s_coverNames.emplace_back(albumId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the cover to the results
|
||||||
|
m_results[row].cover = data;
|
||||||
|
setResultsAvailable(true);
|
||||||
|
emit coverAvailable(index(row, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QtGui
|
} // namespace QtGui
|
||||||
|
|
|
@ -313,7 +313,9 @@ void LyricsWikiaResultsModel::handleLyricsReplyFinished(QNetworkReply *reply, in
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
parseLyricsResults(row, data);
|
parseLyricsResults(row, data);
|
||||||
}
|
}
|
||||||
setResultsAvailable(true);
|
if (!m_resultsAvailable) {
|
||||||
|
setResultsAvailable(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LyricsWikiaResultsModel::parseLyricsResults(int row, const QByteArray &data)
|
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));
|
textDoc.setHtml(html.mid(lyricsStart, (lyricsEnd > lyricsStart) ? (lyricsEnd - lyricsStart) : -1));
|
||||||
assocDesc.lyrics = textDoc.toPlainText();
|
assocDesc.lyrics = textDoc.toPlainText();
|
||||||
|
|
||||||
|
setResultsAvailable(true);
|
||||||
emit lyricsAvailable(index(row, 0));
|
emit lyricsAvailable(index(row, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -603,13 +603,8 @@ void DbQueryWidget::fetchAndShowCoverForSelection()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const QByteArray *const cover = m_model->cover(selectedIndex)) {
|
|
||||||
showCover(*cover);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_model->fetchCover(selectedIndex)) {
|
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);
|
showCover(*cover);
|
||||||
} else {
|
} else {
|
||||||
// cover couldn't be fetched, error tracked via resultsAvailable() signal so nothing to do
|
// cover couldn't be fetched, error tracked via resultsAvailable() signal so nothing to do
|
||||||
|
@ -632,14 +627,9 @@ void DbQueryWidget::fetchAndShowLyricsForSelection()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const QString *const lyrics = m_model->lyrics(selectedIndex)) {
|
|
||||||
showLyrics(*lyrics);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_model->fetchLyrics(selectedIndex)) {
|
if (m_model->fetchLyrics(selectedIndex)) {
|
||||||
if (const QByteArray *cover = m_model->cover(selectedIndex)) {
|
if (const auto *const lyrics = m_model->lyrics(selectedIndex)) {
|
||||||
showLyrics(*cover);
|
showLyrics(*lyrics);
|
||||||
} else {
|
} else {
|
||||||
// lyrics couldn't be fetched, error tracked via resultsAvailable() signal so nothing to do
|
// lyrics couldn't be fetched, error tracked via resultsAvailable() signal so nothing to do
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue