aboutsummaryrefslogtreecommitdiff
path: root/works/life/cpp-practicum/Record.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-30 17:23:15 +0800
committercrupest <crupest@outlook.com>2020-12-30 17:23:15 +0800
commitd0b6d6377de44484568af2ef3a3bbd4da7cdfb4b (patch)
treeee87702ec50a5c5a26ee8fb446bd4995082bd792 /works/life/cpp-practicum/Record.hpp
parent1e148e88abe8aca881590f4b9d992a2f03587ed7 (diff)
downloadcrupest-d0b6d6377de44484568af2ef3a3bbd4da7cdfb4b.tar.gz
crupest-d0b6d6377de44484568af2ef3a3bbd4da7cdfb4b.tar.bz2
crupest-d0b6d6377de44484568af2ef3a3bbd4da7cdfb4b.zip
import(life): ...
Diffstat (limited to 'works/life/cpp-practicum/Record.hpp')
-rw-r--r--works/life/cpp-practicum/Record.hpp35
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