Hobrasoft httpd server
Embedded HTTP server for Qt and C++
list.cpp
Go to the documentation of this file.
1 
5 #include "list.h"
6 #include "item.h"
7 
8 using namespace Example;
9 
10 List::List(QObject *parent) : QObject(parent) {
11 }
12 
13 
14 QVariantList List::webStatus() const {
15  QVariantList data;
16  QHashIterator<QString, Item *> iterator(m_items);
17  while (iterator.hasNext()) {
18  iterator.next();
19  Item *item = iterator.value();
20  data << item->webStatus();
21  }
22  return data;
23 }
24 
25 
26 void List::insert(Item *item) {
27  m_items[item->id()] = item;
28  connect (item, SIGNAL(statusChanged(const Item *)), this, SIGNAL(statusChanged(const Item *)));
29 }
30 
31 
32 bool List::contains(const QString& id) const {
33  return m_items.contains(id);
34 }
35 
36 
37 Item *List::item(const QString& id) const {
38  return m_items.value(id, NULL);
39 }
40 
41 
Namespace for Example.
Definition: application.h:11
QVariantMap webStatus() const
Returns webStatus of the item.
Definition: item.cpp:42
Item * item(const QString &id) const
Returns pointer to an item with given id or NULL if the item does not exist.
Definition: list.cpp:37
One data item in the example.
Definition: item.h:20
bool contains(const QString &id) const
Returns true if item with the given id exists.
Definition: list.cpp:32
const QString & id() const
Returns id of the item.
Definition: item.cpp:32
void statusChanged(const Item *)
Signal is invoked when some item status changed.
void insert(Item *)
Insert one item to the list.
Definition: list.cpp:26