KDEGames

kchatbase.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 __KCHATBASE_H__
21 #define __KCHATBASE_H__
22 
23 #include <QFrame>
24 #include <QLoggingCategory>
25 
26 #include <KCompletion>
27 #include "libkdegamesprivate_export.h"
28 
29 class KConfig;
30 
31 class KChatBasePrivate;
32 class KChatBaseModel;
34 class QModelIndex;
35 class QPoint;
36 
37 Q_DECLARE_LOGGING_CATEGORY(GAMES_BACKGAMMON)
38 Q_DECLARE_LOGGING_CATEGORY(GAMES_PRIVATE_KGAME)
39 
75 class KDEGAMESPRIVATE_EXPORT KChatBase : public QFrame
76 {
77  Q_OBJECT
78 public:
87  explicit KChatBase(QWidget* parent, KChatBaseModel* model=nullptr,
88  KChatBaseItemDelegate* delegate=nullptr,
89  bool noComboBox = false);
90 
96  virtual ~KChatBase();
97 
98  enum SendingIds {
99  SendToAll = 0
100  };
101 
107  virtual QString fromName() const = 0;
108 
120  bool addSendingEntry(const QString& text, int id);
121 
133  bool insertSendingEntry(const QString& text, int id, int index = -1);
134 
140  void changeSendingEntry(const QString& text, int id);
141 
146  void setSendingEntry(int id);
147 
154  void removeSendingEntry(int id);
155 
163  int sendingEntry() const;
164 
168  int findIndex(int id) const;
169 
174  int nextId() const;
175 
182  virtual bool acceptMessage() const;
183 
187  void setCompletionMode(KCompletion::CompletionMode mode);
188 
193  void setNameFont(const QFont& font);
194 
199  void setMessageFont(const QFont& font);
200 
207  void setBothFont(const QFont& font);
208 
213  void setSystemNameFont(const QFont& font);
214 
219  void setSystemMessageFont(const QFont& font);
220 
225  void setSystemBothFont(const QFont& font);
226 
234  QFont nameFont() const;
235 
243  QFont messageFont() const;
244 
249  QFont systemNameFont() const;
250 
255  QFont systemMessageFont() const;
256 
266  virtual void saveConfig(KConfig* conf = nullptr);
267 
273  virtual void readConfig(KConfig* conf = nullptr);
274 
282  void setMaxItems(int maxItems);
283 
287  void clear();
288 
293  int maxItems() const;
294 
295  KChatBaseModel* model();
296  void setModel(KChatBaseModel* m);
297 
298 public Q_SLOTS:
310  virtual void addMessage(const QString& fromName, const QString& text);
311 
319  virtual void addSystemMessage(const QString& fromName, const QString& text);
320 
325  void slotClear();
326 
331  void setAcceptMessage(bool a);
332 
333 protected:
345  virtual void returnPressed(const QString& text) = 0;
346 
354  virtual QString comboBoxItem(const QString& name) const;
355 
361  const QModelIndex indexAt(const QPoint& pos) const;
362 
363 private Q_SLOTS:
369  void slotReturnPressed(const QString&);
370 
375  virtual void customMenuHandler(const QPoint &pos);
376 
377 private:
378 
379  KChatBasePrivate* d;
380 };
381 
382 #endif
The base class for chat widgets.
Definition: kchatbase.h:75
A delegate (see the Qt Model/View module for details) to paint the lines of the KChatBase list model ...
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.