TRestorableGuiWrap.h
Go to the documentation of this file.
1 #ifndef iqtgui_TRestorableGuiWrap_included
2 #define iqtgui_TRestorableGuiWrap_included
3 
4 
5 // ACF includes
7 #include <icomp/CComponentBase.h>
8 
9 
10 namespace iqtgui
11 {
12 
13 
17 template <class Gui>
18 class TRestorableGuiWrap: public Gui
19 {
20 public:
21  typedef Gui BaseClass;
22 
23  I_BEGIN_BASE_COMPONENT(TRestorableGuiWrap);
24  I_ASSIGN(m_settingsProviderCompPtr, "SettingsProvider", "Application settings provider", false, "SettingsProvider");
25  I_END_COMPONENT;
26 
27 protected:
28  // abstract methods
29  virtual void OnRestoreSettings(const QSettings& settings) = 0;
30  virtual void OnSaveSettings(QSettings& settings) const = 0;
31 
32  // pseudo-reimplemented (iqtgui::CGuiComponentBase)
33  virtual bool CreateGui(QWidget* parentPtr);
34  virtual bool DestroyGui();
35 
36 private:
37  I_REF(iqt::ISettingsProvider, m_settingsProviderCompPtr);
38 };
39 
40 
41 // protected methods
42 
43 template <class Gui>
44 bool TRestorableGuiWrap<Gui>::CreateGui(QWidget* parentPtr)
45 {
46  bool retVal = BaseClass::CreateGui(parentPtr);
47 
48  if (m_settingsProviderCompPtr.IsValid()){
49  OnRestoreSettings(m_settingsProviderCompPtr->GetSettings());
50  }
51 
52  return retVal;
53 }
54 
55 
56 template <class Gui>
58 {
59  if (m_settingsProviderCompPtr.IsValid()){
60  OnSaveSettings(m_settingsProviderCompPtr->GetSettings());
61  }
62 
63  return BaseClass::DestroyGui();
64 }
65 
66 
67 } // namespace iqtgui
68 
69 
70 #endif // !iqtgui_TRestorableGuiWrap_included
71 
72 
virtual void OnRestoreSettings(const QSettings &settings)=0
A wrapper for saving/restoring of GUI component states in the application settings.
virtual void OnSaveSettings(QSettings &settings) const =0
virtual bool CreateGui(QWidget *parentPtr)
Interface for access the application settings object.

© 2007-2017 Witold Gantzke and Kirill Lepskiy