X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilepicker.cpp;h=06e517d0e2d5235c4a014d6c46f5c46aa0c39c5f;hb=f24ae2128609d5ab8c9a57dfd9dbb46afb7302a9;hp=d7f1507293885e82c4910a6b6967b0bd6390f2ec;hpb=481bb094f715443e52695fc46307785e61556c0d;p=virtualjaguar diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index d7f1507..06e517d 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -15,6 +15,7 @@ #include "filepicker.h" +#include "file.h" #include "filedb.h" #include "filelistmodel.h" #include "filethread.h" @@ -132,10 +133,10 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); labels->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); dataLayout->addWidget(labels); data = new QLabel(QString(tr( - "4MB Cartridge
" - "FEDCBA98
" - "DOES NOT WORK
" - "Universal Header detected; Requires DSP" + "?MB Cartridge
" + "????????
" + "???
" + "???" ))); data->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); dataLayout->addWidget(data); @@ -161,8 +162,14 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); fileThread = new FileThread(this); // connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long))); - connect(fileThread, SIGNAL(FoundAFile2(unsigned long, QString, QImage *, unsigned long)), this, SLOT(AddFileToList2(unsigned long, QString, QImage *, unsigned long))); - fileThread->Go(); +// connect(fileThread, SIGNAL(FoundAFile2(unsigned long, QString, QImage *, unsigned long)), this, SLOT(AddFileToList2(unsigned long, QString, QImage *, unsigned long))); + connect(fileThread, SIGNAL(FoundAFile3(unsigned long, QString, QImage *, + unsigned long, bool, unsigned long, unsigned long)), this, + SLOT(AddFileToList3(unsigned long, QString, QImage *, unsigned long, + bool, unsigned long, unsigned long))); + +// Let's defer this to the main window, so we can have some control over when this is done. +// fileThread->Go(); /* New sizes: 373x172 (label), 420x340 (cart) */ @@ -179,6 +186,13 @@ QString FilePickerWindow::GetSelectedPrettyName(void) return prettyFilename; } +void FilePickerWindow::ScanSoftwareFolder(bool allow/*= false*/) +{ + // "allow" is whether or not to allow scanning for unknown software. + model->ClearData(); + fileThread->Go(allow); +} + // // This slot gets called by the FileThread's run() function when it finds a // match in the filesystem to a ROM on our CRC list. @@ -193,7 +207,9 @@ printf("FilePickerWindow: Found match [%s]...\n", romList[index].name); void FilePickerWindow::AddFileToList2(unsigned long index, QString str, QImage * img, unsigned long size) { -printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name); +if (index != 0xFFFFFFFF) + printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name); + if (img) { model->AddData(index, str, *img, size); @@ -204,6 +220,21 @@ printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name); model->AddData(index, str, QImage(), size); } +void FilePickerWindow::AddFileToList3(unsigned long index, QString str, QImage * img, unsigned long size, bool haveUniversalHeader, unsigned long fileType, unsigned long crc) +{ +if (index != 0xFFFFFFFF) + printf("FilePickerWindow(3): Found match [%s]...\n", romList[index].name); + + if (img) + { + 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 @@ -229,9 +260,15 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel unsigned long i = current.model()->data(current, FLM_INDEX).toUInt(); QImage label = current.model()->data(current, FLM_LABEL).value(); 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; @@ -268,27 +305,101 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel // 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(":/res/cart-blank.png"); - QPainter painter(&cart); -// painter.drawPixmap(23, 87, QPixmap::fromImage(QImage(":/res/label-blank.png"))); - painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/label-blank.png"))); - painter.end(); + 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 - prettyFilename = romList[i].name; - title->setText(QString("

%1

").arg(romList[i].name)); + if (!haveUnknown) + prettyFilename = romList[i].name; + else + { + int lastSlashPos = currentFile.lastIndexOf('/'); + prettyFilename = "\"" + currentFile.mid(lastSlashPos + 1) + "\""; + } + + title->setText(QString("

%1

").arg(prettyFilename)); + //Kludge for now, we'll have to fix this later... - QString fileType = QString(romList[i].flags & FF_ROM ? "%1MB Cartridge" : "%1*** UNKNOWN ***") - .arg(fileSize / 1048576); - QString crcString = QString("%1").arg(romList[i].crc32, 8, 16, QChar('0')).toUpper(); - QString notes = -/* (romList[i].flags & FF_ROM ? "Jaguar ROM " : "")*/ - QString(romList[i].flags & FF_BAD_DUMP ? "BAD DUMP" : ""); - data->setText(QString("%1
%2
%3
%4").arg(fileType).arg(crcString).arg("???%").arg(notes)); +// So let's fix it now! + QString fileTypeString, crcString, notes, compatibility; + +#if 0 + if (!haveUnknown) + { + if (romList[i].flags & FF_ROM) + fileTypeString = QString(tr("%1MB Cartridge")).arg(fileSize / 1048576); + else if (romList[i].flags & FF_ALPINE) + fileTypeString = QString(tr("%1MB Alpine ROM")).arg(fileSize / 1048576); + else + fileTypeString = QString(tr("*** UNKNOWN *** (%1 bytes)")).arg(fileSize); + } +#else + if ((!haveUnknown && (romList[i].flags & FF_ROM)) || (haveUnknown && (fileType == JST_ROM))) + fileTypeString = QString(tr("%1MB Cartridge")).arg(fileSize / 1048576); + else if ((!haveUnknown && (romList[i].flags & FF_ALPINE)) || (haveUnknown && (fileType == JST_ALPINE))) + fileTypeString = QString(tr("%1MB Alpine ROM")).arg(fileSize / 1048576); + else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2)) + fileTypeString = QString(tr("ABS/COF Executable (%1 bytes)")).arg(fileSize); + else if (haveUnknown && (fileType == JST_JAGSERVER)) + fileTypeString = QString(tr("Jaguar Server Executable (%1 bytes)")).arg(fileSize); + else + fileTypeString = QString(tr("*** UNKNOWN *** (%1 bytes)")).arg(fileSize); +#endif + +// crcString = QString("%1").arg(romList[i].crc32, 8, 16, QChar('0')).toUpper(); + crcString = QString("%1").arg(crc, 8, 16, QChar('0')).toUpper(); + + if (!haveUnknown && (romList[i].flags & FF_NON_WORKING)) + compatibility = "DOES NOT WORK"; + else + compatibility = "Unknown"; + + // This is going to need some formatting love before long... + if (!haveUnknown && (romList[i].flags & FF_BAD_DUMP)) + notes = "BAD DUMP"; + + if (haveUniversalHeader) + notes += " Universal Header detected"; + + if (!haveUnknown && (romList[i].flags & FF_REQ_DSP)) + notes += " Requires DSP"; + + if (!haveUnknown && (romList[i].flags & FF_VERIFIED)) + notes += " (Verified)"; + + data->setText(QString("%1
%2
%3
%4") + .arg(fileTypeString).arg(crcString).arg(compatibility).arg(notes)); } /* @@ -314,6 +425,4 @@ Compatibility: Unknown CRC32: 44889921 Compatibility: 80% (or ****) Notes: EEPROM available - - */