mirror of
https://github.com/YACReader/yacreader
synced 2025-07-22 15:04:40 -04:00
movidos los POCOs a common
This commit is contained in:
408
common/comic_db.cpp
Normal file
408
common/comic_db.cpp
Normal file
@ -0,0 +1,408 @@
|
||||
#include "comic_db.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//COMIC------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
ComicDB::ComicDB()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ComicDB::isDir()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ComicDB::toTXT()
|
||||
{
|
||||
QString txt;
|
||||
|
||||
//Legacy info
|
||||
txt.append(QString("comicid:%1\r\n").arg(id));
|
||||
txt.append(QString("hash:%1\r\n").arg(info.hash));
|
||||
txt.append(QString("path:%1\r\n").arg(path));
|
||||
txt.append(QString("numpages:%1\r\n").arg(*info.numPages));
|
||||
|
||||
//Informaci<63>n general
|
||||
if(info.coverPage != NULL)
|
||||
txt.append(QString("coverPage:%1\r\n").arg(*info.coverPage));
|
||||
|
||||
if(info.title != NULL)
|
||||
txt.append(QString("title:%1\r\n").arg(*info.title));
|
||||
|
||||
if(info.number != NULL)
|
||||
txt.append(QString("number:%1\r\n").arg(*info.number));
|
||||
|
||||
if(info.isBis != NULL)
|
||||
txt.append(QString("isBis:%1\r\n").arg(*info.isBis));
|
||||
|
||||
if(info.count != NULL)
|
||||
txt.append(QString("count:%1\r\n").arg(*info.count));
|
||||
|
||||
if(info.volume != NULL)
|
||||
txt.append(QString("volume:%1\r\n").arg(*info.volume));
|
||||
|
||||
if(info.storyArc != NULL)
|
||||
txt.append(QString("storyArc:%1\r\n").arg(*info.storyArc));
|
||||
|
||||
if(info.arcNumber != NULL)
|
||||
txt.append(QString("arcNumber:%1\r\n").arg(*info.arcNumber));
|
||||
|
||||
if(info.arcCount != NULL)
|
||||
txt.append(QString("arcCount:%1\r\n").arg(*info.arcCount));
|
||||
|
||||
if(info.genere != NULL)
|
||||
txt.append(QString("genere:%1\r\n").arg(*info.genere));
|
||||
|
||||
//Autores
|
||||
if(info.writer != NULL)
|
||||
txt.append(QString("writer:%1\r\n").arg(*info.writer));
|
||||
|
||||
if(info.penciller != NULL)
|
||||
txt.append(QString("penciller:%1\r\n").arg(*info.penciller));
|
||||
|
||||
if(info.inker != NULL)
|
||||
txt.append(QString("inker:%1\r\n").arg(*info.inker));
|
||||
|
||||
if(info.colorist != NULL)
|
||||
txt.append(QString("colorist:%1\r\n").arg(*info.colorist));
|
||||
|
||||
if(info.letterer != NULL)
|
||||
txt.append(QString("letterer:%1\r\n").arg(*info.letterer));
|
||||
|
||||
if(info.coverArtist != NULL)
|
||||
txt.append(QString("coverArtist:%1\r\n").arg(*info.coverArtist));
|
||||
//Publicaci<63>n
|
||||
if(info.date != NULL)
|
||||
txt.append(QString("date:%1\r\n").arg(*info.date));
|
||||
|
||||
if(info.publisher != NULL)
|
||||
txt.append(QString("publisher:%1\r\n").arg(*info.publisher));
|
||||
|
||||
if(info.format != NULL)
|
||||
txt.append(QString("format:%1\r\n").arg(*info.format));
|
||||
|
||||
if(info.color != NULL)
|
||||
txt.append(QString("color:%1\r\n").arg(*info.color));
|
||||
|
||||
if(info.ageRating != NULL)
|
||||
txt.append(QString("ageRating:%1\r\n").arg(*info.ageRating));
|
||||
//Argumento
|
||||
if(info.synopsis != NULL)
|
||||
txt.append(QString("synopsis:%1\r\n").arg(*info.synopsis));
|
||||
|
||||
if(info.characters != NULL)
|
||||
txt.append(QString("characters:%1\r\n").arg(*info.characters));
|
||||
|
||||
if(info.notes != NULL)
|
||||
txt.append(QString("notes:%1\r\n").arg(*info.notes));
|
||||
|
||||
return txt;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
//COMIC_INFO-------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
ComicInfo::ComicInfo()
|
||||
:existOnDb(false),
|
||||
title(NULL),
|
||||
coverPage(NULL),
|
||||
numPages(NULL),
|
||||
number(NULL),
|
||||
isBis(NULL),
|
||||
count(NULL),
|
||||
volume(NULL),
|
||||
storyArc(NULL),
|
||||
arcNumber(NULL),
|
||||
arcCount(NULL),
|
||||
genere(NULL),
|
||||
writer(NULL),
|
||||
penciller(NULL),
|
||||
inker(NULL),
|
||||
colorist(NULL),
|
||||
letterer(NULL),
|
||||
coverArtist(NULL),
|
||||
date(NULL),
|
||||
publisher(NULL),
|
||||
format(NULL),
|
||||
color(NULL),
|
||||
ageRating(NULL),
|
||||
synopsis(NULL),
|
||||
characters(NULL),
|
||||
notes(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ComicInfo::ComicInfo(const ComicInfo & comicInfo)
|
||||
: title(NULL),
|
||||
coverPage(NULL),
|
||||
numPages(NULL),
|
||||
number(NULL),
|
||||
isBis(NULL),
|
||||
count(NULL),
|
||||
volume(NULL),
|
||||
storyArc(NULL),
|
||||
arcNumber(NULL),
|
||||
arcCount(NULL),
|
||||
genere(NULL),
|
||||
writer(NULL),
|
||||
penciller(NULL),
|
||||
inker(NULL),
|
||||
colorist(NULL),
|
||||
letterer(NULL),
|
||||
coverArtist(NULL),
|
||||
date(NULL),
|
||||
publisher(NULL),
|
||||
format(NULL),
|
||||
color(NULL),
|
||||
ageRating(NULL),
|
||||
synopsis(NULL),
|
||||
characters(NULL),
|
||||
notes(NULL)
|
||||
{
|
||||
operator=(comicInfo);
|
||||
}
|
||||
|
||||
ComicInfo::~ComicInfo()
|
||||
{
|
||||
delete title;
|
||||
delete coverPage;
|
||||
delete numPages;
|
||||
delete number;
|
||||
delete isBis;
|
||||
delete count;
|
||||
delete volume;
|
||||
delete storyArc;
|
||||
delete arcNumber;
|
||||
delete arcCount;
|
||||
delete genere;
|
||||
delete writer;
|
||||
delete penciller;
|
||||
delete inker;
|
||||
delete colorist;
|
||||
delete letterer;
|
||||
delete coverArtist;
|
||||
delete date;
|
||||
delete publisher;
|
||||
delete format;
|
||||
delete color;
|
||||
delete ageRating;
|
||||
delete synopsis;
|
||||
delete characters;
|
||||
delete notes;
|
||||
}
|
||||
ComicInfo & ComicInfo::operator=(const ComicInfo & comicInfo)
|
||||
{
|
||||
copyField(title,comicInfo.title);
|
||||
copyField(coverPage,comicInfo.coverPage);
|
||||
copyField(numPages,comicInfo.numPages);
|
||||
copyField(number,comicInfo.number);
|
||||
copyField(isBis,comicInfo.isBis);
|
||||
copyField(count,comicInfo.count);
|
||||
copyField(volume,comicInfo.volume);
|
||||
copyField(storyArc,comicInfo.storyArc);
|
||||
copyField(arcNumber,comicInfo.arcNumber);
|
||||
copyField(arcCount,comicInfo.arcCount);
|
||||
copyField(genere,comicInfo.genere);
|
||||
copyField(writer,comicInfo.writer);
|
||||
copyField(penciller,comicInfo.penciller);
|
||||
copyField(inker,comicInfo.inker);
|
||||
copyField(colorist,comicInfo.colorist);
|
||||
copyField(letterer,comicInfo.letterer);
|
||||
copyField(coverArtist,comicInfo.coverArtist);
|
||||
copyField(date,comicInfo.date);
|
||||
copyField(publisher,comicInfo.publisher);
|
||||
copyField(format,comicInfo.format);
|
||||
copyField(color,comicInfo.color);
|
||||
copyField(ageRating,comicInfo.ageRating);
|
||||
copyField(synopsis,comicInfo.synopsis);
|
||||
copyField(characters,comicInfo.characters);
|
||||
copyField(notes,comicInfo.notes);
|
||||
|
||||
hash = comicInfo.hash;
|
||||
id = comicInfo.id;
|
||||
existOnDb = comicInfo.existOnDb;
|
||||
read = comicInfo.read;
|
||||
edited = comicInfo.edited;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void ComicInfo::setValue(QString * & field, const QString & value)
|
||||
{
|
||||
if(field == NULL)
|
||||
field = new QString;
|
||||
*field = value;
|
||||
}
|
||||
|
||||
void ComicInfo::setValue(int * & field, int value)
|
||||
{
|
||||
if(field == NULL)
|
||||
field = new int;
|
||||
*field = value;
|
||||
}
|
||||
|
||||
void ComicInfo::setValue(bool * & field, bool value)
|
||||
{
|
||||
if(field == NULL)
|
||||
field = new bool;
|
||||
*field = value;
|
||||
}
|
||||
|
||||
void ComicInfo::copyField(QString * & field, const QString * value)
|
||||
{
|
||||
if(value != NULL)
|
||||
field = new QString(*value);
|
||||
}
|
||||
|
||||
void ComicInfo::copyField(int * & field, int * value)
|
||||
{
|
||||
if(value != NULL)
|
||||
field = new int(*value);
|
||||
}
|
||||
|
||||
void ComicInfo::copyField(bool * & field, bool * value)
|
||||
{
|
||||
if(value != NULL)
|
||||
field = new bool(*value);
|
||||
}
|
||||
|
||||
|
||||
//set fields
|
||||
void ComicInfo::setTitle(QString value)
|
||||
{
|
||||
setValue(title,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setCoverPage(int value)
|
||||
{
|
||||
setValue(coverPage,value);
|
||||
}
|
||||
void ComicInfo::setNumPages(int value)
|
||||
{
|
||||
setValue(numPages,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setNumber(int value)
|
||||
{
|
||||
setValue(number,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setIsBis(bool value)
|
||||
{
|
||||
setValue(isBis,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setCount(int value)
|
||||
{
|
||||
setValue(count,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setVolume(QString value)
|
||||
{
|
||||
setValue(volume,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setStoryArc(QString value)
|
||||
{
|
||||
setValue(storyArc,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setArcNumber(int value)
|
||||
{
|
||||
setValue(arcNumber,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setArcCount(int value)
|
||||
{
|
||||
setValue(arcCount,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setGenere(QString value)
|
||||
{
|
||||
setValue(genere,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setWriter(QString value)
|
||||
{
|
||||
setValue(writer,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setPenciller(QString value)
|
||||
{
|
||||
setValue(penciller,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setInker(QString value)
|
||||
{
|
||||
setValue(inker,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setColorist(QString value)
|
||||
{
|
||||
setValue(colorist,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setLetterer(QString value)
|
||||
{
|
||||
setValue(letterer,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setCoverArtist(QString value)
|
||||
{
|
||||
setValue(coverArtist,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setDate(QString value)
|
||||
{
|
||||
setValue(date,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setPublisher(QString value)
|
||||
{
|
||||
setValue(publisher,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setFormat(QString value)
|
||||
{
|
||||
setValue(format,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setColor(bool value)
|
||||
{
|
||||
setValue(color,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setAgeRating(QString value)
|
||||
{
|
||||
setValue(ageRating,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setSynopsis(QString value)
|
||||
{
|
||||
setValue(synopsis,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setCharacters(QString value)
|
||||
{
|
||||
setValue(characters,value);
|
||||
}
|
||||
|
||||
void ComicInfo::setNotes(QString value)
|
||||
{
|
||||
setValue(notes,value);
|
||||
}
|
||||
|
||||
QPixmap ComicInfo::getCover(const QString & basePath)
|
||||
{
|
||||
if(cover.isNull())
|
||||
{
|
||||
cover.load(basePath + "/.yacreaderlibrary/covers/" + hash + ".jpg");
|
||||
}
|
||||
QPixmap c;
|
||||
c.convertFromImage(cover);
|
||||
return c;
|
||||
}
|
121
common/comic_db.h
Normal file
121
common/comic_db.h
Normal file
@ -0,0 +1,121 @@
|
||||
#ifndef __COMICDB_H
|
||||
#define __COMICDB_H
|
||||
|
||||
#include "library_item.h"
|
||||
#include <QList>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
|
||||
class ComicInfo
|
||||
{
|
||||
public:
|
||||
ComicInfo();
|
||||
ComicInfo(const ComicInfo & comicInfo);
|
||||
~ComicInfo();
|
||||
|
||||
ComicInfo & operator=(const ComicInfo & comicInfo);
|
||||
|
||||
qulonglong id;
|
||||
bool read;
|
||||
bool edited;
|
||||
QString hash;
|
||||
bool existOnDb;
|
||||
|
||||
QString * title;
|
||||
|
||||
int * coverPage;
|
||||
int * numPages;
|
||||
|
||||
int * number;
|
||||
bool * isBis;
|
||||
int * count;
|
||||
|
||||
QString * volume;
|
||||
QString * storyArc;
|
||||
int * arcNumber;
|
||||
int * arcCount;
|
||||
|
||||
QString * genere;
|
||||
|
||||
QString * writer;
|
||||
QString * penciller;
|
||||
QString * inker;
|
||||
QString * colorist;
|
||||
QString * letterer;
|
||||
QString * coverArtist;
|
||||
|
||||
QString * date;
|
||||
QString * publisher;
|
||||
QString * format;
|
||||
bool * color;
|
||||
QString * ageRating;
|
||||
|
||||
QString * synopsis;
|
||||
QString * characters;
|
||||
QString * notes;
|
||||
|
||||
QImage cover;
|
||||
|
||||
void setTitle(QString value);
|
||||
|
||||
void setCoverPage(int value);
|
||||
void setNumPages(int value);
|
||||
|
||||
void setNumber(int value);
|
||||
void setIsBis(bool value);
|
||||
void setCount(int value);
|
||||
|
||||
void setVolume(QString value);
|
||||
void setStoryArc(QString value);
|
||||
void setArcNumber(int value);
|
||||
void setArcCount(int value);
|
||||
|
||||
void setGenere(QString value);
|
||||
|
||||
void setWriter(QString value);
|
||||
void setPenciller(QString value);
|
||||
void setInker(QString value);
|
||||
void setColorist(QString value);
|
||||
void setLetterer(QString value);
|
||||
void setCoverArtist(QString value);
|
||||
|
||||
void setDate(QString value);
|
||||
void setPublisher(QString value);
|
||||
void setFormat(QString value);
|
||||
void setColor(bool value);
|
||||
void setAgeRating(QString value);
|
||||
|
||||
void setSynopsis(QString value);
|
||||
void setCharacters(QString value);
|
||||
void setNotes(QString value);
|
||||
|
||||
QPixmap getCover(const QString & basePath);
|
||||
|
||||
private:
|
||||
void setValue(QString * & field, const QString & value);
|
||||
void setValue(int * & field, int value);
|
||||
void setValue(bool * & field, bool value);
|
||||
|
||||
void copyField(QString * & field, const QString * value);
|
||||
void copyField(int * & field, int * value);
|
||||
void copyField(bool * & field, bool * value);
|
||||
};
|
||||
|
||||
class ComicDB : public LibraryItem
|
||||
{
|
||||
public:
|
||||
ComicDB();
|
||||
|
||||
bool isDir();
|
||||
|
||||
bool _hasCover;
|
||||
|
||||
bool hasCover() {return _hasCover;};
|
||||
|
||||
QString toTXT();
|
||||
|
||||
ComicInfo info;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
0
common/folder.cpp
Normal file
0
common/folder.cpp
Normal file
22
common/folder.h
Normal file
22
common/folder.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef __FOLDER_H
|
||||
#define __FOLDER_H
|
||||
|
||||
#include "library_item.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
class Folder : public LibraryItem
|
||||
{
|
||||
public:
|
||||
bool knownParent;
|
||||
bool knownId;
|
||||
|
||||
Folder():knownParent(false), knownId(false){};
|
||||
Folder(qulonglong sid, qulonglong pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;};
|
||||
Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;};
|
||||
void setId(qulonglong sid){id = sid;knownId = true;};
|
||||
void setFather(qulonglong pid){parentId = pid;knownParent = true;};
|
||||
bool isDir(){return true;};
|
||||
};
|
||||
|
||||
#endif
|
0
common/library_item.cpp
Normal file
0
common/library_item.cpp
Normal file
16
common/library_item.h
Normal file
16
common/library_item.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __LIBRARY_ITEM_H
|
||||
#define __LIBRARY_ITEM_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class LibraryItem
|
||||
{
|
||||
public:
|
||||
virtual bool isDir() = 0;
|
||||
QString name;
|
||||
QString path;
|
||||
qulonglong parentId;
|
||||
qulonglong id;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user