KDEGames

kchatbasemodel.h
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Andreas Beckermann ([email protected])
4  Copyright (C) 2007 Gael de Chalendar (aka Kleag) <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 #ifndef __KCHATBASEMODEL_H__
21 #define __KCHATBASEMODEL_H__
22 
23 #include <QAbstractListModel>
24 #include <QPair>
25 #include <QLoggingCategory>
26 
27 #include "libkdegamesprivate_export.h"
28 
29 Q_DECLARE_LOGGING_CATEGORY(GAMES_LIB)
30 
31 class KChatBaseModelPrivate;
32 class KChatBaseMessagePrivate;
33 class KConfig;
34 
44 class KDEGAMESPRIVATE_EXPORT KChatBaseMessage : public QPair< QString, QString >
45 {
46  public:
49  {
50  Normal,
51  System
52  };
53 
56 
58  KChatBaseMessage(const QString& sender, const QString& message,
59  MessageType type=Normal);
60 
63 
65  virtual ~KChatBaseMessage();
66 
67  private:
68  KChatBaseMessagePrivate* d;
69 };
70 Q_DECLARE_METATYPE(KChatBaseMessage)
71 
72 
79 class KDEGAMESPRIVATE_EXPORT KChatBaseModel : public QAbstractListModel
80 {
81  Q_OBJECT
82 
83 public:
85  explicit KChatBaseModel(QObject *parent = nullptr);
86 
88  ~KChatBaseModel() override;
89 
94  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
95 
96 
101  QVariant data(const QModelIndex &index, int role) const override;
102 
107  void setNameFont(const QFont& font);
108 
113  void setMessageFont(const QFont& font);
114 
121  void setBothFont(const QFont& font);
122 
126  void setSystemNameFont(const QFont& font);
127 
131  void setSystemMessageFont(const QFont& font);
132 
136  void setSystemBothFont(const QFont& font);
137 
145  const QFont& nameFont() const;
146 
154  const QFont& messageFont() const;
155 
159  const QFont& systemNameFont() const;
160 
164  const QFont& systemMessageFont() const;
165 
175  virtual void saveConfig(KConfig* conf = nullptr);
176 
182  virtual void readConfig(KConfig* conf = nullptr);
183 
191  void setMaxItems(int maxItems);
192 
196  void clear();
197 
202  int maxItems() const;
203 
204 public Q_SLOTS:
216  virtual void addMessage(const QString& fromName, const QString& text);
217 
224  virtual void addSystemMessage(const QString& fromName, const QString& text);
225 
230  void slotClear();
231 
232  private:
233  KChatBaseModelPrivate* d;
234 };
235 
236 #endif
The class of the elements stored in the chat list model.
MessageType
The different types of messages.
The model used to store messages displayed in the chat dialog messages list.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:37:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.