mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
store the hash of the first comic in a folder, this is more useful than storing the id
This commit is contained in:
parent
b9e7dbe41e
commit
e23f6b0bc3
@ -197,11 +197,9 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
"completed BOOLEAN DEFAULT 1," //collecting
|
||||
//new 8.6 fields
|
||||
"numChildren INTEGER,"
|
||||
"firstChildId INTEGER,"
|
||||
"firstChildHash TEXT,"
|
||||
"customImage TEXT,"
|
||||
"FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE, "
|
||||
//8.6
|
||||
"FOREIGN KEY(firstChildId) REFERENCES comic_info(id))");
|
||||
"FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE)");
|
||||
success = success && queryFolder.exec();
|
||||
|
||||
//COMIC (representa un cómic en disco, contiene el nombre de fichero)
|
||||
@ -771,10 +769,9 @@ bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
|
||||
QStringList columnDefs;
|
||||
//TODO
|
||||
columnDefs << "numChildren INTEGER";
|
||||
columnDefs << "firstChildId INTEGER";
|
||||
columnDefs << "firstChildHash TEXT";
|
||||
columnDefs << "customImage TEXT";
|
||||
//returnValue = returnValue && addColumns("folder", columnDefs, db);
|
||||
//returnValue = returnValue && addConstraint("folder", FOREIGN KEY(firstChildId) REFERENCES comic_info(id), db);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,10 +419,10 @@ void DBHelper::updateChildrenInfo(const Folder & folder, QSqlDatabase & db)
|
||||
QSqlQuery updateFolderInfo(db);
|
||||
updateFolderInfo.prepare("UPDATE folder SET "
|
||||
"numChildren = :numChildren, "
|
||||
"firstChildId = :firstChildId "
|
||||
"firstChildHash = :firstChildHash "
|
||||
"WHERE id = :id ");
|
||||
updateFolderInfo.bindValue(":numChildren", folder.getNumChildren());
|
||||
updateFolderInfo.bindValue(":firstChildId", folder.getFirstChildId());
|
||||
updateFolderInfo.bindValue(":firstChildHash", folder.getFirstChildHash());
|
||||
updateFolderInfo.bindValue(":id", folder.id);
|
||||
updateFolderInfo.exec();
|
||||
}
|
||||
@ -439,10 +439,10 @@ void DBHelper::updateChildrenInfo(qulonglong folderId, QSqlDatabase & db)
|
||||
QSqlQuery updateFolderInfo(db);
|
||||
updateFolderInfo.prepare("UPDATE folder SET "
|
||||
"numChildren = :numChildren, "
|
||||
"firstChildId = :firstChildId "
|
||||
"firstChildHash = :firstChildHash "
|
||||
"WHERE id = :id ");
|
||||
updateFolderInfo.bindValue(":numChildren", subfolders.count() + comics.count());
|
||||
updateFolderInfo.bindValue(":firstChildId", firstComic != NULL ? firstComic->info.id : 0);
|
||||
updateFolderInfo.bindValue(":firstChildHash", firstComic != NULL ? firstComic->info.hash : "");
|
||||
updateFolderInfo.bindValue(":id", folderId);
|
||||
updateFolderInfo.exec();
|
||||
}
|
||||
@ -783,7 +783,7 @@ QList<LibraryItem *> DBHelper::getFoldersFromParent(qulonglong parentId, QSqlDat
|
||||
|
||||
if(!record.value("numChildren").isNull() && record.value("numChildren").isValid())
|
||||
currentItem->setNumChildren(record.value("numChildren").toInt());
|
||||
currentItem->setFirstChildId(record.value("firstChildId").toULongLong());
|
||||
currentItem->setFirstChildHash(record.value("firstChildHash").toString());
|
||||
currentItem->setCustomImage(record.value("customImage").toString());
|
||||
|
||||
int lessThan = 0;
|
||||
@ -985,7 +985,7 @@ Folder DBHelper::loadFolder(qulonglong id, QSqlDatabase & db)
|
||||
//new 8.6
|
||||
if(!record.value("numChildren").isNull() && record.value("numChildren").isValid())
|
||||
folder.setNumChildren(record.value("numChildren").toInt());
|
||||
folder.setFirstChildId(record.value("firstChildId").toULongLong());
|
||||
folder.setFirstChildHash(record.value("firstChildHash").toString());
|
||||
folder.setCustomImage(record.value("customImage").toString());
|
||||
}
|
||||
|
||||
@ -1018,7 +1018,7 @@ Folder DBHelper::loadFolder(const QString &folderName, qulonglong parentId, QSql
|
||||
//new 8.6
|
||||
if(!record.value("numChildren").isNull() && record.value("numChildren").isValid())
|
||||
folder.setNumChildren(record.value("numChildren").toInt());
|
||||
folder.setFirstChildId(record.value("firstChildId").toULongLong());
|
||||
folder.setFirstChildHash(record.value("firstChildHash").toString());
|
||||
folder.setCustomImage(record.value("customImage").toString());
|
||||
|
||||
QLOG_DEBUG() << "FOUND!!";
|
||||
|
@ -3,15 +3,13 @@
|
||||
Folder::Folder()
|
||||
:knownParent(false),
|
||||
knownId(false),
|
||||
numChildren(-1),
|
||||
firstChildId(0)
|
||||
numChildren(-1)
|
||||
{}
|
||||
|
||||
Folder::Folder(qulonglong folderId, qulonglong parentId, const QString &folderName, const QString &folderPath)
|
||||
:knownParent(true),
|
||||
knownId(true),
|
||||
numChildren(-1),
|
||||
firstChildId(0)
|
||||
numChildren(-1)
|
||||
{
|
||||
this->id = folderId;
|
||||
this->parentId = parentId;
|
||||
@ -22,8 +20,7 @@ Folder::Folder(qulonglong folderId, qulonglong parentId, const QString &folderNa
|
||||
Folder::Folder(const QString & folderName, const QString & folderPath)
|
||||
:knownParent(false),
|
||||
knownId(false),
|
||||
numChildren(-1),
|
||||
firstChildId(0)
|
||||
numChildren(-1)
|
||||
{
|
||||
this->name = folderName;
|
||||
this->path = folderPath;
|
||||
|
@ -62,19 +62,19 @@ public:
|
||||
numChildren = v;
|
||||
}
|
||||
|
||||
inline qulonglong getFirstChildId() const
|
||||
inline QString getFirstChildHash() const
|
||||
{
|
||||
return firstChildId;
|
||||
return firstChildHash;
|
||||
}
|
||||
|
||||
inline void setFirstChildId(const qulonglong v)
|
||||
inline void setFirstChildHash(const QString & v)
|
||||
{
|
||||
firstChildId = v;
|
||||
firstChildHash = v;
|
||||
}
|
||||
|
||||
inline qulonglong getCustomImage() const
|
||||
inline QString getCustomImage() const
|
||||
{
|
||||
return firstChildId;
|
||||
return customImage;
|
||||
}
|
||||
|
||||
inline void setCustomImage(const QString & s)
|
||||
@ -87,7 +87,7 @@ private:
|
||||
bool completed;
|
||||
|
||||
qint32 numChildren; //-1 for unknown number of children
|
||||
qulonglong firstChildId; //0 for unknown first child
|
||||
QString firstChildHash; //empty for unknown first child
|
||||
QString customImage; //empty for none custom image
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user