KDbMessageHandler

Search for usage in LXR

#include <KDbMessageHandler.h>

Public Types

enum  ButtonCode {
  Ok = 1, Cancel = 2, Yes = Ok, No = 3,
  Continue = 4
}
 
enum  MessageType {
  Information = 1, Error = 2, Warning = 3, Sorry = 4,
  Fatal = 5
}
 
enum  Option { Notify = 1, AllowLink = 2, Dangerous = 4 }
 
typedef QFlags< OptionOptions
 
enum  QuestionType {
  QuestionYesNo = 1, QuestionYesNoCancel = 2, WarningYesNo = 3, WarningContinueCancel = 4,
  WarningYesNoCancel = 5
}
 

Public Member Functions

 KDbMessageHandler (QWidget *parent=nullptr)
 
virtual KDbMessageHandler::ButtonCode askQuestion (KDbMessageHandler::QuestionType messageType, const QString &message, const QString &caption=QString(), KDbMessageHandler::ButtonCode defaultResult=KDbMessageHandler::Yes, const KDbGuiItem &buttonYes=KDbGuiItem(), const KDbGuiItem &buttonNo=KDbGuiItem(), const QString &dontShowAskAgainName=QString(), KDbMessageHandler::Options options=nullptr, KDbMessageHandler *msgHandler=nullptr)
 
bool messagesEnabled () const
 
KDbMessageHandlerredirection ()
 
const KDbMessageHandlerredirection () const
 
void setMessagesEnabled (bool enable)
 
void setRedirection (KDbMessageHandler *otherHandler)
 
virtual void showErrorMessage (const KDbResult &result, KDbMessageHandler::MessageType messageType=Error, const QString &message=QString(), const QString &caption=QString())=0
 
virtual void showErrorMessage (KDbMessageHandler::MessageType messageType, const QString &message, const QString &details=QString(), const QString &caption=QString())=0
 

Protected Member Functions

QWidgetparentWidget ()
 

Protected Attributes

Private *const d
 

Detailed Description

A prototype for Message Handler usable for reacting on messages sent by KDbObject object(s).

Definition at line 134 of file KDbMessageHandler.h.

Member Enumeration Documentation

◆ ButtonCode

Button codes.

Definition at line 158 of file KDbMessageHandler.h.

◆ MessageType

Message types.

Definition at line 138 of file KDbMessageHandler.h.

◆ Option

Message options.

Enumerator
Notify 

Emit a KNotify event.

AllowLink 

The message may contain links.

Dangerous 

The action to be confirmed by the dialog is a potentially destructive one.

Definition at line 168 of file KDbMessageHandler.h.

◆ QuestionType

Question types.

Definition at line 148 of file KDbMessageHandler.h.

Constructor & Destructor Documentation

◆ KDbMessageHandler()

KDbMessageHandler::KDbMessageHandler ( QWidget parent = nullptr)
explicit

Constructs message handler, parent is a widget that will be a parent for displaying gui elements (e.g. message boxes). Can be 0 for non-gui usage.

Definition at line 122 of file KDbMessageHandler.cpp.

Member Function Documentation

◆ askQuestion()

KDbMessageHandler::ButtonCode KDbMessageHandler::askQuestion ( KDbMessageHandler::QuestionType  messageType,
const QString message,
const QString caption = QString(),
KDbMessageHandler::ButtonCode  defaultResult = KDbMessageHandler::Yes,
const KDbGuiItem buttonYes = KDbGuiItem(),
const KDbGuiItem buttonNo = KDbGuiItem(),
const QString dontShowAskAgainName = QString(),
KDbMessageHandler::Options  options = nullptr,
KDbMessageHandler msgHandler = nullptr 
)
virtual

Interactively asks a question. For GUI version, message boxes are used. defaultResult is returned in case when no message handler is installed. message should contain translated string. Value of ButtonCode is returned. Reimplement this. This implementation does nothing, just returns defaultResult.

Definition at line 143 of file KDbMessageHandler.cpp.

◆ messagesEnabled()

bool KDbMessageHandler::messagesEnabled ( ) const
Returns
true if the handler is enables so messages are not blocked.
See also
setEnabled(bool)

Definition at line 133 of file KDbMessageHandler.cpp.

◆ parentWidget()

QWidget * KDbMessageHandler::parentWidget ( )
protected
Returns
a widget that will be parent for displaying gui elements (e.g. message boxes). Can be 0 for non-gui cases.

Definition at line 177 of file KDbMessageHandler.cpp.

◆ redirection()

KDbMessageHandler * KDbMessageHandler::redirection ( )
Returns
message redirection for this handler or 0 if there is no redirection.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 162 of file KDbMessageHandler.cpp.

◆ setMessagesEnabled()

void KDbMessageHandler::setMessagesEnabled ( bool  enable)

Enables or disabled the handler to block/unblock its messages. Sometimes both lower- and higher-level messages are received, what is not optimal as only one of them should be displayed (e.g. a higher level with details). This can be solved by calling setEnabled(false) shortly before an action that can send the unwanted message. Afterwards messages can be enabled again by calling setEnabled(true). By default messages are enabled.

Definition at line 138 of file KDbMessageHandler.cpp.

◆ setRedirection()

void KDbMessageHandler::setRedirection ( KDbMessageHandler otherHandler)

Sets redirection of all messages for this handler to otherHandler. Passing 0 removes redirection. Setting new redirection replaces previous.

Definition at line 172 of file KDbMessageHandler.cpp.

◆ showErrorMessage() [1/2]

virtual void KDbMessageHandler::showErrorMessage ( const KDbResult result,
KDbMessageHandler::MessageType  messageType = Error,
const QString message = QString(),
const QString caption = QString() 
)
pure virtual

Shows error message with message text. Existing error message from obj object is also copied, if present.

◆ showErrorMessage() [2/2]

virtual void KDbMessageHandler::showErrorMessage ( KDbMessageHandler::MessageType  messageType,
const QString message,
const QString details = QString(),
const QString caption = QString() 
)
pure virtual

Shows error message with title (it is not caption) and details.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Dec 8 2022 04:10:39 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.