• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libkdegames

KChatBaseModel Class Reference

#include <kchatbasemodel.h>

Inheritance diagram for KChatBaseModel:

Inheritance graph
[legend]

List of all members.


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.


Public Slots

virtual void addMessage (const QString &fromName, const QString &text)
virtual void addSystemMessage (const QString &fromName, const QString &text)
void slotClear ()

Public Member Functions

 KChatBaseModel (QObject *parent=0)
virtual ~KChatBaseModel ()
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
virtual QVariant data (const QModelIndex &index, int role) const
void setNameFont (const QFont &font)
void setMessageFont (const QFont &font)
void setBothFont (const QFont &font)
void setSystemNameFont (const QFont &font)
void setSystemMessageFont (const QFont &font)
void setSystemBothFont (const QFont &font)
const QFont & nameFont () const
const QFont & messageFont () const
const QFont & systemNameFont () const
const QFont & systemMessageFont () const
virtual void saveConfig (KConfig *conf=0)
virtual void readConfig (KConfig *conf=0)
void setMaxItems (int maxItems)
void clear ()
int maxItems () const

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.


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.

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.

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.

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.

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.

void KChatBaseModel::setSystemNameFont ( const QFont &  font  ) 

Same as setNameFont but applies only to system messages.

Definition at line 128 of file kchatbasemodel.cpp.

void KChatBaseModel::setSystemMessageFont ( const QFont &  font  ) 

Same as setMessageFont but applies only to system messages.

Definition at line 133 of file kchatbasemodel.cpp.

void KChatBaseModel::setSystemBothFont ( const QFont &  font  ) 

Same as setBothFont but applies only to system messages.

Definition at line 138 of file kchatbasemodel.cpp.

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.

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.

const QFont & KChatBaseModel::systemNameFont (  )  const

Same as systemNameFont but applies only to system messages.

Definition at line 144 of file kchatbasemodel.cpp.

const QFont & KChatBaseModel::systemMessageFont (  )  const

Same as systemMessageFont but applies only to system messages.

Definition at line 147 of file kchatbasemodel.cpp.

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.

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.

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.

void KChatBaseModel::clear (  ) 

Clear all messages in the list.

Definition at line 178 of file kchatbasemodel.cpp.

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.

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.

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.

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.


The documentation for this class was generated from the following files:
  • kchatbasemodel.h
  • kchatbasemodel.cpp

libkdegames

Skip menu "libkdegames"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal