]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/gui/imagedelegate.cpp
Changed executable from vj to virtualjaguar to avoid possible future naming
[virtualjaguar] / src / gui / imagedelegate.cpp
index 70879151f081dc3d4f47a8cbdacf288fd94f63db..eaae05fc00ed1ac3e3b2478bcf6ee4f00f4036e6 100644 (file)
 // class utilized in FilePicker.
 
 #include "imagedelegate.h"
-#warning "Move ROM database to its own file... !!! FIX !!!"
-#include "filethread.h"
 
+#include "filedb.h"
 
-ImageDelegate::ImageDelegate(QObject * parent): QAbstractItemDelegate(parent), pixelSize(12)
+
+//ImageDelegate::ImageDelegate(QObject * parent): QAbstractItemDelegate(parent)//, pixelSize(12)
+//{
+//}
+
+ImageDelegate::ImageDelegate()
 {
+       QImage cartImg(":/res/cart-blank.png");
+       QPainter painter(&cartImg);
+       painter.drawPixmap(23, 87, QPixmap(":/res/label-blank.png"));
+       painter.end();
+       cartSmall = cartImg.scaled(488/4, 395/4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
 }
 
 /*
@@ -72,12 +81,52 @@ The foreground of the item (the circle representing a pixel) must be rendered us
                option.rect.y() + option.rect.height()/2 - radius, 2*radius, 2*radius));
 #else
 //     painter->drawPixmap(option.rect.x()+8, option.rect.y()+8, 200, 94, QPixmap(":/res/labels/rayman.jpg"));
-       painter->drawPixmap(option.rect.x(), option.rect.y(), 488/2, 395/2, QPixmap(":/res/cart-blank.png"));
 //     painter->drawPixmap(option.rect.x()+13, option.rect.y()+51, 433/2, 203/2, QPixmap(":/res/labels/rayman.jpg"));
-       painter->drawPixmap(option.rect.x()+14, option.rect.y()+50, 433/2, 203/2, QPixmap(":/res/label-blank.png"));
-//Need to query the model for the data we're supposed to draw here...
+//     painter->drawPixmap(option.rect.x(), option.rect.y(), 488/2, 395/2, QPixmap(":/res/cart-blank.png"));
+
+
+       // This is crappy. We really should have a properly scaled image ready to go so we
+       // don't get Qt's default ugly looking fast scaling...
+#warning "!!! FIX !!! Need to create properly scaled down cart/label images!"
+//     unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt();
        unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt();
-       painter->drawText(17, 73, QString(romList[i].name));
+       QString filename = index.model()->data(index, Qt::EditRole).toString();
+       QImage label = index.model()->data(index, Qt::DecorationRole).value<QImage>();
+
+#if 0
+       if (role == Qt::DecorationRole)
+               return list.at(index.row()).label;
+       else if (role == Qt::DisplayRole)
+               return (uint)list.at(index.row()).dbIndex;
+       else if (role == Qt::EditRole)
+               return list.at(index.row()).filename;
+#endif
+
+//     if (romList[i].file[0] == 0)
+       if (label.isNull())
+       {
+//     painter->drawPixmap(option.rect.x()+14, option.rect.y()+50, 433/2, 203/2, QPixmap(":/res/label-blank.png"));
+//             painter->drawPixmap(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4, QPixmap(":/res/label-blank.png"));
+               painter->drawImage(option.rect.x() + 2, option.rect.y() + 2, cartSmall);
+//Need to query the model for the data we're supposed to draw here...
+//     painter->drawText(17, 73, QString(romList[i].name));
+//     painter->setPen(Qt::white);
+               painter->setPen(QColor(255, 128, 0, 255));
+//     painter->drawText(QRect(option.rect.x()+20, option.rect.y()+73, 196, 70), Qt::TextWordWrap | Qt::AlignHCenter, QString(romList[i].name));
+               painter->drawText(QRect(option.rect.x()+10, option.rect.y()+36, 196/2, 70/2), Qt::TextWordWrap | Qt::AlignHCenter, QString(romList[i].name));
+       }
+       else
+       {
+#if 0
+               QString filename(romList[i].file);
+               filename.prepend("./label/");
+               QImage img(filename);
+               painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), img);
+#else
+               painter->drawPixmap(option.rect.x() + 2, option.rect.y() + 2, 488/4, 395/4, QPixmap(":/res/cart-blank.png"));
+               painter->drawImage(QRect(option.rect.x()+2+7, option.rect.y()+2+25, 433/4, 203/4), label);
+#endif
+       }
 //26x100
 #endif
        painter->restore();
@@ -99,7 +148,8 @@ QSize ImageDelegate::sizeHint(const QStyleOptionViewItem & /* option */, const Q
        // 200x94 is shrunk dimension...
 //     return QSize(100, 47);
 //     return QSize(216, 110);
-       return QSize(488/2, 395/2);
+//     return QSize(488/2, 395/2);
+       return QSize((488/4) + 4, (395/4) + 4);
 }
 
 /*