Older/WebApplication/model/VisitorRecordTableModel.h

35 lines
1.8 KiB
C
Raw Normal View History

2024-11-28 19:34:24 +08:00
#ifndef __VISITORRECORDTABLEMODEL_H__
#define __VISITORRECORDTABLEMODEL_H__
2024-11-29 20:01:10 +08:00
#include "Database/VisitorRecord.h"
2024-11-28 19:34:24 +08:00
#include <Wt/WAbstractTableModel.h>
2024-11-29 20:01:10 +08:00
class Session;
2024-11-28 19:34:24 +08:00
class VisitorRecordTableModel : public Wt::WAbstractTableModel {
public:
2024-11-29 20:01:10 +08:00
VisitorRecordTableModel(Session &session);
2024-11-28 19:34:24 +08:00
Wt::cpp17::any data(const Wt::WModelIndex &index, Wt::ItemDataRole role = Wt::ItemDataRole::Display) const final;
2024-11-29 20:01:10 +08:00
bool setData(const Wt::WModelIndex &index, const Wt::cpp17::any &value, Wt::ItemDataRole role = Wt::ItemDataRole::Edit) final;
2024-11-28 19:34:24 +08:00
int columnCount(const Wt::WModelIndex &parent = Wt::WModelIndex()) const final;
int rowCount(const Wt::WModelIndex &parent = Wt::WModelIndex()) const final;
2024-11-28 23:39:15 +08:00
Wt::WFlags<Wt::ItemFlag> flags(const Wt::WModelIndex &index) const final;
Wt::WFlags<Wt::HeaderFlag> headerFlags(int section, Wt::Orientation orientation = Wt::Orientation::Horizontal) const final;
Wt::cpp17::any headerData(int section, Wt::Orientation orientation = Wt::Orientation::Horizontal,
Wt::ItemDataRole role = Wt::ItemDataRole::Display) const final;
2024-11-29 20:01:10 +08:00
bool setHeaderData(int section, Wt::Orientation orientation, const Wt::cpp17::any &value,
Wt::ItemDataRole role = Wt::ItemDataRole::Edit) final;
void sort(int column, Wt::SortOrder order = Wt::SortOrder::Ascending) final;
2024-12-01 15:10:25 +08:00
Wt::WModelIndexSet selectedIndexes() const;
2025-01-17 02:55:03 +08:00
void filter(const std::string &search);
2024-11-29 20:01:10 +08:00
2024-12-01 15:10:25 +08:00
bool removeRows(int row, int count, const Wt::WModelIndex &parent = Wt::WModelIndex()) final;
bool removeSelectedRows(const Wt::WModelIndexSet &indexes);
2024-11-29 20:01:10 +08:00
private:
Session &m_session;
using Item = std::tuple<VisitorRecord, bool>;
std::vector<Item> m_records;
bool m_selectAll = false;
2024-11-28 19:34:24 +08:00
};
#endif // __VISITORRECORDTABLEMODEL_H__