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 
41 namespace armarx
42 {
43  using ObserverList = std::vector<std::string>;
44 
45  // class IceManager;
46  // using IceManagerPtr = IceUtil::Handle<IceManager>;
47 
48  enum EItemType
49  {
59  };
60 
61  class ObserverItemModel : public QStandardItemModel
62  {
63  public:
64  ObserverItemModel(IceManagerPtr iceManager, VariantInfoPtr info = NULL);
65 
66  ~ObserverItemModel() override
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
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::eChannelItem
@ eChannelItem
Definition: ObserverItemModel.h:52
armarx::ObserverItemModel::getPropertiesWidget
QWidget * getPropertiesWidget(const QModelIndex &index, QWidget *parent)
Definition: ObserverItemModel.cpp:77
armarx::eChecksItem
@ eChecksItem
Definition: ObserverItemModel.h:54
armarx::EItemType
EItemType
Definition: ObserverItemModel.h:48
armarx::ObserverItemModel::updateModel
void updateModel(const std::string &observerName, const ChannelRegistry &channels, const StringConditionCheckMap &checks)
Definition: ObserverItemModel.cpp:48
armarx::eConditionItem
@ eConditionItem
Definition: ObserverItemModel.h:57
armarx::eElementaryConditionItem
@ eElementaryConditionItem
Definition: ObserverItemModel.h:58
armarx::ObserverItemModel::ObserverItemModel
ObserverItemModel(IceManagerPtr iceManager, VariantInfoPtr info=NULL)
Definition: ObserverItemModel.cpp:39
armarx::ObserverItemModel::updateObservers
void updateObservers()
Definition: ObserverItemModel.cpp:254
armarx::eObserverItem
@ eObserverItem
Definition: ObserverItemModel.h:50
armarx::eCheckItem
@ eCheckItem
Definition: ObserverItemModel.h:55
IceManager.h
armarx::armem::server::ltm::util::mongodb::detail::insert
bool insert(mongocxx::collection &coll, const nlohmann::json &value)
Definition: mongodb.cpp:44
armarx::ObserverItemModel::getObservers
ObserverList getObservers()
Definition: ObserverItemModel.cpp:218
armarx::ObserverItemModel::~ObserverItemModel
~ObserverItemModel() override
Definition: ObserverItemModel.h:66
armarx::ObserverList
std::vector< std::string > ObserverList
Definition: ObserverItemModel.h:43
PropertiesWidget.h
IceUtil::Handle< IceManager >
armarx::eDataFieldItem
@ eDataFieldItem
Definition: ObserverItemModel.h:53
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::ObserverItemModel
Definition: ObserverItemModel.h:61
armarx::eChannelsItem
@ eChannelsItem
Definition: ObserverItemModel.h:51
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::eConditionsItem
@ eConditionsItem
Definition: ObserverItemModel.h:56
VariantInfo.h