mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
delete books with simple ui
add a column at the book's list's table with "delete" button. This ui is temporary. On click, this button sends the id of the selected book at the ContentManager class which gets book by this id, and erases all files in relationship with this book on the computer.
This commit is contained in:
parent
3a425980ef
commit
2848fc1e43
@ -74,6 +74,9 @@ function init() {
|
|||||||
downloadUpdaters[book.id] = setInterval(function() { getDownloadInfo(book.id); }, 1000);
|
downloadUpdaters[book.id] = setInterval(function() { getDownloadInfo(book.id); }, 1000);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
eraseBook : function(book) {
|
||||||
|
contentManager.eraseBook(book.id);
|
||||||
|
},
|
||||||
displayedBooks : function(books, nb) {
|
displayedBooks : function(books, nb) {
|
||||||
var a = books.slice(0, nb);
|
var a = books.slice(0, nb);
|
||||||
return a;
|
return a;
|
||||||
@ -215,6 +218,7 @@ details:hover {
|
|||||||
</div>
|
</div>
|
||||||
<div id="bookTable">
|
<div id="bookTable">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
<span class="tablecell cell0">icone poubelle</span>
|
||||||
<span class="tablecell cell0"></span>
|
<span class="tablecell cell0"></span>
|
||||||
<span class="tablecell cell1">File name</span>
|
<span class="tablecell cell1">File name</span>
|
||||||
<span class="tablecell cell2">Size</span>
|
<span class="tablecell cell2">Size</span>
|
||||||
@ -225,6 +229,9 @@ details:hover {
|
|||||||
<div id="bookList" onscroll=scrolled(this)>
|
<div id="bookList" onscroll=scrolled(this)>
|
||||||
<details v-for="book in displayedBooks(books, displayedBooksNb)" class="book">
|
<details v-for="book in displayedBooks(books, displayedBooksNb)" class="book">
|
||||||
<summary class="tablerow">
|
<summary class="tablerow">
|
||||||
|
<span class="tablecell cell0">
|
||||||
|
<button v-if="book.path" v-on:click="eraseBook(book)">Delete</button>
|
||||||
|
</span>
|
||||||
<span class="tablecell cell0">
|
<span class="tablecell cell0">
|
||||||
<img v-if="book.faviconUrl" v-bind:src="'http://' + book.faviconUrl" />
|
<img v-if="book.faviconUrl" v-bind:src="'http://' + book.faviconUrl" />
|
||||||
<img v-else-if="book.faviconMimeType" v-bind:src="'zim://' + book.id + '.favicon.meta'" />
|
<img v-else-if="book.faviconMimeType" v-bind:src="'zim://' + book.id + '.favicon.meta'" />
|
||||||
|
@ -25,7 +25,6 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader,
|
|||||||
connect(this, &ContentManager::filterParamsChanged, this, &ContentManager::updateLibrary);
|
connect(this, &ContentManager::filterParamsChanged, this, &ContentManager::updateLibrary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ContentManager::setLocal(bool local) {
|
void ContentManager::setLocal(bool local) {
|
||||||
if (local == m_local) {
|
if (local == m_local) {
|
||||||
return;
|
return;
|
||||||
@ -185,10 +184,23 @@ QString ContentManager::downloadBook(const QString &id)
|
|||||||
mp_library->addBookToLibrary(book);
|
mp_library->addBookToLibrary(book);
|
||||||
mp_library->save();
|
mp_library->save();
|
||||||
emit(mp_library->booksChanged());
|
emit(mp_library->booksChanged());
|
||||||
emit(booksChanged());
|
|
||||||
return QString::fromStdString(download->getDid());
|
return QString::fromStdString(download->getDid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentManager::eraseBook(const QString& id)
|
||||||
|
{
|
||||||
|
kiwix::Book book = mp_library->getBookById(id);
|
||||||
|
QString dirName = QString::fromUtf8(getDataDirectory().c_str());
|
||||||
|
QString fileSelection = QString::fromUtf8(getLastPathElement(book.getPath()).c_str()) + "*";
|
||||||
|
QDir dir(dirName, fileSelection);
|
||||||
|
for(const QString& filename: dir.entryList()) {
|
||||||
|
dir.remove(filename);
|
||||||
|
}
|
||||||
|
mp_library->removeBookFromLibraryById(id);
|
||||||
|
mp_library->save();
|
||||||
|
emit(mp_library->booksChanged());
|
||||||
|
}
|
||||||
|
|
||||||
QStringList ContentManager::getDownloadIds()
|
QStringList ContentManager::getDownloadIds()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
@ -51,6 +51,7 @@ public slots:
|
|||||||
QString downloadBook(const QString& id);
|
QString downloadBook(const QString& id);
|
||||||
void updateLibrary();
|
void updateLibrary();
|
||||||
void setSearch(const QString& search);
|
void setSearch(const QString& search);
|
||||||
|
void eraseBook(const QString& id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTENTMANAGER_H
|
#endif // CONTENTMANAGER_H
|
||||||
|
@ -113,6 +113,10 @@ void Library::addBookToLibrary(kiwix::Book &book)
|
|||||||
m_library.addBook(book);
|
m_library.addBook(book);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Library::removeBookFromLibraryById(const QString& id) {
|
||||||
|
m_library.removeBookById(id.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
void Library::addBookmark(kiwix::Bookmark &bookmark)
|
void Library::addBookmark(kiwix::Bookmark &bookmark)
|
||||||
{
|
{
|
||||||
m_library.addBookmark(bookmark);
|
m_library.addBookmark(bookmark);
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
QStringList listBookIds(const QString& query, const QString &categoryFilter);
|
QStringList listBookIds(const QString& query, const QString &categoryFilter);
|
||||||
const std::vector<kiwix::Bookmark>& getBookmarks() { return m_library.getBookmarks(); }
|
const std::vector<kiwix::Bookmark>& getBookmarks() { return m_library.getBookmarks(); }
|
||||||
void addBookToLibrary(kiwix::Book& book);
|
void addBookToLibrary(kiwix::Book& book);
|
||||||
|
void removeBookFromLibraryById(const QString& id);
|
||||||
void addBookmark(kiwix::Bookmark& bookmark);
|
void addBookmark(kiwix::Bookmark& bookmark);
|
||||||
void removeBookmark(const QString& zimId, const QString& url);
|
void removeBookmark(const QString& zimId, const QString& url);
|
||||||
void save();
|
void save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user