Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/adapters/controllers/library_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void LibraryController::syncWithServer()
}

int LibraryController::addBook(const QString& path, bool allowDuplicates,
int projectGutenbergId)
int projectGutenbergId, QString parentFolder)
{
auto localPath = QUrl(path).toLocalFile();
QFileInfo fileInfo(localPath);
Expand All @@ -134,7 +134,7 @@ int LibraryController::addBook(const QString& path, bool allowDuplicates,

QApplication::setOverrideCursor(Qt::WaitCursor);
auto result = m_libraryService->addBook(localPath, allowDuplicates,
projectGutenbergId);
projectGutenbergId, parentFolder);
QApplication::restoreOverrideCursor();

emit addingBookFinished(
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/controllers/library_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ADAPTERS_EXPORT LibraryController : public ILibraryController
LibraryController(application::ILibraryService* bookService);

int addBook(const QString& path, bool allowDuplicates = false,
int projectGutenbergId = 0) override;
int projectGutenbergId = 0, QString parentFolder = "") override;
int deleteBook(const QString& uuid) override;
int deleteAllBooks() override;
int uninstallBook(const QString& uuid) override;
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/interfaces/controllers/i_library_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class ADAPTERS_EXPORT ILibraryController : public QObject
Q_INVOKABLE virtual void syncWithServer() = 0;
Q_INVOKABLE virtual int addBook(const QString& path,
bool allowDuplicates = false,
int projectGutenbergId = 0) = 0;
int projectGutenbergId = 0,
QString parentFolder = "") = 0;
Q_INVOKABLE virtual int deleteBook(const QString& uuid) = 0;
Q_INVOKABLE virtual int deleteAllBooks() = 0;
Q_INVOKABLE virtual int uninstallBook(const QString& uuid) = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/application/interfaces/services/i_library_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class APPLICATION_EXPORT ILibraryService : public QObject
virtual void downloadBooks() = 0;
virtual BookOperationStatus addBook(const QString& filePath,
bool allowDuplicates,
int projectGutenbergId) = 0;
int projectGutenbergId,
QString parentFolder = "") = 0;
virtual BookOperationStatus deleteBook(const QUuid& uuid) = 0;
virtual BookOperationStatus deleteAllBooks() = 0;
virtual BookOperationStatus uninstallBook(const QUuid& uuid) = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/application/services/library_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void LibraryService::downloadBooks()

BookOperationStatus LibraryService::addBook(const QString& filePath,
bool allowDuplicates,
int projectGutenbergId)
int projectGutenbergId,
QString parentFolder)
{
auto success = m_bookMetadataHelper->setup(filePath);
if(!success)
Expand Down Expand Up @@ -147,6 +148,7 @@ BookOperationStatus LibraryService::addBook(const QString& filePath,
book.setHasCover(true);
book.setCoverPath(coverPath);
book.setProjectGutenbergId(projectGutenbergId);
book.setParentFolderId(QUuid(parentFolder));

addBookToLibrary(book);

Expand Down
3 changes: 2 additions & 1 deletion src/application/services/library_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class APPLICATION_EXPORT LibraryService : public ILibraryService
void downloadBooks() override;
BookOperationStatus addBook(const QString& filePath,
bool allowDuplicates = false,
int projectGutenbergId = 0) override;
int projectGutenbergId = 0,
QString parentFolder = "") override;
BookOperationStatus deleteBook(const QUuid& uuid) override;
BookOperationStatus deleteAllBooks() override;
BookOperationStatus uninstallBook(const QUuid& uuid) override;
Expand Down
12 changes: 7 additions & 5 deletions src/presentation/desktop/homePage/MHomePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ Page {
}

onLeftButtonClicked: LibraryController.addBook(
internal.lastAddedBookPath, true)
internal.lastAddedBookPath, true, 0,
LibraryController.libraryModel.folder)
}

MWarningPopup {
Expand Down Expand Up @@ -863,13 +864,14 @@ Page {
// adding is resumed by calling continueAddingBooks().
function addBooks(container) {
internal.booksCurrentlyAdding = container
for (var i = container.length - 1; i >= 0; i--) {
internal.lastAddedBookPath = container[i]
for (var i = internal.booksCurrentlyAdding.length - 1; i >= 0; i--) {
internal.lastAddedBookPath = internal.booksCurrentlyAdding[i]
let result = LibraryController.addBook(
internal.lastAddedBookPath)
internal.lastAddedBookPath, false, 0,
LibraryController.libraryModel.folder)

// Remove the already added book
container.splice(i, 1)
internal.booksCurrentlyAdding.splice(i, 1)

if (result === BookOperationStatus.OpeningBookFailed) {
unsupportedFilePopup.open()
Expand Down
Loading