close Warning: Can't use blame annotator:
svn blame failed on branches/mavlink/tools/FlairGCS/src/ListWidget.cpp: 200029 - Couldn't perform atomic initialization

source: flair-src/branches/mavlink/tools/FlairGCS/src/ListWidget.cpp@ 54

Last change on this file since 54 was 54, checked in by Thomas Fuhrmann, 8 years ago

Default xml configuration is working with ListWidget

File size: 2.3 KB
RevLine 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5#include "ListWidget.h"
6#include "Layout.h"
7#include <QListWidget>
8#include <QFormLayout>
9#include <QLabel>
10
11#include <iostream>
12
13ListWidget::ListWidget(Layout *parent, int row, int col, QString name)
14 : FormLayout(parent, row, col, name, "ListWidget") {
15 listwidget = new QListWidget();
16 object_layout->addRow(new QLabel(name));
17 object_layout->addRow(listwidget);
18 // to avoid duplicates when adding items
19 SetIsExpandable(true);
20}
21
22ListWidget::ListWidget(Layout *parent, int row, int col, QString name, QStringList& items)
23 : ListWidget(parent, row, col, name) {
24 if (!items.isEmpty()) {
25 listwidget->addItems(items);
26 }
27}
28
29ListWidget::~ListWidget() { delete listwidget; }
30
31void ListWidget::XmlEvent(QDomElement dom) {
32 if (dom.attribute("item") != "") {
33 QString item = dom.attribute("item");
34 listwidget->addItem(item);
35 }
36 if (dom.attribute("delete") != "") {
37 QListWidgetItem* current_item = listwidget->currentItem();
38 listwidget->removeItemWidget(current_item);
39 if (current_item) {
40 delete current_item;
41 }
42 }
43}
44
45void ListWidget::SetUptodate(void) {
46 // ui_to_var();
47 // ui_to_xml();
48 std::cout << "SetUptodate" << std::endl;
49 visible_widget->setPalette(black_pal);
50}
51
52// void ListWidget::ui_to_var(void) { combobox_value = listwidget->currentIndex(); }
53
54// void ListWidget::ui_to_xml(void) {
55// SetValue(QString::number(listwidget->currentIndex()));
56// }
57
58void ListWidget::Reset(void) {
59 // listwidget->setCurrentIndex(combobox_value);
60}
61
62void ListWidget::LoadEvent(QDomElement dom) {
63 std::cout << "In LoadEvent" << std::endl;
64 // Parse the item list
65 QStringList items;
66 int count = 0;
67 while (dom.hasAttribute("item" + QString::number(count))) {
68 QString item = dom.attribute("item" + QString::number(count));
69 std::cout << "Item" << count << " : " << item.toStdString() << std::endl;
70 items.append(item);
71 count++;
72 }
73
74 listwidget->addItems(items);
75
76 // if (listwidget->isEnabled() == true) {
77 // listwidget->setCurrentIndex((dom.attribute("value")).toInt());
78 // }
79}
80
81// void ListWidget::valuechanged(int value) {
82// if (value != combobox_value) {
83// visible_widget->setPalette(red_pal);
84// } else {
85// visible_widget->setPalette(black_pal);
86// }
87// }
Note: See TracBrowser for help on using the repository browser.