QPixmap tmp;
if(pixmap.isNull()) {
+ qDebug() << "Got NULL image - using default.jpg";
tmp = QPixmap(":/images/default.jpg");
}
else {
int horizontalCount = 0;
- if(count == 12) {
- horizontalCount = 4;
+ if(count == EASY_PIECE_COUNT) {
+ horizontalCount = EASY_HORIZONTAL_COUNT;
}
- else if(count == 20) {
- horizontalCount = 5;
+ else if(count == HARD_PIECE_COUNT) {
+ horizontalCount = HARD_HORIZONTAL_COUNT;
}
else {
+ qDebug() << QString("Bad piece count ( %1 ) @ ImageImporter::newPieces").arg(count);
return list;
}
int verticalStep = IMAGE_HEIGHT / verticalCount;
int horizontalStep = IMAGE_WIDTH / horizontalCount;
+ int pieceNo = 1;
+
for(int i = 0; i < verticalCount; ++i) {
for(int j = 0; j < horizontalCount; ++j) {
PuzzleItem *item = new PuzzleItem;
item->setPixmap(tmp.copy(QRect(QPoint(j * horizontalStep, i * verticalStep),
QPoint(horizontalStep + j * horizontalStep, verticalStep + i * verticalStep))));
+ item->setPieceNumber(pieceNo);
+ pieceNo++;
list.append(item);
}
}