|
|
@ -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>"; |
|
|
|
} |
|
|
|
} |
|
|
|