diff --git a/YACReaderLibrary/db/data_base_management.cpp b/YACReaderLibrary/db/data_base_management.cpp index a84c67d8..8a241a33 100644 --- a/YACReaderLibrary/db/data_base_management.cpp +++ b/YACReaderLibrary/db/data_base_management.cpp @@ -71,5 +71,14 @@ bool DataBaseManagement::createTables(QSqlDatabase & database) queryComic.prepare("CREATE TABLE comic (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, comicInfoId INTEGER NOT NULL, fileName TEXT NOT NULL, path TEXT, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE, FOREIGN KEY(comicInfoId) REFERENCES comic_info(id))"); success = success && queryComic.exec(); + //DB INFO + QSqlQuery queryDBInfo(database); + queryDBInfo.prepare("CREATE TABLE db_info (version TEXT NOT NULL)"); + success = success && queryDBInfo.exec(); + + QSqlQuery query("INSERT INTO db_info (version) " + "VALUES ('5.0.0')",database); + + return success; } \ No newline at end of file diff --git a/YACReaderLibrary/db/tablemodel.cpp b/YACReaderLibrary/db/tablemodel.cpp index edee0d89..3d9ff294 100644 --- a/YACReaderLibrary/db/tablemodel.cpp +++ b/YACReaderLibrary/db/tablemodel.cpp @@ -211,7 +211,7 @@ void TableModel::setupModelData(QSqlQuery &sqlquery) } } -Comic TableModel::getComic(QModelIndex & mi) +Comic TableModel::getComic(const QModelIndex & mi) { Comic c; _database.open(); @@ -220,6 +220,16 @@ Comic TableModel::getComic(QModelIndex & mi) return c; } +Comic TableModel::_getComic(const QModelIndex & mi) +{ + Comic c; + + c.load(_data.at(mi.row())->data(0).toLongLong(),_database); + + return c; +} + + QVector TableModel::getReadList() { int numComics = _data.count(); @@ -252,4 +262,20 @@ QVector TableModel::setAllComicsRead(bool read) _database.close(); return readList; +} + +QList TableModel::getComics(QList list) +{ + QList comics; + + _database.open(); + _database.transaction(); + QList::const_iterator itr; + for(itr = list.constBegin(); itr!= list.constEnd();itr++) + { + comics.append(_getComic(*itr)); + } + _database.commit(); + _database.close(); + return comics; } \ No newline at end of file diff --git a/YACReaderLibrary/db/tablemodel.h b/YACReaderLibrary/db/tablemodel.h index 6b5596ba..4b9fc8f4 100644 --- a/YACReaderLibrary/db/tablemodel.h +++ b/YACReaderLibrary/db/tablemodel.h @@ -35,16 +35,16 @@ public: //Métodos de conveniencia QStringList getPaths(const QString & _source); QString getComicPath(QModelIndex & mi); - Comic getComic(QModelIndex & mi); //--> para la edición + Comic getComic(const QModelIndex & mi); //--> para la edición QVector getReadList(); QVector setAllComicsRead(bool read); - //getComicsInfo(QList list); --> recupera la información común a los comics seleccionados + QList getComics(QList list); //--> recupera la información común a los comics seleccionados //setcomicInfo(QModelIndex & mi); --> inserta en la base datos //setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez. //setComicInfoForSelectedComis(QList list); -->inserta la información común para los comics seleccionados private: void setupModelData( QSqlQuery &sqlquery); - + Comic _getComic(const QModelIndex & mi); QList _data; QSqlDatabase _database; diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 25069e41..af69773f 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -24,19 +24,22 @@ LibraryCreator::LibraryCreator() void LibraryCreator::createLibrary(const QString &source, const QString &target) { - _source = source; - _target = target; - if(!QDir(target+"/library.ydb").exists()) - _mode = CREATOR; - else - _mode = UPDATER; + processLibrary(source,target); } void LibraryCreator::updateLibrary(const QString &source, const QString &target) +{ + processLibrary(source,target); +} + +void LibraryCreator::processLibrary(const QString & source, const QString & target) { _source = source; _target = target; - _mode = UPDATER; + 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" + _mode = CREATOR; + else + _mode = UPDATER; } diff --git a/YACReaderLibrary/library_creator.h b/YACReaderLibrary/library_creator.h index 69f5649b..4f7699ca 100644 --- a/YACReaderLibrary/library_creator.h +++ b/YACReaderLibrary/library_creator.h @@ -27,6 +27,7 @@ void updateLibrary(const QString & source, const QString & target); void stop(); private: + void processLibrary(const QString & source, const QString & target); enum Mode {CREATOR,UPDATER}; //atributos "globales" durante el proceso de creación y actualización enum Mode _mode; diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 063461ac..f92907c3 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -361,6 +361,9 @@ void LibraryWindow::disableAllActions() setAsNonReadAction->setEnabled(false); setAllAsReadAction->setEnabled(false); setAllAsNonReadAction->setEnabled(false); + selectAllComicsAction->setEnabled(false); + editSelectedComicsAction->setEnabled(false); + asignOrderActions->setEnabled(false); } //librería de sólo lectura @@ -375,6 +378,9 @@ void LibraryWindow::disableActions() setAsNonReadAction->setEnabled(false); setAllAsReadAction->setEnabled(false); setAllAsNonReadAction->setEnabled(false); + selectAllComicsAction->setEnabled(false); + editSelectedComicsAction->setEnabled(false); + asignOrderActions->setEnabled(false); } //librería abierta void LibraryWindow::enableActions() @@ -456,7 +462,7 @@ void LibraryWindow::createToolBars() editInfoToolBar->addAction(editSelectedComicsAction); editInfoToolBar->addAction(selectAllComicsAction); editInfoToolBar->addSeparator(); - editInfoToolBar->addAction(forceConverExtractedAction); + //editInfoToolBar->addAction(forceConverExtractedAction); editInfoToolBar->addWidget(new QToolBarStretch()); editInfoToolBar->addAction(hideComicViewAction); } @@ -549,6 +555,7 @@ void LibraryWindow::createConnections() //connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString))); //Comicts edition connect(selectAllComicsAction,SIGNAL(triggered()),comicView,SLOT(selectAll())); + connect(editSelectedComicsAction,SIGNAL(triggered()),this,SLOT(showProperties())); connect(hideComicViewAction, SIGNAL(toggled(bool)),this, SLOT(hideComicFlow(bool))); @@ -653,6 +660,9 @@ void LibraryWindow::loadCovers(const QModelIndex & mi) setAsNonReadAction->setEnabled(true); setAllAsReadAction->setEnabled(true); setAllAsNonReadAction->setEnabled(true); + selectAllComicsAction->setEnabled(true); + editSelectedComicsAction->setEnabled(true); + asignOrderActions->setEnabled(true); } else { @@ -662,6 +672,9 @@ void LibraryWindow::loadCovers(const QModelIndex & mi) setAsNonReadAction->setEnabled(false); setAllAsReadAction->setEnabled(false); setAllAsNonReadAction->setEnabled(false); + selectAllComicsAction->setEnabled(false); + editSelectedComicsAction->setEnabled(false); + asignOrderActions->setEnabled(false); } if(paths.size()>0) comicView->setCurrentIndex(dmCV->index(0,0)); @@ -995,17 +1008,22 @@ void LibraryWindow::setFoldersFilter(QString filter) void LibraryWindow::showProperties() { - QModelIndex mi = comicView->currentIndex(); - QString path = QDir::cleanPath(currentPath()+dmCV->getComicPath(mi)); + QModelIndexList indexList = comicView->selectionModel()->selectedRows(); - ThumbnailCreator tc(path,""); - tc.create(); - propertiesDialog->setCover(tc.getCover()); + QList comics = dmCV->getComics(indexList); + + //QModelIndex mi = comicView->currentIndex(); + //QString path = QDir::cleanPath(currentPath()+dmCV->getComicPath(mi)); + + //ThumbnailCreator tc(path,""); + //tc.create(); + propertiesDialog->setComics(comics); + /*propertiesDialog->setCover(tc.getCover()); propertiesDialog->setFilename(path.split("/").last()); propertiesDialog->setNumpages(tc.getNumPages()); QFile file(path); propertiesDialog->setSize(file.size()/(1024.0*1024)); - file.close(); + file.close();*/ propertiesDialog->show(); } diff --git a/YACReaderLibrary/properties_dialog.cpp b/YACReaderLibrary/properties_dialog.cpp index c6b3de59..c451a0fb 100644 --- a/YACReaderLibrary/properties_dialog.cpp +++ b/YACReaderLibrary/properties_dialog.cpp @@ -231,7 +231,14 @@ void PropertiesDialog::createButtonBox() void PropertiesDialog::setComics(QList comics) { - + if(comics.length() > 1) + { + } + else + { + Comic comic = comics.at(0); + title->setText(comic.name); + } } diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index d474be89..239218eb 100644 --- a/common/check_new_version.cpp +++ b/common/check_new_version.cpp @@ -4,7 +4,8 @@ #include #include -#define VERSION "0.4.5" +#define VERSION "5.0" +#define PREVIOUS_VERSION "0.4.5" HttpVersionChecker::HttpVersionChecker() :QWidget() @@ -42,9 +43,18 @@ void HttpVersionChecker::read(const QHttpResponseHeader &){ void HttpVersionChecker::httpRequestFinished(int requestId, bool error) { +#ifdef QT_DEBUG + QString response("YACReader-5.0.0 win32.exe"); +#else + QString response(content); +#endif + checkNewVersion(response); +} - QString response(content); -#ifdef Q_WS_WIN +//TODO escribir prueba unitaria +bool HttpVersionChecker::checkNewVersion(QString sourceContent) +{ + #ifdef Q_WS_WIN QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}win32.*"); #endif @@ -60,34 +70,44 @@ void HttpVersionChecker::httpRequestFinished(int requestId, bool error) bool newVersion = false; bool sameVersion = true; //bool currentVersionIsNewer = false; - +#ifdef QT_DEBUG + QString version(PREVIOUS_VERSION); +#else QString version(VERSION); - QStringList sl = version.split("."); - if((index = rx.indexIn(response))!=-1) - { - int length = qMin(sl.size(),(rx.cap(4)!="")?4:3); - for(int i=0;isl.at(i).toInt()){ - newVersion=true; - break; - } - else - sameVersion = sameVersion && rx.cap(i+1).toInt()==sl.at(i).toInt(); - } - if(!newVersion && sameVersion) -{ - if((sl.size()==3)&&(rx.cap(4)!="")) - newVersion = true; -} + if(rx.cap(i+1).toInt()>sl.at(i).toInt()){ + newVersion=true; + break; + } + else + sameVersion = sameVersion && rx.cap(i+1).toInt()==sl.at(i).toInt(); + } + if(!newVersion && sameVersion) + { + if((sl.size()==3)&&(rx.cap(4)!="")) + newVersion = true; + } - } + } - if(newVersion == true) - emit newVersionDetected(); -} + if(newVersion == true) + { + emit newVersionDetected(); + return true; + } + else + { + return false; + } +} \ No newline at end of file diff --git a/common/check_new_version.h b/common/check_new_version.h index e9f8ab3e..7f0afbfb 100644 --- a/common/check_new_version.h +++ b/common/check_new_version.h @@ -22,6 +22,7 @@ int httpGetId; QByteArray content; bool found; + bool checkNewVersion(QString sourceContent); signals: void newVersionDetected(); };