CRegistryTreeViewComp.h
Go to the documentation of this file.
1 #ifndef icmpstr_CRegistryTreeViewComp_included
2 #define icmpstr_CRegistryTreeViewComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QMap>
7 #include <QtCore/QTimer>
8 
9 // ACF includes
10 #include "ifile/IFilePersistence.h"
11 #include "iser/CArchiveTag.h"
12 
13 #include "imod/TModelWrap.h"
14 
15 #include "icomp/IRegistry.h"
17 #include "icomp/CRegistryElement.h"
18 
19 #include "idoc/IDocumentManager.h"
20 
23 
26 #include "GeneratedFiles/icmpstr/ui_CRegistryTreeViewComp.h"
27 
28 
29 namespace icmpstr
30 {
31 
32 
35  Ui::CRegistryTreeViewComp, icomp::IRegistry>
36 {
37  Q_OBJECT
38 
39 public:
41  Ui::CRegistryTreeViewComp, icomp::IRegistry> BaseClass;
42 
43  enum DataRole
44  {
45  DR_MESSAGE_LIST = Qt::UserRole + 1,
46  DR_ELEMENT_NAME = Qt::UserRole + 2,
47  DR_ELEMENT_ID = Qt::UserRole + 3,
48  DR_ELEMENT_PACKAGE_ID = Qt::UserRole + 4,
49  DR_REGISTRY = Qt::UserRole + 5
50  };
51 
53  {
57  };
58 
59  I_BEGIN_COMPONENT(CRegistryTreeViewComp);
60  I_REGISTER_SUBELEMENT(SelectionInfo);
61  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, IElementSelectionInfo, ExtractSelectionInfo);
62  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, imod::IModel, ExtractSelectionInfo);
63  I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, istd::IChangeable, ExtractSelectionInfo);
64  I_ASSIGN(m_envManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
65  I_ASSIGN_TO(m_envManagerModelCompPtr, m_envManagerCompPtr, false);
66  I_ASSIGN(m_consistInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
67  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager allowing to load files on double click", false, "DocumentManager");
68  I_END_COMPONENT;
69 
71 
72  void AddSubcomponents(
73  const icomp::CComponentAddress& address,
74  QTreeWidgetItem* registryElementItemPtr);
75 
76  void CreateRegistryTree(const icomp::IRegistry& registry, QTreeWidgetItem* registryRootItemPtr);
77 
78 protected:
79  class EnvironmentObserver: public imod::TSingleModelObserverBase<icomp::IComponentEnvironmentManager>
80  {
81  public:
83 
84  protected:
85  // reimplemented (imod::TSingleModelObserverBase)
86  virtual void OnUpdate(int updateFlags, istd::IPolymorphic* updateParamsPtr);
87 
88  private:
89  CRegistryTreeViewComp& m_parent;
90  };
91 
97  QTreeWidgetItem* AddRegistryElementItem(
98  const icomp::IRegistry& registry,
99  const icomp::IRegistry::ElementInfo* elementPtr,
100  const QByteArray& elementId,
101  QTreeWidgetItem* parentItemPtr);
102 
106  bool IsRegistryValid(const icomp::IRegistry& registry) const;
107 
111  void UpdateRegistryStatus();
112 
117 
118  // reimplemented (iqtgui::TGuiObserverWrap)
119  virtual void UpdateGui(int updateFlags);
120  virtual void OnGuiModelDetached();
121 
122  // reimplemented (iqtgui::CGuiComponentBase)
123  virtual void OnGuiCreated();
124 
125  // reimplemented (imod::CSingleModelObserverBase)
126  virtual void AfterUpdate(imod::IModel* modelPtr, int updateFlags, istd::IPolymorphic* updateParamsPtr);
127 
128  // reimplemented (icomp::CComponentBase)
129  virtual void OnComponentCreated();
130  virtual void OnComponentDestroyed();
131 
132 protected Q_SLOTS:
134  void on_RegistryTree_itemDoubleClicked(QTreeWidgetItem* itemPtr, int column);
135  void on_FilterEdit_textChanged(const QString& filterText);
136  void on_ShowOnlyErrorsCheck_stateChanged(int state);
137 
138 private:
139  class SelectionInfoImpl: virtual public IElementSelectionInfo
140  {
141  public:
142  void SetParent(CRegistryTreeViewComp* parentPtr);
143 
144  // reimplemented (icmpstr::IElementSelectionInfo)
145  virtual icomp::IRegistry* GetSelectedRegistry() const;
146  virtual Elements GetSelectedElements() const;
147 
148  private:
149  CRegistryTreeViewComp* m_parentPtr;
150  };
151 
152  friend class imod::TModelWrap<SelectionInfoImpl>;
153 
154  // static template methods for subelement access
155  template <class InterfaceType>
156  static InterfaceType* ExtractSelectionInfo(CRegistryTreeViewComp& component)
157  {
158  return &component.m_selectionInfo;
159  }
160 
161  I_REF(icomp::IComponentEnvironmentManager, m_envManagerCompPtr);
162  I_REF(imod::IModel, m_envManagerModelCompPtr);
163  I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
164  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
165 
166  typedef QSet<QByteArray> ElementIds;
167 
168  struct SelectedElements
169  {
170  SelectedElements()
171  :registryPtr(NULL)
172  {
173  }
174 
175  ElementIds selectedElementIds;
176  icomp::IRegistry* registryPtr;
177  };
178 
179  SelectedElements m_selectedElements;
180 
181  EnvironmentObserver m_environmentObserver;
182 
183  imod::TModelWrap<SelectionInfoImpl> m_selectionInfo;
184 };
185 
186 
187 } // namespace icmpstr
188 
189 
190 #endif // !icmpstr_CRegistryTreeViewComp_included
191 
192 
void on_FilterEdit_textChanged(const QString &filterText)
void on_ShowOnlyErrorsCheck_stateChanged(int state)
virtual void UpdateGui(int updateFlags)
void CreateRegistryTree(const icomp::IRegistry &registry, QTreeWidgetItem *registryRootItemPtr)
void on_RegistryTree_itemDoubleClicked(QTreeWidgetItem *itemPtr, int column)
virtual void AfterUpdate(imod::IModel *modelPtr, int updateFlags, istd::IPolymorphic *updateParamsPtr)
QTreeWidgetItem * AddRegistryElementItem(const icomp::IRegistry &registry, const icomp::IRegistry::ElementInfo *elementPtr, const QByteArray &elementId, QTreeWidgetItem *parentItemPtr)
Create instance of shape representing some element.
iqtgui::TDesignerGuiObserverCompBase< Ui::CRegistryTreeViewComp, icomp::IRegistry > BaseClass
I_REGISTER_SUBELEMENT(SelectionInfo)
virtual void OnUpdate(int updateFlags, istd::IPolymorphic *updateParamsPtr)
bool IsRegistryValid(const icomp::IRegistry &registry) const
Calculate visual status of the entire registry tree.
#define NULL
EnvironmentObserver(CRegistryTreeViewComp *parentPtr)
virtual void OnComponentDestroyed()
I_ASSIGN_TO(m_envManagerModelCompPtr, m_envManagerCompPtr, false)
I_REGISTER_SUBELEMENT_INTERFACE(SelectionInfo, IElementSelectionInfo, ExtractSelectionInfo)
Interface containing all information about registry selected element.
void AddSubcomponents(const icomp::CComponentAddress &address, QTreeWidgetItem *registryElementItemPtr)
void UpdateRegistryStatus()
Update visual state of the registry validation.
void UpdateTreeItemsVisibility()
Update visibility state of the registry tree elements according to the settings of the item filter...

© 2007-2011 Witold Gantzke and Kirill Lepskiy