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
29 * @short The view used to display information in a device popup
32 class NotifierView
: public QTreeView
39 * @param parent the parent of this object
41 NotifierView(QWidget
*parent
= 0);
46 virtual ~NotifierView();
49 * Creates rects in widget coordinates for the model
51 void calculateRects();
55 * Call when the view is resized
56 * @param event the resize event
58 void resizeEvent(QResizeEvent
* event
);
61 * Call when a mouse move event is catch
62 * @param event the mouse event
64 void mouseMoveEvent(QMouseEvent
*event
);
67 * Call when a mouse move event is catch
68 * @param event the mouse event
70 void mousePressEvent(QMouseEvent
*event
);
73 * Call when cursor leave the widget
74 * @param event the leave event
76 void leaveEvent(QEvent
*event
);
79 * Move the cursor in the way describe by cursorAction
80 * @param cursorAction the cursor action
82 QModelIndex
moveCursor(CursorAction cursorAction
,Qt::KeyboardModifiers
);
85 * Call when the view is paint
86 * @param event the paint event
88 void paintEvent(QPaintEvent
*event
);
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
96 void paintHeaderItem(QPainter
&painter
,const QRect
&itemRect
,const QModelIndex
&index
);
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;
122 QPersistentModelIndex m_hoveredIndex
;
123 QHash
<QModelIndex
,QRect
> itemRects
;
127 #endif // NOTIFIERVIEW_H