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, "EnvironmentManager", "Allows access to component environment information", true, "EnvironmentManager");
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::IRegistry& registry,
74  const icomp::CComponentAddress& address,
75  QTreeWidgetItem* registryElementItemPtr);
76 
77  void CreateRegistryTree(const icomp::IRegistry& registry, QTreeWidgetItem* registryRootItemPtr);
78 
79 protected:
84  class EnvironmentObserver: public imod::TSingleModelObserverBase<icomp::IComponentEnvironmentManager>
85  {
86  public:
88 
89  protected:
90  // reimplemented (imod::TSingleModelObserverBase)
91  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
92 
93  private:
94  CRegistryTreeViewComp& m_parent;
95  };
96 
102  QTreeWidgetItem* AddRegistryElementItem(
103  const icomp::IRegistry& registry,
104  const icomp::IRegistry::ElementInfo* elementPtr,
105  const QByteArray& elementId,
106  QTreeWidgetItem* parentItemPtr);
107 
111  bool IsRegistryValid(const icomp::IRegistry& registry) const;
112 
116  void UpdateRegistryStatus();
117 
122 
123  // reimplemented (iqtgui::TGuiObserverWrap)
124  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
125  virtual void OnGuiModelDetached();
126 
127  // reimplemented (iqtgui::CGuiComponentBase)
128  virtual void OnGuiCreated();
129 
130  // reimplemented (imod::CSingleModelObserverBase)
131  virtual void AfterUpdate(imod::IModel* modelPtr, const istd::IChangeable::ChangeSet& changeSet);
132 
133  // reimplemented (icomp::CComponentBase)
134  virtual void OnComponentCreated();
135  virtual void OnComponentDestroyed();
136 
137 protected Q_SLOTS:
139  void on_RegistryTree_itemDoubleClicked(QTreeWidgetItem* itemPtr, int column);
140  void on_FilterEdit_textChanged(const QString& filterText);
141  void on_ShowOnlyErrorsCheck_stateChanged(int state);
143 
144 private:
145  typedef QMap<QString, int> Histogram;
146 
147  void FillStatistics(const Histogram& dataHistogram, QTreeWidget& list) const;
148 
149 private:
150  class SelectionInfoImpl: virtual public IElementSelectionInfo
151  {
152  public:
153  SelectionInfoImpl(): m_parentPtr(NULL) {}
154 
155  void SetParent(CRegistryTreeViewComp* parentPtr);
156 
157  // reimplemented (icmpstr::IElementSelectionInfo)
158  virtual icomp::IRegistry* GetSelectedRegistry() const;
159  virtual Elements GetSelectedElements() const;
160 
161  private:
162  CRegistryTreeViewComp* m_parentPtr;
163  };
164 
165  friend class imod::TModelWrap<SelectionInfoImpl>;
166 
167  // static template methods for subelement access
168  template <class InterfaceType>
169  static InterfaceType* ExtractSelectionInfo(CRegistryTreeViewComp& component)
170  {
171  return &component.m_selectionInfo;
172  }
173 
174  I_REF(icomp::IComponentEnvironmentManager, m_envManagerCompPtr);
175  I_REF(imod::IModel, m_envManagerModelCompPtr);
176  I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
177  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
178 
179  typedef QSet<QByteArray> ElementIds;
180 
181  struct SelectedElements
182  {
183  SelectedElements()
184  :registryPtr(NULL)
185  {
186  }
187 
188  ElementIds selectedElementIds;
189  icomp::IRegistry* registryPtr;
190  };
191 
192  SelectedElements m_selectedElements;
193 
194  EnvironmentObserver m_environmentObserver;
195 
196  imod::TModelWrap<SelectionInfoImpl> m_selectionInfo;
197 
198  Histogram m_componentHistogram;
199  Histogram m_packageHistogram;
200  Histogram m_projectHistogram;
201 };
202 
203 
204 } // namespace icmpstr
205 
206 
207 #endif // !icmpstr_CRegistryTreeViewComp_included
208 
209 
void on_FilterEdit_textChanged(const QString &filterText)
void on_ShowOnlyErrorsCheck_stateChanged(int state)
void AddSubcomponents(const icomp::IRegistry &registry, const icomp::CComponentAddress &address, QTreeWidgetItem *registryElementItemPtr)
void CreateRegistryTree(const icomp::IRegistry &registry, QTreeWidgetItem *registryRootItemPtr)
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
void on_RegistryTree_itemDoubleClicked(QTreeWidgetItem *itemPtr, int column)
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet)
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
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
bool IsRegistryValid(const icomp::IRegistry &registry) const
Calculate visual status of the entire registry tree.
#define NULL
EnvironmentObserver(CRegistryTreeViewComp *parentPtr)
virtual void OnComponentDestroyed()
Interface containing all information about registry selected element.
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-2017 Witold Gantzke and Kirill Lepskiy