Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / plasma / applets / kickoff / ui / itemdelegate.h
blob0163744ea8b5293b33eb84b515b9f9a8e6aabb93
1 /*
2 Copyright 2007 Robert Knight <robertknight@gmail.com>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef ITEMDELEGATE_H
21 #define ITEMDELEGATE_H
23 // Qt
24 #include <QtGui/QAbstractItemDelegate>
26 // Local
27 #include "core/models.h"
29 namespace Kickoff
32 /**
33 * Item delegate for rendering items in the Kickoff launcher's views.
35 * The delegate makes use of the various additional Kickoff item data roles
36 * to draw the item. For example, if the DiskFreeSpaceRole and DiskUsedSpaceRole item
37 * data is valid then a bar chart showing the amount of free space available on the disk
38 * will be drawn.
40 class ItemDelegate : public QAbstractItemDelegate , public ItemStateProvider
42 public:
43 ItemDelegate();
44 virtual void paint(QPainter *painter,const QStyleOptionViewItem& option,const QModelIndex& index) const;
45 virtual QSize sizeHint(const QStyleOptionViewItem& option , const QModelIndex& index) const;
47 // reimplemented from ItemStateProvider
48 virtual bool isVisible(const QModelIndex& index) const;
50 // margin is equivalent to ItemDelegate::BACK_ARROW_WIDTH + ItemDelegate::BACK_ARROW_SPACING
51 static const int HEADER_LEFT_MARGIN = 5;
52 static const int HEADER_TOP_MARGIN = 15;
53 static const int HEADER_BOTTOM_MARGIN = 4;
54 static const int HEADER_HEIGHT = 35;
55 static const int FIRST_HEADER_HEIGHT = 20;
57 static const int ICON_TEXT_MARGIN = 10;
58 static const int ICON_SIZE = 32;
60 static const int ITEM_LEFT_MARGIN = 25;
61 static const int ITEM_RIGHT_MARGIN = 7;
62 static const int ITEM_HEIGHT = 32 + 4 /* give some space between icons */;
63 static const int TOP_OFFSET = 5;
65 static const int BACK_ARROW_WIDTH = 20;
66 static const int BACK_ARROW_SPACING = 5;
68 private:
69 QPainterPath roundedRectangle(const QRectF& rect,qreal radius) const;
70 QFont fontForSubTitle(const QFont& titleFont) const;
75 #endif // ITEMDELEGATE_H