mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -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;
|
||||
|
||||
processLabel = new QLabel("Procesing : ");
|
||||
progressBar = new QProgressBar(this);
|
||||
progressBar->setMinimum(0);
|
||||
progressBar->setMaximum(0);
|
||||
progressBar->setTextVisible(false);
|
||||
progressBar->hide();
|
||||
|
||||
currentFileLabel = new QLabel("");
|
||||
middleLayout->addWidget(processLabel);
|
||||
middleLayout->addWidget(currentFileLabel);
|
||||
middleLayout->addStretch();
|
||||
|
||||
@ -63,6 +67,7 @@ void CreateLibraryDialog::setupUI()
|
||||
mainLayout->addLayout(libraryLayout);
|
||||
mainLayout->addLayout(middleLayout);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(progressBar);
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
@ -80,6 +85,7 @@ void CreateLibraryDialog::setupUI()
|
||||
|
||||
void CreateLibraryDialog::create()
|
||||
{
|
||||
progressBar->show();
|
||||
accept->setEnabled(false);
|
||||
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()
|
||||
{
|
||||
progressBar->hide();
|
||||
path->clear();
|
||||
nameEdit->clear();
|
||||
currentFileLabel->setText("");
|
||||
@ -126,6 +133,13 @@ UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
|
||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||
|
||||
mainLayout->addStretch();
|
||||
|
||||
progressBar = new QProgressBar(this);
|
||||
progressBar->setMinimum(0);
|
||||
progressBar->setMaximum(0);
|
||||
progressBar->setTextVisible(false);
|
||||
|
||||
mainLayout->addWidget(progressBar);
|
||||
mainLayout->addLayout(bottom);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QThread>
|
||||
#include <QProgressBar>
|
||||
|
||||
class CreateLibraryDialog : public QDialog
|
||||
{
|
||||
@ -15,7 +16,7 @@
|
||||
private:
|
||||
QLabel * nameLabel;
|
||||
QLabel * textLabel;
|
||||
QLabel * processLabel;
|
||||
QProgressBar *progressBar;
|
||||
QLabel * currentFileLabel;
|
||||
QLineEdit * path;
|
||||
QLineEdit * nameEdit;
|
||||
@ -41,6 +42,7 @@
|
||||
private:
|
||||
QLabel * message;
|
||||
QLabel * currentFileLabel;
|
||||
QProgressBar *progressBar;
|
||||
QPushButton * cancel;
|
||||
public slots:
|
||||
void showCurrentFile(QString file);
|
||||
|
@ -2,13 +2,48 @@
|
||||
|
||||
#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()
|
||||
:QObject(),dataBasesList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TreeModel * DataBaseManagement::newTreeModel(QString path)
|
||||
/*TreeModel * DataBaseManagement::newTreeModel(QString path)
|
||||
{
|
||||
//la consulta se ejecuta...
|
||||
QSqlQuery selectQuery(loadDatabase(path));
|
||||
@ -16,7 +51,7 @@ TreeModel * DataBaseManagement::newTreeModel(QString path)
|
||||
selectQuery.exec("select * from folder order by parentId,name");
|
||||
//selectQuery.finish();
|
||||
return new TreeModel(selectQuery);
|
||||
}
|
||||
}*/
|
||||
|
||||
QSqlDatabase DataBaseManagement::createDatabase(QString name, QString path)
|
||||
{
|
||||
@ -32,12 +67,15 @@ QSqlDatabase DataBaseManagement::createDatabase(QString dest)
|
||||
else {
|
||||
qDebug() << db.tables();
|
||||
}
|
||||
|
||||
{
|
||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",db);
|
||||
//pragma.finish();
|
||||
DataBaseManagement::createTables(db);
|
||||
|
||||
QSqlQuery query("INSERT INTO folder (parentId, name, path) "
|
||||
"VALUES (1,'root', '/')",db);
|
||||
}
|
||||
//query.finish();
|
||||
//db.close();
|
||||
|
||||
@ -60,11 +98,30 @@ QSqlDatabase DataBaseManagement::loadDatabase(QString path)
|
||||
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 success = true;
|
||||
|
||||
//FOLDER (representa una carpeta en disco)
|
||||
{
|
||||
QSqlQuery queryFolder(database);
|
||||
queryFolder.prepare("CREATE TABLE folder (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE)");
|
||||
success = success && queryFolder.exec();
|
||||
@ -106,9 +163,9 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
"characters TEXT,"
|
||||
"notes TEXT,"
|
||||
|
||||
"hash TEXT NOT NULL,"
|
||||
"hash TEXT UNIQUE NOT NULL,"
|
||||
"edited BOOLEAN DEFAULT 0,"
|
||||
"read BOOLEAN)");
|
||||
"read BOOLEAN DEFAULT 0)");
|
||||
success = success && queryComicInfo.exec();
|
||||
//queryComicInfo.finish();
|
||||
|
||||
@ -126,32 +183,30 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
||||
QSqlQuery query("INSERT INTO db_info (version) "
|
||||
"VALUES ('5.0.0')",database);
|
||||
//query.finish();
|
||||
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
#include <qmessagebox.h>
|
||||
void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
{
|
||||
QSqlDatabase sourceDB = loadDatabase(source);
|
||||
QSqlDatabase destDB = QSqlDatabase::addDatabase("QSQLITE");
|
||||
destDB.setDatabaseName(dest);
|
||||
destDB.open();
|
||||
sourceDB.open();
|
||||
|
||||
QSqlQuery attach(sourceDB);
|
||||
//QSqlDatabase sourceDB = loadDatabase(source);
|
||||
QSqlDatabase destDB = loadDatabaseFromFile(dest);
|
||||
//sourceDB.open();
|
||||
{
|
||||
QSqlQuery attach(destDB);
|
||||
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
||||
//attach.bindValue(":dest",QDir().toNativeSeparators(dest));
|
||||
attach.exec();
|
||||
//attach.finish();
|
||||
|
||||
QSqlQuery attach2(sourceDB);
|
||||
QSqlQuery attach2(destDB);
|
||||
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
||||
attach2.exec();
|
||||
//attach2.finish();
|
||||
|
||||
//sourceDB.close();
|
||||
QSqlQuery queryDBInfo(sourceDB);
|
||||
QSqlQuery queryDBInfo(destDB);
|
||||
queryDBInfo.prepare("CREATE TABLE dest.db_info (version TEXT NOT NULL)");
|
||||
queryDBInfo.exec();
|
||||
//queryDBInfo.finish();
|
||||
@ -161,22 +216,22 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
queryComicsInfo.exec();*/
|
||||
|
||||
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
||||
"VALUES ('5.0.0')",sourceDB);
|
||||
"VALUES ('5.0.0')",destDB);
|
||||
//query.finish();
|
||||
|
||||
QSqlQuery exportData(sourceDB);
|
||||
exportData.prepare("create table dest.comic_info as select * from source.comic_info where source.comic_info.edited = 1");
|
||||
QSqlQuery exportData(destDB);
|
||||
exportData.prepare("create table dest.comic_info as select " + fields +
|
||||
" from source.comic_info where source.comic_info.edited = 1");
|
||||
exportData.exec();
|
||||
//exportData.finish();
|
||||
}
|
||||
|
||||
QString error = exportData.lastError().databaseText();
|
||||
QString error2 = exportData.lastError().text();
|
||||
|
||||
sourceDB.close();
|
||||
//sourceDB.close();
|
||||
destDB.close();
|
||||
QSqlDatabase::removeDatabase(dest);
|
||||
|
||||
}
|
||||
#include <qmessagebox.h>
|
||||
|
||||
bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||
{
|
||||
QString error;
|
||||
@ -184,44 +239,254 @@ bool DataBaseManagement::importComicsInfo(QString source, QString dest)
|
||||
|
||||
bool b = false;
|
||||
|
||||
QSqlDatabase destDB = QSqlDatabase::addDatabase("QSQLITE",dest);
|
||||
destDB.setDatabaseName(dest);
|
||||
if(destDB.open())
|
||||
{
|
||||
QSqlQuery pragma("PRAGMA foreign_keys = ON",destDB);
|
||||
QSqlDatabase sourceDB = loadDatabaseFromFile(source);
|
||||
QSqlDatabase destDB = loadDatabaseFromFile(dest);
|
||||
|
||||
QSqlQuery attach(destDB);
|
||||
attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
||||
attach.exec();
|
||||
QSqlQuery pragma("PRAGMA synchronous=OFF",destDB);
|
||||
|
||||
error = attach.lastError().databaseText();
|
||||
driver = attach.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,tr("db error"),error);
|
||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
|
||||
QSqlQuery attach2(destDB);
|
||||
attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
||||
attach2.exec();
|
||||
|
||||
error = attach2.lastError().databaseText();
|
||||
driver = attach2.lastError().driverText();
|
||||
//QSqlQuery attach(destDB);
|
||||
//attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;");
|
||||
//attach.exec();
|
||||
|
||||
//error = attach.lastError().databaseText();
|
||||
//driver = attach.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,tr("db error"),error);
|
||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
//QMessageBox::critical(NULL,tr("db error"),error);
|
||||
//QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
|
||||
//QSqlQuery attach2(destDB);
|
||||
//attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;");
|
||||
//attach2.exec();
|
||||
//
|
||||
//error = attach2.lastError().databaseText();
|
||||
//driver = attach2.lastError().driverText();
|
||||
|
||||
//QMessageBox::critical(NULL,tr("db error"),error);
|
||||
//QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
//TODO check versions...
|
||||
//QSqlQuery 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);
|
||||
import.prepare("insert or replace into dest.comic_info select * from source.comic_info;");
|
||||
bool b = import.exec();
|
||||
error = import.lastError().databaseText();
|
||||
driver = import.lastError().driverText();
|
||||
//error = update.lastError().databaseText();
|
||||
//driver = update.lastError().driverText();
|
||||
|
||||
QMessageBox::critical(NULL,tr("db error"),error);
|
||||
QMessageBox::critical(NULL,tr("db error"),driver);
|
||||
//QMessageBox::critical(NULL,tr("db error"),error);
|
||||
//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;
|
||||
|
||||
}
|
||||
|
@ -34,12 +34,13 @@ private:
|
||||
QList<QString> dataBasesList;
|
||||
public:
|
||||
DataBaseManagement();
|
||||
TreeModel * newTreeModel(QString path);
|
||||
//TreeModel * newTreeModel(QString path);
|
||||
//crea una base de datos y todas sus tablas
|
||||
static QSqlDatabase createDatabase(QString name, QString path);
|
||||
static QSqlDatabase createDatabase(QString dest);
|
||||
//carga una base de datos desde la ruta path
|
||||
static QSqlDatabase loadDatabase(QString path);
|
||||
static QSqlDatabase loadDatabaseFromFile(QString path);
|
||||
static bool createTables(QSqlDatabase & database);
|
||||
|
||||
static void exportComicsInfo(QString source, QString dest);
|
||||
|
@ -217,11 +217,14 @@ void TreeModel::setupModelData(QString path)
|
||||
_database.close();
|
||||
_database = DataBaseManagement::loadDatabase(path);
|
||||
//crear la consulta
|
||||
{
|
||||
QSqlQuery selectQuery("select * from folder where id <> 1 order by parentId,name",_database);
|
||||
|
||||
setupModelData(selectQuery,rootItem);
|
||||
}
|
||||
//selectQuery.finish();
|
||||
_database.close();
|
||||
QSqlDatabase::removeDatabase(path);
|
||||
endResetModel();
|
||||
|
||||
}
|
||||
|
@ -34,10 +34,16 @@ ExportLibraryDialog::ExportLibraryDialog(QWidget * parent)
|
||||
bottomLayout->addWidget(accept);
|
||||
bottomLayout->addWidget(cancel);
|
||||
|
||||
progressBar = new QProgressBar(this);
|
||||
progressBar->setMinimum(0);
|
||||
progressBar->setMaximum(0);
|
||||
progressBar->setTextVisible(false);
|
||||
progressBar->hide();
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(libraryLayout);
|
||||
mainLayout->addWidget(progress=new QLabel());
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(progressBar);
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
@ -57,6 +63,7 @@ ExportLibraryDialog::ExportLibraryDialog(QWidget * parent)
|
||||
|
||||
void ExportLibraryDialog::exportLibrary()
|
||||
{
|
||||
progressBar->show();
|
||||
accept->setEnabled(false);
|
||||
emit exportPath(QDir::cleanPath(path->text()));
|
||||
t.start();
|
||||
@ -75,10 +82,10 @@ void ExportLibraryDialog::findPath()
|
||||
void ExportLibraryDialog::close()
|
||||
{
|
||||
path->clear();
|
||||
progressBar->hide();
|
||||
accept->setEnabled(false);
|
||||
t.stop();
|
||||
progressCount=0;
|
||||
progress->setText("");
|
||||
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 <QThread>
|
||||
#include <QTimer>
|
||||
#include <QProgressBar>
|
||||
|
||||
class ExportLibraryDialog : public QDialog
|
||||
{
|
||||
@ -18,10 +19,9 @@ public slots:
|
||||
void exportLibrary();
|
||||
void findPath();
|
||||
void close();
|
||||
void updateProgress();
|
||||
private:
|
||||
int progressCount;
|
||||
QLabel * progress;
|
||||
QProgressBar *progressBar;
|
||||
QLabel * textLabel;
|
||||
QLineEdit * path;
|
||||
QPushButton * find;
|
||||
|
@ -66,12 +66,19 @@ void ImportLibraryDialog::setupUI()
|
||||
bottomLayout->addWidget(accept);
|
||||
bottomLayout->addWidget(cancel);
|
||||
|
||||
progressBar = new QProgressBar(this);
|
||||
progressBar->setMinimum(0);
|
||||
progressBar->setMaximum(0);
|
||||
progressBar->setTextVisible(false);
|
||||
progressBar->hide();
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(nameLayout);
|
||||
mainLayout->addLayout(libraryLayout);
|
||||
mainLayout->addLayout(destLayout);
|
||||
mainLayout->addWidget(progress = new QLabel());
|
||||
//mainLayout->addWidget(progress = new QLabel());
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(progressBar);
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
@ -85,16 +92,12 @@ void ImportLibraryDialog::setupUI()
|
||||
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Extract a catalog"));
|
||||
|
||||
t.setInterval(500);
|
||||
t.stop();
|
||||
connect(&t,SIGNAL(timeout()),this,SLOT(updateProgress()));
|
||||
}
|
||||
|
||||
void ImportLibraryDialog::add()
|
||||
{
|
||||
accept->setEnabled(false);
|
||||
t.start();
|
||||
progressBar->show();
|
||||
emit(unpackCLC(QDir::cleanPath(path->text()),QDir::cleanPath(destPath->text()),nameEdit->text()));
|
||||
}
|
||||
|
||||
@ -138,26 +141,10 @@ void ImportLibraryDialog::close()
|
||||
destPath->clear();
|
||||
nameEdit->clear();
|
||||
accept->setEnabled(false);
|
||||
if(t.isActive())
|
||||
{
|
||||
t.stop();
|
||||
emit rejected();
|
||||
}
|
||||
progress->setText("");
|
||||
progressBar->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 )
|
||||
{
|
||||
close();
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QProgressBar>
|
||||
|
||||
class ImportLibraryDialog : public QDialog
|
||||
{
|
||||
@ -25,9 +25,8 @@
|
||||
QPushButton * findDest;
|
||||
QPushButton * accept;
|
||||
QPushButton * cancel;
|
||||
QLabel * progress;
|
||||
QProgressBar *progressBar;
|
||||
void setupUI();
|
||||
QTimer t;
|
||||
int progressCount;
|
||||
void closeEvent ( QCloseEvent * e );
|
||||
public slots:
|
||||
@ -35,7 +34,6 @@
|
||||
void findPath();
|
||||
void findDestination();
|
||||
void close();
|
||||
void updateProgress();
|
||||
void nameEntered();
|
||||
|
||||
signals:
|
||||
|
@ -881,8 +881,10 @@ void LibraryWindow::deleteLibrary()
|
||||
|
||||
void LibraryWindow::deleteCurrentLibrary()
|
||||
{
|
||||
|
||||
dm->getDatabase().close();
|
||||
QSqlDatabase db = dm->getDatabase();
|
||||
db.commit();
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(db.connectionName());
|
||||
if(!dm->getDatabase().isOpen())
|
||||
{
|
||||
QString path = libraries.value(selectedLibrary->currentText());
|
||||
|
@ -95,13 +95,13 @@
|
||||
public slots:
|
||||
void setComics(QList<Comic> comics);
|
||||
void updateComics();
|
||||
|
||||
void save();
|
||||
//Deprecated
|
||||
void setCover(const QPixmap & cover);
|
||||
void setFilename(const QString & name);
|
||||
void setNumpages(int pages);
|
||||
void setSize(float size);
|
||||
void save();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user