summaryrefslogtreecommitdiff
path: root/client/widgets/multilist.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/multilist.cc')
-rw-r--r--client/widgets/multilist.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index dbc23b9..4d34691 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -26,6 +26,7 @@
*/
#include "multilist.h"
+#include <QMessageBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
@@ -38,6 +39,8 @@
MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
: QFrame(), Widget(node, macrowindow)
{
+ innerwidget_has_changes = false;
+
setCommonAttributes(this, node);
QGridLayout *layout = new QGridLayout();
@@ -97,7 +100,10 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
QString iwname = elem.attribute("innerwidget");
QVector< Widget* >::iterator ws = widgets.begin();
while(ws != widgets.end()) {
- if((*ws)->getName() == iwname) innerwidget = *ws;
+ if((*ws)->getName() == iwname) {
+ innerwidget = *ws;
+ innerwidget->connectFrom(SIGNAL(wasChanged()), this, SLOT(changed()));
+ }
ws++;
}
if(innerwidget == NULL) {
@@ -113,6 +119,41 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
void MultiList::changed()
{
+ innerwidget_has_changes = true;
+ printf("Multilist innerwidget was changed\n");
+}
+
+
+bool MultiList::isValid()
+{
+ if(innerwidget_has_changes) {
+ switch(QMessageBox::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?",
+ QMessageBox::Save | QMessageBox::Close | QMessageBox::Cancel)) {
+ case QMessageBox::Save:
+ if(innerwidget && innerwidget->isValid()) {
+ add();
+ } else {
+ QMessageBox::critical(NULL,
+ "Fejl",
+ "Der er fejl i ændringen, og den kan ikke tilføjes til listen.\n",
+ QMessageBox::Ok);
+ return false;
+ }
+ break;
+ case QMessageBox::Close:
+ break;
+ case QMessageBox::Cancel:
+ default:
+ // FIXME: How to we actually block the commit and return to the editor?
+ return false;
+ break;
+ }
+ }
+
+ return regexpValidator() && luaValidator();
}
QString MultiList::getValue()
@@ -166,6 +207,7 @@ void MultiList::add()
emit wasChanged();
innerwidget->reset();
+ innerwidget_has_changes = false;
}
}