KVIrc 5.2.0
Developer APIs
KviTalIconAndRichTextItemDelegate.h
Go to the documentation of this file.
1#ifndef _KVI_TAL_DELEGATES_H_
2#define _KVI_TAL_DELEGATES_H_
3//=============================================================================
4//
5// File : KviTalIconAndRichTextItemDelegate.h
6// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com)
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
33#include "kvi_settings.h"
34
35#include <QListWidget>
36#include <QPixmap>
37#include <QSize>
38#include <QStyledItemDelegate>
39
40class QAbstractItemView;
41
42#define LVI_ICON_SIZE 32
43#define LVI_BORDER 4
44#define LVI_SPACING 8
45#define LVI_MINIMUM_TEXT_WIDTH 300
46
47#define LVI_MINIMUM_CELL_WIDTH (LVI_MINIMUM_TEXT_WIDTH + LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING + LVI_BORDER)
48
53class KVILIB_API KviTalIconAndRichTextItemDelegate : public QStyledItemDelegate
54{
55public:
61 KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget = nullptr);
62
67
68protected:
69 QAbstractItemView * m_pParent;
73
74public:
79 void setMinimumSize(const QSize & s)
80 {
81 m_oMinimumSize = s;
82 }
83
87 void setIconSize(const QSize & s)
88 {
89 m_oIconSize = s;
90 }
91
98 QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const override;
99
107 void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
108
114 void setDefaultIcon(QPixmap * pPix) { m_oDefaultPix = *pPix; };
115 void setDefaultIcon(const QPixmap & oPix) { m_oDefaultPix = oPix; };
116};
117
118#endif // _KVI_TAL_LISTWIDGET_H_
Toolkit Abstraction Layer: itemdelegate class.
Definition KviTalIconAndRichTextItemDelegate.h:54
QAbstractItemView * m_pParent
Definition KviTalIconAndRichTextItemDelegate.h:69
~KviTalIconAndRichTextItemDelegate()
Destroys the icon and rich text item delegate object.
QSize m_oIconSize
Definition KviTalIconAndRichTextItemDelegate.h:72
void setDefaultIcon(const QPixmap &oPix)
Definition KviTalIconAndRichTextItemDelegate.h:115
QSize m_oMinimumSize
Definition KviTalIconAndRichTextItemDelegate.h:71
void setIconSize(const QSize &s)
Set the size of the icons. Should be set in the view constructor.
Definition KviTalIconAndRichTextItemDelegate.h:87
void setDefaultIcon(QPixmap *pPix)
Sets the default icon.
Definition KviTalIconAndRichTextItemDelegate.h:114
void setMinimumSize(const QSize &s)
Set the absolute minimum size of the items. Should be set in the view constructor as QListWidget cach...
Definition KviTalIconAndRichTextItemDelegate.h:79
QPixmap m_oDefaultPix
Definition KviTalIconAndRichTextItemDelegate.h:70
#define s
Definition detector.cpp:84
This file contains compile time settings.
#define KVILIB_API
Definition kvi_settings.h:124