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,
49  const QModelIndex &index) const override;
50 
51  void paint(QPainter *painter,
52  const QStyleOptionViewItem &option,
53  const QModelIndex &index,
54  const QString& sender,
55  const QString& message) const;
56  /**
57  * Reimplementation of the default sizeHint. Computes the given item size
58  * depending on the name and message sizes and on the fonts they use.
59  *
60  * Should be reimplemented in inherited delegates
61  */
62  QSize sizeHint(const QStyleOptionViewItem &option,
63  const QModelIndex &index ) const override;
64 
65  virtual QSize sizeHint(const QStyleOptionViewItem &option,
66  const QModelIndex &index, const QString& sender,
67  const QString& message) const;
68 };
69 
70 #endif
A delegate (see the Qt Model/View module for details) to paint the lines of the KChatBase list model ...
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Dec 7 2021 22:34:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.