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>
15 #include <QSvgRenderer>
22 * A lazy-loading QGraphicsItem to display one track in the playlist.
23 * If a user drags 20000 tracks into the playlist, 20000 GraphicsItem's
24 * will be created. However only the tracks that are visible will query
25 * the model for their information, the rest will take up very little memory
26 * and really aren't associated with a particular track yet.
27 * On a paint operation the GraphicsItem will be "active" by creating an ActiveItems.
28 * Do not add any data members to GraphicsItem, you should be able to add them to
29 * ActiveItems instead.
31 class GraphicsItem
: public QGraphicsItem
38 ///Be sure to read ::paint rules in-method
39 void paint( QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
);
40 QRectF
boundingRect() const;
45 void setRow( int row
);
48 void dragEnterEvent( QGraphicsSceneDragDropEvent
*event
);
49 void dropEvent( QGraphicsSceneDragDropEvent
* event
);
50 void mouseDoubleClickEvent( QGraphicsSceneMouseEvent
* event
);
51 void mousePressEvent( QGraphicsSceneMouseEvent
* event
);
52 void mouseMoveEvent( QGraphicsSceneMouseEvent
* event
);
53 void mouseReleaseEvent ( QGraphicsSceneMouseEvent
* event
);
56 void init( Meta::TrackPtr track
);
57 void resize( Meta::TrackPtr track
, int totalWidth
);
58 QString
findArtistForCurrentAlbum() const;
64 bool m_groupModeChanged
;
66 static const qreal ALBUM_WIDTH
;
67 static const qreal MARGIN
;
68 static QFontMetricsF
* s_fm
;
69 static QSvgRenderer
* s_svgRenderer
;