KMessage/KMessageHandler: a core/ui seperation for displaying message.
thiago at kde.org
Sun May 28 22:14:41 BST 2006
Michaël Larouche wrote:
>> Yes, use KSharedPtr or its equivalent instead. If reimplementers of
>> the generic message handler need a QObject, then they can use multiple
>I used QObject because QPointer need to be a QObject derivate. But using
>KSharedPtr make sense too.
I see no reason for either. Just don't share the value: let the callee
take possession of the value. For that matter, there's also no need to
make it a static member in KMessage. Just use an internal, static
Don't overcomplicate such a simple thing: KMessageHandler is just a
virtual table. There's absolutely no need to have a parent class.
If you don't want to do this, at least don't make QPointer or KSharedPtr
(or QShared or whatever) a static member. Don't create static non-POD
>I normally do this do, one file per class, but I found KMessageHandler
> too small to be put in a separate file.
In this case, I'd agree. As I said, the class is just a virtual table,
>> IIRC, values don't need to be OR'able in order to be used by QFlags.
>> Just the proper Q_DECLARE_FLAGS( MessageTypes, MessageType ) macro
>> needs to be used instead. AFAIK, "typedef QFlags<MessageType>
>> MessageTypes;" is less correct.
>I prefer Q_DECLARE_FLAGS myself.
>KMessage doesn't offer many possibilies so I don't see why I should
>overengineer it to check for capability of the handler.
Indeed. It makes no sense to have a message that is at the same time a
Fatal and a Debug message.
One thing I would recommend, though, is to declare the values in
decreasing order of severity.
>Yes, I didn't put d-ptr because there is no need for it. I didn't want
> to manage a d-ptr just for 1 or 2 private members. And yes, you can put
> private members into a d-ptr
I agree. There's no need for a d pointer or private members. Hide them all
in the .cpp file, as static variables and functions.
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
thiago.macieira (AT) trolltech.com Trolltech AS
GPG: 0x6EF45358 | Sandakerveien 116,
E067 918B B660 DBD1 105C | NO-0402
966C 33F5 F005 6EF4 5358 | Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 191 bytes
Desc: not available
More information about the kde-core-devel