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
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
44namespace 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
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
uint8_t index
eItemType
Enum that is used to store the type of a treeEntry.
void findSubstate(StateIceBasePtr state, const std::string &globalStateIdStr, StateIceBasePtr &resultState)
void updateModel(const std::string &componentName, const std::vector< StateIceBasePtr > &topLevelBaseStates, const std::vector< StateIceBasePtr > &topLevelRequestedStates)
bool setData(const QModelIndex &index, const QVariant &value, int role) override
StateItemModel(QObject *parent=0)
StateIceBasePtr getState(std::string componentName, const std::string &globalStateIdStr)
This file offers overloads of toIce() and fromIce() functions for STL container types.