File indexing completed on 2025-01-05 04:25:39

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Seb Ruiz <ruiz@kde.org>                                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef AMAROK_ALBUMITEM_H
0018 #define AMAROK_ALBUMITEM_H
0019 
0020 #include "core/meta/Observer.h"
0021 
0022 #include <QSize>
0023 #include <QObject>
0024 #include <QStandardItem>
0025 
0026 class AlbumItem : public QObject, public QStandardItem, public Meta::Observer
0027 {
0028     Q_OBJECT
0029 
0030     public:
0031         AlbumItem();
0032         ~AlbumItem() override;
0033 
0034         /**
0035          * Sets the AlbumPtr for this item to associate with
0036          *
0037          * @arg album pointer to associate with
0038          */
0039         void setAlbum( const Meta::AlbumPtr &albumPtr );
0040 
0041         /**
0042          * @return the album pointer associated with this item
0043          */
0044         Meta::AlbumPtr album() const { return m_album; }
0045 
0046         /**
0047          * Sets the size of the album art to display
0048          */
0049         void setIconSize( const int iconSize );
0050 
0051         /**
0052          * @return the size of the album art
0053          */
0054         int iconSize() const { return m_iconSize; }
0055 
0056         /**
0057          * Setter to determine whether the item should show the Artist as well as the
0058          * album name. Used for 'recent albums' listing.
0059          */
0060         void setShowArtist( const bool showArtist );
0061 
0062         // overloaded from Meta::Observer
0063         using Observer::metadataChanged;
0064         void metadataChanged( const Meta::AlbumPtr &album ) override;
0065 
0066         int type() const override;
0067 
0068         bool operator<( const QStandardItem &other ) const override;
0069 
0070     private Q_SLOTS:
0071         /** Updates the item after metadataChanged was called.
0072             We need this indirection to get executed by the UI thread.
0073         */
0074         void update();
0075 
0076     private:
0077         Meta::AlbumPtr m_album;
0078         int            m_iconSize;
0079         bool           m_showArtist;
0080 };
0081 
0082 #endif // multiple inclusion guard