mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
updated Folder class
This commit is contained in:
parent
37328edc64
commit
bac7fe1351
@ -733,7 +733,13 @@ QList<LibraryItem *> DBHelper::getFoldersFromParent(qulonglong parentId, QSqlDat
|
|||||||
data << record.value(i);
|
data << record.value(i);
|
||||||
//TODO sort by sort indicator and name
|
//TODO sort by sort indicator and name
|
||||||
currentItem = new Folder(record.value("id").toULongLong(),record.value("parentId").toULongLong(),record.value("name").toString(),record.value("path").toString());
|
currentItem = new Folder(record.value("id").toULongLong(),record.value("parentId").toULongLong(),record.value("name").toString(),record.value("path").toString());
|
||||||
int lessThan = 0;
|
|
||||||
|
if(!record.value("numChildren").isNull() && record.value("numChildren").isValid())
|
||||||
|
currentItem->setNumChildren(record.value("numChildren").toInt());
|
||||||
|
currentItem->setFirstChildId(record.value("firstChildId").toULongLong());
|
||||||
|
currentItem->setCustomImage(record.value("customImage").toString());
|
||||||
|
|
||||||
|
int lessThan = 0;
|
||||||
|
|
||||||
if(list.isEmpty() || !sort)
|
if(list.isEmpty() || !sort)
|
||||||
list.append(currentItem);
|
list.append(currentItem);
|
||||||
@ -930,9 +936,10 @@ Folder DBHelper::loadFolder(qulonglong id, QSqlDatabase & db)
|
|||||||
folder.setFinished(record.value("finished").toBool());
|
folder.setFinished(record.value("finished").toBool());
|
||||||
folder.setCompleted(record.value("completed").toBool());
|
folder.setCompleted(record.value("completed").toBool());
|
||||||
//new 8.6
|
//new 8.6
|
||||||
folder.numChildren = record.value("numChildren").isNull() ? -1 : record.value("numChildren").toInt();
|
if(!record.value("numChildren").isNull() && record.value("numChildren").isValid())
|
||||||
folder.firstChildId = record.value("firstChildId").toULongLong();
|
folder.setNumChildren(record.value("numChildren").toInt());
|
||||||
folder.customImage = record.value("customImage").toString();
|
folder.setFirstChildId(record.value("firstChildId").toULongLong());
|
||||||
|
folder.setCustomImage(record.value("customImage").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
@ -962,9 +969,10 @@ Folder DBHelper::loadFolder(const QString &folderName, qulonglong parentId, QSql
|
|||||||
folder.setFinished(record.value("finished").toBool());
|
folder.setFinished(record.value("finished").toBool());
|
||||||
folder.setCompleted(record.value("completed").toBool());
|
folder.setCompleted(record.value("completed").toBool());
|
||||||
//new 8.6
|
//new 8.6
|
||||||
folder.numChildren = record.value("numChildren").isNull() ? -1 : record.value("numChildren").toInt();
|
if(!record.value("numChildren").isNull() && record.value("numChildren").isValid())
|
||||||
folder.firstChildId = record.value("firstChildId").toULongLong();
|
folder.setNumChildren(record.value("numChildren").toInt());
|
||||||
folder.customImage = record.value("customImage").toString();
|
folder.setFirstChildId(record.value("firstChildId").toULongLong());
|
||||||
|
folder.setCustomImage(record.value("customImage").toString());
|
||||||
|
|
||||||
QLOG_DEBUG() << "FOUND!!";
|
QLOG_DEBUG() << "FOUND!!";
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void FolderContentController::serviceContent(const int &library, const qulonglon
|
|||||||
if((*itr)->isDir())
|
if((*itr)->isDir())
|
||||||
{
|
{
|
||||||
currentFolder = (Folder *)(*itr);
|
currentFolder = (Folder *)(*itr);
|
||||||
response.writeText(QString("f:%1:%2:%3:%4\r\n").arg(library).arg(currentFolder->id).arg(currentFolder->name).arg(currentFolder->numChildren));
|
response.writeText(QString("f:%1:%2:%3:%4\r\n").arg(library).arg(currentFolder->id).arg(currentFolder->name).arg(currentFolder->getNumChildren()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ ComicDB::ComicDB()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComicDB::isDir()
|
bool ComicDB::isDir() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ class ComicDB : public LibraryItem
|
|||||||
public:
|
public:
|
||||||
ComicDB();
|
ComicDB();
|
||||||
|
|
||||||
bool isDir();
|
bool isDir() const;
|
||||||
|
|
||||||
bool _hasCover;
|
bool _hasCover;
|
||||||
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
#include "folder.h"
|
||||||
|
|
||||||
|
Folder::Folder()
|
||||||
|
:knownParent(false),
|
||||||
|
knownId(false),
|
||||||
|
numChildren(-1),
|
||||||
|
firstChildId(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Folder::Folder(qulonglong folderId, qulonglong parentId, const QString &folderName, const QString &folderPath)
|
||||||
|
:knownParent(true),
|
||||||
|
knownId(true),
|
||||||
|
numChildren(-1),
|
||||||
|
firstChildId(0)
|
||||||
|
{
|
||||||
|
this->id = folderId;
|
||||||
|
this->parentId = parentId;
|
||||||
|
this->name = folderName;
|
||||||
|
this->path = folderPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
Folder::Folder(const QString & folderName, const QString & folderPath)
|
||||||
|
:knownParent(false),
|
||||||
|
knownId(false),
|
||||||
|
numChildren(-1),
|
||||||
|
firstChildId(0)
|
||||||
|
{
|
||||||
|
this->name = folderName;
|
||||||
|
this->path = folderPath;
|
||||||
|
}
|
@ -10,25 +10,86 @@ class Folder : public LibraryItem
|
|||||||
public:
|
public:
|
||||||
bool knownParent;
|
bool knownParent;
|
||||||
bool knownId;
|
bool knownId;
|
||||||
|
|
||||||
qint32 numChildren; //-1 for unknown number of children
|
|
||||||
qulonglong firstChildId; //0 for unknown first child
|
|
||||||
QString customImage; //empty for none custom image
|
|
||||||
|
|
||||||
Folder():knownParent(false), knownId(false){};
|
Folder();
|
||||||
Folder(qulonglong sid, qulonglong pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;};
|
Folder(qulonglong folderId, qulonglong parentId,const QString & folderName, const QString & folderPath);
|
||||||
Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;};
|
Folder(const QString & folderName, const QString & folderPath);
|
||||||
void setId(qulonglong sid){id = sid;knownId = true;};
|
|
||||||
void setFather(qulonglong pid){parentId = pid;knownParent = true;};
|
inline void setId(qulonglong sid)
|
||||||
bool isDir() {return true;};
|
{
|
||||||
bool isFinished() const {return finished;};
|
id = sid;
|
||||||
bool isCompleted() const {return completed;};
|
knownId = true;
|
||||||
void setFinished(bool b) {finished = b;};
|
}
|
||||||
void setCompleted(bool b) {completed = b;};
|
|
||||||
|
inline void setFather(qulonglong pid)
|
||||||
|
{
|
||||||
|
parentId = pid;
|
||||||
|
knownParent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isDir() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isFinished() const
|
||||||
|
{
|
||||||
|
return finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isCompleted() const
|
||||||
|
{
|
||||||
|
return completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setFinished(bool b)
|
||||||
|
{
|
||||||
|
finished = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setCompleted(bool b)
|
||||||
|
{
|
||||||
|
completed = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline qint32 getNumChildren() const
|
||||||
|
{
|
||||||
|
return numChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setNumChildren(const qint32 v)
|
||||||
|
{
|
||||||
|
numChildren = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline qulonglong getFirstChildId() const
|
||||||
|
{
|
||||||
|
return firstChildId;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setFirstChildId(const qulonglong v)
|
||||||
|
{
|
||||||
|
firstChildId = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline qulonglong getCustomImage() const
|
||||||
|
{
|
||||||
|
return firstChildId;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setCustomImage(const QString & s)
|
||||||
|
{
|
||||||
|
customImage = s;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool finished;
|
bool finished;
|
||||||
bool completed;
|
bool completed;
|
||||||
|
|
||||||
|
qint32 numChildren; //-1 for unknown number of children
|
||||||
|
qulonglong firstChildId; //0 for unknown first child
|
||||||
|
QString customImage; //empty for none custom image
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
class LibraryItem
|
class LibraryItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool isDir() = 0;
|
virtual bool isDir() const = 0;
|
||||||
QString name;
|
QString name;
|
||||||
QString path;
|
QString path;
|
||||||
qulonglong parentId;
|
qulonglong parentId;
|
||||||
qulonglong id;
|
qulonglong id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user