TItemModelEditorCompBase.h
Go to the documentation of this file.
1 #ifndef iqtgui_TItemModelEditorCompBase_included
2 #define iqtgui_TItemModelEditorCompBase_included
3 
4 
5 // Qt includes
6 #include <QtCore/QAbstractItemModel>
7 
8 // ACF includes
12 
13 
14 namespace iqtgui
15 {
16 
17 
22 template <class ItemWidgetClass>
25  TGuiObserverWrap<
26  TGuiComponentBase<ItemWidgetClass>,
27  imod::TSingleModelObserverBase<ibase::IQtItemModelProvider> > >
28 {
29 public:
34 
35  I_BEGIN_COMPONENT(TItemModelEditorCompBase);
36  I_ASSIGN(m_sortingEnabledAttrPtr, "SortingEnabled", "If set, sorting of table data is enabled", true, true);
37  I_END_COMPONENT;
38 
39 protected:
42 
43  // reimplemented (CGuiComponentBase)
44  virtual void OnGuiCreated();
45 
46  // reimplemented (TGuiObserverWrap)
47  virtual void OnGuiModelAttached();
48 
49 private:
50  I_ATTR(bool, m_sortingEnabledAttrPtr);
51 };
52 
53 
54 // protected methods
55 
56 // reimplemented (iqtgui::TGuiObserverWrap)
57 
58 template <class ItemWidgetClass>
60 {
61  BaseClass::OnGuiModelAttached();
62 
63  ibase::IQtItemModelProvider* objectPtr = BaseClass::GetObservedObject();
64  Q_ASSERT(objectPtr != NULL);
65 
66  QAbstractItemModel* itemModelPtr = const_cast<QAbstractItemModel*>(objectPtr->GetItemModel());
67  if (itemModelPtr != NULL){
68  ItemWidgetClass* viewPtr = BaseClass::GetQtWidget();
69  Q_ASSERT(viewPtr != NULL);
70 
71  viewPtr->setModel(itemModelPtr);
72  }
73 }
74 
75 
76 // reimplemented (CGuiComponentBase)
77 
78 template <class ItemWidgetClass>
80 {
81  BaseClass::OnGuiCreated();
82 
83  ItemWidgetClass* viewPtr = BaseClass::GetQtWidget();
84 
85  Q_ASSERT(viewPtr != NULL);
86  Q_ASSERT(m_sortingEnabledAttrPtr.IsValid());
87 
88  viewPtr->setSortingEnabled(*m_sortingEnabledAttrPtr);
89 }
90 
91 
92 } // namespace iqtgui
93 
94 
95 #endif // !iqtgui_TItemModelEditorCompBase_included
96 
97 
Generic basic implementation of component wrapper for model observer classes.
Basic generic implementation of a data model editor for components which provide access to Qt's item ...
Join functionality of iqtgui::IGuiObject interface and imod::IObserver.
virtual const QAbstractItemModel * GetItemModel() const =0
Get access to the Qt's item model.
ibase::IQtItemModelProvider * GetObservedObject() const
Get instance of observed object.
Interface for getting access to the Qt's item based data model.
ibase::TModelObserverCompBaseWrap< TGuiObserverWrap< TGuiComponentBase< ItemWidgetClass >, imod::TSingleModelObserverBase< ibase::IQtItemModelProvider > > > BaseClass
#define NULL
Definition: istd.h:64
virtual void OnGuiModelAttached()
Called when model is attached and GUI is created.
virtual void OnGuiCreated()
Called just after GUI is initialized.
virtual ItemWidgetClass * GetQtWidget() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy