ACF $AcfVersion:0$
TDesignerGuiObserverCompBase.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QtGlobal>
7#if QT_VERSION >= 0x050000
8#include <QtWidgets/QWidget>
9#else
10#include <QtGui/QWidget>
11#endif
12
13// ACF includes
18
19
20namespace iqtgui
21{
22
23
29template <class UI, class Model, class WidgetType = QWidget>
32 iqtgui::TGuiObserverWrap< iqtgui::TDesignerGuiCompBase<UI, WidgetType>, imod::TSingleModelObserverBase<Model> > >
33{
34public:
37
38 I_BEGIN_BASE_COMPONENT(TDesignerGuiObserverCompBase);
39 I_REGISTER_INTERFACE(imod::IModelEditor);
40 I_ASSIGN(m_isReadOnlyAttrPtr, "EditorReadOnly", "If enabled, the editor for the data model is always read only", false, false);
41 I_END_COMPONENT;
42
43 // reimplemented (imod::IModelEditor)
44 virtual void SetReadOnly(bool state) override;
45
46protected:
47 // reimplemented (iqtgui::CGuiComponentBase)
48 virtual void OnGuiCreated() override;
49
50 // reimplemented (icomp::CComponentBase)
51 virtual void OnComponentCreated() override;
52
53private:
54 I_ATTR(bool, m_isReadOnlyAttrPtr);
55};
56
57
58// public methods
59
60// reimplemented (imod::IModelEditor)
61
62template <class UI, class Model, class WidgetType>
64{
65 // Skip state changes for "permanent-read-only" configured editors:
66 if (m_isReadOnlyAttrPtr.IsValid() && *m_isReadOnlyAttrPtr){
67 return;
68 }
69
70 BaseClass::SetReadOnly(state);
71}
72
73
74// protected methods
75
76// reimplemented (iqtgui::CGuiComponentBase)
77
78template <class UI, class Model, class WidgetType>
80{
81 BaseClass::OnGuiCreated();
82
83 if (m_isReadOnlyAttrPtr.IsValid() && *m_isReadOnlyAttrPtr){
84 BaseClass::SetReadOnly(true);
85 }
86}
87
88
89// reimplemented (icomp::CComponentBase)
90
91template <class UI, class Model, class WidgetType>
93{
94 BaseClass::OnComponentCreated();
95
96 if (m_isReadOnlyAttrPtr.IsValid()){
97 this->m_isReadOnly = *m_isReadOnlyAttrPtr;
98 }
99}
100
101
102} // namespace iqtgui
103
104
105
106
Generic basic implementation of component wrapper for model observer classes.
Common interface for an model editor.
Basic implementation for a single model observer with binding to concrete data object interface.
Base class for all Qt GUI components.
ibase::TModelObserverCompBaseWrap< iqtgui::TGuiObserverWrap< iqtgui::TDesignerGuiCompBase< UI, WidgetType >, imod::TSingleModelObserverBase< Model > > > BaseClass
virtual void SetReadOnly(bool state) override
Join functionality of iqtgui::IGuiObject interface and imod::IObserver.
Standard GUI specific interfaces and components based on Qt.