mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
a?adidos validadores al di?logo properties
arreglado bug que provocaba que al actualizar una libreria se perdiese su ruta (creadas 2 se?ales que permiten distinguir la creaci?n de la actualizaci?n) finalizada la importaci?n de informaci?n coverPage tiene ahora un valor por defecto -> 1. VERSION "5.0.0" es ahora compartido por YACReader y YACReaderLibrary.
This commit is contained in:
parent
f8ee0da89b
commit
dbfaaa2d96
@ -38,7 +38,8 @@ HEADERS += comic_flow.h \
|
||||
./db/folder.h \
|
||||
./db/library_item.h \
|
||||
export_comics_info_dialog.h \
|
||||
import_comics_info_dialog.h
|
||||
import_comics_info_dialog.h \
|
||||
../common/check_new_version.h
|
||||
|
||||
SOURCES += comic_flow.cpp \
|
||||
create_library_dialog.cpp \
|
||||
@ -65,7 +66,8 @@ SOURCES += comic_flow.cpp \
|
||||
./db/folder.cpp \
|
||||
./db/library_item.cpp \
|
||||
export_comics_info_dialog.cpp \
|
||||
import_comics_info_dialog.cpp
|
||||
import_comics_info_dialog.cpp \
|
||||
../common/check_new_version.cpp
|
||||
|
||||
include(./server/server.pri)
|
||||
|
||||
|
@ -56,7 +56,7 @@ void AddLibraryDialog::setupUI()
|
||||
QLabel * imgLabel = new QLabel(this);
|
||||
QPixmap p(":/images/openLibrary.png");
|
||||
imgLabel->setPixmap(p);
|
||||
imgMainLayout->addWidget(imgLabel);
|
||||
imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop);
|
||||
imgMainLayout->addLayout(mainLayout);
|
||||
|
||||
setLayout(imgMainLayout);
|
||||
|
@ -166,6 +166,7 @@ UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
|
||||
setLayout(imgMainLayout);
|
||||
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Update library"));
|
||||
}
|
||||
|
||||
void UpdateLibraryDialog::showCurrentFile(QString file)
|
||||
|
@ -21,6 +21,7 @@ Comic::Comic(qulonglong cparentId, QString cname, QString cpath, QString chash,
|
||||
if(!info.load(chash,database))
|
||||
{
|
||||
info.hash = chash;
|
||||
info.coverPage = new int(1);
|
||||
_hasCover = false;
|
||||
}
|
||||
else
|
||||
@ -91,7 +92,9 @@ bool Comic::load(qulonglong idc, QSqlDatabase & db)
|
||||
//id = record.value("id").toULongLong();
|
||||
parentId = record.value("parentId").toULongLong();
|
||||
name = record.value("name").toString();
|
||||
path = record.value("path").toString();
|
||||
info.load(record.value("hash").toString(),db);
|
||||
|
||||
return true;
|
||||
}
|
||||
//selectQuery.finish();
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "data_base_management.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include "library_creator.h"
|
||||
#include "check_new_version.h"
|
||||
|
||||
static QString fields = "title ,"
|
||||
|
||||
@ -181,7 +183,7 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
//queryDBInfo.finish();
|
||||
|
||||
QSqlQuery query("INSERT INTO db_info (version) "
|
||||
"VALUES ('5.0.0')",database);
|
||||
"VALUES ('"VERSION"')",database);
|
||||
//query.finish();
|
||||
}
|
||||
|
||||
@ -236,6 +238,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||
{
|
||||
QString error;
|
||||
QString driver;
|
||||
QStringList hashes;
|
||||
|
||||
bool b = false;
|
||||
|
||||
@ -285,149 +288,253 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||
" WHERE hash = :hash ");
|
||||
|
||||
QSqlQuery insert(destDB);
|
||||
insert.prepare("INSERT INTO comic_info SET "
|
||||
"title = :title,"
|
||||
insert.prepare("INSERT INTO comic_info "
|
||||
"(title,"
|
||||
"coverPage,"
|
||||
"numPages,"
|
||||
"number,"
|
||||
"isBis,"
|
||||
"count,"
|
||||
"volume,"
|
||||
"storyArc,"
|
||||
"arcNumber,"
|
||||
"arcCount,"
|
||||
"genere,"
|
||||
"writer,"
|
||||
"penciller,"
|
||||
"inker,"
|
||||
"colorist,"
|
||||
"letterer,"
|
||||
"coverArtist,"
|
||||
"date,"
|
||||
"publisher,"
|
||||
"format,"
|
||||
"color,"
|
||||
"ageRating,"
|
||||
"synopsis,"
|
||||
"characters,"
|
||||
"notes,"
|
||||
"read,"
|
||||
"edited,"
|
||||
"hash)"
|
||||
|
||||
"VALUES (:title,"
|
||||
":coverPage,"
|
||||
":numPages,"
|
||||
":number,"
|
||||
":isBis,"
|
||||
":count,"
|
||||
|
||||
":volume,"
|
||||
":storyArc,"
|
||||
":arcNumber,"
|
||||
":arcCount,"
|
||||
|
||||
":genere,"
|
||||
|
||||
"coverPage = :coverPage,"
|
||||
"numPages = :numPages,"
|
||||
":writer,"
|
||||
":penciller,"
|
||||
":inker,"
|
||||
":colorist,"
|
||||
":letterer,"
|
||||
":coverArtist,"
|
||||
|
||||
"number = :number,"
|
||||
"isBis = :isBis,"
|
||||
"count = :count,"
|
||||
":date,"
|
||||
":publisher,"
|
||||
":format,"
|
||||
":color,"
|
||||
":ageRating,"
|
||||
|
||||
"volume = :volume,"
|
||||
"storyArc = :storyArc,"
|
||||
"arcNumber = :arcNumber,"
|
||||
"arcCount = :arcCount,"
|
||||
|
||||
"genere = :genere,"
|
||||
":synopsis,"
|
||||
":characters,"
|
||||
":notes,"
|
||||
|
||||
"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,"
|
||||
":edited,"
|
||||
|
||||
"read = :read,"
|
||||
"edited = :edited,"
|
||||
|
||||
"hash = :hash ");
|
||||
":hash )");
|
||||
QSqlQuery newInfo(sourceDB);
|
||||
newInfo.prepare("SELECT * FROM comic_info");
|
||||
newInfo.exec();
|
||||
destDB.transaction();
|
||||
int cp;
|
||||
while (newInfo.next()) //cada tupla deberá ser insertada o actualizada
|
||||
{
|
||||
for(int i = 0; i<10000; i++)
|
||||
{
|
||||
QSqlRecord record = newInfo.record();
|
||||
|
||||
update.bindValue(":title",record.value("title").toString());
|
||||
cp = record.value("coverPage").toInt();
|
||||
if(cp>1)
|
||||
{
|
||||
QSqlQuery checkCoverPage(destDB);
|
||||
checkCoverPage.prepare("SELECT coverPage FROM comic_info where hash = :hash");
|
||||
checkCoverPage.bindValue(":hash",record.value("hash").toString());
|
||||
checkCoverPage.exec();
|
||||
bool extract = false;
|
||||
if(checkCoverPage.next())
|
||||
{
|
||||
extract = checkCoverPage.record().value("coverPage").toInt() != cp;
|
||||
}
|
||||
if(extract)
|
||||
hashes.append(record.value("hash").toString());
|
||||
}
|
||||
|
||||
update.bindValue(":coverPage",record.value("coverPage").toInt());
|
||||
update.bindValue(":numPages",record.value("numPages").toInt());
|
||||
|
||||
update.bindValue(":number",record.value("number").toInt());
|
||||
update.bindValue(":isBis",record.value("isBis").toInt());
|
||||
update.bindValue(":count",record.value("count").toInt());
|
||||
|
||||
update.bindValue(":volume",record.value("volume").toString());
|
||||
update.bindValue(":storyArc",record.value("storyArc").toString());
|
||||
update.bindValue(":arcNumber",record.value("arcNumber").toString());
|
||||
update.bindValue(":arcCount",record.value("arcCount").toString());
|
||||
|
||||
update.bindValue(":genere",record.value("genere").toString());
|
||||
|
||||
update.bindValue(":writer",record.value("writer").toString());
|
||||
update.bindValue(":penciller",record.value("penciller").toString());
|
||||
update.bindValue(":inker",record.value("inker").toString());
|
||||
update.bindValue(":colorist",record.value("colorist").toString());
|
||||
update.bindValue(":letterer",record.value("letterer").toString());
|
||||
update.bindValue(":coverArtist",record.value("coverArtist").toString());
|
||||
|
||||
update.bindValue(":date",record.value("date").toString());
|
||||
update.bindValue(":publisher",record.value("publisher").toString());
|
||||
update.bindValue(":format",record.value("format").toString());
|
||||
update.bindValue(":color",record.value("color").toInt());
|
||||
update.bindValue(":ageRating",record.value("ageRating").toString());
|
||||
|
||||
update.bindValue(":synopsis",record.value("synopsis").toString());
|
||||
update.bindValue(":characters",record.value("characters").toString());
|
||||
update.bindValue(":notes",record.value("notes").toString());
|
||||
bindValuesFromRecord(record,update);
|
||||
|
||||
update.bindValue(":edited",1);
|
||||
|
||||
update.bindValue(":hash",record.value("hash").toString());
|
||||
|
||||
update.exec();
|
||||
|
||||
if(update.numRowsAffected() == 0)
|
||||
{
|
||||
insert.bindValue(":title",record.value("title").toString());
|
||||
|
||||
insert.bindValue(":coverPage",record.value("coverPage").toInt());
|
||||
insert.bindValue(":numPages",record.value("numPages").toInt());
|
||||
|
||||
insert.bindValue(":number",record.value("number").toInt());
|
||||
insert.bindValue(":isBis",record.value("isBis").toInt());
|
||||
insert.bindValue(":count",record.value("count").toInt());
|
||||
|
||||
insert.bindValue(":volume",record.value("volume").toString());
|
||||
insert.bindValue(":storyArc",record.value("storyArc").toString());
|
||||
insert.bindValue(":arcNumber",record.value("arcNumber").toString());
|
||||
insert.bindValue(":arcCount",record.value("arcCount").toString());
|
||||
|
||||
insert.bindValue(":genere",record.value("genere").toString());
|
||||
|
||||
insert.bindValue(":writer",record.value("writer").toString());
|
||||
insert.bindValue(":penciller",record.value("penciller").toString());
|
||||
insert.bindValue(":inker",record.value("inker").toString());
|
||||
insert.bindValue(":colorist",record.value("colorist").toString());
|
||||
insert.bindValue(":letterer",record.value("letterer").toString());
|
||||
insert.bindValue(":coverArtist",record.value("coverArtist").toString());
|
||||
|
||||
insert.bindValue(":date",record.value("date").toString());
|
||||
insert.bindValue(":publisher",record.value("publisher").toString());
|
||||
insert.bindValue(":format",record.value("format").toString());
|
||||
insert.bindValue(":color",record.value("color").toInt());
|
||||
insert.bindValue(":ageRating",record.value("ageRating").toString());
|
||||
|
||||
insert.bindValue(":synopsis",record.value("synopsis").toString());
|
||||
insert.bindValue(":characters",record.value("characters").toString());
|
||||
insert.bindValue(":notes",record.value("notes").toString());
|
||||
|
||||
bindValuesFromRecord(record,insert);
|
||||
insert.bindValue(":edited",1);
|
||||
insert.bindValue(":read",0);
|
||||
|
||||
insert.bindValue(":hash",record.value("hash").toString());
|
||||
insert.exec();
|
||||
|
||||
QString error1 = insert.lastError().databaseText();
|
||||
QString error2 = insert.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,"db",error1);
|
||||
QMessageBox::critical(NULL,"driver",error2);
|
||||
}
|
||||
update.finish();
|
||||
insert.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
destDB.commit();
|
||||
QString hash;
|
||||
foreach(hash, hashes)
|
||||
{
|
||||
QSqlQuery getComic(destDB);
|
||||
getComic.prepare("SELECT c.path,ci.coverPage FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) where ci.hash = :hash");
|
||||
getComic.bindValue(":hash",hash);
|
||||
getComic.exec();
|
||||
if(getComic.next())
|
||||
{
|
||||
QString basePath = QString(dest).remove("/.yacreaderlibrary/library.ydb");
|
||||
QString path = basePath + getComic.record().value("path").toString();
|
||||
int coverPage = getComic.record().value("coverPage").toInt();
|
||||
ThumbnailCreator tc(path,basePath+"/.yacreaderlibrary/covers/"+hash+".jpg",coverPage);
|
||||
tc.create();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
destDB.close();
|
||||
sourceDB.close();
|
||||
|
||||
QSqlDatabase::removeDatabase(source);
|
||||
QSqlDatabase::removeDatabase(dest);
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query)
|
||||
{
|
||||
bindString("title",record,query);
|
||||
|
||||
bindInt("coverPage",record,query);
|
||||
bindInt("numPages",record,query);
|
||||
|
||||
bindInt("number",record,query);
|
||||
bindInt("isBis",record,query);
|
||||
bindInt("count",record,query);
|
||||
|
||||
bindString("volume",record,query);
|
||||
bindString("storyArc",record,query);
|
||||
bindInt("arcNumber",record,query);
|
||||
bindInt("arcCount",record,query);
|
||||
|
||||
bindString("genere",record,query);
|
||||
|
||||
bindString("writer",record,query);
|
||||
bindString("penciller",record,query);
|
||||
bindString("inker",record,query);
|
||||
bindString("colorist",record,query);
|
||||
bindString("letterer",record,query);
|
||||
bindString("coverArtist",record,query);
|
||||
|
||||
bindString("date",record,query);
|
||||
bindString("publisher",record,query);
|
||||
bindString("format",record,query);
|
||||
bindInt("color",record,query);
|
||||
bindString("ageRating",record,query);
|
||||
|
||||
bindString("synopsis",record,query);
|
||||
bindString("characters",record,query);
|
||||
bindString("notes",record,query);
|
||||
|
||||
bindString("hash",record,query);
|
||||
}
|
||||
|
||||
void DataBaseManagement::bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query)
|
||||
{
|
||||
if(!record.value(name).isNull())
|
||||
{
|
||||
query.bindValue(":"+name,record.value(name).toString());
|
||||
}
|
||||
}
|
||||
void DataBaseManagement::bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query)
|
||||
{
|
||||
if(!record.value(name).isNull())
|
||||
{
|
||||
query.bindValue(":"+name,record.value(name).toInt());
|
||||
}
|
||||
}
|
||||
|
||||
QString DataBaseManagement::checkValidDB(const QString & fullPath)
|
||||
{
|
||||
QSqlDatabase db = loadDatabaseFromFile(fullPath);
|
||||
if(db.isValid() && db.isOpen())
|
||||
{
|
||||
QSqlQuery version(db);
|
||||
version.prepare("SELECT * FROM db_info");
|
||||
version.exec();
|
||||
if(version.next())
|
||||
{
|
||||
return version.record().value("version").toString();
|
||||
}
|
||||
else
|
||||
return "";
|
||||
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
int DataBaseManagement::compareVersions(const QString & v1, const QString v2)
|
||||
{
|
||||
QStringList v1l = v1.split('.');
|
||||
QStringList v2l = v2.split('.');
|
||||
QList<int> v1il;
|
||||
QList<int> v2il;
|
||||
|
||||
foreach(QString s, v1l)
|
||||
v1il.append(s.toInt());
|
||||
|
||||
foreach(QString s,v2l)
|
||||
v2il.append(s.toInt());
|
||||
|
||||
for(int i=0;i<qMin(v1il.length(),v2il.length());i++)
|
||||
{
|
||||
if(v1il[i]<v2il[i])
|
||||
return -1;
|
||||
if(v1il[i]>v2il[i])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(v1il.length() < v2il.length())
|
||||
return -1;
|
||||
if(v1il.length() == v2il.length())
|
||||
return 0;
|
||||
if(v1il.length() > v2il.length())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//COMICS_INFO_EXPORTER
|
||||
ComicsInfoExporter::ComicsInfoExporter()
|
||||
:QThread()
|
||||
|
@ -25,6 +25,7 @@ public:
|
||||
void importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest);
|
||||
private:
|
||||
void run();
|
||||
|
||||
};
|
||||
|
||||
class DataBaseManagement : public QObject
|
||||
@ -32,6 +33,10 @@ class DataBaseManagement : public QObject
|
||||
Q_OBJECT
|
||||
private:
|
||||
QList<QString> dataBasesList;
|
||||
static void bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query);
|
||||
static void bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query);
|
||||
static void bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query);
|
||||
|
||||
public:
|
||||
DataBaseManagement();
|
||||
//TreeModel * newTreeModel(QString path);
|
||||
@ -45,6 +50,9 @@ public:
|
||||
|
||||
static void exportComicsInfo(QString source, QString dest);
|
||||
static bool importComicsInfo(QString source, QString dest);
|
||||
|
||||
static QString checkValidDB(const QString & fullPath); //retorna "" si la DB es inválida ó la versión si es válida.
|
||||
static int compareVersions(const QString & v1, const QString v2); //retorna <0 si v1 < v2, 0 si v1 = v2 y >0 si v1 > v2
|
||||
};
|
||||
|
||||
#endif
|
@ -100,6 +100,7 @@ void ImportComicsInfoDialog::close()
|
||||
progressBar->hide();
|
||||
accept->setDisabled(true);
|
||||
QDialog::close();
|
||||
emit(finished(0));
|
||||
}
|
||||
|
||||
void Importer::run()
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlRecord>
|
||||
#include "data_base_management.h"
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
//QMutex mutex;
|
||||
|
||||
|
||||
@ -68,6 +73,7 @@ void LibraryCreator::run()
|
||||
_database.commit();
|
||||
_database.close();
|
||||
QSqlDatabase::removeDatabase(_database.connectionName());
|
||||
emit(created());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -83,7 +89,9 @@ void LibraryCreator::run()
|
||||
_database.commit();
|
||||
_database.close();
|
||||
QSqlDatabase::removeDatabase(_target);
|
||||
emit(updated());
|
||||
}
|
||||
msleep(100);//TODO try to solve the problem with the udpate dialog
|
||||
emit(finished());
|
||||
}
|
||||
|
||||
@ -174,6 +182,11 @@ void LibraryCreator::create(QDir dir)
|
||||
}
|
||||
}
|
||||
|
||||
bool LibraryCreator::checkCover(const QString & hash)
|
||||
{
|
||||
return QFile::exists(_target+"/covers/"+hash+".jpg");
|
||||
}
|
||||
|
||||
void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo & fileInfo)
|
||||
{
|
||||
//en este punto sabemos que todos los folders que hay en _currentPath, deberían estar añadidos a la base de datos
|
||||
@ -191,10 +204,10 @@ void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo &
|
||||
QString hash = QString(crypto.result().toHex().constData()) + QString::number(fileInfo.size());
|
||||
Comic comic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database);
|
||||
int numPages;
|
||||
|
||||
if(!comic.hasCover())
|
||||
|
||||
if(! ( comic.hasCover() && checkCover(hash)))
|
||||
{
|
||||
ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+hash+".jpg");
|
||||
ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+hash+".jpg",*comic.info.coverPage);
|
||||
//ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+fileInfo.fileName()+".jpg");
|
||||
tc.create();
|
||||
numPages = tc.getNumPages();
|
||||
@ -352,8 +365,8 @@ void LibraryCreator::update(QDir dirS)
|
||||
}
|
||||
}
|
||||
}
|
||||
ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target="")
|
||||
:_fileSource(fileSource),_target(target),_numPages(0)
|
||||
ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target="", int coverPage)
|
||||
:_fileSource(fileSource),_target(target),_numPages(0),_coverPage(coverPage)
|
||||
{
|
||||
}
|
||||
|
||||
@ -374,15 +387,32 @@ void ThumbnailCreator::create()
|
||||
QString line;
|
||||
_currentName = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; //TODO
|
||||
QString name;
|
||||
foreach(line,lines)
|
||||
if(_coverPage == 1)
|
||||
{
|
||||
if(rx.indexIn(line)!=-1)
|
||||
foreach(line,lines)
|
||||
{
|
||||
name = rx.cap(3).trimmed();
|
||||
if(0 > QString::localeAwareCompare(name,_currentName))
|
||||
_currentName = name;
|
||||
_numPages++;
|
||||
}
|
||||
if(rx.indexIn(line)!=-1)
|
||||
{
|
||||
name = rx.cap(3).trimmed();
|
||||
if(naturalSortLessThanCI(name,_currentName))
|
||||
_currentName = name;
|
||||
_numPages++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<QString> names;
|
||||
foreach(line,lines)
|
||||
{
|
||||
if(rx.indexIn(line)!=-1)
|
||||
{
|
||||
name = rx. cap(3).trimmed();
|
||||
names.append(name);
|
||||
}
|
||||
}
|
||||
std::sort(names.begin(),names.end(),naturalSortLessThanCI);
|
||||
_currentName = names[_coverPage-1];
|
||||
}
|
||||
delete _7z;
|
||||
attributes.clear();
|
||||
|
@ -41,6 +41,7 @@
|
||||
void update(QDir currentDirectory);
|
||||
void run();
|
||||
qulonglong insertFolders();//devuelve el id del último folder añadido (último en la ruta)
|
||||
bool checkCover(const QString & hash);
|
||||
void insertComic(const QString & relativePath,const QFileInfo & fileInfo);
|
||||
//qulonglong insertFolder(qulonglong parentId,const Folder & folder);
|
||||
//qulonglong insertComic(const Comic & comic);
|
||||
@ -49,6 +50,8 @@
|
||||
void finished();
|
||||
void coverExtracted(QString);
|
||||
void folderUpdated(QString);
|
||||
void updated();
|
||||
void created();
|
||||
};
|
||||
|
||||
class ThumbnailCreator : public QObject
|
||||
@ -56,7 +59,7 @@
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ThumbnailCreator(QString fileSource, QString target);
|
||||
ThumbnailCreator(QString fileSource, QString target, int coverPage = 1);
|
||||
private:
|
||||
QProcess * _7z;
|
||||
QString _fileSource;
|
||||
@ -64,6 +67,7 @@
|
||||
QString _currentName;
|
||||
int _numPages;
|
||||
QPixmap _cover;
|
||||
int _coverPage;
|
||||
|
||||
public slots:
|
||||
void create();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <iterator>
|
||||
|
||||
#include "data_base_management.h"
|
||||
#include "check_new_version.h"
|
||||
|
||||
//
|
||||
|
||||
@ -504,11 +505,13 @@ void LibraryWindow::createConnections()
|
||||
{
|
||||
//libraryCreator connections
|
||||
connect(createLibraryDialog,SIGNAL(createLibrary(QString,QString,QString)),this,SLOT(create(QString,QString,QString)));
|
||||
connect(importComicsInfoDialog,SIGNAL(finished(int)),this,SLOT(reloadCurrentLibrary()));
|
||||
connect(libraryCreator,SIGNAL(coverExtracted(QString)),createLibraryDialog,SLOT(showCurrentFile(QString)));
|
||||
connect(libraryCreator,SIGNAL(finished()),createLibraryDialog,SLOT(close()));
|
||||
connect(libraryCreator,SIGNAL(coverExtracted(QString)),updateLibraryDialog,SLOT(showCurrentFile(QString)));
|
||||
connect(libraryCreator,SIGNAL(finished()),updateLibraryDialog,SLOT(close()));
|
||||
connect(libraryCreator,SIGNAL(finished()),this,SLOT(openLastCreated()));
|
||||
connect(libraryCreator,SIGNAL(updated()),this,SLOT(reloadCurrentLibrary()));
|
||||
connect(libraryCreator,SIGNAL(created()),this,SLOT(openLastCreated()));
|
||||
|
||||
//packageManager connections
|
||||
connect(exportLibraryDialog,SIGNAL(exportPath(QString)),this,SLOT(exportLibrary(QString)));
|
||||
@ -600,9 +603,13 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
if(libraries.size()>0)
|
||||
{
|
||||
QString path=libraries.value(name)+"/.yacreaderlibrary";
|
||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||
if(d.exists(path))
|
||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||
QString dbVersion;
|
||||
if(d.exists(path) && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "")
|
||||
{
|
||||
int comparation;
|
||||
if((comparation = DataBaseManagement::compareVersions(dbVersion,VERSION)) == 0)
|
||||
{
|
||||
index = 0;
|
||||
sm->clear();
|
||||
//foldersView->setModel(NULL); //TODO comprobar pq no sirve con usar simplemente las señales beforeReset y reset
|
||||
@ -630,6 +637,36 @@ void LibraryWindow::loadLibrary(const QString & name)
|
||||
|
||||
//includeComicsCheckBox->setCheckState(Qt::Unchecked);
|
||||
foldersFilter->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(comparation < 0)
|
||||
{
|
||||
int ret = QMessageBox::question(this,tr("Update needed"),tr("This library was created with a previous version of YACReaderLibrary. It needs to be updated. Update now?"));
|
||||
if(ret == QMessageBox::Yes)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
comicView->setModel(NULL);
|
||||
foldersView->setModel(NULL);
|
||||
comicFlow->clear();
|
||||
disableAllActions();//TODO comprobar que se deben deshabilitar
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int ret = QMessageBox::question(this,tr("Download new version"),tr("This library was created with a newer version of YACReaderLibrary. Download the new version now?"),QMessageBox::Yes,QMessageBox::No);
|
||||
if(ret == QMessageBox::Yes)
|
||||
QDesktopServices::openUrl(QUrl("http://code.google.com/p/yacreader/"));
|
||||
|
||||
comicView->setModel(NULL);
|
||||
foldersView->setModel(NULL);
|
||||
comicFlow->clear();
|
||||
disableAllActions();//TODO comprobar que se deben deshabilitar
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -831,6 +868,11 @@ void LibraryWindow::create(QString source, QString dest, QString name)
|
||||
|
||||
}
|
||||
|
||||
void LibraryWindow::reloadCurrentLibrary()
|
||||
{
|
||||
loadLibrary(selectedLibrary->currentText());
|
||||
}
|
||||
|
||||
void LibraryWindow::openLastCreated()
|
||||
{
|
||||
|
||||
@ -854,9 +896,16 @@ void LibraryWindow::showAddLibrary()
|
||||
|
||||
void LibraryWindow::openLibrary(QString path, QString name)
|
||||
{
|
||||
_lastAdded = name;
|
||||
_sourceLastAdded = path;
|
||||
openLastCreated();
|
||||
path.remove("/.yacreaderlibrary");
|
||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||
if(d.exists(path + "/.yacreaderlibrary"))
|
||||
{
|
||||
_lastAdded = name;
|
||||
_sourceLastAdded = path;
|
||||
openLastCreated();
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(this,tr("Library not found"),tr("The selected folder doesn't contain any library."));
|
||||
}
|
||||
|
||||
void LibraryWindow::loadLibraries()
|
||||
@ -903,13 +952,12 @@ void LibraryWindow::saveLibraries()
|
||||
|
||||
void LibraryWindow::updateLibrary()
|
||||
{
|
||||
updateLibraryDialog->show();
|
||||
QString currentLibrary = selectedLibrary->currentText();
|
||||
QString path = libraries.value(currentLibrary);
|
||||
_lastAdded = currentLibrary;
|
||||
updateLibraryDialog->show();
|
||||
libraryCreator->updateLibrary(path,path+"/.yacreaderlibrary");
|
||||
libraryCreator->start();
|
||||
|
||||
}
|
||||
|
||||
void LibraryWindow::deleteLibrary()
|
||||
|
@ -168,6 +168,7 @@ public:
|
||||
void openLibrary(QString path, QString name);
|
||||
void loadLibraries();
|
||||
void saveLibraries();
|
||||
void reloadCurrentLibrary();
|
||||
void openLastCreated();
|
||||
void updateLibrary();
|
||||
void deleteLibrary();
|
||||
|
@ -6,8 +6,10 @@
|
||||
#include <QFormLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QTabWidget>
|
||||
#include <QIntValidator>
|
||||
|
||||
#include "data_base_management.h"
|
||||
#include "library_creator.h"
|
||||
|
||||
PropertiesDialog::PropertiesDialog(QWidget * parent)
|
||||
:QDialog(parent)
|
||||
@ -88,7 +90,7 @@ void PropertiesDialog::createCoverBox()
|
||||
|
||||
QFrame * createLine()
|
||||
{
|
||||
QFrame * line = new QFrame();
|
||||
QFrame * line = new QFrame();
|
||||
line->setObjectName(QString::fromUtf8("line"));
|
||||
//line->setGeometry(QRect(320, 150, 118, 3));
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
@ -103,20 +105,20 @@ void PropertiesDialog::createGeneralInfoBox()
|
||||
|
||||
QFormLayout *generalInfoLayout = new QFormLayout;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//generalInfoLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||
generalInfoLayout->addRow(tr("Title:"), title = new YACReaderFieldEdit());
|
||||
|
||||
|
||||
QHBoxLayout * number = new QHBoxLayout;
|
||||
number->addWidget(numberEdit = new YACReaderFieldEdit());
|
||||
numberValidator.setBottom(0);
|
||||
numberEdit->setValidator(&numberValidator);
|
||||
number->addWidget(new QLabel("Bis:"));
|
||||
number->addWidget(isBisCheck = new QCheckBox());
|
||||
number->addWidget(new QLabel("of:"));
|
||||
number->addWidget(countEdit = new YACReaderFieldEdit());
|
||||
countValidator.setBottom(0);
|
||||
countEdit->setValidator(&countValidator);
|
||||
number->addStretch(1);
|
||||
/*generalInfoLayout->addRow(tr("&Issue number:"), );
|
||||
generalInfoLayout->addRow(tr("&Bis:"), );*/
|
||||
@ -128,8 +130,12 @@ void PropertiesDialog::createGeneralInfoBox()
|
||||
arc->addWidget(storyArcEdit = new YACReaderFieldEdit());
|
||||
arc->addWidget(new QLabel("Arc number:"));
|
||||
arc->addWidget(arcNumberEdit = new YACReaderFieldEdit());
|
||||
arcNumberValidator.setBottom(0);
|
||||
arcNumberEdit->setValidator(&arcNumberValidator);
|
||||
arc->addWidget(new QLabel("of:"));
|
||||
arc->addWidget(arcCountEdit = new YACReaderFieldEdit());
|
||||
arcCountValidator.setBottom(0);
|
||||
arcCountEdit->setValidator(&arcCountValidator);
|
||||
arc->addStretch(1);
|
||||
generalInfoLayout->addRow(tr("Story arc:"), arc);
|
||||
|
||||
@ -200,10 +206,16 @@ void PropertiesDialog::createPublishingBox()
|
||||
QHBoxLayout * date = new QHBoxLayout;
|
||||
date->addWidget(new QLabel(tr("Day:")));
|
||||
date->addWidget(dayEdit = new YACReaderFieldEdit());
|
||||
dayValidator.setRange(1,31);
|
||||
dayEdit->setValidator(&dayValidator);
|
||||
date->addWidget(new QLabel(tr("Month:")));
|
||||
date->addWidget(monthEdit = new YACReaderFieldEdit());
|
||||
monthValidator.setRange(1,12);
|
||||
monthEdit->setValidator(&monthValidator);
|
||||
date->addWidget(new QLabel(tr("Year:")));
|
||||
date->addWidget(yearEdit = new YACReaderFieldEdit());
|
||||
yearValidator.setRange(1,9999);
|
||||
yearEdit->setValidator(&yearValidator);
|
||||
date->addStretch(1);
|
||||
|
||||
publishingLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||
@ -256,7 +268,11 @@ void PropertiesDialog::setComics(QList<Comic> comics)
|
||||
title->setText(*comic.info.title);
|
||||
|
||||
if(comic.info.coverPage != NULL)
|
||||
{
|
||||
coverPageEdit->setText(QString::number(*comic.info.coverPage));
|
||||
coverPageValidator.setRange(1,*comic.info.numPages);
|
||||
coverPageEdit->setValidator(&coverPageValidator);
|
||||
}
|
||||
/*if(comic.info.numPages != NULL)
|
||||
numPagesEdit->setText(QString::number(*comic.info.numPages));*/
|
||||
|
||||
@ -293,6 +309,8 @@ void PropertiesDialog::setComics(QList<Comic> comics)
|
||||
if(comic.info.coverArtist != NULL)
|
||||
coverArtist->setPlainText(*comic.info.coverArtist);
|
||||
|
||||
size->setText(QString::number(comic.info.hash.right(comic.info.hash.length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb");
|
||||
|
||||
if(comic.info.date != NULL)
|
||||
{
|
||||
QStringList date = (*comic.info.date).split("/");
|
||||
@ -478,7 +496,7 @@ void PropertiesDialog::save()
|
||||
}
|
||||
|
||||
if(comics.size()==1)
|
||||
if(coverPageEdit->isModified() && !coverPageEdit->text().isEmpty())
|
||||
if(coverPageEdit->isModified() && !coverPageEdit->text().isEmpty() && coverPageEdit->text().toInt() != 0)
|
||||
{
|
||||
itr->info.setCoverPage(coverPageEdit->text().toInt());
|
||||
edited = true;
|
||||
@ -609,6 +627,14 @@ void PropertiesDialog::save()
|
||||
itr->info.edited = edited;
|
||||
}
|
||||
updateComics();
|
||||
if(comics.count() == 1)
|
||||
{
|
||||
if(coverPageEdit->isModified())// && coverPageEdit->text().toInt() != *comics[0].info.coverPage)
|
||||
{
|
||||
ThumbnailCreator tc(basePath+comics[0].path,basePath+"/.yacreaderlibrary/covers/"+comics[0].info.hash+".jpg",*comics[0].info.coverPage);
|
||||
tc.create();
|
||||
}
|
||||
}
|
||||
close();
|
||||
emit(accepted());
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QGridLayout>
|
||||
#include <QTabWidget>
|
||||
#include <QCheckBox>
|
||||
#include <QIntValidator>
|
||||
|
||||
#include "comic.h"
|
||||
#include "custom_widgets.h"
|
||||
@ -32,15 +33,20 @@
|
||||
QLabel * size;
|
||||
|
||||
YACReaderFieldEdit * coverPageEdit;
|
||||
QIntValidator coverPageValidator;
|
||||
|
||||
YACReaderFieldEdit * numberEdit;
|
||||
QIntValidator numberValidator;
|
||||
QCheckBox * isBisCheck;
|
||||
YACReaderFieldEdit * countEdit;
|
||||
QIntValidator countValidator;
|
||||
|
||||
YACReaderFieldEdit * volumeEdit;
|
||||
YACReaderFieldEdit * storyArcEdit;
|
||||
YACReaderFieldEdit * arcNumberEdit;
|
||||
QIntValidator arcNumberValidator;
|
||||
YACReaderFieldEdit * arcCountEdit;
|
||||
QIntValidator arcCountValidator;
|
||||
|
||||
YACReaderFieldEdit * genereEdit;
|
||||
|
||||
@ -52,8 +58,11 @@
|
||||
YACReaderFieldPlainTextEdit * coverArtist;
|
||||
|
||||
YACReaderFieldEdit * dayEdit;
|
||||
QIntValidator dayValidator;
|
||||
YACReaderFieldEdit * monthEdit;
|
||||
QIntValidator monthValidator;
|
||||
YACReaderFieldEdit * yearEdit;
|
||||
QIntValidator yearValidator;
|
||||
YACReaderFieldEdit * publisherEdit;
|
||||
YACReaderFieldEdit * formatEdit;
|
||||
QCheckBox * colorCheck;
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QtGlobal>
|
||||
#include <QStringList>
|
||||
|
||||
#define VERSION "5.0"
|
||||
#define PREVIOUS_VERSION "0.4.5"
|
||||
|
||||
HttpVersionChecker::HttpVersionChecker()
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <QHttpResponseHeader>
|
||||
#include <QByteArray>
|
||||
|
||||
#define VERSION "5.0.0"
|
||||
|
||||
class HttpVersionChecker : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Loading…
x
Reference in New Issue
Block a user