add more spacing
[personal-kdebase.git] / workspace / plasma / applets / devicenotifier / notifierview.h
blob45df30b2e94d015e743bf824a5e1b5ede613b55f
1 /* Copyright 2007 by Alexis Ménard <darktears31@gmail.com>
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
18 #ifndef NOTIFIERVIEW_H
19 #define NOTIFIERVIEW_H
21 // Qt
22 #include <QTreeView>
24 class QModelIndex;
26 namespace Notifier
28 /**
29 * @short The view used to display information in a device popup
32 class NotifierView : public QTreeView
34 Q_OBJECT
36 public:
37 /**
38 * Constructor of view
39 * @param parent the parent of this object
40 **/
41 NotifierView(QWidget *parent = 0);
43 /**
44 * Default destructor
45 **/
46 virtual ~NotifierView();
48 /**
49 * Creates rects in widget coordinates for the model
51 void calculateRects();
53 protected:
54 /**
55 * Call when the view is resized
56 * @param event the resize event
57 **/
58 void resizeEvent(QResizeEvent * event);
60 /**
61 * Call when a mouse move event is catch
62 * @param event the mouse event
63 **/
64 void mouseMoveEvent(QMouseEvent *event);
66 /**
67 * Call when a mouse move event is catch
68 * @param event the mouse event
69 **/
70 void mousePressEvent(QMouseEvent *event);
72 /**
73 * Call when cursor leave the widget
74 * @param event the leave event
75 **/
76 void leaveEvent(QEvent *event);
78 /**
79 * Move the cursor in the way describe by cursorAction
80 * @param cursorAction the cursor action
81 **/
82 QModelIndex moveCursor(CursorAction cursorAction,Qt::KeyboardModifiers );
84 /**
85 * Call when the view is paint
86 * @param event the paint event
87 **/
88 void paintEvent(QPaintEvent *event);
90 /**
91 * Paint a header item
92 * @param painter the painter used to paint
93 * @param itemRect the rect where the item will be paint
94 * @param index the QModelIndex that represent the item to paint
95 **/
96 void paintHeaderItem(QPainter &painter,const QRect &itemRect,const QModelIndex &index);
98 /**
99 * Paint an item in the view by using the delegate
100 * @param painter the painter used to paint
101 * @param itemRect the rect where the item will be paint
102 * @param index the QModelIndex that represent the item to paint
104 void paintItem(QPainter &painter,const QRect &itemRect,const QModelIndex &index);
107 * Return an index at the position "point" if exist otherwise return a default
108 * constructed value of QModelIndex
109 * @param point the point where we will looking for an item
111 QModelIndex indexAt(const QPoint& point) const;
113 static const int HEADER_LEFT_MARGIN = 5;
114 static const int HEADER_TOP_MARGIN = 5;
115 static const int HEADER_HEIGHT = 35;
116 static const int COLUMN_EJECT_MARGIN = 5;
117 static const int COLUMN_EJECT_SIZE = 50;
118 static const int TOP_OFFSET = 5;
120 private:
121 ///The hovered index
122 QPersistentModelIndex m_hoveredIndex;
123 QHash<QModelIndex,QRect> itemRects;
127 #endif // NOTIFIERVIEW_H