]> Shamusworld >> Repos - virtualjaguar/commitdiff
More ROM picker refinements...
authorShamus Hammons <jlhamm@acm.org>
Thu, 4 Feb 2010 20:26:53 +0000 (20:26 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 4 Feb 2010 20:26:53 +0000 (20:26 +0000)
Makefile
src/gui/app.cpp
src/gui/filelistmodel.cpp
src/gui/filepicker.cpp
src/gui/filepicker.h
src/gui/filethread.cpp
src/gui/filethread.h

index f0ae69e7a65f878cc199520d692d37799f9a0e36..1bc442f9ba52180725ddaa7b79e0fb8bb05380cf 100644 (file)
--- 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      \
index 3bd8c6ce8aade20fcbec73113227635b2309521a..9a2cdbfaddba548b5fef72f0fa73a35275ac319d 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <QApplication>
 #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<uint32>();
 
        App app(argc, argv);                                            // Declare an instance of the application
 
index b509957d144a9d10014139735aac24e49a02f8e6..2730a4509ad82e07c8eb0b0ce69ab586e12f0199 100644 (file)
@@ -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)
index a221d03a2fbd3f030dd6a99b95a09b8e556b2202..e8a44d1bad7ea9d88d32fb99bd71fa06170afdff 100644 (file)
@@ -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)
 {
index a476a50c8817a619064ec9dedc43da5e4b370a61..e11dc34777729f31b3b51f40c165dfc1f30ed3ec 100644 (file)
@@ -3,20 +3,31 @@
 //
 
 #include <QtGui>
+#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;
 };
index 55d9e4223a8a93b93615e8ae7923c944f869eb81..8bb2b87b70f4edda23d8acd3369b9ebc136ee784 100644 (file)
@@ -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);
                        }
                }
 
index aec0038fa70d05726af9a4d40d1c974b34cb98a8..12c316fa52d2bfaa4427466b946190d44cd059de 100644 (file)
@@ -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);