|
|
@ -63,28 +63,31 @@ public: |
|
|
|
const qulonglong nb_pieces = pieces.size(); |
|
|
|
const qulonglong nb_pieces = pieces.size(); |
|
|
|
// Reduce the number of pieces before creating the pixmap
|
|
|
|
// Reduce the number of pieces before creating the pixmap
|
|
|
|
// otherwise it can crash when there are too many pieces
|
|
|
|
// otherwise it can crash when there are too many pieces
|
|
|
|
if(nb_pieces > (uint)width()) { |
|
|
|
const uint w = width(); |
|
|
|
const int ratio = floor(nb_pieces/(double)width()); |
|
|
|
if(nb_pieces > w) { |
|
|
|
std::vector<bool> scaled_pieces; |
|
|
|
const uint ratio = floor(nb_pieces/(double)w); |
|
|
|
std::vector<bool> scaled_downloading; |
|
|
|
bitfield scaled_pieces(ceil(nb_pieces/(double)ratio), false); |
|
|
|
|
|
|
|
bitfield scaled_downloading(ceil(nb_pieces/(double)ratio), false); |
|
|
|
|
|
|
|
uint scaled_index = 0; |
|
|
|
for(qulonglong i=0; i<nb_pieces; i+= ratio) { |
|
|
|
for(qulonglong i=0; i<nb_pieces; i+= ratio) { |
|
|
|
bool have = true; |
|
|
|
bool have = true; |
|
|
|
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) { |
|
|
|
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) { |
|
|
|
if(!pieces[i]) { have = false; break; } |
|
|
|
if(!pieces[i]) { have = false; break; } |
|
|
|
} |
|
|
|
} |
|
|
|
scaled_pieces.push_back(have); |
|
|
|
|
|
|
|
if(have) { |
|
|
|
if(have) { |
|
|
|
scaled_downloading.push_back(false); |
|
|
|
scaled_pieces.set_bit(scaled_index); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
bool downloading = false; |
|
|
|
bool downloading = false; |
|
|
|
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) { |
|
|
|
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) { |
|
|
|
if(downloading_pieces[i]) { downloading = true; break; } |
|
|
|
if(downloading_pieces[i]) { downloading = true; break; } |
|
|
|
} |
|
|
|
} |
|
|
|
scaled_downloading.push_back(downloading); |
|
|
|
if(downloading) |
|
|
|
|
|
|
|
scaled_downloading.set_bit(scaled_index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
++scaled_index; |
|
|
|
} |
|
|
|
} |
|
|
|
QPixmap pix = QPixmap(scaled_pieces.size(), 1); |
|
|
|
QPixmap pix = QPixmap(scaled_pieces.size(), 1); |
|
|
|
pix.fill(); |
|
|
|
//pix.fill();
|
|
|
|
QPainter painter(&pix); |
|
|
|
QPainter painter(&pix); |
|
|
|
for(uint i=0; i<scaled_pieces.size(); ++i) { |
|
|
|
for(uint i=0; i<scaled_pieces.size(); ++i) { |
|
|
|
if(scaled_pieces[i]) { |
|
|
|
if(scaled_pieces[i]) { |
|
|
@ -101,7 +104,7 @@ public: |
|
|
|
pixmap = pix; |
|
|
|
pixmap = pix; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
QPixmap pix = QPixmap(pieces.size(), 1); |
|
|
|
QPixmap pix = QPixmap(pieces.size(), 1); |
|
|
|
pix.fill(); |
|
|
|
//pix.fill();
|
|
|
|
QPainter painter(&pix); |
|
|
|
QPainter painter(&pix); |
|
|
|
for(uint i=0; i<pieces.size(); ++i) { |
|
|
|
for(uint i=0; i<pieces.size(); ++i) { |
|
|
|
if(pieces[i]) { |
|
|
|
if(pieces[i]) { |
|
|
|