Implement automatic database refresh on root category listing.
This commit is contained in:
@@ -29,6 +29,15 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
const int ohfi_array[] = {
|
||||||
|
VITA_OHFI_MUSIC, VITA_OHFI_PHOTO, VITA_OHFI_VIDEO,
|
||||||
|
VITA_OHFI_PACKAGE, VITA_OHFI_BACKUP, VITA_OHFI_VITAAPP,
|
||||||
|
VITA_OHFI_PSPAPP, VITA_OHFI_PSPSAVE, VITA_OHFI_PSXAPP,
|
||||||
|
VITA_OHFI_PSMAPP
|
||||||
|
};
|
||||||
|
|
||||||
static bool nameLessThan(const QFileInfo &v1, const QFileInfo &v2)
|
static bool nameLessThan(const QFileInfo &v1, const QFileInfo &v2)
|
||||||
{
|
{
|
||||||
if(v1.isDir() && v2.isDir()) {
|
if(v1.isDir() && v2.isDir()) {
|
||||||
@@ -115,24 +124,15 @@ void QListDB::clear()
|
|||||||
object_list.clear();
|
object_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QListDB::create()
|
int QListDB::createFromOhfi(int ohfi)
|
||||||
{
|
{
|
||||||
int total_objects = 0;
|
|
||||||
//QMutexLocker locker(&mutex);
|
|
||||||
const int ohfi_array[] = { VITA_OHFI_MUSIC, VITA_OHFI_PHOTO, VITA_OHFI_VIDEO,
|
|
||||||
VITA_OHFI_PACKAGE, VITA_OHFI_BACKUP, VITA_OHFI_VITAAPP,
|
|
||||||
VITA_OHFI_PSPAPP, VITA_OHFI_PSPSAVE, VITA_OHFI_PSXAPP,
|
|
||||||
VITA_OHFI_PSMAPP
|
|
||||||
};
|
|
||||||
CMAObject::resetOhfiCounter();
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
for(int i = 0, max = sizeof(ohfi_array) / sizeof(int); i < max; i++) {
|
CMARootObject *obj = new CMARootObject(ohfi);
|
||||||
CMARootObject *obj = new CMARootObject(ohfi_array[i]);
|
|
||||||
bool skipCurrent = false;
|
bool skipCurrent = false;
|
||||||
int dir_count;
|
int dir_count;
|
||||||
|
|
||||||
switch(ohfi_array[i]) {
|
switch(ohfi) {
|
||||||
case VITA_OHFI_MUSIC:
|
case VITA_OHFI_MUSIC:
|
||||||
obj->initObject(settings.value("musicPath").toString());
|
obj->initObject(settings.value("musicPath").toString());
|
||||||
skipCurrent = settings.value("musicSkip", false).toBool();
|
skipCurrent = settings.value("musicSkip", false).toBool();
|
||||||
@@ -166,7 +166,7 @@ int QListDB::create()
|
|||||||
emit directoryAdded(obj->m_path);
|
emit directoryAdded(obj->m_path);
|
||||||
|
|
||||||
if(!skipCurrent) {
|
if(!skipCurrent) {
|
||||||
dir_count = recursiveScanRootDirectory(list, obj, ohfi_array[i]);
|
dir_count = recursiveScanRootDirectory(list, obj, ohfi);
|
||||||
} else {
|
} else {
|
||||||
dir_count = 0;
|
dir_count = 0;
|
||||||
}
|
}
|
||||||
@@ -175,10 +175,23 @@ int QListDB::create()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("Added objects for OHFI 0x%02X: %i", ohfi_array[i], dir_count);
|
qDebug("Added objects for OHFI 0x%02X: %i", ohfi, dir_count);
|
||||||
total_objects += dir_count;
|
object_list[ohfi] = list;
|
||||||
object_list[ohfi_array[i]] = list;
|
|
||||||
|
return dir_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QListDB::create()
|
||||||
|
{
|
||||||
|
int total_objects = 0;
|
||||||
|
//QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
|
CMAObject::resetOhfiCounter();
|
||||||
|
|
||||||
|
for(int i = 0, max = sizeof(ohfi_array) / sizeof(int); i < max; i++) {
|
||||||
|
total_objects += createFromOhfi(ohfi_array[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_objects;
|
return total_objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,6 +333,16 @@ bool QListDB::findInternal(const root_list &list, int ohfi, find_data &data)
|
|||||||
|
|
||||||
bool QListDB::find(int ohfi, QListDB::find_data &data)
|
bool QListDB::find(int ohfi, QListDB::find_data &data)
|
||||||
{
|
{
|
||||||
|
// reescan when accessing a root element
|
||||||
|
if(std::binary_search(ohfi_array, ohfi_array + sizeof(ohfi_array)/sizeof(ohfi_array[0]), ohfi)) {
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
if(settings.value("autorefresh", false).toBool()) {
|
||||||
|
qDebug("Reescanning root for ohfi: %i", ohfi);
|
||||||
|
createFromOhfi(ohfi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
|
for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
|
||||||
if(findInternal(*root, ohfi, data)) {
|
if(findInternal(*root, ohfi, data)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ private:
|
|||||||
typedef QMap<int, root_list> map_list;
|
typedef QMap<int, root_list> map_list;
|
||||||
|
|
||||||
int create();
|
int create();
|
||||||
|
int createFromOhfi(int ohfi);
|
||||||
int scanRootDirectory(root_list &list,int ohfi_type);
|
int scanRootDirectory(root_list &list,int ohfi_type);
|
||||||
int recursiveScanRootDirectory(root_list &list, CMAObject *parent, int ohfi_type);
|
int recursiveScanRootDirectory(root_list &list, CMAObject *parent, int ohfi_type);
|
||||||
bool hasFilter(const CMARootObject *object,int ohfi);
|
bool hasFilter(const CMARootObject *object,int ohfi);
|
||||||
|
|||||||
@@ -174,6 +174,9 @@ void ConfigWidget::setDefaultData()
|
|||||||
bool ignorexml = settings.value("ignorexml", true).toBool();
|
bool ignorexml = settings.value("ignorexml", true).toBool();
|
||||||
ui->ignorexmlCheck->setChecked(ignorexml);
|
ui->ignorexmlCheck->setChecked(ignorexml);
|
||||||
|
|
||||||
|
bool autorefresh = settings.value("autorefresh", false).toBool();
|
||||||
|
ui->refreshCheck->setChecked(autorefresh);
|
||||||
|
|
||||||
QString versiontype = settings.value("versiontype", "zero").toString();
|
QString versiontype = settings.value("versiontype", "zero").toString();
|
||||||
QString customVersion = settings.value("customversion", "00.000.000").toString();
|
QString customVersion = settings.value("customversion", "00.000.000").toString();
|
||||||
|
|
||||||
@@ -285,7 +288,7 @@ void ConfigWidget::accept()
|
|||||||
settings.setValue("versiontype", "custom");
|
settings.setValue("versiontype", "custom");
|
||||||
|
|
||||||
settings.setValue("ignorexml", ui->ignorexmlCheck->isChecked());
|
settings.setValue("ignorexml", ui->ignorexmlCheck->isChecked());
|
||||||
|
settings.setValue("autorefresh", ui->refreshCheck->isChecked());
|
||||||
settings.setValue("customversion", ui->psversionEdit->text());
|
settings.setValue("customversion", ui->psversionEdit->text());
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>519</width>
|
<width>519</width>
|
||||||
<height>559</height>
|
<height>577</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -357,6 +357,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="refreshCheck">
|
||||||
|
<property name="text">
|
||||||
|
<string>Automatic database refresh (experimental)</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="ignorexmlCheck">
|
<widget class="QCheckBox" name="ignorexmlCheck">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
Reference in New Issue
Block a user