summaryrefslogtreecommitdiff
path: root/client/widgets/multilist.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/widgets/multilist.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/widgets/multilist.cc')
-rw-r--r--client/widgets/multilist.cc113
1 files changed, 70 insertions, 43 deletions
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index bff3ad7..5f28368 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -43,9 +43,29 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
QGridLayout *layout = new QGridLayout();
setLayout(layout);
+ list = new QListWidget(this);
+ layout->addWidget(list, 0, 0, 1, 2, Qt::AlignTop);
+ list->installEventFilter(this);
+
+ QPushButton *add = new QPushButton(this);
+ connect(add, SIGNAL(clicked()), this, SLOT(add()));
+ add->setText("Tilføj nedenstående til listen");
+ add->setIcon(QIcon(QPixmap(":icons/add.png")));
+ layout->addWidget(add, 1, 0, 1, 1, Qt::AlignTop);
+
+ QPushButton *rem = new QPushButton(this);
+ connect(rem, SIGNAL(clicked()), this, SLOT(remove()));
+ rem->setText("Fjern det markerede element fra listen");
+ rem->setIcon(QIcon(QPixmap(":icons/del.png")));
+ layout->addWidget(rem, 1, 1, 1, 1, Qt::AlignTop);
+
+ QLabel *arrows = new QLabel();
+ arrows->setPixmap(QPixmap(":icons/arrows.png"));
+ layout->addWidget(arrows, 2, 0, 1, 2, Qt::AlignHCenter);
+
QWidget *inputbox = new QWidget(this);
inputbox->setContentsMargins(0,0,0,0);
- layout->addWidget(inputbox, 0, 0, 1, 2, Qt::AlignTop);
+ layout->addWidget(inputbox, 3, 0, 1, 2, Qt::AlignTop);
QDomElement elem = node.toElement();
if(elem.hasAttribute("layout")) {
@@ -68,7 +88,7 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
QVector< Widget* > widgets;
for (int i=0; i<children.count();i++) {
QDomNode child = children.at(i);
- widgets += widgetBuilder(child, inputbox, macrowindow);
+ widgets += widgetBuilder(child, inputbox, macrowindow, false);
}
macrowindow->addAuxWidgets(widgets);
@@ -88,35 +108,6 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
printf("ERROR: Missing 'innerwidget' attribute on multilist!\n");
}
- QLabel *arrows = new QLabel();
- arrows->setPixmap(QPixmap(":icons/arrows.png"));
- layout->addWidget(arrows, 1, 0, 1, 2, Qt::AlignHCenter);
-
- QPushButton *add = new QPushButton(this);
- connect(add, SIGNAL(clicked()), this, SLOT(add()));
- add->setText("Tilføj ovenstående til listen");
- add->setIcon(QIcon(QPixmap(":icons/add.png")));
-
- // layout->addWidget(add, 0, 1, Qt::AlignTop);
- layout->addWidget(add, 2, 0, 1, 1, Qt::AlignTop);
-
- QPushButton *rem = new QPushButton(this);
- connect(rem, SIGNAL(clicked()), this, SLOT(remove()));
- rem->setText("Fjern det markerede element fra listen");
- rem->setIcon(QIcon(QPixmap(":icons/del.png")));
- // layout->addWidget(rem, 1, 1, Qt::AlignTop);
- layout->addWidget(rem, 2, 1, 1, 1, Qt::AlignTop);
-
- list = new QListWidget(this);
- // layout->addWidget(list, 1, 0, Qt::AlignTop);
- layout->addWidget(list, 3, 0, 1, 2, Qt::AlignTop);
-
- /* // This is done later
- if(elem.hasAttribute("value")) {
- setValue(elem.attribute("value"));
- }
- */
-
layout->setContentsMargins(0,0,0,0);
}
@@ -140,8 +131,10 @@ QString MultiList::getValue()
return values;
}
-void MultiList::setValue(QString values)
+void MultiList::setValue(QString values, QString source)
{
+ if(isUserSource(source)) emit wasChanged();
+
QString value;
list->clear();
@@ -152,26 +145,28 @@ void MultiList::setValue(QString values)
if(value != "") list->addItem(value);
idx++;
} while(value != "");
+
+ setInitialValue(values);
}
void MultiList::remove()
{
- list->takeItem(list->currentRow());
+ QListWidgetItem *item = list->currentItem();
+
+ if(item && item->isSelected()) {
+ delete item;
+ emit wasChanged();
+ }
}
void MultiList::add()
{
- /*
- QVector< Widget * >::iterator i = widgets.begin();
- while(i != widgets.end()) {
- if(!(*i)->isValid()) return;
- i++;
- }
- list->addItem(format_parser(format, widgets));
- */
+ if(innerwidget && innerwidget->isValid()) {
+ list->addItem(innerwidget->getValue());
+ emit wasChanged();
- if(innerwidget && innerwidget->isValid()) list->addItem(innerwidget->getValue());
-
+ innerwidget->reset();
+ }
}
void MultiList::enable()
@@ -183,3 +178,35 @@ void MultiList::disable()
{
setEnabled(false);
}
+
+void MultiList::connectFrom(const char *signal,
+ const QObject *receiver, const char *method)
+{
+ connect(this, signal, receiver, method);
+}
+
+void MultiList::connectTo(const QObject *sender, const char *signal,
+ const char *method)
+{
+ connect(sender, signal, this, method);
+}
+
+bool MultiList::setKeyboardFocus()
+{
+ if(innerwidget) return innerwidget->setKeyboardFocus();
+ return false;
+}
+
+bool MultiList::eventFilter(QObject *obj, QEvent *event)
+{
+ if(event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ if(keyEvent->key() == Qt::Key_Delete) remove();
+ }
+ return QObject::eventFilter(obj, event);
+}
+
+void MultiList::setVisibility(bool visible)
+{
+ setVisible(visible);
+}