ICF 3.0.5.47
Technical documentation of ICF Libraries
CGeneralSupplierGuiComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iqtinsp_CGeneralSupplierGuiComp_included
7#define iqtinsp_CGeneralSupplierGuiComp_included
8
9
10// Qt includes
11#include <QtCore/QTimer>
12
13// ICF includes
15#include <iinsp/ISupplier.h>
17#include <GeneratedFiles/iinspgui/ui_CGeneralSupplierGuiComp.h>
18
19
20namespace iinspgui
21{
22
23
24template <class UI = Ui::CGeneralSupplierGuiComp>
26{
27public:
29
30protected:
31 // pseudo slots
32 virtual void Test();
33
34protected:
35 // reimplemented (iinspgui::TSupplierGuiCompBase)
36 virtual QWidget* GetParamsWidget() const;
37 virtual void OnSupplierParamsChanged();
38
39 // reimplemented (istdgui::TGuiObserverWrap)
40 virtual void OnGuiModelAttached();
41 virtual void OnGuiHidden();
42 virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
43};
44
45
46// protected methods
47
48template <class UI>
50{
51 iinsp::ISupplier* supplierPtr = BaseClass::GetObservedObject();
52 if (supplierPtr != nullptr) {
53 istd::CChangeGroup changeGroup(supplierPtr);
54
55 supplierPtr->InvalidateSupplier();
56 supplierPtr->EnsureWorkInitialized();
57 supplierPtr->EnsureWorkFinished();
58
59 if (supplierPtr->GetWorkStatus() == iinsp::ISupplier::WS_FAILED) {
60 QMessageBox::warning(
61 BaseClass::GetQtWidget(),
62 QObject::tr("Error"),
63 QObject::tr("Processing Error"));
64
65 if (BaseClass::AutoTestButton->isChecked()) {
66 BaseClass::AutoTestButton->setChecked(false);
67 }
68 }
69 }
70}
71
72
73// reimplemented (iinspgui::TSupplierGuiCompBase)
74
75template <class UI>
77{
78 Q_ASSERT(BaseClass::IsGuiCreated());
79
80 return BaseClass::ParamsFrame;
81}
82
83
84template <class UI>
86{
87 if (BaseClass::IsGuiCreated() && BaseClass::AutoTestButton->isChecked()) {
88 QTimer::singleShot(1, this, SLOT(on_TestButton_clicked()));
89 }
90}
91
92
93// reimplemented (istdgui::TGuiObserverWrap)
94
95template <class UI>
97{
98 BaseClass::OnGuiModelAttached();
99
100 bool isLoadSupported = BaseClass::IsLoadParamsSupported();
101 bool isSaveSupported = BaseClass::IsSaveParamsSupported();
102 bool isEditSupported = BaseClass::AreParamsEditable();
103
104 BaseClass::ParamsGB->setVisible(isEditSupported || isLoadSupported);
105
106 BaseClass::LoadParamsButton->setVisible(isLoadSupported);
107 BaseClass::SaveParamsButton->setVisible(isSaveSupported);
108}
109
110
111template <class UI>
113{
114 BaseClass::AutoTestButton->setChecked(false);
115
116 BaseClass::OnGuiHidden();
117}
118
119
120template <class UI>
122{
123 BaseClass::UpdateGui(changeSet);
124
125 Q_ASSERT(BaseClass::IsGuiCreated());
126
127 BaseClass::UpdateVisualStatus();
128
129 QString statusLabelText = BaseClass::tr("Unknown");
130
131 QString description;
132 const iinsp::ISupplier* supplierPtr = BaseClass::GetObservedObject();
133 if (supplierPtr != nullptr) {
134 BaseClass::UpdateAllViews();
135
136 const istd::IInformationProvider* infoProviderPtr = dynamic_cast<const istd::IInformationProvider*>(supplierPtr);
137 if (infoProviderPtr != nullptr) {
138 description = infoProviderPtr->GetInformationDescription();
139 }
140 }
141
142 BaseClass::StatusLabel->setText(BaseClass::m_visualStatus.GetStatusText());
143 if (!description.isEmpty()) {
144 BaseClass::DescriptionLabel->setText(description);
145 BaseClass::DescriptionLabel->setVisible(true);
146 }
147 else {
148 BaseClass::DescriptionLabel->setVisible(false);
149 }
150}
151
152
157{
158 Q_OBJECT
159
160public:
162
163 I_BEGIN_COMPONENT(CGeneralSupplierGuiComp);
164 I_ASSIGN(m_showResultStatusFrameAttrPtr, "ShowResultStatusFrame", "If enabled, show result status group box on the bottom of the view", true, true);
165 I_END_COMPONENT;
166
168
169protected:
170 // reimplemented (istdgui::CGuiComponentBase)
171 void OnGuiCreated() override;
172
173protected Q_SLOTS:
177
178private:
179 I_ATTR(bool, m_showResultStatusFrameAttrPtr);
180};
181
182
183} // namespace iinspgui
184
185
186#endif // !iqtinsp_CGeneralSupplierGuiComp_included
187
188
Base interface for suppliers providing calculating of objects on demand ("pull data" model).
Definition ISupplier.h:28
virtual void InvalidateSupplier()=0
Called to signalize that this supplier is invalid.
virtual int GetWorkStatus() const =0
Get status of last work.
@ WS_FAILED
Work couldn't be done.
Definition ISupplier.h:55
virtual void EnsureWorkInitialized()=0
Force the supplier to initialize its work.
virtual void EnsureWorkFinished()=0
Ensure that all objects are produced.
Default implementation of the supplier's UI.
void OnGuiCreated() override
Called just after GUI is initialized.
virtual void OnGuiHidden()
Called from widget event filter when slave widget is hidden.
virtual QWidget * GetParamsWidget() const
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
Help class which provides the group of changes for update mechanism of the model.
Set of change flags (its IDs).
Definition IChangeable.h:38
Common interface for class providing some basic information object.
virtual QString GetInformationDescription() const =0
Get the text description of the information.
Contains Qt based implementations of inspection classes and components.

© Witold Gantzke and Kirill Lepskiy