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