36 std::function<void()> mNewCallback;
43 Builder& withNewButton(
const std::function<
void()>& onNew) {
47 Builder& withModifyButton(
const std::function<
void(
const AListModelIndex&)>& onModify) {
48 mModifyCallback = onModify;
59 WindowStyle::NO_RESIZE |
60 WindowStyle::NO_MINIMIZE_MAXIMIZE);
65 auto c = _new<ABasicListEditor>();
66 auto list = _new<AListView>(mModel);
69 auto modifyButton = mModifyCallback ? _new<AButton>(
"Modify...").connect(&
AView::clicked, c, [callback = mModifyCallback, list] {
70 callback(list->getSelectionModel().first());
75 removeButton = _new<AButton>(
"Remove").connect(&
AView::clicked, c, [list, model] {
76 model->removeItems(list->getSelectionModel());
80 if (mModel->listSize() != 0) {
83 AUI_NULLSAFE(removeButton)->disable();
84 AUI_NULLSAFE(modifyButton)->disable();
86 auto updateEnabledState = [list, modifyButton, removeButton]() {
87 auto& s = list->getSelectionModel().getIndices();
88 AUI_NULLSAFE(modifyButton)->setDisabled(s.empty());
89 AUI_NULLSAFE(removeButton)->setDisabled(s.empty());
91 connect(list->selectionChanged, c, updateEnabledState);
92 connect(mModel->dataRemoved, c, updateEnabledState);
93 connect(mModel->dataInserted, c, updateEnabledState);
95 c->setContents(Horizontal {
98 mNewCallback ? _new<AButton>(
"New...").connect(&
AView::clicked, c, [callback = mNewCallback] {