| 14 | } |
| 15 | |
| 16 | void ConsoleUILibraryCreator::createLibrary(const QString &name, const QString &path) |
| 17 | { |
| 18 | QDir pathDir(path); |
| 19 | if (!pathDir.exists()) { |
| 20 | std::cout << "Directory not found." << std::endl; |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | QEventLoop eventLoop; |
| 25 | LibraryCreator *libraryCreator = new LibraryCreator(settings); |
| 26 | QString cleanPath = QDir::cleanPath(pathDir.absolutePath()); |
| 27 | |
| 28 | YACReaderLibraries yacreaderLibraries; |
| 29 | yacreaderLibraries.load(); |
| 30 | if (yacreaderLibraries.contains(name)) { |
| 31 | std::cout << "A Library named \"" << name.toUtf8().constData() << "\" already exists in database." << std::endl; |
| 32 | delete libraryCreator; |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | libraryCreator->createLibrary(cleanPath, LibraryPaths::libraryDataPath(cleanPath)); |
| 37 | |
| 38 | connect(libraryCreator, &LibraryCreator::finished, this, &ConsoleUILibraryCreator::done); |
| 39 | connect(libraryCreator, &LibraryCreator::comicAdded, this, &ConsoleUILibraryCreator::newComic); |
| 40 | connect(libraryCreator, &LibraryCreator::failedCreatingDB, this, &ConsoleUILibraryCreator::manageCreatingError); |
| 41 | |
| 42 | connect(libraryCreator, &LibraryCreator::finished, &eventLoop, &QEventLoop::quit); |
| 43 | |
| 44 | std::cout << "Processing comics"; |
| 45 | |
| 46 | libraryCreator->start(); |
| 47 | eventLoop.exec(); |
| 48 | |
| 49 | yacreaderLibraries.addLibrary(name, cleanPath); |
| 50 | yacreaderLibraries.save(); |
| 51 | } |
| 52 | |
| 53 | void ConsoleUILibraryCreator::updateLibrary(const QString &path) |
| 54 | { |
no test coverage detected