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