making future proof refactor of image and video get system

This commit is contained in:
Chris Cochrun 2022-04-11 14:04:03 -05:00
parent 8d07c7355d
commit f1378cc1ff
8 changed files with 72 additions and 44 deletions

View file

@ -156,12 +156,28 @@ void VideoSqlModel::updateFilePath(const int &row, const QUrl &filePath) {
emit filePathChanged();
}
QVariantList VideoSqlModel::getVideo(const int &row) {
qDebug() << "Row we are getting is " << row;
QVariantList video;
QSqlRecord rec = record(row);
qDebug() << rec.value("title");
video.append(rec.value("title"));
video.append(rec.value("filePath"));
return video;
QVariantMap VideoSqlModel::getVideo(const int &row) {
// qDebug() << "Row we are getting is " << row;
// QVariantList video;
// QSqlRecord rec = record(row);
// qDebug() << rec.value("title");
// video.append(rec.value("title"));
// video.append(rec.value("filePath"));
// return video;
QVariantMap data;
const QModelIndex idx = this->index(row,0);
// qDebug() << idx;
if( !idx.isValid() )
return data;
const QHash<int,QByteArray> rn = roleNames();
// qDebug() << rn;
QHashIterator<int,QByteArray> it(rn);
while (it.hasNext()) {
it.next();
qDebug() << it.key() << ":" << it.value();
data[it.value()] = idx.data(it.key());
}
return data;
}