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"
18 #include "ifile/IFileNameParam.h"
19 #include "idoc/IHelpViewer.h"
20 #include "idoc/IDocumentManager.h"
23 
24 // ACF-Solutions includes
28 
29 #include "GeneratedFiles/icmpstr/ui_CPackageOverviewComp.h"
30 
31 
32 namespace icmpstr
33 {
34 
35 
37  public iqtgui::TDesignerGuiObserverCompBase<Ui::CPackageOverviewComp, IElementSelectionInfo>,
38  virtual public ibase::ICommandsProvider,
39  virtual public IAttributeSelectionObserver
40 {
41  Q_OBJECT
42 
43 public:
45 
46  I_BEGIN_COMPONENT(CPackageOverviewComp);
47  I_REGISTER_INTERFACE(ibase::ICommandsProvider);
48  I_REGISTER_INTERFACE(IAttributeSelectionObserver);
49  I_ASSIGN(m_envManagerCompPtr, "EnvironmentManager", "Packages manager used to provide icon paths", true, "PackagesManager");
50  I_ASSIGN(m_consistInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and access to buffered icons", false, "ConsistencyInfo");
51  I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Show help of selected component using its address", false, "HelpViewer");
52  I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager allowing to load files on double click", false, "DocumentManager");
53  I_ASSIGN(m_configFilePathCompPtr, "ConfigFilePath", "Path of packages configuration file will be loaded, if enabled", false, "ConfigFilePath");
54  I_ASSIGN_TO(m_configFilePathModelCompPtr, m_configFilePathCompPtr, false);
55  I_END_COMPONENT;
56 
58 
59  // reimplemented (ibase::ICommandsProvider)
60  virtual const ibase::IHierarchicalCommand* GetCommands() const;
61 
62  // reimplemented (icmpstr::IAttributeSelectionObserver)
63  virtual void OnAttributeSelected(const icomp::IAttributeStaticInfo* attributeStaticInfoPtr);
64 
65 protected:
66  struct RootInfo
67  {
69 
70  QTreeWidgetItem* itemPtr;
73  };
74 
75  void GenerateComponentTree(bool forceUpdate);
76  void UpdateComponentGroups();
77  void UpdateInterfaceList();
78  void UpdateAllLists();
79 
83  icomp::IMetaInfoManager::ComponentAddresses GetFilteredComponentAdresses() const;
84 
88  QPixmap CreateComponentDragPixmap(const icomp::CComponentAddress &address) const;
89 
90  RootInfo& EnsureRoot(const QByteArray& path, const icomp::CComponentAddress& address, const icomp::IComponentStaticInfo* staticInfoPtr);
91 
92  void SetCommandNames();
93 
94  // reimplemented (QObject)
95  virtual bool eventFilter(QObject* sourcePtr, QEvent* eventPtr);
96 
97  // reimplemented (iqtgui::TGuiObserverWrap)
98  virtual void UpdateGui(int updateFlags = 0);
99 
100  // reimplemented (iqtgui::CGuiComponentBase)
101  virtual void OnGuiCreated();
102  virtual void OnGuiDestroyed();
103  virtual void OnRetranslate();
104  virtual void OnGuiRetranslate();
105 
106 protected Q_SLOTS:
108  void on_GroupByCB_currentIndexChanged(int index);
110  void on_PackagesList_itemExpanded(QTreeWidgetItem* item);
111  void on_PackagesList_itemClicked(QTreeWidgetItem* item, int column);
112  void on_PackagesList_itemDoubleClicked(QTreeWidgetItem* item, int column);
113  void on_FilterGB_toggled(bool on);
114  void on_InterfaceCB_currentIndexChanged(int index);
115  void OnReloadPackages();
118 
119 private:
120  class PackageItemBase: public QTreeWidgetItem
121  {
122  public:
123  PackageItemBase(
124  CPackageOverviewComp& parent,
125  const QString& description,
126  const QIcon& icon = QIcon());
127 
128  virtual const QString& GetDescription() const;
129 
130  protected:
131  CPackageOverviewComp& m_parent;
132  QString m_description;
133  };
134 
135  class PackageComponentItem: public PackageItemBase
136  {
137  public:
138  typedef PackageItemBase BaseClass;
139 
140  PackageComponentItem(
141  CPackageOverviewComp& parent,
142  const icomp::CComponentAddress& address,
143  const icomp::IComponentStaticInfo* staticInfoPtr,
144  const QIcon& icon);
145 
146  bool IsInterfaceSupported(const istd::CClassInfo& interfaceInfo) const;
147  const icomp::CComponentAddress& GetAddress() const;
148 
149  private:
150  icomp::CComponentAddress m_address;
151  };
152 
153  class PackageItem: public PackageItemBase
154  {
155  public:
156  typedef PackageItemBase BaseClass;
157 
158  PackageItem(
159  CPackageOverviewComp& parent,
160  const QString& description,
161  const QIcon& icon = QIcon());
162  };
163 
164  class RegistryObserver: public imod::CSingleModelObserverBase
165  {
166  public:
167  RegistryObserver(CPackageOverviewComp* parentPtr);
168 
169  protected:
170  // reimplemented (imod::CSingleModelObserverBase)
171  virtual void OnUpdate(int updateFlags, istd::IPolymorphic* updateParamsPtr);
172 
173  private:
174  CPackageOverviewComp& m_parent;
175  };
176 
177  class ConfigObserver: public imod::CSingleModelObserverBase
178  {
179  public:
180  ConfigObserver(CPackageOverviewComp* parentPtr);
181 
182  protected:
183  // reimplemented (imod::CSingleModelObserverBase)
184  virtual void OnUpdate(int updateFlags, istd::IPolymorphic* updateParamsPtr);
185 
186  private:
187  CPackageOverviewComp& m_parent;
188  };
189 
190  enum GruppingMode
191  {
192  GM_NONE,
193  GM_PACKAGE
194  };
195 
196  I_REF(icomp::IComponentEnvironmentManager, m_envManagerCompPtr);
197  I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
198  I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
199  I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
200  I_REF(ifile::IFileNameParam, m_configFilePathCompPtr);
201  I_REF(imod::IModel, m_configFilePathModelCompPtr);
202 
203  iqtgui::CHierarchicalCommand m_commands;
204  iqtgui::CHierarchicalCommand m_packagesCommand;
205  iqtgui::CHierarchicalCommand m_reloadCommand;
206 
207  typedef QMap<QByteArray, RootInfo> RootInfos;
208  RootInfos m_roots;
209 
210  RegistryObserver m_registryObserver;
211  ConfigObserver m_configObserver;
212 
213  typedef QSet<QByteArray> InterfaceFilter;
214  InterfaceFilter m_interfaceFilter;
215  QStringList m_keywordsFilter;
216 
217  QIcon m_realComponentIcon;
218  QIcon m_compositeComponentIcon;
219  QIcon m_mixedComponentIcon;
220  QIcon m_embeddedComponentIcon;
221 
222  typedef QMap<QString, QTreeWidget*> CategoryWidgetsMap;
223  CategoryWidgetsMap m_categoryWidgetsMap;
224 
225  icomp::IMetaInfoManager::ComponentAddresses m_shownAddresses;
226 
227  int m_currentPackageGroupIndex;
228  bool m_startDrag;
229  QPoint m_starDragPosition;
230 
231  friend class CItemDelegate;
232 };
233 
234 
235 } // namespace icmpstr
236 
237 
238 #endif // !icmpstr_CPackageOverviewComp_included
239 
void on_PackagesList_itemExpanded(QTreeWidgetItem *item)
virtual void UpdateGui(int updateFlags=0)
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)
void on_PackagesList_itemClicked(QTreeWidgetItem *item, int column)
icomp::IMetaInfoManager::ComponentAddresses GetFilteredComponentAdresses() const
Get a list of components that match the filter criteria.
I_ASSIGN_TO(m_configFilePathModelCompPtr, m_configFilePathCompPtr, false)
#define NULL
iqtgui::TDesignerGuiObserverCompBase< Ui::CPackageOverviewComp, IElementSelectionInfo > BaseClass
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)

© 2007-2011 Witold Gantzke and Kirill Lepskiy