aboutsummaryrefslogtreecommitdiff
path: root/works/life/cpp-practicum/Record.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-30 20:04:07 +0800
committercrupest <crupest@outlook.com>2020-12-30 20:04:07 +0800
commit6469683b4cca6aaae9d27e34c17b8f75a988fa81 (patch)
tree4439c87658790948bd9028df5acb9de3d840d431 /works/life/cpp-practicum/Record.hpp
parent5dc5500d0a31497f69404c463f39e44f8a70f3df (diff)
downloadcrupest-6469683b4cca6aaae9d27e34c17b8f75a988fa81.tar.gz
crupest-6469683b4cca6aaae9d27e34c17b8f75a988fa81.tar.bz2
crupest-6469683b4cca6aaae9d27e34c17b8f75a988fa81.zip
import(life): ...
Diffstat (limited to 'works/life/cpp-practicum/Record.hpp')
-rw-r--r--works/life/cpp-practicum/Record.hpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/works/life/cpp-practicum/Record.hpp b/works/life/cpp-practicum/Record.hpp
index 78b70ba..c379f04 100644
--- a/works/life/cpp-practicum/Record.hpp
+++ b/works/life/cpp-practicum/Record.hpp
@@ -5,7 +5,7 @@
#include "Vendor.hpp"
#include <QAbstractTableModel>
-#include <QFile>
+#include <QTextStream>
#include <optional>
#include <vector>
@@ -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<Book> &GetBooks() { return books_; }
std::vector<Vendor> &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_;
+};