diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-07-26 21:50:41 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-07-26 22:06:04 +0200 |
| commit | ba31faa55abedea506443df821e32aff93378c15 (patch) | |
| tree | ef192cd7b1c1fcc87ed8238353ea40c5f3e1dc32 /src/gui_qt.cc | |
| parent | 629bd9dbd099af60812e80f851afb7902fc28c37 (diff) | |
Add GuiForm::Listener::changed which is called whenever a value is changed
Diffstat (limited to 'src/gui_qt.cc')
| -rw-r--r-- | src/gui_qt.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui_qt.cc b/src/gui_qt.cc index 3e7c696..cad859e 100644 --- a/src/gui_qt.cc +++ b/src/gui_qt.cc @@ -1021,13 +1021,18 @@ protected: static_cast<FileValue*>(value.get())->value_)); break; } + auto vp = value.get(); + edit->connect(edit, &QLineEdit::textChanged, + [=](QString const& UNUSED(text)) { + notify_changed(vp->id_); + }); layout->addWidget(label, row, 0); if (value->type_ == FILE) { auto button = new QPushButton("..."); edit->setReadOnly(true); dialog_->connect(button, &QPushButton::clicked, - [this,&value](bool UNUSED(checked)) { - showFileDialog(static_cast<FileValue*>(value.get())); + [=](bool UNUSED(checked)) { + showFileDialog(static_cast<FileValue*>(vp)); }); layout->addWidget(edit, row, 1); layout->addWidget(button, row, 2); @@ -1088,6 +1093,13 @@ protected: return true; } + void notify_changed(std::string const& id) { + auto it = observers_.notify(); + while (it.has_next()) { + it.next()->changed(this, id); + } + } + virtual int add_extra_widgets(QGridLayout*, int row, int UNUSED(columns)) { return row; } |
