kchatbasemodel.h

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
00004     Copyright (C) 2007 Gael de Chalendar (aka Kleag) <kleag@free.fr>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License version 2 as published by the Free Software Foundation.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 #ifndef __KCHATBASEMODEL_H__
00021 #define __KCHATBASEMODEL_H__
00022 
00023 #include <QtCore/QAbstractListModel>
00024 #include <QtCore/QPair>
00025 
00026 #include <libkdegames_export.h>
00027 
00028 class KChatBaseModelPrivate;
00029 class KChatBaseMessagePrivate;
00030 class KConfig;
00031 
00039 class KDEGAMES_EXPORT KChatBaseMessage : public QPair< QString, QString >
00040 {
00041   public:
00043     enum MessageType
00044     {
00045       Normal,
00046       System
00047     };
00048     
00050     KChatBaseMessage();
00051     
00053     KChatBaseMessage(const QString& sender, const QString& message, 
00054           MessageType type=Normal);
00055 
00057     KChatBaseMessage(const KChatBaseMessage& m);
00058 
00060     virtual ~KChatBaseMessage();
00061     
00062   private:
00063     KChatBaseMessagePrivate* d;
00064 };
00065 Q_DECLARE_METATYPE(KChatBaseMessage)
00066 
00067 
00072 class KDEGAMES_EXPORT KChatBaseModel : public QAbstractListModel
00073 {
00074   Q_OBJECT
00075   
00076 public:
00078   KChatBaseModel(QObject *parent = 0);
00079 
00081   virtual ~KChatBaseModel();
00082     
00087   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00088   
00089   
00094   virtual QVariant data(const QModelIndex &index, int role) const;
00095 
00100   void setNameFont(const QFont& font);
00101   
00106   void setMessageFont(const QFont& font);
00107 
00114   void setBothFont(const QFont& font);
00115 
00119   void setSystemNameFont(const QFont& font);
00120 
00124   void setSystemMessageFont(const QFont& font);
00125 
00129   void setSystemBothFont(const QFont& font);
00130 
00138   const QFont& nameFont() const;
00139 
00147   const QFont& messageFont() const;
00148 
00152   const QFont& systemNameFont() const;
00153 
00157   const QFont& systemMessageFont() const;
00158 
00168   virtual void saveConfig(KConfig* conf = 0);
00169 
00175   virtual void readConfig(KConfig* conf = 0);
00176 
00184   void setMaxItems(int maxItems);
00185 
00189   void clear();
00190 
00195   int maxItems() const;
00196 
00197 public Q_SLOTS:
00209   virtual void addMessage(const QString& fromName, const QString& text);
00210 
00217   virtual void addSystemMessage(const QString& fromName, const QString& text);
00218 
00223   void slotClear();
00224 
00225   private:
00226     KChatBaseModelPrivate* d;
00227 };
00228 
00229 #endif

Generated on Sun Mar 16 08:02:52 2008 for Libkdegames by  doxygen 1.5.3