+ {
+ model->AddData(index, str, *img, size, haveUniversalHeader, fileType, crc);
+//It would be better to pass the pointer into the model though...
+ delete img;
+ }
+ else
+ model->AddData(index, str, QImage(), size, haveUniversalHeader, fileType, crc);
+}
+
+void FilePickerWindow::LoadButtonPressed(void)
+{
+ // TODO: Get the text of the current selection, call the MainWin slot for loading
+ emit(RequestLoad(currentFile));
+ this->hide();
+}
+
+//
+// This slot gets called when the QListView gets clicked on. Updates
+// the cart graphic and accompanying text.
+//
+void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModelIndex &/*previous*/)
+{
+#if 0
+ QString s = current.model()->data(current, Qt::EditRole).toString();
+ unsigned long i = current.model()->data(current, Qt::DisplayRole).toUInt();
+ QImage label = current.model()->data(current, Qt::DecorationRole).value<QImage>();
+// printf("FPW: %s\n", s.toAscii().data());
+ unsigned long fileSize = current.model()->data(current, Qt::WhatsThisRole).toUInt();
+#else
+// QString s = current.model()->data(current, FLM_FILENAME).toString();
+ currentFile = current.model()->data(current, FLM_FILENAME).toString();
+ unsigned long i = current.model()->data(current, FLM_INDEX).toUInt();
+ QImage label = current.model()->data(current, FLM_LABEL).value<QImage>();
+ unsigned long fileSize = current.model()->data(current, FLM_FILESIZE).toUInt();
+ bool haveUniversalHeader = current.model()->data(current, FLM_UNIVERSALHDR).toBool();
+ unsigned long fileType = current.model()->data(current, FLM_FILETYPE).toUInt();
+ uint32 crc = (uint32)current.model()->data(current, FLM_CRC).toUInt();
+// printf("FPW: %s\n", s.toAscii().data());
+ bool haveUnknown = (i == 0xFFFFFFFF ? true : false);
+#endif
+
+ // Disallow loading completely unknown files, but allow all others.
+ insertCart->setEnabled(haveUnknown && (fileType == JST_NONE) ? false : true);
+//hm.
+//currentFile = s;
+
+//373x172 is label size...
+//365x168 now...
+ if (!label.isNull())
+ {
+/*
+ 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);
+*/
+ QImage cart(":/res/cart-blank.png");
+ QPainter painter(&cart);
+//Though this should probably be done when this is loaded, instead of every time here...
+//QImage scaledImg = label.scaled(373, 172, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+//painter.drawPixmap(23, 87, QPixmap::fromImage(scaledImg));
+ // Now, looks like it is...
+// painter.drawPixmap(23, 87, QPixmap::fromImage(label));
+ painter.drawPixmap(27, 89, QPixmap::fromImage(label));
+// painter.drawPixmap(23, 87, 373, 172, QPixmap::fromImage(label));
+
+// Well, heck. This should be done to the label *before* we get here.
+ painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/upper-left.png")));
+ painter.drawPixmap(27+355, 89, QPixmap::fromImage(QImage(":/res/upper-right.png")));
+
+ painter.end();
+ cartImage->setPixmap(QPixmap::fromImage(cart));
+ }
+ else
+ {
+ // We should try to be intelligent with our updates here, and only redraw when
+ // we're going from a selection with a label to a selection without. Now, we
+ // redraw regardless.
+ QImage cart;
+
+// We now have to sources of data for the passed in files:
+// - The file DB
+// - The file type detection
+// This means we have to be mindful of what's passed back by that stuff.
+// We can assume that if it wasn't found in the DB, then the fileType
+// should be valid.
+// The DB takes precedence over the fileType.
+ if ((!haveUnknown && (romList[i].flags & FF_ROM))
+ || (haveUnknown && (fileType == JST_ROM)))
+ {
+ cart = QImage(":/res/cart-blank.png");
+ QPainter painter(&cart);
+ painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/label-blank.png")));
+ painter.end();
+ }
+ else if ((!haveUnknown && (romList[i].flags & FF_ALPINE))
+ || (haveUnknown && (fileType == JST_ALPINE)))
+ {
+ cart = QImage(":/res/alpine-file.png");
+ }
+ else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2 || fileType == JST_JAGSERVER))
+ {
+ cart = QImage(":/res/homebrew-file.png");
+ }
+ else
+ cart = QImage(":/res/unknown-file.png");
+
+ cartImage->setPixmap(QPixmap::fromImage(cart));
+ }
+
+//1048576
+//2097152
+//4194304
+ if (!haveUnknown)
+ prettyFilename = romList[i].name;