KDEGames

kchatbaseitemdelegate.h
1 /*
2  This file is part of the KDE games library
3  SPDX-FileCopyrightText: 2007 Gael de Chalendar (aka Kleag) <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-only
6 */
7 
8 #ifndef __KCHATBASEITEMDELEGATE_H__
9 #define __KCHATBASEITEMDELEGATE_H__
10 
11 // own
12 #include "libkdegamesprivate_export.h"
13 // Qt
14 #include <QAbstractItemDelegate>
15 
16 /**
17  * \class KChatBaseItemDelegate kchatbaseitemdelegate.h <KChatBaseItemDelegate>
18  *
19  * A delegate (see the Qt Model/View module for details) to paint the lines of
20  * the KChatBase list model (@ref KChatBaseModel).
21  *
22  * A KChatBaseItemDelegate paints two text items: first the player part then the
23  * text part. This honors KChatBase::addMessage which also uses both.
24  *
25  * Colors and fonts for both parts are set in the corresponding model.
26  */
27 class KDEGAMESPRIVATE_EXPORT KChatBaseItemDelegate : public QAbstractItemDelegate
28 {
29  Q_OBJECT
30 
31 public:
32  /**
33  * Constructs a KChatBaseItemDelegate object
34  */
35  explicit KChatBaseItemDelegate(QObject *parent = nullptr);
36 
37  /**
38  * Destruct a KChatBaseItemDelegate object.
39  */
40  ~KChatBaseItemDelegate() override;
41 
42  /**
43  * Reimplementation of the default paint method. Draws the item at the
44  * given index in the model with good fonts for player name and message.
45  *
46  * Should be reimplemented in inherited delegates
47  */
48  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
49 
50  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const QString &sender, const QString &message) const;
51  /**
52  * Reimplementation of the default sizeHint. Computes the given item size
53  * depending on the name and message sizes and on the fonts they use.
54  *
55  * Should be reimplemented in inherited delegates
56  */
57  QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
58 
59  virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index, const QString &sender, const QString &message) const;
60 };
61 
62 #endif
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const const=0
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const const=0
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 03:47:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.