Revert previous commit, was incorrect
[amarok.git] / src / MediaItem.h
blob3cf90ddbcbdb96a7d00867d258df593f5742d550
1 /* Copyright (C) 2005-2007 Jeff Mitchell <kde-dev@emailgoeshere.com>
2 (c) 2004 Christian Muehlhaeuser <chris@chris.de>
3 (c) 2005-2006 Martin Aumueller <aumuell@reserv.at>
4 (c) 2005 Seb Ruiz <ruiz@kde.org>
5 (c) 2006 T.R.Shashwath <trshash84@gmail.com>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
24 #ifndef AMAROK_MEDIAITEM_H
25 #define AMAROK_MEDIAITEM_H
27 #include <QDateTime>
29 #include <k3listview.h>
30 #include <kurl.h>
32 #include "amarok_export.h"
33 #include "Meta.h"
35 class MediaDevice;
36 //class MetaBundle;
38 class AMAROK_EXPORT MediaItem : public K3ListViewItem
40 public:
41 MediaItem( Q3ListView* parent );
42 MediaItem( Q3ListViewItem* parent );
43 MediaItem( Q3ListView* parent, Q3ListViewItem* after );
44 MediaItem( Q3ListViewItem* parent, Q3ListViewItem* after );
45 void init();
46 virtual ~MediaItem();
48 MediaItem *lastChild() const;
50 virtual KUrl url() const;
51 const Meta::DataPtr meta() const;
52 void setMeta( Meta::DataPtr meta );
54 enum Type { UNKNOWN, ARTIST, ALBUM, TRACK, PODCASTSROOT, PODCASTCHANNEL,
55 PODCASTITEM, PLAYLISTSROOT, PLAYLIST, PLAYLISTITEM, INVISIBLEROOT,
56 INVISIBLE, STALEROOT, STALE, ORPHANEDROOT, ORPHANED, DIRECTORY };
58 enum Flags { Failed=1, BeginTransfer=2, StopTransfer=4, Transferring=8, SmartPlaylist=16 };
60 void setType( Type type );
61 void setFailed( bool failed=true );
62 Type type() const { return m_type; }
63 MediaItem *findItem(const QString &key, const MediaItem *after=0) const;
64 const QString &data() const { return m_data; }
65 void setData( const QString &data ) { m_data = data; }
67 virtual bool isLeafItem() const; // A leaf node of the tree
68 virtual bool isFileBacked() const; // Should the file be deleted of the device when removed
69 virtual QDateTime playTime() const { return QDateTime(); }
70 virtual int played() const { return 0; }
71 virtual int recentlyPlayed() const { return 0; } // no of times played on device since last sync
72 virtual void setPlayCount( int ) {}
73 virtual int rating() const { return 0; } // rating on device, normalized to 100
74 virtual void setRating( int /*rating*/ ) {}
75 virtual bool ratingChanged() const { return false; }
76 virtual void setLastPlayed( uint ) {}
77 virtual void syncStatsFromPath( const QString &path );
78 virtual long size() const;
79 virtual MediaDevice *device() const { return m_device; }
80 virtual bool listened() const { return m_listened; }
81 virtual void setListened( bool listened=true ) { m_listened = listened; }
83 int compare( Q3ListViewItem *i, int col, bool ascending ) const;
84 int flags() const { return m_flags; }
85 void createToolTip();
87 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
89 //attributes:
90 int m_order;
91 Type m_type;
92 QString m_playlistName;
93 QString m_data;
94 MediaDevice *m_device;
95 int m_flags;
96 bool m_listened;
98 static QPixmap *s_pixUnknown;
99 static QPixmap *s_pixRootItem;
100 static QPixmap *s_pixFile;
101 static QPixmap *s_pixArtist;
102 static QPixmap *s_pixAlbum;
103 static QPixmap *s_pixPlaylist;
104 static QPixmap *s_pixPodcast;
105 static QPixmap *s_pixTrack;
106 static QPixmap *s_pixInvisible;
107 static QPixmap *s_pixStale;
108 static QPixmap *s_pixOrphaned;
109 static QPixmap *s_pixDirectory;
110 static QPixmap *s_pixTransferFailed;
111 static QPixmap *s_pixTransferBegin;
112 static QPixmap *s_pixTransferEnd;
114 private:
115 mutable Meta::DataPtr m_meta;
118 #endif /*AMAROK_MEDIAITEM_H*/