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;
|
|
|
|
|
|
|
|
std::vector<VisitorRecord> selected() const;
|
|
|
|
void removeSelected();
|
|
|
|
|
|
|
|
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__
|