diff options
author | crupest <crupest@outlook.com> | 2020-12-30 17:23:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-12-30 17:23:15 +0800 |
commit | a5a3bb42dc812e9c57baf85fbc5960f4b55c3206 (patch) | |
tree | 5a0f2d69c41a4470a3e0e3d75e71cb24ad153020 /cpp-practicum/Record.hpp | |
parent | da40ea05ecee7e9a8478b672263ed7217cabbed4 (diff) | |
download | life-a5a3bb42dc812e9c57baf85fbc5960f4b55c3206.tar.gz life-a5a3bb42dc812e9c57baf85fbc5960f4b55c3206.tar.bz2 life-a5a3bb42dc812e9c57baf85fbc5960f4b55c3206.zip |
...
Diffstat (limited to 'cpp-practicum/Record.hpp')
-rw-r--r-- | cpp-practicum/Record.hpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/cpp-practicum/Record.hpp b/cpp-practicum/Record.hpp index e39e626..78b70ba 100644 --- a/cpp-practicum/Record.hpp +++ b/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 |