X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fimagedelegate.cpp;h=eaae05fc00ed1ac3e3b2478bcf6ee4f00f4036e6;hb=4beff2f35f649bb0befa58c8a89fdd702b3c9b4f;hp=f7dfa9b1d5603fbb49a0ea8507ea25522845b2fe;hpb=caf1236884015695c52910a75b8420be7c63d574;p=virtualjaguar diff --git a/src/gui/imagedelegate.cpp b/src/gui/imagedelegate.cpp index f7dfa9b..eaae05f 100644 --- a/src/gui/imagedelegate.cpp +++ b/src/gui/imagedelegate.cpp @@ -17,11 +17,19 @@ #include "imagedelegate.h" #include "filedb.h" -//#include "filelistmodel.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); } /* @@ -75,7 +83,11 @@ The foreground of the item (the circle representing a pixel) must be rendered us // painter->drawPixmap(option.rect.x()+8, option.rect.y()+8, 200, 94, QPixmap(":/res/labels/rayman.jpg")); // painter->drawPixmap(option.rect.x()+13, option.rect.y()+51, 433/2, 203/2, 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(), option.rect.y(), 488/4, 395/4, 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(); QString filename = index.model()->data(index, Qt::EditRole).toString(); @@ -94,7 +106,8 @@ The foreground of the item (the circle representing a pixel) must be rendered us 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->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); @@ -110,7 +123,8 @@ The foreground of the item (the circle representing a pixel) must be rendered us QImage img(filename); painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), img); #else - painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), label); + 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 @@ -135,7 +149,7 @@ QSize ImageDelegate::sizeHint(const QStyleOptionViewItem & /* option */, const Q // return QSize(100, 47); // return QSize(216, 110); // return QSize(488/2, 395/2); - return QSize(488/4, 395/4); + return QSize((488/4) + 4, (395/4) + 4); } /*