ACF $AcfVersion:0$
Public Types | Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
iloggui::CMessageBoxComp Class Reference

Component for displaying log messages in modal Qt message boxes. More...

#include <CMessageBoxComp.h>

Inheritance diagram for iloggui::CMessageBoxComp:
icomp::CComponentBase ilog::IMessageConsumer icomp::IComponent istd::IPolymorphic istd::IPolymorphic

Public Types

typedef icomp::CComponentBase BaseClass
 
- Public Types inherited from ilog::IMessageConsumer
typedef istd::TSharedInterfacePtr< istd::IInformationProviderMessagePtr
 Shared pointer type for message objects.
 

Signals

void EmitAddMessage ()
 

Public Member Functions

 CMessageBoxComp ()
 
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.
 
virtual void AddMessage (const MessagePtr &messagePtr) override
 Adds a message to this consumer.
 
- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Protected Slots

virtual void OnAddMessage ()
 

Protected Member Functions

QIcon GetCategoryIcon (int category) const
 Get icons corresponding to specified information category.
 
virtual void OnComponentCreated () override
 
virtual void OnComponentDestroyed () override
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 

Additional Inherited Members

- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 

Detailed Description

Component for displaying log messages in modal Qt message boxes.

CMessageBoxComp provides a simple way to display important messages (especially errors and warnings) to users in standard Qt message box dialogs. It implements IMessageConsumer to receive messages and displays them in modal dialogs with appropriate icons.

Messages are queued and displayed one at a time. If multiple messages are added before the dialog is shown, they're batched into a single dialog with a detailed text area.

Features
  • Modal message box display
  • Severity-appropriate icons (info, warning, critical)
  • Thread-safe message queuing with QMutex
  • Batch multiple messages into one dialog
  • Signal/slot based asynchronous display
  • Automatic message formatting
Message Icons
  • IC_INFO, IC_NONE: Information icon (blue "i")
  • IC_WARNING: Warning icon (yellow triangle)
  • IC_ERROR, IC_CRITICAL: Critical icon (red "X")
Usage Example
// Create message box component
// Send error message (displays immediately)
5001,
"Database connection failed",
"DatabaseManager"
)
));
// Dialog blocks until user clicks OK
Basic implementation of the istd::IInformationProvider interface for log messages.
Definition CMessage.h:80
Component for displaying log messages in modal Qt message boxes.
@ IC_CRITICAL
Information about critical error - unnormal state of system, should never be returned.
Shared ownership smart pointer for interface types.
Component Configuration
<Component Id="ErrorDialog" Class="iloggui::CMessageBoxComp">
<!-- No additional configuration needed -->
</Component>
Integration with Logging
// Create main log
// Create message box for errors
// Create router to send only errors to message box
// Configure:
// InputMessageContainer -> mainLog
// OutputMessageConsumer -> errorBox
// MinimalCategory -> IC_ERROR
// All messages go to log, but only errors show in dialogs
Complete logging component with message storage and container interface.
Definition CLogComp.h:86
Component that routes messages from one container to another with filtering.
Warning
Message boxes are modal and block the application. Use sparingly for critical messages only, not for general logging.
See also
ilog::IMessageConsumer, ilog::CMessage, QMessageBox

Definition at line 105 of file CMessageBoxComp.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 113 of file CMessageBoxComp.h.

Constructor & Destructor Documentation

◆ CMessageBoxComp()

iloggui::CMessageBoxComp::CMessageBoxComp ( )

Member Function Documentation

◆ AddMessage()

virtual void iloggui::CMessageBoxComp::AddMessage ( const MessagePtr messagePtr)
overridevirtual

Adds a message to this consumer.

This method transfers ownership of the message to the consumer via shared pointer. The consumer may store, display, forward, or otherwise process the message.

Most implementations deliver messages asynchronously using Qt signals/slots to ensure thread safety when messages are added from worker threads.

Parameters
messagePtrShared pointer to the message. After this call, the message is owned by the shared pointer and will be automatically deleted when no longer referenced.
Note
This method should not throw exceptions. Implementations should handle errors gracefully (e.g., by logging internally or ignoring invalid messages).
Warning
The message object should not be modified after being added to a consumer, as multiple consumers may reference the same message object.
Example
// Create message with shared pointer
2001,
"File not found: config.xml",
"ConfigLoader"
)
);
// Add to consumer (ownership transferred)
consumer->AddMessage(msg);
// msg can still be used as shared pointer maintains reference count
// but don't modify the message after adding it
@ IC_ERROR
Information about error, processing could not be done correctly.
See also
IsMessageSupported()

Implements ilog::IMessageConsumer.

◆ EmitAddMessage

void iloggui::CMessageBoxComp::EmitAddMessage ( )
signal

◆ GetCategoryIcon()

QIcon iloggui::CMessageBoxComp::GetCategoryIcon ( int  category) const
protected

Get icons corresponding to specified information category.

◆ IsMessageSupported()

virtual bool iloggui::CMessageBoxComp::IsMessageSupported ( int  messageCategory = -1,
int  messageId = -1,
const istd::IInformationProvider messagePtr = NULL 
) const
overridevirtual

Check if a message is supported by this consumer.

This method allows consumers to filter messages based on category, ID, or the complete message object. It's used to determine whether a message should be sent to this consumer before actually adding it.

Parameters
messageCategoryCategory of message (IC_NONE, IC_INFO, IC_WARNING, IC_ERROR, IC_CRITICAL) or -1 if category check should be skipped.
See also
istd::IInformationProvider::InformationCategory.
Parameters
messageIdNumeric ID of message or -1 if ID check should be skipped. Message IDs are application-defined for filtering and routing.
messagePtrOptional pointer to complete message object for detailed inspection, or NULL if not needed. The consumer will not store this pointer.
Returns
true if the message is supported and should be sent to this consumer, false if the message should be filtered out.
Note
Returning false does not indicate an error; it simply means the message doesn't match the consumer's filter criteria.
Example
// Check if consumer accepts warnings
if (consumer->IsMessageSupported(istd::IInformationProvider::IC_WARNING)) {
// Consumer accepts warnings
}
// Check specific message ID
if (consumer->IsMessageSupported(-1, 5001)) {
// Consumer accepts message ID 5001
}
// Check complete message
if (consumer->IsMessageSupported(-1, -1, &msg)) {
// Consumer accepts this specific message
}
@ IC_INFO
Normal information level.
@ IC_WARNING
Information about warning, processing could be done.

Implements ilog::IMessageConsumer.

◆ OnAddMessage

virtual void iloggui::CMessageBoxComp::OnAddMessage ( )
protectedvirtualslot

◆ OnComponentCreated()

virtual void iloggui::CMessageBoxComp::OnComponentCreated ( )
overrideprotectedvirtual

Reimplemented from icomp::CComponentBase.

◆ OnComponentDestroyed()

virtual void iloggui::CMessageBoxComp::OnComponentDestroyed ( )
overrideprotectedvirtual

Reimplemented from icomp::CComponentBase.


The documentation for this class was generated from the following file: