CPackageOverviewComp.h
Go to the documentation of this file.
1 #ifndef icmpstr_CPackageOverviewComp_included
2 #define icmpstr_CPackageOverviewComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QDir>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QTreeWidget>
9 #else
10 #include <QtGui/QTreeWidget>
11 #endif
12 
13 // ACF includes
14 #include <istd/TDelPtr.h>
19 #include <ifile/IFileNameParam.h>
20 #include <idoc/IHelpViewer.h>
21 #include <idoc/IDocumentManager.h>
24 
25 // ACF-Solutions includes
29 
30 #include <GeneratedFiles/icmpstr/ui_CPackageOverviewComp.h>
31 
32 
33 namespace icmpstr
34 {
35 
36 
38  public iqtgui::TDesignerGuiObserverCompBase<Ui::CPackageOverviewComp, icomp::IRegistry>,
39  virtual public ibase::ICommandsProvider,
40  virtual public IAttributeSelectionObserver
41 {
42  Q_OBJECT
43 
44 public:
46 
47  I_BEGIN_COMPONENT(CPackageOverviewComp);
48  I_REGISTER_INTERFACE(ibase::ICommandsProvider);
49  I_REGISTER_INTERFACE(IAttributeSelectionObserver);
50  I_REGISTER_SUBELEMENT(LocalMetaInfoManager);
51  I_REGISTER_SUBELEMENT_INTERFACE(LocalMetaInfoManager, icomp::IMetaInfoManager, ExtractLocalMetaInfoManager);
52  I_REGISTER_SUBELEMENT_INTERFACE(LocalMetaInfoManager, imod::IModel, ExtractLocalMetaInfoManager);
53  I_REGISTER_SUBELEMENT_INTERFACE(LocalMetaInfoManager, istd::IChangeable, ExtractLocalMetaInfoManager);
54  I_REGISTER_SUBELEMENT_INTERFACE(LocalMetaInfoManager, istd::IPolymorphic, ExtractLocalMetaInfoManager);
55  I_ASSIGN(m_envManagerCompPtr, "EnvironmentManager", "Packages manager used to provide icon paths", true, "PackagesManager");
56  I_ASSIGN(m_consistInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and access to buffered icons", false, "ConsistencyInfo");
57  I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Show help of selected component using its address", false, "HelpViewer");
58  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager allowing to load files on double click", false, "DocumentManager");
59  I_ASSIGN(m_configFilePathCompPtr, "ConfigFilePath", "Path of packages configuration file will be loaded, if enabled", false, "ConfigFilePath");
60  I_ASSIGN_TO(m_configFilePathModelCompPtr, m_configFilePathCompPtr, false);
61  I_END_COMPONENT;
62 
64 
65  // reimplemented (ibase::ICommandsProvider)
66  virtual const ibase::IHierarchicalCommand* GetCommands() const;
67 
68  // reimplemented (icmpstr::IAttributeSelectionObserver)
69  virtual void OnAttributeSelected(const icomp::IAttributeStaticInfo* attributeStaticInfoPtr);
70 
71 protected:
72  struct RootInfo
73  {
75 
76  QTreeWidgetItem* itemPtr;
79  };
80 
81  typedef QSet<QString> MetaInfoFilter;
82 
83  void GenerateComponentTree(bool forceUpdate);
85  void UpdateSingleMetaInfoList(const MetaInfoFilter& filter, QComboBox& result);
86  void UpdateAllLists();
87 
91  icomp::IMetaInfoManager::ComponentAddresses GetFilteredComponentAdresses() const;
92 
96  QPixmap CreateComponentDragPixmap(const icomp::CComponentAddress &address) const;
97 
98  RootInfo& EnsureRoot(const QByteArray& path, const icomp::CComponentAddress& address, const icomp::IComponentStaticInfo* staticInfoPtr);
99 
100  void SetCommandNames();
101 
102  // reimplemented (QObject)
103  virtual bool eventFilter(QObject* sourcePtr, QEvent* eventPtr);
104 
105  // reimplemented (iqtgui::TGuiObserverWrap)
106  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
107 
108  // reimplemented (iqtgui::CGuiComponentBase)
109  virtual void OnGuiCreated();
110  virtual void OnGuiDestroyed();
111  virtual void OnRetranslate();
112  virtual void OnGuiRetranslate();
113 
114 protected Q_SLOTS:
116  void on_GroupByCB_currentIndexChanged(int index);
118  void on_PackagesList_itemExpanded(QTreeWidgetItem* item);
119  void on_PackagesList_itemClicked(QTreeWidgetItem* item, int column);
120  void on_PackagesList_itemDoubleClicked(QTreeWidgetItem* item, int column);
121  void on_EnableFiltersButton_toggled(bool on);
122  void on_InterfaceCB_currentIndexChanged(int index);
123  void OnReloadPackages();
132 
133 private:
134  class PackageItemBase: public QTreeWidgetItem
135  {
136  public:
137  PackageItemBase(
138  CPackageOverviewComp& parent,
139  const QString& description,
140  const QIcon& icon = QIcon());
141 
142  virtual const QString& GetDescription() const;
143 
144  protected:
145  CPackageOverviewComp& m_parent;
146  QString m_description;
147  };
148 
149  class PackageComponentItem: public PackageItemBase
150  {
151  public:
152  typedef PackageItemBase BaseClass;
153 
154  PackageComponentItem(
155  CPackageOverviewComp& parent,
156  const icomp::CComponentAddress& address,
157  const icomp::IComponentStaticInfo* staticInfoPtr,
158  const QIcon& icon);
159 
160  bool IsInterfaceSupported(const istd::CClassInfo& interfaceInfo) const;
161  const icomp::CComponentAddress& GetAddress() const;
162 
163  private:
164  icomp::CComponentAddress m_address;
165  };
166 
167  class PackageItem: public PackageItemBase
168  {
169  public:
170  typedef PackageItemBase BaseClass;
171 
172  PackageItem(
173  CPackageOverviewComp& parent,
174  const QString& description,
175  const QIcon& icon = QIcon());
176  };
177 
178  class ConfigObserver: public imod::CSingleModelObserverBase
179  {
180  public:
181  ConfigObserver(CPackageOverviewComp* parentPtr);
182 
183  protected:
184  // reimplemented (imod::CSingleModelObserverBase)
185  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
186 
187  private:
188  CPackageOverviewComp& m_parent;
189  };
190 
191  class MetaInfoManager:
192  virtual public icomp::IMetaInfoManager,
194  {
195  public:
196  MetaInfoManager();
197 
198  void UpdateLocalMetaInfoMap();
199 
200  // reimplemented (icomp::IComponentListProvider)
201  virtual ComponentAddresses GetComponentAddresses(int typeFlag = CTF_ALL) const;
202 
203  // reimplemented (icomp::IMetaInfoManager)
204  virtual const icomp::IComponentStaticInfo* GetComponentMetaInfo(const icomp::CComponentAddress& address) const;
205  virtual const icomp::IComponentStaticInfo* GetPackageMetaInfo(const QByteArray& packageId) const;
206 
207  // reimplemented (icomp::IElementStaticInfo)
208  virtual Ids GetMetaIds(int metaGroupId) const;
209  virtual const icomp::IComponentStaticInfo* GetEmbeddedComponentInfo(const QByteArray& embeddedId) const;
210 
211  CPackageOverviewComp* parentPtr;
212 
213  private:
214  typedef QMap<QByteArray, istd::TDelPtr<const icomp::IComponentStaticInfo> > IdToInfoMap;
215  IdToInfoMap m_idToInfoMap;
216  };
217 
218  enum GruppingMode
219  {
220  GM_NONE,
221  GM_PACKAGE
222  };
223 
224  I_REF(icomp::IComponentEnvironmentManager, m_envManagerCompPtr);
225  I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
226  I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
227  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
228  I_REF(ifile::IFileNameParam, m_configFilePathCompPtr);
229  I_REF(imod::IModel, m_configFilePathModelCompPtr);
230 
231  iqtgui::CHierarchicalCommand m_commands;
232  iqtgui::CHierarchicalCommand m_packagesCommand;
233  iqtgui::CHierarchicalCommand m_reloadCommand;
234 
235  typedef QMap<QByteArray, RootInfo> RootInfos;
236  RootInfos m_roots;
237 
238  ConfigObserver m_configObserver;
239 
240  typedef QSet<QByteArray> InterfaceFilter;
241  InterfaceFilter m_interfaceFilter;
242  QStringList m_keywordsFilter;
243 
244  QIcon m_realComponentIcon;
245  QIcon m_compositeComponentIcon;
246  QIcon m_mixedComponentIcon;
247  QIcon m_embeddedComponentIcon;
248 
249  typedef QMap<QString, QTreeWidget*> CategoryWidgetsMap;
250  CategoryWidgetsMap m_categoryWidgetsMap;
251 
252  icomp::IMetaInfoManager::ComponentAddresses m_shownAddresses;
253 
254  imod::TModelWrap<MetaInfoManager> m_localMetaInfoManager;
255 
256  template <class InterfaceType>
257  static InterfaceType* ExtractLocalMetaInfoManager(CPackageOverviewComp& component)
258  {
259  return &component.m_localMetaInfoManager;
260  }
261 
262  int m_currentPackageGroupIndex;
263  bool m_startDrag;
264  QPoint m_starDragPosition;
265 
266  friend class CPackageItemDelegate;
267 };
268 
269 
270 } // namespace icmpstr
271 
272 
273 #endif // !icmpstr_CPackageOverviewComp_included
274 
void on_PackagesList_itemExpanded(QTreeWidgetItem *item)
virtual bool eventFilter(QObject *sourcePtr, QEvent *eventPtr)
void on_PackagesList_itemDoubleClicked(QTreeWidgetItem *item, int column)
void GenerateComponentTree(bool forceUpdate)
virtual void OnAttributeSelected(const icomp::IAttributeStaticInfo *attributeStaticInfoPtr)
RootInfo & EnsureRoot(const QByteArray &path, const icomp::CComponentAddress &address, const icomp::IComponentStaticInfo *staticInfoPtr)
iqtgui::TDesignerGuiObserverCompBase< Ui::CPackageOverviewComp, icomp::IRegistry > BaseClass
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
void on_PackagesList_itemClicked(QTreeWidgetItem *item, int column)
icomp::IMetaInfoManager::ComponentAddresses GetFilteredComponentAdresses() const
Get a list of components that match the filter criteria.
#define NULL
void UpdateSingleMetaInfoList(const MetaInfoFilter &filter, QComboBox &result)
void on_GroupByCB_currentIndexChanged(int index)
QPixmap CreateComponentDragPixmap(const icomp::CComponentAddress &address) const
Create the drag preview for the component.
virtual const ibase::IHierarchicalCommand * GetCommands() const
void on_InterfaceCB_currentIndexChanged(int index)
void on_EnableFiltersButton_toggled(bool on)

© 2007-2017 Witold Gantzke and Kirill Lepskiy