From 09adab3161f986d5cc8dbeffe15cb6545afa138f Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 4 Feb 2010 20:26:53 +0000 Subject: [PATCH] More ROM picker refinements... --- Makefile | 2 ++ src/gui/app.cpp | 3 +++ src/gui/filelistmodel.cpp | 8 ++++++++ src/gui/filepicker.cpp | 19 ++++++++++++++++--- src/gui/filepicker.h | 13 ++++++++++++- src/gui/filethread.cpp | 2 +- src/gui/filethread.h | 5 +++++ 7 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index f0ae69e..1bc442f 100644 --- a/Makefile +++ b/Makefile @@ -76,8 +76,10 @@ OBJS = \ obj/app.o \ obj/configwin.o \ obj/filepicker.o \ + obj/moc_filepicker.o \ obj/filelistmodel.o \ obj/filethread.o \ + obj/moc_filethread.o \ obj/mainwin.o \ obj/moc_mainwin.o \ obj/glwidget.o \ diff --git a/src/gui/app.cpp b/src/gui/app.cpp index 3bd8c6c..9a2cdbf 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -15,6 +15,7 @@ #include #include "mainwin.h" +#include "types.h" // Here's the main application loop--short and simple... int main(int argc, char * argv[]) @@ -32,6 +33,8 @@ int main(int argc, char * argv[]) Q_INIT_RESOURCE(vj); // This must the same name as the exe filename //or is it the .qrc filename??? + // This is so we can pass this stuff using signal/slot mechanism... +//ick int id = qRegisterMetaType(); App app(argc, argv); // Declare an instance of the application diff --git a/src/gui/filelistmodel.cpp b/src/gui/filelistmodel.cpp index b509957..2730a45 100644 --- a/src/gui/filelistmodel.cpp +++ b/src/gui/filelistmodel.cpp @@ -37,6 +37,7 @@ QVariant FileListModel::data(const QModelIndex & index, int role) const QVariant FileListModel::headerData(int section, Qt::Orientation orientation, int role/*= Qt::DisplayRole*/) const { +#if 0 // Not sure that this is necessary for our purposes... // Especially since this model would never make use of this info... if (role != Qt::DisplayRole) @@ -46,6 +47,13 @@ QVariant FileListModel::headerData(int section, Qt::Orientation orientation, int return QString("Column %1").arg(section); else return QString("Row %1").arg(section); +#else + // This seems more like what we want... + if (role == Qt::SizeHintRole) + return QSize(1, 1); + + return QVariant(); +#endif } void FileListModel::AddData(QIcon pix) diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index a221d03..e8a44d1 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -14,6 +14,7 @@ #include "filepicker.h" #include "crc32.h" +#include "filelistmodel.h" #include "filethread.h" #include "settings.h" #include "types.h" @@ -113,18 +114,22 @@ FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt: setWindowTitle("Insert Cartridge..."); #if 1 - fileList = new QListWidget(this); + fileList2 = new QListWidget(this); // addWidget(fileList); QVBoxLayout * layout = new QVBoxLayout(); // layout->setSizeConstraint(QLayout::SetFixedSize); setLayout(layout); - layout->addWidget(fileList); + layout->addWidget(fileList2); // PopulateList(); fileThread = new FileThread(this); - fileThread->Go(fileList); + + /*bool b =*/ connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long))); +//printf("FilePickerWindow: Connection to FileThread %s...\n", (b ? "succeeded" : "failed")); + + fileThread->Go(fileList2); #else QStringList numbers; numbers << "One" << "Two" << "Three" << "Four" << "Five"; @@ -136,6 +141,14 @@ view->setModel(model); #endif } +// Need a slot here to pickup stuff from the thread... + +void FilePickerWindow::AddFileToList(unsigned long index) +{ + printf("--> Found CRC: %08X...\n", (uint32)index); +} + + /* void FilePickerWindow::PopulateList(void) { diff --git a/src/gui/filepicker.h b/src/gui/filepicker.h index a476a50..e11dc34 100644 --- a/src/gui/filepicker.h +++ b/src/gui/filepicker.h @@ -3,20 +3,31 @@ // #include +#include "types.h" // Forward declarations class QListWidget; class FileThread; +class FileListModel; +class QListView; class FilePickerWindow: public QWidget { + // Once we have signals/slots, we need this... + Q_OBJECT + public: FilePickerWindow(QWidget * parent = 0); + public slots: + void AddFileToList(unsigned long index); + protected: // void PopulateList(void); private: - QListWidget * fileList; + QListWidget * fileList2; FileThread * fileThread; + FileListModel * model; + QListView * fileList; }; diff --git a/src/gui/filethread.cpp b/src/gui/filethread.cpp index 55d9e42..8bb2b87 100644 --- a/src/gui/filethread.cpp +++ b/src/gui/filethread.cpp @@ -167,7 +167,7 @@ printf("FileThread: Aborting!!!\n"); { printf("FileThread: Found match [%s]...\n", romList[index].name); new QListWidgetItem(QIcon(":/res/generic.png"), romList[index].name, listWidget); -// break; + emit FoundAFile(romList[index].crc32); } } diff --git a/src/gui/filethread.h b/src/gui/filethread.h index aec0038..12c316f 100644 --- a/src/gui/filethread.h +++ b/src/gui/filethread.h @@ -13,11 +13,16 @@ class QListWidget; class FileThread: public QThread { + Q_OBJECT + public: FileThread(QObject * parent = 0); ~FileThread(); void Go(QListWidget * lw); + signals: + void FoundAFile(unsigned long index); + protected: void run(void); uint32 FindCRCIndexInFileList(uint32); -- 2.37.2