X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilelistmodel.cpp;h=09389b86289043e5afd7b2d93af51bc2a4794aa9;hb=e0a3f430ecbda85e5f0903011bf8ffeb01f10fe0;hp=a975b82cc2e66f860ef7bdf37082086648869bd0;hpb=25cc16d819c81e08d2e21b57720dd4ea08ae9e25;p=virtualjaguar diff --git a/src/gui/filelistmodel.cpp b/src/gui/filelistmodel.cpp index a975b82..09389b8 100644 --- a/src/gui/filelistmodel.cpp +++ b/src/gui/filelistmodel.cpp @@ -27,17 +27,42 @@ FileListModel::FileListModel(QObject * parent/*= 0*/): QAbstractListModel(parent 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()); +//It could be that this is fucking things up... +#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; + else if (role == Qt::WhatsThisRole) + return (uint)list.at(index.row()).fileSize; + else + return QVariant(); +#else + if (role == FLM_LABEL) + return list.at(index.row()).label; + else if (role == FLM_INDEX) + return (uint)list.at(index.row()).dbIndex; + else if (role == FLM_FILENAME) + return list.at(index.row()).filename; + else if (role == FLM_FILESIZE) + return (uint)list.at(index.row()).fileSize; + + return QVariant(); +#endif } -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... @@ -58,6 +83,7 @@ QVariant FileListModel::headerData(int section, Qt::Orientation orientation, int #endif } +/* void FileListModel::AddData(QIcon pix) { pixList.push_back(pix); @@ -69,7 +95,26 @@ void FileListModel::AddData(unsigned long index) dbIndex.push_back(index); reset(); } +*/ + +void FileListModel::AddData(unsigned long index, QString str, QImage img, unsigned long size) +{ + // Assuming that both QString and QImage have copy constructors, this should work. + FileListData data; + + data.dbIndex = index; + data.fileSize = size; + 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