mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
a?adido indicador de "loading" a los di?logos que procesan
a?adido el codigo adecuado para relaizar los imports (falta incluir las opciones) comprobado que si se elimina la conexi?n a la BD despu?s del primer load, se puede manipular el archivo library.ydb
This commit is contained in:
parent
d8a78b6df4
commit
0b1b3df8b2
@ -47,9 +47,13 @@ void CreateLibraryDialog::setupUI()
|
|||||||
|
|
||||||
QHBoxLayout *middleLayout = new QHBoxLayout;
|
QHBoxLayout *middleLayout = new QHBoxLayout;
|
||||||
|
|
||||||
processLabel = new QLabel("Procesing : ");
|
progressBar = new QProgressBar(this);
|
||||||
|
progressBar->setMinimum(0);
|
||||||
|
progressBar->setMaximum(0);
|
||||||
|
progressBar->setTextVisible(false);
|
||||||
|
progressBar->hide();
|
||||||
|
|
||||||
currentFileLabel = new QLabel("");
|
currentFileLabel = new QLabel("");
|
||||||
middleLayout->addWidget(processLabel);
|
|
||||||
middleLayout->addWidget(currentFileLabel);
|
middleLayout->addWidget(currentFileLabel);
|
||||||
middleLayout->addStretch();
|
middleLayout->addStretch();
|
||||||
|
|
||||||
@ -63,6 +67,7 @@ void CreateLibraryDialog::setupUI()
|
|||||||
mainLayout->addLayout(libraryLayout);
|
mainLayout->addLayout(libraryLayout);
|
||||||
mainLayout->addLayout(middleLayout);
|
mainLayout->addLayout(middleLayout);
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
mainLayout->addWidget(progressBar);
|
||||||
mainLayout->addLayout(bottomLayout);
|
mainLayout->addLayout(bottomLayout);
|
||||||
|
|
||||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||||
@ -80,6 +85,7 @@ void CreateLibraryDialog::setupUI()
|
|||||||
|
|
||||||
void CreateLibraryDialog::create()
|
void CreateLibraryDialog::create()
|
||||||
{
|
{
|
||||||
|
progressBar->show();
|
||||||
accept->setEnabled(false);
|
accept->setEnabled(false);
|
||||||
emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
|
emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
|
||||||
}
|
}
|
||||||
@ -102,6 +108,7 @@ void CreateLibraryDialog::showCurrentFile(QString file)
|
|||||||
}
|
}
|
||||||
void CreateLibraryDialog::close()
|
void CreateLibraryDialog::close()
|
||||||
{
|
{
|
||||||
|
progressBar->hide();
|
||||||
path->clear();
|
path->clear();
|
||||||
nameEdit->clear();
|
nameEdit->clear();
|
||||||
currentFileLabel->setText("");
|
currentFileLabel->setText("");
|
||||||
@ -126,6 +133,13 @@ UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
|
|||||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||||
|
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
|
progressBar = new QProgressBar(this);
|
||||||
|
progressBar->setMinimum(0);
|
||||||
|
progressBar->setMaximum(0);
|
||||||
|
progressBar->setTextVisible(false);
|
||||||
|
|
||||||
|
mainLayout->addWidget(progressBar);
|
||||||
mainLayout->addLayout(bottom);
|
mainLayout->addLayout(bottom);
|
||||||
|
|
||||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
class CreateLibraryDialog : public QDialog
|
class CreateLibraryDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -15,7 +16,7 @@
|
|||||||
private:
|
private:
|
||||||
QLabel * nameLabel;
|
QLabel * nameLabel;
|
||||||
QLabel * textLabel;
|
QLabel * textLabel;
|
||||||
QLabel * processLabel;
|
QProgressBar *progressBar;
|
||||||
QLabel * currentFileLabel;
|
QLabel * currentFileLabel;
|
||||||
QLineEdit * path;
|
QLineEdit * path;
|
||||||
QLineEdit * nameEdit;
|
QLineEdit * nameEdit;
|
||||||
@ -41,6 +42,7 @@
|
|||||||
private:
|
private:
|
||||||
QLabel * message;
|
QLabel * message;
|
||||||
QLabel * currentFileLabel;
|
QLabel * currentFileLabel;
|
||||||
|
QProgressBar *progressBar;
|
||||||
QPushButton * cancel;
|
QPushButton * cancel;
|
||||||
public slots:
|
public slots:
|
||||||
void showCurrentFile(QString file);
|
void showCurrentFile(QString file);
|
||||||
|
@ -2,13 +2,48 @@
|
|||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
|
static QString fields = "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,"
|
||||||
|
|
||||||
|
"hash";
|
||||||
|
|
||||||
DataBaseManagement::DataBaseManagement()
|
DataBaseManagement::DataBaseManagement()
|
||||||
:QObject(),dataBasesList()
|
:QObject(),dataBasesList()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeModel * DataBaseManagement::newTreeModel(QString path)
|
/*TreeModel * DataBaseManagement::newTreeModel(QString path)
|
||||||
{
|
{
|
||||||
//la consulta se ejecuta...
|
//la consulta se ejecuta...
|
||||||
QSqlQuery selectQuery(loadDatabase(path));
|
QSqlQuery selectQuery(loadDatabase(path));
|
||||||
@ -16,7 +51,7 @@ TreeModel * DataBaseManagement::newTreeModel(QString path)
|
|||||||
selectQuery.exec("select * from folder order by parentId,name");
|
selectQuery.exec("select * from folder order by parentId,name");
|
||||||
//selectQuery.finish();
|
//selectQuery.finish();
|
||||||
return new TreeModel(selectQuery);
|
return new TreeModel(selectQuery);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
QSqlDatabase DataBaseManagement::createDatabase(QString name, QString path)
|
QSqlDatabase DataBaseManagement::createDatabase(QString name, QString path)
|
||||||
{
|
{
|
||||||
@ -32,12 +67,15 @@ QSqlDatabase DataBaseManagement::createDatabase(QString dest)
|
|||||||
else {
|
else {
|
||||||
qDebug() << db.tables();
|
qDebug() << db.tables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
|
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
|
||||||
//pragma.finish();
|
//pragma.finish();
|
||||||
DataBaseManagement::createTables(db);
|
DataBaseManagement::createTables(db);
|
||||||
|
|
||||||
QSqlQuery query("INSERT INTO folder (parentId, name, path) "
|
QSqlQuery query("INSERT INTO folder (parentId, name, path) "
|
||||||
"VALUES (1,'root', '/')",db);
|
"VALUES (1,'root', '/')",db);
|
||||||
|
}
|
||||||
//query.finish();
|
//query.finish();
|
||||||
//db.close();
|
//db.close();
|
||||||
|
|
||||||
@ -60,11 +98,30 @@ QSqlDatabase DataBaseManagement::loadDatabase(QString path)
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSqlDatabase DataBaseManagement::loadDatabaseFromFile(QString filePath)
|
||||||
|
{
|
||||||
|
//TODO check path
|
||||||
|
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",filePath);
|
||||||
|
db.setDatabaseName(filePath);
|
||||||
|
if (!db.open()) {
|
||||||
|
//se devuelve una base de datos vacía e inválida
|
||||||
|
|
||||||
|
return QSqlDatabase();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
|
||||||
|
}
|
||||||
|
//pragma.finish();
|
||||||
|
//devuelve la base de datos
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
bool DataBaseManagement::createTables(QSqlDatabase & database)
|
bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
//FOLDER (representa una carpeta en disco)
|
//FOLDER (representa una carpeta en disco)
|
||||||
|
{
|
||||||
QSqlQuery queryFolder(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)");
|
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();
|
success = success && queryFolder.exec();
|
||||||
@ -106,9 +163,9 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
|||||||
"characters TEXT,"
|
"characters TEXT,"
|
||||||
"notes TEXT,"
|
"notes TEXT,"
|
||||||
|
|
||||||
"hash TEXT NOT NULL,"
|
"hash TEXT UNIQUE NOT NULL,"
|
||||||
"edited BOOLEAN DEFAULT 0,"
|
"edited BOOLEAN DEFAULT 0,"
|
||||||
"read BOOLEAN)");
|
"read BOOLEAN DEFAULT 0)");
|
||||||
success = success && queryComicInfo.exec();
|
success = success && queryComicInfo.exec();
|
||||||
//queryComicInfo.finish();
|
//queryComicInfo.finish();
|
||||||
|
|
||||||
@ -126,32 +183,30 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
|||||||
QSqlQuery query("INSERT INTO db_info (version) "
|
QSqlQuery query("INSERT INTO db_info (version) "
|
||||||
"VALUES ('5.0.0')",database);
|
"VALUES ('5.0.0')",database);
|
||||||
//query.finish();
|
//query.finish();
|
||||||
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
#include <qmessagebox.h>
|
||||||
void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||||
{
|
{
|
||||||
QSqlDatabase sourceDB = loadDatabase(source);
|
//QSqlDatabase sourceDB = loadDatabase(source);
|
||||||
QSqlDatabase destDB = QSqlDatabase::addDatabase("QSQLITE");
|
QSqlDatabase destDB = loadDatabaseFromFile(dest);
|
||||||
destDB.setDatabaseName(dest);
|
//sourceDB.open();
|
||||||
destDB.open();
|
{
|
||||||
sourceDB.open();
|
QSqlQuery attach(destDB);
|
||||||
|
|
||||||
QSqlQuery attach(sourceDB);
|
|
||||||
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
||||||
//attach.bindValue(":dest",QDir().toNativeSeparators(dest));
|
//attach.bindValue(":dest",QDir().toNativeSeparators(dest));
|
||||||
attach.exec();
|
attach.exec();
|
||||||
//attach.finish();
|
//attach.finish();
|
||||||
|
|
||||||
QSqlQuery attach2(sourceDB);
|
QSqlQuery attach2(destDB);
|
||||||
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
||||||
attach2.exec();
|
attach2.exec();
|
||||||
//attach2.finish();
|
//attach2.finish();
|
||||||
|
|
||||||
//sourceDB.close();
|
//sourceDB.close();
|
||||||
QSqlQuery queryDBInfo(sourceDB);
|
QSqlQuery queryDBInfo(destDB);
|
||||||
queryDBInfo.prepare("CREATE TABLE dest.db_info (version TEXT NOT NULL)");
|
queryDBInfo.prepare("CREATE TABLE dest.db_info (version TEXT NOT NULL)");
|
||||||
queryDBInfo.exec();
|
queryDBInfo.exec();
|
||||||
//queryDBInfo.finish();
|
//queryDBInfo.finish();
|
||||||
@ -161,22 +216,22 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
|||||||
queryComicsInfo.exec();*/
|
queryComicsInfo.exec();*/
|
||||||
|
|
||||||
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
||||||
"VALUES ('5.0.0')",sourceDB);
|
"VALUES ('5.0.0')",destDB);
|
||||||
//query.finish();
|
//query.finish();
|
||||||
|
|
||||||
QSqlQuery exportData(sourceDB);
|
QSqlQuery exportData(destDB);
|
||||||
exportData.prepare("create table dest.comic_info as select * from source.comic_info where source.comic_info.edited = 1");
|
exportData.prepare("create table dest.comic_info as select " + fields +
|
||||||
|
" from source.comic_info where source.comic_info.edited = 1");
|
||||||
exportData.exec();
|
exportData.exec();
|
||||||
//exportData.finish();
|
//exportData.finish();
|
||||||
|
}
|
||||||
|
|
||||||
QString error = exportData.lastError().databaseText();
|
//sourceDB.close();
|
||||||
QString error2 = exportData.lastError().text();
|
|
||||||
|
|
||||||
sourceDB.close();
|
|
||||||
destDB.close();
|
destDB.close();
|
||||||
|
QSqlDatabase::removeDatabase(dest);
|
||||||
|
|
||||||
}
|
}
|
||||||
#include <qmessagebox.h>
|
|
||||||
bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
@ -184,44 +239,254 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
|||||||
|
|
||||||
bool b = false;
|
bool b = false;
|
||||||
|
|
||||||
QSqlDatabase destDB = QSqlDatabase::addDatabase("QSQLITE",dest);
|
QSqlDatabase sourceDB = loadDatabaseFromFile(source);
|
||||||
destDB.setDatabaseName(dest);
|
QSqlDatabase destDB = loadDatabaseFromFile(dest);
|
||||||
if(destDB.open())
|
|
||||||
{
|
|
||||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",destDB);
|
|
||||||
|
|
||||||
QSqlQuery attach(destDB);
|
QSqlQuery pragma("PRAGMA synchronous=OFF",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();
|
//QSqlQuery attach(destDB);
|
||||||
driver = attach2.lastError().driverText();
|
//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"),error);
|
||||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
//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...
|
//TODO check versions...
|
||||||
|
//QSqlQuery update(destDB);
|
||||||
|
//update.prepare("UPDATE dest.comic_info"
|
||||||
|
// "SET"
|
||||||
|
//"title = coalesce(title , (select source.comic_info.title from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"coverPage = coalesce(coverPage , (select source.comic_info.coverPage from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"numPages = coalesce(numPages , (select source.comic_info.numPages from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"number = coalesce(number , (select source.comic_info.number from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"isBis = coalesce(isBis , (select source.comic_info.isBis from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"count = coalesce(count , (select source.comic_info.count from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"volume = coalesce(volume , (select source.comic_info.volume from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"storyArc = coalesce(storyArc , (select source.comic_info.storyArc from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"arcNumber = coalesce(arcNumber , (select source.comic_info.arcNumber from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"arcCount = coalesce(arcCount , (select source.comic_info.arcCount from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"genere = coalesce(genere , (select source.comic_info.genere from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"writer = coalesce(writer , (select source.comic_info.writer from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"penciller = coalesce(penciller , (select source.comic_info.penciller from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"inker = coalesce(inker , (select source.comic_info.inker from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"colorist = coalesce(colorist , (select source.comic_info.colorist from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"letterer = coalesce(letterer , (select source.comic_info.letterer from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"coverArtist = coalesce(coverArtist , (select source.comic_info.coverArtist from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"date = coalesce(date , (select source.comic_info.date from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"publisher = coalesce(publisher , (select source.comic_info.publisher from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"format = coalesce(format , (select source.comic_info.format from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"color = coalesce(color , (select source.comic_info.color from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"ageRating = coalesce(ageRating , (select source.comic_info.ageRating from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"synopsis = coalesce(synopsis , (select source.comic_info.synopsis from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"characters = coalesce(characters , (select source.comic_info.characters from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"notes = coalesce(notes , (select source.comic_info.notes from source.comic_info where dest.comic_info.hash = source.comic_info.hash)),"
|
||||||
|
//"edited = 1"
|
||||||
|
// );
|
||||||
|
//b = b || update.exec();
|
||||||
|
|
||||||
QSqlQuery import(destDB);
|
//error = update.lastError().databaseText();
|
||||||
import.prepare("insert or replace into dest.comic_info select * from source.comic_info;");
|
//driver = update.lastError().driverText();
|
||||||
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"),error);
|
||||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
//QMessageBox::critical(NULL,tr("db error"),driver);
|
||||||
|
|
||||||
destDB.close();
|
//QSqlQuery import(destDB);
|
||||||
|
//import.prepare("insert or ignore into dest.comic_info (" +fields + ",edited,read) select " + fields + ",1 as edited, 0 as read from source.comic_info;");
|
||||||
|
////import.prepare("insert into dest.comic_info (" +fields + ",edited,read) select " + fields + ",1 as edited, 0 as read from source.comic_info where sourc.comic_info.hash not in (select dest.comic_info.hash from dest.comic_info);");
|
||||||
|
//b = 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);
|
||||||
|
|
||||||
|
QSqlQuery update(destDB);
|
||||||
|
update.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,"
|
||||||
|
|
||||||
|
"edited = :edited"
|
||||||
|
|
||||||
|
" WHERE hash = :hash ");
|
||||||
|
|
||||||
|
QSqlQuery insert(destDB);
|
||||||
|
insert.prepare("INSERT INTO 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,"
|
||||||
|
|
||||||
|
"hash = :hash ");
|
||||||
|
QSqlQuery newInfo(sourceDB);
|
||||||
|
newInfo.prepare("SELECT * FROM comic_info");
|
||||||
|
newInfo.exec();
|
||||||
|
destDB.transaction();
|
||||||
|
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());
|
||||||
|
|
||||||
|
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(":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());
|
||||||
|
|
||||||
|
insert.bindValue(":edited",1);
|
||||||
|
insert.bindValue(":read",0);
|
||||||
|
|
||||||
|
insert.bindValue(":hash",record.value("hash").toString());
|
||||||
|
insert.exec();
|
||||||
|
}
|
||||||
|
update.finish();
|
||||||
|
insert.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destDB.commit();
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,13 @@ private:
|
|||||||
QList<QString> dataBasesList;
|
QList<QString> dataBasesList;
|
||||||
public:
|
public:
|
||||||
DataBaseManagement();
|
DataBaseManagement();
|
||||||
TreeModel * newTreeModel(QString path);
|
//TreeModel * newTreeModel(QString path);
|
||||||
//crea una base de datos y todas sus tablas
|
//crea una base de datos y todas sus tablas
|
||||||
static QSqlDatabase createDatabase(QString name, QString path);
|
static QSqlDatabase createDatabase(QString name, QString path);
|
||||||
static QSqlDatabase createDatabase(QString dest);
|
static QSqlDatabase createDatabase(QString dest);
|
||||||
//carga una base de datos desde la ruta path
|
//carga una base de datos desde la ruta path
|
||||||
static QSqlDatabase loadDatabase(QString path);
|
static QSqlDatabase loadDatabase(QString path);
|
||||||
|
static QSqlDatabase loadDatabaseFromFile(QString path);
|
||||||
static bool createTables(QSqlDatabase & database);
|
static bool createTables(QSqlDatabase & database);
|
||||||
|
|
||||||
static void exportComicsInfo(QString source, QString dest);
|
static void exportComicsInfo(QString source, QString dest);
|
||||||
|
@ -217,11 +217,14 @@ void TreeModel::setupModelData(QString path)
|
|||||||
_database.close();
|
_database.close();
|
||||||
_database = DataBaseManagement::loadDatabase(path);
|
_database = DataBaseManagement::loadDatabase(path);
|
||||||
//crear la consulta
|
//crear la consulta
|
||||||
|
{
|
||||||
QSqlQuery selectQuery("select * from folder where id <> 1 order by parentId,name",_database);
|
QSqlQuery selectQuery("select * from folder where id <> 1 order by parentId,name",_database);
|
||||||
|
|
||||||
setupModelData(selectQuery,rootItem);
|
setupModelData(selectQuery,rootItem);
|
||||||
|
}
|
||||||
//selectQuery.finish();
|
//selectQuery.finish();
|
||||||
_database.close();
|
_database.close();
|
||||||
|
QSqlDatabase::removeDatabase(path);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,16 @@ ExportLibraryDialog::ExportLibraryDialog(QWidget * parent)
|
|||||||
bottomLayout->addWidget(accept);
|
bottomLayout->addWidget(accept);
|
||||||
bottomLayout->addWidget(cancel);
|
bottomLayout->addWidget(cancel);
|
||||||
|
|
||||||
|
progressBar = new QProgressBar(this);
|
||||||
|
progressBar->setMinimum(0);
|
||||||
|
progressBar->setMaximum(0);
|
||||||
|
progressBar->setTextVisible(false);
|
||||||
|
progressBar->hide();
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(libraryLayout);
|
mainLayout->addLayout(libraryLayout);
|
||||||
mainLayout->addWidget(progress=new QLabel());
|
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
mainLayout->addWidget(progressBar);
|
||||||
mainLayout->addLayout(bottomLayout);
|
mainLayout->addLayout(bottomLayout);
|
||||||
|
|
||||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||||
@ -57,6 +63,7 @@ ExportLibraryDialog::ExportLibraryDialog(QWidget * parent)
|
|||||||
|
|
||||||
void ExportLibraryDialog::exportLibrary()
|
void ExportLibraryDialog::exportLibrary()
|
||||||
{
|
{
|
||||||
|
progressBar->show();
|
||||||
accept->setEnabled(false);
|
accept->setEnabled(false);
|
||||||
emit exportPath(QDir::cleanPath(path->text()));
|
emit exportPath(QDir::cleanPath(path->text()));
|
||||||
t.start();
|
t.start();
|
||||||
@ -75,10 +82,10 @@ void ExportLibraryDialog::findPath()
|
|||||||
void ExportLibraryDialog::close()
|
void ExportLibraryDialog::close()
|
||||||
{
|
{
|
||||||
path->clear();
|
path->clear();
|
||||||
|
progressBar->hide();
|
||||||
accept->setEnabled(false);
|
accept->setEnabled(false);
|
||||||
t.stop();
|
t.stop();
|
||||||
progressCount=0;
|
progressCount=0;
|
||||||
progress->setText("");
|
|
||||||
QDialog::close();
|
QDialog::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,14 +94,3 @@ void ExportLibraryDialog::run()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportLibraryDialog::updateProgress()
|
|
||||||
{
|
|
||||||
if(progressCount == 0)
|
|
||||||
progress->setText(tr("Creating package ."));
|
|
||||||
else
|
|
||||||
progress->setText(progress->text()+" .");
|
|
||||||
progressCount++;
|
|
||||||
if(progressCount == 15)
|
|
||||||
progressCount = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
class ExportLibraryDialog : public QDialog
|
class ExportLibraryDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -18,10 +19,9 @@ public slots:
|
|||||||
void exportLibrary();
|
void exportLibrary();
|
||||||
void findPath();
|
void findPath();
|
||||||
void close();
|
void close();
|
||||||
void updateProgress();
|
|
||||||
private:
|
private:
|
||||||
int progressCount;
|
int progressCount;
|
||||||
QLabel * progress;
|
QProgressBar *progressBar;
|
||||||
QLabel * textLabel;
|
QLabel * textLabel;
|
||||||
QLineEdit * path;
|
QLineEdit * path;
|
||||||
QPushButton * find;
|
QPushButton * find;
|
||||||
|
@ -66,12 +66,19 @@ void ImportLibraryDialog::setupUI()
|
|||||||
bottomLayout->addWidget(accept);
|
bottomLayout->addWidget(accept);
|
||||||
bottomLayout->addWidget(cancel);
|
bottomLayout->addWidget(cancel);
|
||||||
|
|
||||||
|
progressBar = new QProgressBar(this);
|
||||||
|
progressBar->setMinimum(0);
|
||||||
|
progressBar->setMaximum(0);
|
||||||
|
progressBar->setTextVisible(false);
|
||||||
|
progressBar->hide();
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(nameLayout);
|
mainLayout->addLayout(nameLayout);
|
||||||
mainLayout->addLayout(libraryLayout);
|
mainLayout->addLayout(libraryLayout);
|
||||||
mainLayout->addLayout(destLayout);
|
mainLayout->addLayout(destLayout);
|
||||||
mainLayout->addWidget(progress = new QLabel());
|
//mainLayout->addWidget(progress = new QLabel());
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
mainLayout->addWidget(progressBar);
|
||||||
mainLayout->addLayout(bottomLayout);
|
mainLayout->addLayout(bottomLayout);
|
||||||
|
|
||||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||||
@ -85,16 +92,12 @@ void ImportLibraryDialog::setupUI()
|
|||||||
|
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setWindowTitle(tr("Extract a catalog"));
|
setWindowTitle(tr("Extract a catalog"));
|
||||||
|
|
||||||
t.setInterval(500);
|
|
||||||
t.stop();
|
|
||||||
connect(&t,SIGNAL(timeout()),this,SLOT(updateProgress()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportLibraryDialog::add()
|
void ImportLibraryDialog::add()
|
||||||
{
|
{
|
||||||
accept->setEnabled(false);
|
accept->setEnabled(false);
|
||||||
t.start();
|
progressBar->show();
|
||||||
emit(unpackCLC(QDir::cleanPath(path->text()),QDir::cleanPath(destPath->text()),nameEdit->text()));
|
emit(unpackCLC(QDir::cleanPath(path->text()),QDir::cleanPath(destPath->text()),nameEdit->text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,26 +141,10 @@ void ImportLibraryDialog::close()
|
|||||||
destPath->clear();
|
destPath->clear();
|
||||||
nameEdit->clear();
|
nameEdit->clear();
|
||||||
accept->setEnabled(false);
|
accept->setEnabled(false);
|
||||||
if(t.isActive())
|
progressBar->hide();
|
||||||
{
|
|
||||||
t.stop();
|
|
||||||
emit rejected();
|
|
||||||
}
|
|
||||||
progress->setText("");
|
|
||||||
QDialog::hide();
|
QDialog::hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportLibraryDialog::updateProgress()
|
|
||||||
{
|
|
||||||
if(progressCount == 0)
|
|
||||||
progress->setText(tr("Importing package ."));
|
|
||||||
else
|
|
||||||
progress->setText(progress->text()+" .");
|
|
||||||
progressCount++;
|
|
||||||
if(progressCount == 15)
|
|
||||||
progressCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImportLibraryDialog::closeEvent ( QCloseEvent * e )
|
void ImportLibraryDialog::closeEvent ( QCloseEvent * e )
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QProgressBar>
|
||||||
|
|
||||||
class ImportLibraryDialog : public QDialog
|
class ImportLibraryDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -25,9 +25,8 @@
|
|||||||
QPushButton * findDest;
|
QPushButton * findDest;
|
||||||
QPushButton * accept;
|
QPushButton * accept;
|
||||||
QPushButton * cancel;
|
QPushButton * cancel;
|
||||||
QLabel * progress;
|
QProgressBar *progressBar;
|
||||||
void setupUI();
|
void setupUI();
|
||||||
QTimer t;
|
|
||||||
int progressCount;
|
int progressCount;
|
||||||
void closeEvent ( QCloseEvent * e );
|
void closeEvent ( QCloseEvent * e );
|
||||||
public slots:
|
public slots:
|
||||||
@ -35,7 +34,6 @@
|
|||||||
void findPath();
|
void findPath();
|
||||||
void findDestination();
|
void findDestination();
|
||||||
void close();
|
void close();
|
||||||
void updateProgress();
|
|
||||||
void nameEntered();
|
void nameEntered();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -881,8 +881,10 @@ void LibraryWindow::deleteLibrary()
|
|||||||
|
|
||||||
void LibraryWindow::deleteCurrentLibrary()
|
void LibraryWindow::deleteCurrentLibrary()
|
||||||
{
|
{
|
||||||
|
QSqlDatabase db = dm->getDatabase();
|
||||||
dm->getDatabase().close();
|
db.commit();
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(db.connectionName());
|
||||||
if(!dm->getDatabase().isOpen())
|
if(!dm->getDatabase().isOpen())
|
||||||
{
|
{
|
||||||
QString path = libraries.value(selectedLibrary->currentText());
|
QString path = libraries.value(selectedLibrary->currentText());
|
||||||
|
@ -95,13 +95,13 @@
|
|||||||
public slots:
|
public slots:
|
||||||
void setComics(QList<Comic> comics);
|
void setComics(QList<Comic> comics);
|
||||||
void updateComics();
|
void updateComics();
|
||||||
|
void save();
|
||||||
//Deprecated
|
//Deprecated
|
||||||
void setCover(const QPixmap & cover);
|
void setCover(const QPixmap & cover);
|
||||||
void setFilename(const QString & name);
|
void setFilename(const QString & name);
|
||||||
void setNumpages(int pages);
|
void setNumpages(int pages);
|
||||||
void setSize(float size);
|
void setSize(float size);
|
||||||
void save();
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user