diff options
Diffstat (limited to 'works/life/cpp-practicum/Record.hpp')
-rw-r--r-- | works/life/cpp-practicum/Record.hpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/works/life/cpp-practicum/Record.hpp b/works/life/cpp-practicum/Record.hpp index e39e626..78b70ba 100644 --- a/works/life/cpp-practicum/Record.hpp +++ b/works/life/cpp-practicum/Record.hpp @@ -4,13 +4,14 @@ #include "Book.hpp"
#include "Vendor.hpp"
+#include <QAbstractTableModel>
#include <QFile>
#include <optional>
#include <vector>
class Record final {
public:
- Record();
+ Record() = default;
CRU_DEFAULT_COPY(Record);
CRU_DEFAULT_MOVE(Record);
@@ -21,16 +22,32 @@ public: void WriteTo(QFile file);
void ReadFrom(QFile file);
- const std::vector<Book> &GetBooks() const { return books_; }
- const std::vector<Vendor> &GetVendors() const { return vendors_; }
-
- // TODO: Implementation
- std::optional<Book> FindBookByIsbn(std::u16string_view isbn);
-
- // TODO: Implementation
- void RemoveBookByIsbn(std::u16string_view isbn);
+ std::vector<Book> &GetBooks() { return books_; }
+ std::vector<Vendor> &GetVendors() { return vendors_; }
private:
std::vector<Book> books_;
std::vector<Vendor> vendors_;
};
+
+class BookModel : public QAbstractTableModel {
+public:
+ explicit BookModel(Record *record) : record_(record) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const override;
+ QVariant data(const QModelIndex &index,
+ int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole) override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ bool insertRows(int row, int count,
+ const QModelIndex &parent = QModelIndex()) override;
+ bool removeRows(int row, int count,
+ const QModelIndex &parent = QModelIndex()) override;
+
+private:
+ Record *record_;
+};
\ No newline at end of file |