Older/WebApplication/VisitorRecordTableModel.cpp
amass 51bfddd40f
All checks were successful
Deploy / Build (push) Successful in 8m1s
add checkbox for view.
2024-11-28 23:39:15 +08:00

55 lines
1.9 KiB
C++

#include "VisitorRecordTableModel.h"
#include "BoostLog.h"
int VisitorRecordTableModel::columnCount(const Wt::WModelIndex &parent) const {
return 5;
}
int VisitorRecordTableModel::rowCount(const Wt::WModelIndex &parent) const {
return 50;
}
Wt::WFlags<Wt::ItemFlag> VisitorRecordTableModel::flags(const Wt::WModelIndex &index) const {
if (index.column() == 0) {
return Wt::ItemFlag::UserCheckable | Wt::ItemFlag::Selectable;
} else {
return Wt::ItemFlag::Selectable;
}
}
Wt::WFlags<Wt::HeaderFlag> VisitorRecordTableModel::headerFlags(int section, Wt::Orientation orientation) const {
if (section == 0 && orientation== Wt::Orientation::Horizontal) {
return Wt::HeaderFlag::UserCheckable|Wt::HeaderFlag::XHTMLText;
} else {
return Wt::HeaderFlag::XHTMLText;
}
}
Wt::cpp17::any VisitorRecordTableModel::headerData(int section, Wt::Orientation orientation, Wt::ItemDataRole role) const {
if ((role == Wt::ItemDataRole::Checked || role == Wt::ItemDataRole::Edit) &&
section == 0) { // Assuming first column for checkbox
return true;
} else if ((role == Wt::ItemDataRole::Display || role == Wt::ItemDataRole::Edit) &&
section == 0) { // Assuming first column for checkbox
return Wt::cpp17::any{};
} else {
return Wt::cpp17::any{};
}
}
Wt::cpp17::any VisitorRecordTableModel::data(const Wt::WModelIndex &index, Wt::ItemDataRole role) const {
LOG(info) << "VisitorRecordTableModel: " << role.value();
if ((role == Wt::ItemDataRole::Checked || role == Wt::ItemDataRole::Edit) &&
index.column() == 0) { // Assuming first column for checkbox
return true;
} else if ((role == Wt::ItemDataRole::Checked || role == Wt::ItemDataRole::Edit) &&
index.column() == 1) { // Assuming first column for checkbox
return false;
} else {
return Wt::cpp17::any{};
}
}