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 <iwidgets/CItemDelegate.h>
21 
22 // ACF-Solutions includes
24 #include <GeneratedFiles/icmpstr/ui_CAttributeEditorComp.h>
25 
26 
27 namespace icmpstr
28 {
29 
30 
33  iqtgui::TDesignerGuiCompBase<Ui::CAttributeEditorComp>,
34  CElementSelectionInfoManagerBase>
35 {
36  Q_OBJECT
37 
38 public:
42 
43  I_BEGIN_COMPONENT(CAttributeEditorComp);
44  I_REGISTER_INTERFACE(imod::IModelEditor);
45  I_ASSIGN(m_metaInfoManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
46  I_ASSIGN(m_attributeSelectionObserverCompPtr, "AttributeSelectionObserver", "Attribute selection observer", false, "AttributeSelectionObserver");
47  I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Shows object info during selection using its type", false, "QuickHelpGui");
48  I_ASSIGN(m_consistInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
49  I_ASSIGN(m_registryPropGuiCompPtr, "RegistryPropGui", "Display and edit registry properties if no element is selected", false, "RegistryPropGui");
50  I_ASSIGN_TO(m_registryPropObserverCompPtr, m_registryPropGuiCompPtr, false);
51  I_END_COMPONENT;
52 
53  enum TabIndex
54  {
60  };
61 
63  {
64  AM_NONE = 0,
75  };
76 
78  {
83  };
84 
86  {
87  AC_NAME = 0,
89  };
90 
92  {
93  AttributeMining = Qt::UserRole + 1,
99  };
100 
101 public:
103 
104  // reimplemented (CElementSelectionInfoManagerBase)
105  virtual const icomp::IMetaInfoManager* GetMetaInfoManagerPtr() const;
107 
108 protected Q_SLOTS:
110  void on_AttributeTree_itemChanged(QTreeWidgetItem* item, int column);
112  void on_InterfacesTree_itemChanged(QTreeWidgetItem* item, int column);
113  void on_AutoInstanceCB_toggled(bool checked);
114  void on_IsDetachedCB_toggled(bool checked);
115  void UpdateGeneralView();
116  void UpdateAttributesView();
117  void UpdateInterfacesView();
118  void UpdateFlagsView();
120 
121 Q_SIGNALS:
122  void AfterAttributesChange();
123  void AfterInterfacesChange();
125 
126 protected:
127  struct AttrInfo
128  {
133  };
134 
135  typedef QMap<QByteArray, AttrInfo> ElementIdToAttrInfoMap;
136  typedef QMap<QByteArray, ElementIdToAttrInfoMap> AttrInfosMap;
137 
138  bool SetAttributeToItem(
139  AttributeGroupType groupType,
140  int& itemIndex,
141  const icomp::IRegistry& registry,
142  const QByteArray& attributeId,
143  const ElementIdToAttrInfoMap& infos,
144  const QFont& normalFont,
145  const QFont& importantFont,
146  bool& hasError,
147  bool& hasWarning,
148  bool& hasExport) const;
149  bool SetInterfaceToItem(
150  QTreeWidgetItem& item,
151  icomp::IRegistry::ExportedInterfacesMap* interfacesMapPtr,
152  const QByteArray& elementId,
153  const QByteArray& interfaceName,
154  bool& hasWarning,
155  bool& hasExport,
156  bool readOnly) const;
157  bool ResetItem(QTreeWidgetItem& item);
158  bool DecodeAttribute(
159  const iser::ISerializable& attribute,
160  QString& text,
161  int& meaning) const;
162  bool EncodeAttribute(
163  const QString& text,
164  int meaning,
165  iser::ISerializable& result) const;
166 
168  const QByteArray& elementId,
169  const icomp::IElementStaticInfo* infoPtr,
170  icomp::IRegistry::ExportedInterfacesMap& registryInterfaces,
171  QTreeWidgetItem* parentItemPtr,
172  bool& hasWarning,
173  bool& hasExport,
174  bool includeSubelement,
175  bool readOnly);
177  const QByteArray& elementId,
178  const QByteArray& globalElementId,
179  const icomp::IElementStaticInfo* elementMetaInfoPtr,
180  QTreeWidgetItem& item,
181  bool& hasWarning,
182  bool& hasExport,
183  bool readOnly) const;
184 
185  // reimplemented (iqt::TGuiObserverWrap)
186  virtual void OnGuiModelDetached();
187  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
188 
189  // reimplemented (CGuiComponentBase)
190  virtual void OnGuiCreated();
191  virtual void OnGuiDestroyed();
192 
193  // static methods
194  static QString DecodeFromEdit(const QString& text);
195  static QString EncodeToEdit(const QString& text);
196 
197 private:
198  class AttributeItemDelegate: public iwidgets::CItemDelegate
199  {
200  public:
202 
203  AttributeItemDelegate(CAttributeEditorComp* parentPtr);
204 
205  template <class AttributeImpl>
206  static QString GetMultiAttributeValueAsString(const AttributeImpl& attribute);
207 
208  // reimplemented (QItemDelegate)
209  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
210  virtual void setEditorData(QWidget* editor, const QModelIndex& index ) const;
211  virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
212 
213  protected:
214  bool SetComponentExportEditor(const QByteArray& attributeId, const QString& defaultValue, QWidget& editor) const;
215  bool SetAttributeExportEditor(const QByteArray& id, const QByteArray& exportId, QWidget& editor) const;
216  bool SetAttributeValueEditor(const QByteArray& id, int propertyMining, QWidget& editor) const;
217 
218  bool SetComponentValue(const QByteArray& attributeId, int propertyMining, const QString& value) const;
219  bool SetComponentExportData(const QByteArray& attributeId, const QString& value) const;
220 
221  private:
222  CAttributeEditorComp& m_parent;
223  };
224 
225  class RegistryObserver: public imod::CSingleModelObserverBase
226  {
227  public:
228  RegistryObserver(CAttributeEditorComp* parentPtr);
229 
230  protected:
231  // reimplemented (imod::CSingleModelObserverBase)
232  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
233 
234  private:
235  CAttributeEditorComp& m_parent;
236  };
237 
238  I_REF(icomp::IMetaInfoManager, m_metaInfoManagerCompPtr);
239  I_REF(IAttributeSelectionObserver, m_attributeSelectionObserverCompPtr);
240  I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
241  I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
242  I_REF(iqtgui::IGuiObject, m_registryPropGuiCompPtr);
243  I_REF(imod::IObserver, m_registryPropObserverCompPtr);
244 
245  AttributeItemDelegate m_attributeItemDelegate;
246  RegistryObserver m_registryObserver;
247 
248  typedef QPair<QString, AttributeGroupType> TypeDescr;
249  typedef QMap<QByteArray, TypeDescr> AttributeTypesMap;
250  AttributeTypesMap m_attributeTypesMap;
251 
252  AttrInfosMap m_attrInfosMap; // all current displayed attributes
253 
254  istd::TDelPtr<iwidgets::CTreeWidgetFilter> m_attributesTreeFilter;
255  istd::TDelPtr<iwidgets::CTreeWidgetFilter> m_interfacesTreeFilter;
256  istd::TDelPtr<iwidgets::CTreeWidgetFilter> m_subcomponentsTreeFilter;
257 
258  imod::IModel* m_lastRegistryModelPtr;
259 
260  QIcon m_invalidIcon;
261  QIcon m_warningIcon;
262  QIcon m_exportIcon;
263  QIcon m_importIcon;
264 };
265 
266 
267 // public static methods
268 
269 template <class AttributeImpl>
270 QString CAttributeEditorComp::AttributeItemDelegate::GetMultiAttributeValueAsString(const AttributeImpl& attribute)
271 {
272  QString valuesString;
273  for (int index = 0; index < attribute.GetValuesCount(); index++){
274  if (!valuesString.isEmpty()){
275  valuesString += ";";
276  }
277 
278  valuesString += attribute.GetValueAt(index);
279  }
280 
281  return valuesString;
282 }
283 
284 
285 } // namespace icmpstr
286 
287 
288 #endif // !icmpstr_CAttributeEditorComp_included
289 
void CreateInterfacesTree(const QByteArray &elementId, const icomp::IElementStaticInfo *infoPtr, icomp::IRegistry::ExportedInterfacesMap &registryInterfaces, QTreeWidgetItem *parentItemPtr, bool &hasWarning, bool &hasExport, bool includeSubelement, bool readOnly)
QMap< QByteArray, ElementIdToAttrInfoMap > AttrInfosMap
iqtgui::TGuiObserverWrap< iqtgui::TDesignerGuiCompBase< Ui::CAttributeEditorComp >, CElementSelectionInfoManagerBase > BaseClass
bool EncodeAttribute(const QString &text, int meaning, iser::ISerializable &result) const
bool SetInterfaceToItem(QTreeWidgetItem &item, icomp::IRegistry::ExportedInterfacesMap *interfacesMapPtr, const QByteArray &elementId, const QByteArray &interfaceName, bool &hasWarning, bool &hasExport, bool readOnly) const
bool DecodeAttribute(const iser::ISerializable &attribute, QString &text, int &meaning) const
Base class for all components depending of meta information in current selected registry context...
void on_InterfacesTree_itemChanged(QTreeWidgetItem *item, int column)
virtual const icomp::IMetaInfoManager * GetMetaInfoManagerPtr() const
void on_AutoInstanceCB_toggled(bool checked)
const icomp::IAttributeStaticInfo * staticInfoPtr
static QString EncodeToEdit(const QString &text)
const icomp::IComponentStaticInfo * componentStaticInfoPtr
virtual void OnGuiModelDetached()
void CreateExportedComponentsTree(const QByteArray &elementId, const QByteArray &globalElementId, const icomp::IElementStaticInfo *elementMetaInfoPtr, QTreeWidgetItem &item, bool &hasWarning, bool &hasExport, bool readOnly) const
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
icomp::IRegistryElement::AttributeInfo * infoPtr
bool SetAttributeToItem(AttributeGroupType groupType, int &itemIndex, const icomp::IRegistry &registry, const QByteArray &attributeId, const ElementIdToAttrInfoMap &infos, const QFont &normalFont, const QFont &importantFont, bool &hasError, bool &hasWarning, bool &hasExport) const
QMap< QByteArray, AttrInfo > ElementIdToAttrInfoMap
void on_AttributeTree_itemChanged(QTreeWidgetItem *item, int column)
bool ResetItem(QTreeWidgetItem &item)
void on_IsDetachedCB_toggled(bool checked)
virtual const icmpstr::IRegistryConsistInfo * GetConsistencyInfoPtr() const
static QString DecodeFromEdit(const QString &text)

© 2007-2017 Witold Gantzke and Kirill Lepskiy