Browse Source

Fix wrong file names displayed in tooltip

Also rename variable.
Closes #17179.
adaptive-webui-19844
Chocobo1 2 years ago
parent
commit
9cb686a6b7
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 23
      src/gui/properties/piecesbar.cpp

23
src/gui/properties/piecesbar.cpp

@ -265,30 +265,25 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
{ {
const PieceIndexToImagePos transform {torrentInfo, m_image}; const PieceIndexToImagePos transform {torrentInfo, m_image};
const int pieceIndex = transform.pieceIndex(imagePos); const int pieceIndex = transform.pieceIndex(imagePos);
const QVector<int> files {torrentInfo.fileIndicesForPiece(pieceIndex)}; const QVector<int> fileIndexes = torrentInfo.fileIndicesForPiece(pieceIndex);
QString tooltipTitle; QString tooltipTitle;
if (files.count() > 1) if (fileIndexes.count() > 1)
{
tooltipTitle = tr("Files in this piece:"); tooltipTitle = tr("Files in this piece:");
} else if (torrentInfo.fileSize(fileIndexes.front()) == torrentInfo.pieceLength(pieceIndex))
tooltipTitle = tr("File in this piece:");
else else
{ tooltipTitle = tr("File in these pieces:");
if (torrentInfo.fileSize(files.front()) == torrentInfo.pieceLength(pieceIndex))
tooltipTitle = tr("File in this piece");
else
tooltipTitle = tr("File in these pieces");
}
toolTipText.reserve(files.size() * 128); toolTipText.reserve(fileIndexes.size() * 128);
toolTipText += u"<html><body>"; toolTipText += u"<html><body>";
DetailedTooltipRenderer renderer {toolTipText, tooltipTitle}; DetailedTooltipRenderer renderer {toolTipText, tooltipTitle};
for (const int f : files) for (const int index : fileIndexes)
{ {
const Path filePath = torrentInfo.filePath(f); const Path filePath = m_torrent->filePath(index);
renderer(Utils::Misc::friendlyUnit(torrentInfo.fileSize(f)), filePath); renderer(Utils::Misc::friendlyUnit(torrentInfo.fileSize(index)), filePath);
} }
toolTipText += u"</body></html>"; toolTipText += u"</body></html>";
} }

Loading…
Cancel
Save