CAttributeEditorComp.h
Go to the documentation of this file.
1 #ifndef icmpstr_CAttributeEditorComp_included
2 #define icmpstr_CAttributeEditorComp_included
3 
4 
5 // Qt includes
6 #include <QtGui/QIcon>
7 #if QT_VERSION >= 0x050000
8 #include <QtWidgets/QWidget>
9 #include <QtWidgets/QItemDelegate>
10 #else
11 #include <QtGui/QWidget>
12 #include <QtGui/QItemDelegate>
13 #endif
14 
15 // ACF includes
16 #include "istd/CClassInfo.h"
17 #include "idoc/IHelpViewer.h"
20 #include "iqtgui/CItemDelegate.h"
21 
22 // ACF-Solutions includes
25 #include "GeneratedFiles/icmpstr/ui_CAttributeEditorComp.h"
26 
27 
28 namespace icmpstr
29 {
30 
31 
34  iqtgui::TGuiObserverWrap<
35  iqtgui::TDesignerGuiCompBase<Ui::CAttributeEditorComp>, CElementSelectionInfoManagerBase> >
36 {
37  Q_OBJECT
38 
39 public:
43 
44  I_BEGIN_COMPONENT(CAttributeEditorComp);
45  I_REGISTER_INTERFACE(imod::IModelEditor);
46  I_ASSIGN(m_metaInfoManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
47  I_ASSIGN(m_attributeSelectionObserverCompPtr, "AttributeSelectionObserver", "Attribute selection observer", false, "AttributeSelectionObserver");
48  I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Shows object info during selection using its type", false, "QuickHelpGui");
49  I_ASSIGN(m_consistInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
50  I_ASSIGN(m_registryPropGuiCompPtr, "RegistryPropGui", "Display and edit registry properties if no element is selected", false, "RegistryPropGui");
51  I_ASSIGN_TO(m_registryPropObserverCompPtr, m_registryPropGuiCompPtr, false);
52  I_END_COMPONENT;
53 
54  enum TabIndex
55  {
61  };
62 
64  {
65  AM_NONE = 0,
74  };
75 
77  {
78  AC_NAME = 0,
80  };
81 
83  {
84  AttributeMining = Qt::UserRole + 1,
90  };
91 
92 public:
94 
95  // reimplemented (CElementSelectionInfoManagerBase)
98 
99 protected Q_SLOTS:
101  void on_AttributeTree_itemChanged(QTreeWidgetItem* item, int column);
103  void on_InterfacesTree_itemChanged(QTreeWidgetItem* item, int column);
104  void on_AutoInstanceCB_toggled(bool checked);
105  void UpdateGeneralView();
106  void UpdateAttributesView();
107  void UpdateInterfacesView();
108  void UpdateFlagsView();
110 
111 Q_SIGNALS:
112  void AfterAttributesChange();
113  void AfterInterfacesChange();
115 
116 protected:
117  struct AttrInfo
118  {
122  };
123 
124  typedef QMap<QByteArray, AttrInfo> ElementIdToAttrInfoMap;
125  typedef QMap<QByteArray, ElementIdToAttrInfoMap> AttrInfosMap;
126 
127  bool SetAttributeToItem(
128  QTreeWidgetItem& attributeItem,
129  const icomp::IRegistry& registry,
130  const QByteArray& attributeId,
131  const ElementIdToAttrInfoMap& infos,
132  bool& hasError,
133  bool& hasWarning,
134  bool& hasExport) const;
135  bool SetInterfaceToItem(
136  QTreeWidgetItem& item,
137  icomp::IRegistry::ExportedInterfacesMap* interfacesMapPtr,
138  const QByteArray& elementId,
139  const QByteArray& interfaceName,
140  bool& hasWarning,
141  bool& hasExport) const;
142  bool ResetItem(QTreeWidgetItem& item);
143  bool DecodeAttribute(
144  const iser::ISerializable& attribute,
145  QString& text,
146  int& meaning) const;
147  bool EncodeAttribute(
148  const QString& text,
149  int meaning,
150  iser::ISerializable& result) const;
151 
153  const QByteArray& elementId,
154  const icomp::IElementStaticInfo* infoPtr,
155  icomp::IRegistry::ExportedInterfacesMap& registryInterfaces,
156  QTreeWidgetItem* parentItemPtr,
157  bool& hasWarning,
158  bool& hasExport,
159  bool includeSubelement);
161  const QByteArray& elementId,
162  const QByteArray& globalElementId,
163  const icomp::IElementStaticInfo* elementMetaInfoPtr,
164  QTreeWidgetItem& item,
165  bool& hasWarning,
166  bool& hasExport) const;
167 
168  // reimplemented (iqt::TGuiObserverWrap)
169  virtual void OnGuiModelDetached();
170  virtual void UpdateGui(int updateFlags = 0);
171 
172  // reimplemented (CGuiComponentBase)
173  virtual void OnGuiCreated();
174  virtual void OnGuiDestroyed();
175 
176  // static methods
177  static QString DecodeFromEdit(const QString& text);
178  static QString EncodeToEdit(const QString& text);
179 
180 private:
181  class AttributeItemDelegate: public iqtgui::CItemDelegate
182  {
183  public:
185 
186  AttributeItemDelegate(CAttributeEditorComp* parentPtr);
187 
188  template <class AttributeImpl>
189  static QString GetMultiAttributeValueAsString(const AttributeImpl& attribute);
190 
191  // reimplemented (QItemDelegate)
192  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
193  virtual void setEditorData(QWidget* editor, const QModelIndex& index ) const;
194  virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
195 
196  protected:
197  bool SetComponentExportEditor(const QByteArray& attributeId, const QString& defaultValue, QWidget& editor) const;
198  bool SetAttributeExportEditor(const QByteArray& id, const QByteArray& exportId, QWidget& editor) const;
199  bool SetAttributeValueEditor(const QByteArray& id, int propertyMining, QWidget& editor) const;
200 
201  bool SetComponentValue(const QByteArray& attributeId, int propertyMining, const QString& value) const;
202  bool SetComponentExportData(const QByteArray& attributeId, const QString& value) const;
203 
204  private:
205  CAttributeEditorComp& m_parent;
206  };
207 
208  class RegistryObserver: public imod::CSingleModelObserverBase
209  {
210  public:
211  RegistryObserver(CAttributeEditorComp* parentPtr);
212 
213  protected:
214  // reimplemented (imod::CSingleModelObserverBase)
215  virtual void OnUpdate(int updateFlags, istd::IPolymorphic* updateParamsPtr);
216 
217  private:
218  CAttributeEditorComp& m_parent;
219  };
220 
221  I_REF(icomp::IComponentEnvironmentManager, m_metaInfoManagerCompPtr);
222  I_REF(IAttributeSelectionObserver, m_attributeSelectionObserverCompPtr);
223  I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
224  I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
225  I_REF(iqtgui::IGuiObject, m_registryPropGuiCompPtr);
226  I_REF(imod::IObserver, m_registryPropObserverCompPtr);
227 
228  AttributeItemDelegate m_attributeItemDelegate;
229  RegistryObserver m_registryObserver;
230 
231  typedef QMap<QByteArray, QString> AttributeTypesMap;
232  AttributeTypesMap m_attributeTypesMap;
233 
234  AttrInfosMap m_attrInfosMap; // all current displayed attributes
235 
236  istd::TDelPtr<iqtgui::CTreeWidgetFilter> m_attributesTreeFilter;
237  istd::TDelPtr<iqtgui::CTreeWidgetFilter> m_interfacesTreeFilter;
238  istd::TDelPtr<iqtgui::CTreeWidgetFilter> m_subcomponentsTreeFilter;
239 
240  imod::IModel* m_lastRegistryModelPtr;
241 
242  QIcon m_invalidIcon;
243  QIcon m_warningIcon;
244  QIcon m_exportIcon;
245  QIcon m_importIcon;
246 };
247 
248 
249 // public static methods
250 
251 template <class AttributeImpl>
252 QString CAttributeEditorComp::AttributeItemDelegate::GetMultiAttributeValueAsString(const AttributeImpl& attribute)
253 {
254  QString valuesString;
255  for (int index = 0; index < attribute.GetValuesCount(); index++){
256  if (!valuesString.isEmpty()){
257  valuesString += ";";
258  }
259 
260  valuesString += attribute.GetValueAt(index);
261  }
262 
263  return valuesString;
264 }
265 
266 
267 } // namespace icmpstr
268 
269 
270 #endif // !icmpstr_CAttributeEditorComp_included
271 
void CreateExportedComponentsTree(const QByteArray &elementId, const QByteArray &globalElementId, const icomp::IElementStaticInfo *elementMetaInfoPtr, QTreeWidgetItem &item, bool &hasWarning, bool &hasExport) const
QMap< QByteArray, ElementIdToAttrInfoMap > AttrInfosMap
bool EncodeAttribute(const QString &text, int meaning, iser::ISerializable &result) const
void CreateInterfacesTree(const QByteArray &elementId, const icomp::IElementStaticInfo *infoPtr, icomp::IRegistry::ExportedInterfacesMap &registryInterfaces, QTreeWidgetItem *parentItemPtr, bool &hasWarning, bool &hasExport, bool includeSubelement)
bool DecodeAttribute(const iser::ISerializable &attribute, QString &text, int &meaning) const
bool SetInterfaceToItem(QTreeWidgetItem &item, icomp::IRegistry::ExportedInterfacesMap *interfacesMapPtr, const QByteArray &elementId, const QByteArray &interfaceName, bool &hasWarning, bool &hasExport) const
void on_InterfacesTree_itemChanged(QTreeWidgetItem *item, int column)
bool SetAttributeToItem(QTreeWidgetItem &attributeItem, const icomp::IRegistry &registry, const QByteArray &attributeId, const ElementIdToAttrInfoMap &infos, bool &hasError, bool &hasWarning, bool &hasExport) const
void on_AutoInstanceCB_toggled(bool checked)
I_ASSIGN_TO(m_registryPropObserverCompPtr, m_registryPropGuiCompPtr, false)
const icomp::IAttributeStaticInfo * staticInfoPtr
static QString EncodeToEdit(const QString &text)
virtual void UpdateGui(int updateFlags=0)
virtual void OnGuiModelDetached()
ibase::TModelObserverCompWrap< iqtgui::TGuiObserverWrap< iqtgui::TDesignerGuiCompBase< Ui::CAttributeEditorComp >, CElementSelectionInfoManagerBase > > BaseClass
icomp::IRegistryElement::AttributeInfo * infoPtr
QMap< QByteArray, AttrInfo > ElementIdToAttrInfoMap
void on_AttributeTree_itemChanged(QTreeWidgetItem *item, int column)
bool ResetItem(QTreeWidgetItem &item)
virtual const icomp::IComponentEnvironmentManager * GetMetaInfoManagerPtr() const
virtual const icmpstr::IRegistryConsistInfo * GetConsistencyInfoPtr() const
static QString DecodeFromEdit(const QString &text)

© 2007-2011 Witold Gantzke and Kirill Lepskiy