diff --git a/src/services/lastfm/LastFmService.h b/src/services/lastfm/LastFmService.h index e96a76d8f5..69964e2472 100644 --- a/src/services/lastfm/LastFmService.h +++ b/src/services/lastfm/LastFmService.h @@ -1,113 +1,113 @@ /**************************************************************************************** * Copyright (c) 2007 Shane King * * Copyright (c) 2008 Leo Franchi * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFMSERVICE_H #define LASTFMSERVICE_H #include "services/ServiceBase.h" #include "services/lastfm/LastFmServiceConfig.h" #include "statsyncing/Provider.h" #include namespace Collections { class LastFmServiceCollection; } namespace Dynamic { class AbstractBiasFactory; } class ScrobblerAdapter; class QLineEdit; class QComboBox; class QLabel; class QNetworkReply; class QPixmap; class LastFmServiceFactory : public ServiceFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_lastfm.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: LastFmServiceFactory(); - virtual void init(); - virtual QString name(); - virtual KConfigGroup config(); + void init() override; + QString name() override; + KConfigGroup config() override; - virtual bool possiblyContainsTrack( const QUrl &url ) const; + bool possiblyContainsTrack( const QUrl &url ) const override; }; class LastFmService : public ServiceBase { Q_OBJECT public: LastFmService( LastFmServiceFactory* parent, const QString &name ); virtual ~LastFmService(); - virtual void polish(); + void polish() override; - virtual Collections::Collection * collection(); + Collections::Collection * collection() override; void love( Meta::TrackPtr track ); private Q_SLOTS: void loveCurrentTrack(); void playCustomStation(); void updateEditHint( int index ); void slotReconfigure(); void onAuthenticated(); void onGetUserInfo(); void onAvatarDownloaded( const QString& username, QPixmap avatar ); private: void continueReconfiguring(); void playLastFmStation( const QUrl &url ); void updateProfileInfo(); QSharedPointer m_scrobbler; StatSyncing::ProviderPtr m_synchronizationAdapter; Collections::LastFmServiceCollection *m_collection; QList m_biasFactories; bool m_polished; QWidget *m_profileBox; QLabel *m_avatarLabel; QLabel *m_profile; QLabel *m_userinfo; QComboBox *m_globalComboBox; QLineEdit *m_customStationEdit; QPushButton *m_customStationButton; QComboBox *m_customStationCombo; QString m_station; QString m_age; QString m_gender; QString m_country; QString m_playcount; QPixmap m_avatar; bool m_subscriber; QNetworkReply *m_authenticateReply; LastFmServiceConfigPtr m_config; }; #endif // LASTFMSERVICE_H diff --git a/src/services/lastfm/LastFmServiceCollection.h b/src/services/lastfm/LastFmServiceCollection.h index 3b2bed07fb..50a142328b 100644 --- a/src/services/lastfm/LastFmServiceCollection.h +++ b/src/services/lastfm/LastFmServiceCollection.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2008 Shane King * * Copyright (c) 2008 Leo Franchi * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFMSERVICECOLLECTION_H #define LASTFMSERVICECOLLECTION_H #include "services/ServiceCollection.h" class QNetworkReply; namespace Meta { class ServiceGenre; } namespace Collections { class LastFmServiceCollection : public ServiceCollection { Q_OBJECT public: explicit LastFmServiceCollection( const QString &userName ); virtual ~LastFmServiceCollection(); - virtual bool possiblyContainsTrack( const QUrl &url ) const; - virtual Meta::TrackPtr trackForUrl( const QUrl &url ); + bool possiblyContainsTrack( const QUrl &url ) const override; + Meta::TrackPtr trackForUrl( const QUrl &url ) override; - virtual QString collectionId() const; - virtual QString prettyName() const; + QString collectionId() const override; + QString prettyName() const override; - virtual QueryMaker* queryMaker(); + QueryMaker* queryMaker() override; private Q_SLOTS: void slotAddFriendsLoved(); void slotAddFriendsPersonal(); private: QMap< QString, QNetworkReply* > m_jobs; Meta::ServiceGenre *m_friendsLoved; Meta::ServiceGenre *m_friendsPersonal; }; } //namespace Collections #endif // LASTFMSERVICECOLLECTION_H diff --git a/src/services/lastfm/LastFmServiceSettings.h b/src/services/lastfm/LastFmServiceSettings.h index 3ef6bc6d43..e48c0eede0 100644 --- a/src/services/lastfm/LastFmServiceSettings.h +++ b/src/services/lastfm/LastFmServiceSettings.h @@ -1,68 +1,68 @@ /**************************************************************************************** * Copyright (c) 2007 Shane King * * Copyright (c) 2013 Vedant Agarwala * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFMSERVICESETTINGS_H #define LASTFMSERVICESETTINGS_H #include "LastFmServiceConfig.h" #include "core/meta/forward_declarations.h" // for using the Meta::LabelList #include #include #include namespace Ui { class LastFmConfigWidget; } class LastFmServiceSettings : public KCModule { Q_OBJECT public: explicit LastFmServiceSettings( QWidget *parent = nullptr, const QVariantList &args = QVariantList() ); virtual ~LastFmServiceSettings(); - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; private Q_SLOTS: void testLogin(); void onAuthenticated(); void onError( QNetworkReply::NetworkError code ); void onConfigUpdated(); private: /** * gets the index of the @param label in the QComboBox * If the label doesn't exist in the list, its added and then the index is returned */ int filteredLabelComboIndex( const QString &label ); Ui::LastFmConfigWidget *m_configDialog; LastFmServiceConfigPtr m_config; QNetworkReply* m_authQuery; private Q_SLOTS: void settingsChanged(); void addNewLabels( const Meta::LabelList &labels ); }; #endif // LASTFMSERVICESETTINGS_H diff --git a/src/services/lastfm/LastFmTreeModel.h b/src/services/lastfm/LastFmTreeModel.h index a5d69c41cb..4dcd3c48ab 100644 --- a/src/services/lastfm/LastFmTreeModel.h +++ b/src/services/lastfm/LastFmTreeModel.h @@ -1,160 +1,160 @@ /**************************************************************************************** * Copyright (c) 2009 Casey Link * * Copyright (c) 2009 Nikolaj Hald Nielsen * * Copyright (c) 2009 Mark Kretschmann * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFMTREEMODEL_H #define LASTFMTREEMODEL_H #include "core/meta/forward_declarations.h" #include #include #include #include namespace LastFm { enum Type { Root = 0, MyRecommendations, PersonalRadio, MixRadio, TopArtists, MyTags, Friends, RowCount, MyTagsChild, FriendsChild, ArtistsChild, RecentlyBannedTrack, RecentlyPlayedTrack, RecentlyLovedTrack, HistoryStation, UserChildPersonal, TypeUnknown }; enum Role { StationUrlRole = Qt::UserRole, UrlRole, TrackRole, TypeRole }; enum SortOrder { MostWeightOrder, AscendingOrder, DescendingOrder }; } class LastFmTreeItem; class QUrl; class LastFmTreeModel : public QAbstractItemModel { Q_OBJECT public: explicit LastFmTreeModel( QObject *parent = nullptr ); ~LastFmTreeModel(); - QVariant data( const QModelIndex &index, int role ) const; - Qt::ItemFlags flags( const QModelIndex &index ) const; + QVariant data( const QModelIndex &index, int role ) const override; + Qt::ItemFlags flags( const QModelIndex &index ) const override; QModelIndex index( int row, int column, - const QModelIndex &parent = QModelIndex() ) const; - QModelIndex parent( const QModelIndex &index ) const; + const QModelIndex &parent = QModelIndex() ) const override; + QModelIndex parent( const QModelIndex &index ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const; - int columnCount( const QModelIndex &parent = QModelIndex() ) const; + int columnCount( const QModelIndex &parent = QModelIndex() ) const override; static int avatarSize(); void prepareAvatar( QPixmap& avatar, int size ); - virtual QMimeData *mimeData( const QModelIndexList &indices ) const; + QMimeData *mimeData( const QModelIndexList &indices ) const override; private Q_SLOTS: void onAvatarDownloaded( const QString& username, QPixmap ); void slotAddFriends(); void slotAddTags(); void slotAddTopArtists(); private: void setupModelData( LastFmTreeItem *parent ); QIcon avatar( const QString &username, const QUrl &avatarUrl ) const; QString mapTypeToUrl( LastFm::Type type, const QString &key = "" ); void appendUserStations( LastFmTreeItem* item, const QString& user ); lastfm::User m_user; LastFmTreeItem *m_rootItem; LastFmTreeItem *m_myTags; LastFmTreeItem *m_myFriends; LastFmTreeItem *m_myTopArtists; QHash m_avatars; }; class LastFmTreeItem { public: LastFmTreeItem ( const LastFm::Type &type, const QVariant &data, LastFmTreeItem *parent = nullptr ); LastFmTreeItem ( const QString &url, const LastFm::Type &type, const QVariant &data, LastFmTreeItem *parent = nullptr ); explicit LastFmTreeItem ( const LastFm::Type &type, LastFmTreeItem *parent = nullptr ); LastFmTreeItem ( const QString &url, const LastFm::Type &type, LastFmTreeItem *parent = nullptr ); ~LastFmTreeItem(); void appendChild ( LastFmTreeItem *child ); LastFmTreeItem *child ( int row ); int childCount() const; QVariant data () const; int row() const; LastFmTreeItem *parent(); Meta::TrackPtr track() const; LastFm::Type type() const { return mType; } QUrl avatarUrl() const { return avatar; } void setAvatarUrl( const QUrl &url ) { avatar = url; } private: QList childItems; LastFm::Type mType; LastFmTreeItem *parentItem; QVariant itemData; QString mUrl; QUrl avatar; }; #endif diff --git a/src/services/lastfm/LastFmTreeView.h b/src/services/lastfm/LastFmTreeView.h index f09f007d92..34510d040a 100644 --- a/src/services/lastfm/LastFmTreeView.h +++ b/src/services/lastfm/LastFmTreeView.h @@ -1,76 +1,76 @@ /**************************************************************************************** * Copyright (c) 2009 Casey Link * * Copyright (c) 2005-2007 Christian Muehlhaeuser, Last.fm Ltd * * Copyright (c) 2005-2007 Max Howell, Last.fm Ltd * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFMTREEVIEW_H #define LASTFMTREEVIEW_H #include "playlist/PlaylistController.h" #include "widgets/PrettyTreeView.h" #include #include #include class LastFmTreeModel; class QAction; class QContextMenuEvent; class QMouseEvent; class PopupDropper; typedef QList QActionList; class LastFmTreeView : public Amarok::PrettyTreeView { Q_OBJECT public: explicit LastFmTreeView ( QWidget* parent = nullptr ); ~LastFmTreeView(); Q_SIGNALS: void statusMessage ( const QString& message ); void plsShowRestState(); void plsShowNowPlaying(); private Q_SLOTS: void slotReplacePlaylistByChildTracks(); void slotAppendChildTracks(); protected: - virtual void contextMenuEvent ( QContextMenuEvent* ); - void mouseDoubleClickEvent( QMouseEvent *event ); - void startDrag( Qt::DropActions supportedActions ); + void contextMenuEvent ( QContextMenuEvent* ) override; + void mouseDoubleClickEvent( QMouseEvent *event ) override; + void startDrag( Qt::DropActions supportedActions ) override; private: enum ContextMenuActionType { ExecQMenu, DoQMenuDefaultAction }; void playChildTracks ( const QModelIndex &item, Playlist::AddOptions insertMode ); void playChildTracks ( const QModelIndexList &items, Playlist::AddOptions insertMode ); QActionList createBasicActions( const QModelIndexList &indices ); QTimer* m_timer; LastFmTreeModel* m_model; PopupDropper* m_pd; QAction* m_appendAction; QAction* m_loadAction; QModelIndexList m_currentItems; QMutex m_dragMutex; bool m_ongoingDrag; }; #endif diff --git a/src/services/lastfm/ScrobblerAdapter.h b/src/services/lastfm/ScrobblerAdapter.h index 9d034f1f08..a44397cc83 100644 --- a/src/services/lastfm/ScrobblerAdapter.h +++ b/src/services/lastfm/ScrobblerAdapter.h @@ -1,78 +1,78 @@ /**************************************************************************************** * Copyright (c) 2007 Shane King * * Copyright (c) 2008 Leo Franchi * * Copyright (c) 2013 Vedant Agarwala * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFMSCROBBLERADAPTER_H #define LASTFMSCROBBLERADAPTER_H #include "core/meta/forward_declarations.h" #include "services/lastfm/LastFmServiceConfig.h" #include "statsyncing/ScrobblingService.h" #include #include #include class LastFmServiceConfig; class ScrobblerAdapter : public QObject, public StatSyncing::ScrobblingService { Q_OBJECT public: ScrobblerAdapter( const QString &clientId, const LastFmServiceConfigPtr &config ); virtual ~ScrobblerAdapter(); public: // ScrobblingService methods: - QString prettyName() const; + QString prettyName() const override; ScrobbleError scrobble( const Meta::TrackPtr &track, double playedFraction = 1.0, - const QDateTime &time = QDateTime() ); - void updateNowPlaying( const Meta::TrackPtr &track ); + const QDateTime &time = QDateTime() ) override; + void updateNowPlaying( const Meta::TrackPtr &track ) override; public Q_SLOTS: // own methods void loveTrack( const Meta::TrackPtr &track ); void banTrack( const Meta::TrackPtr &track ); private Q_SLOTS: void slotScrobblesSubmitted( const QList &tracks ); void slotNowPlayingError( int code, const QString &message ); private: /** * Copies metadata from @param from to @param to. */ void copyTrackMetadata( lastfm::MutableTrack& to, const Meta::TrackPtr &from ); /** * Announces Last.fm suggested @param track corrections to Amarok pop-up log. */ void announceTrackCorrections( const lastfm::Track &track ); /** * Checks whether the @param track contains the m_config->skipLabel * Also, returns false if "filterByLabel" is unchecked by user. */ bool isToBeSkipped( const Meta::TrackPtr &track ) const; lastfm::Audioscrobbler m_scrobbler; LastFmServiceConfigPtr m_config; }; #endif // LASTFMSCROBBLERADAPTER_H diff --git a/src/services/lastfm/SynchronizationAdapter.h b/src/services/lastfm/SynchronizationAdapter.h index 5cd1f6180a..61e1acea71 100644 --- a/src/services/lastfm/SynchronizationAdapter.h +++ b/src/services/lastfm/SynchronizationAdapter.h @@ -1,87 +1,87 @@ /**************************************************************************************** * Copyright (c) 2012 Matěj Laitl * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef SYNCHRONIZATIONADAPTER_H #define SYNCHRONIZATIONADAPTER_H #include "services/lastfm/LastFmServiceConfig.h" #include "statsyncing/Provider.h" #include class LastFmServiceConfig; class SynchronizationAdapter : public StatSyncing::Provider { Q_OBJECT public: /** * @param config a pointer to Last.fm config */ explicit SynchronizationAdapter( const LastFmServiceConfigPtr &config ); virtual ~SynchronizationAdapter(); - virtual QString id() const; - virtual QString prettyName() const; - virtual QString description() const; - virtual QIcon icon() const; - virtual qint64 reliableTrackMetaData() const; - virtual qint64 writableTrackStatsData() const; - virtual Preference defaultPreference(); - virtual QSet artists(); - virtual StatSyncing::TrackList artistTracks( const QString &artistName ); + QString id() const override; + QString prettyName() const override; + QString description() const override; + QIcon icon() const override; + qint64 reliableTrackMetaData() const override; + qint64 writableTrackStatsData() const; + Preference defaultPreference() override; + QSet artists() override; + StatSyncing::TrackList artistTracks( const QString &artistName ) override; Q_SIGNALS: /// hacks to create and start Last.fm queries in main eventloop // Last.fm indexes from 1! void startArtistSearch( int page ); void startTrackSearch( QString artistName, int page ); void startTagSearch( QString artistName, QString trackName ); private Q_SLOTS: /// @see startArtistSearch void slotStartArtistSearch( int page ); void slotStartTrackSearch( QString artistName, int page ); void slotStartTagSearch( QString artistName, QString trackName ); void slotArtistsReceived(); void slotTracksReceived(); void slotTagsReceived(); private: LastFmServiceConfigPtr m_config; /** * number of artist or track entries to request from Last.fm in earch webservice * query. Last.fm default is 50; the greater the number, the faster the fetching * (of long lists) is. On the other hand, Last.fm has own limit, 200 works well. */ static const int s_entriesPerQuery; QSet m_artists; StatSyncing::TrackList m_tracks; StatSyncing::TrackList m_tagQueue; // tracks waiting to be assigned tags /** * Semaphore for the simplified producer-consumer pattern, where * slotArtistsReceived() is producer and artist() is consumer, or * slotTracksReceived() is producer and artistTracks() is consumer, or * slotTagsReceived() is producer and artistTracks() is consumer. */ QSemaphore m_semaphore; }; #endif // SYNCHRONIZATIONADAPTER_H diff --git a/src/services/lastfm/SynchronizationTrack.h b/src/services/lastfm/SynchronizationTrack.h index aef7572832..763dea3dd0 100644 --- a/src/services/lastfm/SynchronizationTrack.h +++ b/src/services/lastfm/SynchronizationTrack.h @@ -1,84 +1,84 @@ /**************************************************************************************** * Copyright (c) 2012 Matěj Laitl * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef SYNCHRONIZATIONTRACK_H #define SYNCHRONIZATIONTRACK_H #include "statsyncing/Track.h" #include /** * A class that represents a track in Last.fm users library. Can be used to synchronize * users's data with Last.fm through StatSyncing. */ class SynchronizationTrack : public QObject, public StatSyncing::Track { Q_OBJECT public: /** * Create track used for synchronization with Last.fm. Can only be called from * the main thread. */ SynchronizationTrack( QString artist, QString album, QString name, int playCount, bool useFancyRatingTags ); - virtual QString name() const; - virtual QString album() const; - virtual QString artist() const; - virtual int rating() const; - virtual void setRating( int rating ); - virtual QDateTime firstPlayed() const; - virtual QDateTime lastPlayed() const; - virtual int playCount() const; - virtual QSet labels() const; - virtual void setLabels( const QSet &labels ); - virtual void commit(); + QString name() const override; + QString album() const override; + QString artist() const override; + int rating() const override; + void setRating( int rating ) override; + QDateTime firstPlayed() const override; + QDateTime lastPlayed() const override; + int playCount() const override; + QSet labels() const override; + void setLabels( const QSet &labels ) override; + void commit() override; /** * Set tags from Last.fm, parse them into Amarok labels and rating */ void parseAndSaveLastFmTags( const QSet &tags ); Q_SIGNALS: /// hacks to create and start Last.fm queries in main eventloop void startTagAddition( QStringList tags ); void startTagRemoval(); private Q_SLOTS: void slotStartTagAddition( QStringList tags ); void slotStartTagRemoval(); void slotTagsAdded(); void slotTagRemoved(); private: QString m_artist; QString m_album; QString m_name; int m_rating; int m_newRating; int m_playCount; bool m_useFancyRatingTags; QSet m_labels; QSet m_newLabels; QSet m_ratingLabels; QStringList m_tagsToRemove; QSemaphore m_semaphore; }; #endif // SYNCHRONIZATIONTRACK_H diff --git a/src/services/lastfm/biases/LastFmBias.h b/src/services/lastfm/biases/LastFmBias.h index d4ef8ea75f..f841b9ec45 100644 --- a/src/services/lastfm/biases/LastFmBias.h +++ b/src/services/lastfm/biases/LastFmBias.h @@ -1,119 +1,119 @@ /**************************************************************************************** * Copyright (c) 2009 Leo Franchi * * Copyright (c) 2011 Ralf Engels * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef LASTFM_BIAS_H #define LASTFM_BIAS_H #include "dynamic/biases/TagMatchBias.h" #include namespace Dynamic { /** This is a bias which adds the suggested songs to the playlist. */ class LastFmBias : public SimpleMatchBias { Q_OBJECT public: /** The tracks that are used for the matching */ enum MatchType { SimilarArtist, SimilarTrack }; LastFmBias(); ~LastFmBias(); - virtual void fromXml( QXmlStreamReader *reader ); - virtual void toXml( QXmlStreamWriter *writer ) const; + void fromXml( QXmlStreamReader *reader ) override; + void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); - virtual QString name() const; - virtual QString toString() const; + QString name() const override; + QString toString() const override; - virtual QWidget* widget( QWidget* parent = nullptr ); + QWidget* widget( QWidget* parent = nullptr ) override; virtual Dynamic::TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, Dynamic::TrackCollectionPtr universe ) const; - virtual bool trackMatches( int position, - const Meta::TrackList& playlist, - int contextCount ) const; + bool trackMatches( int position, + const Meta::TrackList& playlist, + int contextCount ) const override; MatchType match() const; void setMatch( MatchType value ); public Q_SLOTS: - virtual void invalidate(); + void invalidate() override; private Q_SLOTS: - virtual void newQuery(); + void newQuery() override; virtual void newSimilarQuery(); void similarArtistQueryDone(); void similarTrackQueryDone(); void queryFailed( const char *message ); void setMatchTypeArtist( bool matchArtist ); private: /** The pair is used for the tracks */ typedef QPair TitleArtistPair; static QString nameForMatch( MatchType match ); static MatchType matchForName( const QString &name ); void saveDataToFile() const; void readSimilarArtists( QXmlStreamReader *reader ); TitleArtistPair readTrack( QXmlStreamReader *reader ); void readSimilarTracks( QXmlStreamReader *reader ); void loadDataFromFile(); mutable QString m_currentArtist; mutable QString m_currentTrack; MatchType m_match; mutable QMutex m_mutex; // mutex protecting all of the below structures mutable QMap< QString, QStringList> m_similarArtistMap; mutable QMap< TitleArtistPair, QList > m_similarTrackMap; mutable QMap< QString, TrackSet> m_tracksMap; // for artist AND album private: Q_DISABLE_COPY(LastFmBias) }; class LastFmBiasFactory : public Dynamic::AbstractBiasFactory { public: - virtual QString i18nName() const; - virtual QString name() const; - virtual QString i18nDescription() const; - virtual BiasPtr createBias(); + QString i18nName() const override; + QString name() const override; + QString i18nDescription() const override; + BiasPtr createBias() override; }; } #endif diff --git a/src/services/lastfm/biases/WeeklyTopBias.h b/src/services/lastfm/biases/WeeklyTopBias.h index da6cce5a5b..6fbc1ae4ba 100644 --- a/src/services/lastfm/biases/WeeklyTopBias.h +++ b/src/services/lastfm/biases/WeeklyTopBias.h @@ -1,103 +1,103 @@ /**************************************************************************************** * Copyright (c) 2009 Leo Franchi * * Copyright (c) 2011 Ralf Engels * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef WEEKLY_TOP_BIAS_H #define WEEKLY_TOP_BIAS_H #include "dynamic/biases/TagMatchBias.h" class QNetworkReply; namespace Dynamic { /** * This is a bias which allows the user to select a range of dates, and then * adds to the playlist tracks/artists/albums that were on their last.fm top * tracks during that time * */ class WeeklyTopBias : public SimpleMatchBias { Q_OBJECT public: struct DateRange { QDateTime from; QDateTime to; }; WeeklyTopBias(); ~WeeklyTopBias(); - virtual void fromXml( QXmlStreamReader *reader ); - virtual void toXml( QXmlStreamWriter *writer ) const; + void fromXml( QXmlStreamReader *reader ) override; + void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); - virtual QString name() const; - virtual QString toString() const; + QString name() const override; + QString toString() const override; - virtual QWidget* widget( QWidget* parent = nullptr ); + QWidget* widget( QWidget* parent = nullptr ) override; - virtual bool trackMatches( int position, - const Meta::TrackList& playlist, - int contextCount ) const; + bool trackMatches( int position, + const Meta::TrackList& playlist, + int contextCount ) const override; DateRange range() const; void setRange( const DateRange &range ); private Q_SLOTS: - virtual void newQuery(); + void newQuery() override; void newWeeklyTimesQuery(); void newWeeklyArtistQuery(); void weeklyTimesQueryFinished(); void weeklyArtistQueryFinished(); void fromDateChanged( const QDateTime& ); void toDateChanged( const QDateTime& ); private: void loadFromFile(); void saveDataToFile() const; DateRange m_range; // be able to warn the user uint m_earliestDate; QList< uint > m_weeklyFromTimes; QList< uint > m_weeklyToTimes; QHash< uint, QStringList > m_weeklyArtistMap; QNetworkReply* m_weeklyTimesJob; QHash< uint, QNetworkReply*> m_weeklyArtistJobs; }; class WeeklyTopBiasFactory : public Dynamic::AbstractBiasFactory { public: - virtual QString i18nName() const; - virtual QString name() const; - virtual QString i18nDescription() const; - virtual BiasPtr createBias(); + QString i18nName() const override; + QString name() const override; + QString i18nDescription() const override; + BiasPtr createBias() override; }; } #endif diff --git a/src/services/lastfm/meta/LastFmMeta.h b/src/services/lastfm/meta/LastFmMeta.h index 4698867f6b..f68ef3aec6 100644 --- a/src/services/lastfm/meta/LastFmMeta.h +++ b/src/services/lastfm/meta/LastFmMeta.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2008 Shane King * * Copyright (c) 2008 Leo Franchi * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef AMAROK_LASTFMMETA_H #define AMAROK_LASTFMMETA_H #include "core/meta/Meta.h" #include "core/capabilities/Capability.h" #include "services/ServiceMetaBase.h" // for the SourceInfoProvider namespace lastfm { class Track; } namespace LastFm { class Track : public QObject, public Meta::Track, public SourceInfoProvider { Q_OBJECT public: class Private; explicit Track( const QString &lastFmUri ); explicit Track( lastfm::Track track ); //Convenience Constructor to allow constructing a Meta::LastFmTrack from a LastFmTrack (confusing?) virtual ~Track(); // methods inherited from Meta::Base - virtual QString name() const; - virtual QString sortableName() const; + QString name() const override; + QString sortableName() const override; // methods inherited from Meta::Track - virtual QUrl playableUrl() const; - virtual QString prettyUrl() const; - virtual QString uidUrl() const; - virtual QString notPlayableReason() const; + QUrl playableUrl() const override; + QString prettyUrl() const override; + QString uidUrl() const override; + QString notPlayableReason() const override; - virtual Meta::AlbumPtr album() const; - virtual Meta::ArtistPtr artist() const; - virtual Meta::GenrePtr genre() const; - virtual Meta::ComposerPtr composer() const; - virtual Meta::YearPtr year() const; + Meta::AlbumPtr album() const override; + Meta::ArtistPtr artist() const override; + Meta::GenrePtr genre() const override; + Meta::ComposerPtr composer() const override; + Meta::YearPtr year() const override; - virtual qreal bpm() const; + qreal bpm() const override; - virtual QString comment() const; + QString comment() const override; - virtual int trackNumber() const; + int trackNumber() const override; - virtual int discNumber() const; + int discNumber() const override; - virtual qint64 length() const; - virtual int filesize() const; - virtual int sampleRate() const; - virtual int bitrate() const; + qint64 length() const override; + int filesize() const override; + int sampleRate() const override; + int bitrate() const override; - virtual QString type() const; + QString type() const override; - virtual bool inCollection() const; - virtual Collections::Collection *collection() const; + bool inCollection() const override; + Collections::Collection *collection() const override; - virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const; - virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ); + bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; + Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; - virtual Meta::StatisticsPtr statistics(); + Meta::StatisticsPtr statistics() override; // own methods: void setTrackInfo( const lastfm::Track &trackInfo ); - virtual QString sourceName(); - virtual QString sourceDescription(); - virtual QPixmap emblem(); - virtual QString scalableEmblem(); + QString sourceName() override; + QString sourceDescription() override; + QPixmap emblem() override; + QString scalableEmblem() override; //LastFm specific methods, cast the object to LastFm::Track to use them //you can cast the Track when type() returns "stream/lastfm" (or use a dynamic cast:) QUrl internalUrl() const; // this returns the private temporary url to the .mp3, DO NOT USE, // if you are asking, it has already expired QString streamName() const; // A nice name for the stream.. public Q_SLOTS: void ban(); private Q_SLOTS: void slotResultReady(); void slotWsReply(); Q_SIGNALS: void skipTrack(); // needed for communication with multiplayablecapability private: void init( int id = -1 ); //use a d-pointer because some code is going to work directly with LastFm::Track Private * const d; QList< QAction * > m_trackActions; }; class LastFmProviderCapability : public Capabilities::Capability { public: LastFmProviderCapability(); ~LastFmProviderCapability(); }; typedef AmarokSharedPointer TrackPtr; } #endif diff --git a/src/services/lastfm/meta/LastFmMeta_p.h b/src/services/lastfm/meta/LastFmMeta_p.h index e0a1fec6a9..98f24a22d2 100644 --- a/src/services/lastfm/meta/LastFmMeta_p.h +++ b/src/services/lastfm/meta/LastFmMeta_p.h @@ -1,376 +1,376 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2008 Leo Franchi * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef AMAROK_LASTFMMETA_P_H #define AMAROK_LASTFMMETA_P_H #include "core/support/Debug.h" #include "amarokconfig.h" #include "core/meta/Meta.h" #include "core/support/Amarok.h" #include "core-impl/support/TagStatisticsStore.h" #include #include #include #include #include #include #include #include #include #include #include namespace LastFm { class Track::Private : public QObject { Q_OBJECT public: Track *t; lastfm::Track lastFmTrack; // this is how we love, ban, etc QUrl trackPath; QUrl lastFmUri; QImage albumArt; QString artist; QString album; QString track; qint64 length; //not sure what these are for but they exist in the LastFmBundle QString albumUrl; QString artistUrl; QString trackUrl; QString imageUrl; Meta::ArtistPtr artistPtr; Meta::AlbumPtr albumPtr; Meta::GenrePtr genrePtr; Meta::ComposerPtr composerPtr; Meta::YearPtr yearPtr; QNetworkReply* trackFetch; QNetworkReply* wsReply; Meta::StatisticsPtr statsStore; uint currentTrackStartTime; public: Private() : lastFmUri( QUrl() ) , currentTrackStartTime( 0 ) { artist = QString ( "Last.fm" ); } ~Private() { } void notifyObservers(); void setTrackInfo( const lastfm::Track &trackInfo ) { DEBUG_BLOCK bool newTrackInfo = artist != trackInfo.artist() || album != trackInfo.album() || track != trackInfo.title(); lastFmTrack = trackInfo; artist = trackInfo.artist(); album = trackInfo.album(); track = trackInfo.title(); length = trackInfo.duration() * 1000; trackPath = trackInfo.url(); // need to reset other items albumUrl = ""; trackUrl = ""; albumArt = QImage(); if( newTrackInfo ) { statsStore = new TagStatisticsStore( t ); currentTrackStartTime = QDateTime::currentDateTime().toTime_t(); } notifyObservers(); if( !trackInfo.isNull() ) { QMap< QString, QString > params; params[ "method" ] = "track.getInfo"; params[ "artist" ] = artist; params[ "track" ] = track; m_userFetch = lastfm::ws::post( params ); connect( m_userFetch, SIGNAL( finished() ), SLOT( requestResult() ) ); } } public Q_SLOTS: void requestResult( ) { if( !m_userFetch ) return; if( m_userFetch->error() == QNetworkReply::NoError ) { lastfm::XmlQuery lfm; if( lfm.parse( m_userFetch->readAll() ) ) { albumUrl = lfm[ "track" ][ "album" ][ "url" ].text(); trackUrl = lfm[ "track" ][ "url" ].text(); artistUrl = lfm[ "track" ][ "artist" ][ "url" ].text(); notifyObservers(); imageUrl = lfm[ "track" ][ "album" ][ "image size=large" ].text(); if( !imageUrl.isEmpty() ) { KIO::Job* job = KIO::storedGet( QUrl( imageUrl ), KIO::Reload, KIO::HideProgressInfo ); connect( job, SIGNAL( result( KJob* ) ), this, SLOT( fetchImageFinished( KJob* ) ) ); } } else { debug() << "Got exception in parsing from last.fm:" << lfm.parseError().message(); return; } } } void fetchImageFinished( KJob* job ) { if( job->error() == 0 ) { const int size = 100; QImage img = QImage::fromData( static_cast( job )->data() ); if( !img.isNull() ) { img.scaled( size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); albumArt = img; } else albumArt = QImage(); } else { //use default image albumArt = QImage(); } notifyObservers(); } private: QNetworkReply* m_userFetch; }; // internal helper classes class LastFmArtist : public Meta::Artist { public: explicit LastFmArtist( Track::Private *dptr ) : Meta::Artist() , d( dptr ) {} - Meta::TrackList tracks() + Meta::TrackList tracks() override { return Meta::TrackList(); } - QString name() const + QString name() const override { if( d ) return d->artist; return QStringLiteral( "Last.fm" ); } Track::Private * const d; friend class Track::Private; }; class LastFmAlbum : public Meta::Album { public: explicit LastFmAlbum( Track::Private *dptr ) : Meta::Album() , d( dptr ) {} - bool isCompilation() const { return false; } - bool hasAlbumArtist() const { return false; } - Meta::ArtistPtr albumArtist() const { return Meta::ArtistPtr(); } + bool isCompilation() const override { return false; } + bool hasAlbumArtist() const override { return false; } + Meta::ArtistPtr albumArtist() const override { return Meta::ArtistPtr(); } - Meta::TrackList tracks() + Meta::TrackList tracks() override { return Meta::TrackList(); } - QString name() const + QString name() const override { if( d ) return d->album; return QString(); } - QImage image( int size ) const + QImage image( int size ) const override { if( !d || d->albumArt.isNull() ) { //return Meta::Album::image( size, withShadow ); //TODO implement shadow //TODO improve this if ( size <= 1 ) size = 100; QString sizeKey = QString::number( size ) + '@'; QImage image; QDir cacheCoverDir = QDir( Amarok::saveLocation( "albumcovers/cache/" ) ); if( cacheCoverDir.exists( sizeKey + "lastfm-default-cover.png" ) ) image = QImage( cacheCoverDir.filePath( sizeKey + "lastfm-default-cover.png" ) ); else { QImage orgImage = QImage( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/lastfm-default-cover.png" ) ); //optimize this! //scaled() does not change the original image but returns a scaled copy image = orgImage.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); image.save( cacheCoverDir.filePath( sizeKey + "lastfm-default-cover.png" ), "PNG" ); } return image; } if( d->albumArt.width() != size && size > 0 ) return d->albumArt.scaled( size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); return d->albumArt; } - QUrl imageLocation( int size ) + QUrl imageLocation( int size ) override { Q_UNUSED( size ); if( d && !d->imageUrl.isEmpty() ) return QUrl( d->imageUrl ); return QUrl(); } // return true since we handle our own fetching - bool hasImage( int size = 1 ) const { Q_UNUSED( size ); return true; } + bool hasImage( int size = 1 ) const override { Q_UNUSED( size ); return true; } Track::Private * const d; friend class Track::Private; }; class LastFmGenre : public Meta::Genre { public: explicit LastFmGenre( Track::Private *dptr ) : Meta::Genre() , d( dptr ) {} - QString name() const + QString name() const override { return QString(); } - Meta::TrackList tracks() + Meta::TrackList tracks() override { return Meta::TrackList(); } Track::Private * const d; friend class Track::Private; }; class LastFmComposer : public Meta::Composer { public: explicit LastFmComposer( Track::Private *dptr ) : Meta::Composer() , d( dptr ) {} - QString name() const + QString name() const override { return QString(); } - Meta::TrackList tracks() + Meta::TrackList tracks() override { return Meta::TrackList(); } Track::Private * const d; friend class Track::Private; }; class LastFmYear : public Meta::Year { public: explicit LastFmYear( Track::Private *dptr ) : Meta::Year() , d( dptr ) {} - QString name() const + QString name() const override { return QString(); } - Meta::TrackList tracks() + Meta::TrackList tracks() override { return Meta::TrackList(); } Track::Private * const d; friend class Track::Private; }; void Track::Private::notifyObservers() { // TODO: only notify what actually has changed t->notifyObservers(); static_cast( t->album().data() )->notifyObservers(); static_cast( t->artist().data() )->notifyObservers(); } } #endif diff --git a/src/services/lastfm/meta/LastFmMultiPlayableCapability.h b/src/services/lastfm/meta/LastFmMultiPlayableCapability.h index 0ebe5a847d..98bf9073c6 100644 --- a/src/services/lastfm/meta/LastFmMultiPlayableCapability.h +++ b/src/services/lastfm/meta/LastFmMultiPlayableCapability.h @@ -1,61 +1,61 @@ /**************************************************************************************** * Copyright (c) 2008 Shane King * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef AMAROK_LASTFM_MULTIPLAYABLECAPABILITY_H #define AMAROK_LASTFM_MULTIPLAYABLECAPABILITY_H #include "core/support/Components.h" #include "core/support/Debug.h" #include "core/logger/Logger.h" #include "MainWindow.h" #include "LastFmMeta.h" #include "core/meta/forward_declarations.h" #include "core/capabilities/MultiPlayableCapability.h" #include #include #include #include #include class LastFmMultiPlayableCapability : public Capabilities::MultiPlayableCapability { Q_OBJECT public: explicit LastFmMultiPlayableCapability( LastFm::Track *track ); virtual ~LastFmMultiPlayableCapability(); // Capabilities::MultiPlayableCapability methods - virtual void fetchFirst(); - virtual void fetchNext(); + void fetchFirst() override; + void fetchNext() override; private Q_SLOTS: void slotTrackPlaying( const Meta::TrackPtr &track ); void slotNewTrackAvailable(); void skip(); void error( lastfm::ws::Error e ); private: QUrl m_url; LastFm::TrackPtr m_track; lastfm::Track m_currentTrack; lastfm::RadioTuner *m_tuner; }; #endif diff --git a/src/services/lastfm/meta/LastFmStreamInfoCapability.h b/src/services/lastfm/meta/LastFmStreamInfoCapability.h index 4120de927f..7358740c7a 100644 --- a/src/services/lastfm/meta/LastFmStreamInfoCapability.h +++ b/src/services/lastfm/meta/LastFmStreamInfoCapability.h @@ -1,41 +1,41 @@ /**************************************************************************************** * Copyright (c) 2008 Dan Meltzer * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef AMAROK_LASTFMSTREAMINFOCAPABILITY_H #define AMAROK_LASTFMSTREAMINFOCAPABILITY_H #include "core/capabilities/StreamInfoCapability.h" namespace LastFm { class Track; } class LastFmStreamInfoCapability : public Capabilities::StreamInfoCapability { Q_OBJECT public: explicit LastFmStreamInfoCapability( LastFm::Track *track ); ~LastFmStreamInfoCapability(); - virtual QString streamName() const; - virtual QString streamSource() const; + QString streamName() const override; + QString streamSource() const override; private: LastFm::Track *m_sourceTrack; }; #endif