StateItemModel.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 
31 #include "../ObserverPropertiesPlugin/widgets/properties/PropertiesWidget.h"
32 
33 
34 #define STATE_ITEM_TYPE Qt::UserRole + 1
35 //#define STATE_UNIQUEID Qt::UserRole+2
36 #define STATE_COMPONENT_NAME Qt::UserRole + 3
37 #define STATE_ITEM_DELETE Qt::UserRole + 4
38 #define STATE_TYPE Qt::UserRole + 5
39 #define STATE_GLOBALSTATEID Qt::UserRole + 6
40 
41 #define ARMARXGUI_BASEINSTANCE_STR "Base Instances"
42 #define ARMARXGUI_REQUESTEDINSTANCE_STR "Requested Instances"
43 
44 namespace armarx
45 {
46 
47  class StateItemModel : public QStandardItemModel
48  {
49  Q_OBJECT
50  public:
51  StateItemModel(QObject* parent = 0);
52 
53  ~StateItemModel() override
54  {
55  }
56 
57  //! Enum that is used to store the type of a treeEntry
58  enum eItemType
59  {
65  };
66 
67  void updateModel(const std::string& componentName,
68  const std::vector<StateIceBasePtr>& topLevelBaseStates,
69  const std::vector<StateIceBasePtr>& topLevelRequestedStates);
70  StateIceBasePtr getState(std::string componentName, const std::string& globalStateIdStr);
71  void findSubstate(StateIceBasePtr state,
72  const std::string& globalStateIdStr,
73  StateIceBasePtr& resultState);
74 
75  // QString getSearchString(){ return searchString;}
76 
77  // QAbstractItemModel interface
78  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
79  public slots:
80  // void setSearchString(QString search){ searchString = search;}
81  private:
82  std::map<std::string, std::vector<StateIceBasePtr>> requestedInstanceList;
83 
84  QStandardItem* updateComponent(std::string componentName);
85  void updateStates(QStandardItem* componentItem,
86  const std::vector<StateIceBasePtr>& topLevelStates,
87  std::string componentName,
88  eItemType itemType);
89 
90  void markAllForDelete(QStandardItem* stateItem);
91  void deleteUnusedItems(QStandardItem* stateItem);
92  void insertSubstates(QStandardItem* parentStateItem,
93  StateIceBasePtr state,
94  std::string componentName,
95  eItemType itemType);
96  QStandardItem* updateOrInsertItem(QStandardItem* parent, QStandardItem* insert);
97 
98 
99  QVariant data(const QModelIndex& index, int role) const override;
100 
101  // QString searchString;
102 
103 
104  // // QAbstractItemModel interface
105  // public:
106  // Qt::ItemFlags flags(const QModelIndex &index) const;
107  };
108 } // namespace armarx
armarx::StateItemModel::eItemType
eItemType
Enum that is used to store the type of a treeEntry.
Definition: StateItemModel.h:58
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::StateItemModel
Definition: StateItemModel.h:47
armarx::StateItemModel::updateModel
void updateModel(const std::string &componentName, const std::vector< StateIceBasePtr > &topLevelBaseStates, const std::vector< StateIceBasePtr > &topLevelRequestedStates)
Definition: StateItemModel.cpp:37
armarx::StateItemModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition: StateItemModel.cpp:376
Statechart.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::StateItemModel::findSubstate
void findSubstate(StateIceBasePtr state, const std::string &globalStateIdStr, StateIceBasePtr &resultState)
Definition: StateItemModel.cpp:96
armarx::StateItemModel::eInputItem
@ eInputItem
Definition: StateItemModel.h:64
armarx::armem::server::ltm::util::mongodb::detail::insert
bool insert(mongocxx::collection &coll, const nlohmann::json &value)
Definition: mongodb.cpp:44
armarx::StateItemModel::eBaseStateItem
@ eBaseStateItem
Definition: StateItemModel.h:62
armarx::StateItemModel::eInstanceStateItem
@ eInstanceStateItem
Definition: StateItemModel.h:63
armarx::StateItemModel::getState
StateIceBasePtr getState(std::string componentName, const std::string &globalStateIdStr)
Definition: StateItemModel.cpp:65
armarx::StateItemModel::eComponentItem
@ eComponentItem
Definition: StateItemModel.h:60
armarx::StateItemModel::ePlaceHolderItem
@ ePlaceHolderItem
Definition: StateItemModel.h:61
armarx::StateItemModel::StateItemModel
StateItemModel(QObject *parent=0)
Definition: StateItemModel.cpp:30
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::StateItemModel::~StateItemModel
~StateItemModel() override
Definition: StateItemModel.h:53