From 630a65e4b0899515bc61b03d9ea25a024c87e75a Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 30 Dec 2020 20:04:07 +0800 Subject: ... --- cpp-practicum/Record.hpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'cpp-practicum/Record.hpp') diff --git a/cpp-practicum/Record.hpp b/cpp-practicum/Record.hpp index 78b70ba..c379f04 100644 --- a/cpp-practicum/Record.hpp +++ b/cpp-practicum/Record.hpp @@ -5,7 +5,7 @@ #include "Vendor.hpp" #include -#include +#include #include #include @@ -19,8 +19,8 @@ public: ~Record() = default; public: - void WriteTo(QFile file); - void ReadFrom(QFile file); + void WriteTo(QTextStream &stream); + void ReadFrom(QTextStream &stream); std::vector &GetBooks() { return books_; } std::vector &GetVendors() { return vendors_; } @@ -47,7 +47,30 @@ public: const QModelIndex &parent = QModelIndex()) override; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; private: Record *record_; -}; \ No newline at end of file +}; + +class VendorModel : public QAbstractTableModel { +public: + explicit VendorModel(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_; +}; -- cgit v1.2.3