mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
46 lines
1.1 KiB
C++
46 lines
1.1 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; }
|
|
};
|
|
|
|
struct RecentBookWithCover {
|
|
RecentBook book;
|
|
std::string coverBmpPath;
|
|
};
|
|
|
|
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);
|
|
|
|
// 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()
|