Adding icon
[impuzzle] / src / imageimporter.cpp
index 961171f..e666335 100644 (file)
@@ -46,6 +46,7 @@ QList<PuzzleItem *> ImageImporter::newPieces(const QPixmap &pixmap, const int co
     QPixmap tmp;
 
     if(pixmap.isNull()) {
+        qDebug() << "Got NULL image - using default.jpg";
         tmp = QPixmap(":/images/default.jpg");
     }
     else {
@@ -60,13 +61,14 @@ QList<PuzzleItem *> ImageImporter::newPieces(const QPixmap &pixmap, const int co
 
     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;
     }
 
@@ -74,11 +76,15 @@ QList<PuzzleItem *> ImageImporter::newPieces(const QPixmap &pixmap, const int co
     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);
         }
     }