<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> <head> <title>libkdegames: kchatbase.cpp Source File (libkdegames)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <div id="nav_header_title" align="left">KDE API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_right" style="text-align: left;"> / <a href="../..">API Reference</a> / <a href=".">libkdegames</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <a name="content"></a> <!-- Generated by Doxygen 1.5.5 --> <h1>kchatbase.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> This file is part of the KDE games library</span> <a name="l00003"></a>00003 <span class="comment"> Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00006"></a>00006 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00007"></a>00007 <span class="comment"> License version 2 as published by the Free Software Foundation.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00012"></a>00012 <span class="comment"> Library General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> You should have received a copy of the GNU Library General Public License</span> <a name="l00015"></a>00015 <span class="comment"> along with this library; see the file COPYING.LIB. If not, write to</span> <a name="l00016"></a>00016 <span class="comment"> the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span> <a name="l00017"></a>00017 <span class="comment"> Boston, MA 02110-1301, USA.</span> <a name="l00018"></a>00018 <span class="comment">*/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#include "kchatbase.h"</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include <klineedit.h></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <klocale.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <kstandarddirs.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <kconfig.h></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <kapplication.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <kdebug.h></span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include <qlayout.h></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <qcombobox.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <qpainter.h></span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="keyword">class </span>KChatBaseTextPrivate <a name="l00034"></a>00034 { <a name="l00035"></a>00035 <span class="keyword">public</span>: <a name="l00036"></a>00036 KChatBaseTextPrivate() <a name="l00037"></a>00037 { <a name="l00038"></a>00038 mNameFont = 0; <a name="l00039"></a>00039 mMessageFont = 0; <a name="l00040"></a>00040 } <a name="l00041"></a>00041 <a name="l00042"></a>00042 QString mName; <a name="l00043"></a>00043 QString mMessage; <a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="keyword">const</span> QFont* mNameFont; <a name="l00046"></a>00046 <span class="keyword">const</span> QFont* mMessageFont; <a name="l00047"></a>00047 }; <a name="l00048"></a>00048 <a name="l00049"></a>00049 <a name="l00050"></a><a class="code" href="classKChatBaseText.html#0623436b8be9ff7a4e446c776d859b92">00050</a> <a class="code" href="classKChatBaseText.html#0623436b8be9ff7a4e446c776d859b92" title="Constructs a KChatBaseText object with the player and text part.">KChatBaseText::KChatBaseText</a>(<span class="keyword">const</span> QString& name, <span class="keyword">const</span> QString& message) : QListBoxText() <a name="l00051"></a>00051 { <a name="l00052"></a>00052 init(); <a name="l00053"></a>00053 <a class="code" href="classKChatBaseText.html#72bc269fd9d679909c34b92152f71e3e" title="Set the name part of a message.">setName</a>(name); <a name="l00054"></a>00054 <a class="code" href="classKChatBaseText.html#16143a4630d3d8c3bd0e159e208c6c3a" title="Set the text part of a message.">setMessage</a>(message); <a name="l00055"></a>00055 } <a name="l00056"></a>00056 <a name="l00057"></a><a class="code" href="classKChatBaseText.html#b63d3e542cbbf0cecc7302a2c450400a">00057</a> <a class="code" href="classKChatBaseText.html#0623436b8be9ff7a4e446c776d859b92" title="Constructs a KChatBaseText object with the player and text part.">KChatBaseText::KChatBaseText</a>(<span class="keyword">const</span> QString& <a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">message</a>) : QListBoxText() <a name="l00058"></a>00058 { <a name="l00059"></a>00059 init(); <a name="l00060"></a>00060 <a class="code" href="classKChatBaseText.html#16143a4630d3d8c3bd0e159e208c6c3a" title="Set the text part of a message.">setMessage</a>(message); <a name="l00061"></a>00061 } <a name="l00062"></a>00062 <a name="l00063"></a><a class="code" href="classKChatBaseText.html#6191a2d38e22ccbfd9920fc84e39a5e2">00063</a> <a class="code" href="classKChatBaseText.html#6191a2d38e22ccbfd9920fc84e39a5e2" title="Destruct a KChatBaseText object.">KChatBaseText::~KChatBaseText</a>() <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <span class="keyword">delete</span> d; <a name="l00066"></a>00066 } <a name="l00067"></a>00067 <a name="l00068"></a>00068 <span class="keywordtype">void</span> KChatBaseText::init() <a name="l00069"></a>00069 { <a name="l00070"></a>00070 d = <span class="keyword">new</span> KChatBaseTextPrivate; <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00073"></a><a class="code" href="classKChatBaseText.html#72bc269fd9d679909c34b92152f71e3e">00073</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBaseText.html#72bc269fd9d679909c34b92152f71e3e" title="Set the name part of a message.">KChatBaseText::setName</a>(<span class="keyword">const</span> QString& n) <a name="l00074"></a>00074 { <a name="l00075"></a>00075 <span class="comment">// d->mName = n;</span> <a name="l00076"></a>00076 d->mName = QString(<span class="stringliteral">"%1: "</span>).arg(n); <a name="l00077"></a>00077 setText(QString(<span class="stringliteral">"%1: %2"</span>).arg(<a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">name</a>()).arg(<a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">message</a>())); <span class="comment">// esp. for sorting</span> <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <a name="l00080"></a><a class="code" href="classKChatBaseText.html#16143a4630d3d8c3bd0e159e208c6c3a">00080</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBaseText.html#16143a4630d3d8c3bd0e159e208c6c3a" title="Set the text part of a message.">KChatBaseText::setMessage</a>(<span class="keyword">const</span> QString& m) <a name="l00081"></a>00081 { <a name="l00082"></a>00082 d->mMessage = m; <a name="l00083"></a>00083 setText(QString(<span class="stringliteral">"%1: %2"</span>).arg(<a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">name</a>()).arg(<a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">message</a>())); <span class="comment">// esp. for sorting</span> <a name="l00084"></a>00084 } <a name="l00085"></a>00085 <a name="l00086"></a><a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">00086</a> <span class="keyword">const</span> QString& <a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">KChatBaseText::name</a>()<span class="keyword"> const</span> <a name="l00087"></a>00087 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mName; } <a name="l00088"></a>00088 <a name="l00089"></a><a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">00089</a> <span class="keyword">const</span> QString& <a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">KChatBaseText::message</a>()<span class="keyword"> const</span> <a name="l00090"></a>00090 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mMessage; } <a name="l00091"></a>00091 <a name="l00092"></a><a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901">00092</a> QFont <a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901" title="You can set the font of the sender name independently of the message itself.">KChatBaseText::nameFont</a>()<span class="keyword"> const</span> <a name="l00093"></a>00093 <span class="keyword"></span>{ <a name="l00094"></a>00094 <span class="keywordflow">if</span> (d->mNameFont) { <a name="l00095"></a>00095 <span class="keywordflow">return</span> *d->mNameFont; <a name="l00096"></a>00096 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (listBox()) { <a name="l00097"></a>00097 <span class="keywordflow">return</span> listBox()->font(); <a name="l00098"></a>00098 } <span class="keywordflow">else</span> { <a name="l00099"></a>00099 <span class="keywordflow">return</span> QFont(); <a name="l00100"></a>00100 } <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <a name="l00103"></a><a class="code" href="classKChatBaseText.html#ee344ac8e852c396009e52492f64180f">00103</a> QFont <a class="code" href="classKChatBaseText.html#ee344ac8e852c396009e52492f64180f" title="You can set the font of the message independently of the sender name.">KChatBaseText::messageFont</a>()<span class="keyword"> const</span> <a name="l00104"></a>00104 <span class="keyword"></span>{ <a name="l00105"></a>00105 <span class="keywordflow">if</span> (d->mMessageFont) { <a name="l00106"></a>00106 <span class="keywordflow">return</span> *d->mMessageFont; <a name="l00107"></a>00107 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (listBox()) { <a name="l00108"></a>00108 <span class="keywordflow">return</span> listBox()->font(); <a name="l00109"></a>00109 } <span class="keywordflow">else</span> { <a name="l00110"></a>00110 <span class="keywordflow">return</span> QFont(); <a name="l00111"></a>00111 } <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a><a class="code" href="classKChatBaseText.html#d17ea04616417e48697f5841a415378c">00114</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBaseText.html#d17ea04616417e48697f5841a415378c" title="Set the font for the name.">KChatBaseText::setNameFont</a>(<span class="keyword">const</span> QFont* f) <a name="l00115"></a>00115 { d->mNameFont = f; } <a name="l00116"></a>00116 <a name="l00117"></a><a class="code" href="classKChatBaseText.html#5331fbd5f458abc22f55cfba0498d5fa">00117</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBaseText.html#5331fbd5f458abc22f55cfba0498d5fa" title="Set the font for the message text.">KChatBaseText::setMessageFont</a>(<span class="keyword">const</span> QFont* f) <a name="l00118"></a>00118 { d->mMessageFont = f; } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordtype">void</span> KChatBaseText::paint(QPainter* painter) <a name="l00121"></a>00121 { <a name="l00122"></a>00122 QFontMetrics fm = painter->fontMetrics(); <a name="l00123"></a>00123 painter->setFont(<a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901" title="You can set the font of the sender name independently of the message itself.">nameFont</a>()); <a name="l00124"></a>00124 painter->drawText(3, fm.ascent() + fm.leading()/2, <a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">name</a>()); <a name="l00125"></a>00125 painter->setFont(<a class="code" href="classKChatBaseText.html#ee344ac8e852c396009e52492f64180f" title="You can set the font of the message independently of the sender name.">messageFont</a>()); <a name="l00126"></a>00126 painter->drawText(3 + QFontMetrics(<a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901" title="You can set the font of the sender name independently of the message itself.">nameFont</a>()).width(<a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">name</a>()), fm.ascent() + fm.leading()/2, <a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">message</a>()); <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="keywordtype">int</span> KChatBaseText::width(QListBox* lb)<span class="keyword"> const</span> <a name="l00130"></a>00130 <span class="keyword"></span>{ <a name="l00131"></a>00131 <span class="keywordtype">int</span> w = 0; <a name="l00132"></a>00132 <span class="keywordflow">if</span> (lb) { <a name="l00133"></a>00133 w += 6; <a name="l00134"></a>00134 w += QFontMetrics(<a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901" title="You can set the font of the sender name independently of the message itself.">nameFont</a>()).width(<a class="code" href="classKChatBaseText.html#82a659ab3bd1ca713568173c5a1065a1">name</a>()); <a name="l00135"></a>00135 w += QFontMetrics(<a class="code" href="classKChatBaseText.html#ee344ac8e852c396009e52492f64180f" title="You can set the font of the message independently of the sender name.">messageFont</a>()).width(<a class="code" href="classKChatBaseText.html#6a93405e6fad2cd428ded4227335f706">message</a>()); <a name="l00136"></a>00136 } <a name="l00137"></a>00137 <span class="comment">// int w = lb ? lb->fontMetrics().width( text() ) + 6 : 0; // QT orig</span> <a name="l00138"></a>00138 <span class="keywordflow">return</span> QMAX(w, QApplication::globalStrut().width()); <a name="l00139"></a>00139 } <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="keywordtype">int</span> KChatBaseText::height(QListBox* lb)<span class="keyword"> const</span> <a name="l00142"></a>00142 <span class="keyword"></span>{ <a name="l00143"></a>00143 <span class="keywordtype">int</span> h = 0; <a name="l00144"></a>00144 <span class="keywordflow">if</span> (lb) { <a name="l00145"></a>00145 h += 2; <a name="l00146"></a>00146 <span class="comment">// AB: is lineSpacing still correct?</span> <a name="l00147"></a>00147 <span class="keywordflow">if</span> (QFontMetrics(<a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901" title="You can set the font of the sender name independently of the message itself.">nameFont</a>()).lineSpacing() > QFontMetrics(<a class="code" href="classKChatBaseText.html#ee344ac8e852c396009e52492f64180f" title="You can set the font of the message independently of the sender name.">messageFont</a>()).lineSpacing()) { <a name="l00148"></a>00148 h += QFontMetrics(<a class="code" href="classKChatBaseText.html#8c76b6141233e304cf1890710f3f8901" title="You can set the font of the sender name independently of the message itself.">nameFont</a>()).lineSpacing(); <a name="l00149"></a>00149 } <span class="keywordflow">else</span> { <a name="l00150"></a>00150 h += QFontMetrics(<a class="code" href="classKChatBaseText.html#ee344ac8e852c396009e52492f64180f" title="You can set the font of the message independently of the sender name.">messageFont</a>()).lineSpacing(); <a name="l00151"></a>00151 } <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <span class="comment">// int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0; // QT orig</span> <a name="l00154"></a>00154 <span class="keywordflow">return</span> QMAX(h, QApplication::globalStrut().height()); <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <a name="l00157"></a>00157 <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keyword">class </span>KChatBasePrivate <a name="l00160"></a>00160 { <a name="l00161"></a>00161 <span class="keyword">public</span>: <a name="l00162"></a>00162 KChatBasePrivate() <a name="l00163"></a>00163 { <a name="l00164"></a>00164 mBox = 0; <a name="l00165"></a>00165 mEdit = 0; <a name="l00166"></a>00166 mCombo = 0; <a name="l00167"></a>00167 <a name="l00168"></a>00168 mAcceptMessage = <span class="keyword">true</span>; <a name="l00169"></a>00169 mMaxItems = -1; <a name="l00170"></a>00170 } <a name="l00171"></a>00171 QListBox* mBox; <a name="l00172"></a>00172 KLineEdit* mEdit; <a name="l00173"></a>00173 QComboBox* mCombo; <a name="l00174"></a>00174 <span class="keywordtype">bool</span> mAcceptMessage; <a name="l00175"></a>00175 <span class="keywordtype">int</span> mMaxItems; <a name="l00176"></a>00176 <a name="l00177"></a>00177 QValueList<int> mIndex2Id; <a name="l00178"></a>00178 <a name="l00179"></a>00179 QFont mNameFont; <a name="l00180"></a>00180 QFont mMessageFont; <a name="l00181"></a>00181 QFont mSystemNameFont; <a name="l00182"></a>00182 QFont mSystemMessageFont; <a name="l00183"></a>00183 }; <a name="l00184"></a>00184 <a name="l00185"></a><a class="code" href="classKChatBase.html#34b074951a40e4dea7f51666c09dc379">00185</a> <a class="code" href="classKChatBase.html#34b074951a40e4dea7f51666c09dc379">KChatBase::KChatBase</a>(QWidget* parent, <span class="keywordtype">bool</span> noComboBox) : QFrame(parent) <a name="l00186"></a>00186 { <a name="l00187"></a>00187 init(noComboBox); <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a><a class="code" href="classKChatBase.html#1c08ad8495491a42e654f9bedc26cf40">00190</a> <a class="code" href="classKChatBase.html#1c08ad8495491a42e654f9bedc26cf40" title="Destruct the KChatBase object.">KChatBase::~KChatBase</a>() <a name="l00191"></a>00191 { <a name="l00192"></a>00192 <span class="comment">// kdDebug(11000) << "KChatBase: DESTRUCT (" << this << ")" << endl;</span> <a name="l00193"></a>00193 <a class="code" href="classKChatBase.html#d2f4855df42c431116f65da6741997b2" title="Save the configuration of the dialog to a KConfig object.">saveConfig</a>(); <a name="l00194"></a>00194 <span class="keyword">delete</span> d; <a name="l00195"></a>00195 } <a name="l00196"></a>00196 <a name="l00197"></a>00197 <span class="keywordtype">void</span> KChatBase::init(<span class="keywordtype">bool</span> noComboBox) <a name="l00198"></a>00198 { <a name="l00199"></a>00199 <span class="comment">// kdDebug(11000) << "KChatBase: INIT (" << this << ")" << endl;</span> <a name="l00200"></a>00200 <a name="l00201"></a>00201 d = <span class="keyword">new</span> KChatBasePrivate; <a name="l00202"></a>00202 <a name="l00203"></a>00203 setMinimumWidth(100); <a name="l00204"></a>00204 setMinimumHeight(150); <a name="l00205"></a>00205 <a name="l00206"></a>00206 QVBoxLayout* l = <span class="keyword">new</span> QVBoxLayout(<span class="keyword">this</span>); <a name="l00207"></a>00207 <a name="l00208"></a>00208 d->mBox = <span class="keyword">new</span> QListBox(<span class="keyword">this</span>); <a name="l00209"></a>00209 connect(d->mBox, SIGNAL(<a class="code" href="classKChatBase.html#643e49619b129fcbfffd297bf320c52d" title="Emitted when the user right-clicks on a list item.">rightButtonClicked</a>(QListBoxItem*, <span class="keyword">const</span> QPoint&)), <a name="l00210"></a>00210 <span class="keyword">this</span>, SIGNAL(<a class="code" href="classKChatBase.html#643e49619b129fcbfffd297bf320c52d" title="Emitted when the user right-clicks on a list item.">rightButtonClicked</a>(QListBoxItem*, <span class="keyword">const</span> QPoint&))); <a name="l00211"></a>00211 l->addWidget(d->mBox); <a name="l00212"></a>00212 d->mBox->setVScrollBarMode(QScrollView::AlwaysOn); <a name="l00213"></a>00213 d->mBox->setHScrollBarMode(QScrollView::AlwaysOff); <a name="l00214"></a>00214 d->mBox->setFocusPolicy(QWidget::NoFocus); <a name="l00215"></a>00215 <span class="comment">// d->mBox->setSelectionMode(QListBox::NoSelection);</span> <a name="l00216"></a>00216 d->mBox->setSelectionMode(QListBox::Single); <a name="l00217"></a>00217 <a name="l00218"></a>00218 l->addSpacing(5); <a name="l00219"></a>00219 <a name="l00220"></a>00220 QHBoxLayout* h = <span class="keyword">new</span> QHBoxLayout(l); <a name="l00221"></a>00221 d->mEdit = <span class="keyword">new</span> KLineEdit(<span class="keyword">this</span>); <a name="l00222"></a>00222 d->mEdit->setHandleSignals(<span class="keyword">false</span>); <a name="l00223"></a>00223 d->mEdit->setTrapReturnKey(<span class="keyword">true</span>); <a name="l00224"></a>00224 d->mEdit->completionObject(); <span class="comment">// add the completion object</span> <a name="l00225"></a>00225 d->mEdit->setCompletionMode(KGlobalSettings::CompletionNone); <a name="l00226"></a>00226 connect(d->mEdit, SIGNAL(<a class="code" href="classKChatBase.html#a5094584b796d548536a6fdaa36e1364" title="This is called whenever the user pushed return ie wants to send a message.">returnPressed</a>(<span class="keyword">const</span> QString&)), <span class="keyword">this</span>, SLOT(slotReturnPressed(<span class="keyword">const</span> QString&))); <a name="l00227"></a>00227 h->addWidget(d->mEdit); <a name="l00228"></a>00228 <a name="l00229"></a>00229 <span class="keywordflow">if</span> (!noComboBox) { <a name="l00230"></a>00230 d->mCombo = <span class="keyword">new</span> QComboBox(<span class="keyword">this</span>); <a name="l00231"></a>00231 h->addWidget(d->mCombo); <a name="l00232"></a>00232 <a class="code" href="classKChatBase.html#d86a506bd30b229d77a6643cf63f3140" title="Adds a new entry in the combo box.">addSendingEntry</a>(i18n(<span class="stringliteral">"Send to All Players"</span>), SendToAll);<span class="comment">//FIXME: where to put the id?</span> <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 d->mAcceptMessage = <span class="keyword">true</span>; <span class="comment">// by default</span> <a name="l00236"></a>00236 <a class="code" href="classKChatBase.html#f51fada611ee3da3048bebc436294b73" title="Set the maximum number of items in the list.">setMaxItems</a>(-1); <span class="comment">// unlimited</span> <a name="l00237"></a>00237 <a name="l00238"></a>00238 <span class="keywordflow">if</span> (kapp) { <a name="l00239"></a>00239 <span class="comment">// kapp might be NULL as well - in case we are in Qt designer.</span> <a name="l00240"></a>00240 <a class="code" href="classKChatBase.html#a0f471424d712734bf6a101becd4e238" title="Read the configuration from a KConfig object.">readConfig</a>(); <a name="l00241"></a>00241 } <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <a name="l00244"></a><a class="code" href="classKChatBase.html#1931017a0a696ab9797c848b72f61e6c">00244</a> <span class="keywordtype">bool</span> <a class="code" href="classKChatBase.html#1931017a0a696ab9797c848b72f61e6c">KChatBase::acceptMessage</a>()<span class="keyword"> const</span> <a name="l00245"></a>00245 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mAcceptMessage; } <a name="l00246"></a>00246 <a name="l00247"></a><a class="code" href="classKChatBase.html#39ac0cdb3d270e7ff638806c24e6dda3">00247</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#39ac0cdb3d270e7ff638806c24e6dda3">KChatBase::setAcceptMessage</a>(<span class="keywordtype">bool</span> a) <a name="l00248"></a>00248 { d->mAcceptMessage = a; } <a name="l00249"></a>00249 <a name="l00250"></a><a class="code" href="classKChatBase.html#d86a506bd30b229d77a6643cf63f3140">00250</a> <span class="keywordtype">bool</span> <a class="code" href="classKChatBase.html#d86a506bd30b229d77a6643cf63f3140" title="Adds a new entry in the combo box.">KChatBase::addSendingEntry</a>(<span class="keyword">const</span> QString& text, <span class="keywordtype">int</span> <span class="keywordtype">id</span>) <a name="l00251"></a>00251 { <a name="l00252"></a>00252 <span class="comment">//FIXME: is ID used correctly? </span> <a name="l00253"></a>00253 <span class="comment">// do we need ID at all? </span> <a name="l00254"></a>00254 <span class="comment">// what the hell should be here?</span> <a name="l00255"></a>00255 <span class="comment">// d->mCombo->insertItem(i18n("Send to All Players"), SendToAll);</span> <a name="l00256"></a>00256 <span class="keywordflow">return</span> <a class="code" href="classKChatBase.html#1d4b3ecaf55e833cdaa2d21f26cc0b8d" title="Inserts a new entry in the combo box.">insertSendingEntry</a>(text, <span class="keywordtype">id</span>); <a name="l00257"></a>00257 } <a name="l00258"></a>00258 <a name="l00259"></a><a class="code" href="classKChatBase.html#1d4b3ecaf55e833cdaa2d21f26cc0b8d">00259</a> <span class="keywordtype">bool</span> <a class="code" href="classKChatBase.html#1d4b3ecaf55e833cdaa2d21f26cc0b8d" title="Inserts a new entry in the combo box.">KChatBase::insertSendingEntry</a>(<span class="keyword">const</span> QString& text, <span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> index) <a name="l00260"></a>00260 { <a name="l00261"></a>00261 <span class="keywordflow">if</span> (!d->mCombo) { <a name="l00262"></a>00262 kdWarning(11000) << <span class="stringliteral">"KChatBase: Cannot add an entry to the combo box"</span> << endl; <a name="l00263"></a>00263 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <span class="keywordflow">if</span> (d->mIndex2Id.findIndex(<span class="keywordtype">id</span>) != -1) { <a name="l00266"></a>00266 kdError(11000) << <span class="stringliteral">"KChatBase: Cannot add more than one entry with the same ID! "</span> << endl; <a name="l00267"></a>00267 kdError(11000) << <span class="stringliteral">"KChatBase: Text="</span><<text<<endl; <a name="l00268"></a>00268 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00269"></a>00269 } <a name="l00270"></a>00270 d->mCombo->insertItem(text, index); <a name="l00271"></a>00271 <span class="keywordflow">if</span> (index < 0) { <a name="l00272"></a>00272 d->mIndex2Id.append(<span class="keywordtype">id</span>); <a name="l00273"></a>00273 } <span class="keywordflow">else</span> { <a name="l00274"></a>00274 d->mIndex2Id.insert(d->mIndex2Id.at(index), id); <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <span class="keywordflow">if</span> (d->mIndex2Id.count() != (uint)d->mCombo->count()) { <a name="l00277"></a>00277 kdError(11000) << <span class="stringliteral">"KChatBase: internal ERROR - local IDs do not match combo box entries!"</span> << endl; <a name="l00278"></a>00278 } <a name="l00279"></a>00279 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00280"></a>00280 } <a name="l00281"></a>00281 <a name="l00282"></a><a class="code" href="classKChatBase.html#1847d424028059dbf73c95eacf3be977">00282</a> <span class="keywordtype">int</span> <a class="code" href="classKChatBase.html#1847d424028059dbf73c95eacf3be977">KChatBase::sendingEntry</a>()<span class="keyword"> const</span> <a name="l00283"></a>00283 <span class="keyword"></span>{ <a name="l00284"></a>00284 <span class="keywordflow">if</span> (!d->mCombo) { <a name="l00285"></a>00285 kdWarning(11001) << <span class="stringliteral">"Cannot retrieve index from NULL combo box"</span> << endl; <a name="l00286"></a>00286 <span class="keywordflow">return</span> -1; <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <span class="keywordtype">int</span> index = d->mCombo->currentItem(); <a name="l00289"></a>00289 <span class="keywordflow">if</span> (d->mIndex2Id.at(index) == d->mIndex2Id.end()) { <a name="l00290"></a>00290 kdWarning(11000) << <span class="stringliteral">"could not find the selected sending entry!"</span> << endl; <a name="l00291"></a>00291 <span class="keywordflow">return</span> -1; <a name="l00292"></a>00292 } <a name="l00293"></a>00293 <span class="keywordflow">return</span> d->mIndex2Id[index]; <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <a name="l00296"></a><a class="code" href="classKChatBase.html#e346a006e004c0bc94f68b65fd06fb56">00296</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#e346a006e004c0bc94f68b65fd06fb56" title="Removes the entry with the ID id from the combo box.">KChatBase::removeSendingEntry</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>) <a name="l00297"></a>00297 { <a name="l00298"></a>00298 <span class="keywordflow">if</span> (!d->mCombo) { <a name="l00299"></a>00299 kdWarning(11000) << <span class="stringliteral">"KChatBase: Cannot remove an entry from the combo box"</span> << endl; <a name="l00300"></a>00300 <span class="keywordflow">return</span>; <a name="l00301"></a>00301 } <a name="l00302"></a>00302 d->mCombo->removeItem(<a class="code" href="classKChatBase.html#33820910302d6df6f1c39ed429df7906">findIndex</a>(<span class="keywordtype">id</span>)); <a name="l00303"></a>00303 d->mIndex2Id.remove(<span class="keywordtype">id</span>); <a name="l00304"></a>00304 } <a name="l00305"></a>00305 <a name="l00306"></a><a class="code" href="classKChatBase.html#336dcd96d5ea1e1913e676481f9e7278">00306</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#336dcd96d5ea1e1913e676481f9e7278" title="This changes a combo box entry.">KChatBase::changeSendingEntry</a>(<span class="keyword">const</span> QString& text, <span class="keywordtype">int</span> <span class="keywordtype">id</span>) <a name="l00307"></a>00307 { <a name="l00308"></a>00308 <span class="keywordflow">if</span> (!d->mCombo) { <a name="l00309"></a>00309 kdWarning(11000) << <span class="stringliteral">"KChatBase: Cannot change an entry in the combo box"</span> << endl; <a name="l00310"></a>00310 <span class="keywordflow">return</span>; <a name="l00311"></a>00311 } <a name="l00312"></a>00312 <span class="keywordtype">int</span> index = <a class="code" href="classKChatBase.html#33820910302d6df6f1c39ed429df7906">findIndex</a>(<span class="keywordtype">id</span>); <a name="l00313"></a>00313 d->mCombo->changeItem(text, index); <a name="l00314"></a>00314 } <a name="l00315"></a>00315 <a name="l00316"></a><a class="code" href="classKChatBase.html#1a213361ee41714548233f695978bf88">00316</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#1a213361ee41714548233f695978bf88" title="This selects a combo box entry.">KChatBase::setSendingEntry</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>) <a name="l00317"></a>00317 { <a name="l00318"></a>00318 <span class="keywordflow">if</span> (!d->mCombo) { <a name="l00319"></a>00319 kdWarning(11000) << <span class="stringliteral">"KChatBase: Cannot set an entry in the combo box"</span> << endl; <a name="l00320"></a>00320 <span class="keywordflow">return</span>; <a name="l00321"></a>00321 } <a name="l00322"></a>00322 d->mCombo->setCurrentItem(<a class="code" href="classKChatBase.html#33820910302d6df6f1c39ed429df7906">findIndex</a>(<span class="keywordtype">id</span>)); <a name="l00323"></a>00323 } <a name="l00324"></a>00324 <a name="l00325"></a><a class="code" href="classKChatBase.html#33820910302d6df6f1c39ed429df7906">00325</a> <span class="keywordtype">int</span> <a class="code" href="classKChatBase.html#33820910302d6df6f1c39ed429df7906">KChatBase::findIndex</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>)<span class="keyword"> const</span> <a name="l00326"></a>00326 <span class="keyword"></span>{ <a name="l00327"></a>00327 <span class="keywordflow">return</span> d->mIndex2Id.findIndex(<span class="keywordtype">id</span>); <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <a name="l00330"></a><a class="code" href="classKChatBase.html#e21c4af4ab72b7d8880b7e9ac615c45a">00330</a> <span class="keywordtype">int</span> <a class="code" href="classKChatBase.html#e21c4af4ab72b7d8880b7e9ac615c45a">KChatBase::nextId</a>()<span class="keyword"> const</span> <a name="l00331"></a>00331 <span class="keyword"></span>{ <a name="l00332"></a>00332 <span class="keywordtype">int</span> i = SendToAll + 1; <a name="l00333"></a>00333 <span class="keywordflow">while</span> (d->mIndex2Id.findIndex(i) != -1) { <a name="l00334"></a>00334 i++; <a name="l00335"></a>00335 } <a name="l00336"></a>00336 <span class="keywordflow">return</span> i; <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a><a class="code" href="classKChatBase.html#3432f2b359a43df83fdf69870a245b6a">00339</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#3432f2b359a43df83fdf69870a245b6a" title="This member function is mainly internally used to add a message.">KChatBase::addItem</a>(<span class="keyword">const</span> QListBoxItem* text) <a name="l00340"></a>00340 { <a name="l00341"></a>00341 d->mBox->insertItem(text); <a name="l00342"></a>00342 <span class="keywordtype">int</span> index = d->mBox->count() -1; <a name="l00343"></a>00343 d->mBox->setBottomItem(index);<span class="comment">//FIXME: don't scroll to bottom if user scrolled down manually</span> <a name="l00344"></a>00344 <span class="keywordflow">if</span> (<a class="code" href="classKChatBase.html#c54c161e68ad83fe9d734c189ed3e63a">maxItems</a>() >= 0 && d->mBox->count() > (<span class="keywordtype">unsigned</span> int)<a class="code" href="classKChatBase.html#c54c161e68ad83fe9d734c189ed3e63a">maxItems</a>()) { <a name="l00345"></a>00345 d->mBox->removeItem(0); <a name="l00346"></a>00346 } <a name="l00347"></a>00347 } <a name="l00348"></a>00348 <a name="l00349"></a><a class="code" href="classKChatBase.html#87230262c5a40c360fddc4df22bd396c">00349</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#87230262c5a40c360fddc4df22bd396c" title="Add a text in the listbox.">KChatBase::addMessage</a>(<span class="keyword">const</span> QString& <a class="code" href="classKChatBase.html#bcbc2a1c411c4c352ea22dbe7325645d">fromName</a>, <span class="keyword">const</span> QString& text) <a name="l00350"></a>00350 { <a name="l00351"></a>00351 <span class="comment">//maybe "%1 says: %2" or so</span> <a name="l00352"></a>00352 <a class="code" href="classKChatBase.html#3432f2b359a43df83fdf69870a245b6a" title="This member function is mainly internally used to add a message.">addItem</a>(<a class="code" href="classKChatBase.html#67cd8c0b75d8b833affe947247c6e89a" title="Create a QListBoxItem for this message.">layoutMessage</a>(fromName, text)); <a name="l00353"></a>00353 } <a name="l00354"></a>00354 <a name="l00355"></a><a class="code" href="classKChatBase.html#228a7f5d7accac8c71bce23e76e68878">00355</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#228a7f5d7accac8c71bce23e76e68878" title="This works just like addMessage but adds a system message.">KChatBase::addSystemMessage</a>(<span class="keyword">const</span> QString& <a class="code" href="classKChatBase.html#bcbc2a1c411c4c352ea22dbe7325645d">fromName</a>, <span class="keyword">const</span> QString& text) <a name="l00356"></a>00356 { <a name="l00357"></a>00357 <a class="code" href="classKChatBase.html#3432f2b359a43df83fdf69870a245b6a" title="This member function is mainly internally used to add a message.">addItem</a>(<a class="code" href="classKChatBase.html#de8b61ac8cf004d1f520587afec51cb1" title="Create a QListBoxItem for this message.">layoutSystemMessage</a>(fromName, text)); <a name="l00358"></a>00358 } <a name="l00359"></a>00359 <a name="l00360"></a><a class="code" href="classKChatBase.html#67cd8c0b75d8b833affe947247c6e89a">00360</a> QListBoxItem* <a class="code" href="classKChatBase.html#67cd8c0b75d8b833affe947247c6e89a" title="Create a QListBoxItem for this message.">KChatBase::layoutMessage</a>(<span class="keyword">const</span> QString& <a class="code" href="classKChatBase.html#bcbc2a1c411c4c352ea22dbe7325645d">fromName</a>, <span class="keyword">const</span> QString& text) <a name="l00361"></a>00361 { <a name="l00362"></a>00362 <span class="comment">//TODO: KChatBaseConfigure? - e.g. color</span> <a name="l00363"></a>00363 QListBoxItem* message; <a name="l00364"></a>00364 <span class="keywordflow">if</span> (text.startsWith(<span class="stringliteral">"/me "</span>)) { <a name="l00365"></a>00365 <span class="comment">// replace "/me" by a nice star. leave one space after the star</span> <a name="l00366"></a>00366 QPixmap pix; <a name="l00367"></a>00367 pix.load(locate(<span class="stringliteral">"data"</span>, QString::fromLatin1(<span class="stringliteral">"kdegames/pics/star.png"</span>))); <a name="l00368"></a>00368 <a name="l00369"></a>00369 <span class="comment">//TODO KChatBasePixmap? Should change the font here!</span> <a name="l00370"></a>00370 <a name="l00371"></a>00371 message = (QListBoxItem*)<span class="keyword">new</span> QListBoxPixmap(pix, i18n(<span class="stringliteral">"%1 %2"</span>).arg(fromName).arg(text.mid(3))); <a name="l00372"></a>00372 } <span class="keywordflow">else</span> { <a name="l00373"></a>00373 <span class="comment">// the text is not edited in any way. just return an item</span> <a name="l00374"></a>00374 <a class="code" href="classKChatBaseText.html" title="A QListBoxText implementation for KChatBase.">KChatBaseText</a>* m = <span class="keyword">new</span> <a class="code" href="classKChatBaseText.html" title="A QListBoxText implementation for KChatBase.">KChatBaseText</a>(fromName, text); <a name="l00375"></a>00375 m-><a class="code" href="classKChatBaseText.html#d17ea04616417e48697f5841a415378c" title="Set the font for the name.">setNameFont</a>(&d->mNameFont); <a name="l00376"></a>00376 m-><a class="code" href="classKChatBaseText.html#5331fbd5f458abc22f55cfba0498d5fa" title="Set the font for the message text.">setMessageFont</a>(&d->mMessageFont); <a name="l00377"></a>00377 message = (QListBoxItem*)m; <a name="l00378"></a>00378 } <a name="l00379"></a>00379 <span class="keywordflow">return</span> message; <a name="l00380"></a>00380 } <a name="l00381"></a>00381 <a name="l00382"></a><a class="code" href="classKChatBase.html#de8b61ac8cf004d1f520587afec51cb1">00382</a> QListBoxItem* <a class="code" href="classKChatBase.html#de8b61ac8cf004d1f520587afec51cb1" title="Create a QListBoxItem for this message.">KChatBase::layoutSystemMessage</a>(<span class="keyword">const</span> QString& <a class="code" href="classKChatBase.html#bcbc2a1c411c4c352ea22dbe7325645d">fromName</a>, <span class="keyword">const</span> QString& text) <a name="l00383"></a>00383 { <a name="l00384"></a>00384 <span class="comment">//TODO: KChatBaseConfigure? - e.g. color</span> <a name="l00385"></a>00385 <a name="l00386"></a>00386 <span class="comment">// no need to check for /me etc.</span> <a name="l00387"></a>00387 <a class="code" href="classKChatBaseText.html" title="A QListBoxText implementation for KChatBase.">KChatBaseText</a>* m = <span class="keyword">new</span> <a class="code" href="classKChatBaseText.html" title="A QListBoxText implementation for KChatBase.">KChatBaseText</a>(i18n(<span class="stringliteral">"--- %1"</span>).arg(fromName), text); <a name="l00388"></a>00388 m-><a class="code" href="classKChatBaseText.html#d17ea04616417e48697f5841a415378c" title="Set the font for the name.">setNameFont</a>(&d->mSystemNameFont); <a name="l00389"></a>00389 m-><a class="code" href="classKChatBaseText.html#5331fbd5f458abc22f55cfba0498d5fa" title="Set the font for the message text.">setMessageFont</a>(&d->mSystemMessageFont); <a name="l00390"></a>00390 <span class="keywordflow">return</span> (QListBoxItem*)m; <a name="l00391"></a>00391 } <a name="l00392"></a>00392 <a name="l00393"></a>00393 <span class="keywordtype">void</span> KChatBase::slotReturnPressed(<span class="keyword">const</span> QString& text) <a name="l00394"></a>00394 { <a name="l00395"></a>00395 <span class="keywordflow">if</span> (text.length() <= 0) { <a name="l00396"></a>00396 <span class="comment">// no text entered - probably hit return by accident</span> <a name="l00397"></a>00397 <span class="keywordflow">return</span>; <a name="l00398"></a>00398 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!<a class="code" href="classKChatBase.html#1931017a0a696ab9797c848b72f61e6c">acceptMessage</a>()) { <a name="l00399"></a>00399 <span class="keywordflow">return</span>; <a name="l00400"></a>00400 } <a name="l00401"></a>00401 d->mEdit->completionObject()->addItem(text); <a name="l00402"></a>00402 <span class="comment">// connect(d->mEdit, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&)));</span> <a name="l00403"></a>00403 d->mEdit->clear(); <a name="l00404"></a>00404 <a class="code" href="classKChatBase.html#a5094584b796d548536a6fdaa36e1364" title="This is called whenever the user pushed return ie wants to send a message.">returnPressed</a>(text); <a name="l00405"></a>00405 } <a name="l00406"></a>00406 <a name="l00407"></a><a class="code" href="classKChatBase.html#7819bcbe55a1eaf8695ed128bb54b185">00407</a> QString <a class="code" href="classKChatBase.html#7819bcbe55a1eaf8695ed128bb54b185" title="Replace to customise the combo box.">KChatBase::comboBoxItem</a>(<span class="keyword">const</span> QString& name)<span class="keyword"> const</span> <a name="l00408"></a>00408 <span class="keyword"></span>{ <span class="comment">// TODO: such a function for "send to all" and "send to my group"</span> <a name="l00409"></a>00409 <span class="keywordflow">return</span> i18n(<span class="stringliteral">"Send to %1"</span>).arg(name); <a name="l00410"></a>00410 } <a name="l00411"></a>00411 <a name="l00412"></a><a class="code" href="classKChatBase.html#0474a55d602a8831bac9a6a297b68013">00412</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#0474a55d602a8831bac9a6a297b68013" title="This clears all messages in the view.">KChatBase::slotClear</a>() <a name="l00413"></a>00413 { <a name="l00414"></a>00414 d->mBox->clear(); <a name="l00415"></a>00415 } <a name="l00416"></a>00416 <a name="l00417"></a><a class="code" href="classKChatBase.html#79119584247e280b45ff19f329ed896a">00417</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#79119584247e280b45ff19f329ed896a" title="See KLineEdit::setCompletionMode.">KChatBase::setCompletionMode</a>(KGlobalSettings::Completion mode) <a name="l00418"></a>00418 { d->mEdit->setCompletionMode(mode); } <a name="l00419"></a>00419 <a name="l00420"></a><a class="code" href="classKChatBase.html#1fb0604a30685ff35eb0c4dc9c67ee72">00420</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#1fb0604a30685ff35eb0c4dc9c67ee72" title="Set the font that used used for the name part of a message.">KChatBase::setNameFont</a>(<span class="keyword">const</span> QFont& font) <a name="l00421"></a>00421 { <a name="l00422"></a>00422 d->mNameFont = font; <a name="l00423"></a>00423 d->mBox->triggerUpdate(<span class="keyword">false</span>); <a name="l00424"></a>00424 } <a name="l00425"></a>00425 <a name="l00426"></a><a class="code" href="classKChatBase.html#8247cf4db2da92cfbea8239ed50e3f13">00426</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#8247cf4db2da92cfbea8239ed50e3f13" title="Set the font that used used for the message part of a message.">KChatBase::setMessageFont</a>(<span class="keyword">const</span> QFont& font) <a name="l00427"></a>00427 { <a name="l00428"></a>00428 d->mMessageFont = font; <a name="l00429"></a>00429 d->mBox->triggerUpdate(<span class="keyword">false</span>); <a name="l00430"></a>00430 } <a name="l00431"></a>00431 <a name="l00432"></a><a class="code" href="classKChatBase.html#0317422d8bd14a5f38ee57666587d71c">00432</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#0317422d8bd14a5f38ee57666587d71c" title="This sets both - nameFont and messageFont to font.">KChatBase::setBothFont</a>(<span class="keyword">const</span> QFont& font) <a name="l00433"></a>00433 { <a name="l00434"></a>00434 <a class="code" href="classKChatBase.html#1fb0604a30685ff35eb0c4dc9c67ee72" title="Set the font that used used for the name part of a message.">setNameFont</a>(font); <a name="l00435"></a>00435 <a class="code" href="classKChatBase.html#8247cf4db2da92cfbea8239ed50e3f13" title="Set the font that used used for the message part of a message.">setMessageFont</a>(font); <a name="l00436"></a>00436 } <a name="l00437"></a>00437 <a name="l00438"></a><a class="code" href="classKChatBase.html#85f8a7b772c81dfad60a57d313c66acb">00438</a> <span class="keyword">const</span> QFont& <a class="code" href="classKChatBase.html#85f8a7b772c81dfad60a57d313c66acb" title="This font should be used for the name (the &quot;from: &quot; part) of a message...">KChatBase::nameFont</a>()<span class="keyword"> const</span> <a name="l00439"></a>00439 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mNameFont; } <a name="l00440"></a>00440 <a name="l00441"></a><a class="code" href="classKChatBase.html#84d64953870abacd0b3d5fc580b474e3">00441</a> <span class="keyword">const</span> QFont& <a class="code" href="classKChatBase.html#84d64953870abacd0b3d5fc580b474e3" title="This font should be used for a message.">KChatBase::messageFont</a>()<span class="keyword"> const</span> <a name="l00442"></a>00442 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mMessageFont; } <a name="l00443"></a>00443 <a name="l00444"></a><a class="code" href="classKChatBase.html#462382c8a3aa1bac04b93275b08ff1ae">00444</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#462382c8a3aa1bac04b93275b08ff1ae" title="Same as setNameFont but applies only to system messages.">KChatBase::setSystemNameFont</a>(<span class="keyword">const</span> QFont& font) <a name="l00445"></a>00445 { <a name="l00446"></a>00446 d->mSystemNameFont = font; <a name="l00447"></a>00447 d->mBox->triggerUpdate(<span class="keyword">false</span>); <a name="l00448"></a>00448 } <a name="l00449"></a>00449 <a name="l00450"></a><a class="code" href="classKChatBase.html#7802497435b319cc7ff0a84897411773">00450</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#7802497435b319cc7ff0a84897411773" title="Same as setMessageFont but applies only to system messages.">KChatBase::setSystemMessageFont</a>(<span class="keyword">const</span> QFont& font) <a name="l00451"></a>00451 { <a name="l00452"></a>00452 d->mSystemMessageFont = font; <a name="l00453"></a>00453 d->mBox->triggerUpdate(<span class="keyword">false</span>); <a name="l00454"></a>00454 } <a name="l00455"></a>00455 <a name="l00456"></a><a class="code" href="classKChatBase.html#56180fb8853d28a05d8bb31bd9ccc473">00456</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#56180fb8853d28a05d8bb31bd9ccc473" title="Same as setBothFont but applies only to system messages.">KChatBase::setSystemBothFont</a>(<span class="keyword">const</span> QFont& font) <a name="l00457"></a>00457 { <a name="l00458"></a>00458 <a class="code" href="classKChatBase.html#462382c8a3aa1bac04b93275b08ff1ae" title="Same as setNameFont but applies only to system messages.">setSystemNameFont</a>(font); <a name="l00459"></a>00459 <a class="code" href="classKChatBase.html#7802497435b319cc7ff0a84897411773" title="Same as setMessageFont but applies only to system messages.">setSystemMessageFont</a>(font); <a name="l00460"></a>00460 } <a name="l00461"></a>00461 <a name="l00462"></a><a class="code" href="classKChatBase.html#47aa2edca1c29f5adacf744820eab4b7">00462</a> <span class="keyword">const</span> QFont& <a class="code" href="classKChatBase.html#47aa2edca1c29f5adacf744820eab4b7" title="Same as systemNameFont but applies only to system messages.">KChatBase::systemNameFont</a>()<span class="keyword"> const</span> <a name="l00463"></a>00463 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mSystemNameFont; } <a name="l00464"></a>00464 <a name="l00465"></a><a class="code" href="classKChatBase.html#5f780dc058418febf113fc0fc7d2ee81">00465</a> <span class="keyword">const</span> QFont& <a class="code" href="classKChatBase.html#5f780dc058418febf113fc0fc7d2ee81" title="Same as systemMessageFont but applies only to system messages.">KChatBase::systemMessageFont</a>()<span class="keyword"> const</span> <a name="l00466"></a>00466 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mSystemMessageFont; } <a name="l00467"></a>00467 <a name="l00468"></a><a class="code" href="classKChatBase.html#d2f4855df42c431116f65da6741997b2">00468</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#d2f4855df42c431116f65da6741997b2" title="Save the configuration of the dialog to a KConfig object.">KChatBase::saveConfig</a>(KConfig* conf) <a name="l00469"></a>00469 { <a name="l00470"></a>00470 QString oldGroup; <a name="l00471"></a>00471 <span class="keywordflow">if</span> (!conf) { <a name="l00472"></a>00472 conf = kapp->config(); <a name="l00473"></a>00473 oldGroup = conf->group(); <a name="l00474"></a>00474 conf->setGroup(<span class="stringliteral">"KChatBase"</span>); <a name="l00475"></a>00475 } <a name="l00476"></a>00476 <a name="l00477"></a>00477 conf->writeEntry(<span class="stringliteral">"NameFont"</span>, <a class="code" href="classKChatBase.html#85f8a7b772c81dfad60a57d313c66acb" title="This font should be used for the name (the &quot;from: &quot; part) of a message...">nameFont</a>()); <a name="l00478"></a>00478 conf->writeEntry(<span class="stringliteral">"MessageFont"</span>, <a class="code" href="classKChatBase.html#84d64953870abacd0b3d5fc580b474e3" title="This font should be used for a message.">messageFont</a>()); <a name="l00479"></a>00479 conf->writeEntry(<span class="stringliteral">"SystemNameFont"</span>, <a class="code" href="classKChatBase.html#47aa2edca1c29f5adacf744820eab4b7" title="Same as systemNameFont but applies only to system messages.">systemNameFont</a>()); <a name="l00480"></a>00480 conf->writeEntry(<span class="stringliteral">"SystemMessageFont"</span>, <a class="code" href="classKChatBase.html#5f780dc058418febf113fc0fc7d2ee81" title="Same as systemMessageFont but applies only to system messages.">systemMessageFont</a>()); <a name="l00481"></a>00481 conf->writeEntry(<span class="stringliteral">"MaxMessages"</span>, <a class="code" href="classKChatBase.html#c54c161e68ad83fe9d734c189ed3e63a">maxItems</a>()); <a name="l00482"></a>00482 <a name="l00483"></a>00483 <span class="keywordflow">if</span> (!oldGroup.isNull()) { <a name="l00484"></a>00484 conf->setGroup(oldGroup); <a name="l00485"></a>00485 } <a name="l00486"></a>00486 } <a name="l00487"></a>00487 <a name="l00488"></a><a class="code" href="classKChatBase.html#a0f471424d712734bf6a101becd4e238">00488</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#a0f471424d712734bf6a101becd4e238" title="Read the configuration from a KConfig object.">KChatBase::readConfig</a>(KConfig* conf) <a name="l00489"></a>00489 { <a name="l00490"></a>00490 QString oldGroup; <a name="l00491"></a>00491 <span class="keywordflow">if</span> (!conf) { <a name="l00492"></a>00492 conf = kapp->config(); <a name="l00493"></a>00493 oldGroup = conf->group(); <a name="l00494"></a>00494 conf->setGroup(<span class="stringliteral">"KChatBase"</span>); <a name="l00495"></a>00495 } <a name="l00496"></a>00496 <a name="l00497"></a>00497 <a class="code" href="classKChatBase.html#1fb0604a30685ff35eb0c4dc9c67ee72" title="Set the font that used used for the name part of a message.">setNameFont</a>(conf->readFontEntry(<span class="stringliteral">"NameFont"</span>)); <a name="l00498"></a>00498 <a class="code" href="classKChatBase.html#8247cf4db2da92cfbea8239ed50e3f13" title="Set the font that used used for the message part of a message.">setMessageFont</a>(conf->readFontEntry(<span class="stringliteral">"MessageFont"</span>)); <a name="l00499"></a>00499 <a class="code" href="classKChatBase.html#462382c8a3aa1bac04b93275b08ff1ae" title="Same as setNameFont but applies only to system messages.">setSystemNameFont</a>(conf->readFontEntry(<span class="stringliteral">"SystemNameFont"</span>)); <a name="l00500"></a>00500 <a class="code" href="classKChatBase.html#7802497435b319cc7ff0a84897411773" title="Same as setMessageFont but applies only to system messages.">setSystemMessageFont</a>(conf->readFontEntry(<span class="stringliteral">"SystemMessageFont"</span>)); <a name="l00501"></a>00501 <a class="code" href="classKChatBase.html#f51fada611ee3da3048bebc436294b73" title="Set the maximum number of items in the list.">setMaxItems</a>(conf->readNumEntry(<span class="stringliteral">"MaxMessages"</span>, -1)); <a name="l00502"></a>00502 <a name="l00503"></a>00503 <span class="keywordflow">if</span> (!oldGroup.isNull()) { <a name="l00504"></a>00504 conf->setGroup(oldGroup); <a name="l00505"></a>00505 } <a name="l00506"></a>00506 } <a name="l00507"></a>00507 <a name="l00508"></a><a class="code" href="classKChatBase.html#c5235e88eb5dac20545a001daa9cf118">00508</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#c5235e88eb5dac20545a001daa9cf118" title="Clear all messages in the list.">KChatBase::clear</a>() <a name="l00509"></a>00509 { <a name="l00510"></a>00510 d->mBox->clear(); <a name="l00511"></a>00511 } <a name="l00512"></a>00512 <a name="l00513"></a><a class="code" href="classKChatBase.html#f51fada611ee3da3048bebc436294b73">00513</a> <span class="keywordtype">void</span> <a class="code" href="classKChatBase.html#f51fada611ee3da3048bebc436294b73" title="Set the maximum number of items in the list.">KChatBase::setMaxItems</a>(<span class="keywordtype">int</span> <a class="code" href="classKChatBase.html#c54c161e68ad83fe9d734c189ed3e63a">maxItems</a>) <a name="l00514"></a>00514 { <a name="l00515"></a>00515 d->mMaxItems = maxItems; <a name="l00516"></a>00516 <span class="comment">//TODO cut too many messages</span> <a name="l00517"></a>00517 <span class="keywordflow">if</span> (maxItems == 0) { <a name="l00518"></a>00518 <a class="code" href="classKChatBase.html#c5235e88eb5dac20545a001daa9cf118" title="Clear all messages in the list.">clear</a>(); <a name="l00519"></a>00519 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (maxItems > 0) { <a name="l00520"></a>00520 <span class="keywordflow">while</span> (d->mBox->count() > (<span class="keywordtype">unsigned</span> int)maxItems) { <a name="l00521"></a>00521 d->mBox->removeItem(0); <a name="l00522"></a>00522 } <a name="l00523"></a>00523 } <a name="l00524"></a>00524 } <a name="l00525"></a>00525 <a name="l00526"></a><a class="code" href="classKChatBase.html#c54c161e68ad83fe9d734c189ed3e63a">00526</a> <span class="keywordtype">int</span> <a class="code" href="classKChatBase.html#c54c161e68ad83fe9d734c189ed3e63a">KChatBase::maxItems</a>()<span class="keyword"> const</span> <a name="l00527"></a>00527 <span class="keyword"></span>{ <span class="keywordflow">return</span> d->mMaxItems; } <a name="l00528"></a>00528 <a name="l00529"></a>00529 <a name="l00530"></a>00530 <span class="preprocessor">#include "kchatbase.moc"</span> </pre></div></div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>libkdegames</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classKCanvasRootPixmap.html">kcanvasrootpixmap</option>, <option value="classKCardDialog.html">kcarddialog</option>, <option value="classKChat.html">kchat</option>, <option value="classKChatBase.html">kchatbase</option>, <option value="classKChatBaseText.html">kchatbasetext</option>, <option value="classKExtHighscore_1_1Item.html">kexthighscore::item</option>, <option value="classKExtHighscore_1_1ItemArray.html">kexthighscore::itemarray</option>, <option value="classKExtHighscore_1_1Manager.html">kexthighscore::manager</option>, <option value="classKExtHighscore_1_1MultiplayerScores.html">kexthighscore::multiplayerscores</option>, <option value="classKExtHighscore_1_1Score.html">kexthighscore::score</option>, <option value="classKGame.html">kgame</option>, <option value="classKGameChat.html">kgamechat</option>, <option value="classKGameComputerIO.html">kgamecomputerio</option>, <option value="classKGameConnectDialog.html">kgameconnectdialog</option>, <option value="classKGameDialog.html">kgamedialog</option>, <option value="classKGameDialogChatConfig.html">kgamedialogchatconfig</option>, <option value="classKGameDialogConfig.html">kgamedialogconfig</option>, <option value="classKGameErrorDialog.html">kgameerrordialog</option>, <option value="classKGameErrorMessageDialog.html">kgameerrormessagedialog</option>, <option value="classKGameIO.html">kgameio</option>, <option value="classKGameKeyIO.html">kgamekeyio</option>, <option value="classKGameLCD.html">kgamelcd</option>, <option value="classKGameLCDClock.html">kgamelcdclock</option>, <option value="classKGameLCDList.html">kgamelcdlist</option>, <option value="classKGameMisc.html">kgamemisc</option>, <option value="classKGameMouseIO.html">kgamemouseio</option>, <option value="classKGameNetwork.html">kgamenetwork</option>, <option value="classKGameProcess.html">kgameprocess</option>, <option value="classKGameProcessIO.html">kgameprocessio</option>, <option value="classKGameProgress.html">kgameprogress</option>, <option value="classKGameProperty.html">kgameproperty</option>, <option value="classKGamePropertyBase.html">kgamepropertybase</option>, <option value="classKGamePropertyHandler.html">kgamepropertyhandler</option>, <option value="classKGameSequence.html">kgamesequence</option>, <option value="classKGrid2D_1_1Generic.html">kgrid2d::generic</option>, <option value="classKGrid2D_1_1Hexagonal.html">kgrid2d::hexagonal</option>, <option value="classKGrid2D_1_1HexagonalBase.html">kgrid2d::hexagonalbase</option>, <option value="classKGrid2D_1_1Square.html">kgrid2d::square</option>, <option value="classKGrid2D_1_1SquareBase.html">kgrid2d::squarebase</option>, <option value="classKHighscore.html">khighscore</option>, <option value="classKMessageClient.html">kmessageclient</option>, <option value="classKMessageDirect.html">kmessagedirect</option>, <option value="classKMessageIO.html">kmessageio</option>, <option value="classKMessageServer.html">kmessageserver</option>, <option value="classKMessageServerSocket.html">kmessageserversocket</option>, <option value="classKMessageSocket.html">kmessagesocket</option>, <option value="classKPlayer.html">kplayer</option>, <option value="classKScoreDialog.html">kscoredialog</option>, <option value="classKStdGameAction.html">kstdgameaction</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../libkdegames/html/index.html">libkdegames</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>