mirror of
https://github.com/YACReader/yacreader
synced 2025-07-21 06:24:39 -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:
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;
|
||||
}
|
Reference in New Issue
Block a user