mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added new class for creating and updating libraries using command line, the opearion progress is shown in the console. TODO add the library to the settings files
This commit is contained in:
parent
2b4c972219
commit
a5baa5278e
@ -78,7 +78,8 @@ HEADERS += library_creator.h \
|
||||
comics_remover.h \
|
||||
../common/http_worker.h \
|
||||
yacreader_libraries.h \
|
||||
comic_files_manager.h
|
||||
comic_files_manager.h \
|
||||
headless/console_ui_library_creator.h
|
||||
|
||||
|
||||
SOURCES += library_creator.cpp \
|
||||
@ -98,7 +99,8 @@ SOURCES += library_creator.cpp \
|
||||
../common/http_worker.cpp \
|
||||
../common/yacreader_global.cpp \
|
||||
yacreader_libraries.cpp \
|
||||
comic_files_manager.cpp
|
||||
comic_files_manager.cpp \
|
||||
headless/console_ui_library_creator.cpp
|
||||
|
||||
|
||||
include(./server/server.pri)
|
||||
@ -122,6 +124,9 @@ TRANSLATIONS = yacreaderlibraryserver_es.ts \
|
||||
yacreaderlibraryserver_source.ts
|
||||
|
||||
|
||||
RESOURCES += headless/images.qrc
|
||||
|
||||
|
||||
Release:DESTDIR = ../release
|
||||
Debug:DESTDIR = ../debug
|
||||
|
||||
|
55
YACReaderLibrary/headless/console_ui_library_creator.cpp
Normal file
55
YACReaderLibrary/headless/console_ui_library_creator.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "console_ui_library_creator.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "library_creator.h"
|
||||
|
||||
|
||||
|
||||
ConsoleUILibraryCreator::ConsoleUILibraryCreator(QObject *parent) :
|
||||
QObject(parent), numComicsProcessed(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ConsoleUILibraryCreator::createLibrary(const QString & name, const QString & path)
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
LibraryCreator * libraryCreator = new LibraryCreator();
|
||||
|
||||
libraryCreator->createLibrary(QDir::cleanPath(path),QDir::cleanPath(path)+"/.yacreaderlibrary");
|
||||
|
||||
connect(libraryCreator, &LibraryCreator::finished, this, &ConsoleUILibraryCreator::done);
|
||||
connect(libraryCreator, &LibraryCreator::comicAdded, this, &ConsoleUILibraryCreator::newComic);
|
||||
connect(libraryCreator, &LibraryCreator::failedCreatingDB, this, &ConsoleUILibraryCreator::manageCreatingError);
|
||||
|
||||
connect(libraryCreator, &LibraryCreator::finished, &eventLoop, &QEventLoop::quit);
|
||||
|
||||
std::cout << "Processing comics";
|
||||
|
||||
libraryCreator->start();
|
||||
eventLoop.exec();
|
||||
}
|
||||
|
||||
void ConsoleUILibraryCreator::updateLibrary(const QString & path)
|
||||
{
|
||||
//TODO
|
||||
//connect(libraryCreator,SIGNAL(failedUpdatingDB(QString)),this,SLOT(manageUpdatingError(QString)));
|
||||
}
|
||||
|
||||
void ConsoleUILibraryCreator::newComic(const QString & relativeComicPath, const QString & coverPath)
|
||||
{
|
||||
numComicsProcessed++;
|
||||
std::cout << ".";
|
||||
}
|
||||
|
||||
void ConsoleUILibraryCreator::manageCreatingError(const QString & error)
|
||||
{
|
||||
std::cout << std::endl << "Error creating library! " << error.toUtf8().constData();
|
||||
}
|
||||
|
||||
void ConsoleUILibraryCreator::done()
|
||||
{
|
||||
std::cout << "Done!" << std::endl;
|
||||
std::cout << "Number of comis processed = " << numComicsProcessed << std::endl;
|
||||
}
|
26
YACReaderLibrary/headless/console_ui_library_creator.h
Normal file
26
YACReaderLibrary/headless/console_ui_library_creator.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef CONSOLE_UI_LIBRARY_CREATOR_H
|
||||
#define CONSOLE_UI_LIBRARY_CREATOR_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class ConsoleUILibraryCreator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConsoleUILibraryCreator(QObject *parent = 0);
|
||||
void createLibrary(const QString & name, const QString & path);
|
||||
void updateLibrary(const QString & path);
|
||||
|
||||
private:
|
||||
uint numComicsProcessed;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected slots:
|
||||
void newComic(const QString & relativeComicPath, const QString & coverPath);
|
||||
void manageCreatingError(const QString & error);
|
||||
void done();
|
||||
};
|
||||
|
||||
#endif // CONSOLE_UI_LIBRARY_CREATOR_H
|
Loading…
x
Reference in New Issue
Block a user