File indexing completed on 2025-01-05 04:25:41
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com> * 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_CURRENT_ENGINE 0018 #define AMAROK_CURRENT_ENGINE 0019 0020 #include "core/meta/Meta.h" 0021 0022 #include <QObject> 0023 #include <QPixmap> 0024 #include <QVariant> 0025 0026 0027 namespace Collections { 0028 class QueryMaker; 0029 } 0030 0031 class CurrentEngine : public QObject 0032 { 0033 Q_OBJECT 0034 Q_PROPERTY(QString artist READ artist NOTIFY trackChanged) 0035 Q_PROPERTY(QString track READ track NOTIFY trackChanged) 0036 Q_PROPERTY(QString album READ album NOTIFY trackChanged) 0037 Q_PROPERTY(int rating READ rating WRITE setRating NOTIFY trackChanged) 0038 Q_PROPERTY(int score READ score NOTIFY trackChanged) 0039 Q_PROPERTY(int length READ length NOTIFY trackChanged) 0040 Q_PROPERTY(QString lastPlayed READ lastPlayed NOTIFY trackChanged) 0041 Q_PROPERTY(int timesPlayed READ timesPlayed NOTIFY trackChanged) 0042 Q_PROPERTY(QVariant cover READ cover NOTIFY albumChanged) 0043 Q_PROPERTY(bool hasValidCover READ hasValidCover NOTIFY albumChanged) 0044 0045 public: 0046 explicit CurrentEngine( QObject* parent = nullptr ); 0047 ~CurrentEngine() override; 0048 0049 QString artist() const; 0050 QString track() const; 0051 QString album() const; 0052 int rating() const; 0053 void setRating( int rating ); 0054 int score() const; 0055 int length() const; 0056 QString lastPlayed() const; 0057 int timesPlayed() const; 0058 QVariant cover() const { return QVariant(m_cover); } 0059 bool hasValidCover() const { return !m_cover.isNull(); } 0060 0061 Q_SIGNALS: 0062 void trackChanged(); 0063 void albumChanged(); 0064 void coverWidthChanged(); 0065 0066 private Q_SLOTS: 0067 void slotAlbumMetadataChanged(const Meta::AlbumPtr &album ); 0068 void slotTrackMetadataChanged( Meta::TrackPtr track ); 0069 void slotTrackChanged( const Meta::TrackPtr &track ); 0070 void stopped(); 0071 0072 private: 0073 void update( Meta::TrackPtr track ); 0074 void update( Meta::AlbumPtr album ); 0075 0076 QPixmap m_cover; 0077 Meta::AlbumList m_albums; 0078 Meta::TrackPtr m_currentTrack; 0079 0080 /** The address of the query maker used for the albums query. 0081 This is only used to check if the query results are from the latest started query maker. 0082 */ 0083 Collections::QueryMaker *m_lastQueryMaker; 0084 0085 private Q_SLOTS: 0086 void resultReady( const Meta::AlbumList &albums ); 0087 }; 0088 0089 0090 #endif