TDesignerGuiObserverCompBase.h
Go to the documentation of this file.
1 #ifndef iqtgui_TDesignerGuiObserverCompBase_included
2 #define iqtgui_TDesignerGuiObserverCompBase_included
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 
20 namespace iqtgui
21 {
22 
23 
29 template <class UI, class Model, class WidgetType = QWidget>
32  iqtgui::TGuiObserverWrap< iqtgui::TDesignerGuiCompBase<UI, WidgetType>, imod::TSingleModelObserverBase<Model> > >
33 {
34 public:
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);
45 
46 protected:
47  // reimplemented (iqtgui::CGuiComponentBase)
48  virtual void OnGuiCreated();
49 
50  // reimplemented (icomp::CComponentBase)
51  virtual void OnComponentCreated();
52 
53 private:
54  I_ATTR(bool, m_isReadOnlyAttrPtr);
55 };
56 
57 
58 // public methods
59 
60 // reimplemented (imod::IModelEditor)
61 
62 template <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 
78 template <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 
91 template <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 #endif // !iqtgui_TDesignerGuiObserverCompBase_included
106 
107 
virtual void OnGuiCreated()
Called just after GUI is initialized.
Generic basic implementation of component wrapper for model observer classes.
ibase::TModelObserverCompBaseWrap< iqtgui::TGuiObserverWrap< iqtgui::TDesignerGuiCompBase< UI, WidgetType >, imod::TSingleModelObserverBase< Model > > > BaseClass
Join functionality of iqtgui::IGuiObject interface and imod::IObserver.
Common interface for an model editor.
Definition: IModelEditor.h:19
virtual void SetReadOnly(bool state)
Set flag that the model data can be changed.
Base class for all Qt GUI components.

© 2007-2017 Witold Gantzke and Kirill Lepskiy