ICF 3.1.1.10
Technical documentation of ICF Libraries
CHierarchicalCommand.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iqtgui_CHierarchicalCommand_included
7#define iqtgui_CHierarchicalCommand_included
8
9
10// Qt includes
11#include <QtCore/QString>
12#include <QtGui/QAction>
13
14// ICF includes
15#include <istd/TOptDelPtr.h>
17#include <iprm/CNameParam.h>
19#include <ibase/ICommand.h>
20#include <istdgui/istdgui.h>
21
22
23namespace istdgui
24{
25
26
31 public QAction,
33 public iprm::CNameParam,
34 public istd::THierarchicalBase<ibase::IHierarchicalCommand>
35{
36 Q_OBJECT
37
38public:
39 typedef QAction BaseClass;
42
43 explicit CHierarchicalCommand(const QString& name = "", int priority = 100, int staticFlags = CF_GLOBAL_MENU, int groupId = GI_NORMAL);
44
45 void SetPriority(int priority);
46 void SetStaticFlags(int flags);
47 void SetGroupId(int groupId);
48
53
62 void InsertChild(istd::TOptDelPtr<CHierarchicalCommand>&& commandPtr, int index = -1);
63
67 void RemoveChild(int index);
68
74
83 void SetVisuals(const QString& name, const QString& shortName, const QString& description, const QIcon& icon = QIcon());
84
85 // reimplemented (ibase::ICommand)
86 int GetPriority() const override;
87 int GetGroupId() const override;
88 int GetStaticFlags() const override;
89 bool Execute(istd::IPolymorphic* contextPtr) override;
90
91 // reimplemented (istd::TIHierarchical<ibase::ICommand>)
92 int GetChildsCount() const override;
93 ibase::ICommand* GetChild(int index) const override;
94
95 // reimplemented (iprm::INameParam)
96 void SetName(const QString& name) override;
97
98 // reimplemented (iprm::IEnableableParam)
99 bool SetEnabled(bool isEnabled = true) override;
100
101 // reimplemented (iser::ISerializable)
102 bool Serialize(iser::IArchive& archive) override;
103
104 // reimplemented (istd::IChangeable)
105 int GetSupportedOperations() const override;
106 bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
107 std::unique_ptr<istd::IChangeable> CloneMe(istd::IChangeable::CompatibilityMode mode = istd::IChangeable::CM_WITHOUT_REFS) const override;
108 bool IsEqual(const istd::IChangeable& object) const override;
109
110 // operators
111 bool operator==(const CHierarchicalCommand& command) const;
112 bool operator!=(const CHierarchicalCommand& command) const;
114
115protected Q_SLOTS:
117
118protected:
128 int FindInsertingIndex(int priority) const;
129
130private:
131 int m_priority;
132 int m_staticFlags;
133 int m_groupId;
134
135 typedef std::vector<istd::TOptDelPtr<CHierarchicalCommand>> Childs;
136 Childs m_childs;
137};
138
139
140} // namespace istdgui
141
142
143#endif // !iqtgui_CHierarchicalCommand_included
144
145
Provides single command for interaction with user.
Definition ICommand.h:25
Basic implementation of IEnableableParam interface.
Implementation of a named object over iprm::INameParam interface.
Definition CNameParam.h:22
Represent input/output persistence archive.
Definition IArchive.h:34
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Template based implementation of a hierarchical object.
Common interface to define the hierarchical graph structures.
Pointer wrapper providing activatable deleting pointed object during destruction.
Definition TOptDelPtr.h:23
Implementation of hierarchical command based on QAction from Qt.
bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
Copy this object from another one.
std::unique_ptr< istd::IChangeable > CloneMe(istd::IChangeable::CompatibilityMode mode=istd::IChangeable::CM_WITHOUT_REFS) const override
Make a copy of this object.
int GetSupportedOperations() const override
Get set of flags for supported operations.
void ResetChilds()
Reset list of childs.
bool IsEqual(const istd::IChangeable &object) const override
Compare this object with another object.
bool operator!=(const CHierarchicalCommand &command) const
int GetGroupId() const override
int GetStaticFlags() const override
bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
void SetStaticFlags(int flags)
void SetGroupId(int groupId)
int FindTheSameCommand(const ibase::IHierarchicalCommand &command) const
Find the same command in child list.
void InsertChild(istd::TOptDelPtr< CHierarchicalCommand > &&commandPtr, int index=-1)
Insert command to child list.
bool Execute(istd::IPolymorphic *contextPtr) override
void SetName(const QString &name) override
Set the object name.
ibase::ICommand * GetChild(int index) const override
Get child value.
void JoinLinkFrom(const ibase::IHierarchicalCommand *rootPtr)
Joint the second root as links.
CHierarchicalCommand & operator=(const CHierarchicalCommand &command)
bool SetEnabled(bool isEnabled=true) override
Set something to isEnabled state.
int GetPriority() const override
bool operator==(const CHierarchicalCommand &command) const
void SetPriority(int priority)
int GetChildsCount() const override
Get number of childs.
void SetVisuals(const QString &name, const QString &shortName, const QString &description, const QIcon &icon=QIcon())
Set all visual elements of this command.
int FindInsertingIndex(int priority) const
Find index where element with specified priority should be inserted.
CHierarchicalCommand(const QString &name="", int priority=100, int staticFlags=CF_GLOBAL_MENU, int groupId=GI_NORMAL)
void RemoveChild(int index)
Remove child at specified index.
iprm::CEnableableParam BaseClass2
Standard GUI specific interfaces and components based on Qt.

© Witold Gantzke and Kirill Lepskiy