summaryrefslogtreecommitdiff
path: root/client/macrowindow.cc
diff options
context:
space:
mode:
authordeva <deva>2009-01-13 09:59:22 +0000
committerdeva <deva>2009-01-13 09:59:22 +0000
commit9fcf15a06b9ec422dbad53508e8ce71d2d4145c3 (patch)
treed54147e52b1939ba9ebaf356e7047dfebea02887 /client/macrowindow.cc
parent9d982a5b4fc9c7efaa56c8f7a4130361f26b0302 (diff)
A huge amount of changes, based on the results of two usertest.
The changes are contained (but not limited to) in the following list: - Make disabled widgets ignored in validation test. - Do not commit values of disabled widgets to the database. - Make storechildren attribute on metawidget, that enables storing of the child widgets in the database. - Implement LUA resume generator. - Make language attribute on resume tag, and switch parser (format/LUA). - Case insensitive search in combobox. - Click on macro name or line, expands macro. - Greyed out widgets in AltComboBox should be hidden instead. - Keyboard 'delete' should delete item from multilist. - "Commit" button needs to be more visible? Icon? - Upon opening of a second macro, the first macro should indicate itself as 'not saved'. - After 'add' in multilist, the input widgets should be reset. - First widget in a macro should have keyboard focus after expansion. - "Endnu ikke udfyldt" needs to be more clear (darker). - Meta widgets must recurse the isValid() call to its children. - Greyed out widgets must be hidden. - Multilist should be read as a list prior to its input fields. - Visible field on widgets. Hides a widget without disabling it.
Diffstat (limited to 'client/macrowindow.cc')
-rw-r--r--client/macrowindow.cc154
1 files changed, 114 insertions, 40 deletions
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index ac44b06..2206929 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -47,6 +47,8 @@ MacroWindow::MacroWindow(NetCom *netcom, QDomNode &xml_doc, QString course,
bool collapsed, bool compact)
: Collapser()
{
+ waschanged = false;
+
this->course = course;
this->netcom = netcom;
@@ -115,7 +117,7 @@ void MacroWindow::initMacro(QDomNode &node)
widgets += widgetBuilder(child, mainwidget, this);
}
- // Insert their values (this must be done last for lua progs to work properly)
+ // Insert their values (this must be done last for scripts to work properly)
for (int i=0; i<children.count();i++) {
QDomNode child = children.at(i);
setValues(child, this);
@@ -140,7 +142,7 @@ bool MacroWindow::doCommit()
QVector< Widget* >::iterator i = widgets.begin();
while (i != widgets.end()) {
Widget* w = *i;
- if(!w->isValid()) faulty++; // Regexp check, returns valid if entry passed
+ if(!w->isDisabled() && !w->isValid()) faulty++; // Regexp check, returns valid if entry passed
i++;
}
@@ -167,24 +169,40 @@ void MacroWindow::commit()
// close();
} else {
QMessageBox::critical(NULL, "Fejl",
- "Makroen er ikke udfyldt korrekt, prøv igen.\n"
+ "Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n"
, QMessageBox::Ok);
}
}
void MacroWindow::reset()
{
+ /*
QMessageBox::warning(NULL, tr("Reset"),
tr("Du har valgt at nulstille de indtastede data.\n"
"Er du sikker?"),
QMessageBox::Yes | QMessageBox::Cancel);
printf("MacroWindow -> resetting...\n");
+ */
+ QVector< Widget* >::iterator i = widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ w->reset();
+ i++;
+ }
+
+ QVector< Widget* >::iterator j = auxwidgets.begin();
+ while (j != auxwidgets.end()) {
+ Widget* w = *j;
+ w->reset();
+ j++;
+ }
+
+ waschanged = false;
}
void MacroWindow::cancel()
{
- printf("MacroWindow -> cancelling...\n");
- // close();
+ collapseWrapper();
}
void MacroWindow::cont(QString name)
@@ -208,7 +226,7 @@ void MacroWindow::cont(QString name)
// close();
} else {
QMessageBox::critical(NULL, "Fejl",
- "Makroen er ikke udfyldt korrekt, prøv igen.\n",
+ "Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
QMessageBox::Ok);
}
printf("%s : MacroWindow -> continuing...\n", macro.toStdString().c_str());
@@ -235,7 +253,7 @@ void MacroWindow::cont_nocommit(QString name)
// close();
} else {
QMessageBox::critical(NULL, "Fejl",
- "Makroen er ikke udfyldt korrekt, prøv igen.\n",
+ "Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
QMessageBox::Ok);
}
printf("%s : MacroWindow -> continuing...\n", macro.toStdString().c_str());
@@ -272,49 +290,105 @@ void MacroWindow::addAuxWidgets(QVector< Widget* > ws)
auxwidgets += ws;
}
-void MacroWindow::toggleMacro()
+void MacroWindow::addWidgets(QVector< Widget* > ws)
{
- if(isCollapsed()) {
- widgets.clear();
- auxwidgets.clear();
- luaprograms.clear();
+ widgets += ws;
+}
- QDomDocument xml_doc = netcom->send(course, macro);
+void MacroWindow::expandWrapper()
+{
+ if(!isCollapsed()) return;
- //
- // TODO: This is where the dependency checking should occur.
- //
+ widgets.clear();
+ auxwidgets.clear();
+ luaprograms.clear();
+ waschanged = false;
+
+ QDomDocument xml_doc = netcom->send(course, macro);
+
+ //
+ // TODO: This is where the dependency checking should occur.
+ //
+
+ // Initiate the new macro window with the xml document and push
+ // it to the window list
+ QDomNodeList courses = xml_doc.documentElement().childNodes();
+ QDomNode coursenode = courses.at(0); // There can be only one! (Swush, flomp)
+ QDomNodeList macronodes = coursenode.childNodes();
+ for(int j = 0; j < macronodes.count(); j++) {
+ QDomNode macronode = macronodes.at(j);
- // Initiate the new macro window with the xml document and push
- // it to the window list
- QDomNodeList courses = xml_doc.documentElement().childNodes();
- QDomNode coursenode = courses.at(0); // There can be only one! (Swush, flomp)
- QDomNodeList macronodes = coursenode.childNodes();
- for(int j = 0; j < macronodes.count(); j++) {
- QDomNode macronode = macronodes.at(j);
+ if(true || macronode.childNodes().count()) {
+ // macrowindows.push_back( new MacroWindow( netcom, macronode ) );
+ QDomElement xml_elem = macronode.toElement();
- if(true || macronode.childNodes().count()) {
- // macrowindows.push_back( new MacroWindow( netcom, macronode ) );
- QDomElement xml_elem = macronode.toElement();
+ if(xml_elem.tagName() == "macro") {
- if(xml_elem.tagName() == "macro") {
-
- // Assign the macro name and version to QStrings for use when comitting
- QString macroname;
- if(xml_elem.hasAttribute("name")) {
- if(xml_elem.attribute("name") == macro) {
- // update me!
- initMacro(macronode);
- }
+ // Assign the macro name and version to QStrings for use when comitting
+ QString macroname;
+ if(xml_elem.hasAttribute("name")) {
+ if(xml_elem.attribute("name") == macro) {
+ // update me!
+ initMacro(macronode);
}
- }
- }
+ }
+ }
}
- setExpandedWidget(mainwidget);
- expand();
+ }
+ setExpandedWidget(mainwidget);
+ expand();
+
+ QVector< Widget* >::iterator i = widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ if(w->setKeyboardFocus()) break;
+ i++;
+ }
+}
+void MacroWindow::collapseWrapper()
+{
+ if(isCollapsed()) return;
+
+ if(waschanged) {
+ switch(QMessageBox::warning(NULL,
+ "Gem ændringerne i makroen?",
+ "Du har valgt at lukke makroen " + macrotitle + ".\n"
+ "Ønsker du at gemme inden du lukker?",
+ QMessageBox::Save | QMessageBox::Close | QMessageBox::Cancel)) {
+ case QMessageBox::Save:
+ if(doCommit()) setCollapsed(true);
+ else QMessageBox::critical(NULL,
+ "Fejl",
+ "Makroen " + macrotitle + " er ikke udfyldt korrekt, prøv igen.\n",
+ QMessageBox::Ok);
+
+ break;
+ case QMessageBox::Close:
+ collapse();
+ break;
+ case QMessageBox::Cancel:
+ default:
+ // emit expanding(); // signal the other to close again (if any)
+ break;
+ }
} else {
collapse();
-
}
}
+
+void MacroWindow::toggleMacro()
+{
+ if(isCollapsed()) {
+ expandWrapper();
+ } else {
+ collapseWrapper();
+ }
+}
+
+void MacroWindow::macroChanged()
+{
+ printf("This macro was changed!\n");
+ emit macroHasChanged();
+ waschanged = true;
+}