Create a unified base class to access the database.

Moved the default database class to QListDB and disallow leaking CMAObjects outside this class.
Rewrote QListDB and CMAEvent to use the new internal API.
Moved the file format constants to the base database class.
Moved the metadata loading methods to the base database class.
This commit is contained in:
codestation
2014-01-28 14:00:15 -04:30
parent e1aa32894d
commit b7ad2b13f4
15 changed files with 514 additions and 380 deletions

View File

@@ -66,12 +66,13 @@ void BackupManagerForm::removeEntry(BackupItem *item)
QMutexLocker locker(&db->mutex);
CMAObject *obj = db->ohfiToObject(item->ohfi);
if(obj) {
obj->removeReferencedObject();
db->remove(obj);
metadata meta;
if(db->getObjectMetadata(item->ohfi, meta)) {
setBackupUsage(db->getObjectSize(meta.ohfiParent));
}
db->deleteEntry(item->ohfi);
for(int i = 0; i < ui->tableWidget->rowCount(); ++i) {
BackupItem *iter_item = static_cast<BackupItem *>(ui->tableWidget->cellWidget(i, 0));
if(iter_item == item) {
@@ -79,11 +80,6 @@ void BackupManagerForm::removeEntry(BackupItem *item)
break;
}
}
obj = db->ohfiToObject(obj->metadata.ohfiParent);
if(obj) {
setBackupUsage(obj->metadata.size);
}
}
void BackupManagerForm::setBackupUsage(quint64 size)
@@ -146,10 +142,9 @@ void BackupManagerForm::loadBackupListing(int index)
db->mutex.lock();
// get the item list
// get the item list
metadata_t *meta;
int row_count = db->filterObjects(ohfi, &meta);
int row_count = db->getObjectMetadatas(ohfi, meta);
ui->tableWidget->setRowCount(row_count);
// exit if there aren't any items
@@ -167,13 +162,12 @@ void BackupManagerForm::loadBackupListing(int index)
#else
horiz_header->setResizeMode(QHeaderView::Stretch);
#endif
CMAObject *obj = db->ohfiToObject(ohfi);
setBackupUsage(obj->metadata.size);
setBackupUsage(db->getObjectSize(ohfi));
QString path = db->getAbsolutePath(ohfi);
QList<BackupItem *> item_list;
while(meta) {
QString base_path = obj->path + QDir::separator() + meta->name;
QString base_path = path + QDir::separator() + meta->name;
QString parent_path = sys_dir ? base_path + QDir::separator() + "sce_sys" : base_path;
SfoReader reader;
QString game_name;
@@ -213,7 +207,7 @@ void BackupManagerForm::loadBackupListing(int index)
item->setItemInfo(game_name, size, info);
item->setItemIcon(QDir(parent_path).absoluteFilePath(sys_dir ? "icon0.png" : "ICON0.PNG"), img_width, ohfi == VITA_OHFI_PSMAPP);
item->setDirectory(obj->path + QDir::separator() + meta->name);
item->setDirectory(path + QDir::separator() + meta->name);
item->resize(646, 68);
item_list << item;