From f371dbd15dd8d6f51a712520fc5cfdecdd9acb54 Mon Sep 17 00:00:00 2001 From: luddens Date: Tue, 6 Aug 2019 17:08:58 +0200 Subject: [PATCH] delete a book closes all tabs opened of it Before deleting a book, check all the tabs opened (except the first wich is the home tab and the last wich is the "new tab" button) and close those who have the same id of the book. --- src/contentmanager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 8c34052..a1d0f0f 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -218,6 +218,16 @@ void ContentManager::eraseBookFilesFromComputer(const QString fileToRemove) void ContentManager::eraseBook(const QString& id) { + auto tabBar = KiwixApp::instance()->getTabWidget(); + int i = 1; + while (i < tabBar->count() - 1) { + WebView* webView = tabBar->widget(i); + if (webView->zimId() == id) { + tabBar->closeTab(i); + } else { + i++; + } + } kiwix::Book book = mp_library->getBookById(id); QString fileToRemove = QString::fromUtf8(getLastPathElement(book.getPath()).c_str()) + "*"; eraseBookFilesFromComputer(fileToRemove);