1 /***************************************************************************
2 * copyright : (C) 2007 Ian Monroe <ian@monroe.nu> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License version 2 *
6 * as published by the Free Software Foundation. *
7 ***************************************************************************/
9 #ifndef AMAROK_PLAYLISTGRAPHICSITEM_H
10 #define AMAROK_PLAYLISTGRAPHICSITEM_H
14 #include <QGraphicsItem>
21 * A lazy-loading QGraphicsItem to display one track in the playlist.
22 * If a user drags 20000 tracks into the playlist, 20000 GraphicsItem's
23 * will be created. However only the tracks that are visible will query
24 * the model for their information, the rest will take up very little memory
25 * and really aren't associated with a particular track yet.
26 * On a paint operation the GraphicsItem will be "active" by creating an ActiveItems.
27 * Do not add any data members to GraphicsItem, you should be able to add them to
28 * ActiveItems instead.
30 class GraphicsItem
: public QGraphicsItem
37 ///Be sure to read ::paint rules in-method
38 void paint( QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
);
39 QRectF
boundingRect() const;
41 static qreal
height() { return s_height
; }
46 void dragEnterEvent( QGraphicsSceneDragDropEvent
*event
);
47 void dropEvent( QGraphicsSceneDragDropEvent
* event
);
48 void mouseDoubleClickEvent( QGraphicsSceneMouseEvent
* event
);
49 void mousePressEvent( QGraphicsSceneMouseEvent
* event
);
50 void mouseMoveEvent( QGraphicsSceneMouseEvent
* event
);
51 void mouseReleaseEvent ( QGraphicsSceneMouseEvent
* event
);
54 void init( Meta::TrackPtr track
);
55 void resize( Meta::TrackPtr track
, int totalWidth
);
56 int getRow() const { return int( ( mapToScene( 0.0, 0.0 ).y() ) / s_height
); }
61 static const qreal ALBUM_WIDTH
;
62 static const qreal MARGIN
;
63 static qreal s_height
;
64 static QFontMetricsF
* s_fm
;