CGeneralSupplierGuiComp.h
Go to the documentation of this file.
1 #ifndef iqtinsp_CGeneralSupplierGuiComp_included
2 #define iqtinsp_CGeneralSupplierGuiComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QTimer>
7 
8 // ACF includes
9 #include <istd/CChangeNotifier.h>
10 #include <iinsp/ISupplier.h>
11 
12 // ACF-Solutions includes
14 #include <GeneratedFiles/iqtinsp/ui_CGeneralSupplierGuiComp.h>
15 
16 
17 namespace iqtinsp
18 {
19 
20 
21 template <class UI = Ui::CGeneralSupplierGuiComp>
23 {
24 public:
26 
27 protected:
28  // pseudo slots
29  virtual void Test();
30 
31 protected:
32  // reimplemented (iqtinsp::TSupplierGuiCompBase)
33  virtual QWidget* GetParamsWidget() const;
34  virtual void OnSupplierParamsChanged();
35 
36  // reimplemented (iqtgui::TGuiObserverWrap)
37  virtual void OnGuiModelAttached();
38  virtual void OnGuiHidden();
39  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
40 };
41 
42 
43 // protected methods
44 
45 template <class UI>
47 {
48  iinsp::ISupplier* supplierPtr = BaseClass::GetObservedObject();
49  if (supplierPtr != NULL){
50  istd::CChangeGroup changeGroup(supplierPtr);
51 
52  supplierPtr->InvalidateSupplier();
53  supplierPtr->EnsureWorkInitialized();
54  supplierPtr->EnsureWorkFinished();
55 
56  if (supplierPtr->GetWorkStatus() == iinsp::ISupplier::WS_FAILED){
57  QMessageBox::warning(
58  BaseClass::GetQtWidget(),
59  QObject::tr("Error"),
60  QObject::tr("Processing Error"));
61 
62  if (BaseClass::AutoTestButton->isChecked()){
63  BaseClass::AutoTestButton->setChecked(false);
64  }
65  }
66  }
67 }
68 
69 
70 // reimplemented (iqtinsp::TSupplierGuiCompBase)
71 
72 template <class UI>
74 {
75  Q_ASSERT(BaseClass::IsGuiCreated());
76 
77  return BaseClass::ParamsFrame;
78 }
79 
80 
81 template <class UI>
83 {
84  if (BaseClass::IsGuiCreated() && BaseClass::AutoTestButton->isChecked()){
85  QTimer::singleShot(1, this, SLOT(on_TestButton_clicked()));
86  }
87 }
88 
89 
90 // reimplemented (iqtgui::TGuiObserverWrap)
91 
92 template <class UI>
94 {
95  BaseClass::OnGuiModelAttached();
96 
97  bool isLoadSupported = BaseClass::IsLoadParamsSupported();
98  bool isSaveSupported = BaseClass::IsSaveParamsSupported();
99  bool isEditSupported = BaseClass::AreParamsEditable();
100 
101  BaseClass::ParamsGB->setVisible(isEditSupported || isLoadSupported);
102 
103  BaseClass::LoadParamsButton->setVisible(isLoadSupported);
104  BaseClass::SaveParamsButton->setVisible(isSaveSupported);
105 }
106 
107 
108 template <class UI>
110 {
111  BaseClass::AutoTestButton->setChecked(false);
112 
113  BaseClass::OnGuiHidden();
114 }
115 
116 
117 template <class UI>
119 {
120  BaseClass::UpdateGui(changeSet);
121 
122  Q_ASSERT(BaseClass::IsGuiCreated());
123 
124  BaseClass::UpdateVisualStatus();
125 
126  QString statusLabelText = BaseClass::tr("Unknown");
127 
128  QString description;
129  const iinsp::ISupplier* supplierPtr = BaseClass::GetObservedObject();
130  if (supplierPtr != NULL){
131  BaseClass::UpdateAllViews();
132 
133  const istd::IInformationProvider* infoProviderPtr = dynamic_cast<const istd::IInformationProvider*>(supplierPtr);
134  if (infoProviderPtr != NULL){
135  description = infoProviderPtr->GetInformationDescription();
136  }
137  }
138 
139  BaseClass::StatusLabel->setText(BaseClass::m_visualStatus.GetStatusText());
140  if (!description.isEmpty()){
141  BaseClass::DescriptionLabel->setText(description);
142  BaseClass::DescriptionLabel->setVisible(true);
143  }
144  else{
145  BaseClass::DescriptionLabel->setVisible(false);
146  }
147 }
148 
149 
154 {
155  Q_OBJECT
156 
157 public:
159 
160  I_BEGIN_COMPONENT(CGeneralSupplierGuiComp);
161  I_ASSIGN(m_showResultStatusFrameAttrPtr, "ShowResultStatusFrame", "If enabled, show result status group box on the bottom of the view", true, true);
162  I_END_COMPONENT;
163 
165 
166 protected:
167  // reimplemented (iqtgui::CGuiComponentBase)
168  virtual void OnGuiCreated();
169 
170 protected Q_SLOTS:
171  void on_TestButton_clicked();
174 
175 private:
176  I_ATTR(bool, m_showResultStatusFrameAttrPtr);
177 };
178 
179 
180 } // namespace iqtinsp
181 
182 
183 #endif // !iqtinsp_CGeneralSupplierGuiComp_included
184 
185 
virtual QString GetInformationDescription() const =0
virtual QWidget * GetParamsWidget() const
Get parameters widget object.
Default implementation of the supplier's UI.
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
virtual void EnsureWorkFinished()=0
Ensure that all objects are produced.
virtual void OnSupplierParamsChanged()
Method will be called every time if the parameter set of the supplier has been changed.
TSupplierGuiCompBase< UI > BaseClass
virtual int GetWorkStatus() const =0
Get status of last work.
Work couldn't be done.
Definition: ISupplier.h:50
#define NULL
virtual void InvalidateSupplier()=0
Called to signalize that this supplier is invalid.
Base interface for suppliers providing calculating of objects on demand ("pull data" model)...
Definition: ISupplier.h:22
virtual void EnsureWorkInitialized()=0
Force the supplier to initialize its work.

© 2007-2017 Witold Gantzke and Kirill Lepskiy