mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
ya se puede editar la informaci?n de los comics adecuadamente.
ya se puede hacer import de los datos de c?mics
This commit is contained in:
@ -73,7 +73,7 @@ QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabas
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//selectQuery.finish();
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -94,6 +94,7 @@ bool Comic::load(qulonglong id, QSqlDatabase & db)
|
||||
info.load(record.value("hash").toString(),db);
|
||||
return true;
|
||||
}
|
||||
//selectQuery.finish();
|
||||
return false;
|
||||
|
||||
}
|
||||
@ -138,6 +139,7 @@ void Comic::removeFromDB(QSqlDatabase & db)
|
||||
query.prepare("DELETE FROM comic WHERE id = :id");
|
||||
query.bindValue(":id", id);
|
||||
query.exec();
|
||||
//query.finish();
|
||||
}
|
||||
|
||||
bool Comic::isDir()
|
||||
@ -149,11 +151,217 @@ bool Comic::isDir()
|
||||
//COMIC_INFO-------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
ComicInfo::ComicInfo()
|
||||
:existOnDb(false)
|
||||
: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)
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void ComicInfo::setField(const QString & name, QString * & field, QSqlRecord & record)
|
||||
{
|
||||
if(!record.value(name).isNull())
|
||||
{
|
||||
field = new QString();
|
||||
*field = record.value(name).toString();
|
||||
}
|
||||
}
|
||||
|
||||
void ComicInfo::setField(const QString & name, int * & field, QSqlRecord & record)
|
||||
{
|
||||
if(!record.value(name).isNull())
|
||||
{
|
||||
field = new int;
|
||||
*field = record.value(name).toInt();
|
||||
}
|
||||
}
|
||||
|
||||
void ComicInfo::setField(const QString & name, bool * & field, QSqlRecord & record)
|
||||
{
|
||||
if(!record.value(name).isNull())
|
||||
{
|
||||
field = new bool;
|
||||
*field = record.value(name).toBool();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ComicInfo::bindField(const QString & name, QString * field, QSqlQuery & query)
|
||||
{
|
||||
if(field != NULL)
|
||||
{
|
||||
query.bindValue(name,*field);
|
||||
}
|
||||
}
|
||||
|
||||
void ComicInfo::bindField(const QString & name, int * field, QSqlQuery & query)
|
||||
{
|
||||
if(field != NULL)
|
||||
{
|
||||
query.bindValue(name,*field);
|
||||
}
|
||||
}
|
||||
|
||||
void ComicInfo::bindField(const QString & name, bool * field, QSqlQuery & query)
|
||||
{
|
||||
if(field != NULL)
|
||||
{
|
||||
query.bindValue(name,*field);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bool ComicInfo::load(QString hash, QSqlDatabase & db)
|
||||
{
|
||||
QSqlQuery findComicInfo(db);
|
||||
@ -164,6 +372,7 @@ bool ComicInfo::load(QString hash, QSqlDatabase & db)
|
||||
|
||||
if(findComicInfo.next())
|
||||
{
|
||||
this->hash = hash;
|
||||
QSqlRecord record = findComicInfo.record();
|
||||
|
||||
hash = hash;
|
||||
@ -171,41 +380,38 @@ bool ComicInfo::load(QString hash, QSqlDatabase & db)
|
||||
read = record.value("read").toBool();
|
||||
edited = record.value("edited").toBool();
|
||||
|
||||
title = record.value("title").toString();
|
||||
pages = record.value("pages").toInt();
|
||||
|
||||
coverPage = record.value("coverPage").toInt();
|
||||
setField("title",title,record);
|
||||
setField("numPages",numPages,record);
|
||||
|
||||
setField("coverPage",coverPage,record);
|
||||
|
||||
if(!record.value("number").isNull())
|
||||
number = record.value("number").toInt();
|
||||
else
|
||||
number = -1;
|
||||
isBis = record.value("isBis").toBool();
|
||||
count = record.value("count").toInt();
|
||||
setField("number",number,record);
|
||||
setField("isBis",isBis,record);
|
||||
setField("count",count,record);
|
||||
|
||||
volume = record.value("volume").toString();
|
||||
storyArc = record.value("storyArc").toString();
|
||||
arcNumber = record.value("arcNumber").toInt();
|
||||
arcCount = record.value("arcCount").toInt();
|
||||
setField("volume",volume,record);
|
||||
setField("storyArc",storyArc,record);
|
||||
setField("arcNumber",arcNumber,record);
|
||||
setField("arcCount",arcCount,record);
|
||||
|
||||
genere = record.value("genere").toString();
|
||||
setField("genere",genere,record);
|
||||
|
||||
writer = record.value("writer").toString();
|
||||
penciller = record.value("penciller").toString();
|
||||
inker = record.value("inker").toString();
|
||||
colorist = record.value("colorist").toString();
|
||||
letterer = record.value("letterer").toString();
|
||||
coverArtist = record.value("coverArtist").toString();
|
||||
setField("writer",writer,record);
|
||||
setField("penciller",penciller,record);
|
||||
setField("inker",inker,record);
|
||||
setField("colorist",colorist,record);
|
||||
setField("letterer",letterer,record);
|
||||
setField("coverArtist",coverArtist,record);
|
||||
|
||||
date = record.value("date").toString();
|
||||
publisher = record.value("publisher").toString();
|
||||
format = record.value("format").toString();
|
||||
color = record.value("color").toBool();
|
||||
ageRating = record.value("ageRating").toString();
|
||||
setField("date",date,record);
|
||||
setField("publisher",publisher,record);
|
||||
setField("format",format,record);
|
||||
setField("color",color,record);
|
||||
setField("ageRating",ageRating,record);
|
||||
|
||||
synopsis = record.value("synopsis").toString();
|
||||
characters = record.value("characters").toString();
|
||||
notes = record.value("notes").toString();
|
||||
setField("synopsis",synopsis,record);
|
||||
setField("characters",characters,record);
|
||||
setField("notes",notes,record);
|
||||
|
||||
return existOnDb = true;
|
||||
}
|
||||
@ -224,12 +430,232 @@ void ComicInfo::removeFromDB(QSqlDatabase & db)
|
||||
void ComicInfo::update(QSqlDatabase & db)
|
||||
{
|
||||
//db.open();
|
||||
QSqlQuery findComicInfo(db);
|
||||
findComicInfo.prepare("UPDATE comic_info SET title = :title, read = :read, edited = :edited WHERE id = :id ");
|
||||
findComicInfo.bindValue(":title", title);
|
||||
findComicInfo.bindValue(":read", read?1:0);
|
||||
findComicInfo.bindValue(":id", id);
|
||||
findComicInfo.bindValue(":edited", edited?1:0);
|
||||
findComicInfo.exec();
|
||||
QSqlQuery updateComicInfo(db);
|
||||
updateComicInfo.prepare("UPDATE comic_info SET "
|
||||
"title = :title,"
|
||||
|
||||
"coverPage = :coverPage,"
|
||||
"numPages = :numPages,"
|
||||
|
||||
"number = :number,"
|
||||
"isBis = :isBis,"
|
||||
"count = :count,"
|
||||
|
||||
"volume = :volume,"
|
||||
"storyArc = :storyArc,"
|
||||
"arcNumber = :arcNumber,"
|
||||
"arcCount = :arcCount,"
|
||||
|
||||
"genere = :genere,"
|
||||
|
||||
"writer = :writer,"
|
||||
"penciller = :penciller,"
|
||||
"inker = :inker,"
|
||||
"colorist = :colorist,"
|
||||
"letterer = :letterer,"
|
||||
"coverArtist = :coverArtist,"
|
||||
|
||||
"date = :date,"
|
||||
"publisher = :publisher,"
|
||||
"format = :format,"
|
||||
"color = :color,"
|
||||
"ageRating = :ageRating,"
|
||||
|
||||
"synopsis = :synopsis,"
|
||||
"characters = :characters,"
|
||||
"notes = :notes,"
|
||||
|
||||
"read = :read,"
|
||||
"edited = :edited"
|
||||
|
||||
" WHERE id = :id ");
|
||||
bindField(":title",title,updateComicInfo);
|
||||
|
||||
bindField(":coverPage",coverPage,updateComicInfo);
|
||||
bindField(":numPages",numPages,updateComicInfo);
|
||||
|
||||
bindField(":number",number,updateComicInfo);
|
||||
bindField(":isBis",isBis,updateComicInfo);
|
||||
bindField(":count",count,updateComicInfo);
|
||||
|
||||
bindField(":volume",volume,updateComicInfo);
|
||||
bindField(":storyArc",storyArc,updateComicInfo);
|
||||
bindField(":arcNumber",arcNumber,updateComicInfo);
|
||||
bindField(":arcCount",arcCount,updateComicInfo);
|
||||
|
||||
bindField(":genere",genere,updateComicInfo);
|
||||
|
||||
bindField(":writer",writer,updateComicInfo);
|
||||
bindField(":penciller",penciller,updateComicInfo);
|
||||
bindField(":inker",inker,updateComicInfo);
|
||||
bindField(":colorist",colorist,updateComicInfo);
|
||||
bindField(":letterer",letterer,updateComicInfo);
|
||||
bindField(":coverArtist",coverArtist,updateComicInfo);
|
||||
|
||||
bindField(":date",date,updateComicInfo);
|
||||
bindField(":publisher",publisher,updateComicInfo);
|
||||
bindField(":format",format,updateComicInfo);
|
||||
bindField(":color",color,updateComicInfo);
|
||||
bindField(":ageRating",ageRating,updateComicInfo);
|
||||
|
||||
bindField(":synopsis",synopsis,updateComicInfo);
|
||||
bindField(":characters",characters,updateComicInfo);
|
||||
bindField(":notes",notes,updateComicInfo);
|
||||
|
||||
updateComicInfo.bindValue(":read", read?1:0);
|
||||
updateComicInfo.bindValue(":id", id);
|
||||
updateComicInfo.bindValue(":edited", edited?1:0);
|
||||
updateComicInfo.exec();
|
||||
//updateComicInfo.finish();
|
||||
//db.close();
|
||||
}
|
||||
|
||||
void ComicInfo::updateRead(QSqlDatabase & db)
|
||||
{
|
||||
QSqlQuery findComicInfo(db);
|
||||
findComicInfo.prepare("UPDATE comic_info SET "
|
||||
"read = :read"
|
||||
" WHERE id = :id ");
|
||||
|
||||
findComicInfo.bindValue(":read", read?1:0);
|
||||
findComicInfo.bindValue(":id", id);
|
||||
findComicInfo.exec();
|
||||
//findComicInfo.finish();
|
||||
}
|
||||
|
||||
|
||||
//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;
|
||||
}
|
@ -4,57 +4,114 @@
|
||||
#include "library_item.h"
|
||||
#include <QSqlDatabase>
|
||||
#include <QList>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
|
||||
class ComicInfo
|
||||
{
|
||||
public:
|
||||
ComicInfo();
|
||||
ComicInfo(const ComicInfo & comicInfo);
|
||||
~ComicInfo();
|
||||
|
||||
bool load(QString hash, QSqlDatabase & db);
|
||||
qulonglong insert(QSqlDatabase & db);
|
||||
void removeFromDB(QSqlDatabase & db);
|
||||
void update(QSqlDatabase & db);
|
||||
void updateRead(QSqlDatabase & db);
|
||||
|
||||
qulonglong id;
|
||||
bool read;
|
||||
bool edited;
|
||||
QString hash;
|
||||
|
||||
QString title;
|
||||
int pages;
|
||||
|
||||
int coverPage;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
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 setField(const QString & name, QString * & field, QSqlRecord & record);
|
||||
void setField(const QString & name, int * & field, QSqlRecord & record);
|
||||
void setField(const QString & name, bool * & field, QSqlRecord & record);
|
||||
|
||||
void bindField(const QString & name, QString * field, QSqlQuery & query);
|
||||
void bindField(const QString & name, int * field, QSqlQuery & query);
|
||||
void bindField(const QString & name, bool * field, QSqlQuery & query);
|
||||
|
||||
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 Comic : public LibraryItem
|
||||
|
@ -14,6 +14,7 @@ TreeModel * DataBaseManagement::newTreeModel(QString path)
|
||||
QSqlQuery selectQuery(loadDatabase(path));
|
||||
selectQuery.setForwardOnly(true);
|
||||
selectQuery.exec("select * from folder order by parentId,name");
|
||||
//selectQuery.finish();
|
||||
return new TreeModel(selectQuery);
|
||||
}
|
||||
|
||||
@ -32,11 +33,12 @@ QSqlDatabase DataBaseManagement::createDatabase(QString dest)
|
||||
qDebug() << db.tables();
|
||||
}
|
||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
|
||||
//pragma.finish();
|
||||
DataBaseManagement::createTables(db);
|
||||
|
||||
QSqlQuery query("INSERT INTO folder (parentId, name, path) "
|
||||
"VALUES (1,'root', '/')",db);
|
||||
|
||||
//query.finish();
|
||||
//db.close();
|
||||
|
||||
return db;
|
||||
@ -45,7 +47,7 @@ QSqlDatabase DataBaseManagement::createDatabase(QString dest)
|
||||
QSqlDatabase DataBaseManagement::loadDatabase(QString path)
|
||||
{
|
||||
//TODO check path
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",path);
|
||||
db.setDatabaseName(path+"/library.ydb");
|
||||
if (!db.open()) {
|
||||
//se devuelve una base de datos vac<61>a e inv<6E>lida
|
||||
@ -53,6 +55,7 @@ QSqlDatabase DataBaseManagement::loadDatabase(QString path)
|
||||
return QSqlDatabase();
|
||||
}
|
||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
|
||||
//pragma.finish();
|
||||
//devuelve la base de datos
|
||||
return db;
|
||||
}
|
||||
@ -65,7 +68,7 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
QSqlQuery queryFolder(database);
|
||||
queryFolder.prepare("CREATE TABLE folder (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE)");
|
||||
success = success && queryFolder.exec();
|
||||
|
||||
//queryFolder.finish();
|
||||
//COMIC INFO (representa la informaci<63>n de un c<>mic, cada c<>mic tendr<64> un id<69>ntificador <20>nico formado por un hash sha1'de los primeros 512kb' + su tama<6D>o en bytes)
|
||||
QSqlQuery queryComicInfo(database);
|
||||
queryComicInfo.prepare("CREATE TABLE comic_info ("
|
||||
@ -107,19 +110,22 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
"edited BOOLEAN DEFAULT 0,"
|
||||
"read BOOLEAN)");
|
||||
success = success && queryComicInfo.exec();
|
||||
//queryComicInfo.finish();
|
||||
|
||||
//COMIC (representa un c<>mic en disco, contiene el nombre de fichero)
|
||||
QSqlQuery queryComic(database);
|
||||
queryComic.prepare("CREATE TABLE comic (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, comicInfoId INTEGER NOT NULL, fileName TEXT NOT NULL, path TEXT, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE, FOREIGN KEY(comicInfoId) REFERENCES comic_info(id))");
|
||||
success = success && queryComic.exec();
|
||||
|
||||
//queryComic.finish();
|
||||
//DB INFO
|
||||
QSqlQuery queryDBInfo(database);
|
||||
queryDBInfo.prepare("CREATE TABLE db_info (version TEXT NOT NULL)");
|
||||
success = success && queryDBInfo.exec();
|
||||
//queryDBInfo.finish();
|
||||
|
||||
QSqlQuery query("INSERT INTO db_info (version) "
|
||||
"VALUES ('5.0.0')",database);
|
||||
//query.finish();
|
||||
|
||||
|
||||
return success;
|
||||
@ -137,15 +143,18 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
||||
//attach.bindValue(":dest",QDir().toNativeSeparators(dest));
|
||||
attach.exec();
|
||||
//attach.finish();
|
||||
|
||||
QSqlQuery attach2(sourceDB);
|
||||
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
||||
attach2.exec();
|
||||
//attach2.finish();
|
||||
|
||||
//sourceDB.close();
|
||||
QSqlQuery queryDBInfo(sourceDB);
|
||||
queryDBInfo.prepare("CREATE TABLE dest.db_info (version TEXT NOT NULL)");
|
||||
queryDBInfo.exec();
|
||||
//queryDBInfo.finish();
|
||||
|
||||
/*QSqlQuery queryComicsInfo(sourceDB);
|
||||
queryComicsInfo.prepare("CREATE TABLE dest.comic_info (id INTEGER PRIMARY KEY, hash TEXT NOT NULL, edited BOOLEAN DEFAULT FALSE, title TEXT, read BOOLEAN)");
|
||||
@ -153,10 +162,12 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
|
||||
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
||||
"VALUES ('5.0.0')",sourceDB);
|
||||
//query.finish();
|
||||
|
||||
QSqlQuery exportData(sourceDB);
|
||||
exportData.prepare("create table dest.comic_info as select * from source.comic_info where source.comic_info.edited = 1");
|
||||
exportData.exec();
|
||||
//exportData.finish();
|
||||
|
||||
QString error = exportData.lastError().databaseText();
|
||||
QString error2 = exportData.lastError().text();
|
||||
@ -165,10 +176,53 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
destDB.close();
|
||||
|
||||
}
|
||||
void DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||
#include <qmessagebox.h>
|
||||
bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||
{
|
||||
QSqlDatabase sourceDB = loadDatabase(source);
|
||||
QSqlDatabase destDB = loadDatabase(dest);
|
||||
QString error;
|
||||
QString driver;
|
||||
|
||||
bool b = false;
|
||||
|
||||
QSqlDatabase destDB = QSqlDatabase::addDatabase("QSQLITE",dest);
|
||||
destDB.setDatabaseName(dest);
|
||||
if(destDB.open())
|
||||
{
|
||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",destDB);
|
||||
|
||||
QSqlQuery attach(destDB);
|
||||
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
||||
attach.exec();
|
||||
|
||||
error = attach.lastError().databaseText();
|
||||
driver = attach.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,tr("db error"),error);
|
||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
|
||||
QSqlQuery attach2(destDB);
|
||||
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
||||
attach2.exec();
|
||||
|
||||
error = attach2.lastError().databaseText();
|
||||
driver = attach2.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,tr("db error"),error);
|
||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
//TODO check versions...
|
||||
|
||||
QSqlQuery import(destDB);
|
||||
import.prepare("insert or replace into dest.comic_info select * from source.comic_info;");
|
||||
bool b = import.exec();
|
||||
error = import.lastError().databaseText();
|
||||
driver = import.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,tr("db error"),error);
|
||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
|
||||
destDB.close();
|
||||
}
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
static bool createTables(QSqlDatabase & database);
|
||||
|
||||
static void exportComicsInfo(QString source, QString dest);
|
||||
static void importComicsInfo(QString source, QString dest);
|
||||
static bool importComicsInfo(QString source, QString dest);
|
||||
};
|
||||
|
||||
#endif
|
@ -163,6 +163,7 @@ void TableModel::setupModelData(unsigned long long int folderId,QSqlDatabase & d
|
||||
//timer.restart();
|
||||
setupModelData(selectQuery);
|
||||
//txtS << "TABLEMODEL: Tiempo de creaci<63>n del modelo: " << timer.elapsed() << "ms\r\n";
|
||||
//selectQuery.finish();
|
||||
db.close();
|
||||
_database = db;
|
||||
endResetModel();
|
||||
|
@ -72,6 +72,7 @@ TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
||||
rootItem->id = ROOT;
|
||||
rootItem->parentItem = 0;
|
||||
setupModelData(sqlquery, rootItem);
|
||||
//sqlquery.finish();
|
||||
}
|
||||
//! [0]
|
||||
|
||||
@ -219,6 +220,7 @@ void TreeModel::setupModelData(QString path)
|
||||
QSqlQuery selectQuery("select * from folder where id <> 1 order by parentId,name",_database);
|
||||
|
||||
setupModelData(selectQuery,rootItem);
|
||||
//selectQuery.finish();
|
||||
_database.close();
|
||||
endResetModel();
|
||||
|
||||
@ -285,7 +287,10 @@ void TreeModel::setupFilteredModelData()
|
||||
selectQuery.bindValue(":filter2", "%%"+filter+"%%");
|
||||
}
|
||||
selectQuery.exec();
|
||||
|
||||
setupFilteredModelData(selectQuery,rootItem);
|
||||
|
||||
//selectQuery.finish();
|
||||
_database.close();
|
||||
|
||||
endResetModel();
|
||||
|
@ -138,7 +138,7 @@ void LibraryWindow::doLayout()
|
||||
|
||||
//FINAL LAYOUT-------------------------------------------------------------
|
||||
sVertical->addWidget(comicFlow);
|
||||
QWidget *comics = new QWidget;
|
||||
comics = new QWidget;
|
||||
QVBoxLayout * comicsLayout = new QVBoxLayout;
|
||||
comicsLayout->setContentsMargins(2,2,0,0);
|
||||
comicsLayout->addWidget(editInfoToolBar = new QToolBar(comics));
|
||||
@ -586,6 +586,7 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
{
|
||||
if(libraries.size()>0)
|
||||
{
|
||||
dm->getDatabase().close();
|
||||
QString path=libraries.value(name)+"/.yacreaderlibrary";
|
||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||
if(d.exists(path))
|
||||
@ -751,7 +752,7 @@ void LibraryWindow::setCurrentComicReaded()
|
||||
c.info.read = true;
|
||||
QSqlDatabase db = dm->getDatabase();
|
||||
db.open();
|
||||
c.info.update(db);
|
||||
c.info.updateRead(db);
|
||||
db.close();
|
||||
}
|
||||
|
||||
@ -770,7 +771,7 @@ void LibraryWindow::setCurrentComicUnreaded()
|
||||
c.info.read = false;
|
||||
QSqlDatabase db = dm->getDatabase();
|
||||
db.open();
|
||||
c.info.update(db);
|
||||
c.info.updateRead(db);
|
||||
db.close();
|
||||
|
||||
}
|
||||
@ -880,12 +881,16 @@ void LibraryWindow::deleteLibrary()
|
||||
|
||||
void LibraryWindow::deleteCurrentLibrary()
|
||||
{
|
||||
|
||||
dm->getDatabase().close();
|
||||
if(!dm->getDatabase().isOpen())
|
||||
{
|
||||
QString path = libraries.value(selectedLibrary->currentText());
|
||||
libraries.remove(selectedLibrary->currentText());
|
||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||
selectedLibrary->setCurrentIndex(0);
|
||||
path = path+"/.yacreaderlibrary";
|
||||
dm->getDatabase().close();
|
||||
|
||||
QDir d(path);
|
||||
delTree(d);
|
||||
d.rmdir(path);
|
||||
@ -896,6 +901,7 @@ void LibraryWindow::deleteCurrentLibrary()
|
||||
comicFlow->clear();
|
||||
}
|
||||
saveLibraries();
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::removeLibrary()
|
||||
@ -975,7 +981,7 @@ void LibraryWindow::toFullScreen()
|
||||
comicFlow->hide();
|
||||
comicFlow->setSlideSize(slideSizeF);
|
||||
comicFlow->setCenterIndex(comicFlow->centerIndex());
|
||||
comicView->hide();
|
||||
comics->hide();
|
||||
left->hide();
|
||||
libraryToolBar->hide();
|
||||
|
||||
@ -994,7 +1000,7 @@ void LibraryWindow::toNormal()
|
||||
comicFlow->setSlideSize(slideSizeW);
|
||||
comicFlow->setCenterIndex(comicFlow->centerIndex());
|
||||
comicFlow->render();
|
||||
comicView->show();
|
||||
comics->show();
|
||||
left->show();
|
||||
fullScreenToolTip->hide();
|
||||
libraryToolBar->show();
|
||||
@ -1038,8 +1044,10 @@ void LibraryWindow::showProperties()
|
||||
|
||||
//ThumbnailCreator tc(path,"");
|
||||
//tc.create();
|
||||
propertiesDialog->setComics(comics);
|
||||
propertiesDialog->database = dm->getDatabase();
|
||||
propertiesDialog->basePath = currentPath();
|
||||
propertiesDialog->setComics(comics);
|
||||
|
||||
/*propertiesDialog->setCover(tc.getCover());
|
||||
propertiesDialog->setFilename(path.split("/").last());
|
||||
propertiesDialog->setNumpages(tc.getNumPages());
|
||||
@ -1157,5 +1165,6 @@ void LibraryWindow::showExportComicsInfo()
|
||||
|
||||
void LibraryWindow::showImportComicsInfo()
|
||||
{
|
||||
importComicsInfoDialog->dest = currentPath() + "/.yacreaderlibrary/library.ydb";
|
||||
importComicsInfoDialog->show();
|
||||
}
|
@ -63,6 +63,7 @@ private:
|
||||
QPushButton * clearFoldersFilter;
|
||||
QCheckBox * includeComicsCheckBox;
|
||||
//-------------
|
||||
QWidget *comics;
|
||||
QTableView * comicView;
|
||||
QTreeView * foldersView;
|
||||
QComboBox * selectedLibrary;
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <QSizePolicy>
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QLineEdit>
|
||||
#include <QTabWidget>
|
||||
|
||||
|
||||
@ -32,7 +31,6 @@ PropertiesDialog::PropertiesDialog(QWidget * parent)
|
||||
|
||||
this->setLayout(mainLayout);
|
||||
mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
this->setWindowTitle(tr("Comic properties"));
|
||||
|
||||
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
|
||||
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
|
||||
@ -74,7 +72,7 @@ void PropertiesDialog::createCoverBox()
|
||||
|
||||
QVBoxLayout * coverLayout = new QVBoxLayout();
|
||||
coverLayout->addWidget(cover);
|
||||
coverLayout->addWidget(coverPageEdit = new QLineEdit());
|
||||
coverLayout->addWidget(coverPageEdit = new YACReaderFieldEdit());
|
||||
|
||||
coverBox->setLayout(coverLayout);
|
||||
}
|
||||
@ -101,34 +99,34 @@ void PropertiesDialog::createGeneralInfoBox()
|
||||
|
||||
|
||||
//generalInfoLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||
generalInfoLayout->addRow(tr("Title:"), title = new QLineEdit());
|
||||
generalInfoLayout->addRow(tr("Title:"), title = new YACReaderFieldEdit());
|
||||
|
||||
|
||||
QHBoxLayout * number = new QHBoxLayout;
|
||||
number->addWidget(numberEdit = new QLineEdit());
|
||||
number->addWidget(numberEdit = new YACReaderFieldEdit());
|
||||
number->addWidget(new QLabel("Bis:"));
|
||||
number->addWidget(isBisCheck = new QCheckBox());
|
||||
number->addWidget(new QLabel("of:"));
|
||||
number->addWidget(countEdit = new QLineEdit());
|
||||
number->addWidget(countEdit = new YACReaderFieldEdit());
|
||||
number->addStretch(1);
|
||||
/*generalInfoLayout->addRow(tr("&Issue number:"), );
|
||||
generalInfoLayout->addRow(tr("&Bis:"), );*/
|
||||
generalInfoLayout->addRow(tr("Issue number:"), number);
|
||||
|
||||
generalInfoLayout->addRow(tr("&Volume:"), volumeEdit = new QLineEdit());
|
||||
generalInfoLayout->addRow(tr("Volume:"), volumeEdit = new YACReaderFieldEdit());
|
||||
|
||||
QHBoxLayout * arc = new QHBoxLayout;
|
||||
arc->addWidget(storyArcEdit = new QLineEdit());
|
||||
arc->addWidget(storyArcEdit = new YACReaderFieldEdit());
|
||||
arc->addWidget(new QLabel("Arc number:"));
|
||||
arc->addWidget(arcNumberEdit = new QLineEdit());
|
||||
arc->addWidget(arcNumberEdit = new YACReaderFieldEdit());
|
||||
arc->addWidget(new QLabel("of:"));
|
||||
arc->addWidget(arcCountEdit = new QLineEdit());
|
||||
arc->addWidget(arcCountEdit = new YACReaderFieldEdit());
|
||||
arc->addStretch(1);
|
||||
generalInfoLayout->addRow(tr("&Story arc:"), arc);
|
||||
generalInfoLayout->addRow(tr("Story arc:"), arc);
|
||||
|
||||
generalInfoLayout->addRow(tr("&Genere:"), genereEdit = new QLineEdit());
|
||||
generalInfoLayout->addRow(tr("Genere:"), genereEdit = new YACReaderFieldEdit());
|
||||
|
||||
generalInfoLayout->addRow(tr("&Size:"), size = new QLabel("size"));
|
||||
generalInfoLayout->addRow(tr("Size:"), size = new QLabel("size"));
|
||||
|
||||
generalInfoBox->setLayout(generalInfoLayout);
|
||||
}
|
||||
@ -144,37 +142,37 @@ void PropertiesDialog::createAuthorsBox()
|
||||
QVBoxLayout * vl1 = new QVBoxLayout;
|
||||
QVBoxLayout * vr1 = new QVBoxLayout;
|
||||
vl1->addWidget(new QLabel(tr("Writer(s):")));
|
||||
vl1->addWidget(writer = new QPlainTextEdit());
|
||||
vl1->addWidget(writer = new YACReaderFieldPlainTextEdit());
|
||||
h1->addLayout(vl1);
|
||||
vr1->addWidget(new QLabel(tr("Penciller(s):")));
|
||||
vr1->addWidget(penciller = new QPlainTextEdit());
|
||||
vr1->addWidget(penciller = new YACReaderFieldPlainTextEdit());
|
||||
h1->addLayout(vr1);
|
||||
//authorsLayout->addRow(tr("Writer(s):"), new QPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Penciller(s):"), new QPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Writer(s):"), new YACReaderFieldPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Penciller(s):"), new YACReaderFieldPlainTextEdit());
|
||||
QHBoxLayout * h2 = new QHBoxLayout;
|
||||
QVBoxLayout * vl2 = new QVBoxLayout;
|
||||
QVBoxLayout * vr2 = new QVBoxLayout;
|
||||
vl2->addWidget(new QLabel(tr("Inker(s):")));
|
||||
vl2->addWidget(inker = new QPlainTextEdit());
|
||||
vl2->addWidget(inker = new YACReaderFieldPlainTextEdit());
|
||||
h2->addLayout(vl2);
|
||||
vr2->addWidget(new QLabel(tr("Colorist(s):")));
|
||||
vr2->addWidget(colorist = new QPlainTextEdit());
|
||||
vr2->addWidget(colorist = new YACReaderFieldPlainTextEdit());
|
||||
h2->addLayout(vr2);
|
||||
|
||||
//authorsLayout->addRow(tr("Inker(s):"), new QPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Colorist(s):"), new QPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Inker(s):"), new YACReaderFieldPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Colorist(s):"), new YACReaderFieldPlainTextEdit());
|
||||
|
||||
QHBoxLayout * h3 = new QHBoxLayout;
|
||||
QVBoxLayout * vl3 = new QVBoxLayout;
|
||||
QVBoxLayout * vr3 = new QVBoxLayout;
|
||||
vl3->addWidget(new QLabel(tr("Letterer(es):")));
|
||||
vl3->addWidget(letterer = new QPlainTextEdit());
|
||||
vl3->addWidget(letterer = new YACReaderFieldPlainTextEdit());
|
||||
h3->addLayout(vl3);
|
||||
vr3->addWidget(new QLabel(tr("Cover Artist(s):")));
|
||||
vr3->addWidget(coverArtist = new QPlainTextEdit());
|
||||
vr3->addWidget(coverArtist = new YACReaderFieldPlainTextEdit());
|
||||
h3->addLayout(vr3);
|
||||
//authorsLayout->addRow(tr("Letterer(es):"), new QPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Cover Artist(s):"), new QPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Letterer(es):"), new YACReaderFieldPlainTextEdit());
|
||||
//authorsLayout->addRow(tr("Cover Artist(s):"), new YACReaderFieldPlainTextEdit());
|
||||
|
||||
authorsLayout->addLayout(h1);
|
||||
authorsLayout->addLayout(h2);
|
||||
@ -192,19 +190,19 @@ void PropertiesDialog::createPublishingBox()
|
||||
|
||||
QHBoxLayout * date = new QHBoxLayout;
|
||||
date->addWidget(new QLabel(tr("Day:")));
|
||||
date->addWidget(dayEdit = new QLineEdit());
|
||||
date->addWidget(dayEdit = new YACReaderFieldEdit());
|
||||
date->addWidget(new QLabel(tr("Month:")));
|
||||
date->addWidget(monthEdit = new QLineEdit());
|
||||
date->addWidget(monthEdit = new YACReaderFieldEdit());
|
||||
date->addWidget(new QLabel(tr("Year:")));
|
||||
date->addWidget(yearEdit = new QLineEdit());
|
||||
date->addWidget(yearEdit = new YACReaderFieldEdit());
|
||||
date->addStretch(1);
|
||||
|
||||
publishingLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||
publishingLayout->addRow(date);
|
||||
publishingLayout->addRow(tr("Publisher:"), publisherEdit = new QLineEdit());
|
||||
publishingLayout->addRow(tr("Format:"), formatEdit = new QLineEdit());
|
||||
publishingLayout->addRow(tr("Publisher:"), publisherEdit = new YACReaderFieldEdit());
|
||||
publishingLayout->addRow(tr("Format:"), formatEdit = new YACReaderFieldEdit());
|
||||
publishingLayout->addRow(tr("Color/BW:"), colorCheck = new QCheckBox());
|
||||
publishingLayout->addRow(tr("Age rating:"), ageRatingEdit = new QLineEdit());
|
||||
publishingLayout->addRow(tr("Age rating:"), ageRatingEdit = new YACReaderFieldEdit());
|
||||
|
||||
publishingBox->setLayout(publishingLayout);
|
||||
}
|
||||
@ -216,9 +214,9 @@ void PropertiesDialog::createPlotBox()
|
||||
QFormLayout *plotLayout = new QFormLayout;
|
||||
|
||||
plotLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||
plotLayout->addRow(tr("Synopsis:"), synopsis = new QPlainTextEdit());
|
||||
plotLayout->addRow(tr("Characters:"), characters = new QPlainTextEdit());
|
||||
plotLayout->addRow(tr("Notes:"), notes = new QPlainTextEdit());
|
||||
plotLayout->addRow(tr("Synopsis:"), synopsis = new YACReaderFieldPlainTextEdit());
|
||||
plotLayout->addRow(tr("Characters:"), characters = new YACReaderFieldPlainTextEdit());
|
||||
plotLayout->addRow(tr("Notes:"), notes = new YACReaderFieldPlainTextEdit());
|
||||
|
||||
plotBox->setLayout(plotLayout);
|
||||
|
||||
@ -237,22 +235,158 @@ void PropertiesDialog::createButtonBox()
|
||||
connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PropertiesDialog::setComics(QList<Comic> comics)
|
||||
{
|
||||
this->comics = comics;
|
||||
|
||||
Comic comic = comics.at(0);
|
||||
|
||||
if(comic.info.title != NULL)
|
||||
title->setText(*comic.info.title);
|
||||
|
||||
if(comic.info.coverPage != NULL)
|
||||
coverPageEdit->setText(QString::number(*comic.info.coverPage));
|
||||
/*if(comic.info.numPages != NULL)
|
||||
numPagesEdit->setText(QString::number(*comic.info.numPages));*/
|
||||
|
||||
|
||||
if(comic.info.number != NULL)
|
||||
numberEdit->setText(QString::number(*comic.info.number));
|
||||
if(comic.info.isBis != NULL)
|
||||
isBisCheck->setChecked(*comic.info.isBis);
|
||||
if(comic.info.count != NULL)
|
||||
countEdit->setText(QString::number(*comic.info.count));
|
||||
|
||||
if(comic.info.volume != NULL)
|
||||
volumeEdit->setText(*comic.info.volume);
|
||||
if(comic.info.storyArc != NULL)
|
||||
storyArcEdit->setText(*comic.info.storyArc);
|
||||
if(comic.info.arcNumber != NULL)
|
||||
arcNumberEdit->setText(QString::number(*comic.info.arcNumber));
|
||||
if(comic.info.arcCount != NULL)
|
||||
arcCountEdit->setText(QString::number(*comic.info.arcCount));
|
||||
|
||||
if(comic.info.genere != NULL)
|
||||
genereEdit->setText(*comic.info.genere);
|
||||
|
||||
if(comic.info.writer != NULL)
|
||||
writer->setPlainText(*comic.info.writer);
|
||||
if(comic.info.penciller != NULL)
|
||||
penciller->setPlainText(*comic.info.penciller);
|
||||
if(comic.info.inker != NULL)
|
||||
inker->setPlainText(*comic.info.inker);
|
||||
if(comic.info.colorist != NULL)
|
||||
colorist->setPlainText(*comic.info.colorist);
|
||||
if(comic.info.letterer != NULL)
|
||||
letterer->setPlainText(*comic.info.letterer);
|
||||
if(comic.info.coverArtist != NULL)
|
||||
coverArtist->setPlainText(*comic.info.coverArtist);
|
||||
|
||||
if(comic.info.date != NULL)
|
||||
{
|
||||
QStringList date = (*comic.info.date).split("/");
|
||||
dayEdit->setText(date[0]);
|
||||
monthEdit->setText(date[1]);
|
||||
yearEdit->setText(date[2]);
|
||||
}
|
||||
if(comic.info.publisher != NULL)
|
||||
publisherEdit->setText(*comic.info.publisher);
|
||||
if(comic.info.format != NULL)
|
||||
formatEdit->setText(*comic.info.format);
|
||||
if(comic.info.color != NULL)
|
||||
colorCheck->setChecked(*comic.info.color);
|
||||
if(comic.info.ageRating != NULL)
|
||||
ageRatingEdit->setText(*comic.info.ageRating);
|
||||
|
||||
if(comic.info.synopsis != NULL)
|
||||
synopsis->setPlainText(*comic.info.synopsis);
|
||||
if(comic.info.characters != NULL)
|
||||
characters->setPlainText(*comic.info.characters);
|
||||
if(comic.info.notes != NULL)
|
||||
notes->setPlainText(*comic.info.notes);
|
||||
|
||||
|
||||
if(comics.length() > 1)
|
||||
{
|
||||
setDisableUniqueValues(true);
|
||||
this->setWindowTitle(tr("Edit selected comics information"));
|
||||
setCover(QPixmap(":/images/editComic.png"));
|
||||
|
||||
QList<Comic>::iterator itr;
|
||||
for(itr = ++comics.begin();itr!=comics.end();itr++)
|
||||
{
|
||||
if(itr->info.title == NULL || *(itr->info.title) != title->text())
|
||||
{
|
||||
title->clear();
|
||||
}
|
||||
if(itr->info.count == NULL || *(itr->info.count) != countEdit->text().toInt()) //TODO esto est<73> mal
|
||||
countEdit->clear();
|
||||
|
||||
if(itr->info.volume == NULL || *(itr->info.volume) != volumeEdit->text())
|
||||
volumeEdit->clear();
|
||||
if(itr->info.storyArc == NULL || *(itr->info.storyArc) != storyArcEdit->text())
|
||||
storyArcEdit->clear();
|
||||
if(itr->info.arcCount == NULL || *(itr->info.arcCount) != storyArcEdit->text().toInt())
|
||||
arcCountEdit->clear();
|
||||
|
||||
if(itr->info.genere == NULL || *(itr->info.genere) != genereEdit->text())
|
||||
genereEdit->clear();
|
||||
|
||||
if(itr->info.writer == NULL || *(itr->info.writer) != writer->toPlainText())
|
||||
writer->clear();
|
||||
if(itr->info.penciller == NULL || *(itr->info.penciller) != penciller->toPlainText())
|
||||
penciller->clear();
|
||||
if(itr->info.inker == NULL || *(itr->info.inker) != inker->toPlainText())
|
||||
inker->clear();
|
||||
if(itr->info.colorist == NULL || *(itr->info.colorist) != colorist->toPlainText())
|
||||
colorist->clear();
|
||||
if(itr->info.letterer == NULL || *(itr->info.letterer) != letterer->toPlainText())
|
||||
letterer->clear();
|
||||
if(itr->info.coverArtist == NULL || *(itr->info.coverArtist) != coverArtist->toPlainText())
|
||||
coverArtist->clear();
|
||||
|
||||
if(itr->info.date == NULL)
|
||||
{
|
||||
dayEdit->clear();
|
||||
monthEdit->clear();
|
||||
yearEdit->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList date = itr->info.date->split("/");
|
||||
if(dayEdit->text() != date[0])
|
||||
dayEdit->clear();
|
||||
if(monthEdit->text() != date[1])
|
||||
monthEdit->clear();
|
||||
if(yearEdit->text() != date[2])
|
||||
yearEdit->clear();
|
||||
}
|
||||
|
||||
if(itr->info.publisher == NULL || *(itr->info.publisher) != publisherEdit->text())
|
||||
publisherEdit->clear();
|
||||
if(itr->info.format == NULL || *(itr->info.format) != formatEdit->text())
|
||||
formatEdit->clear();
|
||||
if(itr->info.color == NULL || *(itr->info.color) != colorCheck->isChecked())
|
||||
colorCheck->setChecked(false);
|
||||
if(itr->info.ageRating == NULL || *(itr->info.ageRating) != ageRatingEdit->text())
|
||||
ageRatingEdit->clear();
|
||||
|
||||
if(itr->info.synopsis == NULL || *(itr->info.synopsis) != synopsis->toPlainText())
|
||||
synopsis->clear();
|
||||
if(itr->info.characters == NULL || *(itr->info.characters) != characters->toPlainText())
|
||||
characters->clear();
|
||||
if(itr->info.notes == NULL || *(itr->info.notes) != notes->toPlainText())
|
||||
notes->clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Comic comic = comics.at(0);
|
||||
title->setText(comic.info.title);
|
||||
|
||||
numberEdit->setText(QString::number(comic.info.number));
|
||||
|
||||
setDisableUniqueValues(false);
|
||||
this->setWindowTitle(tr("Edit comic information"));
|
||||
setCover(comic.info.getCover(basePath));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -260,8 +394,15 @@ void PropertiesDialog::setComics(QList<Comic> comics)
|
||||
void PropertiesDialog::updateComics()
|
||||
{
|
||||
database.open();
|
||||
comics[0].info.update(database);
|
||||
database.close();
|
||||
database.transaction();
|
||||
QList<Comic>::iterator itr;
|
||||
for(itr = comics.begin();itr!=comics.end();itr++)
|
||||
{
|
||||
if(itr->info.edited)
|
||||
itr->info.update(database);
|
||||
}
|
||||
database.commit();
|
||||
database.close();
|
||||
}
|
||||
//Deprecated
|
||||
void PropertiesDialog::setCover(const QPixmap & coverImage)
|
||||
@ -301,7 +442,7 @@ void PropertiesDialog::setFilename(const QString & nameString)
|
||||
}
|
||||
void PropertiesDialog::setNumpages(int pagesNum)
|
||||
{
|
||||
pages->setText(QString::number(pagesNum));
|
||||
numPagesEdit->setText(QString::number(pagesNum));
|
||||
}
|
||||
void PropertiesDialog::setSize(float sizeFloat)
|
||||
{
|
||||
@ -311,10 +452,148 @@ void PropertiesDialog::setSize(float sizeFloat)
|
||||
|
||||
void PropertiesDialog::save()
|
||||
{
|
||||
QList<Comic>::iterator itr;
|
||||
for(itr = comics.begin();itr!=comics.end();itr++)
|
||||
{
|
||||
//Comic & comic = comics[0];
|
||||
bool edited = false;
|
||||
|
||||
comics[0].info.title = title->text();
|
||||
comics[0].info.edited = true;
|
||||
if(title->isModified())
|
||||
{
|
||||
itr->info.setTitle(title->text());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
if(itr->info.coverPage != NULL || !coverPageEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setCoverPage(coverPageEdit->text().toInt());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
/*if(comic.info.numPages != NULL)
|
||||
numPagesEdit->setText(QString::number(*comic.info.numPages));*/
|
||||
|
||||
if(itr->info.number != NULL || !numberEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setNumber(numberEdit->text().toInt());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.isBis != NULL || isBisCheck->isChecked())
|
||||
{
|
||||
itr->info.setIsBis(isBisCheck->isChecked());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.count != NULL || !countEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setCount(countEdit->text().toInt());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
if(itr->info.volume != NULL || !volumeEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setVolume(volumeEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.storyArc != NULL || !storyArcEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setStoryArc(storyArcEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.arcNumber != NULL || !arcNumberEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setArcNumber(arcNumberEdit->text().toInt());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.arcCount != NULL || !arcCountEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setArcCount(arcCountEdit->text().toInt());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
if(itr->info.genere != NULL || !genereEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setGenere(genereEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
if(itr->info.writer != NULL || writer->document()->isModified())
|
||||
{
|
||||
itr->info.setWriter(writer->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.penciller != NULL || penciller->document()->isModified())
|
||||
{
|
||||
itr->info.setPenciller(penciller->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.inker != NULL || inker->document()->isModified())
|
||||
{
|
||||
itr->info.setInker(inker->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.colorist != NULL || colorist->document()->isModified())
|
||||
{
|
||||
itr->info.setColorist(colorist->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.letterer != NULL || letterer->document()->isModified())
|
||||
{
|
||||
itr->info.setLetterer(letterer->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.coverArtist != NULL || coverArtist->document()->isModified())
|
||||
{
|
||||
itr->info.setCoverArtist(coverArtist->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
if(itr->info.date != NULL || !dayEdit->text().isEmpty() || !monthEdit->text().isEmpty() || !yearEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setDate(dayEdit->text()+"/"+monthEdit->text()+"/"+yearEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.publisher != NULL || !publisherEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setPublisher(publisherEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.format != NULL || !formatEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setFormat(formatEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.color != NULL || colorCheck->isChecked())
|
||||
{
|
||||
itr->info.setColor(colorCheck->isChecked());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.ageRating != NULL || !ageRatingEdit->text().isEmpty())
|
||||
{
|
||||
itr->info.setAgeRating(ageRatingEdit->text());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
if(itr->info.synopsis != NULL || synopsis->document()->isModified())
|
||||
{
|
||||
itr->info.setSynopsis(synopsis->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.characters != NULL || characters->document()->isModified())
|
||||
{
|
||||
itr->info.setCharacters(characters->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
if(itr->info.notes != NULL || notes->document()->isModified())
|
||||
{
|
||||
itr->info.setNotes(notes->toPlainText());
|
||||
edited = true;
|
||||
}
|
||||
|
||||
itr->info.edited = edited;
|
||||
}
|
||||
updateComics();
|
||||
close();
|
||||
emit(accepted());
|
||||
}
|
||||
|
||||
void PropertiesDialog::setDisableUniqueValues(bool disabled)
|
||||
@ -323,4 +602,41 @@ void PropertiesDialog::setDisableUniqueValues(bool disabled)
|
||||
numberEdit->setDisabled(disabled);
|
||||
isBisCheck->setDisabled(disabled);
|
||||
arcNumberEdit->setDisabled(disabled);
|
||||
}
|
||||
|
||||
void PropertiesDialog::closeEvent ( QCloseEvent * e )
|
||||
{
|
||||
|
||||
title->clear();
|
||||
title->setModified(false);
|
||||
coverPageEdit->clear();
|
||||
// numPagesEdit->setText(QString::number(*comic.info.numPages));
|
||||
numberEdit->clear();
|
||||
isBisCheck->setChecked(false);
|
||||
countEdit->clear();
|
||||
volumeEdit->clear();
|
||||
storyArcEdit->clear();
|
||||
arcNumberEdit->clear();
|
||||
arcCountEdit->clear();
|
||||
genereEdit->clear();
|
||||
writer->clear();
|
||||
penciller->clear();
|
||||
inker->clear();
|
||||
colorist->clear();
|
||||
letterer->clear();
|
||||
coverArtist->clear();
|
||||
dayEdit->clear();
|
||||
monthEdit->clear();
|
||||
yearEdit->clear();
|
||||
publisherEdit->clear();
|
||||
formatEdit->clear();
|
||||
colorCheck->setChecked(false);
|
||||
ageRatingEdit->clear();
|
||||
synopsis->clear();
|
||||
characters->clear();
|
||||
notes->clear();
|
||||
|
||||
setDisableUniqueValues(false);
|
||||
|
||||
QDialog::closeEvent(e);
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
#include <QGroupBox>
|
||||
@ -11,9 +10,9 @@
|
||||
#include <QGridLayout>
|
||||
#include <QTabWidget>
|
||||
#include <QCheckBox>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "comic.h"
|
||||
#include "custom_widgets.h"
|
||||
|
||||
class PropertiesDialog : public QDialog
|
||||
{
|
||||
@ -28,41 +27,41 @@
|
||||
QScrollArea * sa;
|
||||
|
||||
QWidget * generalInfoBox;
|
||||
QLineEdit * title;
|
||||
QLineEdit * pages;
|
||||
YACReaderFieldEdit * title;
|
||||
YACReaderFieldEdit * numPagesEdit;
|
||||
QLabel * size;
|
||||
|
||||
QLineEdit * coverPageEdit;
|
||||
YACReaderFieldEdit * coverPageEdit;
|
||||
|
||||
QLineEdit * numberEdit;
|
||||
YACReaderFieldEdit * numberEdit;
|
||||
QCheckBox * isBisCheck;
|
||||
QLineEdit * countEdit;
|
||||
YACReaderFieldEdit * countEdit;
|
||||
|
||||
QLineEdit * volumeEdit;
|
||||
QLineEdit * storyArcEdit;
|
||||
QLineEdit * arcNumberEdit;
|
||||
QLineEdit * arcCountEdit;
|
||||
YACReaderFieldEdit * volumeEdit;
|
||||
YACReaderFieldEdit * storyArcEdit;
|
||||
YACReaderFieldEdit * arcNumberEdit;
|
||||
YACReaderFieldEdit * arcCountEdit;
|
||||
|
||||
QLineEdit * genereEdit;
|
||||
YACReaderFieldEdit * genereEdit;
|
||||
|
||||
QPlainTextEdit * writer;
|
||||
QPlainTextEdit * penciller;
|
||||
QPlainTextEdit * inker;
|
||||
QPlainTextEdit * colorist;
|
||||
QPlainTextEdit * letterer;
|
||||
QPlainTextEdit * coverArtist;
|
||||
YACReaderFieldPlainTextEdit * writer;
|
||||
YACReaderFieldPlainTextEdit * penciller;
|
||||
YACReaderFieldPlainTextEdit * inker;
|
||||
YACReaderFieldPlainTextEdit * colorist;
|
||||
YACReaderFieldPlainTextEdit * letterer;
|
||||
YACReaderFieldPlainTextEdit * coverArtist;
|
||||
|
||||
QLineEdit * dayEdit;
|
||||
QLineEdit * monthEdit;
|
||||
QLineEdit * yearEdit;
|
||||
QLineEdit * publisherEdit;
|
||||
QLineEdit * formatEdit;
|
||||
YACReaderFieldEdit * dayEdit;
|
||||
YACReaderFieldEdit * monthEdit;
|
||||
YACReaderFieldEdit * yearEdit;
|
||||
YACReaderFieldEdit * publisherEdit;
|
||||
YACReaderFieldEdit * formatEdit;
|
||||
QCheckBox * colorCheck;
|
||||
QLineEdit * ageRatingEdit;
|
||||
YACReaderFieldEdit * ageRatingEdit;
|
||||
|
||||
QPlainTextEdit * synopsis;
|
||||
QPlainTextEdit * characters;
|
||||
QPlainTextEdit * notes;
|
||||
YACReaderFieldPlainTextEdit * synopsis;
|
||||
YACReaderFieldPlainTextEdit * characters;
|
||||
YACReaderFieldPlainTextEdit * notes;
|
||||
|
||||
QWidget * authorsBox;
|
||||
|
||||
@ -74,7 +73,7 @@
|
||||
QPushButton *closeButton;
|
||||
QPushButton *saveButton;
|
||||
QPushButton *restoreButton; //??
|
||||
|
||||
|
||||
void createTabBar();
|
||||
void createCoverBox();
|
||||
void createGeneralInfoBox();
|
||||
@ -87,10 +86,12 @@
|
||||
void setDisableUniqueValues(bool disabled);
|
||||
|
||||
QList<Comic> comics;
|
||||
|
||||
void closeEvent ( QCloseEvent * e );
|
||||
public:
|
||||
PropertiesDialog(QWidget * parent = 0);
|
||||
QSqlDatabase database;
|
||||
QString basePath;
|
||||
|
||||
public slots:
|
||||
void setComics(QList<Comic> comics);
|
||||
void updateComics();
|
||||
|
@ -369,3 +369,78 @@ bool YACReaderSortComics::lessThan(const QModelIndex &left, const QModelIndex &r
|
||||
|
||||
return naturalSortLessThanCI(leftString,rightString);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent)
|
||||
:QLineEdit(parent)
|
||||
{
|
||||
setPlaceholderText(tr("Click to overwrite"));
|
||||
setModified(false);
|
||||
restore = new QAction(tr("Restore to default"),this);
|
||||
this->addAction(restore);
|
||||
//this->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
void YACReaderFieldEdit::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
if (e->reason() == Qt::MouseFocusReason)
|
||||
{
|
||||
setModified(true);
|
||||
setPlaceholderText("");
|
||||
}
|
||||
|
||||
QLineEdit::focusInEvent(e);
|
||||
}
|
||||
|
||||
void YACReaderFieldEdit::clear()
|
||||
{
|
||||
setModified(false);
|
||||
setPlaceholderText(tr("Click to overwrite"));
|
||||
QLineEdit::clear();
|
||||
}
|
||||
|
||||
void YACReaderFieldEdit::setDisabled(bool disabled)
|
||||
{
|
||||
if(disabled)
|
||||
setPlaceholderText("");
|
||||
QLineEdit::setDisabled(disabled);
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent)
|
||||
:QPlainTextEdit(parent)
|
||||
{
|
||||
document()->setModified(false);
|
||||
setPlainText(tr("Click to overwrite"));
|
||||
restore = new QAction(tr("Restore to default"),this);
|
||||
this->addAction(restore);
|
||||
//this->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
if (e->reason() == Qt::MouseFocusReason)
|
||||
{
|
||||
document()->setModified(true);
|
||||
setPlainText("");
|
||||
}
|
||||
|
||||
QPlainTextEdit::focusInEvent(e);
|
||||
}
|
||||
|
||||
void YACReaderFieldPlainTextEdit::clear()
|
||||
{
|
||||
QPlainTextEdit::clear();
|
||||
document()->setModified(false);
|
||||
setPlainText(tr("Click to overwrite"));
|
||||
}
|
||||
|
||||
void YACReaderFieldPlainTextEdit::setDisabled(bool disabled)
|
||||
{
|
||||
if(disabled)
|
||||
setPlainText(tr("Click to overwrite"));
|
||||
QPlainTextEdit::setDisabled(disabled);
|
||||
}
|
@ -17,7 +17,9 @@
|
||||
#include <QModelIndex>
|
||||
#include <QRegExp>
|
||||
#include <QHash>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QAction>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "pictureflow.h"
|
||||
|
||||
@ -134,5 +136,34 @@ class YACReaderSortComics : public QSortFilterProxyModel
|
||||
};
|
||||
|
||||
void delTree(QDir dir);
|
||||
|
||||
|
||||
class YACReaderFieldEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
YACReaderFieldEdit(QWidget * parent = 0);
|
||||
void clear();
|
||||
void setDisabled(bool disabled);
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent* e);
|
||||
private:
|
||||
QAction * restore;
|
||||
|
||||
};
|
||||
|
||||
class YACReaderFieldPlainTextEdit : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
YACReaderFieldPlainTextEdit(QWidget * parent = 0);
|
||||
void clear();
|
||||
void setDisabled(bool disabled);
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent* e);
|
||||
private:
|
||||
QAction * restore;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user