• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messagelist

  • sources
  • kde-4.14
  • kdepim
  • messagelist
  • core
themedelegate.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  *******************************************************************************/
20 
21 #ifndef __MESSAGELIST_CORE_THEMEDELEGATE_H__
22 #define __MESSAGELIST_CORE_THEMEDELEGATE_H__
23 
24 #include <QStyledItemDelegate>
25 #include <QRect>
26 #include <QColor>
27 
28 #include <messagelist/core/theme.h>
29 #include <messagelist/core/item.h>
30 
31 class QAbstractItemView;
32 
33 namespace MessageList
34 {
35 
36 namespace Core
37 {
38 
39 class Item;
40 
45 class ThemeDelegate : public QStyledItemDelegate
46 {
47  Q_OBJECT
48 
49 public:
50  explicit ThemeDelegate( QAbstractItemView * parent );
51  ~ThemeDelegate();
52 
53 private:
54  const Theme * mTheme;
55  QAbstractItemView * mItemView;
56 
57  QColor mGroupHeaderBackgroundColor; // cache
58 
59  // hitTest results
60  QModelIndex mHitIndex;
61  Item * mHitItem;
62  QRect mHitItemRect;
63  const Theme::Column * mHitColumn;
64  const Theme::Row * mHitRow;
65  int mHitRowIndex;
66  bool mHitRowIsMessageRow;
67  QRect mHitRowRect;
68  bool mHitContentItemRight;
69  const Theme::ContentItem * mHitContentItem;
70  QRect mHitContentItemRect;
71 
72 public:
73  const Theme * theme() const
74  { return mTheme; }
75  void setTheme( const Theme * theme );
76 
81  QSize sizeHintForItemTypeAndColumn( Item::Type type, int column, const Item *item = 0) const;
82 
93  bool hitTest( const QPoint &viewportPoint, bool exact = true );
94 
100  const QModelIndex & hitIndex() const
101  { return mHitIndex; }
102 
108  Item * hitItem() const
109  { return mHitItem; }
110 
117  QRect hitItemRect() const
118  { return mHitItemRect; }
119 
125  const Theme::Column * hitColumn() const
126  { return mHitColumn; }
127 
134  int hitColumnIndex() const
135  { return mHitIndex.column(); }
136 
144  const Theme::Row * hitRow() const
145  { return mHitRow; }
146 
151  int hitRowIndex() const
152  { return mHitRowIndex; }
153 
160  QRect hitRowRect() const
161  { return mHitRowRect; }
162 
167  bool hitRowIsMessageRow() const
168  { return mHitRowIsMessageRow; }
169 
177  const Theme::ContentItem * hitContentItem() const
178  { return mHitContentItem; }
179 
184  bool hitContentItemRight() const
185  { return mHitContentItemRight; }
186 
193  QRect hitContentItemRect() const
194  { return mHitContentItemRect; }
195 
197  static QFont itemFont( const Theme::ContentItem *ci, const Item *item );
198 
200  static QString itemFontKey( const Theme::ContentItem *ci, const Item *item );
201 
202 protected:
207  virtual Item * itemFromIndex( const QModelIndex &index ) const = 0;
208 
212  void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
213 
217  QSize sizeHint( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
218 
219 private slots:
223  void slotGeneralFontChanged();
224 };
225 
226 } // namespace Core
227 
228 } // namespace MessageList
229 
230 #endif
MessageList::Core::Theme::ContentItem
The ContentItem class defines a content item inside a Row.
Definition: theme.h:73
QModelIndex
MessageList::Core::ThemeDelegate::~ThemeDelegate
~ThemeDelegate()
Definition: themedelegate.cpp:58
MessageList::Core::ThemeDelegate::itemFont
static QFont itemFont(const Theme::ContentItem *ci, const Item *item)
return the font to paint given item with, checking global kmail settings and theme settings ...
Definition: themedelegate.cpp:1662
MessageList::Core::Item::Type
Type
The type of the Item.
Definition: item.h:61
QAbstractItemView
MessageList::Core::ThemeDelegate::ThemeDelegate
ThemeDelegate(QAbstractItemView *parent)
Definition: themedelegate.cpp:50
MessageList::Core::ThemeDelegate::hitRowRect
QRect hitRowRect() const
Returns the rectangle of the row that was reported as hit by the previous call to hitTest()...
Definition: themedelegate.h:160
QFont
MessageList::Core::Theme::Row
The Row class defines a row of items inside a Column.
Definition: theme.h:466
MessageList::Core::ThemeDelegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Reimplemented from QStyledItemDelegate.
Definition: themedelegate.cpp:1645
theme.h
QPoint
MessageList::Core::Theme::Column
The Column class defines a view column available inside this theme.
Definition: theme.h:565
MessageList::Core::ThemeDelegate::itemFontKey
static QString itemFontKey(const Theme::ContentItem *ci, const Item *item)
return the font key to paint given item with, checking global kmail settings and theme settings ...
Definition: themedelegate.cpp:1683
QRect
MessageList::Core::ThemeDelegate::paint
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Reimplemented from QStyledItemDelegate.
Definition: themedelegate.cpp:550
QStyleOptionViewItem
MessageList::Core::ThemeDelegate::hitItem
Item * hitItem() const
Returns the Item that was reported as hit by the previous call to hitTest().
Definition: themedelegate.h:108
QPainter
MessageList::Core::ThemeDelegate::hitColumn
const Theme::Column * hitColumn() const
Returns the theme column that was reported as hit by the previous call to hitTest().
Definition: themedelegate.h:125
MessageList::Core::ThemeDelegate::hitIndex
const QModelIndex & hitIndex() const
Returns the model index that was reported as hit by the previous call to hitTest().
Definition: themedelegate.h:100
QString
QColor
MessageList::Core::ThemeDelegate::hitColumnIndex
int hitColumnIndex() const
Returns the index of the theme column that was reported as hit by the previous call to hitTest()...
Definition: themedelegate.h:134
MessageList::Core::ThemeDelegate::hitRowIndex
int hitRowIndex() const
Returns the index of the theme row that was reported as hit by the previous call to hitTest()...
Definition: themedelegate.h:151
MessageList::Core::ThemeDelegate::hitRow
const Theme::Row * hitRow() const
Returns the theme row that was reported as hit by the previous call to hitTest(). ...
Definition: themedelegate.h:144
QSize
MessageList::Core::ThemeDelegate::hitContentItemRect
QRect hitContentItemRect() const
Returns the bounding rect of the content item that was reported as hit by the previous call to hitTes...
Definition: themedelegate.h:193
MessageList::Core::Item
A single item of the MessageList tree managed by MessageList::Model.
Definition: item.h:52
item.h
MessageList::Core::ThemeDelegate::hitContentItemRight
bool hitContentItemRight() const
Returns true if the hit theme content item was a right item and false otherwise.
Definition: themedelegate.h:184
MessageList::Core::ThemeDelegate::hitTest
bool hitTest(const QPoint &viewportPoint, bool exact=true)
Performs a hit test on the specified viewport point.
Definition: themedelegate.cpp:1173
MessageList::Core::ThemeDelegate::itemFromIndex
virtual Item * itemFromIndex(const QModelIndex &index) const =0
Returns the Item for the specified model index.
MessageList::Core::ThemeDelegate::theme
const Theme * theme() const
Definition: themedelegate.h:73
MessageList::Core::ThemeDelegate::hitContentItem
const Theme::ContentItem * hitContentItem() const
Returns the theme content item that was reported as hit by the previous call to hitTest().
Definition: themedelegate.h:177
QModelIndex::column
int column() const
MessageList::Core::ThemeDelegate::setTheme
void setTheme(const Theme *theme)
Definition: themedelegate.cpp:62
MessageList::Core::Theme
The Theme class defines the visual appearance of the MessageList.
Definition: theme.h:65
MessageList::Core::ThemeDelegate
The ThemeDelegate paints the message list view message and group items by using the supplied Theme...
Definition: themedelegate.h:45
MessageList::Core::ThemeDelegate::hitItemRect
QRect hitItemRect() const
Returns the visual rectangle of the item that was reported as hit by the previous call to hitTest()...
Definition: themedelegate.h:117
MessageList::Core::ThemeDelegate::hitRowIsMessageRow
bool hitRowIsMessageRow() const
Returns true if the hitRow() is a message row, false otherwise.
Definition: themedelegate.h:167
QObject::parent
QObject * parent() const
MessageList::Core::ThemeDelegate::sizeHintForItemTypeAndColumn
QSize sizeHintForItemTypeAndColumn(Item::Type type, int column, const Item *item=0) const
Returns a heuristic sizeHint() for the specified item type and column.
Definition: themedelegate.cpp:1592
QStyledItemDelegate
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messagelist

Skip menu "messagelist"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal