Files
crosspoint-reader-mod/src/RecentBooksStore.h
cottongin 4627ec95f9 fix: resolve mod build errors after upstream sync
- Update open-x4-sdk submodule to 9f76376 (BatteryMonitor ESP-IDF 5.x compat)
- Add RTC_NOINIT bounds check for logHead in Logging.cpp
- Add drawTextRotated90CCW to GfxRenderer for dictionary UI
- Add getWordXpos() accessor to TextBlock for dictionary word selection
- Fix bare include paths (ActivityResult.h, RenderLock.h) across 10 files
- Fix rvalue ref binding in setResult() lambdas (std::move pattern)
- Fix std::max type mismatch (uint8_t vs int) in EpubReaderActivity
- Fix FsFile forward declaration conflict in Dictionary.h
- Restore StringUtils::checkFileExtension() and sortFileList()
- Restore RecentBooksStore::removeBook()

Made-with: Cursor
2026-03-07 20:56:40 -05:00

59 lines
1.6 KiB
C++

#pragma once
#include <string>
#include <vector>
struct RecentBook {
std::string path;
std::string title;
std::string author;
std::string coverBmpPath;
bool operator==(const RecentBook& other) const { return path == other.path; }
};
class RecentBooksStore;
namespace JsonSettingsIO {
bool loadRecentBooks(RecentBooksStore& store, const char* json);
} // namespace JsonSettingsIO
class RecentBooksStore {
// Static instance
static RecentBooksStore instance;
std::vector<RecentBook> recentBooks;
friend bool JsonSettingsIO::loadRecentBooks(RecentBooksStore&, const char*);
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,
const std::string& coverBmpPath);
void updateBook(const std::string& path, const std::string& title, const std::string& author,
const std::string& coverBmpPath);
void removeBook(const std::string& path);
// 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();
RecentBook getDataFromBook(std::string path) const;
private:
bool loadFromBinaryFile();
};
// Helper macro to access recent books store
#define RECENT_BOOKS RecentBooksStore::getInstance()