ObserverItemModel.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarX::Gui
17* @author Kai Welke (welke@kit.edu)
18* @copyright 2012 Humanoids Group, IAIM, IFA
19* @license http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
25#include <string>
26
27#include <QStandardItemModel>
28
30#include <ArmarXCore/interface/observers/ConditionCheckBase.h>
31#include <ArmarXCore/interface/observers/ObserverInterface.h>
33
35
36
37#define OBSERVER_ITEM_TYPE Qt::UserRole + 1
38#define OBSERVER_ITEM_ID Qt::UserRole + 2
39#define OBSERVER_ITEM_DELETE Qt::UserRole + 3
40
41namespace armarx
42{
43 using ObserverList = std::vector<std::string>;
44
45 // class IceManager;
46 // using IceManagerPtr = IceUtil::Handle<IceManager>;
47
60
61 class ObserverItemModel : public QStandardItemModel
62 {
63 public:
64 ObserverItemModel(IceManagerPtr iceManager, VariantInfoPtr info = NULL);
65
67 {
68 }
69
70 // void updateModel(const std::string& observerName, const ChannelRegistry& channels, const StringElementaryConditionCheckMap& checks, const ConditionCheckMap& conditions);
71 void updateModel(const std::string& observerName,
72 const ChannelRegistry& channels,
73 const StringConditionCheckMap& checks);
74 QWidget* getPropertiesWidget(const QModelIndex& index, QWidget* parent);
76 public slots:
77
78 void updateObservers();
79
80 private:
81 QStandardItem* updateObserver(std::string observerName);
82 void updateChannels(QStandardItem* channelsItem, const ChannelRegistry& channel);
83 void updateChecks(QStandardItem* checksItem, const StringConditionCheckMap& checks);
84 // void updateConditions(QStandardItem* conditionsItem, const ConditionCheckMap& conditions);
85
86 void markAllForDelete(QStandardItem* observerItem);
87 void deleteUnusedItems(QStandardItem* observerItem);
88
89 QStandardItem* updateOrInsertItem(QStandardItem* parent, QStandardItem* insert);
90
91 QStandardItem* getChildByName(QStandardItem* item, const QString& name);
92
93 std::map<std::string, ChannelRegistry> channelRegistry;
94 std::map<std::string, StringConditionCheckMap> availableChecks;
95 // std::map<std::string,ConditionCheckMap> activeConditions;
96 IceManagerPtr iceManager;
97 VariantInfoPtr info;
98 };
99} // namespace armarx
uint8_t index
void updateModel(const std::string &observerName, const ChannelRegistry &channels, const StringConditionCheckMap &checks)
QWidget * getPropertiesWidget(const QModelIndex &index, QWidget *parent)
ObserverItemModel(IceManagerPtr iceManager, VariantInfoPtr info=NULL)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::vector< std::string > ObserverList
@ eElementaryConditionItem
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition VariantInfo.h:39
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
Definition ArmarXFwd.h:39