ICF 3.1.1.10
Technical documentation of ICF Libraries
CAttributeEditorComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtGui/QIcon>
11#include <QtWidgets/QWidget>
12#include <QtWidgets/QItemDelegate>
13
14// ICF includes
15#include <istd/CClassInfo.h>
16#include <idoc/IHelpViewer.h>
21#include <GeneratedFiles/icmpstr/ui_CAttributeEditorComp.h>
22
23
24namespace icmpstr
25{
26
27
30 istdgui::TDesignerGuiCompBase<Ui::CAttributeEditorComp>,
31 CElementSelectionInfoManagerBase>
32{
33 Q_OBJECT
34
35public:
39
40 I_BEGIN_COMPONENT(CAttributeEditorComp);
41 I_REGISTER_INTERFACE(imod::IModelEditor);
42 I_ASSIGN(m_metaInfoManagerCompPtr, "MetaInfoManager", "Allows access to component meta information", true, "MetaInfoManager");
43 I_ASSIGN(m_attributeSelectionObserverCompPtr, "AttributeSelectionObserver", "Attribute selection observer", false, "AttributeSelectionObserver");
44 I_ASSIGN(m_quickHelpViewerCompPtr, "QuickHelpGui", "Shows object info during selection using its type", false, "QuickHelpGui");
45 I_ASSIGN(m_consistInfoCompPtr, "ConsistencyInfo", "Allows to check consistency of registries and attributes", false, "ConsistencyInfo");
46 I_ASSIGN(m_registryPropGuiCompPtr, "RegistryPropGui", "Display and edit registry properties if no element is selected", false, "RegistryPropGui");
47 I_ASSIGN_TO(m_registryPropObserverCompPtr, m_registryPropGuiCompPtr, false);
48 I_END_COMPONENT;
49
58
73
81
83 {
85 AC_VALUE = 1
86 };
87
97
98public:
100
101 // reimplemented (CElementSelectionInfoManagerBase)
104
105protected Q_SLOTS:
107 void on_AttributeTree_itemChanged(QTreeWidgetItem* item, int column);
109 void on_InterfacesTree_itemChanged(QTreeWidgetItem* item, int column);
110 void on_AutoInstanceCB_toggled(bool checked);
111 void on_IsDetachedCB_toggled(bool checked);
117
118Q_SIGNALS:
122
123protected:
131
132 typedef QMap<QByteArray, AttrInfo> ElementIdToAttrInfoMap;
133 typedef QMap<QByteArray, ElementIdToAttrInfoMap> AttrInfosMap;
134
136 AttributeGroupType groupType,
137 int& itemIndex,
138 const icomp::IRegistry& registry,
139 const QByteArray& attributeId,
140 const ElementIdToAttrInfoMap& infos,
141 const QFont& normalFont,
142 const QFont& importantFont,
143 bool& hasError,
144 bool& hasWarning,
145 bool& hasExport) const;
147 QTreeWidgetItem& item,
149 const QByteArray& elementId,
150 const QByteArray& interfaceName,
151 bool& hasWarning,
152 bool& hasExport,
153 bool readOnly) const;
154 bool ResetItem(QTreeWidgetItem& item);
156 const iser::ISerializable& attribute,
157 QString& text,
158 int& meaning) const;
160 const QString& text,
161 int meaning,
162 iser::ISerializable& result) const;
163
165 const QByteArray& elementId,
166 const icomp::IElementStaticInfo* infoPtr,
167 icomp::IRegistry::ExportedInterfacesMap& registryInterfaces,
168 QTreeWidgetItem* parentItemPtr,
169 bool& hasWarning,
170 bool& hasExport,
171 bool includeSubelement,
172 bool readOnly);
174 const QByteArray& elementId,
175 const QByteArray& globalElementId,
176 const icomp::IElementStaticInfo* elementMetaInfoPtr,
177 QTreeWidgetItem& item,
178 bool& hasWarning,
179 bool& hasExport,
180 bool readOnly) const;
181
182 // reimplemented (ibase::TGuiObserverWrap)
183 void OnGuiModelDetached() override;
184 void UpdateGui(const istd::IChangeable::ChangeSet& changeSet) override;
185
186 // reimplemented (CGuiComponentBase)
187 void OnGuiCreated() override;
188 void OnGuiDestroyed() override;
189
190 // static methods
191 static QString DecodeFromEdit(const QString& text);
192 static QString EncodeToEdit(const QString& text);
193
194private:
195 class AttributeItemDelegate: public iwidgets::CItemDelegate
196 {
197 public:
199
200 AttributeItemDelegate(CAttributeEditorComp* parentPtr);
201
202 template <class AttributeImpl>
203 static QString GetMultiAttributeValueAsString(const AttributeImpl& attribute);
204
205 // reimplemented (QItemDelegate)
206 QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
207 void setEditorData(QWidget* editor, const QModelIndex& index) const override;
208 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
209
210 protected:
211 bool SetComponentExportEditor(const QByteArray& attributeId, const QString& defaultValue, QWidget& editor) const;
212 bool SetAttributeExportEditor(const QByteArray& id, const QByteArray& exportId, QWidget& editor) const;
213 bool SetAttributeValueEditor(const QByteArray& id, int propertyMining, QWidget& editor) const;
214
215 bool SetComponentValue(const QByteArray& attributeId, int propertyMining, const QString& value) const;
216 bool SetComponentExportData(const QByteArray& attributeId, const QString& value) const;
217
218 private:
219 CAttributeEditorComp& m_parent;
220 };
221
222 class RegistryObserver: public imod::CSingleModelObserverBase
223 {
224 public:
225 RegistryObserver(CAttributeEditorComp* parentPtr);
226
227 protected:
228 // reimplemented (imod::CSingleModelObserverBase)
229 void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
230
231 private:
232 CAttributeEditorComp& m_parent;
233 };
234
235 I_REF(icomp::IMetaInfoManager, m_metaInfoManagerCompPtr);
236 I_REF(IAttributeSelectionObserver, m_attributeSelectionObserverCompPtr);
237 I_REF(idoc::IHelpViewer, m_quickHelpViewerCompPtr);
238 I_REF(IRegistryConsistInfo, m_consistInfoCompPtr);
239 I_REF(istdgui::IGuiObject, m_registryPropGuiCompPtr);
240 I_REF(imod::IObserver, m_registryPropObserverCompPtr);
241
242 AttributeItemDelegate m_attributeItemDelegate;
243 RegistryObserver m_registryObserver;
244
245 typedef QPair<QString, AttributeGroupType> TypeDescr;
246 typedef QMap<QByteArray, TypeDescr> AttributeTypesMap;
247 AttributeTypesMap m_attributeTypesMap;
248
249 AttrInfosMap m_attrInfosMap; // all current displayed attributes
250
251 std::unique_ptr<iwidgets::CTreeWidgetFilter> m_attributesTreeFilter;
252 std::unique_ptr<iwidgets::CTreeWidgetFilter> m_interfacesTreeFilter;
253 std::unique_ptr<iwidgets::CTreeWidgetFilter> m_subcomponentsTreeFilter;
254
255 imod::IModel* m_lastRegistryModelPtr;
256
257 QIcon m_invalidIcon;
258 QIcon m_warningIcon;
259 QIcon m_exportIcon;
260 QIcon m_importIcon;
261};
262
263
264// public static methods
265
266template <class AttributeImpl>
267QString CAttributeEditorComp::AttributeItemDelegate::GetMultiAttributeValueAsString(const AttributeImpl& attribute)
268{
269 QString valuesString;
270 for (int index = 0; index < attribute.GetValuesCount(); index++) {
271 if (!valuesString.isEmpty()) {
272 valuesString += ";";
273 }
274
275 valuesString += attribute.GetValueAt(index);
276 }
277
278 return valuesString;
279}
280
281
282} // namespace icmpstr
283
284
void on_IsDetachedCB_toggled(bool checked)
bool ResetItem(QTreeWidgetItem &item)
void on_AutoInstanceCB_toggled(bool checked)
static QString EncodeToEdit(const QString &text)
QMap< QByteArray, AttrInfo > ElementIdToAttrInfoMap
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
static QString DecodeFromEdit(const QString &text)
void on_AttributeTree_itemChanged(QTreeWidgetItem *item, int column)
istdgui::TGuiObserverWrap< istdgui::TDesignerGuiCompBase< Ui::CAttributeEditorComp >, CElementSelectionInfoManagerBase > BaseClass
void CreateInterfacesTree(const QByteArray &elementId, const icomp::IElementStaticInfo *infoPtr, icomp::IRegistry::ExportedInterfacesMap &registryInterfaces, QTreeWidgetItem *parentItemPtr, bool &hasWarning, bool &hasExport, bool includeSubelement, bool readOnly)
const icomp::IMetaInfoManager * GetMetaInfoManagerPtr() const override
QMap< QByteArray, ElementIdToAttrInfoMap > AttrInfosMap
void OnGuiDestroyed() override
Called just before GUI is released.
const icmpstr::IRegistryConsistInfo * GetConsistencyInfoPtr() const override
void on_InterfacesTree_itemChanged(QTreeWidgetItem *item, int column)
void OnGuiModelDetached() override
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
void UpdateGui(const istd::IChangeable::ChangeSet &changeSet) override
void CreateExportedComponentsTree(const QByteArray &elementId, const QByteArray &globalElementId, const icomp::IElementStaticInfo *elementMetaInfoPtr, QTreeWidgetItem &item, bool &hasWarning, bool &hasExport, bool readOnly) const
void OnGuiCreated() override
Called just after GUI is initialized.
bool EncodeAttribute(const QString &text, int meaning, iser::ISerializable &result) const
Base class for all components depending of meta information in current selected registry context.
Describe component attribute static information.
This interface provide static information about component meta info.
This interface provide static information about element meta info.
Represents element of registry describing component parameters.
Interface representing information stored in component registry.
Definition IRegistry.h:30
std::map< QByteArray, QByteArray > ExportedInterfacesMap
Map assigning interface ID (undecorated) to component ID exporting this interface.
Definition IRegistry.h:59
Allow to show help document to specified object or text.
Definition IHelpViewer.h:25
Basic implementation for a single model observer.
Common interface for an model editor.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:29
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition IObserver.h:30
Common class for all classes which objects can be archived or restored from archive.
Set of change flags (its IDs).
Definition IChangeable.h:38
Common interface for GUI objects using in component context.
Definition IGuiObject.h:27
Base class for all Qt GUI components, which use the Qt designer's UI.
Join functionality of istdgui::IGuiObject interface and imod::IObserver.
Standard ICF item view delegator.
This package contains (Qt based) implementations of compositor components.
const icomp::IAttributeStaticInfo * staticInfoPtr
icomp::IRegistryElement::AttributeInfo * infoPtr
const icomp::IComponentStaticInfo * componentStaticInfoPtr
Describe information stored with each attribute.

© Witold Gantzke and Kirill Lepskiy