Status: Implemented
This document describes the tagging feature in Bibliotheca.
The database schema includes two tables for tagging support.
A tags table stores all available tags.
CREATE TABLE IF NOT EXISTS tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE
);
A book_tags junction table associates tags with books.
CREATE TABLE IF NOT EXISTS book_tags (
book_id TEXT NOT NULL,
tag_id INTEGER NOT NULL,
FOREIGN KEY (book_id) REFERENCES books(id) ON DELETE CASCADE,
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE,
PRIMARY KEY (book_id, tag_id)
);
The Book class in Book.hpp includes a tags vector:
class Book {
// ... existing members
std::vector<std::string> m_tags;
};
The DatabaseManager provides these tag methods:
add_tag_to_book(book_id, tag_name) - Associates a tag with a book (creates tag if needed)remove_tag_from_book(book_id, tag_name) - Removes a tag associationget_tags_for_book(book_id) - Returns all tags for a bookload_all_books() - Returns all books with their tags loadedThe BookDetails widget (src/BookDetails.cpp) provides:
The BibliothecaWindow navigates to BookDetails when a book is activated:
onBookActivated() calls m_bookDetails->set_book() and switches to details viewBookDetails view by typing in the entry and clicking "Add Tag"tag:fiction syntax filters to only books with matching tags