From 175d195c0ed56487322a03939a1c60cb05cb3f8e Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 13 Apr 2011 12:16:56 +0000 Subject: Introduce new committable/preCommit methods, that can be used to block a commit from inside the widgets. --- client/widgets/multilist.cc | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'client/widgets/multilist.cc') diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc index 3d03ce5..e261b52 100644 --- a/client/widgets/multilist.cc +++ b/client/widgets/multilist.cc @@ -126,36 +126,23 @@ void MultiList::changed() DEBUG(multilist, "Multilist innerwidget was changed\n"); } - -bool MultiList::preValid() +bool MultiList::preCommit() { - return list->count() != 0; - - /* if(innerwidget_has_changes) { switch(MessageBox::warning(NULL, - "Gem ændringerne i listen?", - "Der er lavet en ændring som ikke er tilføjet til listen.\n" - "Ønsker du at tilføje ændringen til listen inden du gemmer makroen?", - MessageBox::Save | MessageBox::Close | MessageBox::Cancel)) { - case MessageBox::Save: - if(innerwidget && innerwidget->valid()) { - add(); - } else { - return false; - } - break; - case MessageBox::Close: + tr("Inner widget changed."), + tr("The inner widget changed, and you didn't add it to the list.\n" + "Do you want to continue and discard the change?"), + MessageBox::Ignore | MessageBox::Cancel)) { + case MessageBox::Ignore: break; case MessageBox::Cancel: default: - // FIXME: How to we actually block the commit and return to the editor? return false; - break; } } + return true; - */ } QString MultiList::value() @@ -218,6 +205,12 @@ void MultiList::add() } } +void MultiList::setValues() +{ + Widget::setValues(); + innerwidget_has_changes = false; +} + bool MultiList::setKeyboardFocus() { if(innerwidget) return innerwidget->setKeyboardFocus(); -- cgit v1.2.3