KChatBaseModel Class Reference

The model used to store messages displayed in the chat dialog messages list. More...

#include <kchatbasemodel.h>

Collaboration diagram for KChatBaseModel:

Collaboration graph
[legend]

List of all members.

Public Slots

virtual void addMessage (const QString &fromName, const QString &text)
 Add a text in the listbox.
virtual void addSystemMessage (const QString &fromName, const QString &text)
 This works just like addMessage but adds a system message.
void slotClear ()
 This clears all messages in the view.

Public Member Functions

 KChatBaseModel (QObject *parent=0)
 Default constructor.
virtual ~KChatBaseModel ()
 Default destructor.
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 Reimplementation of the inherited method.
virtual QVariant data (const QModelIndex &index, int role) const
 Reimplementation of the inherited method.
void setNameFont (const QFont &font)
 Set the font that is used for the name part of a message.
void setMessageFont (const QFont &font)
 Set the font that is used for the message part of a message.
void setBothFont (const QFont &font)
 This sets both - nameFont and messageFont to font.
void setSystemNameFont (const QFont &font)
 Same as setNameFont but applies only to system messages.
void setSystemMessageFont (const QFont &font)
 Same as setMessageFont but applies only to system messages.
void setSystemBothFont (const QFont &font)
 Same as setBothFont but applies only to system messages.
const QFont & nameFont () const
 This font should be used for the name (the "from: " part) of a message.
const QFont & messageFont () const
 This font should be used for a message.
const QFont & systemNameFont () const
 Same as systemNameFont but applies only to system messages.
const QFont & systemMessageFont () const
 Same as systemMessageFont but applies only to system messages.
virtual void saveConfig (KConfig *conf=0)
 Save the configuration of the dialog to a KConfig object.
virtual void readConfig (KConfig *conf=0)
 Read the configuration from a KConfig object.
void setMaxItems (int maxItems)
 Set the maximum number of items in the list.
void clear ()
 Clear all messages in the list.
int maxItems () const
 
Returns:
The maximum number of messages in the list.


Detailed Description

The model used to store messages displayed in the chat dialog messages list.

This is a list model and thus derived from QAbstractListModel and implementing its abstract API.

Definition at line 72 of file kchatbasemodel.h.


Constructor & Destructor Documentation

KChatBaseModel::KChatBaseModel ( QObject *  parent = 0  ) 

Default constructor.

Definition at line 90 of file kchatbasemodel.cpp.

KChatBaseModel::~KChatBaseModel (  )  [virtual]

Default destructor.

Definition at line 95 of file kchatbasemodel.cpp.

References saveConfig().

Here is the call graph for this function:


Member Function Documentation

int KChatBaseModel::rowCount ( const QModelIndex &  parent = QModelIndex()  )  const [virtual]

Reimplementation of the inherited method.

Returns:
The current number of messages in the list

Definition at line 216 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::m_messages.

Referenced by addMessage(), clear(), KChatBase::clear(), setMaxItems(), and KChatBase::setMaxItems().

QVariant KChatBaseModel::data ( const QModelIndex &  index,
int  role 
) const [virtual]

Reimplementation of the inherited method.

Returns:
The KChatBaseMessage at the given index as a QVariant

Definition at line 203 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::m_messages.

void KChatBaseModel::setNameFont ( const QFont &  font  ) 

Set the font that is used for the name part of a message.

See also nameFont and setBothFont

Definition at line 106 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mNameFont.

Referenced by readConfig(), setBothFont(), and KChatBase::setNameFont().

void KChatBaseModel::setMessageFont ( const QFont &  font  ) 

Set the font that is used for the message part of a message.

See also:
messageFont, setBothFont

Definition at line 111 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mMessageFont.

Referenced by readConfig(), setBothFont(), and KChatBase::setMessageFont().

void KChatBaseModel::setBothFont ( const QFont &  font  ) 

This sets both - nameFont and messageFont to font.

You probably want to use this if you don't wish to distinguish between these parts of a message.

Parameters:
font A font used for both nameFont and messageFont

Definition at line 116 of file kchatbasemodel.cpp.

References setMessageFont(), and setNameFont().

Referenced by KChatBase::setBothFont().

Here is the call graph for this function:

void KChatBaseModel::setSystemNameFont ( const QFont &  font  ) 

Same as setNameFont but applies only to system messages.

Definition at line 128 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mSystemNameFont.

Referenced by readConfig(), setSystemBothFont(), and KChatBase::setSystemNameFont().

void KChatBaseModel::setSystemMessageFont ( const QFont &  font  ) 

Same as setMessageFont but applies only to system messages.

Definition at line 133 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mSystemMessageFont.

Referenced by readConfig(), setSystemBothFont(), and KChatBase::setSystemMessageFont().

void KChatBaseModel::setSystemBothFont ( const QFont &  font  ) 

Same as setBothFont but applies only to system messages.

Definition at line 138 of file kchatbasemodel.cpp.

References setSystemMessageFont(), and setSystemNameFont().

Referenced by KChatBase::setSystemBothFont().

Here is the call graph for this function:

const QFont & KChatBaseModel::nameFont (  )  const

This font should be used for the name (the "from: " part) of a message.

layoutMessage uses this to set the font using KChatBaseItemDelegate::setNameFont but if you want to overwrite layoutMessage you should do this yourself.

Returns:
The font that is used for the name part of the message.

Definition at line 122 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mNameFont.

Referenced by KChatBase::nameFont(), and saveConfig().

const QFont & KChatBaseModel::messageFont (  )  const

This font should be used for a message.

layoutMessage sets the font of a message using KChatBaseItemDelegate::setMessageFont but if ypu replace layoutMessage with your own function you should use messageFont() yourself.

Returns:
The font that is used for a message

Definition at line 125 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mMessageFont.

Referenced by KChatBase::messageFont(), and saveConfig().

const QFont & KChatBaseModel::systemNameFont (  )  const

Same as systemNameFont but applies only to system messages.

Definition at line 144 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mSystemNameFont.

Referenced by saveConfig(), and KChatBase::systemNameFont().

const QFont & KChatBaseModel::systemMessageFont (  )  const

Same as systemMessageFont but applies only to system messages.

Definition at line 147 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mSystemMessageFont.

Referenced by saveConfig(), and KChatBase::systemMessageFont().

void KChatBaseModel::saveConfig ( KConfig *  conf = 0  )  [virtual]

Save the configuration of the dialog to a KConfig object.

If the supplied KConfig pointer is NULL then KGlobal::config() is used instead (and the group is changed to "KChatBase") butr the current group is restored at the end.

Parameters:
conf A pointer to the KConfig object to save the config to. If you use 0 then KGlobal::config() is used and the group is changed to "KChatBase" (the current group is restored at the end).

Definition at line 150 of file kchatbasemodel.cpp.

References maxItems(), messageFont(), nameFont(), systemMessageFont(), and systemNameFont().

Referenced by KChatBase::saveConfig(), and ~KChatBaseModel().

Here is the call graph for this function:

void KChatBaseModel::readConfig ( KConfig *  conf = 0  )  [virtual]

Read the configuration from a KConfig object.

If the pointer is NULL KGlobal::config() is used and the group is changed to "KChatBase". The current KConfig::group is restored after this call.

Definition at line 164 of file kchatbasemodel.cpp.

References setMaxItems(), setMessageFont(), setNameFont(), setSystemMessageFont(), and setSystemNameFont().

Referenced by KChatBase::readConfig().

Here is the call graph for this function:

void KChatBaseModel::setMaxItems ( int  maxItems  ) 

Set the maximum number of items in the list.

If the number of item exceeds the maximum as many items are deleted (oldest first) as necessary. The number of items will never exceed this value.

Parameters:
maxItems the maximum number of items. -1 (default) for unlimited.

Definition at line 183 of file kchatbasemodel.cpp.

References clear(), KChatBaseModelPrivate::mMaxItems, and rowCount().

Referenced by readConfig(), and KChatBase::setMaxItems().

Here is the call graph for this function:

void KChatBaseModel::clear (  ) 

Clear all messages in the list.

Definition at line 178 of file kchatbasemodel.cpp.

References rowCount().

Referenced by setMaxItems(), and slotClear().

Here is the call graph for this function:

int KChatBaseModel::maxItems (  )  const

Returns:
The maximum number of messages in the list.

-1 is unlimited. See also setMaxItems

Definition at line 197 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::mMaxItems.

Referenced by addMessage(), KChatBase::maxItems(), and saveConfig().

void KChatBaseModel::addMessage ( const QString &  fromName,
const QString &  text 
) [virtual, slot]

Add a text in the listbox.

See also signalSendMessage()

Maybe you want to replace this with a function that creates a nicer text than "fromName: text"

Update: the function layoutMessage is called by this now. This means that you will get user defined outlook on the messages :-)

Parameters:
fromName The player who sent this message
text The text to be added

Definition at line 224 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::m_messages, maxItems(), and rowCount().

Referenced by KChatBase::addMessage().

void KChatBaseModel::addSystemMessage ( const QString &  fromName,
const QString &  text 
) [virtual, slot]

This works just like addMessage but adds a system message.

System messages will have a different look than player messages.

You may wish to use this to display status information from your game.

Definition at line 240 of file kchatbasemodel.cpp.

References KChatBaseModelPrivate::m_messages, and KChatBaseMessage::System.

Referenced by KChatBase::addSystemMessage().

void KChatBaseModel::slotClear (  )  [slot]

This clears all messages in the view.

Note that only the messages are cleared, not the sender names in the combo box!

Definition at line 101 of file kchatbasemodel.cpp.

References clear().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 08:03:11 2008 for Libkdegames by  doxygen 1.5.3