mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
comprobaciones de versi?n de la DB implementadas.
Versi?n 5.0 RC1.
This commit is contained in:
parent
dbfaaa2d96
commit
7692ecb2ba
@ -128,6 +128,14 @@ void CreateLibraryDialog::close()
|
|||||||
accept->setEnabled(true);
|
accept->setEnabled(true);
|
||||||
QDialog::close();
|
QDialog::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateLibraryDialog::setDataAndStart(QString name, QString path)
|
||||||
|
{
|
||||||
|
this->path->setText(path);
|
||||||
|
this->nameEdit->setText(name);
|
||||||
|
show();
|
||||||
|
create();
|
||||||
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// UpdateLibraryDialog
|
// UpdateLibraryDialog
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
void findPath();
|
void findPath();
|
||||||
void showCurrentFile(QString file);
|
void showCurrentFile(QString file);
|
||||||
void close();
|
void close();
|
||||||
|
void setDataAndStart(QString name, QString paht);
|
||||||
signals:
|
signals:
|
||||||
void createLibrary(QString source, QString target, QString name);
|
void createLibrary(QString source, QString target, QString name);
|
||||||
void cancelCreate();
|
void cancelCreate();
|
||||||
|
@ -494,14 +494,24 @@ QString DataBaseManagement::checkValidDB(const QString & fullPath)
|
|||||||
version.exec();
|
version.exec();
|
||||||
if(version.next())
|
if(version.next())
|
||||||
{
|
{
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(fullPath);
|
||||||
return version.record().value("version").toString();
|
return version.record().value("version").toString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(fullPath);
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return "";
|
{
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(fullPath);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataBaseManagement::compareVersions(const QString & v1, const QString v2)
|
int DataBaseManagement::compareVersions(const QString & v1, const QString v2)
|
||||||
|
@ -41,8 +41,13 @@ void LibraryCreator::processLibrary(const QString & source, const QString & targ
|
|||||||
{
|
{
|
||||||
_source = source;
|
_source = source;
|
||||||
_target = target;
|
_target = target;
|
||||||
if(!(QFile(target+"/library.ydb").exists())) //TODO, no sirve sólo con realizar el update, hay que validar la base de datos y determinar si existe "/covers"
|
//if(!(QFile(target+"/library.ydb").exists())) //TODO, no sirve sólo con realizar el update, hay que validar la base de datos y determinar si existe "/covers"
|
||||||
|
if(DataBaseManagement::checkValidDB(target+"/library.ydb")=="")
|
||||||
|
{
|
||||||
|
//se limpia el directorio ./yacreaderlibrary
|
||||||
|
delTree(target);
|
||||||
_mode = CREATOR;
|
_mode = CREATOR;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_mode = UPDATER;
|
_mode = UPDATER;
|
||||||
}
|
}
|
||||||
|
@ -600,43 +600,43 @@ void LibraryWindow::createConnections()
|
|||||||
|
|
||||||
void LibraryWindow::loadLibrary(const QString & name)
|
void LibraryWindow::loadLibrary(const QString & name)
|
||||||
{
|
{
|
||||||
if(libraries.size()>0)
|
if(libraries.size()>0) //si hay bibliotecas...
|
||||||
{
|
{
|
||||||
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)
|
||||||
QString dbVersion;
|
QString dbVersion;
|
||||||
if(d.exists(path) && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "")
|
if(d.exists(path) && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "") //si existe en disco la biblioteca seleccionada, y es válida..
|
||||||
{
|
{
|
||||||
int comparation;
|
int comparation;
|
||||||
if((comparation = DataBaseManagement::compareVersions(dbVersion,VERSION)) == 0)
|
if((comparation = DataBaseManagement::compareVersions(dbVersion,VERSION)) == 0) //en caso de que la versión se igual que la actual
|
||||||
{
|
{
|
||||||
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
|
||||||
//comicView->setModel(NULL);
|
//comicView->setModel(NULL);
|
||||||
|
|
||||||
dm->setupModelData(path);
|
dm->setupModelData(path);
|
||||||
foldersView->setModel(dm);
|
foldersView->setModel(dm);
|
||||||
|
|
||||||
d.setCurrent(libraries.value(name));
|
|
||||||
d.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
|
||||||
if(d.count()<=1) //librería de sólo lectura
|
|
||||||
{
|
|
||||||
//QMessageBox::critical(NULL,QString::number(d.count()),QString::number(d.count()));
|
|
||||||
disableActions();
|
|
||||||
importedCovers = true;
|
|
||||||
}
|
|
||||||
else //librería normal abierta
|
|
||||||
{
|
|
||||||
enableActions();
|
|
||||||
importedCovers = false;
|
|
||||||
}
|
|
||||||
enableLibraryActions();
|
|
||||||
|
|
||||||
loadCovers(QModelIndex());
|
d.setCurrent(libraries.value(name));
|
||||||
|
d.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
|
if(d.count()<=1) //librería de sólo lectura
|
||||||
|
{
|
||||||
|
//QMessageBox::critical(NULL,QString::number(d.count()),QString::number(d.count()));
|
||||||
|
disableActions();
|
||||||
|
importedCovers = true;
|
||||||
|
}
|
||||||
|
else //librería normal abierta
|
||||||
|
{
|
||||||
|
enableActions();
|
||||||
|
importedCovers = false;
|
||||||
|
}
|
||||||
|
enableLibraryActions();
|
||||||
|
|
||||||
//includeComicsCheckBox->setCheckState(Qt::Unchecked);
|
loadCovers(QModelIndex());
|
||||||
foldersFilter->clear();
|
|
||||||
|
//includeComicsCheckBox->setCheckState(Qt::Unchecked);
|
||||||
|
foldersFilter->clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -675,14 +675,31 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
comicFlow->clear();
|
comicFlow->clear();
|
||||||
disableAllActions();//TODO comprobar que se deben deshabilitar
|
disableAllActions();//TODO comprobar que se deben deshabilitar
|
||||||
|
|
||||||
QString currentLibrary = selectedLibrary->currentText();
|
//si la librería no existe en disco, se ofrece al usuario la posibiliad de eliminarla
|
||||||
if(QMessageBox::question(this,tr("Library not available"),tr("Library ")+currentLibrary+tr(" is no longer available. Do you want to remove it?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
if(!d.exists(path))
|
||||||
{
|
{
|
||||||
deleteCurrentLibrary();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
|
if(QMessageBox::question(this,tr("Library not available"),tr("Library ")+currentLibrary+tr(" is no longer available. Do you want to remove it?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
deleteCurrentLibrary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else//si existe el path, puede ser que la librería sea alguna versión pre-5.0 ó que esté corrupta
|
||||||
|
{
|
||||||
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
|
QString path = libraries.value(selectedLibrary->currentText());
|
||||||
|
if(QMessageBox::question(this,tr("Old library or corrupted"),tr("Library ")+currentLibrary+tr(" is corrupted or has been created with an older version of YACReaderLibrary. It must be created again. Do you want to create the library now?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
QDir d(path+"/.yacreaderlibrary");
|
||||||
|
delTree(d);
|
||||||
|
d.rmdir(path+"/.yacreaderlibrary");
|
||||||
|
createLibraryDialog->setDataAndStart(currentLibrary,path);
|
||||||
|
//create(path,path+"/.yacreaderlibrary",currentLibrary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else //en caso de que no exista ninguna biblioteca se desactivan los botones pertinentes
|
||||||
{
|
{
|
||||||
disableAllActions();
|
disableAllActions();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user