mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 15:35:03 -04:00
moved settings files from local dir to standar paths
added YACReaderLibraries class, libraries are now identified by id
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "comiccontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
@ -38,14 +39,14 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
//que crear una clase que se encargue de estas cosas
|
||||
//<2F>Se est<73> accediendo a la UI desde un hilo?
|
||||
|
||||
QMap<QString,QString> libraries = DBHelper::getLibraries();
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryName, comicId);
|
||||
|
||||
session.setDownloadedComic(comic.info.hash);
|
||||
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.value(libraryName)+comic.path);
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryName)+comic.path);
|
||||
|
||||
if(comicFile != NULL)
|
||||
{
|
||||
@ -58,7 +59,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
comicFile->load(libraries.value(libraryName)+comic.path);
|
||||
comicFile->load(libraries.getPath(libraryName)+comic.path);
|
||||
|
||||
if(thread != NULL)
|
||||
thread->start();
|
||||
@ -78,4 +79,4 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
}
|
||||
//response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "covercontroller.h"
|
||||
#include "db_helper.h" //get libraries
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
@ -15,7 +16,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
|
||||
response.setHeader("Connection","close");
|
||||
//response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
|
||||
QMap<QString,QString> libraries = DBHelper::getLibraries();
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
QStringList pathElements = path.split('/');
|
||||
@ -40,7 +41,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
|
||||
// file.close();
|
||||
//}
|
||||
|
||||
QImage img(libraries.value(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
||||
QImage img(libraries.getPath(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
||||
if (!img.isNull()) {
|
||||
|
||||
int width = 80;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "librariescontroller.h"
|
||||
#include "db_helper.h" //get libraries
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
@ -39,16 +40,20 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
|
||||
t.enableWarnings();
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
QList<QString> names = DBHelper::getLibrariesNames();
|
||||
|
||||
t.loop("library",names.length());
|
||||
int i=0;
|
||||
while (i<names.length()) {
|
||||
t.setVariable(QString("library%1.name").arg(i),QString::number(i));
|
||||
t.setVariable(QString("library%1.label").arg(i),names.at(i));
|
||||
|
||||
int currentId = 0;
|
||||
int i = 0;
|
||||
foreach (QString name,names) {
|
||||
currentId = libraries.getId(name);
|
||||
t.setVariable(QString("library%1.name").arg(i),QString::number(currentId));
|
||||
t.setVariable(QString("library%1.label").arg(i),name);
|
||||
i++;
|
||||
}
|
||||
|
||||
response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "controllers/errorcontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
RequestMapper::RequestMapper(QObject* parent)
|
||||
:HttpRequestHandler(parent) {}
|
||||
@ -53,7 +54,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
if(!session.isNull() && session.contains("ySession"))
|
||||
{
|
||||
if(library.indexIn(path)!=-1 && DBHelper::getLibraries().count() > library.cap(1).toInt() )
|
||||
if(library.indexIn(path)!=-1 && DBHelper::getLibraries().contains(library.cap(1).toInt()) )
|
||||
{
|
||||
//listar el contenido del folder
|
||||
if(folder.exactMatch(path))
|
||||
@ -89,4 +90,4 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user