summaryrefslogtreecommitdiff
path: root/client/widgets/listbox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/listbox.cc')
-rw-r--r--client/widgets/listbox.cc76
1 files changed, 32 insertions, 44 deletions
diff --git a/client/widgets/listbox.cc b/client/widgets/listbox.cc
index bddc34f..da234ab 100644
--- a/client/widgets/listbox.cc
+++ b/client/widgets/listbox.cc
@@ -25,7 +25,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "listbox.h"
+
#include <QListWidgetItem>
+#include <QListWidget>
#include "common.h"
@@ -69,32 +71,41 @@ static QListWidgetItem *createItem(QDomElement &elem)
}
ListBox::ListBox(QDomNode &node, MacroWindow *macrowindow)
- : QListWidget(), Widget(node, macrowindow)
+ : Widget(node, macrowindow)
{
+ listwidget = new QListWidget();
+ widget = listwidget;
+
valueIsChangingByComputer = false;
- setCommonAttributes(this, node);
+ setCommonAttributes(listwidget, node);
QDomNodeList children = node.childNodes();
for (int i=0; i < children.count(); i++) {
QDomNode child = children.at(i);
QDomElement list_elem = child.toElement();
- addItem(createItem(list_elem));
+ listwidget->addItem(createItem(list_elem));
}
- connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(changed()));
+ connect(listwidget, SIGNAL(itemSelectionChanged()), this, SLOT(changed()));
+}
+
+ListBox::~ListBox()
+{
+ // delete listwidget;
}
-bool ListBox::isValid()
+bool ListBox::preValid()
{
- return selectedItems().size() != 0;
+ return listwidget->selectedItems().size() != 0;
}
-QString ListBox::getValue()
+QString ListBox::value()
{
QString value = "none";
- if(currentRow() != -1) value = currentItem()->data(Qt::UserRole).toString();
+ if(listwidget->currentRow() != -1)
+ value = listwidget->currentItem()->data(Qt::UserRole).toString();
return value;
}
@@ -105,56 +116,33 @@ void ListBox::setValue(QString value, QString source)
valueIsChangingByComputer = true;
int sel = -1; // -1 is default for none selected
- for(int i = 0; i < count(); i++) {
- QListWidgetItem *listitem = item(i);
+ for(int i = 0; i < listwidget->count(); i++) {
+ QListWidgetItem *listitem = listwidget->item(i);
if(listitem->data(Qt::UserRole).toString() == value) sel = i;
}
- setCurrentRow(sel);
+ listwidget->setCurrentRow(sel);
setInitialValue(value);
valueIsChangingByComputer = false;
}
-void ListBox::connectFrom(const char *signal,
- const QObject *receiver, const char *method)
-{
- connect(this, signal, receiver, method);
-}
-
-void ListBox::connectTo(const QObject *sender, const char *signal,
- const char *method)
-{
- connect(sender, signal, this, method);
-}
-
-void ListBox::setVisibility(bool visible)
-{
- setVisible(visible);
-}
-
void ListBox::changed()
{
if(!valueIsChangingByComputer) emit wasChanged();
}
-bool ListBox::setKeyboardFocus()
-{
- setFocus();
- return true;
-}
-
-void ListBox::enable()
+void ListBox::setWdgValid(bool valid)
{
- setEnabled(true);
-}
+ QPalette palette;
-void ListBox::disable()
-{
- setEnabled(false);
-}
+ if(valid) {
+ // valid string
+ palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255)));
+ } else {
+ // invalid string
+ palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200)));
+ }
-bool ListBox::isDisabled()
-{
- return isEnabled() == false;
+ listwidget->setPalette(palette);
}