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