X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fimagedelegate.cpp;h=06fb43e96c54bdbac811ef28fef08c2890749506;hb=6f25f63a18153bc2adc49c5f9a3862c2760716df;hp=b5dc508d8316f966584dbb344f6b866aa3ca5342;hpb=47c26d5d9daba6072bc580029e711292393d3158;p=virtualjaguar diff --git a/src/gui/imagedelegate.cpp b/src/gui/imagedelegate.cpp index b5dc508..06fb43e 100644 --- a/src/gui/imagedelegate.cpp +++ b/src/gui/imagedelegate.cpp @@ -1,10 +1,10 @@ // // imagedelegate.cpp - Qt Model/View rendering class // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- @@ -15,12 +15,21 @@ // class utilized in FilePicker. #include "imagedelegate.h" -#warning "Move ROM database to its own file... !!! FIX !!!" -#include "filethread.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); } /* @@ -74,26 +83,51 @@ 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")); - unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt(); - if (romList[i].file[0] == 0) + + // 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!" +//We've got the carts, now just need to do the labels... + + unsigned long i = index.model()->data(index, FLM_INDEX).toUInt(); + QString filename = index.model()->data(index, FLM_FILENAME).toString(); + QImage label = index.model()->data(index, FLM_LABEL).value(); + QString nameToDraw; + + if (i == 0xFFFFFFFF) // Not found... + { + int lastSlashPos = filename.lastIndexOf('/'); + nameToDraw = "\"" + filename.mid(lastSlashPos + 1) + "\""; + } + else + nameToDraw = romList[i].name; + + 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); - painter->setPen(QColor(255, 128, 0, 255)); + 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)); + painter->drawText(QRect(option.rect.x()+10, option.rect.y()+36, 196/2, 70/2), + Qt::TextWordWrap | Qt::AlignHCenter, nameToDraw); } 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 @@ -117,7 +151,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); } /*