playlist.h

来自「Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 」· C头文件 代码 · 共 550 行 · 第 1/2 页

H
550
字号
           if you're queue()ing many items, consider passing true and emitting queueChanged() yourself. */        /* if invertQueue then queueing an already queued song dequeues it */        void queue( QListViewItem*, bool multi = false, bool invertQueue = true );        void saveUndoState();        void setDelayedFilter();                                           //after the delay is over        void showContextMenu( QListViewItem*, const QPoint&, int );        void slotEraseMarker();        void slotGlowTimer();        void reallyEnsureItemCentered();        void slotMouseButtonPressed( int, QListViewItem*, const QPoint&, int );        void slotSingleClick();        void slotContentsMoving();        void slotRepeatTrackToggled( int mode );        void slotQueueChanged( const PLItemList &in, const PLItemList &out);        void slotUseScores( bool use );        void slotUseRatings( bool use );        void slotMoodbarPrefs( bool show, bool moodier, int alter, bool withMusic );        void updateNextPrev();        void writeTag( QListViewItem*, const QString&, int );    private:        Playlist( QWidget* );        Playlist( const Playlist& ); //not defined        LIBAMAROK_EXPORT static Playlist *s_instance;        void countChanged();        PlaylistItem *currentTrack() const { return m_currentTrack; }        PlaylistItem *restoreCurrentTrack();        void insertMediaInternal( const KURL::List&, PlaylistItem*, int options = 0 );        bool isAdvancedQuery( const QString &query );        void refreshNextTracks( int = -1 );        void removeItem( PlaylistItem*, bool = false );        bool saveState( QStringList& );        void setCurrentTrack( PlaylistItem* );        void setCurrentTrackPixmap( int state = -1 );        void showTagDialog( QPtrList<QListViewItem> items );        void sortQueuedItems();        void switchState( QStringList&, QStringList& );        void saveSelectedAsPlaylist();        void initStarPixmaps();        //engine observer functions        void engineNewMetaData( const MetaBundle&, bool );        void engineStateChanged( Engine::State, Engine::State = Engine::Empty );        /// KListView Overloaded functions        void contentsDropEvent     ( QDropEvent* );        void contentsDragEnterEvent( QDragEnterEvent* );        void contentsDragMoveEvent ( QDragMoveEvent* );        void contentsDragLeaveEvent( QDragLeaveEvent* );        #ifdef PURIST //KListView imposes hand cursor so override it        void contentsMouseMoveEvent( QMouseEvent *e ) { QListView::contentsMouseMoveEvent( e ); }        #endif        void customEvent( QCustomEvent* );        bool eventFilter( QObject*, QEvent* );        void paletteChange( const QPalette& );        void rename( QListViewItem*, int );        void setColumnWidth( int, int );        void setSorting( int, bool = true );        void viewportPaintEvent( QPaintEvent* );        void viewportResizeEvent( QResizeEvent* );        void appendToPreviousTracks( PlaylistItem *item );        void appendToPreviousAlbums( PlaylistAlbum *album );        void removeFromPreviousTracks( PlaylistItem *item = 0 );        void removeFromPreviousAlbums( PlaylistAlbum *album = 0 );        typedef QMap<AtomicString, PlaylistAlbum*> AlbumMap;        typedef QMap<AtomicString, AlbumMap> ArtistAlbumMap;        ArtistAlbumMap m_albums;        uint m_startupTime_t; //QDateTime::currentDateTime().toTime_t as of startup        uint m_oldestTime_t; //the createdate of the oldest song in the collection        /// ATTRIBUTES        PlaylistItem  *m_currentTrack;          //the track that is playing        QListViewItem *m_marker;                //track that has the drag/drop marker under it        PlaylistItem  *m_hoveredRating;         //if the mouse is hovering over the rating of an item        //NOTE these container types were carefully chosen        QPtrList<PlaylistAlbum> m_prevAlbums; //the previously played albums in Entire Albums mode        PLItemList m_prevTracks;    //the previous history        PLItemList m_nextTracks;    //the tracks to be played after the current track        QString m_filter;        QString m_prevfilter;        QTimer *m_filtertimer;        PLItemList m_itemsToChangeTagsFor;        bool          m_smartResizing;        int           m_firstColumn;        int           m_totalCount;        int           m_totalLength;        int           m_selCount;        int           m_selLength;        int           m_visCount;        int           m_visLength;        Q_INT64       m_total; //for Favor Tracks        bool          m_itemCountDirty;        KAction      *m_undoButton;        KAction      *m_redoButton;        KAction      *m_clearButton;        QDir          m_undoDir;        QStringList   m_undoList;        QStringList   m_redoList;        uint          m_undoCounter;        DynamicMode  *m_dynamicMode;        KURL::List    m_queueList;        PlaylistItem *m_stopAfterTrack;        int           m_stopAfterMode;        bool          m_showHelp;        bool          m_dynamicDirt;        //So we don't call advanceDynamicTrack() on activate()        bool          m_queueDirt;          //When queuing disabled items, we need to place the marker on the newly inserted item        bool          m_undoDirt;           //Make sure we don't repopulate the playlist when dynamic mode and undo()        int           m_insertFromADT;      //Don't automatically start playing if a user hits Next in dynamic mode when not already playing        static QMutex *s_dynamicADTMutex;        QListViewItem *m_itemToReallyCenter;        QListViewItem *m_renameItem;        int            m_renameColumn;        QTimer        *m_clicktimer;        QListViewItem *m_itemToRename;        QPoint         m_clickPos;        int            m_columnToRename;        QMap<QString, QStringList> m_customSubmenuItem;        QMap<int, QString>         m_customIdItem;        bool isLocked() const { return m_lockStack > 0; }        /// stack counter for PLaylist::lock() and unlock()        int m_lockStack;        QString m_editOldTag; //text before inline editing ( the new tag is written only if it's changed )        std::vector<double> m_columnFraction;        QMap<QString,QPtrList<PlaylistItem>*> m_uniqueMap;        int m_oldRandom;        int m_oldRepeat;        QString m_playlistName;        bool m_proposeOverwriting;        // indexing stuff        // An index of playlist items by some field. The index is backed by AtomicStrings, to avoid        // duplication thread-safely.         template <class FieldType>        class Index : private QMap<AtomicString, QPtrList<PlaylistItem> >        {          public:            // constructors take the PlaylistItem getter to index by            Index( FieldType (PlaylistItem::*getter)( ) const)            : m_getter( getter ), m_useGetter( true ) { };            Index( const FieldType &(PlaylistItem::*refGetter)() const)                : m_refGetter( refGetter ), m_useGetter( false ) { };                    // we specialize this method, below, for KURLs            AtomicString fieldString( const FieldType &field) { return AtomicString( field ); }                        AtomicString keyOf( const PlaylistItem &item) {                return m_useGetter ? fieldString( ( item.*m_getter ) () )                    : fieldString( ( item.*m_refGetter ) () );            }            bool contains( const FieldType &key ) { return contains( fieldString( key ) ); }                        // Just first match, or NULL            PlaylistItem *getFirst( const FieldType &field )  {                Iterator it = find( fieldString( field ) );                return it == end() || it.data().isEmpty() ? 0 : it.data().getFirst();            }            void add( PlaylistItem *item ) {                QPtrList<PlaylistItem> &row = operator[]( keyOf( *item ) );  // adds one if needed                if ( !row.containsRef(item) ) row.append( item );            }            void remove( PlaylistItem *item ) {                Iterator it = find( keyOf( *item ) );                if (it != end()) {                    while ( it.data().removeRef( item ) ) { };                    if ( it.data().isEmpty() ) erase( it );                }            }                                     private:            FieldType (PlaylistItem::*m_getter) () const;            const FieldType &(PlaylistItem::*m_refGetter) () const;            bool m_useGetter;       // because a valid *member can be zero in C++        };            Index<KURL> m_urlIndex;        // TODO: we can convert m_unique to this, to remove some code and for uniformity and thread        //  safety        // TODO: we should just store the url() as AtomicString, it will save headaches (e.g. at least a        //  crash with multicore enabled traces back to KURL refcounting)        //Index<QString> m_uniqueIndex;};class PlaylistAlbum{public:    PLItemList tracks;    int refcount;    Q_INT64 total; //for Favor Tracks    PlaylistAlbum(): refcount( 0 ), total( 0 ) { }};/** * Iterator class that only edits visible items! Preferentially always use * this! Invisible items should not be operated on! To iterate over all * items use MyIt::All as the flags parameter. MyIt::All cannot be OR'd, * sorry. */class PlaylistIterator : public QListViewItemIterator{public:    PlaylistIterator( QListViewItem *item, int flags = 0 )        //QListViewItemIterator is not great and doesn't allow you to see everything if you        //mask both Visible and Invisible :( instead just visible items are returned        : QListViewItemIterator( item, flags == All ? 0 : flags | Visible  )    {}    PlaylistIterator( QListView *view, int flags = 0 )        : QListViewItemIterator( view, flags == All ? 0 : flags | Visible )    {}    //FIXME! Dirty hack for enabled/disabled items.    enum IteratorFlag {        Visible = QListViewItemIterator::Visible,        All = QListViewItemIterator::Invisible    };    inline PlaylistItem *operator*() { return static_cast<PlaylistItem*>( QListViewItemIterator::operator*() ); }    /// @return the next visible PlaylistItem after item    static PlaylistItem *nextVisible( PlaylistItem *item )    {        PlaylistIterator it( item );        return (*it == item) ? *static_cast<PlaylistIterator&>(++it) : *it;    }    static PlaylistItem *prevVisible( PlaylistItem *item )    {        PlaylistIterator it( item );        return (*it == item) ? *static_cast<PlaylistIterator&>(--it) : *it;    }};// Specialization of Index::fieldString for URLstemplate<>inline AtomicString Playlist::Index<KURL>::fieldString( const KURL &url ){    return AtomicString( url.url() );}#endif //AMAROK_PLAYLIST_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?