OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
NavigationTreeItem.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
10#include "OTGui/GuiTypes.h"
12
13// std header
14#include <list>
15#include <string>
16
17#pragma warning(disable:4251)
18
19namespace ot {
20
29
31 OT_GUI_API_EXPORT std::list<std::string> toStringList(NavigationTreeItemFlags _flags);
34
36 public:
39 NavigationTreeItem(const std::string& _text, const std::string& _iconPath, ot::NavigationTreeItemFlags _flags = ot::NoNavigationTreeItemFlags);
40 NavigationTreeItem(const std::string& _text, const std::string& _iconPath, const std::list<NavigationTreeItem>& _childItems, ot::NavigationTreeItemFlags _flags = ot::NoNavigationTreeItemFlags);
42 virtual ~NavigationTreeItem();
43
44 NavigationTreeItem& operator = (const NavigationTreeItem& _other);
45
49 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
50
54 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
55
56 void setText(const std::string& _text) { m_text = _text; };
57 const std::string text(void) const { return m_text; };
58
59 void setIconPath(const std::string& _iconPath) { m_iconPath = _iconPath; };
60 const std::string& iconPath(void) const { return m_iconPath; };
61
62 void addChildItem(const NavigationTreeItem& _item);
63 void setChildItems(const std::list<NavigationTreeItem>& _items);
64 const std::list<NavigationTreeItem>& childItems(void) const { return m_childs; };
65
66 void setFlag(NavigationTreeItemFlag _flag, bool _active = true) { m_flags.setFlag(_flag, _active); };
67 void setFlags(ot::NavigationTreeItemFlags _flags) { m_flags = _flags; };
68 ot::NavigationTreeItemFlags flags(void) const { return m_flags; };
69
70 void merge(const NavigationTreeItem& _other);
71
72 std::string itemPath(char _delimiter = '/', const std::string& _suffix = std::string()) const;
73
76 bool filter(NavigationTreeItemFlags _flags);
77
78 protected:
79 void setParentNavigationTreeItem(NavigationTreeItem* _parent) { m_parent = _parent; };
80 NavigationTreeItem* parentNavigationTreeItem(void) const { return m_parent; };
81
82 private:
83 NavigationTreeItem* m_parent;
84
85 std::string m_text;
86 std::string m_iconPath;
87 std::list<NavigationTreeItem> m_childs;
89
90 };
91
92}
93
#define OT_ADD_FLAG_FUNCTIONS(___enumName)
Will add the default bitwise operations for the provided private 32/64 bit bitfield....
Definition Flags.h:129
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The Flags class is a wrapper around a enum that allows bitwise operations (flags)....
Definition Flags.h:214
Definition NavigationTreeItem.h:35
void setIconPath(const std::string &_iconPath)
Definition NavigationTreeItem.h:59
const std::string text(void) const
Definition NavigationTreeItem.h:57
void setFlag(NavigationTreeItemFlag _flag, bool _active=true)
Definition NavigationTreeItem.h:66
void setFlags(ot::NavigationTreeItemFlags _flags)
Definition NavigationTreeItem.h:67
void setText(const std::string &_text)
Definition NavigationTreeItem.h:56
const std::list< NavigationTreeItem > & childItems(void) const
Definition NavigationTreeItem.h:64
ot::NavigationTreeItemFlags flags(void) const
Definition NavigationTreeItem.h:68
NavigationTreeItem * parentNavigationTreeItem(void) const
Definition NavigationTreeItem.h:80
const std::string & iconPath(void) const
Definition NavigationTreeItem.h:60
void setParentNavigationTreeItem(NavigationTreeItem *_parent)
Definition NavigationTreeItem.h:79
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
Definition Connector.h:8
OT_GUI_API_EXPORT std::list< std::string > toStringList(const LockTypeFlags &_flags)
Definition GuiTypes.cpp:426
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
OT_GUI_API_EXPORT std::string toString(ColorStyleName _colorStyleName)
Definition ColorStyleTypes.cpp:10
Flags< NavigationTreeItemFlag > NavigationTreeItemFlags
Definition NavigationTreeItem.h:28
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30
NavigationTreeItemFlag
Definition NavigationTreeItem.h:21
@ ItemMayBeAdded
If set the item will be removed when all the child items are removed.
Definition NavigationTreeItem.h:24
@ ItemIsSelected
If set the item may be added/dragged/dropped.
Definition NavigationTreeItem.h:25
@ ItemIsInvisible
If set this item is selected.
Definition NavigationTreeItem.h:26
@ RemoveItemWhenEmpty
Empty mask, no flags set.
Definition NavigationTreeItem.h:23
@ NoNavigationTreeItemFlags
Definition NavigationTreeItem.h:22
OT_GUI_API_EXPORT NavigationTreeItemFlag stringToNavigationItemFlag(const std::string &_flag)
Definition NavigationTreeItem.cpp:39
OT_GUI_API_EXPORT NavigationTreeItemFlags stringListToNavigationItemFlags(const std::list< std::string > &_flags)
Definition NavigationTreeItem.cpp:50