CHierarchicalCommand.h
Go to the documentation of this file.
1 #ifndef iqtgui_CHierarchicalCommand_included
2 #define iqtgui_CHierarchicalCommand_included
3 
4 
5 // Qt includes
6 #include <QtCore/QString>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QAction>
9 #else
10 #include <QtGui/QAction>
11 #endif
12 
13 // ACF includes
14 #include <istd/TOptPointerVector.h>
15 #include <istd/THierarchicalBase.h>
16 #include <iprm/CNameParam.h>
17 #include <iprm/CEnableableParam.h>
18 #include <ibase/ICommand.h>
19 #include <iqtgui/iqtgui.h>
20 
21 
22 namespace iqtgui
23 {
24 
25 
30  public QAction,
32  public iprm::CNameParam,
33  public istd::THierarchicalBase<ibase::IHierarchicalCommand>
34 {
35  Q_OBJECT
36 
37 public:
38  typedef QAction BaseClass;
41 
42  explicit CHierarchicalCommand(const QString& name = "", int priority = 100, int staticFlags = CF_GLOBAL_MENU, int groupId = GI_NORMAL);
43 
44  void SetPriority(int priority);
45  void SetStaticFlags(int flags);
46  void SetGroupId(int groupId);
47 
51  void ResetChilds();
52 
61  void InsertChild(CHierarchicalCommand* commandPtr, bool releaseFlag = false, int index = -1);
62 
66  void RemoveChild(int index);
67 
72  void JoinLinkFrom(const ibase::IHierarchicalCommand* rootPtr);
73 
82  void SetVisuals(const QString& name, const QString& shortName, const QString& description, const QIcon& icon = QIcon());
83 
84  // reimplemented (ibase::ICommand)
85  virtual int GetPriority() const;
86  virtual int GetGroupId() const;
87  virtual int GetStaticFlags() const;
88  virtual bool Execute(istd::IPolymorphic* contextPtr);
89 
90  // reimplemented (istd::TIHierarchical<ibase::ICommand>)
91  virtual int GetChildsCount() const;
92  virtual ibase::ICommand* GetChild(int index) const;
93 
94  // reimplemented (iprm::INameParam)
95  virtual void SetName(const QString& name);
96 
97  // reimplemented (iprm::IEnableableParam)
98  virtual bool SetEnabled(bool isEnabled = true);
99 
100  // reimplemented (iser::ISerializable)
101  virtual bool Serialize(iser::IArchive& archive);
102 
103  // reimplemented (istd::IChangeable)
104  virtual int GetSupportedOperations() const;
105  virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS);
106  virtual bool IsEqual(const istd::IChangeable& object) const;
107 
108  // operators
109  bool operator==(const CHierarchicalCommand& command) const;
110  bool operator!=(const CHierarchicalCommand& command) const;
112 
113 protected Q_SLOTS:
114  void OnTriggered();
115 
116 protected:
122  int FindTheSameCommand(const ibase::IHierarchicalCommand& command) const;
126  int FindInsertingIndex(int priority) const;
127 
128 private:
129  int m_priority;
130  int m_staticFlags;
131  int m_groupId;
132 
134  Childs m_childs;
135 };
136 
137 
138 } // namespace iqtgui
139 
140 
141 #endif // !iqtgui_CHierarchicalCommand_included
142 
143 
Implementation of hierarchical command based on QAction from Qt.
void SetStaticFlags(int flags)
CHierarchicalCommand(const QString &name="", int priority=100, int staticFlags=CF_GLOBAL_MENU, int groupId=GI_NORMAL)
External references are simple ignored.
Definition: IChangeable.h:197
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
Copy this object from another one.
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
void ResetChilds()
Reset list of childs.
virtual bool Execute(istd::IPolymorphic *contextPtr)
void InsertChild(CHierarchicalCommand *commandPtr, bool releaseFlag=false, int index=-1)
Insert command to child list.
virtual bool SetEnabled(bool isEnabled=true)
Set something to isEnabled state.
Implementation of a named object over iprm::INameParam interface.
Definition: CNameParam.h:16
void JoinLinkFrom(const ibase::IHierarchicalCommand *rootPtr)
Joint the second root as links.
Provides single command for interaction with user.
Definition: ICommand.h:18
Template based implementation of a hierarchical object.
int FindTheSameCommand(const ibase::IHierarchicalCommand &command) const
Find the same command in child list.
void SetVisuals(const QString &name, const QString &shortName, const QString &description, const QIcon &icon=QIcon())
Set all visual elements of this command.
Basic implementation of IEnableableParam interface.
void SetGroupId(int groupId)
iprm::CEnableableParam BaseClass2
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Base interface for all used interfaces and implementations.
Definition: IPolymorphic.h:17
bool operator!=(const CHierarchicalCommand &command) const
CHierarchicalCommand & operator=(const CHierarchicalCommand &command)
void SetPriority(int priority)
virtual bool IsEqual(const istd::IChangeable &object) const
Compare this object with another object.
Common interface to define the hierarchical graph structures.
virtual int GetSupportedOperations() const
Get set of flags for supported operations.
virtual ibase::ICommand * GetChild(int index) const
Get child value.
int FindInsertingIndex(int priority) const
Find index where element with specified priority should be inserted.
bool operator==(const CHierarchicalCommand &command) const
virtual int GetPriority() const
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
virtual int GetChildsCount() const
Get number of childs.
void RemoveChild(int index)
Remove child at specified index.
virtual void SetName(const QString &name)
Set the object name.
virtual int GetGroupId() const
virtual int GetStaticFlags() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy