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.
This commit is contained in:
luddens 2019-08-06 17:08:58 +02:00 committed by Matthieu Gautier
parent 4ceccdc7df
commit f371dbd15d

View File

@ -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);