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:
Luis Ángel San Martín 2012-07-08 23:05:14 +02:00
parent f8ee0da89b
commit dbfaaa2d96
15 changed files with 376 additions and 135 deletions

View File

@ -38,7 +38,8 @@ HEADERS += comic_flow.h \
./db/folder.h \ ./db/folder.h \
./db/library_item.h \ ./db/library_item.h \
export_comics_info_dialog.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 \ SOURCES += comic_flow.cpp \
create_library_dialog.cpp \ create_library_dialog.cpp \
@ -65,7 +66,8 @@ SOURCES += comic_flow.cpp \
./db/folder.cpp \ ./db/folder.cpp \
./db/library_item.cpp \ ./db/library_item.cpp \
export_comics_info_dialog.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) include(./server/server.pri)

View File

@ -56,7 +56,7 @@ void AddLibraryDialog::setupUI()
QLabel * imgLabel = new QLabel(this); QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/openLibrary.png"); QPixmap p(":/images/openLibrary.png");
imgLabel->setPixmap(p); imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel); imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop);
imgMainLayout->addLayout(mainLayout); imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout); setLayout(imgMainLayout);

View File

@ -166,6 +166,7 @@ UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
setLayout(imgMainLayout); setLayout(imgMainLayout);
setModal(true); setModal(true);
setWindowTitle(tr("Update library"));
} }
void UpdateLibraryDialog::showCurrentFile(QString file) void UpdateLibraryDialog::showCurrentFile(QString file)

View File

@ -21,6 +21,7 @@ Comic::Comic(qulonglong cparentId, QString cname, QString cpath, QString chash,
if(!info.load(chash,database)) if(!info.load(chash,database))
{ {
info.hash = chash; info.hash = chash;
info.coverPage = new int(1);
_hasCover = false; _hasCover = false;
} }
else else
@ -91,7 +92,9 @@ bool Comic::load(qulonglong idc, QSqlDatabase & db)
//id = record.value("id").toULongLong(); //id = record.value("id").toULongLong();
parentId = record.value("parentId").toULongLong(); parentId = record.value("parentId").toULongLong();
name = record.value("name").toString(); name = record.value("name").toString();
path = record.value("path").toString();
info.load(record.value("hash").toString(),db); info.load(record.value("hash").toString(),db);
return true; return true;
} }
//selectQuery.finish(); //selectQuery.finish();

View File

@ -1,6 +1,8 @@
#include "data_base_management.h" #include "data_base_management.h"
#include <QtCore> #include <QtCore>
#include "library_creator.h"
#include "check_new_version.h"
static QString fields = "title ," static QString fields = "title ,"
@ -181,7 +183,7 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
//queryDBInfo.finish(); //queryDBInfo.finish();
QSqlQuery query("INSERT INTO db_info (version) " QSqlQuery query("INSERT INTO db_info (version) "
"VALUES ('5.0.0')",database); "VALUES ('"VERSION"')",database);
//query.finish(); //query.finish();
} }
@ -236,6 +238,7 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
{ {
QString error; QString error;
QString driver; QString driver;
QStringList hashes;
bool b = false; bool b = false;
@ -285,149 +288,253 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
" WHERE hash = :hash "); " WHERE hash = :hash ");
QSqlQuery insert(destDB); QSqlQuery insert(destDB);
insert.prepare("INSERT INTO comic_info SET " insert.prepare("INSERT INTO comic_info "
"title = :title," "(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)"
"coverPage = :coverPage," "VALUES (:title,"
"numPages = :numPages," ":coverPage,"
":numPages,"
":number,"
":isBis,"
":count,"
"number = :number," ":volume,"
"isBis = :isBis," ":storyArc,"
"count = :count," ":arcNumber,"
":arcCount,"
"volume = :volume," ":genere,"
"storyArc = :storyArc,"
"arcNumber = :arcNumber,"
"arcCount = :arcCount,"
"genere = :genere," ":writer,"
":penciller,"
":inker,"
":colorist,"
":letterer,"
":coverArtist,"
"writer = :writer," ":date,"
"penciller = :penciller," ":publisher,"
"inker = :inker," ":format,"
"colorist = :colorist," ":color,"
"letterer = :letterer," ":ageRating,"
"coverArtist = :coverArtist,"
"date = :date," ":synopsis,"
"publisher = :publisher," ":characters,"
"format = :format," ":notes,"
"color = :color,"
"ageRating = :ageRating,"
"synopsis = :synopsis," ":read,"
"characters = :characters," ":edited,"
"notes = :notes,"
"read = :read," ":hash )");
"edited = :edited,"
"hash = :hash ");
QSqlQuery newInfo(sourceDB); QSqlQuery newInfo(sourceDB);
newInfo.prepare("SELECT * FROM comic_info"); newInfo.prepare("SELECT * FROM comic_info");
newInfo.exec(); newInfo.exec();
destDB.transaction(); destDB.transaction();
int cp;
while (newInfo.next()) //cada tupla deberá ser insertada o actualizada while (newInfo.next()) //cada tupla deberá ser insertada o actualizada
{ {
for(int i = 0; i<10000; i++)
{
QSqlRecord record = newInfo.record(); QSqlRecord record = newInfo.record();
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(":title",record.value("title").toString()); bindValuesFromRecord(record,update);
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());
update.bindValue(":edited",1); update.bindValue(":edited",1);
update.bindValue(":hash",record.value("hash").toString());
update.exec(); update.exec();
if(update.numRowsAffected() == 0) 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(":edited",1);
insert.bindValue(":read",0); insert.bindValue(":read",0);
insert.bindValue(":hash",record.value("hash").toString());
insert.exec(); insert.exec();
QString error1 = insert.lastError().databaseText();
QString error2 = insert.lastError().driverText();
QMessageBox::critical(NULL,"db",error1);
QMessageBox::critical(NULL,"driver",error2);
} }
update.finish(); update.finish();
insert.finish(); insert.finish();
} }
} }
}
destDB.commit(); 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(); destDB.close();
sourceDB.close(); sourceDB.close();
QSqlDatabase::removeDatabase(source); QSqlDatabase::removeDatabase(source);
QSqlDatabase::removeDatabase(dest); QSqlDatabase::removeDatabase(dest);
return b; 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 //COMICS_INFO_EXPORTER
ComicsInfoExporter::ComicsInfoExporter() ComicsInfoExporter::ComicsInfoExporter()
:QThread() :QThread()

View File

@ -25,6 +25,7 @@ public:
void importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest); void importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest);
private: private:
void run(); void run();
}; };
class DataBaseManagement : public QObject class DataBaseManagement : public QObject
@ -32,6 +33,10 @@ class DataBaseManagement : public QObject
Q_OBJECT Q_OBJECT
private: private:
QList<QString> dataBasesList; 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: public:
DataBaseManagement(); DataBaseManagement();
//TreeModel * newTreeModel(QString path); //TreeModel * newTreeModel(QString path);
@ -45,6 +50,9 @@ public:
static void exportComicsInfo(QString source, QString dest); static void exportComicsInfo(QString source, QString dest);
static bool importComicsInfo(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 #endif

View File

@ -100,6 +100,7 @@ void ImportComicsInfoDialog::close()
progressBar->hide(); progressBar->hide();
accept->setDisabled(true); accept->setDisabled(true);
QDialog::close(); QDialog::close();
emit(finished(0));
} }
void Importer::run() void Importer::run()

View File

@ -6,6 +6,11 @@
#include <QSqlQuery> #include <QSqlQuery>
#include <QSqlRecord> #include <QSqlRecord>
#include "data_base_management.h" #include "data_base_management.h"
#include "qnaturalsorting.h"
#include <algorithm>
using namespace std;
//QMutex mutex; //QMutex mutex;
@ -68,6 +73,7 @@ void LibraryCreator::run()
_database.commit(); _database.commit();
_database.close(); _database.close();
QSqlDatabase::removeDatabase(_database.connectionName()); QSqlDatabase::removeDatabase(_database.connectionName());
emit(created());
} }
else else
{ {
@ -83,7 +89,9 @@ void LibraryCreator::run()
_database.commit(); _database.commit();
_database.close(); _database.close();
QSqlDatabase::removeDatabase(_target); QSqlDatabase::removeDatabase(_target);
emit(updated());
} }
msleep(100);//TODO try to solve the problem with the udpate dialog
emit(finished()); 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) 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 //en este punto sabemos que todos los folders que hay en _currentPath, deberían estar añadidos a la base de datos
@ -192,9 +205,9 @@ void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo &
Comic comic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database); Comic comic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database);
int numPages; 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"); //ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+fileInfo.fileName()+".jpg");
tc.create(); tc.create();
numPages = tc.getNumPages(); numPages = tc.getNumPages();
@ -352,8 +365,8 @@ void LibraryCreator::update(QDir dirS)
} }
} }
} }
ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target="") ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target="", int coverPage)
:_fileSource(fileSource),_target(target),_numPages(0) :_fileSource(fileSource),_target(target),_numPages(0),_coverPage(coverPage)
{ {
} }
@ -374,16 +387,33 @@ void ThumbnailCreator::create()
QString line; QString line;
_currentName = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; //TODO _currentName = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; //TODO
QString name; QString name;
foreach(line,lines) if(_coverPage == 1)
{ {
if(rx.indexIn(line)!=-1) foreach(line,lines)
{ {
name = rx.cap(3).trimmed(); if(rx.indexIn(line)!=-1)
if(0 > QString::localeAwareCompare(name,_currentName)) {
_currentName = name; name = rx.cap(3).trimmed();
_numPages++; 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; delete _7z;
attributes.clear(); attributes.clear();
_currentName = QDir::fromNativeSeparators(_currentName).split('/').last(); //separator fixed. _currentName = QDir::fromNativeSeparators(_currentName).split('/').last(); //separator fixed.

View File

@ -41,6 +41,7 @@
void update(QDir currentDirectory); void update(QDir currentDirectory);
void run(); void run();
qulonglong insertFolders();//devuelve el id del último folder añadido (último en la ruta) 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); void insertComic(const QString & relativePath,const QFileInfo & fileInfo);
//qulonglong insertFolder(qulonglong parentId,const Folder & folder); //qulonglong insertFolder(qulonglong parentId,const Folder & folder);
//qulonglong insertComic(const Comic & comic); //qulonglong insertComic(const Comic & comic);
@ -49,6 +50,8 @@
void finished(); void finished();
void coverExtracted(QString); void coverExtracted(QString);
void folderUpdated(QString); void folderUpdated(QString);
void updated();
void created();
}; };
class ThumbnailCreator : public QObject class ThumbnailCreator : public QObject
@ -56,7 +59,7 @@
Q_OBJECT Q_OBJECT
public: public:
ThumbnailCreator(QString fileSource, QString target); ThumbnailCreator(QString fileSource, QString target, int coverPage = 1);
private: private:
QProcess * _7z; QProcess * _7z;
QString _fileSource; QString _fileSource;
@ -64,6 +67,7 @@
QString _currentName; QString _currentName;
int _numPages; int _numPages;
QPixmap _cover; QPixmap _cover;
int _coverPage;
public slots: public slots:
void create(); void create();

View File

@ -18,6 +18,7 @@
#include <iterator> #include <iterator>
#include "data_base_management.h" #include "data_base_management.h"
#include "check_new_version.h"
// //
@ -504,11 +505,13 @@ void LibraryWindow::createConnections()
{ {
//libraryCreator connections //libraryCreator connections
connect(createLibraryDialog,SIGNAL(createLibrary(QString,QString,QString)),this,SLOT(create(QString,QString,QString))); 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(coverExtracted(QString)),createLibraryDialog,SLOT(showCurrentFile(QString)));
connect(libraryCreator,SIGNAL(finished()),createLibraryDialog,SLOT(close())); connect(libraryCreator,SIGNAL(finished()),createLibraryDialog,SLOT(close()));
connect(libraryCreator,SIGNAL(coverExtracted(QString)),updateLibraryDialog,SLOT(showCurrentFile(QString))); connect(libraryCreator,SIGNAL(coverExtracted(QString)),updateLibraryDialog,SLOT(showCurrentFile(QString)));
connect(libraryCreator,SIGNAL(finished()),updateLibraryDialog,SLOT(close())); 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 //packageManager connections
connect(exportLibraryDialog,SIGNAL(exportPath(QString)),this,SLOT(exportLibrary(QString))); connect(exportLibraryDialog,SIGNAL(exportPath(QString)),this,SLOT(exportLibrary(QString)));
@ -601,8 +604,12 @@ void LibraryWindow::loadLibrary(const QString & name)
{ {
QString path=libraries.value(name)+"/.yacreaderlibrary"; QString path=libraries.value(name)+"/.yacreaderlibrary";
QDir d; //TODO change this by static methods (utils class?? with delTree for example) QDir d; //TODO change this by static methods (utils class?? with delTree for example)
if(d.exists(path)) QString dbVersion;
if(d.exists(path) && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "")
{ {
int comparation;
if((comparation = DataBaseManagement::compareVersions(dbVersion,VERSION)) == 0)
{
index = 0; index = 0;
sm->clear(); sm->clear();
//foldersView->setModel(NULL); //TODO comprobar pq no sirve con usar simplemente las señales beforeReset y reset //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); //includeComicsCheckBox->setCheckState(Qt::Unchecked);
foldersFilter->clear(); 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 else
{ {
@ -831,6 +868,11 @@ void LibraryWindow::create(QString source, QString dest, QString name)
} }
void LibraryWindow::reloadCurrentLibrary()
{
loadLibrary(selectedLibrary->currentText());
}
void LibraryWindow::openLastCreated() void LibraryWindow::openLastCreated()
{ {
@ -854,9 +896,16 @@ void LibraryWindow::showAddLibrary()
void LibraryWindow::openLibrary(QString path, QString name) void LibraryWindow::openLibrary(QString path, QString name)
{ {
_lastAdded = name; path.remove("/.yacreaderlibrary");
_sourceLastAdded = path; QDir d; //TODO change this by static methods (utils class?? with delTree for example)
openLastCreated(); 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() void LibraryWindow::loadLibraries()
@ -903,13 +952,12 @@ void LibraryWindow::saveLibraries()
void LibraryWindow::updateLibrary() void LibraryWindow::updateLibrary()
{ {
updateLibraryDialog->show();
QString currentLibrary = selectedLibrary->currentText(); QString currentLibrary = selectedLibrary->currentText();
QString path = libraries.value(currentLibrary); QString path = libraries.value(currentLibrary);
_lastAdded = currentLibrary; _lastAdded = currentLibrary;
updateLibraryDialog->show();
libraryCreator->updateLibrary(path,path+"/.yacreaderlibrary"); libraryCreator->updateLibrary(path,path+"/.yacreaderlibrary");
libraryCreator->start(); libraryCreator->start();
} }
void LibraryWindow::deleteLibrary() void LibraryWindow::deleteLibrary()

View File

@ -168,6 +168,7 @@ public:
void openLibrary(QString path, QString name); void openLibrary(QString path, QString name);
void loadLibraries(); void loadLibraries();
void saveLibraries(); void saveLibraries();
void reloadCurrentLibrary();
void openLastCreated(); void openLastCreated();
void updateLibrary(); void updateLibrary();
void deleteLibrary(); void deleteLibrary();

View File

@ -6,8 +6,10 @@
#include <QFormLayout> #include <QFormLayout>
#include <QCheckBox> #include <QCheckBox>
#include <QTabWidget> #include <QTabWidget>
#include <QIntValidator>
#include "data_base_management.h" #include "data_base_management.h"
#include "library_creator.h"
PropertiesDialog::PropertiesDialog(QWidget * parent) PropertiesDialog::PropertiesDialog(QWidget * parent)
:QDialog(parent) :QDialog(parent)
@ -88,7 +90,7 @@ void PropertiesDialog::createCoverBox()
QFrame * createLine() QFrame * createLine()
{ {
QFrame * line = new QFrame(); QFrame * line = new QFrame();
line->setObjectName(QString::fromUtf8("line")); line->setObjectName(QString::fromUtf8("line"));
//line->setGeometry(QRect(320, 150, 118, 3)); //line->setGeometry(QRect(320, 150, 118, 3));
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
@ -103,20 +105,20 @@ void PropertiesDialog::createGeneralInfoBox()
QFormLayout *generalInfoLayout = new QFormLayout; QFormLayout *generalInfoLayout = new QFormLayout;
//generalInfoLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); //generalInfoLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
generalInfoLayout->addRow(tr("Title:"), title = new YACReaderFieldEdit()); generalInfoLayout->addRow(tr("Title:"), title = new YACReaderFieldEdit());
QHBoxLayout * number = new QHBoxLayout; QHBoxLayout * number = new QHBoxLayout;
number->addWidget(numberEdit = new YACReaderFieldEdit()); number->addWidget(numberEdit = new YACReaderFieldEdit());
numberValidator.setBottom(0);
numberEdit->setValidator(&numberValidator);
number->addWidget(new QLabel("Bis:")); number->addWidget(new QLabel("Bis:"));
number->addWidget(isBisCheck = new QCheckBox()); number->addWidget(isBisCheck = new QCheckBox());
number->addWidget(new QLabel("of:")); number->addWidget(new QLabel("of:"));
number->addWidget(countEdit = new YACReaderFieldEdit()); number->addWidget(countEdit = new YACReaderFieldEdit());
countValidator.setBottom(0);
countEdit->setValidator(&countValidator);
number->addStretch(1); number->addStretch(1);
/*generalInfoLayout->addRow(tr("&Issue number:"), ); /*generalInfoLayout->addRow(tr("&Issue number:"), );
generalInfoLayout->addRow(tr("&Bis:"), );*/ generalInfoLayout->addRow(tr("&Bis:"), );*/
@ -128,8 +130,12 @@ void PropertiesDialog::createGeneralInfoBox()
arc->addWidget(storyArcEdit = new YACReaderFieldEdit()); arc->addWidget(storyArcEdit = new YACReaderFieldEdit());
arc->addWidget(new QLabel("Arc number:")); arc->addWidget(new QLabel("Arc number:"));
arc->addWidget(arcNumberEdit = new YACReaderFieldEdit()); arc->addWidget(arcNumberEdit = new YACReaderFieldEdit());
arcNumberValidator.setBottom(0);
arcNumberEdit->setValidator(&arcNumberValidator);
arc->addWidget(new QLabel("of:")); arc->addWidget(new QLabel("of:"));
arc->addWidget(arcCountEdit = new YACReaderFieldEdit()); arc->addWidget(arcCountEdit = new YACReaderFieldEdit());
arcCountValidator.setBottom(0);
arcCountEdit->setValidator(&arcCountValidator);
arc->addStretch(1); arc->addStretch(1);
generalInfoLayout->addRow(tr("Story arc:"), arc); generalInfoLayout->addRow(tr("Story arc:"), arc);
@ -200,10 +206,16 @@ void PropertiesDialog::createPublishingBox()
QHBoxLayout * date = new QHBoxLayout; QHBoxLayout * date = new QHBoxLayout;
date->addWidget(new QLabel(tr("Day:"))); date->addWidget(new QLabel(tr("Day:")));
date->addWidget(dayEdit = new YACReaderFieldEdit()); date->addWidget(dayEdit = new YACReaderFieldEdit());
dayValidator.setRange(1,31);
dayEdit->setValidator(&dayValidator);
date->addWidget(new QLabel(tr("Month:"))); date->addWidget(new QLabel(tr("Month:")));
date->addWidget(monthEdit = new YACReaderFieldEdit()); date->addWidget(monthEdit = new YACReaderFieldEdit());
monthValidator.setRange(1,12);
monthEdit->setValidator(&monthValidator);
date->addWidget(new QLabel(tr("Year:"))); date->addWidget(new QLabel(tr("Year:")));
date->addWidget(yearEdit = new YACReaderFieldEdit()); date->addWidget(yearEdit = new YACReaderFieldEdit());
yearValidator.setRange(1,9999);
yearEdit->setValidator(&yearValidator);
date->addStretch(1); date->addStretch(1);
publishingLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); publishingLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
@ -256,7 +268,11 @@ void PropertiesDialog::setComics(QList<Comic> comics)
title->setText(*comic.info.title); title->setText(*comic.info.title);
if(comic.info.coverPage != NULL) if(comic.info.coverPage != NULL)
{
coverPageEdit->setText(QString::number(*comic.info.coverPage)); coverPageEdit->setText(QString::number(*comic.info.coverPage));
coverPageValidator.setRange(1,*comic.info.numPages);
coverPageEdit->setValidator(&coverPageValidator);
}
/*if(comic.info.numPages != NULL) /*if(comic.info.numPages != NULL)
numPagesEdit->setText(QString::number(*comic.info.numPages));*/ numPagesEdit->setText(QString::number(*comic.info.numPages));*/
@ -293,6 +309,8 @@ void PropertiesDialog::setComics(QList<Comic> comics)
if(comic.info.coverArtist != NULL) if(comic.info.coverArtist != NULL)
coverArtist->setPlainText(*comic.info.coverArtist); 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) if(comic.info.date != NULL)
{ {
QStringList date = (*comic.info.date).split("/"); QStringList date = (*comic.info.date).split("/");
@ -478,7 +496,7 @@ void PropertiesDialog::save()
} }
if(comics.size()==1) 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()); itr->info.setCoverPage(coverPageEdit->text().toInt());
edited = true; edited = true;
@ -609,6 +627,14 @@ void PropertiesDialog::save()
itr->info.edited = edited; itr->info.edited = edited;
} }
updateComics(); 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(); close();
emit(accepted()); emit(accepted());
} }

View File

@ -10,6 +10,7 @@
#include <QGridLayout> #include <QGridLayout>
#include <QTabWidget> #include <QTabWidget>
#include <QCheckBox> #include <QCheckBox>
#include <QIntValidator>
#include "comic.h" #include "comic.h"
#include "custom_widgets.h" #include "custom_widgets.h"
@ -32,15 +33,20 @@
QLabel * size; QLabel * size;
YACReaderFieldEdit * coverPageEdit; YACReaderFieldEdit * coverPageEdit;
QIntValidator coverPageValidator;
YACReaderFieldEdit * numberEdit; YACReaderFieldEdit * numberEdit;
QIntValidator numberValidator;
QCheckBox * isBisCheck; QCheckBox * isBisCheck;
YACReaderFieldEdit * countEdit; YACReaderFieldEdit * countEdit;
QIntValidator countValidator;
YACReaderFieldEdit * volumeEdit; YACReaderFieldEdit * volumeEdit;
YACReaderFieldEdit * storyArcEdit; YACReaderFieldEdit * storyArcEdit;
YACReaderFieldEdit * arcNumberEdit; YACReaderFieldEdit * arcNumberEdit;
QIntValidator arcNumberValidator;
YACReaderFieldEdit * arcCountEdit; YACReaderFieldEdit * arcCountEdit;
QIntValidator arcCountValidator;
YACReaderFieldEdit * genereEdit; YACReaderFieldEdit * genereEdit;
@ -52,8 +58,11 @@
YACReaderFieldPlainTextEdit * coverArtist; YACReaderFieldPlainTextEdit * coverArtist;
YACReaderFieldEdit * dayEdit; YACReaderFieldEdit * dayEdit;
QIntValidator dayValidator;
YACReaderFieldEdit * monthEdit; YACReaderFieldEdit * monthEdit;
QIntValidator monthValidator;
YACReaderFieldEdit * yearEdit; YACReaderFieldEdit * yearEdit;
QIntValidator yearValidator;
YACReaderFieldEdit * publisherEdit; YACReaderFieldEdit * publisherEdit;
YACReaderFieldEdit * formatEdit; YACReaderFieldEdit * formatEdit;
QCheckBox * colorCheck; QCheckBox * colorCheck;

View File

@ -4,7 +4,6 @@
#include <QtGlobal> #include <QtGlobal>
#include <QStringList> #include <QStringList>
#define VERSION "5.0"
#define PREVIOUS_VERSION "0.4.5" #define PREVIOUS_VERSION "0.4.5"
HttpVersionChecker::HttpVersionChecker() HttpVersionChecker::HttpVersionChecker()

View File

@ -6,6 +6,8 @@
#include <QHttpResponseHeader> #include <QHttpResponseHeader>
#include <QByteArray> #include <QByteArray>
#define VERSION "5.0.0"
class HttpVersionChecker : public QWidget class HttpVersionChecker : public QWidget
{ {
Q_OBJECT Q_OBJECT