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 
26 
27 
28 #include <ArmarXCore/interface/observers/ObserverInterface.h>
29 #include <ArmarXCore/interface/observers/ConditionCheckBase.h>
30 
32 
33 #include <QStandardItemModel>
34 #include <string>
35 
37 
38 
39 #define OBSERVER_ITEM_TYPE Qt::UserRole+1
40 #define OBSERVER_ITEM_ID Qt::UserRole+2
41 #define OBSERVER_ITEM_DELETE Qt::UserRole+3
42 
43 namespace armarx
44 {
45  using ObserverList = std::vector<std::string>;
46 
47  // class IceManager;
48  // using IceManagerPtr = IceUtil::Handle<IceManager>;
49 
50  enum EItemType
51  {
61  };
62 
63 
64  class ObserverItemModel : public QStandardItemModel
65  {
66  public:
67  ObserverItemModel(IceManagerPtr iceManager, VariantInfoPtr info = NULL);
68  ~ObserverItemModel() override {}
69 
70  // void updateModel(const std::string& observerName, const ChannelRegistry& channels, const StringElementaryConditionCheckMap& checks, const ConditionCheckMap& conditions);
71  void updateModel(const std::string& observerName, const ChannelRegistry& channels, const StringConditionCheckMap& checks);
72  QWidget* getPropertiesWidget(const QModelIndex& index, QWidget* parent);
74  public slots:
75 
76  void updateObservers();
77  private:
78  QStandardItem* updateObserver(std::string observerName);
79  void updateChannels(QStandardItem* channelsItem, const ChannelRegistry& channel);
80  void updateChecks(QStandardItem* checksItem, const StringConditionCheckMap& checks);
81  // void updateConditions(QStandardItem* conditionsItem, const ConditionCheckMap& conditions);
82 
83  void markAllForDelete(QStandardItem* observerItem);
84  void deleteUnusedItems(QStandardItem* observerItem);
85 
86  QStandardItem* updateOrInsertItem(QStandardItem* parent, QStandardItem* insert);
87 
88  QStandardItem* getChildByName(QStandardItem* item, const QString& name);
89 
90  std::map<std::string, ChannelRegistry> channelRegistry;
91  std::map<std::string, StringConditionCheckMap> availableChecks;
92  // std::map<std::string,ConditionCheckMap> activeConditions;
93  IceManagerPtr iceManager;
94  VariantInfoPtr info;
95  };
96 }
97 
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::eChannelItem
@ eChannelItem
Definition: ObserverItemModel.h:54
armarx::ObserverItemModel::getPropertiesWidget
QWidget * getPropertiesWidget(const QModelIndex &index, QWidget *parent)
Definition: ObserverItemModel.cpp:76
armarx::eChecksItem
@ eChecksItem
Definition: ObserverItemModel.h:56
armarx::EItemType
EItemType
Definition: ObserverItemModel.h:50
armarx::ObserverItemModel::updateModel
void updateModel(const std::string &observerName, const ChannelRegistry &channels, const StringConditionCheckMap &checks)
Definition: ObserverItemModel.cpp:50
armarx::eConditionItem
@ eConditionItem
Definition: ObserverItemModel.h:59
armarx::eElementaryConditionItem
@ eElementaryConditionItem
Definition: ObserverItemModel.h:60
armarx::ObserverItemModel::ObserverItemModel
ObserverItemModel(IceManagerPtr iceManager, VariantInfoPtr info=NULL)
Definition: ObserverItemModel.cpp:40
armarx::ObserverItemModel::updateObservers
void updateObservers()
Definition: ObserverItemModel.cpp:228
armarx::eObserverItem
@ eObserverItem
Definition: ObserverItemModel.h:52
armarx::eCheckItem
@ eCheckItem
Definition: ObserverItemModel.h:57
IceManager.h
armarx::armem::server::ltm::util::mongodb::detail::insert
bool insert(mongocxx::collection &coll, const nlohmann::json &value)
Definition: mongodb.cpp:43
armarx::ObserverItemModel::getObservers
ObserverList getObservers()
Definition: ObserverItemModel.cpp:195
armarx::ObserverItemModel::~ObserverItemModel
~ObserverItemModel() override
Definition: ObserverItemModel.h:68
armarx::ObserverList
std::vector< std::string > ObserverList
Definition: ObserverItemModel.h:45
PropertiesWidget.h
IceUtil::Handle< IceManager >
armarx::eDataFieldItem
@ eDataFieldItem
Definition: ObserverItemModel.h:55
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::ObserverItemModel
Definition: ObserverItemModel.h:64
armarx::eChannelsItem
@ eChannelsItem
Definition: ObserverItemModel.h:53
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::eConditionsItem
@ eConditionsItem
Definition: ObserverItemModel.h:58
VariantInfo.h