addButton(tr("Add books from folder"), this,
SLOT(onAddFolder()), "folder");
addButton(tr("Search the Web"), this, SLOT(onSearch()), "search");
+ addItemButton(tr("Delete"), this, SLOT(onDelete()), "delete");
// Set selected item
Library *library = Library::instance();
}
}
+void LibraryDialog::onDelete()
+{
+ QModelIndex current = currentItem();
+ if (!current.isValid()) {
+ return;
+ }
+ QModelIndex libraryIndex = sortedLibrary->mapToSource(current);
+ Book *book = Library::instance()->book(libraryIndex);
+ if (QMessageBox::Yes !=
+ QMessageBox::question(this, tr("Delete book"),
+ tr("Delete book \"%1\"?").arg(book->shortName()),
+ QMessageBox::Yes | QMessageBox::No)) {
+ return;
+ }
+ Library::instance()->remove(libraryIndex);
+}
+
QString LibraryDialog::createItemText(Book *book)
{
Q_ASSERT(book);