Add nice svg graphics to the playlist, based on the work of fapasv ( http://kde-look...
[amarok.git] / src / playlist / PlaylistGraphicsItem.h
blobfeef943fa62aa72a7a80b139d284e93fe1137b5c
1 /***************************************************************************
2 * copyright : (C) 2007 Ian Monroe <ian@monroe.nu> *
3 * *
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
13 #include "meta.h"
14 #include <QGraphicsItem>
15 #include <QSvgRenderer>
17 class QFontMetricsF;
19 namespace Playlist
21 /**
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
33 class ActiveItems;
35 public:
36 GraphicsItem();
37 ~GraphicsItem();
38 ///Be sure to read ::paint rules in-method
39 void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );
40 QRectF boundingRect() const;
41 void setupItem();
42 void refresh();
43 void play();
45 void setRow( int row );
47 protected:
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 );
55 private:
56 void init( Meta::TrackPtr track );
57 void resize( Meta::TrackPtr track, int totalWidth );
58 QString findArtistForCurrentAlbum() const;
60 ActiveItems* m_items;
61 qreal m_height;
62 int m_groupMode;
63 int m_currentRow;
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;
75 #endif