delete a book closes all tabs opened of it (#220)

delete a book closes all tabs opened of it
This commit is contained in:
Matthieu Gautier 2019-09-03 16:59:22 +02:00 committed by GitHub
commit cc0c8eeccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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