- Add pill badge system for displaying file type and suffix tags - Add "Remove from Recents" option to remove individual books - Add "Clear All Recents" option to clear entire recents list - Add clearThumbExistsCache() for cache invalidation - Create BadgeConfig.h for customizable badge mappings - Add extractBookTags() utility for parsing filename badges - Add drawPillBadge() component for rendering badges
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct RecentBook {
|
|
std::string path;
|
|
std::string title;
|
|
std::string author;
|
|
|
|
bool operator==(const RecentBook& other) const { return path == other.path; }
|
|
};
|
|
|
|
class RecentBooksStore {
|
|
// Static instance
|
|
static RecentBooksStore instance;
|
|
|
|
std::vector<RecentBook> recentBooks;
|
|
|
|
public:
|
|
~RecentBooksStore() = default;
|
|
|
|
// Get singleton instance
|
|
static RecentBooksStore& getInstance() { return instance; }
|
|
|
|
// Add a book to the recent list (moves to front if already exists)
|
|
void addBook(const std::string& path, const std::string& title, const std::string& author);
|
|
|
|
// Remove a book path from the recent list (e.g., when archived or deleted)
|
|
// Returns true if the book was found and removed
|
|
bool removeBook(const std::string& path);
|
|
|
|
// Clear all recent books from the list
|
|
void clearAll();
|
|
|
|
// Get the list of recent books (most recent first)
|
|
const std::vector<RecentBook>& getBooks() const { return recentBooks; }
|
|
|
|
// Get the count of recent books
|
|
int getCount() const { return static_cast<int>(recentBooks.size()); }
|
|
|
|
bool saveToFile() const;
|
|
|
|
bool loadFromFile();
|
|
};
|
|
|
|
// Helper macro to access recent books store
|
|
#define RECENT_BOOKS RecentBooksStore::getInstance()
|