ACF $AcfVersion:0$
CLogGuiComp.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QTimer>
7#if QT_VERSION >= 0x050000 && QT_VERSION < 0x060000
8#include <QtWidgets/QAction>
9#else
10#include <QtGui/QAction>
11#endif
12
13// ACF includes
14#include <istd/TDelPtr.h>
19#include <ilog/CMessage.h>
22#include <GeneratedFiles/iloggui/ui_CLogGuiComp.h>
23
24
25namespace iloggui
26{
27
28
67 public iqtgui::TDesignerGuiCompBase<Ui::CLogGuiComp>,
69 virtual public ibase::ICommandsProvider
70{
71 Q_OBJECT
72
73public:
76
79
87
88 I_BEGIN_COMPONENT(CLogGuiComp);
89 I_REGISTER_INTERFACE(ibase::ICommandsProvider);
90 I_REGISTER_INTERFACE(ilog::IMessageConsumer);
91 I_REGISTER_SUBELEMENT(DiagnosticState);
92 I_REGISTER_SUBELEMENT_INTERFACE(DiagnosticState, iprm::IEnableableParam, ExtractDiagnosticState);
93 I_REGISTER_SUBELEMENT_INTERFACE(DiagnosticState, iser::ISerializable, ExtractDiagnosticState);
94 I_REGISTER_SUBELEMENT_INTERFACE(DiagnosticState, istd::IChangeable, ExtractDiagnosticState);
95 I_REGISTER_SUBELEMENT_INTERFACE(DiagnosticState, imod::IModel, ExtractDiagnosticState);
96 I_ASSIGN(m_fileLoaderCompPtr, "Exporter", "File loader used for log export", false, "Exporter");
97 I_ASSIGN(m_slaveMessageConsumerCompPtr, "SlaveMessageConsumer", "Slave message consumer", false, "SlaveMessageConsumer");
98 I_ASSIGN_TO(m_slaveMessageContainerCompPtr, m_slaveMessageConsumerCompPtr, false);
99 I_ASSIGN(m_allowDiagnosticMessagesAttrPtr, "AllowDiagnosticMessages", "If enabled the collecting of diagnostic messages and display of corresponding GUI elements is allowed", true, false);
100 I_ASSIGN(m_maxMessagesCountAttrPtr, "MaxMessageCount", "Maximal number of messages supported by the log", true, 1000);
101 I_ASSIGN(m_defaultModeAttrPtr, "DefaultMode", "Default display mode,\n 0 - info,\n 1 - warning,\n 2 - error", true, 0);
102 I_ASSIGN(m_showLogDescriptionAttrPtr, "ShowLogDescription", "Sets the log tables description visible", true, false);
103 I_ASSIGN(m_showMessageTextFilterAttrPtr, "ShowMessageTextFilter", "If enabled, the text filter for the messages will be shown", true, true);
104 I_ASSIGN(m_showPanelAttrPtr, "ShowPanel", "If enabled, the text filter and filter buttons will be shown", true, true);
105 I_ASSIGN(m_autoUpdateVisualStatusAttrPtr, "AutoUpdateVisualStatus", "Automatically update visual status when messages reseived or message mode changed", true, true);
106 I_ASSIGN(m_logTimeFormatAttrPtr, "TimeFormat", "Format of the date/time used for displaing message's time stamp", true, "");
107 I_END_COMPONENT;
108
110
111 // reimplemented (ibase::ICommandsProvider)
112 virtual const ibase::IHierarchicalCommand* GetCommands() const override;
113
114protected:
122
129
131 {
132 DR_CATEGORY = Qt::UserRole
133 };
134
138 virtual QTreeWidgetItem* CreateGuiItem(const istd::IInformationProvider& message);
139
143 virtual QIcon GetCategoryIcon(int category) const;
144
148 virtual QIcon GetActionIcon(int functionType) const;
149
153 virtual QString GetCategoryText(int category) const;
154
158 virtual void SetupCommands();
159
163 virtual void SetCommandsVisuals();
164
165 // reimplemented (ilog::IMessageConsumer)
166 virtual bool IsMessageSupported(
167 int messageCategory = -1,
168 int messageId = -1,
169 const istd::IInformationProvider* messagePtr = NULL) const override;
170 virtual void AddMessage(const MessagePtr& messagePtr) override;
171
172 // reimplemented (ilog::IMessageContainer)
173 virtual void ClearMessages() override;
174
175 // reimplemented (iqtgui::CGuiComponentBase)
176 virtual void OnGuiCreated() override;
177 virtual void OnGuiDestroyed() override;
178 virtual void OnGuiRetranslate() override;
179 virtual void OnGuiDesignChanged() override;
180
181 // reimplemented (icomp::CComponentBase)
182 virtual void OnComponentCreated() override;
183
184private:
185 void UpdateVisualStatus();
186 void UpdateItemVisibility(QTreeWidgetItem* itemPtr, const QString& filterText) const;
187 void GenerateMessageList();
188 void AddMessageToList(const MessagePtr& messagePtr);
189
190protected Q_SLOTS:
191 virtual void OnAddMessage(const MessagePtr& messagePtr);
192 virtual void OnMessageModeChanged();
193
194 virtual void OnClearAction();
195 virtual void OnExportAction();
196
198 void EnableDiagnosticMessages(bool state);
199
200 void on_FilterText_textChanged(const QString& filterText);
201
202Q_SIGNALS:
203 void EmitAddMessage(const MessagePtr& messagePtr);
205
206protected:
208 {
209 CG_FILTER = 5000,
211 };
212
213protected:
220
221 // commands
223 istd::TDelPtr < iqtgui::CHierarchicalCommand> m_infoCommand;
224 istd::TDelPtr < iqtgui::CHierarchicalCommand> m_warningCommand;
225 istd::TDelPtr < iqtgui::CHierarchicalCommand> m_errorCommand;
226 istd::TDelPtr < iqtgui::CHierarchicalCommand> m_clearCommand;
227 istd::TDelPtr < iqtgui::CHierarchicalCommand> m_exportCommand;
228 istd::TDelPtr < iqtgui::CHierarchicalCommand> m_diagnosticCommand;
229
230private:
231 // static template methods for subelement access
232 template <class InterfaceType>
233 static InterfaceType* ExtractDiagnosticState(CLogGuiComp& component)
234 {
235 return &component.m_diagnosticState;
236 }
237
238 I_REF(ifile::IFilePersistence, m_fileLoaderCompPtr);
239 I_REF(ilog::IMessageConsumer, m_slaveMessageConsumerCompPtr);
240 I_REF(ilog::IHierarchicalMessageContainer, m_slaveMessageContainerCompPtr);
241 I_ATTR(bool, m_allowDiagnosticMessagesAttrPtr);
242 I_ATTR(int, m_defaultModeAttrPtr);
243 I_ATTR(int, m_maxMessagesCountAttrPtr);
244 I_ATTR(bool, m_showLogDescriptionAttrPtr);
245 I_ATTR(bool, m_showMessageTextFilterAttrPtr);
246 I_ATTR(bool, m_showPanelAttrPtr);
247 I_ATTR(bool, m_autoUpdateVisualStatusAttrPtr);
248 I_ATTR(QString, m_logTimeFormatAttrPtr);
249
250 int m_currentMessageMode;
251
252 int m_statusCategory;
253
254 QTimer m_removeMessagesTimer;
255
257
258 class DiagnosticStateObserver: public imod::TSingleModelObserverBase<iprm::IEnableableParam>
259 {
260 public:
261 DiagnosticStateObserver(CLogGuiComp& parent);
262
263 protected:
264 // reimplemented (imod::TSingleModelObserverBase)
265 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
266
267 private:
268 CLogGuiComp& m_parent;
269 };
270
271 DiagnosticStateObserver m_diagnosticStateObserver;
272};
273
274
275} // namespace iloggui
276
277
278
Interface for a provider of the heriarchical commands.
Interface providing loading and saving of data objects.
Basic implementation of a message container.
Common interface for a message container consuming information objects (messages).
Interactive log viewer component with filtering and commands.
Definition CLogGuiComp.h:70
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_errorCommand
virtual QString GetCategoryText(int category) const
Get text corresponding to specified information category.
virtual void SetCommandsVisuals()
Setup log gui command visuals.
void EmitAddMessage(const MessagePtr &messagePtr)
virtual void AddMessage(const MessagePtr &messagePtr) override
Adds a message to this consumer.
virtual void OnGuiRetranslate() override
Called from widget event filter when GUI should be retranslated.
virtual void OnComponentCreated() override
virtual QTreeWidgetItem * CreateGuiItem(const istd::IInformationProvider &message)
Create GUI item corresponding to specified message.
QAction * m_diagnosticModeActionPtr
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_diagnosticCommand
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_exportCommand
void EnableDiagnosticMessages(bool state)
QAction * m_exportActionPtr
iqtgui::TDesignerGuiCompBase< Ui::CLogGuiComp > BaseClass
Base class typedef for GUI functionality.
Definition CLogGuiComp.h:75
void on_FilterText_textChanged(const QString &filterText)
virtual void OnExportAction()
QAction * m_errorActionPtr
virtual void OnMessageModeChanged()
ilog::CMessageContainer BaseClass2
Base class typedef for container functionality.
Definition CLogGuiComp.h:78
virtual void OnGuiCreated() override
Called just after GUI is initialized.
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_infoCommand
virtual bool IsMessageSupported(int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const override
Check if a message is supported by this consumer.
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_clearCommand
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_warningCommand
virtual void OnAddMessage(const MessagePtr &messagePtr)
virtual const ibase::IHierarchicalCommand * GetCommands() const override
Get list of menu commands.
virtual QIcon GetCategoryIcon(int category) const
Get icons corresponding to specified information category.
virtual void ClearMessages() override
virtual QIcon GetActionIcon(int functionType) const
Get icons corresponding to specified log action.
virtual void OnClearAction()
QAction * m_clearActionPtr
QAction * m_warningActionPtr
virtual void SetupCommands()
Setup log gui commands.
virtual void OnGuiDesignChanged() override
virtual void OnGuiDestroyed() override
Called just before GUI is released.
QAction * m_infoActionPtr
istd::TDelPtr< iqtgui::CHierarchicalCommand > m_rootCommands
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:24
Basic implementation for a single model observer with binding to concrete data object interface.
Interface for objects which can be enabled/disabled.
Base class for all Qt GUI components, which use the Qt designer's UI.
Common class for all classes which objects can be archived or restored from archive.
Set of change flags (its IDs).
Definition IChangeable.h:36
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
Common interface for class providing some basic information object.
@ IC_ERROR
Information about error, processing could not be done correctly.
@ IC_CRITICAL
Information about critical error - unnormal state of system, should never be returned.
@ IC_NONE
Information is unimportant, for example can be used for diagnostic.
@ IC_WARNING
Information about warning, processing could be done.
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
Common interface to define the hierarchical graph structures.
Shared ownership smart pointer for interface types.
#define NULL
Definition istd.h:74
GUI specific interfaces and components for logging functionality.
Definition CLogGuiComp.h:26