Component for displaying log messages in modal Qt message boxes.
More...
#include <CMessageBoxComp.h>
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
5001,
"Database connection failed",
"DatabaseManager"
)
));
Basic implementation of the istd::IInformationProvider interface for log messages.
Component for displaying log messages in modal Qt message boxes.
Shared ownership smart pointer for interface types.
- Component Configuration
<Component Id="ErrorDialog" Class="iloggui::CMessageBoxComp">
</Component>
- Integration with Logging
Complete logging component with message storage and container interface.
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.
◆ BaseClass
◆ CMessageBoxComp()
| iloggui::CMessageBoxComp::CMessageBoxComp |
( |
| ) |
|
◆ 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
-
| messagePtr | Shared 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
2001,
"File not found: config.xml",
"ConfigLoader"
)
);
consumer->AddMessage(msg);
- 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
-
| messageCategory | Category 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
-
| messageId | Numeric ID of message or -1 if ID check should be skipped. Message IDs are application-defined for filtering and routing. |
| messagePtr | Optional 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
}
if (consumer->IsMessageSupported(-1, 5001)) {
}
if (consumer->IsMessageSupported(-1, -1, &msg)) {
}
Implements ilog::IMessageConsumer.
◆ OnAddMessage
| virtual void iloggui::CMessageBoxComp::OnAddMessage |
( |
| ) |
|
|
protectedvirtualslot |
◆ OnComponentCreated()
| virtual void iloggui::CMessageBoxComp::OnComponentCreated |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ OnComponentDestroyed()
| virtual void iloggui::CMessageBoxComp::OnComponentDestroyed |
( |
| ) |
|
|
overrideprotectedvirtual |
The documentation for this class was generated from the following file: