int FileListModel::rowCount(const QModelIndex & parent/*= QModelIndex()*/) const
{
// return pixList.size();
- return dbIndex.size();
+// return dbIndex.size();
+ return list.size();
}
QVariant FileListModel::data(const QModelIndex & index, int role) const
{
// return QVariant();
// return pixList.at(index.row());
- return (uint)dbIndex.at(index.row());
+// return (uint)dbIndex.at(index.row());
+ 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;
+ else
+ return QVariant();
}
-QVariant FileListModel::headerData(int section, Qt::Orientation orientation, int role/*= Qt::DisplayRole*/) 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...
reset();
}
+void FileListModel::AddData(unsigned long index, QString str, QImage img)
+{
+ // Assuming that both QString and QImage have copy constructors, this should work.
+ FileListData data;
+
+ data.dbIndex = index;
+ data.filename = str;
+ data.label = img;
+
+ list.push_back(data);
+ reset();
+}
+
+//FileListData FileListModel::GetData(const QModelIndex & index) const
+//{
+// return list.at(index.row());
+//}
#if 0
#include <QtGui>
#include <vector>
+struct FileListData
+{
+// FileListData(unsigned long ul=0, QString str="", QImage img=QImage()): dbIndex(ul), filename(str), label(img) {}
+// FileListData(unsigned long ul=0, QString str, QImage img): dbIndex(ul), filename(str), label(img) {}
+
+ unsigned long dbIndex;
+ QString filename;
+ QImage label;
+};
+
class FileListModel: public QAbstractListModel
{
public:
void AddData(QIcon pix);
void AddData(unsigned long);
+ void AddData(unsigned long, QString, QImage);
+
+// FileListData GetData(const QModelIndex & index) const;
private:
std::vector<QIcon> pixList;
std::vector<unsigned long> dbIndex;
+ std::vector<FileListData> list;
};
#endif // __FILELISTMODEL_H__
layout->addWidget(fileList);
fileThread = new FileThread(this);
- connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long)));
+// connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long)));
+ connect(fileThread, SIGNAL(FoundAFile2(unsigned long, QString, QImage *)), this, SLOT(AddFileToList2(unsigned long, QString, QImage *)));
fileThread->Go();
}
// model->AddData(QIcon(":/res/generic.png"));
model->AddData(index);
}
+
+void FilePickerWindow::AddFileToList2(unsigned long index, QString str, QImage * img)
+{
+printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name);
+ if (img)
+ model->AddData(index, str, *img);
+ else
+ model->AddData(index, str, QImage());
+}
+
public slots:
void AddFileToList(unsigned long index);
+ void AddFileToList2(unsigned long index, QString, QImage *);
protected:
// void PopulateList(void);
// --- ---------- -------------------------------------------------------------
// JLH 01/28/2010 Created this file
// JLH 02/16/2010 Moved RomIdentifier stuff to its own file
+// JLH 03/02/2010 Added .ZIP file fishing
//
#include "filethread.h"
QFileInfo fileInfo = list.at(i);
+ // ZIP files are special: They contain more than just the software now... ;-)
+ // So now we fish around inside them to pull out the stuff we want.
+ // Probably also need more stringent error checking as well... :-O
if (fileInfo.suffix().compare("zip", Qt::CaseInsensitive) == 0)
{
uint8 * buffer = NULL;
delete[] buffer;
// Mebbe we should pass a index AND a QImage here???
+/*
+Let's think about this... What *do* we need to send out?
+we need the filename for sure. image file if it exists.
+do we need the index? I think we're only using it to pull the label from the subdir...
+we might need it if we want to pull ROM flags from the fileDB...
+*/
if (index != 0xFFFFFFFF && !(romList[index].flags & FF_BIOS))
{
QImage img;
}
//printf("FileThread: Attempted to load image. Size: %u x %u...\n", img.width(), img.height());
- emit FoundAFile(index);
+// emit FoundAFile(index);
+ emit FoundAFile2(index, fileInfo.canonicalFilePath(), &img);
}
}
}
// Mebbe we should pass a index AND a QImage here???
if (index != 0xFFFFFFFF && !(romList[index].flags & FF_BIOS))
- emit FoundAFile(index);
+// emit FoundAFile(index);
+ emit FoundAFile2(index, fileInfo.canonicalFilePath(), 0);
}
}
}
signals:
void FoundAFile(unsigned long index);
+ void FoundAFile2(unsigned long index, QString filename, QImage * label);
protected:
void run(void);
#include "imagedelegate.h"
#include "filedb.h"
+//#include "filelistmodel.h"
ImageDelegate::ImageDelegate(QObject * parent): QAbstractItemDelegate(parent), pixelSize(12)
// painter->drawPixmap(option.rect.x()+13, option.rect.y()+51, 433/2, 203/2, QPixmap(":/res/labels/rayman.jpg"));
// painter->drawPixmap(option.rect.x(), option.rect.y(), 488/2, 395/2, QPixmap(":/res/cart-blank.png"));
painter->drawPixmap(option.rect.x(), option.rect.y(), 488/4, 395/4, QPixmap(":/res/cart-blank.png"));
+// 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>();
- if (romList[i].file[0] == 0)
+#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
+
+// 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"));
painter->drawPixmap(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4, QPixmap(":/res/label-blank.png"));
}
else
{
+#if 0
QString filename(romList[i].file);
filename.prepend("./label/");
QImage img(filename);
painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), img);
+#else
+ painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), label);
+#endif
}
//26x100
#endif