]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/gui/imagedelegate.cpp
Various fixes for GPU/DSP DIV instruction, fixes for joypad handling.
[virtualjaguar] / src / gui / imagedelegate.cpp
index eaae05fc00ed1ac3e3b2478bcf6ee4f00f4036e6..06fb43e96c54bdbac811ef28fef08c2890749506 100644 (file)
@@ -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 <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // Who  When        What
 // ---  ----------  -------------------------------------------------------------
@@ -17,7 +17,7 @@
 #include "imagedelegate.h"
 
 #include "filedb.h"
-
+#include "filelistmodel.h"
 
 //ImageDelegate::ImageDelegate(QObject * parent): QAbstractItemDelegate(parent)//, pixelSize(12)
 //{
@@ -87,22 +87,23 @@ The foreground of the item (the circle representing a pixel) must be rendered us
 
        // 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();
-       QImage label = index.model()->data(index, Qt::DecorationRole).value<QImage>();
+//We've got the carts, now just need to do the labels...
 
-#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
+       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<QImage>();
+       QString nameToDraw;
+
+       if (i == 0xFFFFFFFF)    // Not found...
+       {
+               int lastSlashPos = filename.lastIndexOf('/');
+               nameToDraw = "\"" + filename.mid(lastSlashPos + 1) + "\"";
+       }
+       else
+               nameToDraw = romList[i].name;
 
-//     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"));
@@ -113,7 +114,8 @@ The foreground of the item (the circle representing a pixel) must be rendered us
 //     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));
+               painter->drawText(QRect(option.rect.x()+10, option.rect.y()+36, 196/2, 70/2),
+                       Qt::TextWordWrap | Qt::AlignHCenter, nameToDraw);
        }
        else
        {