mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
YACReaderLibrary.Comic renombrada a YACReaderLibrary.ComicDB
A?adida la clase YACReader.Comic a YACReaderLibrary Implementado el controlador que sirve la informaci?n de descarga de un c?mic
This commit is contained in:
parent
cbee662df4
commit
12e697bc0f
@ -6,7 +6,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfoList>
|
#include <QFileInfoList>
|
||||||
#include "bookmarks.h"
|
#include "bookmarks.h" //TODO desacoplar la dependencia con bookmarks
|
||||||
#include "qnaturalsorting.h"
|
#include "qnaturalsorting.h"
|
||||||
|
|
||||||
#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"
|
#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"
|
||||||
|
@ -34,12 +34,14 @@ HEADERS += comic_flow.h \
|
|||||||
./db/treemodel.h \
|
./db/treemodel.h \
|
||||||
./db/tablemodel.h \
|
./db/tablemodel.h \
|
||||||
./db/tableitem.h \
|
./db/tableitem.h \
|
||||||
./db/comic.h \
|
./db/comic_db.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
|
../common/check_new_version.h \
|
||||||
|
../YACReader/comic.h \
|
||||||
|
../YACReader/bookmarks.h
|
||||||
|
|
||||||
SOURCES += comic_flow.cpp \
|
SOURCES += comic_flow.cpp \
|
||||||
create_library_dialog.cpp \
|
create_library_dialog.cpp \
|
||||||
@ -62,12 +64,14 @@ SOURCES += comic_flow.cpp \
|
|||||||
./db/treemodel.cpp \
|
./db/treemodel.cpp \
|
||||||
./db/tablemodel.cpp \
|
./db/tablemodel.cpp \
|
||||||
./db/tableitem.cpp \
|
./db/tableitem.cpp \
|
||||||
./db/comic.cpp \
|
./db/comic_db.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
|
../common/check_new_version.cpp \
|
||||||
|
../YACReader/comic.cpp \
|
||||||
|
../YACReader/bookmarks.cpp
|
||||||
|
|
||||||
include(./server/server.pri)
|
include(./server/server.pri)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "comic.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlRecord>
|
#include <QSqlRecord>
|
||||||
@ -7,12 +7,12 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//COMIC------------------------------------------------------------------------
|
//COMIC------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Comic::Comic()
|
ComicDB::ComicDB()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Comic::Comic(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database)
|
ComicDB::ComicDB(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database)
|
||||||
{
|
{
|
||||||
parentId = cparentId;
|
parentId = cparentId;
|
||||||
name = cname;
|
name = cname;
|
||||||
@ -28,7 +28,7 @@ Comic::Comic(qulonglong cparentId, QString cname, QString cpath, QString chash,
|
|||||||
_hasCover = true;
|
_hasCover = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabase & db)
|
QList<LibraryItem *> ComicDB::getComicsFromParent(qulonglong parentId, QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
QList<LibraryItem *> list;
|
QList<LibraryItem *> list;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabas
|
|||||||
selectQuery.bindValue(":parentId", parentId);
|
selectQuery.bindValue(":parentId", parentId);
|
||||||
selectQuery.exec();
|
selectQuery.exec();
|
||||||
|
|
||||||
Comic * currentItem;
|
ComicDB * currentItem;
|
||||||
while (selectQuery.next())
|
while (selectQuery.next())
|
||||||
{
|
{
|
||||||
QList<QVariant> data;
|
QList<QVariant> data;
|
||||||
@ -45,7 +45,7 @@ QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabas
|
|||||||
for(int i=0;i<record.count();i++)
|
for(int i=0;i<record.count();i++)
|
||||||
data << record.value(i);
|
data << record.value(i);
|
||||||
|
|
||||||
currentItem = new Comic();
|
currentItem = new ComicDB();
|
||||||
currentItem->id = record.value("id").toULongLong();
|
currentItem->id = record.value("id").toULongLong();
|
||||||
currentItem->parentId = record.value(1).toULongLong();
|
currentItem->parentId = record.value(1).toULongLong();
|
||||||
currentItem->name = record.value(2).toString();
|
currentItem->name = record.value(2).toString();
|
||||||
@ -56,7 +56,7 @@ QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabas
|
|||||||
list.append(currentItem);
|
list.append(currentItem);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Comic * last = static_cast<Comic *>(list.back());
|
ComicDB * last = static_cast<ComicDB *>(list.back());
|
||||||
QString nameLast = last->name;
|
QString nameLast = last->name;
|
||||||
QString nameCurrent = currentItem->name;
|
QString nameCurrent = currentItem->name;
|
||||||
QList<LibraryItem *>::iterator i;
|
QList<LibraryItem *>::iterator i;
|
||||||
@ -78,7 +78,7 @@ QList<LibraryItem *> Comic::getComicsFromParent(qulonglong parentId, QSqlDatabas
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Comic::load(qulonglong idc, QSqlDatabase & db)
|
bool ComicDB::load(qulonglong idc, QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
|
|
||||||
QSqlQuery selectQuery(db);
|
QSqlQuery selectQuery(db);
|
||||||
@ -102,7 +102,7 @@ bool Comic::load(qulonglong idc, QSqlDatabase & db)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qulonglong Comic::insert(QSqlDatabase & db)
|
qulonglong ComicDB::insert(QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
//TODO cambiar por info.insert(db)
|
//TODO cambiar por info.insert(db)
|
||||||
|
|
||||||
@ -131,12 +131,12 @@ qulonglong Comic::insert(QSqlDatabase & db)
|
|||||||
return query.lastInsertId().toULongLong();
|
return query.lastInsertId().toULongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Comic::update(QSqlDatabase & db)
|
void ComicDB::update(QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Comic::removeFromDB(QSqlDatabase & db)
|
void ComicDB::removeFromDB(QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
query.prepare("DELETE FROM comic WHERE id = :id");
|
query.prepare("DELETE FROM comic WHERE id = :id");
|
||||||
@ -145,7 +145,7 @@ void Comic::removeFromDB(QSqlDatabase & db)
|
|||||||
//query.finish();
|
//query.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Comic::isDir()
|
bool ComicDB::isDir()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -114,13 +114,13 @@ private:
|
|||||||
void copyField(bool * & field, bool * value);
|
void copyField(bool * & field, bool * value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Comic : public LibraryItem
|
class ComicDB : public LibraryItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool _hasCover;
|
bool _hasCover;
|
||||||
public:
|
public:
|
||||||
Comic();
|
ComicDB();
|
||||||
Comic(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
ComicDB(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
||||||
//Comic(QString fn, QString fp):name(fn),path(fp),knownParent(false), knownId(false){};
|
//Comic(QString fn, QString fp):name(fn),path(fp),knownParent(false), knownId(false){};
|
||||||
|
|
||||||
static QList<LibraryItem *> getComicsFromParent(qulonglong parentId, QSqlDatabase & db);
|
static QList<LibraryItem *> getComicsFromParent(qulonglong parentId, QSqlDatabase & db);
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "comic.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
class TableItem
|
class TableItem
|
||||||
|
@ -274,9 +274,9 @@ void TableModel::setupModelData(QSqlQuery &sqlquery)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Comic TableModel::getComic(const QModelIndex & mi)
|
ComicDB TableModel::getComic(const QModelIndex & mi)
|
||||||
{
|
{
|
||||||
Comic c;
|
ComicDB c;
|
||||||
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||||
c.load(_data.at(mi.row())->data(ID).toULongLong(),db);
|
c.load(_data.at(mi.row())->data(ID).toULongLong(),db);
|
||||||
@ -286,9 +286,9 @@ Comic TableModel::getComic(const QModelIndex & mi)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Comic TableModel::_getComic(const QModelIndex & mi)
|
ComicDB TableModel::_getComic(const QModelIndex & mi)
|
||||||
{
|
{
|
||||||
Comic c;
|
ComicDB c;
|
||||||
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||||
c.load(_data.at(mi.row())->data(ID).toULongLong(),db);
|
c.load(_data.at(mi.row())->data(ID).toULongLong(),db);
|
||||||
@ -320,7 +320,7 @@ QVector<bool> TableModel::setAllComicsRead(bool read)
|
|||||||
{
|
{
|
||||||
readList[i] = read;
|
readList[i] = read;
|
||||||
_data.value(i)->data(READ) = QVariant(true);
|
_data.value(i)->data(READ) = QVariant(true);
|
||||||
Comic c;
|
ComicDB c;
|
||||||
c.load(_data.value(i)->data(ID).toULongLong(),db);
|
c.load(_data.value(i)->data(ID).toULongLong(),db);
|
||||||
c.info.read = read;
|
c.info.read = read;
|
||||||
c.info.update(db);
|
c.info.update(db);
|
||||||
@ -332,9 +332,9 @@ QVector<bool> TableModel::setAllComicsRead(bool read)
|
|||||||
return readList;
|
return readList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Comic> TableModel::getComics(QList<QModelIndex> list)
|
QList<ComicDB> TableModel::getComics(QList<QModelIndex> list)
|
||||||
{
|
{
|
||||||
QList<Comic> comics;
|
QList<ComicDB> comics;
|
||||||
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||||
db.transaction();
|
db.transaction();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
#include "comic.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
class TableItem;
|
class TableItem;
|
||||||
|
|
||||||
@ -35,17 +35,17 @@ public:
|
|||||||
//Métodos de conveniencia
|
//Métodos de conveniencia
|
||||||
QStringList getPaths(const QString & _source);
|
QStringList getPaths(const QString & _source);
|
||||||
QString getComicPath(QModelIndex mi);
|
QString getComicPath(QModelIndex mi);
|
||||||
Comic getComic(const QModelIndex & mi); //--> para la edición
|
ComicDB getComic(const QModelIndex & mi); //--> para la edición
|
||||||
QVector<bool> getReadList();
|
QVector<bool> getReadList();
|
||||||
QVector<bool> setAllComicsRead(bool read);
|
QVector<bool> setAllComicsRead(bool read);
|
||||||
QList<Comic> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
|
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
|
||||||
QModelIndex getIndexFromId(quint64 id);
|
QModelIndex getIndexFromId(quint64 id);
|
||||||
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
|
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
|
||||||
//setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez.
|
//setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez.
|
||||||
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
|
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
|
||||||
private:
|
private:
|
||||||
void setupModelData( QSqlQuery &sqlquery);
|
void setupModelData( QSqlQuery &sqlquery);
|
||||||
Comic _getComic(const QModelIndex & mi);
|
ComicDB _getComic(const QModelIndex & mi);
|
||||||
QList<TableItem *> _data;
|
QList<TableItem *> _data;
|
||||||
|
|
||||||
QString _databasePath;
|
QString _databasePath;
|
||||||
|
@ -224,7 +224,7 @@ void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo &
|
|||||||
file.close();
|
file.close();
|
||||||
//hash Sha1 del primer 0.5MB + filesize
|
//hash Sha1 del primer 0.5MB + filesize
|
||||||
QString hash = QString(crypto.result().toHex().constData()) + QString::number(fileInfo.size());
|
QString hash = QString(crypto.result().toHex().constData()) + QString::number(fileInfo.size());
|
||||||
Comic comic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database);
|
ComicDB comic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database);
|
||||||
int numPages;
|
int numPages;
|
||||||
|
|
||||||
if(! ( comic.hasCover() && checkCover(hash)))
|
if(! ( comic.hasCover() && checkCover(hash)))
|
||||||
@ -246,7 +246,7 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
QFileInfoList listS = dirS.entryInfoList();
|
QFileInfoList listS = dirS.entryInfoList();
|
||||||
|
|
||||||
QList<LibraryItem *> folders = Folder::getFoldersFromParent(_currentPathFolders.last().id,_database);
|
QList<LibraryItem *> folders = Folder::getFoldersFromParent(_currentPathFolders.last().id,_database);
|
||||||
QList<LibraryItem *> comics = Comic::getComicsFromParent(_currentPathFolders.last().id,_database);
|
QList<LibraryItem *> comics = ComicDB::getComicsFromParent(_currentPathFolders.last().id,_database);
|
||||||
|
|
||||||
QList <LibraryItem *> listD;
|
QList <LibraryItem *> listD;
|
||||||
listD.append(folders);
|
listD.append(folders);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
#include "folder.h"
|
#include "folder.h"
|
||||||
#include "comic.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
|
|
||||||
class LibraryCreator : public QThread
|
class LibraryCreator : public QThread
|
||||||
|
@ -841,7 +841,7 @@ void LibraryWindow::setCurrentComicReaded()
|
|||||||
comicFlow->markSlide(comicFlow->centerIndex());
|
comicFlow->markSlide(comicFlow->centerIndex());
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
|
|
||||||
Comic c = dmCV->getComic(comicView->currentIndex());
|
ComicDB c = dmCV->getComic(comicView->currentIndex());
|
||||||
c.info.read = true;
|
c.info.read = true;
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase());
|
QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase());
|
||||||
db.open();
|
db.open();
|
||||||
@ -861,7 +861,7 @@ void LibraryWindow::setCurrentComicUnreaded()
|
|||||||
comicFlow->unmarkSlide(comicFlow->centerIndex());
|
comicFlow->unmarkSlide(comicFlow->centerIndex());
|
||||||
comicFlow->updateMarks();
|
comicFlow->updateMarks();
|
||||||
|
|
||||||
Comic c = dmCV->getComic(comicView->currentIndex());
|
ComicDB c = dmCV->getComic(comicView->currentIndex());
|
||||||
c.info.read = false;
|
c.info.read = false;
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase());
|
QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase());
|
||||||
db.open();
|
db.open();
|
||||||
@ -1158,8 +1158,8 @@ void LibraryWindow::showProperties()
|
|||||||
{
|
{
|
||||||
QModelIndexList indexList = comicView->selectionModel()->selectedRows();
|
QModelIndexList indexList = comicView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
QList<Comic> comics = dmCV->getComics(indexList);
|
QList<ComicDB> comics = dmCV->getComics(indexList);
|
||||||
Comic c = comics[0];
|
ComicDB c = comics[0];
|
||||||
_comicIdEdited = c.id;//static_cast<TableItem*>(indexList[0].internalPointer())->data(4).toULongLong();
|
_comicIdEdited = c.id;//static_cast<TableItem*>(indexList[0].internalPointer())->data(4).toULongLong();
|
||||||
|
|
||||||
//QModelIndex mi = comicView->currentIndex();
|
//QModelIndex mi = comicView->currentIndex();
|
||||||
@ -1184,8 +1184,8 @@ void LibraryWindow::asignNumbers()
|
|||||||
{
|
{
|
||||||
QModelIndexList indexList = comicView->selectionModel()->selectedRows();
|
QModelIndexList indexList = comicView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
QList<Comic> comics = dmCV->getComics(indexList);
|
QList<ComicDB> comics = dmCV->getComics(indexList);
|
||||||
Comic c = comics[0];
|
ComicDB c = comics[0];
|
||||||
_comicIdEdited = c.id;
|
_comicIdEdited = c.id;
|
||||||
|
|
||||||
int startingNumber = dmCV->getIndexFromId(comics[0].id).row()+1;
|
int startingNumber = dmCV->getIndexFromId(comics[0].id).row()+1;
|
||||||
@ -1205,7 +1205,7 @@ void LibraryWindow::asignNumbers()
|
|||||||
|
|
||||||
for(int i = 0;i<comics.length();i++)
|
for(int i = 0;i<comics.length();i++)
|
||||||
{
|
{
|
||||||
Comic c = comics[i];
|
ComicDB c = comics[i];
|
||||||
c.info.setNumber(startingNumber+i);
|
c.info.setNumber(startingNumber+i);
|
||||||
c.info.edited = true;
|
c.info.edited = true;
|
||||||
c.info.update(db);
|
c.info.update(db);
|
||||||
@ -1349,7 +1349,7 @@ QList<LibraryItem *> LibraryWindow::getFolderComicsFromLibrary(const QString & l
|
|||||||
{
|
{
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
||||||
|
|
||||||
QList<LibraryItem *> list = Comic::getComicsFromParent(folderId,db);
|
QList<LibraryItem *> list = ComicDB::getComicsFromParent(folderId,db);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
||||||
@ -1365,4 +1365,16 @@ qulonglong LibraryWindow::getParentFromComicFolderId(const QString & libraryName
|
|||||||
db.close();
|
db.close();
|
||||||
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
||||||
return f.parentId;
|
return f.parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComicDB LibraryWindow::getComicInfo(const QString & libraryName, qulonglong id)
|
||||||
|
{
|
||||||
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraries.value(libraryName)+"/.yacreaderlibrary");
|
||||||
|
|
||||||
|
ComicDB comic;
|
||||||
|
comic.load(id,db);
|
||||||
|
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(libraries.value(libraryName));
|
||||||
|
return comic;
|
||||||
}
|
}
|
@ -205,6 +205,7 @@ public:
|
|||||||
QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
|
QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
|
||||||
QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
|
QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
|
||||||
qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
|
qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
|
||||||
|
ComicDB getComicInfo(const QString & libraryName, qulonglong id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -258,11 +258,11 @@ void PropertiesDialog::createButtonBox()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PropertiesDialog::setComics(QList<Comic> comics)
|
void PropertiesDialog::setComics(QList<ComicDB> comics)
|
||||||
{
|
{
|
||||||
this->comics = comics;
|
this->comics = comics;
|
||||||
|
|
||||||
Comic comic = comics.at(0);
|
ComicDB comic = comics.at(0);
|
||||||
|
|
||||||
if(comic.info.title != NULL)
|
if(comic.info.title != NULL)
|
||||||
title->setText(*comic.info.title);
|
title->setText(*comic.info.title);
|
||||||
@ -344,7 +344,7 @@ void PropertiesDialog::setComics(QList<Comic> comics)
|
|||||||
this->setWindowTitle(tr("Edit selected comics information"));
|
this->setWindowTitle(tr("Edit selected comics information"));
|
||||||
setCover(QPixmap(":/images/editComic.png"));
|
setCover(QPixmap(":/images/editComic.png"));
|
||||||
|
|
||||||
QList<Comic>::iterator itr;
|
QList<ComicDB>::iterator itr;
|
||||||
for(itr = ++comics.begin();itr!=comics.end();itr++)
|
for(itr = ++comics.begin();itr!=comics.end();itr++)
|
||||||
{
|
{
|
||||||
if(itr->info.title == NULL || *(itr->info.title) != title->text())
|
if(itr->info.title == NULL || *(itr->info.title) != title->text())
|
||||||
@ -425,7 +425,7 @@ void PropertiesDialog::updateComics()
|
|||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
db.open();
|
db.open();
|
||||||
db.transaction();
|
db.transaction();
|
||||||
QList<Comic>::iterator itr;
|
QList<ComicDB>::iterator itr;
|
||||||
for(itr = comics.begin();itr!=comics.end();itr++)
|
for(itr = comics.begin();itr!=comics.end();itr++)
|
||||||
{
|
{
|
||||||
if(itr->info.edited)
|
if(itr->info.edited)
|
||||||
@ -483,7 +483,7 @@ void PropertiesDialog::setSize(float sizeFloat)
|
|||||||
|
|
||||||
void PropertiesDialog::save()
|
void PropertiesDialog::save()
|
||||||
{
|
{
|
||||||
QList<Comic>::iterator itr;
|
QList<ComicDB>::iterator itr;
|
||||||
for(itr = comics.begin();itr!=comics.end();itr++)
|
for(itr = comics.begin();itr!=comics.end();itr++)
|
||||||
{
|
{
|
||||||
//Comic & comic = comics[0];
|
//Comic & comic = comics[0];
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
|
|
||||||
#include "comic.h"
|
#include "comic_db.h"
|
||||||
#include "custom_widgets.h"
|
#include "custom_widgets.h"
|
||||||
|
|
||||||
class PropertiesDialog : public QDialog
|
class PropertiesDialog : public QDialog
|
||||||
@ -94,7 +94,7 @@
|
|||||||
|
|
||||||
void setDisableUniqueValues(bool disabled);
|
void setDisableUniqueValues(bool disabled);
|
||||||
|
|
||||||
QList<Comic> comics;
|
QList<ComicDB> comics;
|
||||||
void closeEvent ( QCloseEvent * e );
|
void closeEvent ( QCloseEvent * e );
|
||||||
public:
|
public:
|
||||||
PropertiesDialog(QWidget * parent = 0);
|
PropertiesDialog(QWidget * parent = 0);
|
||||||
@ -102,7 +102,7 @@
|
|||||||
QString basePath;
|
QString basePath;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setComics(QList<Comic> comics);
|
void setComics(QList<ComicDB> comics);
|
||||||
void updateComics();
|
void updateComics();
|
||||||
void save();
|
void save();
|
||||||
//Deprecated
|
//Deprecated
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
#include "comiccontroller.h"
|
||||||
|
#include "library_window.h"
|
||||||
|
|
||||||
|
extern LibraryWindow * mw;
|
||||||
|
|
||||||
|
#include "template.h"
|
||||||
|
#include "../static.h"
|
||||||
|
|
||||||
|
#include "comic_db.h"
|
||||||
|
|
||||||
|
ComicController::ComicController() {}
|
||||||
|
|
||||||
|
void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||||
|
{
|
||||||
|
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||||
|
|
||||||
|
QStringList pathElements = ((QString)request.getPath()).split('/');
|
||||||
|
QString libraryName = pathElements.at(2);
|
||||||
|
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||||
|
|
||||||
|
ComicDB comic = mw->getComicInfo(libraryName, comicId);
|
||||||
|
|
||||||
|
response.writeText(QString("comicid:%1\n").arg(comic.id));
|
||||||
|
response.writeText(QString("hash:%1\n").arg(comic.info.hash));
|
||||||
|
response.writeText(QString("path:%1\n").arg(comic.path));
|
||||||
|
response.writeText(QString("numpages:%1\n").arg(*comic.info.numPages));
|
||||||
|
response.writeText(QString("library:%1\n").arg(libraryName),true);
|
||||||
|
|
||||||
|
//response.write(t.toLatin1(),true);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef COMICCONTROLLER_H
|
||||||
|
#define COMICCONTROLLER_H
|
||||||
|
|
||||||
|
#include "httprequest.h"
|
||||||
|
#include "httpresponse.h"
|
||||||
|
#include "httprequesthandler.h"
|
||||||
|
|
||||||
|
class ComicController : public HttpRequestHandler {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(ComicController);
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Constructor */
|
||||||
|
ComicController();
|
||||||
|
|
||||||
|
/** Generates the response */
|
||||||
|
void service(HttpRequest& request, HttpResponse& response);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COMICCONTROLLER_H
|
@ -103,7 +103,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
|
|
||||||
while(j<numComicsAtCurrentPage)
|
while(j<numComicsAtCurrentPage)
|
||||||
{
|
{
|
||||||
const Comic * comic = (Comic *)folderComics.at(j+comicsOffset);
|
const ComicDB * comic = (ComicDB *)folderComics.at(j+comicsOffset);
|
||||||
//if(comic->info.title == 0 || comic->info.title->isEmpty())
|
//if(comic->info.title == 0 || comic->info.title->isEmpty())
|
||||||
t.setVariable(QString("elementcomic%1.name").arg(j),comic->name);
|
t.setVariable(QString("elementcomic%1.name").arg(j),comic->name);
|
||||||
//else
|
//else
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "controllers/librariescontroller.h"
|
#include "controllers/librariescontroller.h"
|
||||||
#include "controllers/foldercontroller.h"
|
#include "controllers/foldercontroller.h"
|
||||||
#include "controllers/covercontroller.h"
|
#include "controllers/covercontroller.h"
|
||||||
|
#include "controllers/comiccontroller.h"
|
||||||
|
|
||||||
RequestMapper::RequestMapper(QObject* parent)
|
RequestMapper::RequestMapper(QObject* parent)
|
||||||
:HttpRequestHandler(parent) {}
|
:HttpRequestHandler(parent) {}
|
||||||
@ -30,40 +31,26 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//listar el contenido del folder
|
//listar el contenido del folder
|
||||||
if(path.contains("folder") && !path.contains("info"))
|
else if(path.contains("folder") && !path.contains("info"))
|
||||||
{
|
{
|
||||||
FolderController().service(request, response);
|
FolderController().service(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(path.contains("cover") )
|
else if(path.contains("cover") )
|
||||||
{
|
{
|
||||||
CoverController().service(request, response);
|
CoverController().service(request, response);
|
||||||
|
}
|
||||||
|
else if(path.contains("comic") && !path.contains("page"))
|
||||||
|
{
|
||||||
|
ComicController().service(request, response);
|
||||||
|
}
|
||||||
|
else if(path.contains("page"))
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (path.startsWith("/dump")) {
|
|
||||||
DumpController().service(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (path.startsWith("/template")) {
|
|
||||||
TemplateController().service(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (path.startsWith("/form")) {
|
|
||||||
FormController().service(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (path.startsWith("/file")) {
|
|
||||||
FileUploadController().service(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (path.startsWith("/session")) {
|
|
||||||
SessionController().service(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
// All other pathes are mapped to the static file controller.
|
|
||||||
else {
|
|
||||||
Static::staticFileController->service(request, response);
|
Static::staticFileController->service(request, response);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user