1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#if defined(Hiro_TableView)
namespace hiro {
auto pTableViewColumn::construct() -> void {
if(auto parent = _parent()) {
auto lock = parent->acquire();
//parent->qtTableView->setAlternatingRowColors(parent->self().columnCount() >= 2);
parent->qtTableView->setColumnCount(parent->self().columnCount());
for(auto& column : parent->state().columns) {
if(auto delegate = column->self()) {
delegate->setIcon(delegate->state().icon);
delegate->setText(delegate->state().text); //also handles setSorting();
delegate->_setState();
}
}
}
}
auto pTableViewColumn::destruct() -> void {
}
auto pTableViewColumn::setActive() -> void {
//unsupported
}
auto pTableViewColumn::setAlignment(Alignment alignment) -> void {
_setState();
}
auto pTableViewColumn::setBackgroundColor(Color color) -> void {
_setState();
}
auto pTableViewColumn::setEditable(bool editable) -> void {
//unsupported
}
auto pTableViewColumn::setExpandable(bool expandable) -> void {
_setState();
}
auto pTableViewColumn::setFont(const Font& font) -> void {
_setState();
}
auto pTableViewColumn::setForegroundColor(Color color) -> void {
_setState();
}
auto pTableViewColumn::setHorizontalAlignment(double alignment) -> void {
_setState();
}
auto pTableViewColumn::setIcon(const image& icon) -> void {
if(auto parent = _parent()) {
parent->qtTableView->headerItem()->setIcon(self().offset(), CreateIcon(icon));
}
}
auto pTableViewColumn::setResizable(bool resizable) -> void {
_setState();
}
auto pTableViewColumn::setSorting(Sort) -> void {
if(auto parent = _parent()) {
string label = state().text;
if(state().sorting == Sort::Ascending ) label.append(" \u25b4");
if(state().sorting == Sort::Descending) label.append(" \u25be");
parent->qtTableView->headerItem()->setText(self().offset(), QString::fromUtf8(label));
}
}
auto pTableViewColumn::setText(const string&) -> void {
if(auto parent = _parent()) {
string label = state().text;
if(state().sorting == Sort::Ascending ) label.append(" \u25b4");
if(state().sorting == Sort::Descending) label.append(" \u25be");
parent->qtTableView->headerItem()->setText(self().offset(), QString::fromUtf8(label));
}
}
auto pTableViewColumn::setVerticalAlignment(double alignment) -> void {
_setState();
}
auto pTableViewColumn::setVisible(bool visible) -> void {
_setState();
}
auto pTableViewColumn::setWidth(s32 width) -> void {
_setState();
}
auto pTableViewColumn::_parent() -> maybe<pTableView&> {
if(auto parent = self().parentTableView()) {
if(auto delegate = parent->self()) return *delegate;
}
return {};
}
auto pTableViewColumn::_setState() -> void {
if(auto parent = _parent()) {
auto lock = parent->acquire();
#if HIRO_QT==4
parent->qtTableView->header()->setResizeMode(self().offset(), state().resizable ? QHeaderView::Interactive : QHeaderView::Fixed);
#elif HIRO_QT==5
parent->qtTableView->header()->setSectionResizeMode(self().offset(), state().resizable ? QHeaderView::Interactive : QHeaderView::Fixed);
#endif
parent->qtTableView->setColumnHidden(self().offset(), !self().visible());
for(auto& item : parent->state().items) {
if(auto cell = item->cell(self().offset())) {
if(auto self = cell->self()) self->_setState();
}
}
}
}
}
#endif
|