You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
5.9 KiB

//Maintainer: Max Howell <>
//Copyright: GPL v2
//NOTE please show restraint when adding data members to this class!
// some users have playlists with 20,000 items or more in, one 32 bit int adds up rapidly!
// -- on second thought, 80KB isn't all that much. be careful with TQStrings, though.
#include "metabundle.h" //baseclass
#include "amarok_export.h"
#include <klistview.h> //baseclass
#include <kurl.h> //stack allocated
#include <tqcolor.h> //stack allocated
#include <tqfont.h> //stack allocated
#include <tqmap.h>
#include <tqpixmap.h>
#include <tqvaluevector.h>
class TQColorGroup;
class TQDomNode;
class TQImage;
class TQListViewItem;
class TQPainter;
class MetaBundle;
class Playlist;
class PlaylistAlbum;
class LIBAMAROK_EXPORT PlaylistItem : public MetaBundle, public KListViewItem
typedef MetaBundle super;
/// Indicates that the current-track pixmap has changed. Animation must be redrawn.
static void setPixmapChanged() { s_pixmapChanged = true; }
/// For the glow colouration stuff
static double glowIntensity;
static TQColor glowText;
static TQColor glowBase;
PlaylistItem( TQListView*, TQListViewItem* ); //used by PlaylistLoader
PlaylistItem( const MetaBundle&, TQListViewItem*, bool enabled = true );
/// pass 'raw' data here, for example "92" for Length, and not "1:32"
virtual void setText( int column, const TQString& );
* @return The text of the column @p column, formatted for display purposes.
* (For example, if the Length is 92, "1:32".)
virtual TQString text( int column ) const;
void filter( const TQString &expression ); //makes visible depending on whether it matches
bool isCurrent() const;
bool isQueued() const;
int queuePosition() const;
bool isEnabled() const { return m_enabled; }
bool isDynamicEnabled() const { return m_dynamicEnabled; }
bool isFilestatusEnabled() const { return m_filestatusEnabled; }
void setEnabled();
void setDynamicEnabled( bool enabled );
void setFilestatusEnabled( bool enabled );
void setAllCriteriaEnabled( bool enabled );
void setSelected( bool selected );
void setVisible( bool visible );
void setEditing( int column );
bool isEditing( int column ) const;
bool anyEditing() const;
void setIsBeingRenamed( bool renaming ) { m_isBeingRenamed = renaming; }
bool isBeingRenamed() const { return m_isBeingRenamed; }
void setDeleteAfterEditing( bool dae ) { m_deleteAfterEdit = dae; }
bool deleteAfterEditing() const { return m_deleteAfterEdit; }
void setIsNew( bool is ) { m_isNew = is; }
/// convenience functions
Playlist *listView() const { return reinterpret_cast<Playlist*>( KListViewItem::listView() ); }
PlaylistItem *nextSibling() const { return static_cast<PlaylistItem*>( KListViewItem::nextSibling() ); }
static int ratingAtPoint( int x );
static int ratingColumnWidth();
/// like TQWidget::update()
void update() const;
//updates only the area of a specific column, avoids flickering of the current item marker
void updateColumn( int column ) const;
virtual void setup(); // from TQListViewItem
virtual bool operator== ( const PlaylistItem & item ) const;
virtual bool operator< ( const PlaylistItem & item ) const;
PlaylistItem *nextInAlbum() const;
PlaylistItem *prevInAlbum() const;
virtual void aboutToChange( const TQValueList<int> &columns );
virtual void reactToChanges( const TQValueList<int> &columns );
friend class Playlist;
struct paintCacheItem {
int width;
int height;
TQString text;
TQFont font;
TQColor color;
bool selected;
TQMap<TQString, TQPixmap> map;
virtual void paintCell( TQPainter*, const TQColorGroup&, int, int, int );
void drawRating( TQPainter *p );
void drawRating( TQPainter *p, int stars, int greystars, bool half );
void drawMood( TQPainter *p, int width, int height );
virtual void moodbarJobEvent( int newState );
// Used for sorting
virtual int compare( TQListViewItem*, int, bool ) const;
* Paints a focus indicator on the rectangle (current item). We disable it
* over the currentTrack, cause it would look like crap and flicker.
void paintFocus( TQPainter*, const TQColorGroup&, const TQRect& );
static void imageTransparency( TQImage& image, float factor );
AtomicString artist_album() const; // returns a placeholder 'artist' for compilations
void refAlbum();
void derefAlbum();
void decrementTotals();
void incrementTotals();
void incrementCounts();
void decrementCounts();
void incrementLengths();
void decrementLengths();
int totalIncrementAmount() const;
PlaylistAlbum *m_album;
bool m_enabled;
bool m_dynamicEnabled;
bool m_filestatusEnabled;
bool m_deleteAfterEdit;
bool m_isBeingRenamed;
bool m_isNew; //New items will be assigned a different color
static bool s_pixmapChanged;
static const TQString &editingText();
class PLItemList: public TQPtrList<PlaylistItem>
PLItemList() : TQPtrList<PlaylistItem>() { }
PLItemList( const TQPtrList<PlaylistItem> &list ) : TQPtrList<PlaylistItem>( list ) { }
PLItemList( PlaylistItem *item ) : TQPtrList<PlaylistItem>() { append( item ); }
inline PLItemList &operator<<( PlaylistItem *item ) { append( item ); return *this; }