File indexing completed on 2024-05-19 04:50:17
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz> * 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 SYNCHRONIZATIONTRACK_H 0018 #define SYNCHRONIZATIONTRACK_H 0019 0020 #include "statsyncing/Track.h" 0021 0022 #include <QSemaphore> 0023 0024 /** 0025 * A class that represents a track in Last.fm users library. Can be used to synchronize 0026 * users's data with Last.fm through StatSyncing. 0027 */ 0028 class SynchronizationTrack : public QObject, public StatSyncing::Track 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 /** 0034 * Create track used for synchronization with Last.fm. Can only be called from 0035 * the main thread. 0036 */ 0037 SynchronizationTrack( QString artist, QString album, QString name, int playCount, bool useFancyRatingTags ); 0038 0039 QString name() const override; 0040 QString album() const override; 0041 QString artist() const override; 0042 int rating() const override; 0043 void setRating( int rating ) override; 0044 QDateTime firstPlayed() const override; 0045 QDateTime lastPlayed() const override; 0046 int playCount() const override; 0047 QSet<QString> labels() const override; 0048 void setLabels( const QSet<QString> &labels ) override; 0049 void commit() override; 0050 0051 /** 0052 * Set tags from Last.fm, parse them into Amarok labels and rating 0053 */ 0054 void parseAndSaveLastFmTags( const QSet<QString> &tags ); 0055 0056 Q_SIGNALS: 0057 /// hacks to create and start Last.fm queries in main eventloop 0058 void startTagAddition( QStringList tags ); 0059 void startTagRemoval(); 0060 0061 private Q_SLOTS: 0062 void slotStartTagAddition( QStringList tags ); 0063 void slotStartTagRemoval(); 0064 0065 void slotTagsAdded(); 0066 void slotTagRemoved(); 0067 0068 private: 0069 QString m_artist; 0070 QString m_album; 0071 QString m_name; 0072 int m_rating; 0073 int m_newRating; 0074 int m_playCount; 0075 bool m_useFancyRatingTags; 0076 QSet<QString> m_labels; 0077 QSet<QString> m_newLabels; 0078 QSet<QString> m_ratingLabels; 0079 0080 QStringList m_tagsToRemove; 0081 QSemaphore m_semaphore; 0082 }; 0083 0084 #endif // SYNCHRONIZATIONTRACK_H