diff --git a/src/EngineController.h b/src/EngineController.h index 1a0b20cc0d..14fb6e78ab 100644 --- a/src/EngineController.h +++ b/src/EngineController.h @@ -1,584 +1,584 @@ /**************************************************************************************** * Copyright (c) 2004 Frederik Holljen * * Copyright (c) 2004,2005 Max Howell * * Copyright (c) 2004-2013 Mark Kretschmann * * Copyright (c) 2008 Jason A. Donenfeld * * Copyright (c) 2009 Artur Szymiec * * * * 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_ENGINECONTROLLER_H #define AMAROK_ENGINECONTROLLER_H #include "amarok_export.h" #include "core/capabilities/BoundedPlaybackCapability.h" #include "core/meta/Observer.h" #include "playback/EqualizerController.h" #include "core/meta/Meta.h" #include #include #include #include #include #include #include #include #include #include #include #include class Fadeouter; namespace Capabilities { class MultiPlayableCapability; class MultiSourceCapability; } namespace Phonon { class AudioOutput; class MediaSource; class VolumeFaderEffect; } class QTimer; /** * A thin wrapper around Phonon that implements Amarok-specific functionality like * replay gain, fade-out on stop and various track capabilities that affect * playback. */ class AMAROK_EXPORT EngineController : public QObject, public Meta::Observer { Q_OBJECT public: static const uint DATAOUTPUT_DATA_SIZE = 512; /** * Construct EngineController. Must be called from the main thread. */ EngineController(); - ~EngineController(); + ~EngineController() override; /** * Returns the global EngineController instance */ static EngineController* instance(); /** * Loads and plays the track that was playing when endSession() was last * called (ie: when Amarok was quit) */ void restoreSession(); /** * Saves the currently playing track and the playing/paused/stopped state */ void endSession(); /** * Returns a list of backend supported mime types. This method is thread-safe. */ QStringList supportedMimeTypes(); /** @return track position (elapsed time) in seconds */ int trackPosition() const; /** @return track position (elapsed time) in milliseconds */ qint64 trackPositionMs() const; /** * Returns the current track that is loaded into the engine. * @return a Meta::TrackPtr which is either the track, or empty if phonon * has a state of Phonon::ErrorState or Phonon::StoppedState */ Meta::TrackPtr currentTrack() const; /** * @return the length of the current track in milliseconds */ qint64 trackLength() const; /** * Used to enqueue a track before it starts to play, for gapless playback. * * This will clear any tracks currently in the queue. If no track is playing, * @p track will be played immediately. */ void setNextTrack( Meta::TrackPtr track ); /** * Gets the volume * @return the volume as a percentage */ int volume() const; /** * @return @c true if sound output is disabled, @c false otherwise */ bool isMuted() const; /** * @return @c true if Amarok is paused, @c false if it is stopped or playing */ bool isPaused() const; /** * @return @c true if Amarok is playing, @c false if it is stopped or pause * Note: A fading out track is considered already stopped. */ bool isPlaying() const; /** * @return @c true if Amarok is stopped, @c false if it is playing or pause * Note: A fading out track is considered already stopped. */ bool isStopped() const; /** * Streams sometimes have to be treated specially. * For example, it is typically not possible to rewind a stream (at least, * not without returning to the start of it). * However for rewinding we have isSeekable(). * Also for streams usually the meta data received by currentTrack() is only * for the whole stream while the meta data received by currentMetaDataChanged * will be more current (or contain advertisement) * * @return @c true if the current track is a stream, @c false otherwise */ bool isStream(); /** * @return @c true if the current track is seekable, @c false otherwise */ bool isSeekable() const; /** * Returns the associated EqualizerController object. */ EqualizerController *equalizerController() const; /** * @return QString with a pretty name for the current track * @param progress whether to include the playing progress (default false) */ QString prettyNowPlaying( bool progress = false ) const; public Q_SLOTS: /** * Plays the current track, if there is one * This happens asynchronously. */ void play(); /** * Plays the specified track * This happens asynchronously. */ void play( Meta::TrackPtr track, uint offset = 0, bool startPaused = false ); /** * Replays the current track * * This is a convenience method, calls seek( 0 ) actually */ void replay(); /** * Pauses the current track * This happens asynchronously. */ void pause(); /** * Stops playing * This happens asynchronously. * * @param forceInstant skip any fade-out effects * @param playingWillContinue don't Q_EMIT stopped() or trackChanged( 0 ) signals */ void stop( bool forceInstant = false, bool playingWillContinue = false ); /** * Stops playing * This happens asynchronously. * Doesn't skip any fade-out effects * Emits stopped() and trackChanged( 0 ) signals */ void regularStop(); /** * Pauses if Amarok is currently playing, plays if Amarok is stopped or paused * This happens asynchronously. */ void playPause(); //pauses if playing, plays if paused or stopped /** * Seeks to a position in the track * * If the media is not seekable, or the state is something other than * PlayingState, BufferingState or PausedState, has no effect. * * Deals correctly with tracks that have the BoundedPlayback capability. * * @param ms the position in milliseconds (counting from the start of the track) */ void seekTo( int ms ); /** * Seeks forward or backward in the track * * If the media is not seekable, or the state is something other than * PlayingState, BufferingState or PausedState, has no effect. * * Deals correctly with tracks that have the BoundedPlayback capability. * * A negative value seeks backwards, a positive value seeks forwards. * * If the value of @p ms would move the position to before the start of the track, * the position is moved to the start of the track. * * @param ms the offset from the current position in milliseconds */ void seekBy( int ms ); /** * Increases the volume * * @param ticks the amount to increase the volume by, given as a percentage of the * maximum possible volume (ie: the same units as for setVolume()). */ int increaseVolume( int ticks = 100/25 ); /** * Decreases the volume * * @param ticks the amount to decrease the volume by, given as a percentage of the * maximum possible volume (ie: the same units as for setVolume()). */ int decreaseVolume( int ticks = 100/25 ); /** * Sets the volume * * @param percent the new volume as a percentage of the maximum possible volume. */ // this amplifier does not go up to 11 int setVolume( int percent ); /** * Mutes or unmutes playback * * @param mute if @c true, audio output will be disabled; if @c false, audio output * will be enabled. */ void setMuted( bool mute ); /** * Toggles mute * * Works like setMuted( !isMuted() ); */ void toggleMute(); /** * Return true if current Phonon back-end supports fade-out. */ bool supportsFadeout() const; /** * Return true if current Phonon back-end supports our implementation of * Replay Gain adjustment. */ bool supportsGainAdjustments() const; /** * Return true if the current Phonon backend supports visualizations. */ bool supportsAudioDataOutput() const; Q_SIGNALS: /** * Emitted when the playback stops while playing a track. * This signal is not emitted when the track pauses or the playback stops because * Amarok was closed and "resume at start" is configured. * It is also not emitted if the playback continues with another track. In such * a case you would just get another trackPlaying signal. * Both parameters are in milliseconds. */ void stopped( qint64 /*ms*/ finalPosition, qint64 /*ms*/ trackLength ); /** * Called when the playback is paused. * When the playback is resumed a trackPlaying signal will be emitted. * When the playback is stopped then a stopped signal will be emitted. */ void paused(); /** While trying to play the track an error occurred. * This usually means that the engine will try to play the next track in * the playlist until it gives up. * So you will get a trackPlaying or stopped signal next. */ void trackError( Meta::TrackPtr track ); /** * Called when a new track starts playing or an old track starts playing now. * * It also might be called several time in sequence * with the same track in cases when e.g. you have * a multi source track. * * Unlike trackChanged(), this is not called when playback stops. */ void trackPlaying( Meta::TrackPtr track ); /** * Called when the current track changes * * Note that this is possibly only called once in case of a stream or on * the other hand multiple times with the same track in cases when e.g. you have * a multi source track. * * Unlike trackPlaying(), this is called when playback stops with Meta::TrackPtr( 0 ) for @p track. * * @param track The new track; may be null */ void trackChanged( Meta::TrackPtr track ); /** * Emitted when the metadata of the current track changes. * * You might want to connect also to trackChanged() or trackPlaying() to get more * changes because this signal is only emitted when the track metadata changes * while it's playing, not when new track starts playing. This method now works * correctly also for streams and is preferred to currentMetaDataChanged() because * it providers somehow more filtered values. */ void trackMetadataChanged( Meta::TrackPtr track ); /** Emitted when the metadata of the current album changes. */ void albumMetadataChanged( Meta::AlbumPtr album ); /** * Emitted then the information for the current changed. * This signal contains data from Phonon about the meta data of the track or stream. * This signal is especially emitted when a stream changes it's metadata. * This can happen e.g. in a ogg stream where the currentTrack data will probably * not be updated. * * MetaStream::Track::Private in Stream_p.h will connect to this signal to update it's internal data * and then itself trigger a trackMetadataChanged. * @param metadata Contains the url, artist, album title, title, genre, tracknumber and length */ void currentMetadataChanged( QVariantMap metadata ); /** * Called when the seekable value was changed */ void seekableChanged( bool seekable ); /** * Called when the volume was changed */ void volumeChanged( int percent ); /** * Called when audio output was enabled or disabled * * NB: if setMute() was called on the engine controller, but it didn't change the * mute state, this will not be called */ void muteStateChanged( bool mute ); /** Called when the track position changes. If the track just progresses you will get a notification every couple of milliseconds. @param position The current position in milliseconds @param userSeek True if the position change was caused by the user */ void trackPositionChanged( qint64 position, bool userSeek ); /** * Emitted when a track finished playing. You generally get this signal once per * played track, but in case of a stream this may be emitted more than once when * stream meta-data changes (which usually indicates that the next track started * playing) - meta-data in the track are updated in this case. When you receive * this signal, track score, play count etc. will be already updated. * * @param track track that has just finished playing * @param playedFraction played/total length fraction, between 0 and 1 */ void trackFinishedPlaying( Meta::TrackPtr track, double playedFraction ); /** Called when the track length changes, typically because the track has changed but also when phonon manages to determine the full track length. */ void trackLengthChanged( qint64 milliseconds ); /** * Called when Amarok is closed and we disconnect from Phonon. * @param resumePlayback True if amarok will continue playback after a restart. */ void sessionEnded( bool resumePlayback ); /** * Called when playback state changes to PlayingState, StoppedState or PausedState. */ void playbackStateChanged(); /** * Is emitted when new audio Data is ready * @param audioData The audio data that is available */ void audioDataReady( const QMap > &audioData ); /** * A trick to call slotFillInSupportedMimeTypes() in a main thread, not to be used * anywhere else than in supportedMimeTypes(). */ void fillInSupportedMimeTypes(); private Q_SLOTS: /** * Sets up the Phonon system */ void initializePhonon(); /** This slot is connected to the phonon finished signal. It is emitted when the queue is empty and the current media come to an end. */ void slotFinished(); void slotAboutToFinish(); void slotNewTrackPlaying( const Phonon::MediaSource &source); void slotStateChanged( Phonon::State newState, Phonon::State oldState); void slotPlayableUrlFetched( const QUrl &url ); void slotTick( qint64 ); void slotTrackLengthChanged( qint64 ); void slotMetaDataChanged(); void slotSeekableChanged( bool ); void slotPause(); /** * For volume/mute changes from the phonon side */ void slotVolumeChanged( qreal ); void slotMutedChanged( bool ); /** * Notify the engine that a new title has been reached when playing a cd. This * is needed as a cd counts as basically one lone track, and we want to be able * to play something else once one track has finished */ void slotTitleChanged( int titleNumber ); /** * Fill in m_supportedMimeTypes list and release m_supportedMimeTypesSemaphore. This * method must be called in the main thread so that there is no chance * Phonon::BackendCapabilities::availableMimeTypes() is called in a non-gui thread * for the first time. */ void slotFillInSupportedMimeTypes(); /** * Calls track->finishedPlaying(), connected to trackFinishedPlaying() signal to * reduce code duplication. */ void slotTrackFinishedPlaying( Meta::TrackPtr track, double playedFraction ); protected: // reimplemented from Meta::Observer using Observer::metadataChanged; void metadataChanged( const Meta::TrackPtr &track ) override; void metadataChanged( const Meta::AlbumPtr &album ) override; private: /** * Plays the media at a specified URL * * @param url the URL of the media * @param offset the position in the media to start at in milliseconds * @param startPaused if true, go to paused state. if false, go to playing state (default) */ void playUrl( const QUrl &url, uint offset, bool startPaused = false ); /** * Try to detect MetaData spam in Streams etc. * * Some streams are doing advertisement in the metadata. We try to filter that * out. Additionally, some Phonon back-ends Q_EMIT more than one * metadataChanged() signals per on track, so filter it all altogether. */ bool isInRecentMetaDataHistory( const QVariantMap &meta ); /** * If m_lastStreamStampPosition is non-negative, update it to current position * and update track length in current stream. */ void stampStreamTrackLength(); /** * Q_EMIT metadataChanged() with info so that MetaStream::Track that is * currently listening updates its length. * * @param length new track length in milliseconds */ void updateStreamLength( qint64 length ); Q_DISABLE_COPY( EngineController ) EqualizerController *m_equalizerController; QPointer m_media; QPointer m_preamp; QPointer m_audio; QPointer m_audioDataOutput; QPointer m_controller; Phonon::Path m_path; Phonon::Path m_dataPath; QPointer m_fadeouter; QPointer m_fader; Meta::TrackPtr m_currentTrack; Meta::AlbumPtr m_currentAlbum; Meta::TrackPtr m_nextTrack; QUrl m_nextUrl; Capabilities::BoundedPlaybackCapability* m_boundedPlayback; Capabilities::MultiPlayableCapability* m_multiPlayback; QScopedPointer m_multiSource; bool m_playWhenFetched; int m_volume; int m_currentAudioCdTrack; QTimer *m_pauseTimer; QList m_metaDataHistory; // against metadata spam // last position (in ms) when the song changed (within the current stream) or -1 for non-stream qint64 m_lastStreamStampPosition; /** * Some flags to prevent feedback loops in volume updates */ bool m_ignoreVolumeChangeAction; bool m_ignoreVolumeChangeObserve; // Used to get a more accurate estimate of the position for slotTick int m_tickInterval; qint64 m_lastTickPosition; qint64 m_lastTickCount; QMutex m_mutex; // FIXME: this variable should be updated when // Phonon::BackendCapabilities::notifier()'s capabilitiesChanged signal is emitted QStringList m_supportedMimeTypes; QSemaphore m_supportedMimeTypesSemaphore; }; namespace The { AMAROK_EXPORT EngineController* engineController(); } #endif diff --git a/src/GlobalCollectionActions.h b/src/GlobalCollectionActions.h index 5b8620d1eb..92a11dbf20 100644 --- a/src/GlobalCollectionActions.h +++ b/src/GlobalCollectionActions.h @@ -1,167 +1,167 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 GLOBALCOLLECTIONACTIONS_H #define GLOBALCOLLECTIONACTIONS_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include class AMAROK_EXPORT GlobalCollectionAction : public QAction { public: GlobalCollectionAction( const QString &text, QObject * parent ); }; class AMAROK_EXPORT GlobalCollectionGenreAction : public GlobalCollectionAction { public: GlobalCollectionGenreAction( const QString &text, QObject * parent ); void setGenre( const Meta::GenrePtr &genre ); protected: Meta::GenrePtr genre(); private: Meta::GenrePtr m_currentGenre; }; class AMAROK_EXPORT GlobalCollectionArtistAction : public GlobalCollectionAction { public: GlobalCollectionArtistAction( const QString &text, QObject * parent ); void setArtist( const Meta::ArtistPtr &artist ); protected: Meta::ArtistPtr artist(); private: Meta::ArtistPtr m_currentArtist; }; class AMAROK_EXPORT GlobalCollectionAlbumAction : public GlobalCollectionAction { public: GlobalCollectionAlbumAction( const QString &text, QObject * parent ); void setAlbum( const Meta::AlbumPtr &album ); protected: Meta::AlbumPtr album(); private: Meta::AlbumPtr m_currentAlbum; }; class AMAROK_EXPORT GlobalCollectionTrackAction : public GlobalCollectionAction { public: GlobalCollectionTrackAction( const QString &text, QObject * parent ); void setTrack( const Meta::TrackPtr &track ); protected: Meta::TrackPtr track(); private: Meta::TrackPtr m_currentTrack; }; class AMAROK_EXPORT GlobalCollectionYearAction : public GlobalCollectionAction { public: GlobalCollectionYearAction( const QString &text, QObject * parent ); void setYear( const Meta::YearPtr &year ); protected: Meta::YearPtr year(); private: Meta::YearPtr m_currentYear; }; class GlobalCollectionComposerAction : public GlobalCollectionAction { public: GlobalCollectionComposerAction( const QString &text, QObject * parent ); void setComposer( const Meta::ComposerPtr &composer ); protected: Meta::ComposerPtr composer(); private: Meta::ComposerPtr m_currentComposer; }; class GlobalCollectionActions; namespace The { AMAROK_EXPORT GlobalCollectionActions* globalCollectionActions(); } /** This class keeps track of global context actions that should be added to all genre, artists or another meta type in all collections. */ class AMAROK_EXPORT GlobalCollectionActions : public QObject { Q_OBJECT friend GlobalCollectionActions* The::globalCollectionActions(); public: QList actionsFor( const Meta::DataPtr &item ); void addGenreAction( GlobalCollectionGenreAction * action ); void addArtistAction( GlobalCollectionArtistAction * action ); void addAlbumAction( GlobalCollectionAlbumAction * action ); void addTrackAction( GlobalCollectionTrackAction * action ); void addYearAction( GlobalCollectionYearAction * action ); void addComposerAction( GlobalCollectionComposerAction * action ); private: GlobalCollectionActions(); - ~GlobalCollectionActions(); + ~GlobalCollectionActions() override; QList actionsFor( const Meta::GenrePtr &genre ); QList actionsFor( const Meta::ArtistPtr &artist ); QList actionsFor( const Meta::AlbumPtr &album ); QList actionsFor( const Meta::TrackPtr &track ); QList actionsFor( const Meta::YearPtr &year ); QList actionsFor( const Meta::ComposerPtr &composer ); QList m_genreActions; QList m_artistActions; QList m_albumActions; QList m_trackActions; QList m_yearActions; QList m_composerActions; }; #endif diff --git a/src/GlobalCurrentTrackActions.h b/src/GlobalCurrentTrackActions.h index 4b8c8bb0dd..4488dfc2d2 100644 --- a/src/GlobalCurrentTrackActions.h +++ b/src/GlobalCurrentTrackActions.h @@ -1,53 +1,53 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 GLOBALCURRENTTRACKACTIONS_H #define GLOBALCURRENTTRACKACTIONS_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include class GlobalCurrentTrackActions; class QAction; namespace The { AMAROK_EXPORT GlobalCurrentTrackActions* globalCurrentTrackActions(); } /** A global list of actions that is made available to all playing tracks. @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT GlobalCurrentTrackActions : public QObject { friend GlobalCurrentTrackActions* The::globalCurrentTrackActions(); public: void addAction( QAction * action ); QList actions(); private: GlobalCurrentTrackActions(); - ~GlobalCurrentTrackActions(); + ~GlobalCurrentTrackActions() override; QList m_actions; }; #endif diff --git a/src/KNotificationBackend.h b/src/KNotificationBackend.h index d43dbbbdf7..465755affd 100644 --- a/src/KNotificationBackend.h +++ b/src/KNotificationBackend.h @@ -1,74 +1,74 @@ /**************************************************************************************** * Copyright (c) 2009-2011 Kevin Funk * * * * 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_KNOTIFICATIONBACKEND_H #define AMAROK_KNOTIFICATIONBACKEND_H #include "core/meta/forward_declarations.h" #include #include #include class KNotification; namespace Amarok { /** * Class for accessing KNotify in KDE **/ class KNotificationBackend : public QObject { Q_OBJECT public: static KNotificationBackend *instance(); static void destroy(); void setEnabled( bool enabled ); bool isEnabled() const; /** * Checks if a fullscreen window is currently active. */ bool isFullscreenWindowActive() const; public Q_SLOTS: /** * Shows a message. Warning, this method doesn't check isEnabled(), you * should do it yourself. */ void show( const QString &title, const QString &body, const QPixmap &pixmap = QPixmap() ); /** * @param force - if true, isEnabled() is not checked, otherwise it is */ void showCurrentTrack( bool force = false ); private: KNotificationBackend(); - ~KNotificationBackend(); + ~KNotificationBackend() override; static KNotificationBackend *s_instance; bool m_enabled; QPointer m_notify; }; } #endif diff --git a/src/MediaDeviceCache.h b/src/MediaDeviceCache.h index 3cf2effffb..63b164025c 100644 --- a/src/MediaDeviceCache.h +++ b/src/MediaDeviceCache.h @@ -1,71 +1,71 @@ /**************************************************************************************** * Copyright (c) 2007 Jeff Mitchell * * * * 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_MEDIADEVICECACHE_H #define AMAROK_MEDIADEVICECACHE_H #include "amarok_export.h" #include #include #include class AMAROK_EXPORT MediaDeviceCache : public QObject { Q_OBJECT public: enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType, SolidGenericType, InvalidType }; static MediaDeviceCache* instance() { return s_instance ? s_instance : new MediaDeviceCache(); } /** * Creates a new MediaDeviceCache. * */ MediaDeviceCache(); - ~MediaDeviceCache(); + ~MediaDeviceCache() override; void refreshCache(); const QStringList getAll() const { return m_type.keys(); } MediaDeviceCache::DeviceType deviceType( const QString &udi ) const; const QString deviceName( const QString &udi ) const; const QString device( const QString & udi ) const; bool isGenericEnabled( const QString &udi ) const; const QString volumeMountPoint( const QString &udi ) const; Q_SIGNALS: void deviceAdded( const QString &udi ); void deviceRemoved( const QString &udi ); void accessibilityChanged( bool accessible, const QString &udi ); public Q_SLOTS: void slotAddSolidDevice( const QString &udi ); void slotRemoveSolidDevice( const QString &udi ); void slotAccessibilityChanged( bool accessible, const QString &udi ); private: QMap m_type; QMap m_name; QMap m_accessibility; QStringList m_volumes; static MediaDeviceCache* s_instance; }; #endif /* AMAROK_MEDIADEVICECACHE_H */ diff --git a/src/MediaDeviceMonitor.h b/src/MediaDeviceMonitor.h index 4b26d6249a..cb97962341 100644 --- a/src/MediaDeviceMonitor.h +++ b/src/MediaDeviceMonitor.h @@ -1,127 +1,127 @@ /**************************************************************************************** * Copyright (c) 2008 Alejandro Wainzinger * * * * 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 . * ****************************************************************************************/ /* Description: The MediaDeviceMonitor connects to the MediaDeviceCache, monitoring the connection and disconnection of devices. It tests for devices known to Amarok, and if it finds them, sends a signal that the appropriate CollectionFactory is connected to, which triggers the creation of the associated Collection. Similar behaviour for when a device is disconnected. All new MediaDeviceCollection-type classes must register their ConnectionAssistant of their device with this class, and have it connect to the right signals to properly build/delete the associated Collection. An example of this is seen in the IpodCollectionFactory. */ #ifndef AMAROK_MEDIADEVICEMONITOR_H #define AMAROK_MEDIADEVICEMONITOR_H #include "amarok_export.h" #include #include #include class ConnectionAssistant; class MediaDeviceInfo; class QStringList; class AMAROK_EXPORT MediaDeviceMonitor : public QObject { Q_OBJECT public: static MediaDeviceMonitor* instance() { return s_instance ? s_instance : new MediaDeviceMonitor(); } MediaDeviceMonitor(); - ~MediaDeviceMonitor(); + ~MediaDeviceMonitor() override; void init(); // connect to MediaDeviceCache QStringList getDevices(); // get list of devices /// Get assistant for a given udi ConnectionAssistant *getUdiAssistant( const QString &udi ) { return m_udiAssistants[ udi ]; } /** registerDeviceType adds the device type described by @param assistant to the list of known device types by the MDM, and then checks the list of known devices for a match with this type */ void registerDeviceType( ConnectionAssistant *assistant ); public Q_SLOTS: /** checkDevice checks if @p udi is a known device and if so attempts to connect it checkOneDevice runs an identify check using the given assistant and udi checkDevicesFor checks if the device type described by @p assistant matches any of the udi's in the MediaDeviceCache, and if so, attempts to connect to it */ void checkDevice( const QString &udi ); void checkOneDevice( ConnectionAssistant* assistant, const QString& udi ); void checkDevicesFor( ConnectionAssistant* assistant ); Q_SIGNALS: void deviceDetected( const MediaDeviceInfo &deviceinfo ); void deviceRemoved( const QString &udi ); private Q_SLOTS: void deviceAdded( const QString &udi ); void slotDeviceRemoved( const QString &udi ); void slotAccessibilityChanged( bool accessible, const QString & udi ); void slotDequeueWaitingAssistant(); private: static MediaDeviceMonitor *s_instance; // keeps track of which CA to contact for which udi QHash m_udiAssistants; // holds all registered assistants QList m_assistants; // holds all waiting assistants QList m_waitingassistants; // holds index of next waiting assistant to check // devices with, during initialization of device // factories int m_nextassistant; }; #endif /* AMAROK_MEDIADEVICEMONITOR_H */ diff --git a/src/PaletteHandler.h b/src/PaletteHandler.h index 699ed934b2..cc72a8f8ac 100644 --- a/src/PaletteHandler.h +++ b/src/PaletteHandler.h @@ -1,97 +1,97 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 PALETTEHANDLER_H #define PALETTEHANDLER_H #include "amarok_export.h" #include #include class QAbstractItemView; class PaletteHandler; namespace The { AMAROK_EXPORT PaletteHandler* paletteHandler(); } /** A small singleton class to handle propagating palette change notifications and hold some utility functions for updating certain widgets @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT PaletteHandler : public QObject { Q_OBJECT friend PaletteHandler* The::paletteHandler(); public: - ~PaletteHandler(); + ~PaletteHandler() override; QPalette palette() const; void setPalette( const QPalette & palette ); /** Gives the item view a special darker palette and transparent background. You need to connect to the newPalette signal afterwards because this darker palette does not automatically update. @param view the item view. */ void updateItemView( QAbstractItemView * view ); /** * Returns the foreground color for the painter by checking the painting QWidget::foregroundRole() and falling back to * QPalette::WindowText (or QPalette::HighlightedText if @p selected) * Uses the widgets palette or the application palette as fallback * @param p the painter. * @param selected the mode switcher. */ QColor foregroundColor( const QPainter *p, bool selected = false ); /** * Returns the highlight color which should be used instead of the color from KDE. * @param percentSaturation Decimal percentage to saturate the highlight color. Will * reduce (or magnify) the saturation in HSV representation of the color. * Defaults to 50% * @param percentValue Decimal percentage to multiply the value of the HSV color with. * Defaults to 100%. * @return Highlight color, which is the KDE highlight color, with reduced saturation * (less contrast). */ static QColor highlightColor( qreal percentSaturation = 0.5, qreal percentValue = 1.0 ); /** * Returns the background color used in context applets. */ static QColor backgroundColor(); /** * Returns the alternate background color used in context applets. */ static QColor alternateBackgroundColor(); Q_SIGNALS: void newPalette( const QPalette & palette ); private: PaletteHandler( QObject* parent = nullptr ); QPalette m_palette; }; #endif diff --git a/src/PluginManager.h b/src/PluginManager.h index 6dba1b589e..8fa44bd6f3 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -1,121 +1,121 @@ /**************************************************************************************** * Copyright (c) 2004-2013 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 AMAROK_PLUGINMANAGER_H #define AMAROK_PLUGINMANAGER_H #include "amarok_export.h" #include #include #include namespace Plugins { class PluginFactory; class AMAROK_EXPORT PluginManager : public QObject { Q_OBJECT Q_PROPERTY( int pluginFrameworkVersion READ pluginFrameworkVersion ) public: /** Type of the plugin. * * Will be determined by the KPluginInfo::category */ enum Type { Collection = 1, ///< the plugin implements a CollectionFactory Service = 2, ///< this is a service plugin Importer = 3, ///< this plugin implements importer functionality Storage = 4, ///< the plugin implements a StorageFactory }; Q_ENUM( Type ) - ~PluginManager(); + ~PluginManager() override; static PluginManager *instance(); /** Destroys the instance of the PluginManager. * * The order of the destruction is somewhat important. * The PluginManager needs to be destroyed after all collections * have been removed and before the CollectionManager, * the ServicePluginManager and the StatSyncing::Controller are destroyed. */ static void destroy(); static int pluginFrameworkVersion(); /** * Load any services that are configured to be loaded */ void init(); /** Returns enabled plugin factories for the given plugin type. * * This function will only return factories for enabled plugins. */ QList > factories( Type type ) const; KPluginInfo::List plugins( Type type ) const; QVector enabledPlugins(Type type ) const; /** Check if any services were disabled and needs to be removed, or any * that are hidden needs to be enabled * * This function will call the sub plugin managers (like CollectionManager) * setFactories function. */ void checkPluginEnabledStates(); private: /** Tries finding Amarok plugins */ QVector findPlugins(); /** Returns true if the plugin is enabled. * This function will check the default enabled state, * the Amarok configuration state and the primary collection. * * @returns true if the plugin is enabled. */ bool isPluginEnabled( const KPluginMetaData &plugin ) const; /** Creates a factories for a plugin */ QSharedPointer createFactory( const KPluginMetaData &pluginInfo ); /// contains the names of all KPluginInfos that have factories created QVector m_plugins; QHash > m_pluginsByType; QHash > > m_factoriesByType; QHash> m_factoryCreated; static const int s_pluginFrameworkVersion; static PluginManager *s_instance; explicit PluginManager( QObject *parent = nullptr ); }; } // namespace Plugins namespace The { inline Plugins::PluginManager *pluginManager() { return Plugins::PluginManager::instance(); } } #endif /* AMAROK_PLUGINMANAGER_H */ diff --git a/src/PopupDropperFactory.h b/src/PopupDropperFactory.h index af057c01aa..401db62c3c 100644 --- a/src/PopupDropperFactory.h +++ b/src/PopupDropperFactory.h @@ -1,62 +1,62 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 POPUPDROPPERFACTORY_H #define POPUPDROPPERFACTORY_H #include "amarok_export.h" #include "context/popupdropper/libpud/PopupDropper.h" /** A central place for creating a Pud that matches system colors @author Nikolaj Hald Nielsen */ class PopupDropperFactory; class PopupDropperItem; namespace The { AMAROK_EXPORT PopupDropperFactory* popupDropperFactory(); } class AMAROK_EXPORT PopupDropperFactory : public QObject { Q_OBJECT friend PopupDropperFactory* The::popupDropperFactory(); public: /** * Creates a new PopupDropper with correct system colors. This function creates it on top of the context view * Function for creating a new PopupDropper with a custom parent * @param parent The widget to act as the parent * @param ignoreEmptyParent Whether to ignore if the parent is null - use this when creating submenus where the parent is 0 * @return The newly created PopupDropper */ PopupDropper * createPopupDropper( QWidget * parent, bool ignoreEmptyParent = false ); PopupDropperItem* createItem( QAction * action ); void adjustItems( PopupDropper *pud ); void adjustItem( PopupDropperItem *item ); static void adjustItemCallback( void *pdi ); private: explicit PopupDropperFactory( QObject* parent ); - ~PopupDropperFactory(); + ~PopupDropperFactory() override; }; #endif diff --git a/src/SvgHandler.h b/src/SvgHandler.h index 7cca4f8189..ea0b45ec91 100644 --- a/src/SvgHandler.h +++ b/src/SvgHandler.h @@ -1,177 +1,177 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * Copyright (c) 2008 Jeff Mitchell * * Copyright (c) 2009-2013 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 SVGHANDLER_H #define SVGHANDLER_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include #include #include #include #include class QStyleOptionSlider; class QSvgRenderer; class SvgHandler; namespace The { AMAROK_EXPORT SvgHandler* svgHandler(); } /** A class to abstract out some common operations of users of tinted svgs */ class AMAROK_EXPORT SvgHandler : public QObject { Q_OBJECT friend SvgHandler* The::svgHandler(); public: - ~SvgHandler(); + ~SvgHandler() override; QSvgRenderer* getRenderer( const QString &name ); QSvgRenderer* getRenderer(); QPixmap renderSvg( const QString &name, const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); /** * Overloaded function that uses the current theme * @param keyname the name of the key to save in the cache * @param width Width of the resulting pixmap * @param height Height of the resulting pixmap * @param element The theme element to render ( if none the entire svg is rendered ) * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. * @param opacity The opacity used for rendering. Range 0.0 to 1.0. * @return The svg element/file rendered into a pixmap */ QPixmap renderSvg( const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); /** * Another overloaded function that loads a svg file from an url. This function is usable from QML. * @param url the given URL * @param keyname the name of the key to save in the cache * @param width Width of the resulting pixmap * @param height Height of the resulting pixmap * @param element The theme element to render ( if none the entire svg is rendered ) * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. * @param opacity The opacity used for rendering. Range 0.0 to 1.0. * @return The svg element/file rendered into a pixmap */ Q_INVOKABLE QPixmap renderSvg( const QUrl& url, const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); /** * Yet another overloaded function. This one renders the svg element and adds half a divider element to the top and the bottom * so it looks sane when multiple elements with the same width are stacked. * * @param keyname the name of the key to save in the cache. * @param width Width of the resulting pixmap. * @param height Height of the resulting pixmap. * @param element The theme element to render ( if none the entire svg is rendered ) * @return The svg element/file rendered into a pixmap. */ QPixmap renderSvgWithDividers( const QString& keyname, int width, int height, const QString& element = QString() ); /** * Take an album and extract the pixmap for sending to addBordersToPixmap. * * @param album The AlbumPtr * @param size The size of the resulting image (border included) * @param borderWidth The desired width of the border */ QPixmap imageWithBorder( Meta::AlbumPtr album, int size = 1, int borderWidth = 5 ); /** * Add nice borders to a pixmap. The function will create and return a new * Pixmap that is the size of the old one plus twice the border width in * each dimension. * * @param orgPixmap The original pixmap. * @param borderWidth The pixel width of the borders to add to the pixmap. * @param name A name for use as the basis of the cache key that for caching the completed image plus borders. * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. */ QPixmap addBordersToPixmap( const QPixmap &orgPixmap, int borderWidth, const QString &name, bool skipCache =false ); /** * Paint a custom slider using the specified painter. The slider consists * of a background part, a "knob" that moves along it to show the current * position, and 2 end markers to clearly mark the ends of the slider. * The background part before the knob, is painted in a different color than the * part after (and under) the knob. * @param p The painter to use. * @param slider The slider. * @param percentage The percentage of the slider that the knob is positioned at. * @param paintMoodbar Whether to paint a moodbar. */ void paintCustomSlider( QPainter *p, QStyleOptionSlider *slider, qreal percentage, bool paintMoodbar = false ); /** * Calculate the visual slider knob rect from its value, use it instead the QStyle functions * QStyle::sliderPositionFromValue() and QStyle::subControlRect(); */ QRect sliderKnobRect( const QRect &slider, qreal percent, bool inverse ) const; /** * Get the path of the currently used svg theme file. * * @return the path of the currently used theme file. */ QString themeFile(); /** * Change the currently used svg theme file. This function also * clears the pixmap cache as all svg elements have potentially changed * and should be re-rendered. * * @param themeFile The path of the new theme file to use. */ void setThemeFile( const QString & themeFile ); public Q_SLOTS: void reTint(); Q_SIGNALS: void retinted(); private Q_SLOTS: void discardCache(); private: SvgHandler( QObject* parent = nullptr ); bool loadSvg( const QString& name, bool forceCustomTheme = false ); QPixmap sliderHandle( const QColor &color, bool pressed, int size ); QColor calcLightColor(const QColor &color) const; QColor calcDarkColor(const QColor &color) const; bool lowThreshold(const QColor &color) const; KImageCache * m_cache; QHash m_renderers; QReadWriteLock m_lock; QString m_themeFile; bool m_customTheme; }; #endif diff --git a/src/aboutdialog/ExtendedAboutDialog.h b/src/aboutdialog/ExtendedAboutDialog.h index 11461e519d..7af7433ef2 100644 --- a/src/aboutdialog/ExtendedAboutDialog.h +++ b/src/aboutdialog/ExtendedAboutDialog.h @@ -1,92 +1,92 @@ /**************************************************************************************** * Copyright (c) 2007 Urs Wolfer * * Copyright (c) 2008 Friedrich W. H. Kossebau * * Copyright (c) 2009 Téo Mrnjavac * * * * Parts of this class have been take from the KAboutApplication class, which was * * Copyright (c) 2000 Waldo Bastian (bastian@kde.org) and Espen Sand (espen@kde.org) * * * * 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_EXTENDEDABOUTDIALOG_H #define AMAROK_EXTENDEDABOUTDIALOG_H #include "core/support/Amarok.h" #include "amarok_export.h" #include "App.h" #include "OcsPersonListWidget.h" #include "AnimatedBarWidget.h" #include #include #include class AMAROK_EXPORT ExtendedAboutDialog : public QDialog { Q_OBJECT public: explicit ExtendedAboutDialog( const KAboutData &aboutData, const OcsData *ocsData, QWidget *parent = nullptr ); - virtual ~ExtendedAboutDialog(); + ~ExtendedAboutDialog() override; private Q_SLOTS: void switchToOcsWidgets(); void onProvidersFetched(); void showLicense( const QString &number ); private: class Private; Private* const d; Q_DISABLE_COPY( ExtendedAboutDialog ) OcsData m_ocsData; Attica::ProviderManager m_providerManager; //Authors: QString m_authorPageTitle; QPointer m_showOcsAuthorButton; QPointer m_authorWidget; QPointer m_authorListWidget; bool m_isOfflineAuthorWidget; //Contributors: QPointer m_showOcsCreditButton; QPointer m_creditWidget; QPointer m_creditListWidget; bool m_isOfflineCreditWidget; //Donors: QPointer m_showOcsDonorButton; QPointer m_donorWidget; QPointer m_donorListWidget; bool m_isOfflineDonorWidget; }; class ExtendedAboutDialog::Private { public: Private(ExtendedAboutDialog *parent) : q(parent), aboutData(nullptr) {} void _k_showLicense( const QString &number ); ExtendedAboutDialog *q; const KAboutData *aboutData; }; #endif //AMAROK_EXTENDEDABOUTDIALOG_H diff --git a/src/aboutdialog/OcsPersonItem.h b/src/aboutdialog/OcsPersonItem.h index 8cb481332c..c78eea85f6 100644 --- a/src/aboutdialog/OcsPersonItem.h +++ b/src/aboutdialog/OcsPersonItem.h @@ -1,100 +1,100 @@ /**************************************************************************************** * Copyright (c) 2009 Téo Mrnjavac * * * * 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_OCSPERSONITEM_H #define AMAROK_OCSPERSONITEM_H #include "ui_OcsPersonItem.h" #include "OcsData.h" #include #include #include #include #include class KJob; namespace Attica { class BaseJob; } class OcsPersonItem : public QWidget, private Ui::OcsPersonItem { Q_OBJECT public: enum PersonStatus { Author = 0, Contributor = 1 }; enum State { Offline = 0, Online = 1 }; OcsPersonItem( const KAboutPerson &person, const QString &ocsUsername, PersonStatus status, QWidget *parent = nullptr ); - virtual ~OcsPersonItem(); + ~OcsPersonItem() override; QString name() const; void switchToOcs( Attica::Provider &provider ); Q_SIGNALS: void ocsFetchStarted(); void ocsFetchResult( int err ); private Q_SLOTS: void launchUrl( QAction *action ); void onJobFinished( Attica::BaseJob *job ); void onAvatarLoadingJobFinished( KJob *job ); private: void init(); void fillOcsData( const Attica::Person &ocsPerson ); const KAboutPerson *m_person; QString m_ocsUsername; QString m_aboutText; KToolBar *m_iconsBar; //!< holds the icons for email, homepage and oD.o profile KToolBar *m_snBar; //!< holds any other icons for social network profiles PersonStatus m_status; State m_state; /* Frank Test developer opendesktop.org opendesktop.org http://www.KDE-Look.org/CONTENT/user-pics/0/Frank.jpg 1 http://www.KDE-Look.org/CONTENT/user-bigpics/0/Frank.jpg 1 Stuttgart Germany karli kde-dev, plasma irc://irc.freenode.org/kde-dev irc://irc.freenode.org/plasma http://www.KDE-Look.org/usermanager/search.php?username=Frank */ }; #endif //AMAROK_OCSPERSONITEM_H diff --git a/src/amarokurls/AmarokUrl.h b/src/amarokurls/AmarokUrl.h index 6a418651a9..d377c59db2 100644 --- a/src/amarokurls/AmarokUrl.h +++ b/src/amarokurls/AmarokUrl.h @@ -1,95 +1,95 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 AMAROKURL_H #define AMAROKURL_H #include "amarok_export.h" #include "BookmarkViewItem.h" #include "BookmarkGroup.h" #include #include class AMAROK_EXPORT AmarokUrl : public BookmarkViewItem { public: AmarokUrl(); explicit AmarokUrl( const QString & urlString, const BookmarkGroupPtr &parent = BookmarkGroupPtr() ); explicit AmarokUrl( const QStringList & resultRow, const BookmarkGroupPtr &parent = BookmarkGroupPtr() ); - ~AmarokUrl(); + ~AmarokUrl() override; void reparent( const BookmarkGroupPtr &parent ); void initFromString( const QString & urlString ); QString command() const; QString prettyCommand() const; QString path() const; QMap args() const; void setCommand( const QString &command ); void setPath( const QString &path ); /** * Sets the url argument named @param name to @param value . Overrides any possible * previous value. */ void setArg( const QString &name, const QString &value ); void setName( const QString &name ); void setDescription( const QString &description ) override; void setCustomValue( const QString &custom ); QString customValue() const; bool run(); QString url() const; bool saveToDb(); void setId( int id ) { m_id = id; } int id() const { return m_id; } bool isNull() const; QString name() const override; QString description() const override; BookmarkGroupPtr parent() const override { return m_parent; } void removeFromDb() override; void rename( const QString &name ) override; static QString escape( const QString &in ); static QString unescape( const QString &in ); private: QString m_command; QString m_path; QMap m_arguments; int m_id; BookmarkGroupPtr m_parent; QString m_description; QString m_name; //this value is used for storing application specific information that should not be made user visible. QString m_customValue; }; #endif diff --git a/src/amarokurls/AmarokUrlHandler.h b/src/amarokurls/AmarokUrlHandler.h index bb57e29d28..49aae91d1f 100644 --- a/src/amarokurls/AmarokUrlHandler.h +++ b/src/amarokurls/AmarokUrlHandler.h @@ -1,103 +1,103 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 AMAROKURLHANDLER_H #define AMAROKURLHANDLER_H #include "amarok_export.h" #include "AmarokUrlGenerator.h" #include "AmarokUrlRunnerBase.h" #include "core/meta/forward_declarations.h" #include "playlist/PlaylistViewUrlRunner.h" #include #include class TimecodeObserver; class AmarokUrlHandler; class NavigationUrlRunner; class PlayUrlRunner; namespace The { AMAROK_EXPORT AmarokUrlHandler* amarokUrlHandler(); } /** A singleton class for handling and delegating all amarok:// urls @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT AmarokUrlHandler : public QObject { Q_OBJECT friend AmarokUrlHandler* The::amarokUrlHandler(); public: void registerRunner( AmarokUrlRunnerBase * runner, const QString & command ); void unRegisterRunner( AmarokUrlRunnerBase * runner ); void registerGenerator( AmarokUrlGenerator * generator ); void unRegisterGenerator( AmarokUrlGenerator * generator ); bool run( const AmarokUrl &url ); BookmarkList urlsByCommand( const QString &command ); QIcon iconForCommand( const QString &command ); void updateTimecodes( const QString * BookmarkName = nullptr ); void paintNewTimecode( const QString &name, int pos ); QList generators() { return m_registeredGenerators; } AmarokUrl createBrowserViewBookmark(); AmarokUrl createPlaylistViewBookmark(); AmarokUrl createContextViewBookmark(); QString prettyCommand( const QString &command ); public Q_SLOTS: void bookmarkAlbum( const Meta::AlbumPtr &album ); void bookmarkArtist( const Meta::ArtistPtr &artist ); void bookmarkCurrentBrowserView(); void bookmarkCurrentPlaylistView(); void bookmarkCurrentContextView(); Q_SIGNALS: void timecodesUpdated( const QString * BookmarkName ); void timecodeAdded( const QString &name, int pos ); private: AmarokUrlHandler(); - ~AmarokUrlHandler(); + ~AmarokUrlHandler() override; QMap m_registeredRunners; QList m_registeredGenerators; NavigationUrlRunner * m_navigationRunner; Playlist::ViewUrlRunner * m_playlistViewRunner; PlayUrlRunner * m_playRunner; TimecodeObserver * m_timecodeObserver; }; #endif diff --git a/src/amarokurls/BookmarkCurrentButton.h b/src/amarokurls/BookmarkCurrentButton.h index bf8277c020..e7605091df 100644 --- a/src/amarokurls/BookmarkCurrentButton.h +++ b/src/amarokurls/BookmarkCurrentButton.h @@ -1,35 +1,35 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 BOOKMARKCURRENTBUTTON_H #define BOOKMARKCURRENTBUTTON_H #include class BookmarkCurrentButton : public QToolButton { Q_OBJECT public: explicit BookmarkCurrentButton( QWidget *parent ); - virtual ~BookmarkCurrentButton(); + ~BookmarkCurrentButton() override; protected Q_SLOTS: void showMenu(); void generateMenu( const QPoint &pos ); }; #endif // BOOKMARKCURRENTBUTTON_H diff --git a/src/amarokurls/BookmarkGroup.h b/src/amarokurls/BookmarkGroup.h index 989a95810c..60b16e608d 100644 --- a/src/amarokurls/BookmarkGroup.h +++ b/src/amarokurls/BookmarkGroup.h @@ -1,92 +1,92 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 BOOKMARKGROUP_H #define BOOKMARKGROUP_H #include "AmarokUrl.h" #include "BookmarkViewItem.h" #include #include #include #include "AmarokSharedPointer.h" class BookmarkGroup; class AmarokUrl; typedef AmarokSharedPointer AmarokUrlPtr; typedef AmarokSharedPointer BookmarkGroupPtr; typedef QList BookmarkList; typedef QList BookmarkGroupList; /** A class for allowing a "folder structure" in the bookmark browser and the database. Takes care of reading and writing itself to the database. */ class BookmarkGroup : public BookmarkViewItem { public: BookmarkGroup( const QStringList &dbResultRow, const BookmarkGroupPtr &parent ); explicit BookmarkGroup( const QString &name, const BookmarkGroupPtr &parent = BookmarkGroupPtr() ); BookmarkGroup( const QString &name, const QString &customType ); - ~BookmarkGroup(); + ~BookmarkGroup() override; int id() const; QString name() const override; QString description() const override; int childCount() const override; BookmarkGroupPtr parent() const override { return m_parent; } void rename( const QString &name ) override; void setDescription( const QString &description ) override; void save(); BookmarkGroupList childGroups() const; BookmarkList childBookmarks() const; void reparent( const BookmarkGroupPtr &parent ); void clear(); void deleteChild( const BookmarkViewItemPtr &item ); void removeFromDb() override; private: int m_dbId; BookmarkGroupPtr m_parent; QString m_name; QString m_description; QString m_customType; mutable BookmarkGroupList m_childGroups; mutable BookmarkList m_childBookmarks; mutable bool m_hasFetchedChildGroups; mutable bool m_hasFetchedChildPlaylists; }; Q_DECLARE_METATYPE( BookmarkGroupPtr ) Q_DECLARE_METATYPE( AmarokUrlPtr ) Q_DECLARE_METATYPE( BookmarkList ) Q_DECLARE_METATYPE( BookmarkGroupList ) #endif diff --git a/src/amarokurls/BookmarkManager.h b/src/amarokurls/BookmarkManager.h index db85854e1c..8e2f9c43c5 100644 --- a/src/amarokurls/BookmarkManager.h +++ b/src/amarokurls/BookmarkManager.h @@ -1,41 +1,41 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 BOOKMARKMANAGER_H #define BOOKMARKMANAGER_H #include "BookmarkManagerWidget.h" #include class BookmarkManager : public QDialog { public: static BookmarkManager * instance(); - ~BookmarkManager(); + ~BookmarkManager() override; static void showOnce( QWidget* parent = nullptr ); private: explicit BookmarkManager( QWidget* parent = nullptr ); static BookmarkManager *s_instance; BookmarkManagerWidget * m_widget; }; #endif // BOOKMARKMANAGER_H diff --git a/src/amarokurls/BookmarkManagerWidget.h b/src/amarokurls/BookmarkManagerWidget.h index 2edf3c7355..96a3396992 100644 --- a/src/amarokurls/BookmarkManagerWidget.h +++ b/src/amarokurls/BookmarkManagerWidget.h @@ -1,58 +1,58 @@ /**************************************************************************************** * Copyright (c) 2008, 2009 Nikolaj Hald Nielsen * * * * 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 BOOKMARKMANAGERWIDGET_H #define BOOKMARKMANAGERWIDGET_H #include "amarok_export.h" #include "amarokurls/BookmarkTreeView.h" #include "widgets/BoxWidget.h" #include "widgets/LineEdit.h" #include #include #include #include /** A widget for managing amarok:// bookmark urls @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT BookmarkManagerWidget : public BoxWidget { Q_OBJECT public: explicit BookmarkManagerWidget( QWidget *parent = nullptr ); - ~BookmarkManagerWidget(); + ~BookmarkManagerWidget() override; BookmarkTreeView * treeView(); private: QToolBar * m_toolBar; Amarok::LineEdit * m_searchEdit; BookmarkTreeView * m_bookmarkView; int m_currentBookmarkId; QString m_lastFilter; QSortFilterProxyModel * m_proxyModel; }; #endif diff --git a/src/browsers/BrowserBreadcrumbItem.h b/src/browsers/BrowserBreadcrumbItem.h index 81c6d9b73a..3de1bb1dbd 100644 --- a/src/browsers/BrowserBreadcrumbItem.h +++ b/src/browsers/BrowserBreadcrumbItem.h @@ -1,83 +1,83 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 BROWSERBREADCRUMBITEM_H #define BROWSERBREADCRUMBITEM_H #include "widgets/BoxWidget.h" #include class FileBrowser; class BrowserCategory; class BreadcrumbItemButton; class BreadcrumbItemMenuButton; struct BreadcrumbSibling { BreadcrumbSibling( const QIcon &icon_, const QString &name_, const QString &callback_ ) : icon( icon_ ), name( name_ ), callback( callback_ ) {} QIcon icon; QString name; QString callback; }; typedef QList BreadcrumbSiblingList; /** * A widget representing a single "breadcrumb" item * It has a mainButton and optionally a menuButton * * @author Nikolaj Hald Nielsen */ class BrowserBreadcrumbItem : public BoxWidget { Q_OBJECT public: explicit BrowserBreadcrumbItem( BrowserCategory* category, QWidget* parent = nullptr ); /** * Overloaded constructor for creating breadcrumb items not bound to a particular BrowserCategory */ BrowserBreadcrumbItem( const QString &name, const QString &callback, const BreadcrumbSiblingList &childItems, FileBrowser *handler, QWidget *parent = nullptr ); - ~BrowserBreadcrumbItem(); + ~BrowserBreadcrumbItem() override; void setActive( bool active ); QSizePolicy sizePolicy () const; int nominalWidth() const; Q_SIGNALS: void activated( const QString &callback ); protected Q_SLOTS: void updateSizePolicy(); void activate(); void activateSibling(); private: BreadcrumbItemMenuButton *m_menuButton; BreadcrumbItemButton *m_mainButton; QString m_callback; int m_nominalWidth; }; #endif diff --git a/src/browsers/BrowserCategory.h b/src/browsers/BrowserCategory.h index 3959010816..665c324c8b 100644 --- a/src/browsers/BrowserCategory.h +++ b/src/browsers/BrowserCategory.h @@ -1,180 +1,180 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 BROWSERCATEGORY_H #define BROWSERCATEGORY_H #include "amarok_export.h" #include "BrowserDefines.h" #include "widgets/BoxWidget.h" #include class BrowserBreadcrumbItem; class BrowserCategoryList; /** * The base class of browsers, services, categories or any other widget that can be inserted into a CategoryList * * @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT BrowserCategory : public BoxWidget { Q_OBJECT public: /** * Constructor. * * @param name The internal name of the category, used for generating Amarok urls. This should never be translated. * @param parent The parent widget. */ explicit BrowserCategory( const QString &name, QWidget *parent = nullptr ); /** * Destructor. */ - ~BrowserCategory(); + ~BrowserCategory() override; /** * Get the internal name of this category. * * @return The name. */ QString name() const; /** * Set the user visible name of this category * @param prettyName The user visible name. */ void setPrettyName( const QString &prettyName ); /** * Get the user visible name of this category. * @return The name of the service. */ virtual QString prettyName() const; /** * Set a short description string for this category. This string is used to describe the category in the category browser. * @param shortDescription The description. */ void setShortDescription( const QString &shortDescription ); /** * Get the short description of this category. * @return The short description. */ QString shortDescription() const; /** * Set a long description of the category. This is for allowing users to get more detailed info a about a category. * @param longDescription The long description. */ void setLongDescription( const QString &longDescription ); /** * Get the long description of this category. * @return The long description. */ QString longDescription() const; /** * Set the icon that will be used to identify this category. * @param icon The icon to use. */ void setIcon( const QIcon &icon ); /** * Get the icon of this category. * @return The icon */ QIcon icon() const; /** * Set the background image of this browser widget * * \param path Fully qualified path (e.g. looked up with KStandardDirs::locate) */ void setBackgroundImage( const QString &path ); /** * Set the path of the imaged used in the presentation of this category. * @param path The path of the image to use. */ void setImagePath( const QString &path ); /** * Get the path of the image used in the presentation of this category. * @return The path of the image. */ QString imagePath() const; BrowserCategoryList * parentList() const; void setParentList( BrowserCategoryList * parent ); /** * Returns an item that will be added to the breadcrumb widget * if this category is selected. * * The caller will have to free the returned item. */ BrowserBreadcrumbItem* breadcrumb(); virtual void polish() {} virtual void setupAddItems() {} //These 2 functions are forwarded to simplify the creation of urls //even though they might not be needed in many cases. virtual QString filter() const { return QString(); } virtual QList levels() const { return QList(); } virtual void setFilter( const QString &filter ) { Q_UNUSED( filter ) }; virtual void setLevels( const QList &levels ) { Q_UNUSED( levels ) }; /** * Add an additional category-specific item to breadcrumbs. This BrowserCategory * takes ownership of the item. */ void addAdditionalItem( BrowserBreadcrumbItem *item ); void clearAdditionalItems(); QList additionalItems(); public Q_SLOTS: void activate(); //Called if this category itself is re-clicked in the breadcrumb virtual void reActivate() {} private Q_SLOTS: void slotSettingsChanged(); private: QString m_name; QString m_prettyName; QString m_shortDescription; QString m_longDescription; QIcon m_icon; QString m_imagePath; BrowserCategoryList * m_parentList; QList m_additionalItems; }; #endif diff --git a/src/browsers/BrowserCategoryList.h b/src/browsers/BrowserCategoryList.h index 15275b77ed..686f7422eb 100644 --- a/src/browsers/BrowserCategoryList.h +++ b/src/browsers/BrowserCategoryList.h @@ -1,155 +1,155 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * 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 AMAROKBROWSERCATEGORYLIST_H #define AMAROKBROWSERCATEGORYLIST_H #include "BrowserCategory.h" #include "BrowserCategoryListModel.h" #include "BrowserCategoryListSortFilterProxyModel.h" #include namespace Amarok { class PrettyTreeView; } class SearchWidget; class QStackedWidget; /** * This is a browser category that can contain other sub-categories * The main (home/root) category is such a BrowserCategoryList * * @author Nikolaj Hald Nielsen */ class BrowserCategoryList : public BrowserCategory { Q_OBJECT public: /** * Constructor * @param parent The parent widget. * @param name The name of this widget. * @param sort Whether to sort the list. */ explicit BrowserCategoryList( const QString& name, QWidget* parent = nullptr, bool sort = false ); /** * Destructor. */ - ~BrowserCategoryList(); + ~BrowserCategoryList() override; /** * Get a map of the categories. * @return the map of categories. */ QMap categories(); BrowserCategory *activeCategory() const; /** * Show a category. Hide any other active category if needed. */ void setActiveCategory( BrowserCategory *category ); /** * Recursively navigate to a specific category. * @param target This is a / delimited string of category names. * This list will take the first category name, and if a child category with * this name exists, it will switch to it. If there are are more category names * in the target string, and the category activated is itself a category list, * it will strip the first category name and / from the targe string and pass * the rest to the navigate() method of the active category list. * * @return this method will navigate as far as the target makes sense. Any parts * of the target that does not match up with child categories will be returned * as this might be additional arguments that are usable elsewhere. */ QString navigate( const QString &target ); QString path(); BrowserCategory *activeCategoryRecursive(); Q_SIGNALS: void viewChanged(); public Q_SLOTS: /** * Add a category. * This category will take ownership of the new sub-category. * @param category The category to add. */ void addCategory( BrowserCategory *category ); /** * Remove a named category from the list and delete it. * @param category The category to remove. */ void removeCategory( BrowserCategory *category ); /** * Slot called when the active category should be hidden the category selection list shown again. */ void home(); /** * Slot called when the we need to move up one level. Forwarded to child lists as needed */ void back(); void childViewChanged(); private Q_SLOTS: /** Sets the current filter value and updates the content */ void setFilter( const QString &filter ) override; private: SearchWidget *m_searchWidget; QStackedWidget *m_widgetStack; Amarok::PrettyTreeView *m_categoryListView; QMap m_categories; BrowserCategoryListModel *m_categoryListModel; BrowserCategoryListSortFilterProxyModel* m_proxyModel; QString m_infoHtmlTemplate; bool m_sorting; private Q_SLOTS: /** * Slot called when an item in the list has been activated and the * corresponding category should be shown. * @param index The index that was activated */ void categoryActivated( const QModelIndex &index ); void categoryEntered( const QModelIndex &index ); QString css(); }; #endif diff --git a/src/browsers/BrowserCategoryListModel.h b/src/browsers/BrowserCategoryListModel.h index df665e2125..b382d9b5eb 100644 --- a/src/browsers/BrowserCategoryListModel.h +++ b/src/browsers/BrowserCategoryListModel.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 BROWSERCATEGORYLISTMODEL_H #define BROWSERCATEGORYLISTMODEL_H #include #include class BrowserCategory; Q_DECLARE_METATYPE( BrowserCategory * ) namespace CustomCategoryRoles { enum CustomCategoryRolesId { CategoryRole = Qt::UserRole + 31, }; } /** A very simple model to hold the available categories @author Nikolaj Hald Nielsen */ class BrowserCategoryListModel : public QAbstractListModel { public: explicit BrowserCategoryListModel( QObject *parent = nullptr ); - ~BrowserCategoryListModel(); + ~BrowserCategoryListModel() override; int rowCount( const QModelIndex & parent = QModelIndex() ) const override; QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override; /** * Adds a new sub-category to this list. * This object will take ownership of the new category. */ void addCategory( BrowserCategory* category ); void removeCategory( BrowserCategory* category ); private: QList m_categories; }; #endif diff --git a/src/browsers/BrowserCategoryListSortFilterProxyModel.h b/src/browsers/BrowserCategoryListSortFilterProxyModel.h index 508055cad6..c0532020c6 100644 --- a/src/browsers/BrowserCategoryListSortFilterProxyModel.h +++ b/src/browsers/BrowserCategoryListSortFilterProxyModel.h @@ -1,32 +1,32 @@ /**************************************************************************************** * Copyright (c) 2008 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 BROWSERCATEGORYLISTSORTFILTERPROXYMODEL_H #define BROWSERCATEGORYLISTSORTFILTERPROXYMODEL_H #include #include "core/meta/forward_declarations.h" class BrowserCategoryListSortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: explicit BrowserCategoryListSortFilterProxyModel( QObject * parent = nullptr ); - virtual ~BrowserCategoryListSortFilterProxyModel(); + ~BrowserCategoryListSortFilterProxyModel() override; }; #endif diff --git a/src/browsers/BrowserDock.h b/src/browsers/BrowserDock.h index e7fe653257..0a1610af53 100644 --- a/src/browsers/BrowserDock.h +++ b/src/browsers/BrowserDock.h @@ -1,57 +1,57 @@ /**************************************************************************************** * 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 BROWSERDOCK_H #define BROWSERDOCK_H #include "BrowserBreadcrumbWidget.h" #include "BrowserCategoryList.h" #include "BrowserMessageArea.h" #include "widgets/AmarokDockWidget.h" #include class BoxWidget; /** The base widget that contains all other browsers, organized in a dig down interface */ class BrowserDock : public AmarokDockWidget { Q_OBJECT public: explicit BrowserDock( QWidget *parent ); - ~BrowserDock(); + ~BrowserDock() override; BrowserCategoryList *list() const; void navigate( const QString &target ); void polish() override; private Q_SLOTS: void home(); void paletteChanged( const QPalette &palette ); private: BrowserBreadcrumbWidget *m_breadcrumbWidget; QPointer m_categoryList; BoxWidget *m_mainWidget; BrowserMessageArea *m_messageArea; }; #endif diff --git a/src/browsers/BrowserMessageArea.h b/src/browsers/BrowserMessageArea.h index 8d8cf9131a..aafa3c4eb2 100644 --- a/src/browsers/BrowserMessageArea.h +++ b/src/browsers/BrowserMessageArea.h @@ -1,69 +1,69 @@ /**************************************************************************************** * Copyright (c) 2011 Bart Cerneels . * ****************************************************************************************/ #ifndef BROWSERMESSAGEAREA_H #define BROWSERMESSAGEAREA_H #include "core/logger/Logger.h" #include "statusbar/CompoundProgressBar.h" #include "statusbar/KJobProgressBar.h" #include "statusbar/NetworkProgressBar.h" #include "widgets/BoxWidget.h" #include class BrowserMessageArea : public BoxWidget, public Amarok::Logger { Q_OBJECT public: explicit BrowserMessageArea( QWidget *parent ); - ~BrowserMessageArea() + ~BrowserMessageArea() override { } protected: /* Amarok::Logger virtual methods */ void shortMessageImpl( const QString &text ) override; void longMessageImpl( const QString &text, MessageType type ) override; - virtual void newProgressOperationImpl( KJob * job, const QString & text, QObject *context, + void newProgressOperationImpl( KJob * job, const QString & text, QObject *context, const std::function &function, Qt::ConnectionType type ) override; - virtual void newProgressOperationImpl( QNetworkReply *reply, const QString &text, QObject *obj, + void newProgressOperationImpl( QNetworkReply *reply, const QString &text, QObject *obj, const std::function &function, Qt::ConnectionType type ) override; - virtual void newProgressOperationImpl( QObject *sender, const QMetaMethod &increment, const QMetaMethod &end, const QString &text, + void newProgressOperationImpl( QObject *sender, const QMetaMethod &increment, const QMetaMethod &end, const QString &text, int maximum, QObject *obj, const std::function &function, Qt::ConnectionType type ) override; Q_SIGNALS: void signalLongMessage( const QString & text, MessageType type ); private Q_SLOTS: void hideProgress(); void nextShortMessage(); void slotLongMessage( const QString &text, MessageType type = Information ); private: CompoundProgressBar *m_progressBar; QLabel *m_messageLabel; bool m_busy; QTimer *m_shortMessageTimer; QList m_shortMessageQueue; }; #endif // BROWSERMESSAGEAREA_H diff --git a/src/browsers/CollectionSortFilterProxyModel.h b/src/browsers/CollectionSortFilterProxyModel.h index 345c9b4700..3f66471e94 100644 --- a/src/browsers/CollectionSortFilterProxyModel.h +++ b/src/browsers/CollectionSortFilterProxyModel.h @@ -1,58 +1,58 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2013 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 COLLECTIONSORTFILTERPROXYMODEL_H #define COLLECTIONSORTFILTERPROXYMODEL_H #include "core/meta/forward_declarations.h" #include class CollectionTreeItem; class QCollator; /** This is a custom QSortFilterProxyModel that gives special sort orders for our meta objects. e.g. it sorts tracks by disc number and track number. @author Nikolaj Hald Nielsen */ class CollectionSortFilterProxyModel : public QSortFilterProxyModel { public: explicit CollectionSortFilterProxyModel( QObject *parent = nullptr ); - virtual ~CollectionSortFilterProxyModel(); + ~CollectionSortFilterProxyModel() override; bool hasChildren(const QModelIndex &parent) const override; protected: bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override; bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const override; private: QCollator *m_col; CollectionTreeItem* treeItem( const QModelIndex &index ) const; bool lessThanTrack( const QModelIndex &left, const QModelIndex &right ) const; bool lessThanAlbum( const QModelIndex &left, const QModelIndex &right ) const; bool lessThanItem( const QModelIndex &left, const QModelIndex &right ) const; }; #endif diff --git a/src/browsers/CollectionTreeItem.h b/src/browsers/CollectionTreeItem.h index 20f9f5dfd7..16570a213f 100644 --- a/src/browsers/CollectionTreeItem.h +++ b/src/browsers/CollectionTreeItem.h @@ -1,136 +1,136 @@ /**************************************************************************************** * Copyright (c) 2007 Alexandre Pereira de Oliveira * * Copyright (c) 2007-2009 Maximilian Kossick * * * * 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 COLLECTIONTREEITEM_H #define COLLECTIONTREEITEM_H #include "amarok_export.h" #include "browsers/BrowserDefines.h" #include "core/collections/Collection.h" #include "core/meta/forward_declarations.h" #include class CollectionTreeItemModelBase; class QAction; class AMAROK_EXPORT CollectionTreeItem : public QObject { Q_OBJECT public: enum Type { Root, Collection, VariousArtist, NoLabel, Data }; Q_ENUM( Type ) explicit CollectionTreeItem( CollectionTreeItemModelBase *model ); //root node CollectionTreeItem( const Meta::DataPtr &data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //data node CollectionTreeItem( Collections::Collection *parentCollection, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //collection node //this ctor creates a "Various Artists" and "No Labels" nodes. do not use it for anything else CollectionTreeItem( Type type, const Meta::DataList &data, CollectionTreeItem *parent, CollectionTreeItemModelBase *model ); //various artist node - ~CollectionTreeItem(); + ~CollectionTreeItem() override; CollectionTreeItem* parent() const { return m_parent; } void appendChild( CollectionTreeItem *child ); void removeChild( int index ); CollectionTreeItem* child( int row ); int childCount() const { return m_childItems.count(); } int columnCount() const { return 1; } QList children() const; QVariant data( int role ) const; int row() const; int level() const; bool isDataItem() const; bool isAlbumItem() const; bool isTrackItem() const; bool isVariousArtistItem() const; bool isNoLabelItem() const; Collections::QueryMaker* queryMaker() const; /** * Call addMatch for this objects data and it's query maker. Handles VariousArtist * item and NoLabel item, too. * * @param qm QueryMaker to add match to * @param levelCategory category for level this item is in, one of the values from * CategoryId::CatMenuId enum. Used only for distinction between Artist and * AlbumArtist. */ void addMatch( Collections::QueryMaker *qm, CategoryId::CatMenuId levelCategory ) const; bool operator<( const CollectionTreeItem &other ) const; const Meta::DataPtr data() const; Collections::Collection* parentCollection() const { return m_parentCollection ? m_parentCollection : (m_parent ? m_parent->parentCollection() : 0); } QList urls() const; Meta::TrackList descendentTracks(); bool allDescendentTracksLoaded() const; //required to mark a tree item as dirty if the model has to require its children Type type() const; bool requiresUpdate() const; void setRequiresUpdate( bool updateRequired ); Q_SIGNALS: void dataUpdated(); private Q_SLOTS: void tracksCounted( QStringList res ); void collectionUpdated(); private: /** Returns a list of collection actions. Collection actions are shown on top of the collection tree item as icons (decorations) */ QList decoratorActions() const; void prepareForRemoval(); Meta::DataPtr m_data; CollectionTreeItem *m_parent; CollectionTreeItemModelBase *m_model; Collections::Collection *m_parentCollection; QList m_childItems; bool m_updateRequired; int m_trackCount; Type m_type; //QString m_name; mutable bool m_isCounting; }; Q_DECLARE_METATYPE( CollectionTreeItem* ) Q_DECLARE_METATYPE( QList ) #endif diff --git a/src/browsers/CollectionTreeItemModelBase.h b/src/browsers/CollectionTreeItemModelBase.h index 2be337e121..5a6378193a 100644 --- a/src/browsers/CollectionTreeItemModelBase.h +++ b/src/browsers/CollectionTreeItemModelBase.h @@ -1,209 +1,209 @@ /**************************************************************************************** * Copyright (c) 2007 Alexandre Pereira de Oliveira * * Copyright (c) 2007-2009 Maximilian Kossick * * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 COLLECTIONTREEITEMMODELBASE_H #define COLLECTIONTREEITEMMODELBASE_H #include "amarok_export.h" #include "core/collections/QueryMaker.h" #include "core/meta/forward_declarations.h" #include "CollectionTreeItem.h" #include #include #include #include #include #include namespace Collections { class Collection; } class CollectionTreeItem; class QTimeLine; class TrackLoaderJob; typedef QPair CollectionRoot; /** @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT CollectionTreeItemModelBase : public QAbstractItemModel { Q_OBJECT friend class TrackLoaderJob; public: CollectionTreeItemModelBase(); - virtual ~CollectionTreeItemModelBase(); + ~CollectionTreeItemModelBase() override; Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const override; // Writable.. bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override; QStringList mimeTypes() const override; QMimeData* mimeData( const QModelIndexList &indices ) const override; virtual QMimeData* mimeData( const QList &items ) const; virtual void listForLevel( int level, Collections::QueryMaker *qm, CollectionTreeItem* parent ); virtual void setLevels( const QList &levelType ); virtual QList levels() const { return m_levelType; } virtual CategoryId::CatMenuId levelCategory( const int level ) const; QString currentFilter() const; void setCurrentFilter( const QString &filter ); void itemAboutToBeDeleted( CollectionTreeItem *item ); /** * This should be called every time a drag enters collection browser */ void setDragSourceCollections( const QSet &collections ); /** * Return true if there are any queries still running. If this returns true, * you can expect allQueriesFinished(bool) signal in some time. */ bool hasRunningQueries() const; static QIcon iconForCategory( CategoryId::CatMenuId category ); static QString nameForCategory( CategoryId::CatMenuId category, bool showYears = false ); void ensureChildrenLoaded( CollectionTreeItem *item ); /** * Get a pointer to collection tree item given its index. It is not safe to * cache this pointer unless QPointer is used. */ CollectionTreeItem *treeItem( const QModelIndex &index ) const; /** * Get (create) index for a collection tree item. The caller must ensure this * item is in this model. Invalid model index is returned on null or root item. */ QModelIndex itemIndex( CollectionTreeItem *item ) const; Q_SIGNALS: void expandIndex( const QModelIndex &index ); void allQueriesFinished( bool autoExpand ); public Q_SLOTS: virtual void queryDone(); void newTracksReady( const Meta::TrackList &); void newArtistsReady( const Meta::ArtistList &); void newAlbumsReady( const Meta::AlbumList &); void newGenresReady( const Meta::GenreList &); void newComposersReady( const Meta::ComposerList &); void newYearsReady( const Meta::YearList &); void newLabelsReady( const Meta::LabelList &); virtual void newDataReady( const Meta::DataList &data ); /** * Apply the current filter. * * @param autoExpand whether to trigger automatic expansion of the tree after * filtering is done. This should be set to true only if filter is run after * user has actually just typed something and defaults to false. */ void slotFilter( bool autoExpand = false ); void slotFilterWithoutAutoExpand() { slotFilter( false ); } void slotCollapsed( const QModelIndex &index ); void slotExpanded( const QModelIndex &index ); private: void handleSpecialQueryResult( CollectionTreeItem::Type type, Collections::QueryMaker *qm, const Meta::DataList &dataList ); void handleNormalQueryResult( Collections::QueryMaker *qm, const Meta::DataList &dataList ); Collections::QueryMaker::QueryType mapCategoryToQueryType( int levelType ) const; void tracksLoaded( const Meta::AlbumPtr &album, const QModelIndex &index, const Meta::TrackList &tracks ); QHash m_years; mutable QSet m_loadingAlbums; protected: /** Adds the query maker to the running queries and connects the slots */ void addQueryMaker( CollectionTreeItem* item, Collections::QueryMaker *qm ) const; virtual void populateChildren(const Meta::DataList &dataList, CollectionTreeItem *parent, const QModelIndex &parentIndex ); virtual void updateHeaderText(); virtual QIcon iconForLevel( int level ) const; virtual QString nameForLevel( int level ) const; virtual int levelModifier() const = 0; virtual QVariant dataForItem( CollectionTreeItem *item, int role, int level = -1 ) const; virtual void filterChildren() = 0; void markSubTreeAsDirty( CollectionTreeItem *item ); /** Initiates a special search for albums without artists */ void handleCompilations( Collections::QueryMaker::QueryType queryType, CollectionTreeItem *parent ) const; /** Initiates a special search for tracks without label */ void handleTracksWithoutLabels( Collections::QueryMaker::QueryType queryType, CollectionTreeItem *parent ) const; QString m_headerText; CollectionTreeItem *m_rootItem; QList m_levelType; QTimeLine *m_timeLine; int m_animFrame; QPixmap m_loading1, m_loading2, m_currentAnimPixmap; //icons for loading animation QString m_currentFilter; QSet m_expandedItems; QSet m_expandedCollections; QSet m_expandedSpecialNodes; /** * Contents of this set are undefined if there is no active drag 'n drop operation. * Additionally, you may _never_ dereference pointers in this set, just compare * them with other pointers */ QSet m_dragSourceCollections; QHash m_collections; //I'll concide this one... :-) mutable QHash m_childQueries; mutable QHash m_compilationQueries; mutable QHash m_noLabelsQueries; mutable QMultiHash m_runningQueries; bool m_autoExpand; // whether to expand tree after queries are done protected Q_SLOTS: void startAnimationTick(); void loadingAnimationTick(); }; #endif diff --git a/src/browsers/CollectionTreeView.h b/src/browsers/CollectionTreeView.h index 1bfe013117..bf2ac25a2d 100644 --- a/src/browsers/CollectionTreeView.h +++ b/src/browsers/CollectionTreeView.h @@ -1,166 +1,166 @@ /**************************************************************************************** * Copyright (c) 2007 Alexandre Pereira de Oliveira * * * * 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 COLLECTIONTREEVIEW_H #define COLLECTIONTREEVIEW_H #include "amarok_export.h" #include "BrowserDefines.h" #include "widgets/PrettyTreeView.h" #include "browsers/CollectionTreeItem.h" #include "core/meta/forward_declarations.h" #include "playlist/PlaylistController.h" #include #include #include #include class AmarokMimeData; class CollectionSortFilterProxyModel; class CollectionTreeItemModelBase; class PopupDropper; namespace Collections { class Collection; class QueryMaker; } class QAction; class QSortFilterProxyModel; typedef QList QActionList; class AMAROK_EXPORT CollectionTreeView : public Amarok::PrettyTreeView { Q_OBJECT public: explicit CollectionTreeView( QWidget *parent = nullptr ); - ~CollectionTreeView(); + ~CollectionTreeView() override; QSortFilterProxyModel* filterModel() const; void setLevels( const QList &levels ); QList levels() const; void setLevel( int level, CategoryId::CatMenuId type ); void setModel( QAbstractItemModel *model ) override; //Helper function to remove children if their parent is already present static QSet cleanItemSet( const QSet &items ); static bool onlyOneCollection( const QModelIndexList &indices ); static Collections::Collection *getCollection( const QModelIndex &index ); Collections::QueryMaker* createMetaQueryFromItems( const QSet &items, bool cleanItems=true ) const; /** * Copies all selected tracks to the local collection. The user can also * choose to do on-the-fly transcoding. */ void copySelectedToLocalCollection(); public Q_SLOTS: void slotSetFilter( const QString &filter ); /** * This should append all currently visible tracks to the playlist. Takes * care to ensure that the tracks are added only after any pending searches * are finished. */ void slotAddFilteredTracksToPlaylist(); void playChildTracksSlot( Meta::TrackList list ); Q_SIGNALS: /** * This signal is emitted when slotAddFilteredTracksToPlaylist() has done its * work. */ void addingFilteredTracksDone(); protected: void contextMenuEvent( QContextMenuEvent *event ) override; void mouseDoubleClickEvent( QMouseEvent *event ) override; void mouseReleaseEvent( QMouseEvent *event ) override; void keyPressEvent( QKeyEvent *event ) override; void dragEnterEvent( QDragEnterEvent *event ) override; void dragMoveEvent( QDragMoveEvent *event ) override; void startDrag( Qt::DropActions supportedActions ) override; protected Q_SLOTS: void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) override; void slotCollapsed( const QModelIndex &index ); void slotExpanded( const QModelIndex &index ); void slotExpandIndex( const QModelIndex &index ); void slotCheckAutoExpand( bool reallyExpand = true ); void slotCheckAutoExpandReally() { slotCheckAutoExpand( true ); } void slotReplacePlaylistWithChildTracks(); void slotAppendChildTracks(); void slotQueueChildTracks(); void slotEditTracks(); void slotCopyTracks(); void slotMoveTracks(); void slotTrashTracks(); void slotDeleteTracks(); void slotOrganize(); private: // Utility function to play all items // that have this as a parent.. void playChildTracks( CollectionTreeItem *item, Playlist::AddOptions insertMode ); void playChildTracks( const QSet &items, Playlist::AddOptions insertMode ); void editTracks( const QSet &items ) const; void organizeTracks( const QSet &items ) const; void copyTracks( const QSet &items, Collections::Collection *destination, bool removeSources) const; void removeTracks( const QSet &items, bool useTrash ) const; // creates different actions from the different objects. // note: you should not delete the created actions. QActionList createBasicActions( const QModelIndexList &indices ); QActionList createExtendedActions( const QModelIndexList &indices ); QActionList createCollectionActions( const QModelIndexList &indices ); QActionList createCustomActions( const QModelIndexList &indices ); QHash getCopyActions( const QModelIndexList &indices ); QHash getMoveActions( const QModelIndexList &indices ); CollectionTreeItem* getItemFromIndex( QModelIndex &index ); CollectionSortFilterProxyModel *m_filterModel; CollectionTreeItemModelBase *m_treeModel; PopupDropper* m_pd; QAction* m_appendAction; QAction* m_loadAction; QAction* m_editAction; QAction* m_organizeAction; QHash m_currentCopyDestination; QHash m_currentMoveDestination; QMap m_playChildTracksMode; QSet m_currentItems; bool m_ongoingDrag; Q_SIGNALS: void itemSelected( CollectionTreeItem * item ); void leavingTree(); }; #endif diff --git a/src/browsers/collectionbrowser/CollectionBrowserTreeView.h b/src/browsers/collectionbrowser/CollectionBrowserTreeView.h index a27807b0bc..383ddf20b4 100644 --- a/src/browsers/collectionbrowser/CollectionBrowserTreeView.h +++ b/src/browsers/collectionbrowser/CollectionBrowserTreeView.h @@ -1,33 +1,33 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * Copyright (c) 2009 Seb Ruiz * * * * 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 COLLECTIONBROWSERTREEVIEW_H #define COLLECTIONBROWSERTREEVIEW_H #include "browsers/CollectionTreeView.h" /** * Specialized CollectionTreeView that handles actions to top level items ( collections ) in a custom way. */ class CollectionBrowserTreeView : public CollectionTreeView { public: explicit CollectionBrowserTreeView( QWidget *parent = nullptr ); - ~CollectionBrowserTreeView(); + ~CollectionBrowserTreeView() override; }; #endif diff --git a/src/browsers/filebrowser/FileBrowser_p.h b/src/browsers/filebrowser/FileBrowser_p.h index 27edd30d22..ed851df15c 100644 --- a/src/browsers/filebrowser/FileBrowser_p.h +++ b/src/browsers/filebrowser/FileBrowser_p.h @@ -1,138 +1,138 @@ /**************************************************************************************** * Copyright (c) 2010 Nikolaj Hald Nielsen * * Copyright (c) 2010 Casey Link * * Copyright (c) 2010 Téo Mrnjavac * * Copyright (c) 2010 Rick W. Chen * * * * 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_FILEBROWSER_P_H #define AMAROK_FILEBROWSER_P_H #include "FileBrowser.h" #include "browsers/BrowserBreadcrumbItem.h" #include #include #include #include #include class QSortFilterProxyModel; class DirBrowserModel; class SearchWidget; class FileView; class QAction; class KFilePlacesModel; class DirPlaylistTrackFilterProxyModel; template class UniqueStack : public QStack { public: inline void push( const T &t ) { if( QStack::isEmpty() || t != QStack::top() ) QStack::push( t ); } }; class FileBrowser::Private { public: Private( FileBrowser *parent ); ~Private(); void readConfig(); void writeConfig(); void restoreHeaderState(); void saveHeaderState(); void updateNavigateActions(); BreadcrumbSiblingList siblingsForDir( const QUrl &path ); void updateHeaderState(); QList columnActions; //!< Maintains the mapping action<->column KFilePlacesModel *bottomPlacesModel; QSortFilterProxyModel *placesModel; DirBrowserModel *kdirModel; DirPlaylistTrackFilterProxyModel *mimeFilterProxyModel; SearchWidget *searchWidget; QUrl currentPath; FileView *fileView; QAction *upAction; QAction *homeAction; QAction *refreshAction; QAction *backAction; QAction *forwardAction; UniqueStack backStack; UniqueStack forwardStack; private: void restoreDefaultHeaderState(); FileBrowser *const q; }; class DirBrowserModel : public KDirModel { Q_OBJECT public: explicit DirBrowserModel( QObject *parent = nullptr ) : KDirModel( parent ) { } - virtual ~DirBrowserModel() {} + ~DirBrowserModel() override {} QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override { if( role == Qt::SizeHintRole ) return QSize( 1, QFontMetrics( QFont() ).height() + 4 ); else return KDirModel::data( index, role ); } }; class FilePlacesModel : public KFilePlacesModel { Q_OBJECT public: explicit FilePlacesModel( QObject *parent = nullptr ) : KFilePlacesModel( parent ) { } - virtual ~FilePlacesModel() {} + ~FilePlacesModel() override {} QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override { if( role == Qt::SizeHintRole ) return QSize( 1, QFontMetrics( QFont() ).height() + 4 ); else return KFilePlacesModel::data( index, role ); } }; #endif /* AMAROK_FILEBROWSER_P_H */ diff --git a/src/browsers/playlistbrowser/APGCategory.h b/src/browsers/playlistbrowser/APGCategory.h index cf710edcec..560b174451 100644 --- a/src/browsers/playlistbrowser/APGCategory.h +++ b/src/browsers/playlistbrowser/APGCategory.h @@ -1,49 +1,49 @@ /**************************************************************************************** * Copyright (c) 2008-2011 Soren Harward * * * * 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 APGCATEGORY_H #define APGCATEGORY_H #include "browsers/BrowserCategory.h" #include namespace PlaylistBrowserNS { /* Playlist Browser toolbox item for the Automatic Playlist Generator */ class APGCategory : public BrowserCategory { Q_OBJECT public: explicit APGCategory( QWidget* parent ); - ~APGCategory(); + ~APGCategory() override; Q_SIGNALS: void validIndexSelected( bool ); private Q_SLOTS: void activeChanged( const QModelIndex& ); void setQualityFactor( int ); void runGenerator(); private: int m_qualityFactor; }; } #endif diff --git a/src/browsers/playlistbrowser/DynamicCategory.h b/src/browsers/playlistbrowser/DynamicCategory.h index 95b7ad3318..64aa5622d1 100644 --- a/src/browsers/playlistbrowser/DynamicCategory.h +++ b/src/browsers/playlistbrowser/DynamicCategory.h @@ -1,67 +1,67 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Jones * * Copyright (c) 2009-2010 Leo Franchi * * 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 DYNAMICCATEGORY_H #define DYNAMICCATEGORY_H #include "browsers/BrowserCategory.h" class QPushButton; class QToolButton; class QSpinBox; namespace PlaylistBrowserNS { class DynamicView; /** */ class DynamicCategory : public BrowserCategory { Q_OBJECT public: explicit DynamicCategory( QWidget* parent ); - ~DynamicCategory(); + ~DynamicCategory() override; bool allowDuplicates() const; private Q_SLOTS: void navigatorChanged(); void selectionChanged(); void playlistCleared(); void setUpcomingTracks( int ); void setPreviousTracks( int ); void setAllowDuplicates( bool value ); private: QToolButton *m_onOffButton; QToolButton *m_duplicateButton; QToolButton *m_addButton; QToolButton *m_editButton; QToolButton *m_deleteButton; QPushButton *m_repopulateButton; DynamicView *m_tree; QSpinBox *m_previous, *m_upcoming; }; } #endif diff --git a/src/browsers/playlistbrowser/PlaylistBrowser.h b/src/browsers/playlistbrowser/PlaylistBrowser.h index b60b7aec1a..7baf5ccbe9 100644 --- a/src/browsers/playlistbrowser/PlaylistBrowser.h +++ b/src/browsers/playlistbrowser/PlaylistBrowser.h @@ -1,43 +1,43 @@ /**************************************************************************************** * Copyright (c) 2007 Bart Cerneels * * * * 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 PLAYLISTBROWSERNSPLAYLISTBROWSER_H #define PLAYLISTBROWSERNSPLAYLISTBROWSER_H #include "browsers/BrowserCategoryList.h" #include namespace PlaylistBrowserNS { /** @author Bart Cerneels */ class PlaylistBrowser : public BrowserCategoryList { Q_OBJECT public: explicit PlaylistBrowser( const QString &name, QWidget *parent = nullptr ); - ~PlaylistBrowser(); + ~PlaylistBrowser() override; private: QMap m_categoryIndexMap; }; } #endif diff --git a/src/browsers/playlistbrowser/PlaylistBrowserCategory.h b/src/browsers/playlistbrowser/PlaylistBrowserCategory.h index 165a3c7280..a2393cbf0c 100644 --- a/src/browsers/playlistbrowser/PlaylistBrowserCategory.h +++ b/src/browsers/playlistbrowser/PlaylistBrowserCategory.h @@ -1,128 +1,128 @@ /**************************************************************************************** * Copyright (c) 2009-2010 Bart Cerneels * * * * 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 PLAYLISTBROWSERCATEGORY_H #define PLAYLISTBROWSERCATEGORY_H #include "browsers/BrowserCategory.h" #include #include namespace Amarok { class PrettyTreeView; } class QAbstractItemDelegate; class QTreeView; class QAction; class KActionMenu; class KToolBar; class PlaylistsInFoldersProxy; class PlaylistsByProviderProxy; class PlaylistBrowserFilterProxy; namespace Playlists { class PlaylistProvider; } namespace PlaylistBrowserNS { class PlaylistBrowserModel; class PlaylistBrowserCategory : public BrowserCategory { Q_OBJECT public: static QString s_mergeViewKey; explicit PlaylistBrowserCategory( int playlistCategory, const QString &categoryName, const QString &configGroup, PlaylistBrowserModel *model, QWidget *parent ); - ~PlaylistBrowserCategory(); + ~PlaylistBrowserCategory() override; QString filter() const override; void setFilter( const QString &filter ) override; /** * Sets the help text for the action. * This help text will be set for all help mechanisms: * - the status-bar help text * - the tooltip (for toolbar buttons) * - the "WhatsThis" help text (unless one was already set) * * This is more convenient than calling all three methods with the * same text, and this level of abstraction can allow to change * the default implementation of help one day more easily. * Of course you can also call setStatusTip, setToolTip and setWhatsThis * separately for more flexibility. * */ void setHelpText(const QString &text, QAction *qa); protected: KToolBar *m_toolBar; /** * A separator in between the add-folder action and visible-source, * merged-view actions. Subclasses can use it to insert their specialized * actions at a suitable place, thus keeping the generic actions in order. */ QAction *m_separator; QTreeView *playlistView(); private Q_SLOTS: void toggleView( bool mergedView ); void slotProviderAdded( Playlists::PlaylistProvider *provider, int category ); void slotProviderRemoved( Playlists::PlaylistProvider *provider, int category ); void slotToggleProviderButton(); void createNewFolder(); void newPalette( const QPalette &palette ); private: void createProviderButton( const Playlists::PlaylistProvider *provider ); KActionMenu *m_providerMenu; QMap m_providerActions; Amarok::PrettyTreeView *m_playlistView; QAction *m_addFolderAction; QAbstractItemDelegate *m_byProviderDelegate; QAbstractItemDelegate *m_defaultItemDelegate; PlaylistsInFoldersProxy *m_byFolderProxy; PlaylistsByProviderProxy *m_byProviderProxy; PlaylistBrowserFilterProxy *m_filterProxy; QString m_configGroup; int m_playlistCategory; }; } //namespace PlaylistBrowserNS //for saving it in a QVariant Q_DECLARE_METATYPE( const Playlists::PlaylistProvider * ) #endif // PLAYLISTBROWSERCATEGORY_H diff --git a/src/browsers/playlistbrowser/PodcastCategory.h b/src/browsers/playlistbrowser/PodcastCategory.h index f641222594..8e972d7607 100644 --- a/src/browsers/playlistbrowser/PodcastCategory.h +++ b/src/browsers/playlistbrowser/PodcastCategory.h @@ -1,55 +1,55 @@ /**************************************************************************************** * Copyright (c) 2007-2010 Bart Cerneels * * * * 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 PODCASTCATEGORY_H #define PODCASTCATEGORY_H #include "PlaylistBrowserCategory.h" class QModelIndex; namespace PlaylistBrowserNS { /** @author Bart Cerneels */ class PodcastCategory : public PlaylistBrowserCategory { Q_OBJECT public: static PodcastCategory *instance(); static void destroy(); private: static PodcastCategory* s_instance; static QString s_configGroup; static QString s_mergedViewKey; explicit PodcastCategory( QWidget *parent ); - ~PodcastCategory(); + ~PodcastCategory() override; private Q_SLOTS: void showInfo( const QModelIndex &index ); void slotImportOpml(); }; } // namespace PlaylistBrowserNS namespace The { PlaylistBrowserNS::PodcastCategory *podcastCategory(); } #endif diff --git a/src/browsers/playlistbrowser/UserPlaylistCategory.h b/src/browsers/playlistbrowser/UserPlaylistCategory.h index 07ae92836b..8ace9f62ab 100644 --- a/src/browsers/playlistbrowser/UserPlaylistCategory.h +++ b/src/browsers/playlistbrowser/UserPlaylistCategory.h @@ -1,48 +1,48 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 USERPLAYLISTCATEGORY_H #define USERPLAYLISTCATEGORY_H #include "PlaylistBrowserCategory.h" #include #include #include #include namespace PlaylistBrowserNS { /** The widget that displays playlists in the playlist browser @author Nikolaj Hald Nielsen */ class UserPlaylistCategory : public PlaylistBrowserCategory { Q_OBJECT public: static QString s_configGroup; explicit UserPlaylistCategory( QWidget *parent ); - ~UserPlaylistCategory(); + ~UserPlaylistCategory() override; }; } #endif //USERPLAYLISTCATEGORY_H diff --git a/src/browsers/servicebrowser/ServiceBrowser.h b/src/browsers/servicebrowser/ServiceBrowser.h index a853730cae..9190dad652 100644 --- a/src/browsers/servicebrowser/ServiceBrowser.h +++ b/src/browsers/servicebrowser/ServiceBrowser.h @@ -1,92 +1,92 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMAROKSERVICEBROWSER_H #define AMAROKSERVICEBROWSER_H #include "browsers/BrowserCategoryList.h" #include "services/scriptable/ScriptableServiceManager.h" #include "services/ServiceBase.h" #include #include #include #include /** * A browser for selecting and displaying a service in the style of the first * embedded Magnatune store from a list of available services. Allows * many services to be shown as a single category. * Implemented as a singleton. * * @author Nikolaj Hald Nielsen */ class ServiceBrowser : public BrowserCategoryList { Q_OBJECT public: /** * Get the ServiceBrowser instance. Create it if it does not exist yet. ( Singleton pattern ). * @return The ServiceBrowser instance. */ static ServiceBrowser *instance(); /** * Destructor. */ - ~ServiceBrowser(); + ~ServiceBrowser() override; /** * Reset a service and make it reload configuration. Not fully implemented.. * @param name The name of the service to reset. */ void resetService( const QString &name ); public Q_SLOTS: /** * Set a scriptable service manager to handle scripted services. * @param scriptableServiceManager The scriptable service manager to set. */ void setScriptableServiceManager( ScriptableServiceManager *scriptableServiceManager ); void addService ( ServiceBase * ); private: /** * Private constructor ( Singleton pattern ) * @param parent The parent widget. * @param name The name of this widget. */ ServiceBrowser( const QString& name, QWidget *parent = nullptr ); static ServiceBrowser *s_instance; ScriptableServiceManager *m_scriptableServiceManager; QTimer m_filterTimer; QString m_currentFilter; }; #endif diff --git a/src/configdialog/dialogs/CollectionConfig.h b/src/configdialog/dialogs/CollectionConfig.h index c6fa3d224f..ed3d828fb0 100644 --- a/src/configdialog/dialogs/CollectionConfig.h +++ b/src/configdialog/dialogs/CollectionConfig.h @@ -1,44 +1,44 @@ /**************************************************************************************** * Copyright (c) 2004-2007 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 COLLECTIONCONFIG_H #define COLLECTIONCONFIG_H #include "configdialog/ConfigDialogBase.h" class CollectionSetup; class CollectionConfig : public ConfigDialogBase { Q_OBJECT public: explicit CollectionConfig( Amarok2ConfigDialog* parent ); - virtual ~CollectionConfig(); + ~CollectionConfig() override; bool hasChanged() override; bool isDefault() override; void updateSettings() override; private: CollectionSetup* m_collectionSetup; }; #endif diff --git a/src/configdialog/dialogs/DatabaseConfig.h b/src/configdialog/dialogs/DatabaseConfig.h index 8bfa6706c1..47e4b79605 100644 --- a/src/configdialog/dialogs/DatabaseConfig.h +++ b/src/configdialog/dialogs/DatabaseConfig.h @@ -1,60 +1,60 @@ /**************************************************************************************** * Copyright (c) 2009 John Atkinson * * * * 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 Pulic License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef DATABASECONFIG_H #define DATABASECONFIG_H #include "ui_DatabaseConfig.h" #include "configdialog/ConfigDialogBase.h" class KConfigDialogManager; class KConfigSkeleton; class DatabaseConfig : public ConfigDialogBase, public Ui_DatabaseConfig { Q_OBJECT public: DatabaseConfig( Amarok2ConfigDialog* parent, KConfigSkeleton *config ); - virtual ~DatabaseConfig(); + ~DatabaseConfig() override; bool hasChanged() override; bool isDefault() override; void updateSettings() override; public Q_SLOTS: void toggleExternalConfigAvailable( int checkBoxState ); void testDatabaseConnection(); private Q_SLOTS: void updateSQLQuery(); private: /** Returns true if the configuration is complete. * * Complete menas that the database, user and host are filled out. */ bool isSQLInfoPresent() const; KConfigDialogManager* m_configManager; }; #endif diff --git a/src/configdialog/dialogs/GeneralConfig.h b/src/configdialog/dialogs/GeneralConfig.h index f6e5a38e79..b8c37f8d82 100644 --- a/src/configdialog/dialogs/GeneralConfig.h +++ b/src/configdialog/dialogs/GeneralConfig.h @@ -1,36 +1,36 @@ /**************************************************************************************** * Copyright (c) 2004-2007 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 GENERALCONFIG_H #define GENERALCONFIG_H #include "ui_GeneralConfig.h" #include "configdialog/ConfigDialogBase.h" class GeneralConfig : public ConfigDialogBase, public Ui_GeneralConfig { Q_OBJECT public: explicit GeneralConfig( Amarok2ConfigDialog* parent ); - virtual ~GeneralConfig(); + ~GeneralConfig() override; bool hasChanged() override; bool isDefault() override; void updateSettings() override; }; #endif diff --git a/src/configdialog/dialogs/NotificationsConfig.h b/src/configdialog/dialogs/NotificationsConfig.h index 2aaed2db69..9eab7b6c58 100644 --- a/src/configdialog/dialogs/NotificationsConfig.h +++ b/src/configdialog/dialogs/NotificationsConfig.h @@ -1,57 +1,57 @@ /**************************************************************************************** * Copyright (c) 2004-2007 Mark Kretschmann * * Copyright (c) 2004 Frederik Holljen * * * * 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 NOTIFICATIONSCONFIG_H #define NOTIFICATIONSCONFIG_H #include "ui_NotificationsConfig.h" #include "configdialog/ConfigDialogBase.h" #include "widgets/Osd.h" class OSDPreviewWidget; class NotificationsConfig : public ConfigDialogBase, public Ui_NotificationsConfig { Q_OBJECT public: explicit NotificationsConfig( Amarok2ConfigDialog* parent ); - virtual ~NotificationsConfig(); + ~NotificationsConfig() override; bool hasChanged() override; bool isDefault() override; void updateSettings() override; Q_SIGNALS: void changed(); private Q_SLOTS: void slotPositionChanged(); void useCustomColorsToggled( bool ); void setGrowlEnabled( bool ); private: OSDPreviewWidget* m_osdPreview; OSDWidget::Alignment m_oldAlignment; uint m_oldYOffset; void hideEvent( QHideEvent* ) override; void showEvent( QShowEvent* ) override; }; #endif diff --git a/src/configdialog/dialogs/ScriptSelector.h b/src/configdialog/dialogs/ScriptSelector.h index 480a86306d..e6cba1b704 100644 --- a/src/configdialog/dialogs/ScriptSelector.h +++ b/src/configdialog/dialogs/ScriptSelector.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2008 Peter ZHOU * * * * 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 SCRIPTSELECTOR_H #define SCRIPTSELECTOR_H #include #include class KCategorizedView; class QLineEdit; class KPluginInfo; class ScriptSelector : public KPluginSelector { Q_OBJECT public: explicit ScriptSelector( QWidget * parent ); - ~ScriptSelector(); + ~ScriptSelector() override; QString currentItem() const; void addScripts( QList pluginInfoList, PluginLoadMethod pluginLoadMethod = ReadConfigFile, const QString &categoryName = QString(), const QString &categoryKey = QString(), const KSharedConfig::Ptr &config = KSharedConfig::Ptr() ); int verticalPosition(); void setVerticalPosition( int position ); QString filter(); void setFilter( const QString &filter ); private: KCategorizedView *m_listView; QMap m_scripts; int m_scriptCount; QLineEdit *m_lineEdit; private Q_SLOTS: void slotFiltered( const QString &filter ); Q_SIGNALS: void filtered(bool); }; #endif diff --git a/src/context/AppletLoader.h b/src/context/AppletLoader.h index aeed8f76f2..cb3bef0366 100644 --- a/src/context/AppletLoader.h +++ b/src/context/AppletLoader.h @@ -1,49 +1,49 @@ /**************************************************************************************** * Copyright (c) 2017 Malte Veerman * * * * 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 APPLETLOADER_H #define APPLETLOADER_H #include #include class KPluginMetaData; namespace Context { class AppletLoader : public QObject { Q_OBJECT public: explicit AppletLoader(QObject *parent = nullptr); - ~AppletLoader(); + ~AppletLoader() override; QList applets() const; QList enabledApplets() const; void findApplets(); Q_SIGNALS: void finished(const QList&); private: QList m_applets; }; } #endif // APPLETLOADER_H diff --git a/src/context/ContextView.h b/src/context/ContextView.h index 90549b9e64..121b2a9333 100644 --- a/src/context/ContextView.h +++ b/src/context/ContextView.h @@ -1,91 +1,91 @@ /**************************************************************************************** * Copyright (c) 2007 Leo Franchi * * Copyright (c) 2008 William Viana Soares * * * * 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 . * ****************************************************************************************/ /* Significant parts of this code is inspired and/or copied from KDE Plasma sources, available at kdebase/workspace/libs/plasma */ #ifndef AMAROK_CONTEXT_VIEW_H #define AMAROK_CONTEXT_VIEW_H #include "amarok_export.h" #include class ContextUrlRunner; class QPalette; namespace Context { class AppletLoader; class AppletModel; class AppletProxyModel; class AMAROK_EXPORT ContextView : public QQuickWidget { Q_OBJECT public: explicit ContextView( QWidget *parent = nullptr ); - ~ContextView(); + ~ContextView() override; /** * Singleton pattern accessor. May return 0 if the view was not yet constructed. */ static ContextView *self() { return s_self; } /** * Get the plugin names, in order, of the applets currently in the contextView. */ QStringList currentApplets() const; /** * Get the user visible applet names, in order, of the applets currently in the contextView. */ QStringList currentAppletNames() const; /** * Get the Context::AppletModel instance in use. * It can be used to show, hide enable or disable applets among other things. */ AppletProxyModel *appletModel() const { return m_proxyModel; } Q_INVOKABLE void runLink( const QUrl &link ) const; Q_INVOKABLE void debug( const QString &error ) const; Q_INVOKABLE void warning( const QString &error ) const; Q_INVOKABLE void error( const QString &error ) const; private Q_SLOTS: void slotStatusChanged( QQuickWidget::Status status ); void updatePalette( const QPalette &palette ); private: static ContextView *s_self; ContextUrlRunner *m_urlRunner; AppletLoader *m_loader; AppletModel *m_appletModel; AppletProxyModel *m_proxyModel; }; } // Context namespace #endif diff --git a/src/context/applets/albums/plugin/AlbumsModel.h b/src/context/applets/albums/plugin/AlbumsModel.h index 84afbd03da..3a3bf65653 100644 --- a/src/context/applets/albums/plugin/AlbumsModel.h +++ b/src/context/applets/albums/plugin/AlbumsModel.h @@ -1,91 +1,91 @@ /**************************************************************************************** * Copyright (c) 2008 Andreas Muetzel * * * * 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_ALBUMSMODEL_H #define AMAROK_ALBUMSMODEL_H #include "core/meta/forward_declarations.h" #include #include /** * This Model is used to get the right mime type/data for entries in the albums treeview */ class AlbumsModel : public QStandardItemModel { Q_OBJECT public: explicit AlbumsModel( QObject *parent = nullptr ); - virtual ~AlbumsModel() {} + ~AlbumsModel() override {} QVariant data( const QModelIndex &index, int role ) const override; QMimeData* mimeData( const QModelIndexList &indices ) const override; QStringList mimeTypes() const override; int rowHeight() const; private Q_SLOTS: void updateRowHeight(); private: Meta::TrackList tracksForIndex( const QModelIndex &index ) const; int m_rowHeight; }; class QCollator; class AlbumsProxyModel : public QSortFilterProxyModel { Q_OBJECT Q_PROPERTY( Mode mode READ mode WRITE setMode NOTIFY modeChanged ) public: explicit AlbumsProxyModel( QObject *parent ); ~AlbumsProxyModel() override; enum Mode { SortByCreateDate, SortByYear }; Q_ENUM( Mode ) Mode mode() const; void setMode( Mode mode ); QHash roleNames() const override; Q_SIGNALS: void modeChanged(); protected: /** * Determine if album @param left is less than album @param right . * * If @param left and @param right both reference albums and @c m_mode * is set to @c SortByCreateDate, @c lessThan will return @c true if * and only the album referenced by @param left has a track that was * added more recently than all of the tracks in the album * referenced by @param right . */ bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override; bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override; private: Mode m_mode; QCollator *m_collator; }; Q_DECLARE_METATYPE( AlbumsProxyModel* ) #endif diff --git a/src/context/applets/analyzer/plugin/AnalyzerBase.h b/src/context/applets/analyzer/plugin/AnalyzerBase.h index 0b8f05a04f..0fdcfce8ec 100644 --- a/src/context/applets/analyzer/plugin/AnalyzerBase.h +++ b/src/context/applets/analyzer/plugin/AnalyzerBase.h @@ -1,127 +1,127 @@ /**************************************************************************************** * Copyright (c) 2004 Max Howell * * Copyright (c) 2009 Martin Sandsmark * * Copyright (c) 2013 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 ANALYZERBASE_H #define ANALYZERBASE_H #ifdef __FreeBSD__ #include #endif #include #include #include #include #include #include namespace Analyzer { class Worker; class Base : public QQuickFramebufferObject { Q_OBJECT Q_PROPERTY(qreal minFrequency READ minFreq WRITE setMinFreq NOTIFY minFreqChanged) Q_PROPERTY(qreal maxFrequency READ maxFreq WRITE setMaxFreq NOTIFY maxFreqChanged) Q_PROPERTY(WindowFunction windowFunction READ windowFunction WRITE setWindowFunction NOTIFY windowFunctionChanged) Q_PROPERTY(qreal minimumFrequency READ minFreq WRITE setMinFreq NOTIFY minFreqChanged) Q_PROPERTY(qreal maximumFrequency READ maxFreq WRITE setMaxFreq NOTIFY maxFreqChanged) Q_PROPERTY(int sampleSize READ sampleSize WRITE setSampleSize NOTIFY sampleSizeChanged) public: enum WindowFunction { Rectangular, Hann, Nuttall, Lanczos, Sine }; Q_ENUM(WindowFunction) static const int DEMO_INTERVAL = 20; // ~50 fps - virtual ~Base(); + ~Base() override; qreal maxFreq() const { return m_maxFreq; } void setMaxFreq( qreal maxFreq ); qreal minFreq() const { return m_minFreq; } void setMinFreq( qreal minFreq ); WindowFunction windowFunction() const; void setWindowFunction( WindowFunction windowFunction ); int sampleSize() const; void setSampleSize( uint sampleSize ); /** * Returns the worker object associated with this analyzer. */ const Worker* worker() const; Q_SIGNALS: void minFreqChanged(); void maxFreqChanged(); void scopeSizeChanged( uint ); void windowFunctionChanged( WindowFunction ); void sampleSizeChanged( uint ); void calculateExpFactorNeeded( qreal, qreal, uint ); protected: Base( QQuickItem* ); /** * Creates a new worker instance. * Subclasses must implement this function. * All compute heavy tasks should be offloaded to the created worker. * If you make any connections with your worker, remember to make them queued connections. * Do not set a parent for the worker. Base will take ownership of it. */ virtual Worker* createWorker() const = 0; /** * Returns the standard KConfigGroup for all analyzers. * You can reimplement this function, if you want your subclass to have a different config. */ virtual KConfigGroup config() const; /** * Use this function to set the size for the scope computed by the worker. */ void setScopeSize( int size ); private: void connectSignals(); void disconnectSignals(); void currentDesktopChanged(); void refreshSampleRate(); double m_minFreq, m_maxFreq; int m_sampleRate; int m_scopeSize; Worker *m_worker; QThread m_workerThread; }; } //END namespace Analyzer #endif diff --git a/src/context/applets/analyzer/plugin/AnalyzerWorker.h b/src/context/applets/analyzer/plugin/AnalyzerWorker.h index e690219488..147088141c 100644 --- a/src/context/applets/analyzer/plugin/AnalyzerWorker.h +++ b/src/context/applets/analyzer/plugin/AnalyzerWorker.h @@ -1,124 +1,124 @@ /* * Copyright 2018 Malte Veerman * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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 ANALYZERWORKER_H #define ANALYZERWORKER_H #include "AnalyzerBase.h" #include #include #include #include #include #include class QTimer; namespace Analyzer { /** * Base worker class for all analyzers * All compute heavy tasks should be offloaded to this. */ class Worker : public QObject { friend class Base; Q_OBJECT public: const static int PROCESSING_INTERVAL = 5; // Interval between new data lookups const static int DATA_BUFFER_SIZE = 8; // Higher values increase latency, lower values increase risk of missing frames Worker(); - ~Worker(); + ~Worker() override; protected: /** * @return The current scope data. */ const QVector& scope() const { return m_currentScope; } /** * This function is being called after new scope data is ready. * Get the scope to be analyzed by calling scope(). * Subclasses must implement this function. */ virtual void analyze() = 0; private: struct BandInfo { double lowerFreq; double midFreq; double upperFreq; double lowerK; double midK; double upperK; int scopeIndex; }; /** * This function is thread-safe. */ void receiveData( const QMap > &newData ); // None of the following functions are thread-safe. Only connect with queued connections to them. void processData(); void applyWindowFunction(); void makeScope(); void setSampleSize( uint size ); void setWindowFunction( Base::WindowFunction windowFunction ); void setScopeSize( int size ); void calculateExpFactor( qreal minFreq, qreal maxFreq, int sampleRate ); void resetDemo() { m_demoT = 201; } void playbackStateChanged(); /** * Override this function for your custom idle animation. */ virtual void demo(); fftw_plan m_plan; mutable QMutex m_rawInMutex; QList m_rawIn; double *m_in; std::complex *m_out; QVector m_currentScope; QVector m_interpolatedScopeBands; QVector m_notInterpolatedScopeBands; uint m_size; double m_expFactor; Base::WindowFunction m_windowFunction; int m_expectedDataTime; int m_demoT; QTime m_lastUpdate; QTimer *m_demoTimer; QTimer *m_processTimer; }; } #endif // ANALYZERWORKER_H diff --git a/src/context/applets/currenttrack/plugin/CurrentEngine.h b/src/context/applets/currenttrack/plugin/CurrentEngine.h index 4e98fa4912..1ae683da3a 100644 --- a/src/context/applets/currenttrack/plugin/CurrentEngine.h +++ b/src/context/applets/currenttrack/plugin/CurrentEngine.h @@ -1,90 +1,90 @@ /**************************************************************************************** * Copyright (c) 2007 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_CURRENT_ENGINE #define AMAROK_CURRENT_ENGINE #include "core/meta/Meta.h" #include #include #include namespace Collections { class QueryMaker; } class CurrentEngine : public QObject { Q_OBJECT Q_PROPERTY(QString artist READ artist NOTIFY trackChanged) Q_PROPERTY(QString track READ track NOTIFY trackChanged) Q_PROPERTY(QString album READ album NOTIFY trackChanged) Q_PROPERTY(int rating READ rating WRITE setRating NOTIFY trackChanged) Q_PROPERTY(int score READ score NOTIFY trackChanged) Q_PROPERTY(int length READ length NOTIFY trackChanged) Q_PROPERTY(QString lastPlayed READ lastPlayed NOTIFY trackChanged) Q_PROPERTY(int timesPlayed READ timesPlayed NOTIFY trackChanged) Q_PROPERTY(QVariant cover READ cover NOTIFY albumChanged) Q_PROPERTY(bool hasValidCover READ hasValidCover NOTIFY albumChanged) public: explicit CurrentEngine( QObject* parent = nullptr ); - virtual ~CurrentEngine(); + ~CurrentEngine() override; QString artist() const; QString track() const; QString album() const; int rating() const; void setRating( int rating ); int score() const; int length() const; QString lastPlayed() const; int timesPlayed() const; QVariant cover() const { return QVariant(m_cover); } bool hasValidCover() const { return !m_cover.isNull(); } Q_SIGNALS: void trackChanged(); void albumChanged(); void coverWidthChanged(); private Q_SLOTS: void slotAlbumMetadataChanged(const Meta::AlbumPtr &album ); void slotTrackMetadataChanged( Meta::TrackPtr track ); void slotTrackChanged( const Meta::TrackPtr &track ); void stopped(); private: void update( Meta::TrackPtr track ); void update( Meta::AlbumPtr album ); QPixmap m_cover; Meta::AlbumList m_albums; Meta::TrackPtr m_currentTrack; /** The address of the query maker used for the albums query. This is only used to check if the query results are from the latest started query maker. */ Collections::QueryMaker *m_lastQueryMaker; private Q_SLOTS: void resultReady( const Meta::AlbumList &albums ); }; #endif diff --git a/src/context/applets/photos/plugin/PhotosEngine.h b/src/context/applets/photos/plugin/PhotosEngine.h index 5b6ce57bab..19853f4bf2 100644 --- a/src/context/applets/photos/plugin/PhotosEngine.h +++ b/src/context/applets/photos/plugin/PhotosEngine.h @@ -1,144 +1,144 @@ /**************************************************************************************** * Copyright (c) 2009 Simon Esneault * * * * 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_PHOTOS_ENGINE #define AMAROK_PHOTOS_ENGINE #include "core/meta/Meta.h" #include "core/meta/Observer.h" #include "network/NetworkAccessManagerProxy.h" #include #include #include /** * This class provide photos from flickr * */ class PhotosEngine : public QObject, public Meta::Observer { Q_OBJECT Q_PROPERTY( int fetchSize READ fetchSize WRITE setFetchSize NOTIFY fetchSizeChanged ) Q_PROPERTY( QStringList keywords READ keywords WRITE setKeywords NOTIFY keywordsChanged ) Q_PROPERTY( QList photoUrls READ photoUrls NOTIFY photosChanged ) Q_PROPERTY( QList pageUrls READ pageUrls NOTIFY photosChanged ) Q_PROPERTY( QList photoTitles READ photoTitles NOTIFY photosChanged ) Q_PROPERTY( Status status READ status NOTIFY statusChanged ) Q_PROPERTY( QString error READ error NOTIFY errorChanged ) Q_PROPERTY( QString artist READ artist NOTIFY artistChanged ) public: enum Status { Stopped, Fetching, Completed, Error }; Q_ENUM( Status ) explicit PhotosEngine( QObject* parent = nullptr ); - virtual ~PhotosEngine(); + ~PhotosEngine() override; int fetchSize() const; void setFetchSize( int size ); QStringList keywords() const; void setKeywords( const QStringList &keywords ); // reimplemented from Meta::Observer using Observer::metadataChanged; void metadataChanged( const Meta::TrackPtr &track ) override; QList photoUrls() const; QList pageUrls() const; QList photoTitles() const; Status status() const { return m_status; } QString error() const { return m_error; } QString artist() const { return m_artist; } Q_SIGNALS: void fetchSizeChanged(); void keywordsChanged(); void photosChanged(); void statusChanged(); void errorChanged(); void artistChanged(); private Q_SLOTS: /** * This slots will handle Flickr result for this query : * API key is : 9c5a288116c34c17ecee37877397fe31 * Secret is : cc25e5a9532ddc97 * http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9c5a288116c34c17ecee37877397fe31&text=My+Bloody+Valentine * see here for details: http://www.flickr.com/services/api/ */ void resultFlickr(const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void stopped(); void trackChanged( const Meta::TrackPtr &track ); private: struct PhotoInfo { QString title; // Name of the phtos QUrl urlphoto; // url of the photos, for the download QUrl urlpage; // Url for the browser ( http://www.flickr.com/photos/wanderlustg/322285063/ ) bool operator==( const PhotoInfo &other ) { return title == other.title && urlphoto == other.urlphoto && urlpage == other.urlpage; } }; /** * Engine was updated, so we check if the songs is different, and if it is, we delete every and start * all the query/ fetching stuff */ void update( bool force = false ); void setPhotos( const QList &photos ); void setStatus( Status status ); void setError( const QString &error ); void setArtist( const QString &artist ); QList photosListFromXml( QXmlStreamReader &xml ); // TODO implement a reload void reloadPhotos(); int m_nbPhotos; QSet m_flickrUrls; QList m_photos; Meta::TrackPtr m_currentTrack; // Cache the artist of the current track so we can check against metadata // updates. We only want to update the photos if the artist change QString m_artist; QStringList m_keywords; Status m_status; QString m_error; }; #endif diff --git a/src/context/applets/wikipedia/plugin/WikipediaEngine.h b/src/context/applets/wikipedia/plugin/WikipediaEngine.h index 6248fc598a..a5149bb7a2 100644 --- a/src/context/applets/wikipedia/plugin/WikipediaEngine.h +++ b/src/context/applets/wikipedia/plugin/WikipediaEngine.h @@ -1,125 +1,125 @@ /**************************************************************************************** * Copyright (c) 2007 Leo Franchi * * Copyright (c) 2008 Mark Kretschmann * * Copyright (c) 2009 Simon Esneault * * * * 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_WIKIPEDIA_ENGINE #define AMAROK_WIKIPEDIA_ENGINE #include "core/meta/Meta.h" #include "network/NetworkAccessManagerProxy.h" #include #include class WikipediaEngine : public QObject { Q_OBJECT Q_PROPERTY(QString page READ page NOTIFY pageChanged) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) Q_PROPERTY(QString message READ message NOTIFY messageChanged) Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) Q_PROPERTY(SelectionType selection READ selection WRITE setSelection NOTIFY selectionChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged) public: enum SelectionType { Artist, Composer, Album, Track }; Q_ENUM(SelectionType) explicit WikipediaEngine( QObject* parent = nullptr ); - virtual ~WikipediaEngine(); + ~WikipediaEngine() override; QString page() const { return m_page; } QUrl url() const { return wikiCurrentUrl; } void setUrl( const QUrl &url ); QString message() const { return m_message; } bool busy() const { return m_busy; } SelectionType selection() const; bool setSelection( SelectionType type ); // returns true if selection is changed QString title() const { return m_title; } QString language() const { return preferredLangs.first(); } void setLanguage( const QString &language ); Q_INVOKABLE void reloadWikipedia(); Q_SIGNALS: void pageChanged(); void messageChanged(); void busyChanged(); void selectionChanged(); void languageChanged(); void titleChanged(); void urlChanged(); private: void fetchWikiUrl( const QString &title, const QString &urlPrefix ); void fetchLangLinks( const QString &title, const QString &hostLang, const QString &llcontinue = QString() ); void fetchListing( const QString &title, const QString &hostLang ); bool setSelection( const QString &type ); void updateEngine(); void wikiParse( QString &page ); QString createLanguageComboBox( const QMap &languageMap ); void setPage( const QString &page ); void setMessage( const QString &message ); void setBusy( bool busy ); void setTitle( const QString &title ); void clear(); SelectionType currentSelection; QUrl wikiCurrentUrl; QStringList preferredLangs; struct TrackMetadata { QString artist; QString composer; QString album; QString track; void clear() { artist.clear(); composer.clear(); album.clear(); track.clear(); } } m_previousTrackMetadata; bool useMobileVersion; QSet< QUrl > urls; QString m_page; QString m_message; bool m_busy; QString m_title; QString m_css; private Q_SLOTS: void _checkRequireUpdate( Meta::TrackPtr track ); void _parseLangLinksResult(const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void _parseListingResult(const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void _wikiResult(const QUrl &url, const QByteArray &result, const NetworkAccessManagerProxy::Error &e ); void _stopped(); void _paletteChanged( const QPalette &palette ); }; #endif diff --git a/src/context/popupdropper/libpud/PopupDropper.h b/src/context/popupdropper/libpud/PopupDropper.h index 0807f7ec38..4e2a977a65 100644 --- a/src/context/popupdropper/libpud/PopupDropper.h +++ b/src/context/popupdropper/libpud/PopupDropper.h @@ -1,159 +1,159 @@ /*************************************************************************** * Copyright (c) 2008 Jeff Mitchell * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef POPUPDROPPER_H #define POPUPDROPPER_H #include #include #include #include "PopupDropper_Export.h" class QMenu; class QSvgRenderer; class QTimeLine; class QWidget; class PopupDropper; class PopupDropperItem; class PopupDropperPrivate; class POPUPDROPPER_EXPORT PopupDropper : public QObject { Q_OBJECT Q_PROPERTY( Fading fading READ fading WRITE setFading ) Q_PROPERTY( int overlayLevel READ overlayLevel ) Q_PROPERTY( int deleteTimeout READ deleteTimeout WRITE setDeleteTimeout ) Q_PROPERTY( bool standalone READ standalone ) Q_PROPERTY( bool quitOnDragLeave READ quitOnDragLeave WRITE setQuitOnDragLeave ) Q_PROPERTY( QColor windowColor READ windowColor WRITE setWindowColor ) Q_PROPERTY( QBrush windowBackgroundBrush READ windowBackgroundBrush WRITE setWindowBackgroundBrush ) Q_PROPERTY( QColor baseTextColor READ baseTextColor WRITE setBaseTextColor ) Q_PROPERTY( QPen hoveredBorderPen READ hoveredBorderPen WRITE setHoveredBorderPen ) Q_PROPERTY( QBrush hoveredFillBrush READ hoveredFillBrush WRITE setHoveredFillBrush ) Q_PROPERTY( QString windowTitle READ windowTitle WRITE setWindowTitle ) Q_PROPERTY( QString svgFile READ svgFile WRITE setSvgFile ) Q_PROPERTY( QSvgRenderer* svgRenderer READ svgRenderer WRITE setSvgRenderer ) Q_PROPERTY( int horizontalOffset READ horizontalOffset WRITE setHorizontalOffset ) Q_PROPERTY( const QTimeLine* fadeHideTimer READ fadeHideTimer ) Q_PROPERTY( const QTimeLine* fadeShowTimer READ fadeShowTimer ) Q_PROPERTY( const QSize viewSize READ viewSize ) public: enum Fading { NoFade, FadeIn, FadeOut, FadeInOut }; Q_ENUM( Fading ) explicit PopupDropper( QWidget *parent, bool standalone = false ); - ~PopupDropper(); + ~PopupDropper() override; int overlayLevel() const; void initOverlay( QWidget* parent, PopupDropperPrivate* priv = nullptr ); void addOverlay(); PopupDropperItem* addSubmenu( PopupDropper** pd, const QString &text ); bool addMenu( const QMenu *menu ); bool standalone() const; void show(); void showAllOverlays(); void hideAllOverlays(); void update(); void updateAllOverlays(); bool isHidden() const; bool isEmpty( bool allItems = true ) const; bool quitOnDragLeave() const; void setQuitOnDragLeave( bool quit ); int fadeInTime() const; void setFadeInTime( const int msecs ); int fadeOutTime() const; void setFadeOutTime( const int msecs ); PopupDropper::Fading fading() const; void setFading( PopupDropper::Fading fade ); const QTimeLine* fadeHideTimer() const; const QTimeLine* fadeShowTimer() const; void setDeleteTimeout( int msecs ); int deleteTimeout() const; QColor windowColor() const; void setWindowColor( const QColor &window ); QBrush windowBackgroundBrush() const; void setWindowBackgroundBrush( const QBrush &window ); QColor baseTextColor() const; void setBaseTextColor( const QColor &baseText ); QColor hoveredTextColor() const; void setHoveredTextColor( const QColor &hoveredText ); QPen hoveredBorderPen() const; void setHoveredBorderPen( const QPen &hoveredBorder ); QBrush hoveredFillBrush() const; void setHoveredFillBrush( const QBrush &hoveredFill ); void setColors( const QColor &window, const QColor &baseText, const QColor &hoveredText, const QColor &hoveredBorder, const QColor &hoveredFill ); void setPalette( const QColor &window ); void setPalette( const QColor &window, const QColor &baseText, const QColor &hoveredText, const QColor &hoveredBorder, const QColor &hoveredFill ); QString windowTitle() const; void setWindowTitle( const QString &title ); QString svgFile() const; void setSvgFile( const QString &file ); QSvgRenderer* svgRenderer(); void setSvgRenderer( QSvgRenderer *renderer ); void setHorizontalOffset( int pixels ); int horizontalOffset() const; const QSize viewSize() const; void addItem( PopupDropperItem *item, bool useSharedRenderer = true ); QList items() const; QList submenuItems( const PopupDropperItem *item ) const; void forEachItem( void callback(void*) ); void addSeparator( PopupDropperItem *separator = nullptr ); Q_SIGNALS: void fadeHideFinished(); public Q_SLOTS: void clear(); void hide(); bool subtractOverlay(); private Q_SLOTS: void activateSubmenu(); void slotHideAllOverlays(); private: friend class PopupDropperView; friend class PopupDropperPrivate; PopupDropperPrivate* d; void addOverlay( PopupDropperPrivate* newD ); void addItem( PopupDropperItem *item, bool useSharedRenderer, bool appendToList ); void forEachItemPrivate( PopupDropperPrivate *pdp, void callback(void*) ); QStack m_viewStack; }; #endif //POPUPDROPPER_H diff --git a/src/context/popupdropper/libpud/PopupDropperItem.h b/src/context/popupdropper/libpud/PopupDropperItem.h index 9bdc58b6dc..55ee113a3a 100644 --- a/src/context/popupdropper/libpud/PopupDropperItem.h +++ b/src/context/popupdropper/libpud/PopupDropperItem.h @@ -1,182 +1,182 @@ /*************************************************************************** * Copyright (c) 2008 Jeff Mitchell * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef POPUPDROPPERITEM_H #define POPUPDROPPERITEM_H #include #include #include #include "PopupDropper_Export.h" class QDropEvent; class QGraphicsTextItem; class QSvgRenderer; class QAction; class PopupDropper; class PopupDropperItemPrivate; class POPUPDROPPER_EXPORT PopupDropperItem : public QObject, public QAbstractGraphicsShapeItem { Q_OBJECT Q_PROPERTY( HoverIndicatorShowStyle hoverIndicatorShowStyle READ hoverIndicatorShowStyle WRITE setHoverIndicatorShowStyle ) Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) Q_PROPERTY( TextProtection textProtection READ textProtection WRITE setTextProtection ) Q_PROPERTY( QAction* action READ action WRITE setAction ) Q_PROPERTY( QString text READ text WRITE setText ) Q_PROPERTY( QFont font READ font WRITE setFont ) Q_PROPERTY( QGraphicsTextItem* textItem READ textItem WRITE setTextItem ) Q_PROPERTY( QGraphicsRectItem* borderRectItem READ borderRectItem WRITE setBorderRectItem ) Q_PROPERTY( QGraphicsSvgItem* svgItem READ svgItem ) Q_PROPERTY( QSvgRenderer* sharedRenderer READ sharedRenderer WRITE setSharedRenderer ) Q_PROPERTY( QString elementId READ elementId WRITE setElementId ) Q_PROPERTY( QRect svgElementRect READ svgElementRect WRITE setSvgElementRect ) Q_PROPERTY( int horizontalOffset READ horizontalOffset WRITE setHorizontalOffset ) Q_PROPERTY( int textOffset READ textOffset WRITE setTextOffset ) Q_PROPERTY( int hoverMsecs READ hoverMsecs WRITE setHoverMsecs ) Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) Q_PROPERTY( int hoverIndicatorRectWidth READ hoverIndicatorRectWidth WRITE setHoverIndicatorRectWidth ) Q_PROPERTY( bool submenuTrigger READ isSubmenuTrigger WRITE setSubmenuTrigger ) Q_PROPERTY( QColor baseTextColor READ baseTextColor WRITE setBaseTextColor ) Q_PROPERTY( QColor hoveredTextColor READ hoveredTextColor WRITE setHoveredTextColor ) Q_PROPERTY( QPen hoveredBorderPen READ hoveredBorderPen WRITE setHoveredBorderPen ) Q_PROPERTY( QBrush hoveredBrush READ hoveredFillBrush WRITE setHoveredFillBrush ) Q_PROPERTY( QBrush hoverIndicatorBrush READ hoverIndicatorFillBrush WRITE setHoverIndicatorFillBrush ) Q_PROPERTY( bool customBaseTextColor READ customBaseTextColor ) Q_PROPERTY( bool customHoveredTextColor READ customHoveredTextColor ) Q_PROPERTY( bool customHoveredBorderPen READ customHoveredBorderPen ) Q_PROPERTY( bool customHoveredFillBrush READ customHoveredFillBrush ) Q_PROPERTY( qreal subitemOpacity READ subitemOpacity WRITE setSubitemOpacity ) Q_PROPERTY( bool separator READ isSeparator WRITE setSeparator ) Q_PROPERTY( PopupDropperItem::SeparatorStyle separatorStyle READ separatorStyle WRITE setSeparatorStyle ) Q_PROPERTY( bool hasLineSeparatorPen READ hasLineSeparatorPen ) Q_PROPERTY( QPen lineSeparatorPen READ lineSeparatorPen WRITE setLineSeparatorPen ) public: enum HoverIndicatorShowStyle { Never, OnHover, AlwaysShow }; Q_ENUM( HoverIndicatorShowStyle ) enum Orientation { Left, Right }; Q_ENUM( Orientation ) enum TextProtection { NoProtection, MultiLine, ScaleFont }; Q_ENUM( TextProtection ) enum SeparatorStyle { TextSeparator, LineSeparator }; Q_ENUM( SeparatorStyle ) PopupDropperItem( QGraphicsItem *parent = nullptr ); explicit PopupDropperItem( const QString &file, QGraphicsItem *parent = nullptr ); - virtual ~PopupDropperItem(); + ~PopupDropperItem() override; void show(); QAction* action() const; void setAction( QAction *action ); HoverIndicatorShowStyle hoverIndicatorShowStyle() const; void setHoverIndicatorShowStyle( HoverIndicatorShowStyle hover ); Orientation orientation() const; void setOrientation( Orientation orientation ); TextProtection textProtection() const; void setTextProtection( TextProtection protection ); QString text() const; void setText( const QString &text ); QFont font() const; void setFont( const QFont &font ); QColor baseTextColor() const; void setBaseTextColor( const QColor &color ); QColor hoveredTextColor() const; void setHoveredTextColor( const QColor &color ); QPen hoveredBorderPen() const; void setHoveredBorderPen( const QPen &pen ); QBrush hoveredFillBrush() const; void setHoveredFillBrush( const QBrush &brush ); QBrush hoverIndicatorFillBrush() const; void setHoverIndicatorFillBrush( const QBrush &brush ); bool customBaseTextColor() const; bool customHoveredTextColor() const; bool customHoveredBorderPen() const; bool customHoveredFillBrush() const; void setSubitemOpacity( qreal opacity ); qreal subitemOpacity() const; QGraphicsTextItem* textItem() const; void setTextItem( QGraphicsTextItem *textItem ); void scaleAndReposSvgItem(); void reposTextItem(); void reposHoverFillRects(); QGraphicsRectItem* borderRectItem() const; void setBorderRectItem( QGraphicsRectItem *borderRectItem ); QGraphicsSvgItem* svgItem() const; QSvgRenderer* sharedRenderer() const; void setSharedRenderer( QSvgRenderer *renderer ); QString elementId() const; void setElementId( const QString &id ); QRect svgElementRect() const; void setSvgElementRect( const QRect &rect ); int horizontalOffset() const; void setHorizontalOffset( int offset ); int textOffset() const; void setTextOffset( int offset ); bool isSeparator() const; void setSeparator( bool separator ); PopupDropperItem::SeparatorStyle separatorStyle() const; void setSeparatorStyle( PopupDropperItem::SeparatorStyle style ); bool hasLineSeparatorPen() const; QPen lineSeparatorPen() const; void setLineSeparatorPen( const QPen &pen ); void clearLineSeparatorPen(); int hoverMsecs() const; void setHoverMsecs( const int msecs ); void hoverEntered(); void hoverLeft(); int borderWidth() const; void setBorderWidth( int width ); int hoverIndicatorRectWidth() const; void setHoverIndicatorRectWidth( int width ); bool isSubmenuTrigger() const; void setSubmenuTrigger( bool trigger ); void setPopupDropper( PopupDropper* pd ); //bool operator<( const PopupDropperItem &other ) const; void fullUpdate(); QRectF boundingRect() const override; void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr ) override; public Q_SLOTS: virtual void dropped( QDropEvent *event ); virtual void hoverFinished(); virtual void hoverFrameChanged( int frame ); private: friend class PopupDropperItemPrivate; PopupDropperItemPrivate* const d; }; #endif diff --git a/src/context/popupdropper/libpud/PopupDropper_p.h b/src/context/popupdropper/libpud/PopupDropper_p.h index f20f523171..4d4665ff68 100644 --- a/src/context/popupdropper/libpud/PopupDropper_p.h +++ b/src/context/popupdropper/libpud/PopupDropper_p.h @@ -1,99 +1,99 @@ /*************************************************************************** * Copyright (c) 2008 Jeff Mitchell * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef POPUPDROPPER_P_H #define POPUPDROPPER_P_H #include #include #include #include #include #include #include "PopupDropper.h" #include "PopupDropperView.h" class QSvgRenderer; class QWidget; class PopupDropperPrivate : public QObject { Q_OBJECT public: PopupDropperPrivate( PopupDropper* parent, bool sa, QWidget* widget ); - ~PopupDropperPrivate(); + ~PopupDropperPrivate() override; void newSceneView( PopupDropper* pud ); void setParent( QObject* parent ); bool standalone; QWidget* widget; QGraphicsScene* scene; PopupDropperView* view; PopupDropper::Fading fade; QTimeLine fadeHideTimer; QTimeLine fadeShowTimer; int fadeInTime; int fadeOutTime; QTimer deleteTimer; int deleteTimeout; int frameMax; QColor windowColor; QBrush windowBackgroundBrush; QColor baseTextColor; QColor hoveredTextColor; QPen hoveredBorderPen; QBrush hoveredFillBrush; QString file; QSvgRenderer* sharedRenderer; int horizontalOffset; QList pdiItems; int overlayLevel; bool entered; QMap submenuMap; bool submenu; QList allItems; bool quitOnDragLeave; bool onTop; QRectF widgetRect; //queuedHide: To prevent multiple hide() from being sent if it's already being hidden bool queuedHide; void dragLeft(); void dragEntered(); void startDeleteTimer(); void reposItems(); bool amIOnTop( PopupDropperView* pdv ); public Q_SLOTS: void fadeHideTimerFrameChanged( int frame ); void fadeShowTimerFrameChanged( int frame ); void fadeShowTimerFinished(); void fadeHideTimerFinished(); void deleteTimerFinished(); private: PopupDropper* q; }; #endif //POPUPDROPPER_P_H diff --git a/src/core-impl/capabilities/AlbumActionsCapability.h b/src/core-impl/capabilities/AlbumActionsCapability.h index 28468bf920..17e3ad69b1 100644 --- a/src/core-impl/capabilities/AlbumActionsCapability.h +++ b/src/core-impl/capabilities/AlbumActionsCapability.h @@ -1,45 +1,45 @@ /**************************************************************************************** * 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 ALBUMACTIONSCAPABILITY_H #define ALBUMACTIONSCAPABILITY_H #include "amarok_export.h" #include "core/capabilities/ActionsCapability.h" #include "core/meta/forward_declarations.h" namespace Capabilities { /** * An ActionsCapability subclass that automatically adds actions that are suitable for * albums - the actions are automatically disabled based on what passed album supports. */ class AMAROK_EXPORT AlbumActionsCapability : public ActionsCapability { public: /** * @param album album to create common actions for * @param actions custom actions to append after common actions */ explicit AlbumActionsCapability( const Meta::AlbumPtr &album, const QList &actions = QList() ); - virtual ~AlbumActionsCapability(); + ~AlbumActionsCapability() override; protected: Meta::AlbumPtr m_album; }; } #endif // ALBUMACTIONSCAPABILITY_H diff --git a/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h b/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h index df172e825f..e82999ae61 100644 --- a/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h +++ b/src/core-impl/capabilities/multisource/MultiSourceCapabilityImpl.h @@ -1,44 +1,44 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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_MULTISOURCECAPABILITYIMPL_P_H #define AMAROK_MULTISOURCECAPABILITYIMPL_P_H #include "core/capabilities/MultiSourceCapability.h" #include "core-impl/meta/multi/MultiTrack.h" namespace Capabilities { class MultiSourceCapabilityImpl : public MultiSourceCapability { Q_OBJECT public: explicit MultiSourceCapabilityImpl( Meta::MultiTrack *track ); - virtual ~MultiSourceCapabilityImpl(); + ~MultiSourceCapabilityImpl() override; QStringList sources() const override; void setSource( int source ) override; int current() const override; QUrl nextUrl() const override; private: Meta::MultiTrack *m_track; }; } #endif diff --git a/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h b/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h index 77376e7df6..37dc8b1603 100644 --- a/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h +++ b/src/core-impl/capabilities/timecode/TimecodeLoadCapability.h @@ -1,66 +1,66 @@ /**************************************************************************************** * Copyright (c) 2009 Casey Link * * * * 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 TIMECODELOADCAPABILITY_H #define TIMECODELOADCAPABILITY_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "core/capabilities/Capability.h" #include "amarokurls/AmarokUrl.h" #include "AmarokSharedPointer.h" #include namespace Capabilities { typedef QList BookmarkList; typedef AmarokSharedPointer AmarokUrlPtr; /** * This capability determines whether a track has timecodes * that can be loaded from it, and supplies them if it can. * @author Casey Link */ class AMAROK_EXPORT TimecodeLoadCapability : public Capability { Q_OBJECT public: - virtual ~TimecodeLoadCapability(); + ~TimecodeLoadCapability() override; /** * @return true if the track has timecodes, false if not */ virtual bool hasTimecodes() = 0 ; /** * @return a QList of AmarokUrlPtrs representing the track's timecodes. Might return an empty list. */ virtual BookmarkList loadTimecodes() = 0; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::LoadTimecode; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::LoadTimecode; } }; } #endif // TIMECODELOADCAPABILITY_H diff --git a/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h b/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h index 77171327a7..874b795988 100644 --- a/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h +++ b/src/core-impl/capabilities/timecode/TimecodeWriteCapability.h @@ -1,68 +1,68 @@ /**************************************************************************************** * Copyright (c) 2009 Casey Link * * * * 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 TIMECODEWRITECAPABILITY_H #define TIMECODEWRITECAPABILITY_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "core/capabilities/Capability.h" namespace Capabilities { /** * This capability determines whether a track can have a timecode * written to it. * @author Casey Link */ class AMAROK_EXPORT TimecodeWriteCapability : public Capability { Q_OBJECT public: - virtual ~TimecodeWriteCapability(); + ~TimecodeWriteCapability() override; /** * Stores a timecode for the track * @param miliseconds the position in milliseconds at which the timecide should be stored. * @return true if the write was successful, false if not. */ virtual bool writeTimecode ( qint64 miliseconds ) = 0; /** * Stores an auto timecode for the track and deletes any previously added auto timecodes * @param miliseconds the position in milliseconds at which the timecide should be stored. * @return true if the write was successful, false if not. */ virtual bool writeAutoTimecode ( qint64 miliseconds ) = 0; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::WriteTimecode; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::WriteTimecode; } protected: bool writeTimecode( qint64 miliseconds, const Meta::TrackPtr &track ); bool writeAutoTimecode( qint64 miliseconds, Meta::TrackPtr track ); }; #endif // TIMECODEWRITECAPABILITY_H } diff --git a/src/core-impl/collections/aggregate/AggregateCollection.h b/src/core-impl/collections/aggregate/AggregateCollection.h index 92ff610ec9..c84160150a 100644 --- a/src/core-impl/collections/aggregate/AggregateCollection.h +++ b/src/core-impl/collections/aggregate/AggregateCollection.h @@ -1,131 +1,131 @@ /* * Copyright (c) 2009 Maximilian Kossick * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef AGGREGATECOLLECTION_H #define AGGREGATECOLLECTION_H #include "core/collections/Collection.h" #include "core-impl/collections/support/CollectionManager.h" #include "core/meta/forward_declarations.h" #include "core/meta/support/MetaKeys.h" #include #include #include #include namespace Meta { class AggreagateYear; class AggregateTrack; class AggregateArtist; class AggregateAlbum; class AggregateGenre; class AggregateComposer; class AggregateLabel; } namespace Collections { class AMAROK_EXPORT AggregateCollection : public Collections::Collection { Q_OBJECT public: AggregateCollection(); - ~AggregateCollection(); + ~AggregateCollection() override; // Collections::Collection methods QString prettyName() const override; QIcon icon() const override; bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; QueryMaker* queryMaker() override; QString collectionId() const override; // AggregateCollection methods void removeTrack( const Meta::TrackKey &key ); Meta::AggregateTrack* getTrack( const Meta::TrackPtr &track ); void setTrack( Meta::AggregateTrack *track ); bool hasTrack( const Meta::TrackKey &key ); void removeAlbum( const QString &album, const QString &albumArtist ); Meta::AggregateAlbum* getAlbum( const Meta::AlbumPtr &album ); void setAlbum( Meta::AggregateAlbum *album ); bool hasAlbum( const QString &album, const QString &albumArtist ); void removeArtist( const QString &artist ); Meta::AggregateArtist* getArtist( Meta::ArtistPtr artist ); void setArtist( Meta::AggregateArtist *artist ); bool hasArtist( const QString &artist ); void removeGenre( const QString &genre ); Meta::AggregateGenre* getGenre( Meta::GenrePtr genre ); void setGenre( Meta::AggregateGenre *genre ); bool hasGenre( const QString &genre ); void removeComposer( const QString &name ); Meta::AggregateComposer* getComposer( Meta::ComposerPtr composer ); void setComposer( Meta::AggregateComposer *composer ); bool hasComposer( const QString &name ); bool hasYear( const QString &name ); void removeYear( const QString &name ); Meta::AggreagateYear* getYear( Meta::YearPtr year ); void setYear( Meta::AggreagateYear *year ); bool hasLabel( const QString &name ); void removeLabel( const QString &name ); Meta::AggregateLabel* getLabel( Meta::LabelPtr label ); void setLabel( Meta::AggregateLabel *label ); public Q_SLOTS: void removeCollectionById( const QString &collectionId ); void removeCollection( Collections::Collection *collection ); void addCollection( Collections::Collection *collection, CollectionManager::CollectionStatus status ); void slotUpdated(); private Q_SLOTS: void emptyCache(); private: QHash m_idCollectionMap; QHash > m_yearMap; QHash > m_genreMap; QHash > m_composerMap; QHash > m_artistMap; QHash > m_albumMap; QHash > m_trackMap; QHash > m_labelMap; QReadWriteLock m_yearLock; QReadWriteLock m_genreLock; QReadWriteLock m_composerLock; QReadWriteLock m_artistLock; QReadWriteLock m_albumLock; QReadWriteLock m_trackLock; QReadWriteLock m_labelLock; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/aggregate/AggregateMeta.h b/src/core-impl/collections/aggregate/AggregateMeta.h index 3e46326e47..22a08b3dcc 100644 --- a/src/core-impl/collections/aggregate/AggregateMeta.h +++ b/src/core-impl/collections/aggregate/AggregateMeta.h @@ -1,301 +1,301 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 AGGREGATEMETA_H #define AGGREGATEMETA_H #include "amarok_export.h" #include "core/meta/Meta.h" #include "core/meta/Observer.h" #include "core/meta/Statistics.h" #include namespace Collections { class AggregateCollection; } namespace Meta { class AMAROK_EXPORT AggregateTrack : public Meta::Track, public Meta::Statistics, private Meta::Observer { public: AggregateTrack( Collections::AggregateCollection *coll, const Meta::TrackPtr &track ); ~AggregateTrack() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; /** * Return a comma separated list of reasons why constituent * tracks are unplayable or an empty string if any of the tracks is playable */ QString notPlayableReason() const override; Meta::AlbumPtr album() const override; Meta::ArtistPtr artist() const override; Meta::ComposerPtr composer() const override; Meta::GenrePtr genre() const override; Meta::YearPtr year() const override; QString comment() const override; qreal bpm() const override; void finishedPlaying( double playedFraction ) override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; QDateTime createDate() const override; int trackNumber() const override; int discNumber() const override; QString type() const override; Collections::Collection* collection() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void addLabel( const QString &label ) override; void addLabel( const Meta::LabelPtr &label ) override; void removeLabel( const Meta::LabelPtr &label ) override; Meta::LabelList labels() const override; TrackEditorPtr editor() override; StatisticsPtr statistics() override; // Meta::Statistics methods: double score() const override; void setScore( double newScore ) override; int rating() const override; void setRating( int newRating ) override; QDateTime firstPlayed() const override; void setFirstPlayed( const QDateTime &date ) override; QDateTime lastPlayed() const override; void setLastPlayed( const QDateTime &date ) override; int playCount() const override; void setPlayCount( int newPlayCount ) override; void add( const Meta::TrackPtr &track ); protected: using Observer::metadataChanged; void metadataChanged( const Meta::TrackPtr &track ) override; private: Collections::AggregateCollection *m_collection; Meta::TrackList m_tracks; QString m_name; Meta::AlbumPtr m_album; Meta::ArtistPtr m_artist; Meta::GenrePtr m_genre; Meta::ComposerPtr m_composer; Meta::YearPtr m_year; }; class AMAROK_EXPORT AggregateAlbum : public Meta::Album, private Meta::Observer { public: AggregateAlbum( Collections::AggregateCollection *coll, Meta::AlbumPtr album ); ~AggregateAlbum() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; Meta::TrackList tracks() override; Meta::ArtistPtr albumArtist() const override; bool isCompilation() const override; bool hasAlbumArtist() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void add( const Meta::AlbumPtr &album ); /** returns true if the album has a cover set */ bool hasImage( int size = 0 ) const override; /** returns the cover of the album */ QImage image( int size = 0 ) const override; /** returns the image location on disk */ QUrl imageLocation( int size = 0 ) override; /** returns the cover of the album with a nice border around it*/ virtual QPixmap imageWithBorder( int size = 0, int borderWidth = 5 ); /** Returns true if it is possible to update the cover of the album */ bool canUpdateImage() const override; /** updates the cover of the album */ void setImage( const QImage &image ) override; void removeImage() override; /** don't automatically fetch artwork */ void setSuppressImageAutoFetch( const bool suppress ) override; /** should automatic artwork retrieval be suppressed? */ bool suppressImageAutoFetch() const override; protected: using Observer::metadataChanged; void metadataChanged(const Meta::AlbumPtr &album ) override; private: Collections::AggregateCollection *m_collection; Meta::AlbumList m_albums; QString m_name; Meta::ArtistPtr m_albumArtist; }; class AMAROK_EXPORT AggregateArtist : public Meta::Artist, private Meta::Observer { public: AggregateArtist( Collections::AggregateCollection *coll, const Meta::ArtistPtr &artist ); ~AggregateArtist() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; Meta::TrackList tracks() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void add( const Meta::ArtistPtr &artist ); protected: using Observer::metadataChanged; void metadataChanged( const Meta::ArtistPtr &artist ) override; private: Collections::AggregateCollection *m_collection; Meta::ArtistList m_artists; QString m_name; }; class AMAROK_EXPORT AggregateGenre : public Meta::Genre, private Meta::Observer { public: AggregateGenre( Collections::AggregateCollection *coll, const Meta::GenrePtr &genre ); - ~AggregateGenre(); + ~AggregateGenre() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; Meta::TrackList tracks() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void add( const Meta::GenrePtr &genre ); protected: using Observer::metadataChanged; void metadataChanged( const Meta::GenrePtr &genre ) override; private: Collections::AggregateCollection *m_collection; Meta::GenreList m_genres; QString m_name; }; class AMAROK_EXPORT AggregateComposer : public Meta::Composer, private Meta::Observer { public: AggregateComposer(Collections::AggregateCollection *coll, const ComposerPtr &composer ); ~AggregateComposer() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; Meta::TrackList tracks() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void add( const Meta::ComposerPtr &composer ); protected: using Observer::metadataChanged; void metadataChanged( const Meta::ComposerPtr &composer ) override; private: Collections::AggregateCollection *m_collection; Meta::ComposerList m_composers; QString m_name; }; class AMAROK_EXPORT AggreagateYear : public Meta::Year, private Meta::Observer { public: AggreagateYear( Collections::AggregateCollection * coll, const Meta::YearPtr &year ); ~AggreagateYear() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; Meta::TrackList tracks() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; /** * adds another Meta::Year instance to be proxied. */ void add( const Meta::YearPtr &year ); protected: using Observer::metadataChanged; void metadataChanged( const Meta::YearPtr &year ) override; private: Collections::AggregateCollection *m_collection; Meta::YearList m_years; QString m_name; }; class AMAROK_EXPORT AggregateLabel : public Meta::Label { public: AggregateLabel( Collections::AggregateCollection *coll, const Meta::LabelPtr &label ); - virtual ~AggregateLabel(); + ~AggregateLabel() override; QString name() const override; QString prettyName() const override; QString sortableName() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; /** adds another Meta::Label instance to be proxied. */ void add( const Meta::LabelPtr &label ); private: Collections::AggregateCollection *m_collection; Meta::LabelList m_labels; QString m_name; }; } // namespace Meta #endif // AGGREGATEMETA_H diff --git a/src/core-impl/collections/aggregate/AggregateQueryMaker.h b/src/core-impl/collections/aggregate/AggregateQueryMaker.h index e988356ad5..419228c3c3 100644 --- a/src/core-impl/collections/aggregate/AggregateQueryMaker.h +++ b/src/core-impl/collections/aggregate/AggregateQueryMaker.h @@ -1,117 +1,117 @@ /* * Copyright (c) 2009 Maximilian Kossick * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef AGGREGATEQUERYMAKER_H #define AGGREGATEQUERYMAKER_H #include "core/collections/QueryMaker.h" #include "core/collections/Collection.h" #include "core-impl/collections/aggregate/AggregateMeta.h" #include #include #include #include "AmarokSharedPointer.h" class CustomReturnFunction; class CustomReturnValue; namespace Collections { class AMAROK_EXPORT AggregateQueryMaker : public QueryMaker { Q_OBJECT public: AggregateQueryMaker( Collections::AggregateCollection *collection, const QList &queryMakers ); - ~AggregateQueryMaker(); + ~AggregateQueryMaker() override; void run() override; void abortQuery() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addReturnValue( qint64 value) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy( qint64 value, bool descending = false ) override; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::YearPtr &year ) override; QueryMaker* addMatch( const Meta::LabelPtr &label ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* limitMaxResultSize( int size ) override; QueryMaker* beginAnd() override; QueryMaker* beginOr() override; QueryMaker* endAndOr() override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override; private: void handleResult(); private Q_SLOTS: void slotQueryDone(); void slotNewTracksReady( const Meta::TrackList &tracks ); void slotNewArtistsReady( const Meta::ArtistList &artists ); void slotNewAlbumsReady( const Meta::AlbumList &albums ); void slotNewGenresReady( const Meta::GenreList &genres ); void slotNewComposersReady( const Meta::ComposerList &composers ); void slotNewYearsReady( const Meta::YearList &years ); void slotNewLabelsReady( const Meta::LabelList &labels ); private: AggregateCollection *m_collection; QList m_builders; int m_queryDoneCount; bool m_returnDataPointers; int m_maxResultSize; QueryType m_queryType; bool m_orderDescending; qint64 m_orderField; bool m_orderByNumberField; QMutex m_queryDoneCountMutex; // store AggregateCollection meta stuff using AmarokSharedPointer, // otherwise AggregateCollection might delete it (as soon as it gets garbage collection) QSet > m_tracks; QSet > m_artists; QSet > m_albums; QSet > m_genres; QSet > m_composers; QSet > m_years; QSet > m_labels; QList m_returnFunctions; QList m_returnValues; }; } #endif /* AGGREGATEQUERYMAKER_H */ diff --git a/src/core-impl/collections/audiocd/AudioCdCollection.h b/src/core-impl/collections/audiocd/AudioCdCollection.h index 22d2c13279..911f7fbfca 100644 --- a/src/core-impl/collections/audiocd/AudioCdCollection.h +++ b/src/core-impl/collections/audiocd/AudioCdCollection.h @@ -1,145 +1,145 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 AUDIOCDCOLLECTION_H #define AUDIOCDCOLLECTION_H #include "core/collections/Collection.h" #include "MediaDeviceCollection.h" #include "MemoryCollection.h" #include "core-impl/meta/proxy/MetaProxy.h" #include #include #include #include class MediaDeviceInfo; class KJob; namespace Collections { class AudioCdCollection; class AudioCdCollectionFactory : public MediaDeviceCollectionFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-audiocdcollection.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: AudioCdCollectionFactory(); - virtual ~AudioCdCollectionFactory() {} + ~AudioCdCollectionFactory() override {} /* virtual void init(); private Q_SLOTS: void audioCdAdded( const QString &uid ); void deviceRemoved( const QString &uid ); private: QString m_currentUid; AudioCdCollection * m_collection;*/ }; /** * This is a Memorycollection subclass that uses the KIO audiocd:/ slave to * populate itself whenever it detects a CD. * * @author Nikolaj Hald Nielsen */ class AudioCdCollection : public MediaDeviceCollection { Q_OBJECT public: enum { WAV, FLAC, OGG, MP3 } EncodingFormat; explicit AudioCdCollection( MediaDeviceInfo* info ); - ~AudioCdCollection(); + ~AudioCdCollection() override; QString encodingFormat() const; QString copyableFilePath( const QString &fileName ) const; void setEncodingFormat( int format ) const; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override; CollectionLocation* location() override; bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; void cdRemoved(); virtual void startFullScan(); //Override this one as I really don't want to move parsing to the handler atm. void startFullScanDevice() override { startFullScan(); } public Q_SLOTS: void eject() override; private Q_SLOTS: void audioCdEntries( KIO::Job *job, const KIO::UDSEntryList &list ); void slotEntriesJobDone( KJob *job ); void infoFetchComplete( KJob *job ); void checkForStartPlayRequest(); private: void readAudioCdSettings(); // Helper function to build the audiocd url. QUrl audiocdUrl( const QString &path = "" ) const; // The file name of the track without extension QString trackBaseFileName( int i ) const; // The file name of the track in .wav format QString trackWavFileName( int i ) const; // The name of the track that should be displayed QString trackDisplayName( int i ) const; // The length of the track in milliseconds qint64 trackLength( int i ) const; /** * Clear collection and read the CD currently in the drive, adding Artist, Album, * Genre, Year and whatnot as detected by audiocd using CDDB. */ void readCd(); void noInfoAvailable(); void updateProxyTracks(); QMap m_cddbTextFiles; QString m_cdName; QString m_discCddbId; QString m_udi; QString m_device; mutable int m_encodingFormat; QString m_fileNamePattern; QString m_albumNamePattern; QMap m_proxyMap; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h b/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h index 13c7954b5a..8eb1c0bacc 100644 --- a/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h +++ b/src/core-impl/collections/audiocd/AudioCdCollectionLocation.h @@ -1,55 +1,55 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 AUDIOCDCOLLECTIONLOCATION_H #define AUDIOCDCOLLECTIONLOCATION_H #include "core/collections/CollectionLocation.h" #include "AudioCdCollection.h" namespace Collections { /** A custom CollectionLocation handling the encoding file type and so on for AudioCd collections @author Nikolaj Hald Nielsen */ class AudioCdCollectionLocation : public CollectionLocation { Q_OBJECT public: explicit AudioCdCollectionLocation( AudioCdCollection *parentCollection ); - ~AudioCdCollectionLocation(); + ~AudioCdCollectionLocation() override; void getKIOCopyableUrls( const Meta::TrackList &tracks ) override; void showSourceDialog( const Meta::TrackList &tracks, bool removeSources ) override; private Q_SLOTS: void formatSelected( int format ); void formatSelectionCancelled(); void onFormatSelected( int format ); void onCancel(); private: AudioCdCollection *m_collection; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/audiocd/AudioCdMeta.h b/src/core-impl/collections/audiocd/AudioCdMeta.h index 27867d3cb7..5af804d58f 100644 --- a/src/core-impl/collections/audiocd/AudioCdMeta.h +++ b/src/core-impl/collections/audiocd/AudioCdMeta.h @@ -1,225 +1,225 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 AUDIOCDMETA_H #define AUDIOCDMETA_H #include "core/meta/Meta.h" namespace Collections { class AudioCdCollection; } namespace Meta { class AudioCdTrack; class AudioCdAlbum; class AudioCdArtist; class AudioCdGenre; class AudioCdComposer; class AudioCdYear; typedef AmarokSharedPointer AudioCdTrackPtr; typedef AmarokSharedPointer AudioCdArtistPtr; typedef AmarokSharedPointer AudioCdAlbumPtr; typedef AmarokSharedPointer AudioCdGenrePtr; typedef AmarokSharedPointer AudioCdComposerPtr; typedef AmarokSharedPointer AudioCdYearPtr; class AudioCdTrack : public Meta::Track { public: AudioCdTrack( Collections::AudioCdCollection *collection, const QString &name, const QUrl &url ); - virtual ~AudioCdTrack(); + ~AudioCdTrack() override; QString name() const override; QUrl playableUrl() const override; QString uidUrl() const override; QString prettyUrl() const override; QString notPlayableReason() const override; AlbumPtr album() const override; ArtistPtr artist() const override; GenrePtr genre() const override; ComposerPtr composer() const override; YearPtr year() const override; virtual void setTitle( const QString &newTitle ); qreal bpm() const override; QString comment() const override; virtual void setComment ( const QString &newComment ); qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; int trackNumber() const override; virtual void setTrackNumber ( int newTrackNumber ); int discNumber() const override; virtual void setDiscNumber ( int newDiscNumber ); QString type() const override; bool inCollection() const override; Collections::Collection* collection() const override; //AudioCdTrack specific methods void setAlbum( AudioCdAlbumPtr album ); void setArtist( AudioCdArtistPtr artist ); void setComposer( AudioCdComposerPtr composer ); void setGenre( AudioCdGenrePtr genre ); void setYear( AudioCdYearPtr year ); void setLength( qint64 length ); void setFileNameBase( const QString &fileNameBase ); QString fileNameBase(); private: Collections::AudioCdCollection *m_collection; AudioCdArtistPtr m_artist; AudioCdAlbumPtr m_album; AudioCdGenrePtr m_genre; AudioCdComposerPtr m_composer; AudioCdYearPtr m_year; QString m_name; qint64 m_length; int m_trackNumber; QUrl m_playableUrl; QString m_fileNameBase; }; class AudioCdArtist : public Meta::Artist { public: explicit AudioCdArtist( const QString &name ); ~AudioCdArtist() override; QString name() const override; TrackList tracks() override; virtual AlbumList albums(); //AudioCdArtist specific methods void addTrack( AudioCdTrackPtr track ); private: QString m_name; TrackList m_tracks; }; class AudioCdAlbum : public Meta::Album { public: explicit AudioCdAlbum( const QString &name ); ~AudioCdAlbum() override; QString name() const override; bool isCompilation() const override; bool canUpdateCompilation() const override; void setCompilation( bool compilation ) override; bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; QImage image( int size = 0 ) const override; bool hasImage( int size = 0 ) const override; bool canUpdateImage() const override; void setImage( const QImage &image ) override; //AudioCdAlbum specific methods void addTrack( AudioCdTrackPtr track ); void setAlbumArtist( AudioCdArtistPtr artist ); private: QString m_name; TrackList m_tracks; bool m_isCompilation; AudioCdArtistPtr m_albumArtist; QImage m_cover; }; class AudioCdGenre : public Meta::Genre { public: explicit AudioCdGenre( const QString &name ); ~AudioCdGenre() override; QString name() const override; TrackList tracks() override; //AudioCdGenre specific methods void addTrack( AudioCdTrackPtr track ); private: QString m_name; TrackList m_tracks; }; class AudioCdComposer : public Meta::Composer { public: explicit AudioCdComposer( const QString &name ); ~AudioCdComposer() override; QString name() const override; TrackList tracks() override; //AudioCdComposer specific methods void addTrack( AudioCdTrackPtr track ); private: QString m_name; TrackList m_tracks; }; class AudioCdYear : public Meta::Year { public: explicit AudioCdYear( const QString &name ); ~AudioCdYear() override; QString name() const override; TrackList tracks() override; //AudioCdYear specific methods void addTrack( AudioCdTrackPtr track ); private: QString m_name; TrackList m_tracks; }; } #endif diff --git a/src/core-impl/collections/audiocd/FormatSelectionDialog.h b/src/core-impl/collections/audiocd/FormatSelectionDialog.h index 27fbbc2428..fb3bb12b50 100644 --- a/src/core-impl/collections/audiocd/FormatSelectionDialog.h +++ b/src/core-impl/collections/audiocd/FormatSelectionDialog.h @@ -1,55 +1,55 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 FORMATSELECTIONDIALOG_H #define FORMATSELECTIONDIALOG_H #include #include "ui_FormatSelectionDialog.h" /** A dialog for selecting the format of of tracks imported from a AudioCdCollection @author */ class FormatSelectionDialog : public QDialog , private Ui::FormatSelectionDialog { Q_OBJECT public: explicit FormatSelectionDialog( QWidget *parent = nullptr ); - ~FormatSelectionDialog(); + ~FormatSelectionDialog() override; public Q_SLOTS: void accept() override; virtual void showAdvancedSettings(); Q_SIGNALS: void formatSelected( int ); private Q_SLOTS: void selectionChanged( bool checked ); private: int m_selectedFormat; }; #endif diff --git a/src/core-impl/collections/audiocd/handler/AudioCdHandler.h b/src/core-impl/collections/audiocd/handler/AudioCdHandler.h index 09509cd7fd..7516ae5184 100644 --- a/src/core-impl/collections/audiocd/handler/AudioCdHandler.h +++ b/src/core-impl/collections/audiocd/handler/AudioCdHandler.h @@ -1,44 +1,44 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 AUDIOCDHANDLER_H #define AUDIOCDHANDLER_H #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h" namespace Meta { /** A hander class for the AudioCd collection @author */ class AudioCdHandler : public MediaDeviceHandler { public: explicit AudioCdHandler( QObject *parent ); - ~AudioCdHandler(); + ~AudioCdHandler() override; void init() override; bool isWritable() const override { return false; } QString prettyName() const override; }; } #endif diff --git a/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h b/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h index 3de879d482..47c3a3adac 100644 --- a/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h +++ b/src/core-impl/collections/audiocd/support/AudioCdConnectionAssistant.h @@ -1,36 +1,36 @@ /**************************************************************************************** * Copyright (C) 2009 Alejandro Wainzinger * * * 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 AUDIOCDCONNECTIONASSISTANT_H #define AUDIOCDCONNECTIONASSISTANT_H #include "ConnectionAssistant.h" #include class AudioCdConnectionAssistant : public ConnectionAssistant { Q_OBJECT public: - virtual ~AudioCdConnectionAssistant(); + ~AudioCdConnectionAssistant() override; bool identify( const QString& udi ) override; MediaDeviceInfo* deviceInfo( const QString& udi ) override; }; #endif // AUDIOCDCONNECTIONASSISTANT_H diff --git a/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h b/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h index 1b48b0bd1d..06ca79a497 100644 --- a/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h +++ b/src/core-impl/collections/audiocd/support/AudioCdDeviceInfo.h @@ -1,35 +1,35 @@ /**************************************************************************************** * copyright (C) 2008 Alejandro Wainzinger * * * 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 AUDIOCD_DEVICE_INFO_H #define AUDIOCD_DEVICE_INFO_H #include "MediaDeviceInfo.h" class AudioCdDeviceInfo : public MediaDeviceInfo { Q_OBJECT public: AudioCdDeviceInfo(const QString &device, const QString &udi ); - ~AudioCdDeviceInfo(); + ~AudioCdDeviceInfo() override; QString device() const; private: QString m_device; }; #endif diff --git a/src/core-impl/collections/daap/DaapCollection.h b/src/core-impl/collections/daap/DaapCollection.h index bebb6daeab..dca67ad420 100644 --- a/src/core-impl/collections/daap/DaapCollection.h +++ b/src/core-impl/collections/daap/DaapCollection.h @@ -1,117 +1,117 @@ /**************************************************************************************** * Copyright (c) 2006 Ian Monroe * * Copyright (c) 2006 Seb Ruiz * * Copyright (c) 2007 Maximilian Kossick * * * * 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 DAAPCOLLECTION_H #define DAAPCOLLECTION_H #include "core/collections/Collection.h" #include "MemoryCollection.h" #include "Reader.h" #include #include #include #include #include #include #include #include namespace KDNSSD { class ServiceBrowser; } namespace Collections { class DaapCollection; class DaapCollectionFactory : public Collections::CollectionFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-daapcollection.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: DaapCollectionFactory(); - virtual ~DaapCollectionFactory(); + ~DaapCollectionFactory() override; void init() override; private: QString serverKey( const QString& host, quint16 port ) const; private Q_SLOTS: void connectToManualServers(); void serverOffline( KDNSSD::RemoteService::Ptr ); void foundDaap( KDNSSD::RemoteService::Ptr ); void resolvedDaap( bool ); void slotCollectionReady(); void slotCollectionDownloadFailed(); void resolvedServiceIp(const QHostInfo&); void resolvedManualServerIp(const QHostInfo&); private: KDNSSD::ServiceBrowser* m_browser; QMap > m_collectionMap; QHash m_lookupHash; }; class DaapCollection : public Collections::Collection { Q_OBJECT public: DaapCollection( const QString &host, const QString &ip, quint16 port ); - virtual ~DaapCollection(); + ~DaapCollection() override; QueryMaker* queryMaker() override; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override { return QIcon::fromTheme("network-server"); } void serverOffline(); QSharedPointer memoryCollection() const { return m_mc; } Q_SIGNALS: void collectionReady(); public Q_SLOTS: void loadedDataFromServer(); void parsingFailed(); private Q_SLOTS: void passwordRequired(); void httpError( const QString &error ); private: QString m_host; quint16 m_port; QString m_ip; Daap::Reader *m_reader; QSharedPointer m_mc; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/daap/DaapMeta.h b/src/core-impl/collections/daap/DaapMeta.h index 391b3bc69e..e3e0440e15 100644 --- a/src/core-impl/collections/daap/DaapMeta.h +++ b/src/core-impl/collections/daap/DaapMeta.h @@ -1,219 +1,219 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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 DAAPMETA_H #define DAAPMETA_H #include "core/meta/Meta.h" namespace Collections { class DaapCollection; } namespace Meta { class DaapTrack; class DaapAlbum; class DaapArtist; class DaapGenre; class DaapComposer; class DaapYear; typedef AmarokSharedPointer DaapTrackPtr; typedef AmarokSharedPointer DaapArtistPtr; typedef AmarokSharedPointer DaapAlbumPtr; typedef AmarokSharedPointer DaapGenrePtr; typedef AmarokSharedPointer DaapComposerPtr; typedef AmarokSharedPointer DaapYearPtr; class DaapTrack : public Meta::Track { public: DaapTrack( Collections::DaapCollection *collection, const QString &host, quint16 port, const QString &dbId, const QString &itemId, const QString &format); - virtual ~DaapTrack(); + ~DaapTrack() override; QString name() const override; QUrl playableUrl() const override; QString uidUrl() const override; QString prettyUrl() const override; QString notPlayableReason() const override; AlbumPtr album() const override; ArtistPtr artist() const override; GenrePtr genre() const override; ComposerPtr composer() const override; YearPtr year() const override; virtual void setAlbum ( const QString &newAlbum ); virtual void setArtist ( const QString &newArtist ); virtual void setGenre ( const QString &newGenre ); virtual void setComposer ( const QString &newComposer ); virtual void setYear ( int newYear ); virtual void setTitle( const QString &newTitle ); qreal bpm() const override; QString comment() const override; virtual void setComment ( const QString &newComment ); qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; int trackNumber() const override; virtual void setTrackNumber ( int newTrackNumber ); int discNumber() const override; virtual void setDiscNumber ( int newDiscNumber ); QString type() const override; bool inCollection() const override; Collections::Collection* collection() const override; //DaapTrack specific methods void setAlbum( const DaapAlbumPtr &album ); void setArtist( const DaapArtistPtr &artist ); void setComposer( const DaapComposerPtr &composer ); void setGenre( const DaapGenrePtr &genre ); void setYear( const DaapYearPtr &year ); void setLength( qint64 length ); private: Collections::DaapCollection *m_collection; DaapArtistPtr m_artist; DaapAlbumPtr m_album; DaapGenrePtr m_genre; DaapComposerPtr m_composer; DaapYearPtr m_year; QString m_name; QString m_type; qint64 m_length; int m_trackNumber; QString m_displayUrl; QString m_playableUrl; }; class DaapArtist : public Meta::Artist { public: explicit DaapArtist( const QString &name ); - virtual ~DaapArtist(); + ~DaapArtist() override; QString name() const override; TrackList tracks() override; virtual AlbumList albums(); //DaapArtist specific methods void addTrack( const DaapTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class DaapAlbum : public Meta::Album { public: explicit DaapAlbum( const QString &name ); - virtual ~DaapAlbum(); + ~DaapAlbum() override; QString name() const override; bool isCompilation() const override; bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; //DaapAlbum specific methods void addTrack( const DaapTrackPtr &track ); void setAlbumArtist( const DaapArtistPtr &artist ); private: QString m_name; TrackList m_tracks; bool m_isCompilation; DaapArtistPtr m_albumArtist; }; class DaapGenre : public Meta::Genre { public: explicit DaapGenre( const QString &name ); - virtual ~DaapGenre(); + ~DaapGenre() override; QString name() const override; TrackList tracks() override; //DaapGenre specific methods void addTrack( const DaapTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class DaapComposer : public Meta::Composer { public: explicit DaapComposer( const QString &name ); - virtual ~DaapComposer(); + ~DaapComposer() override; QString name() const override; TrackList tracks() override; //DaapComposer specific methods void addTrack( const DaapTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class DaapYear : public Meta::Year { public: explicit DaapYear( const QString &name ); - virtual ~DaapYear(); + ~DaapYear() override; QString name() const override; TrackList tracks() override; //DaapYear specific methods void addTrack( const DaapTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; } #endif diff --git a/src/core-impl/collections/daap/daapreader/Reader.h b/src/core-impl/collections/daap/daapreader/Reader.h index 4920dda547..4eac8cd877 100644 --- a/src/core-impl/collections/daap/daapreader/Reader.h +++ b/src/core-impl/collections/daap/daapreader/Reader.h @@ -1,152 +1,152 @@ /**************************************************************************************** * Copyright (c) 2006 Ian Monroe * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 DAAPREADER_H #define DAAPREADER_H #include #include #include #include class QString; namespace Collections { class DaapCollection; } namespace Daap { typedef QMap Map; enum ContentTypes { INVALID = 0, CHAR = 1, SHORT = 3, LONG = 5, LONGLONG = 7, STRING = 9, DATE = 10, DVERSION = 11, CONTAINER = 12 }; struct Code { Code() : type(INVALID) { } Code( const QString& nName, ContentTypes nType ) : name( nName ), type( nType ) { } ~Code() { } QString name; ContentTypes type; }; /** The nucleus of the DAAP client; composes queries and parses responses. @author Ian Monroe */ class Reader : public QObject { Q_OBJECT public: Reader( Collections::DaapCollection *mc, const QString& host, quint16 port, const QString& password, QObject* parent, const char* name ); - ~Reader(); + ~Reader() override; //QPtrList getSongList(); enum Options { SESSION_ID = 1, SERVER_VERSION = 2 }; void loginRequest(); void logoutRequest(); int sessionId() const { return m_sessionId; } QString host() const { return m_host; } quint16 port() const { return m_port; } bool parseSongList( const QByteArray &data, bool set_collection = false); public Q_SLOTS: void logoutRequestFinished(); void contentCodesReceived(); void loginHeaderReceived(); void loginFinished(); void updateFinished(); void databaseIdFinished(); void songListFinished(); void fetchingError( const QString& error ); Q_SIGNALS: //void daapBundles( const QString& host, Daap::SongList bundles ); void httpError( const QString& ); void passwordRequired(); private: /** * Make a map-vector tree out of the DAAP binary result * @param raw stream of DAAP reply */ Map parse( QDataStream &raw); static void addElement( Map &parentMap, char* tag, const QVariant &element ); //!< supporter function for parse static quint32 getTagAndLength( QDataStream &raw, char tag[5] ); QVariant readTagData(QDataStream &, char[5], quint32); void addTrack( const QString& itemId, const QString& title, const QString& artist, const QString& composer, const QString& comment, const QString& album, const QString& genre, int year, const QString& format, qint32 trackNumber, qint32 songTime ); QMap m_codes; Collections::DaapCollection *m_memColl; QString m_host; quint16 m_port; QString m_loginString; QString m_databaseId; int m_sessionId; QString m_password; TrackMap m_trackMap; ArtistMap m_artistMap; AlbumMap m_albumMap; GenreMap m_genreMap; ComposerMap m_composerMap; YearMap m_yearMap; }; class WorkerThread : public QObject, public ThreadWeaver::Job { Q_OBJECT public: WorkerThread( const QByteArray &data, Reader* reader, Collections::DaapCollection *coll ); - virtual ~WorkerThread(); + ~WorkerThread() override; bool success() const override; protected: void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void run(ThreadWeaver::JobPointer self=QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); private: bool m_success; QByteArray m_data; Reader *m_reader; }; } #endif diff --git a/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h b/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h index bd07386fd3..d377ed3dd6 100644 --- a/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h +++ b/src/core-impl/collections/daap/daapreader/authentication/contentfetcher.h @@ -1,68 +1,68 @@ /**************************************************************************************** * Copyright (c) 2006 Ian Monroe * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 DAAPCONTENTFETCHER_H #define DAAPCONTENTFETCHER_H #include #include class QIODevice; class QNetworkReply; namespace Daap { /** Inspired by a daapsharp class of the same name. Basically it adds all the silly headers that DAAP needs @author Ian Monroe */ class ContentFetcher : public QObject { Q_OBJECT public: ContentFetcher( const QString & hostname, quint16 port, const QString& password, QObject * parent = nullptr, const char * name = 0 ); - ~ContentFetcher(); + ~ContentFetcher() override; void getDaap( const QString & command, QIODevice* musicFile = 0 ); QByteArray results(); private Q_SLOTS: void onFinished(); Q_SIGNALS: void httpError( const QString& ); void finished(); void loginRequired(); private: QNetworkReply *m_reply; QByteArray m_lastResult; QString m_hostname; quint16 m_port; QByteArray m_authorize; bool m_selfDestruct; static int s_requestId; //!< Apple needs this for some reason }; } #endif diff --git a/src/core-impl/collections/db/DatabaseCollection.h b/src/core-impl/collections/db/DatabaseCollection.h index 99431d8bd9..d940ec623c 100644 --- a/src/core-impl/collections/db/DatabaseCollection.h +++ b/src/core-impl/collections/db/DatabaseCollection.h @@ -1,156 +1,156 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Casey Link * * Copyright (c) 2010 Jeff Mitchell * * Copyright (c) 2013 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 AMAROK_COLLECTION_DATABASECOLLECTION_H #define AMAROK_COLLECTION_DATABASECOLLECTION_H #include "core/collections/Collection.h" #include "core/capabilities/CollectionScanCapability.h" #include "core/capabilities/CollectionImportCapability.h" #include #include typedef QHash TrackUrls; typedef QHash > ChangedTrackUrls; class MountPointManager; class GenericScanManager; namespace Collections { class CollectionLocation; /** The DatabaseCollection is intended to be a base class for all database backed primary collections. * Primary collection implies that the basis for the collection is a file system. * It also means that there is a scan manager that scans the file system and * a mount point manager for the dynamic collection feature (we can blend out * whole parts of the collection in case a drive is just unmounted). */ class DatabaseCollection : public Collections::Collection { Q_OBJECT /** This property is important. CollectionSetup is using the property to determine the folders covered by this collection (and also setting them) */ Q_PROPERTY( QStringList collectionFolders READ collectionFolders WRITE setCollectionFolders SCRIPTABLE false DESIGNABLE false ) public: /** Creates a new DatabaseCollection. */ DatabaseCollection(); - virtual ~DatabaseCollection(); + ~DatabaseCollection() override; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override; virtual GenericScanManager *scanManager() const; virtual MountPointManager *mountPointManager() const; /** This set's the mount point manager which is actually only useful for testing. * Note: The old MountPointManager is not deleted when the new one is set. */ virtual void setMountPointManager( MountPointManager *mpm ); virtual QStringList collectionFolders() const; virtual void setCollectionFolders( const QStringList &folders ); /** * Call this function to prevent the collection updated signal emitted. * This function can be called in preparation of larger updates. */ void blockUpdatedSignal(); /** * Unblocks one blockUpdatedSignal call. If collectionUpdated() has been called, * when the update was blocked, update() will be emitted here. */ void unblockUpdatedSignal(); /** * Emit updated if the signal. If it is blocked by blockUpdatedSignal(), it will * be postponed until unblockUpdatedSignal() is called, but never discarded. */ void collectionUpdated(); bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; public Q_SLOTS: /** Dumps the complete database content. * The content of all Amarok tables is dumped in a couple of files * in the users homedirectory. */ virtual void dumpDatabaseContent() = 0; protected Q_SLOTS: virtual void slotDeviceAdded( int id ) { Q_UNUSED( id ); } virtual void slotDeviceRemoved( int id ) { Q_UNUSED( id ); } protected: MountPointManager *m_mpm; GenericScanManager *m_scanManager; int m_blockUpdatedSignalCount; bool m_updatedSignalRequested; QMutex m_mutex; }; class DatabaseCollectionScanCapability : public Capabilities::CollectionScanCapability { Q_OBJECT public: explicit DatabaseCollectionScanCapability( DatabaseCollection* collection ); - virtual ~DatabaseCollectionScanCapability(); + ~DatabaseCollectionScanCapability() override; void startFullScan() override; void startIncrementalScan( const QString &directory = QString() ) override; void stopScan() override; private: DatabaseCollection* m_collection; }; class DatabaseCollectionImportCapability : public Capabilities::CollectionImportCapability { Q_OBJECT public: explicit DatabaseCollectionImportCapability( DatabaseCollection* collection ); - virtual ~DatabaseCollectionImportCapability(); + ~DatabaseCollectionImportCapability() override; void import( QIODevice *input, QObject *listener ) override; private: DatabaseCollection* m_collection; }; } Q_DECLARE_METATYPE( TrackUrls ) Q_DECLARE_METATYPE( ChangedTrackUrls ) #endif /* AMAROK_COLLECTION_DATABASECOLLECTION_H */ diff --git a/src/core-impl/collections/db/MountPointManager.h b/src/core-impl/collections/db/MountPointManager.h index f0c9624f2d..343ff503fb 100644 --- a/src/core-impl/collections/db/MountPointManager.h +++ b/src/core-impl/collections/db/MountPointManager.h @@ -1,230 +1,230 @@ /**************************************************************************************** * Copyright (c) 2006-2007 Maximilian Kossick * * * * 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_MOUNTPOINTMANAGER_H #define AMAROK_MOUNTPOINTMANAGER_H #include "core-impl/collections/db/sql/amarok_sqlcollection_export.h" #include #include #include #include #include #include class DeviceHandler; class DeviceHandlerFactory; class SqlStorage; class QUrl; namespace Solid { class Device; } typedef QList IdList; typedef QList FactoryList; typedef QMap HandlerMap; class DeviceHandlerFactory : public QObject { Q_OBJECT public: explicit DeviceHandlerFactory( QObject *parent ) : QObject( parent ) {} - virtual ~DeviceHandlerFactory() {} + ~DeviceHandlerFactory() override {} /** * checks whether a DeviceHandler subclass can handle a given Medium. * @param device the connected solid volume * @return true if the DeviceHandler implementation can handle the medium, * false otherwise */ virtual bool canHandle( const Solid::Device &device ) const = 0; /** * tells the MountPointManager whether it makes sense to ask the factory to * create a Devicehandler when a new Medium was connected * @return true if the factory can create DeviceHandlers from Medium instances */ virtual bool canCreateFromMedium() const = 0; /** * creates a DeviceHandler which represents the Medium. * @param device the Volume for which a DeviceHandler is required * @param udi the device UUID * @param s SQL storage * @return a DeviceHandler or 0 if the factory cannot handle the Medium */ virtual DeviceHandler* createHandler( const Solid::Device &device, const QString &udi, QSharedPointer s ) const = 0; virtual bool canCreateFromConfig() const = 0; virtual DeviceHandler* createHandler( const KSharedConfigPtr &c, QSharedPointer s ) const = 0; /** * returns the type of the DeviceHandler. Should be the same as the value used in * ~/.config/amarokrc * @return a QString describing the type of the DeviceHandler */ virtual QString type() const = 0; }; class DeviceHandler { public: DeviceHandler() {} virtual ~DeviceHandler() {} virtual bool isAvailable() const = 0; /** * returns the type of the DeviceHandler. Should be the same as the value used in * ~/.kde/share/config/amarokrc * @return a QString describing the type of the DeviceHandler */ virtual QString type() const = 0; /** * returns an absolute path which is guaranteed to be playable by amarok's current engine. (based on an * idea by andrewt512: this method would only be called when we actually want to play the file, not when we * simply want to show it to the user. It could for example download a file using KIO and return a path to a * temporary file. Needs some more thought and is not actually used at the moment. * @param absoluteUrl * @param relativeUrl */ virtual void getPlayableURL( QUrl &absoluteUrl, const QUrl &relativeUrl ) = 0; /** * builds an absolute path from a relative path and DeviceHandler specific information. The absolute path * is not necessarily playable! (based on an idea by andrewt512: allows better handling of files stored in remote * collections. this method would return a "pretty" URL which might not be playable by amarok's engines. * @param absoluteUrl the not necessarily playbale absolute path * @param relativeUrl the device specific relative path */ virtual void getURL( QUrl &absoluteUrl, const QUrl &relativeUrl ) = 0; /** * retrieves the unique database id of a given Medium. Implementations are responsible * for generating a (sufficiently) unique value which identifies the Medium. * Additionally, implementations must recognize unknown mediums and store the necessary * information to recognize them the next time they are connected in the database. * @return unique identifier which can be used as a foreign key to the media table. */ virtual int getDeviceID() = 0; virtual const QString &getDevicePath() const = 0; /** * allows MountPointManager to check if a device handler handles a specific medium. * @param udi * @return true if the device handler handles the Medium m */ virtual bool deviceMatchesUdi( const QString &udi ) const = 0; }; /** * @author Maximilian Kossick */ class AMAROK_SQLCOLLECTION_EXPORT MountPointManager : public QObject { Q_OBJECT public: MountPointManager( QObject *parent, QSharedPointer storage ); - ~MountPointManager(); + ~MountPointManager() override; /** * * @param url * @return */ virtual int getIdForUrl( const QUrl &url ); /** * * @param id * @return */ virtual QString getMountPointForId( const int id ) const; /** * builds the absolute path from the mount point of the medium and the given relative * path. * @param deviceId the medium(device)'s unique id * @param relativePath relative path on the medium * @return the absolute path */ virtual QString getAbsolutePath( const int deviceId, const QString& relativePath ) const; /** * calculates a file's/directory's relative path on a given device. * @param deviceId the unique id which identifies the device the file/directory is supposed to be on * @param absolutePath the file's/directory's absolute path */ virtual QString getRelativePath( const int deviceId, const QString& absolutePath ) const; /** * allows calling code to access the ids of all active devices * @return the ids of all devices which are currently mounted or otherwise accessible */ virtual IdList getMountedDeviceIds() const; virtual QStringList collectionFolders() const; virtual void setCollectionFolders( const QStringList &folders ); Q_SIGNALS: void deviceAdded( int id ); void deviceRemoved( int id ); private: void createDeviceFactories(); /** * Old Amarok versions used to have "Use MusicLocation" config option which caused * problems (bug 316216). This method converts out of it and needs to be run after * MountPointManager has initialized. */ void handleMusicLocation(); /** * checks whether a medium identified by its unique database id is currently mounted. * Note: does not handle deviceId = -1! It only checks real devices * @param deviceId the mediums unique id * @return true if the medium is mounted, false otherwise */ bool isMounted ( const int deviceId ) const; QSharedPointer m_storage; /** * maps a device id to a mount point. does only work for mountable filesystems and needs to be * changed for the real Dynamic Collection implementation. */ HandlerMap m_handlerMap; mutable QMutex m_handlerMapMutex; FactoryList m_mediumFactories; FactoryList m_remoteFactories; bool m_ready; //Solid specific void createHandlerFromDevice( const Solid::Device &device, const QString &udi ); private Q_SLOTS: void slotDeviceAdded( const QString &udi ); void slotDeviceRemoved( const QString &udi ); }; #endif diff --git a/src/core-impl/collections/db/sql/SqlCapabilities.h b/src/core-impl/collections/db/sql/SqlCapabilities.h index b8928f903d..ed664169f3 100644 --- a/src/core-impl/collections/db/sql/SqlCapabilities.h +++ b/src/core-impl/collections/db/sql/SqlCapabilities.h @@ -1,116 +1,116 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * Copyright (c) 2013 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 SQLCAPABILITIES_H #define SQLCAPABILITIES_H #include "amarok_sqlcollection_export.h" #include "amarokurls/PlayUrlRunner.h" #include "core/capabilities/Capability.h" #include "core/capabilities/FindInSourceCapability.h" #include "core/capabilities/OrganiseCapability.h" #include "core/meta/TrackEditor.h" #include "core-impl/capabilities/timecode/TimecodeLoadCapability.h" #include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" #include "core-impl/collections/db/sql/SqlMeta.h" /* note: currently SqlTrack has the following capabilities ActionsCapability OrganiseCapabilityImpl BookmarkThisCapability TimecodeWriteCapabilityImpl TimecodeLoadCapabilityImpl SqlReadLabelCapability SqlWriteLabelCapability FindInSourceCapabilityImpl */ namespace Capabilities { class OrganiseCapabilityImpl : public Capabilities::OrganiseCapability { Q_OBJECT public: explicit OrganiseCapabilityImpl( Meta::SqlTrack *track ); - virtual ~OrganiseCapabilityImpl(); + ~OrganiseCapabilityImpl() override; void deleteTrack() override; private: AmarokSharedPointer m_track; }; class TimecodeWriteCapabilityImpl : public Capabilities::TimecodeWriteCapability { Q_OBJECT public: explicit TimecodeWriteCapabilityImpl( Meta::SqlTrack *track ); - virtual ~TimecodeWriteCapabilityImpl(); + ~TimecodeWriteCapabilityImpl() override; bool writeTimecode( qint64 miliseconds ) override { return Capabilities::TimecodeWriteCapability::writeTimecode( miliseconds, Meta::TrackPtr( m_track.data() ) ); } bool writeAutoTimecode( qint64 miliseconds ) override { return Capabilities::TimecodeWriteCapability::writeAutoTimecode( miliseconds, Meta::TrackPtr( m_track.data() ) ); } private: AmarokSharedPointer m_track; }; class TimecodeLoadCapabilityImpl : public Capabilities::TimecodeLoadCapability { Q_OBJECT public: explicit TimecodeLoadCapabilityImpl( Meta::SqlTrack *track ); - virtual ~TimecodeLoadCapabilityImpl(); + ~TimecodeLoadCapabilityImpl() override; bool hasTimecodes() override; QList > loadTimecodes() override; private: AmarokSharedPointer m_track; }; class FindInSourceCapabilityImpl : public Capabilities::FindInSourceCapability { Q_OBJECT public: explicit FindInSourceCapabilityImpl( Meta::SqlTrack *track ); ~FindInSourceCapabilityImpl() override; void findInSource( QFlags tag ) override; private: AmarokSharedPointer m_track; }; } //namespace Capabilities #endif // SQLCAPABILITIES_H diff --git a/src/core-impl/collections/db/sql/SqlCollection.cpp b/src/core-impl/collections/db/sql/SqlCollection.cpp index acb091f3f2..c9b9830b92 100644 --- a/src/core-impl/collections/db/sql/SqlCollection.cpp +++ b/src/core-impl/collections/db/sql/SqlCollection.cpp @@ -1,478 +1,478 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Casey Link * * Copyright (c) 2008-2009 Jeff Mitchell * * Copyright (c) 2013 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 . * ****************************************************************************************/ #define DEBUG_PREFIX "SqlCollection" #include "SqlCollection.h" #include "DefaultSqlQueryMakerFactory.h" #include "DatabaseUpdater.h" #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/capabilities/TranscodeCapability.h" #include "core/transcoding/TranscodingController.h" #include "core-impl/collections/db/MountPointManager.h" #include "scanner/GenericScanManager.h" #include "scanner/AbstractDirectoryWatcher.h" #include "dialogs/OrganizeCollectionDialog.h" #include "SqlCollectionLocation.h" #include "SqlQueryMaker.h" #include "SqlScanResultProcessor.h" #include "SvgHandler.h" #include "MainWindow.h" #include "collectionscanner/BatchFile.h" #include #include #include #include #include #include #include #include /** Concrete implementation of the directory watcher */ class SqlDirectoryWatcher : public AbstractDirectoryWatcher { public: SqlDirectoryWatcher( Collections::SqlCollection* collection ) : AbstractDirectoryWatcher() , m_collection( collection ) { } - ~SqlDirectoryWatcher() + ~SqlDirectoryWatcher() override { } protected: QList collectionFolders() override { return m_collection->mountPointManager()->collectionFolders(); } Collections::SqlCollection* m_collection; }; class SqlScanManager : public GenericScanManager { public: SqlScanManager( Collections::SqlCollection* collection, QObject* parent ) : GenericScanManager( parent ) , m_collection( collection ) { } ~SqlScanManager() override { } protected: QList< QPair > getKnownDirs() { QList< QPair > result; // -- get all (mounted) mount points QList idList = m_collection->mountPointManager()->getMountedDeviceIds(); // -- query all known directories QString deviceIds; foreach( int id, idList ) { if( !deviceIds.isEmpty() ) deviceIds += ','; deviceIds += QString::number( id ); } QString query = QString( "SELECT deviceid, dir, changedate FROM directories WHERE deviceid IN (%1);" ); QStringList values = m_collection->sqlStorage()->query( query.arg( deviceIds ) ); for( QListIterator iter( values ); iter.hasNext(); ) { int deviceid = iter.next().toInt(); QString dir = iter.next(); uint mtime = iter.next().toUInt(); QString folder = m_collection->mountPointManager()->getAbsolutePath( deviceid, dir ); result.append( QPair( folder, mtime ) ); } return result; } QString getBatchFile( const QStringList &scanDirsRequested ) override { // -- write the batch file // the batch file contains the known modification dates so that the scanner only // needs to report changed directories QList > knownDirs = getKnownDirs(); if( !knownDirs.isEmpty() ) { QString path = QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation ) + "/amarok/amarokcollectionscanner_batchscan.xml"; while( QFile::exists( path ) ) path += '_'; CollectionScanner::BatchFile batchfile; batchfile.setTimeDefinitions( knownDirs ); batchfile.setDirectories( scanDirsRequested ); if( !batchfile.write( path ) ) { warning() << "Failed to write batch file" << path; return QString(); } return path; } return QString(); } Collections::SqlCollection* m_collection; }; namespace Collections { class OrganizeCollectionDelegateImpl : public OrganizeCollectionDelegate { public: OrganizeCollectionDelegateImpl() : OrganizeCollectionDelegate() , m_dialog( 0 ) , m_organizing( false ) {} - virtual ~ OrganizeCollectionDelegateImpl() { delete m_dialog; } + ~ OrganizeCollectionDelegateImpl() override { delete m_dialog; } void setTracks( const Meta::TrackList &tracks ) override { m_tracks = tracks; } void setFolders( const QStringList &folders ) override { m_folders = folders; } void setIsOrganizing( bool organizing ) override { m_organizing = organizing; } void setTranscodingConfiguration( const Transcoding::Configuration &configuration ) override { m_targetFileExtension = Amarok::Components::transcodingController()->format( configuration.encoder() )->fileExtension(); } void setCaption( const QString &caption ) override { m_caption = caption; } void show() override { m_dialog = new OrganizeCollectionDialog( m_tracks, m_folders, m_targetFileExtension, The::mainWindow(), //parent "", //name is unused true, //modal m_caption //caption ); connect( m_dialog, &OrganizeCollectionDialog::accepted, this, &OrganizeCollectionDelegateImpl::accepted ); connect( m_dialog, &OrganizeCollectionDialog::rejected, this, &OrganizeCollectionDelegateImpl::rejected ); m_dialog->show(); } bool overwriteDestinations() const override { return m_dialog->overwriteDestinations(); } QMap destinations() const override { return m_dialog->getDestinations(); } private: Meta::TrackList m_tracks; QStringList m_folders; OrganizeCollectionDialog *m_dialog; bool m_organizing; QString m_targetFileExtension; QString m_caption; }; class OrganizeCollectionDelegateFactoryImpl : public OrganizeCollectionDelegateFactory { public: OrganizeCollectionDelegate* createDelegate() override { return new OrganizeCollectionDelegateImpl(); } }; class SqlCollectionLocationFactoryImpl : public SqlCollectionLocationFactory { public: SqlCollectionLocationFactoryImpl( SqlCollection *collection ) : SqlCollectionLocationFactory() , m_collection( collection ) {} SqlCollectionLocation *createSqlCollectionLocation() const override { Q_ASSERT( m_collection ); SqlCollectionLocation *loc = new SqlCollectionLocation( m_collection ); loc->setOrganizeCollectionDelegateFactory( new OrganizeCollectionDelegateFactoryImpl() ); return loc; } Collections::SqlCollection *m_collection; }; } //namespace Collections using namespace Collections; SqlCollection::SqlCollection( const QSharedPointer &storage ) : DatabaseCollection() , m_registry( nullptr ) , m_sqlStorage( storage ) , m_scanProcessor( nullptr ) , m_directoryWatcher( nullptr ) , m_collectionLocationFactory( nullptr ) , m_queryMakerFactory( nullptr ) { qRegisterMetaType( "TrackUrls" ); qRegisterMetaType( "ChangedTrackUrls" ); // update database to current schema version; this must be run *before* MountPointManager // is initialized or its handlers may try to insert // into the database before it's created/updated! DatabaseUpdater updater( this ); if( updater.needsUpdate() ) { if( updater.schemaExists() ) // this is an update { QMessageBox dialog; dialog.setText( i18n( "Updating Amarok database schema. Please don't terminate " "Amarok now as it may result in database corruption." ) ); dialog.setWindowTitle( i18n( "Updating Amarok database schema" ) ); dialog.setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); dialog.show(); dialog.raise(); // otherwise the splash screen doesn't load image and this dialog is not shown: qApp->processEvents(); updater.update(); dialog.hide(); qApp->processEvents(); } else // this is new schema creation updater.update(); } //perform a quick check of the database updater.cleanupDatabase(); m_registry = new SqlRegistry( this ); m_collectionLocationFactory = new SqlCollectionLocationFactoryImpl( this ); m_queryMakerFactory = new DefaultSqlQueryMakerFactory( this ); // scanning m_scanManager = new SqlScanManager( this, this ); m_scanProcessor = new SqlScanResultProcessor( m_scanManager, this, this ); auto directoryWatcher = QSharedPointer::create( this ); m_directoryWatcher = directoryWatcher.toWeakRef(); connect( directoryWatcher.data(), &AbstractDirectoryWatcher::done, directoryWatcher.data(), &AbstractDirectoryWatcher::deleteLater ); // auto delete connect( directoryWatcher.data(), &AbstractDirectoryWatcher::requestScan, m_scanManager, &GenericScanManager::requestScan ); ThreadWeaver::Queue::instance()->enqueue( directoryWatcher ); } SqlCollection::~SqlCollection() { DEBUG_BLOCK if( auto directoryWatcher = m_directoryWatcher.toStrongRef() ) directoryWatcher->requestAbort(); delete m_scanProcessor; // this prevents any further commits from the scanner delete m_collectionLocationFactory; delete m_queryMakerFactory; delete m_registry; } QString SqlCollection::uidUrlProtocol() const { return "amarok-sqltrackuid"; } QString SqlCollection::generateUidUrl( const QString &hash ) { return uidUrlProtocol() + "://" + hash; } QueryMaker* SqlCollection::queryMaker() { Q_ASSERT( m_queryMakerFactory ); return m_queryMakerFactory->createQueryMaker(); } SqlRegistry* SqlCollection::registry() const { Q_ASSERT( m_registry ); return m_registry; } QSharedPointer SqlCollection::sqlStorage() const { Q_ASSERT( m_sqlStorage ); return m_sqlStorage; } bool SqlCollection::possiblyContainsTrack( const QUrl &url ) const { if( url.isLocalFile() ) { foreach( const QString &folder, collectionFolders() ) { QUrl q = QUrl::fromLocalFile( folder ); if( q.isParentOf( url ) || q.matches( url , QUrl::StripTrailingSlash) ) return true; } return false; } else return url.scheme() == uidUrlProtocol(); } Meta::TrackPtr SqlCollection::trackForUrl( const QUrl &url ) { if( url.scheme() == uidUrlProtocol() ) return m_registry->getTrackFromUid( url.url() ); else if( url.scheme() == "file" ) return m_registry->getTrack( url.path() ); else return Meta::TrackPtr(); } Meta::TrackPtr SqlCollection::getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ) { return m_registry->getTrack( deviceId, rpath, directoryId, uidUrl ); } Meta::TrackPtr SqlCollection::getTrackFromUid( const QString &uniqueid ) { return m_registry->getTrackFromUid( uniqueid ); } Meta::AlbumPtr SqlCollection::getAlbum( const QString &album, const QString &artist ) { return m_registry->getAlbum( album, artist ); } CollectionLocation* SqlCollection::location() { Q_ASSERT( m_collectionLocationFactory ); return m_collectionLocationFactory->createSqlCollectionLocation(); } void SqlCollection::slotDeviceAdded( int id ) { QString query = "select count(*) from tracks inner join urls on tracks.url = urls.id where urls.deviceid = %1"; QStringList rs = m_sqlStorage->query( query.arg( id ) ); if( !rs.isEmpty() ) { int count = rs.first().toInt(); if( count > 0 ) { collectionUpdated(); } } else { warning() << "Query " << query << "did not return a result! Is the database available?"; } } void SqlCollection::slotDeviceRemoved( int id ) { QString query = "select count(*) from tracks inner join urls on tracks.url = urls.id where urls.deviceid = %1"; QStringList rs = m_sqlStorage->query( query.arg( id ) ); if( !rs.isEmpty() ) { int count = rs.first().toInt(); if( count > 0 ) { collectionUpdated(); } } else { warning() << "Query " << query << "did not return a result! Is the database available?"; } } bool SqlCollection::hasCapabilityInterface( Capabilities::Capability::Type type ) const { switch( type ) { case Capabilities::Capability::Transcode: return true; default: return DatabaseCollection::hasCapabilityInterface( type ); } } Capabilities::Capability* SqlCollection::createCapabilityInterface( Capabilities::Capability::Type type ) { switch( type ) { case Capabilities::Capability::Transcode: return new SqlCollectionTranscodeCapability(); default: return DatabaseCollection::createCapabilityInterface( type ); } } void SqlCollection::dumpDatabaseContent() { DatabaseUpdater updater( this ); QStringList tables = m_sqlStorage->query( "select table_name from INFORMATION_SCHEMA.tables WHERE table_schema='amarok'" ); foreach( const QString &table, tables ) { QString filePath = QDir::home().absoluteFilePath( table + '-' + QDateTime::currentDateTime().toString( Qt::ISODate ) + ".csv" ); updater.writeCSVFile( table, filePath, true ); } } // ---------- SqlCollectionTranscodeCapability ------------- SqlCollectionTranscodeCapability::~SqlCollectionTranscodeCapability() { // nothing to do } Transcoding::Configuration SqlCollectionTranscodeCapability::savedConfiguration() { KConfigGroup transcodeGroup = Amarok::config( SQL_TRANSCODING_GROUP_NAME ); return Transcoding::Configuration::fromConfigGroup( transcodeGroup ); } void SqlCollectionTranscodeCapability::setSavedConfiguration( const Transcoding::Configuration &configuration ) { KConfigGroup transcodeGroup = Amarok::config( SQL_TRANSCODING_GROUP_NAME ); configuration.saveToConfigGroup( transcodeGroup ); transcodeGroup.sync(); } diff --git a/src/core-impl/collections/db/sql/SqlCollection.h b/src/core-impl/collections/db/sql/SqlCollection.h index ea4c7e294d..bfc39341ee 100644 --- a/src/core-impl/collections/db/sql/SqlCollection.h +++ b/src/core-impl/collections/db/sql/SqlCollection.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Casey Link * * Copyright (c) 2013 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 AMAROK_COLLECTION_SQLCOLLECTION_H #define AMAROK_COLLECTION_SQLCOLLECTION_H #include "amarok_sqlcollection_export.h" #include "core/capabilities/TranscodeCapability.h" #include #include #include "SqlRegistry.h" #include class SqlScanResultProcessor; class AbstractDirectoryWatcher; namespace Collections { class CollectionLocation; class SqlCollectionLocationFactory; class SqlQueryMakerFactory; /// Configuration group name in amarokrc for preferred transcoding configuration for SqlCollection static const QString SQL_TRANSCODING_GROUP_NAME = QStringLiteral("Collection Transcoding Preference"); class AMAROK_SQLCOLLECTION_EXPORT SqlCollection : public Collections::DatabaseCollection { Q_OBJECT public: /** Creates a new SqlCollection. * @param storage The storage this collection should work on. It will be freed by the collection. */ explicit SqlCollection( const QSharedPointer &storage ); ~SqlCollection() override; QueryMaker *queryMaker() override; /** Returns the protocol for the uid urls of this collection. The SqlCollection support "amarok-sqltrackuid" and "file" protocol. */ QString uidUrlProtocol() const override; /** * Generates uidUrl out of a hash (as returned by tag reader) that can be then * fed to Track::setUidUrl(). */ QString generateUidUrl( const QString &hash ); // Local collection cannot have a capacity since it may be spread over multiple // physical locations (even network components) SqlRegistry* registry() const; QSharedPointer sqlStorage() const; /** Every collection has this function. */ bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; /** Gets an existing track (or a new one) at the given position. This function should only be used by the SqlScanResultProcessor. */ virtual Meta::TrackPtr getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ); virtual Meta::TrackPtr getTrackFromUid( const QString &uniqueid ); virtual Meta::AlbumPtr getAlbum( const QString &album, const QString &artist ); CollectionLocation* location() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; public Q_SLOTS: /** Dumps the complete database content. * The content of all Amarok tables is dumped in a couple of files * in the users homedirectory. */ void dumpDatabaseContent() override; private Q_SLOTS: void slotDeviceAdded( int id ) override; void slotDeviceRemoved( int id ) override; private: SqlRegistry* m_registry; QSharedPointer m_sqlStorage; SqlScanResultProcessor* m_scanProcessor; QWeakPointer m_directoryWatcher; SqlCollectionLocationFactory* m_collectionLocationFactory; SqlQueryMakerFactory* m_queryMakerFactory; }; class AMAROK_SQLCOLLECTION_EXPORT SqlCollectionTranscodeCapability : public Capabilities::TranscodeCapability { Q_OBJECT public: - virtual ~SqlCollectionTranscodeCapability(); + ~SqlCollectionTranscodeCapability() override; Transcoding::Configuration savedConfiguration() override; void setSavedConfiguration( const Transcoding::Configuration &configuration ) override; }; } #endif /* AMAROK_COLLECTION_SQLCOLLECTION_H */ diff --git a/src/core-impl/collections/db/sql/SqlCollectionLocation.h b/src/core-impl/collections/db/sql/SqlCollectionLocation.h index 1d6e9daea2..9d867be0fc 100644 --- a/src/core-impl/collections/db/sql/SqlCollectionLocation.h +++ b/src/core-impl/collections/db/sql/SqlCollectionLocation.h @@ -1,165 +1,165 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2008 Jason A. Donenfeld * * Copyright (c) 2010 Casey Link * * Copyright (c) 2010 Teo Mrnjavac * * * * 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_SQLCOLLECTIONLOCATION_H #define AMAROK_SQLCOLLECTIONLOCATION_H #include "amarok_sqlcollection_export.h" #include "core/collections/CollectionLocation.h" #include #include #include #include #include class OrganizeCollectionDelegateFactory; namespace Collections { class SqlCollection; class SqlCollectionLocation; /** * @class TransferJob * A simple class that provides KJob functionality (progress reporting, aborting, etc) for sqlcollectionlocation. * It calls SqlCollectionLocation::startNextJob() */ class TransferJob : public KCompositeJob { Q_OBJECT public: TransferJob( SqlCollectionLocation * location, const Transcoding::Configuration & configuration ); void start() override; bool addSubjob( KJob* job ) override; void emitInfo( const QString &message ); public Q_SLOTS: /** * A move or copy job finished */ void slotJobFinished( KJob *job ); protected Q_SLOTS: void slotResult( KJob *job ) override; void doWork(); void propagateProcessedAmount( KJob *job, KJob::Unit unit, qulonglong amount); protected: bool doKill() override; private: SqlCollectionLocation* m_location; bool m_killed; Transcoding::Configuration m_transcodeFormat; }; class AMAROK_SQLCOLLECTION_EXPORT SqlCollectionLocation : public CollectionLocation { Q_OBJECT public: explicit SqlCollectionLocation( SqlCollection *collection ); - virtual ~SqlCollectionLocation(); + ~SqlCollectionLocation() override; QString prettyLocation() const override; QStringList actualLocation() const override; bool isWritable() const override; bool isOrganizable() const override; bool remove( const Meta::TrackPtr &track ); bool insert( const Meta::TrackPtr &track, const QString &path ) override; //dependency injectors void setOrganizeCollectionDelegateFactory( OrganizeCollectionDelegateFactory *fac ); protected: void showDestinationDialog( const Meta::TrackList &tracks, bool removeSources, const Transcoding::Configuration &configuration ) override; void copyUrlsToCollection( const QMap &sources, const Transcoding::Configuration & configuration ) override; void removeUrlsFromCollection( const Meta::TrackList &sources ) override; private Q_SLOTS: void slotDialogAccepted(); void slotDialogRejected(); void slotJobFinished( KJob *job ); void slotRemoveJobFinished( KJob *job ); void slotTransferJobFinished( KJob *job ); void slotTransferJobAborted(); private: QUrl moodFile( const QUrl &track ) const; void migrateLabels( const QMap &trackMap ); bool startNextJob(const Transcoding::Configuration &configuration ); bool startNextRemoveJob(); Collections::SqlCollection *m_collection; OrganizeCollectionDelegateFactory *m_delegateFactory; QMap m_destinations; QMap m_sources; Meta::TrackList m_removetracks; QHash m_originalUrls; bool m_overwriteFiles; QMap m_jobs; QMap m_removejobs; TransferJob* m_transferjob; friend class TransferJob; // so the transfer job can run the jobs }; class SqlCollectionLocationFactory { public: virtual SqlCollectionLocation* createSqlCollectionLocation() const = 0; virtual ~SqlCollectionLocationFactory() {} }; } //namespace Collections class AMAROK_SQLCOLLECTION_EXPORT OrganizeCollectionDelegate : public QObject { Q_OBJECT public: OrganizeCollectionDelegate() : QObject() {} - virtual ~ OrganizeCollectionDelegate() {} + ~ OrganizeCollectionDelegate() override {} virtual void setTracks( const Meta::TrackList &tracks ) = 0; virtual void setFolders( const QStringList &folders ) = 0; virtual void setIsOrganizing( bool organizing ) = 0; virtual void setTranscodingConfiguration( const Transcoding::Configuration &configuration ) = 0; virtual void setCaption( const QString &caption ) = 0; virtual void show() = 0; virtual bool overwriteDestinations() const = 0; virtual QMap destinations() const = 0; Q_SIGNALS: void accepted(); void rejected(); }; class OrganizeCollectionDelegateFactory { public: virtual OrganizeCollectionDelegate* createDelegate() = 0; virtual ~OrganizeCollectionDelegateFactory() {} }; #endif diff --git a/src/core-impl/collections/db/sql/SqlMeta.h b/src/core-impl/collections/db/sql/SqlMeta.h index 0e830b2592..cf0204ff9e 100644 --- a/src/core-impl/collections/db/sql/SqlMeta.h +++ b/src/core-impl/collections/db/sql/SqlMeta.h @@ -1,589 +1,589 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Alexandre Pereira de Oliveira * * Copyright (c) 2010 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 SQLMETA_H #define SQLMETA_H #include "core/meta/Meta.h" #include "core/meta/Statistics.h" #include "core/meta/TrackEditor.h" #include "core/meta/support/MetaConstants.h" #include "amarok_sqlcollection_export.h" #include "FileType.h" #include #include #include #include #include #include #include namespace Capabilities { } class SqlRegistry; class TrackUrlsTableCommitter; class TrackTracksTableCommitter; class TrackStatisticsTableCommitter; namespace Collections { class SqlCollection; } class SqlScanResultProcessor; namespace Meta { /** The SqlTrack is a Meta::Track used by the SqlCollection. The SqlTrack has a couple of functions for writing values and also some functions for getting e.g. the track id used in the underlying database. However it is not recommended to interface with the database directly. The whole class should be thread save. */ class AMAROK_SQLCOLLECTION_EXPORT SqlTrack : public Track, public Statistics, public TrackEditor { public: /** Creates a new SqlTrack without. * Note that the trackId and urlId are empty meaning that this track * has no database representation until it's written first by setting * some of the meta information. * It is advisable to set at least the path. */ SqlTrack( Collections::SqlCollection *collection, int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ); SqlTrack( Collections::SqlCollection *collection, const QStringList &queryResult ); ~ SqlTrack() override; QString name() const override; QString prettyName() const override; QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; QString notPlayableReason() const override; Meta::AlbumPtr album() const override; Meta::ArtistPtr artist() const override; Meta::ComposerPtr composer() const override; Meta::YearPtr year() const override; Meta::GenrePtr genre() const override; QString type() const override; qreal bpm() const override; QString comment() const override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; QDateTime createDate() const override; QDateTime modifyDate() const override; int trackNumber() const override; int discNumber() const override; qreal replayGain( Meta::ReplayGainTag mode ) const override; bool inCollection() const override; Collections::Collection* collection() const override; QString cachedLyrics() const override; void setCachedLyrics( const QString &lyrics ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void addLabel( const QString &label ) override; void addLabel( const Meta::LabelPtr &label ) override; void removeLabel( const Meta::LabelPtr &label ) override; Meta::LabelList labels() const override; TrackEditorPtr editor() override; StatisticsPtr statistics() override; // Meta::TrackEditor methods: void setAlbum( const QString &newAlbum ) override; void setAlbumArtist( const QString &newAlbumArtist ) override; void setArtist( const QString &newArtist ) override; void setComposer( const QString &newComposer ) override; void setGenre( const QString &newGenre ) override; void setYear( int newYear ) override; void setTitle( const QString &newTitle ) override; void setComment( const QString &newComment ) override; void setTrackNumber( int newTrackNumber ) override; void setDiscNumber( int newDiscNumber ) override; void setBpm( const qreal newBpm ) override; // Meta::Statistics methods: double score() const override; void setScore( double newScore ) override; int rating() const override; void setRating( int newRating ) override; QDateTime firstPlayed() const override; void setFirstPlayed( const QDateTime &newTime ) override; QDateTime lastPlayed() const override; void setLastPlayed( const QDateTime &newTime ) override; int playCount() const override; void setPlayCount( const int newCount ) override; // combined Meta::Statistics and Meta::TrackEditor methods: void beginUpdate() override; void endUpdate() override; // SqlTrack specific methods /** true if there is a collection, the file exists on disk and is writable */ bool isEditable() const; void setUidUrl( const QString &uid ); void setAlbum( int albumId ); void setType( Amarok::FileType newType ); void setLength( qint64 newLength ); void setSampleRate( int newSampleRate ); void setUrl( int deviceId, const QString &rpath, int directoryId ); void setBitrate( int newBitrate ); void setModifyDate( const QDateTime &newTime ); void setReplayGain( Meta::ReplayGainTag mode, qreal value ); /** Enables or disables writing changes to the file. * This function can be useful when changes are imported from the file. * In such a case writing the changes back again is stupid. */ virtual void setWriteFile( const bool enable ) { m_writeFile = enable; } int id() const; int urlId() const; Collections::SqlCollection* sqlCollection() const { return m_collection; } /** Does it's best to remove the track from database. * Considered that there is no signal that says "I am now removed" * this function still tries it's best to notify everyone * That the track is now removed, plus it will also delete it from * the database. */ void remove(); // SqlDatabase specific values /** Some numbers used in SqlRegistry. * Update if getTrackReturnValues is updated. */ enum TrackReturnIndex { returnIndex_urlId = 0, returnIndex_urlDeviceId = 1, returnIndex_urlRPath = 2, returnIndex_urlUid = 4, returnIndex_trackId = 5 }; // SqlDatabase specific values /** returns a string of all database values that can be fetched for a track */ static QString getTrackReturnValues(); /** returns the number of return values in getTrackReturnValues() */ static int getTrackReturnValueCount(); /** returns a string of all database joins that are required to fetch all values for a track*/ static QString getTrackJoinConditions(); protected: /** * Will commit all changes in m_cache if m_batch == 0. Must be called with m_lock * locked for writing. * * commitIfInNonBatchUpdate() will do three things: * 1. It will update the member variables. * 2. It will call all write methods * 3. It will notify all observers and the collection about the changes. */ void commitIfInNonBatchUpdate( qint64 field, const QVariant &value ); void commitIfInNonBatchUpdate(); void updatePlaylistsToDb( const FieldHash &fields, const QString &oldUid ); void updateEmbeddedCoversToDb( const FieldHash &fields, const QString &oldUid ); private: //helper functions static QString prettyTitle( const QString &filename ); Collections::SqlCollection* const m_collection; QString m_title; // the url table int m_urlId; int m_deviceId; QString m_rpath; int m_directoryId; // only set when the urls table needs to be written QUrl m_url; QString m_uid; // the rest int m_trackId; int m_statisticsId; qint64 m_length; qint64 m_filesize; int m_trackNumber; int m_discNumber; QDateTime m_lastPlayed; QDateTime m_firstPlayed; int m_playCount; int m_bitrate; int m_sampleRate; int m_rating; double m_score; QString m_comment; qreal m_bpm; qreal m_albumGain; qreal m_albumPeakGain; qreal m_trackGain; qreal m_trackPeakGain; QDateTime m_createDate; QDateTime m_modifyDate; Meta::AlbumPtr m_album; Meta::ArtistPtr m_artist; Meta::GenrePtr m_genre; Meta::ComposerPtr m_composer; Meta::YearPtr m_year; Amarok::FileType m_filetype; /** * Number of current batch operations started by @see beginUpdate() and not * yet ended by @see endUpdate(). Must only be accessed with m_lock held. */ int m_batchUpdate; bool m_writeFile; bool m_writeAllStatisticsFields; FieldHash m_cache; /** This ReadWriteLock is protecting all internal variables. It is ensuring that m_cache, m_batchUpdate and the other internal variable are in a consistent state all the time. */ mutable QReadWriteLock m_lock; mutable bool m_labelsInCache; mutable Meta::LabelList m_labelsCache; friend class ::SqlRegistry; // needs to call notifyObservers friend class ::TrackUrlsTableCommitter; friend class ::TrackTracksTableCommitter; friend class ::TrackStatisticsTableCommitter; }; class AMAROK_SQLCOLLECTION_EXPORT SqlArtist : public Meta::Artist { public: SqlArtist( Collections::SqlCollection* collection, int id, const QString &name ); - ~SqlArtist(); + ~SqlArtist() override; QString name() const override { return m_name; } virtual void invalidateCache(); Meta::TrackList tracks() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; //SQL specific methods int id() const { return m_id; } private: Collections::SqlCollection* const m_collection; const int m_id; const QString m_name; bool m_tracksLoaded; Meta::TrackList m_tracks; QMutex m_mutex; friend class ::SqlRegistry; // needs to call notifyObservers friend class Meta::SqlTrack; // needs to call notifyObservers }; /** Represents an albums stored in the database. Note: The album without name is special. It will always be a compilation and never have a picture. */ class AMAROK_SQLCOLLECTION_EXPORT SqlAlbum : public Meta::Album { public: SqlAlbum( Collections::SqlCollection* collection, int id, const QString &name, int artist ); - ~SqlAlbum(); + ~SqlAlbum() override; QString name() const override { return m_name; } virtual void invalidateCache(); Meta::TrackList tracks() override; bool isCompilation() const override; bool canUpdateCompilation() const override { return true; } void setCompilation( bool compilation ) override; /** Returns true if this album has an artist. * The following equation is always true: isCompilation() != hasAlbumArtist() */ bool hasAlbumArtist() const override; /** Returns the album artist. * Note that setting the album artist is not supported. * A compilation does not have an artist and not only an empty artist. */ Meta::ArtistPtr albumArtist() const override; //updating album images is possible for local tracks, but let's ignore it for now /** Returns true if the album has a cover image. * @param size The maximum width or height of the result. * when size is <= 1, return the full size image */ bool hasImage(int size = 0) const override; bool canUpdateImage() const override { return true; } /** Returns the album cover image. * Returns a default image if no specific album image could be found. * In such a case it will start the cover fetcher. * * @param size is the maximum width or height of the resulting image. * when size is <= 1, return the full size image */ QImage image( int size = 0 ) const override; QUrl imageLocation( int size = 0 ) override; void setImage( const QImage &image ) override; void removeImage() override; void setSuppressImageAutoFetch( const bool suppress ) override { m_suppressAutoFetch = suppress; } bool suppressImageAutoFetch() const override { return m_suppressAutoFetch; } bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; //SQL specific methods int id() const { return m_id; } Collections::SqlCollection *sqlCollection() const { return m_collection; } private: QByteArray md5sum( const QString& artist, const QString& album, const QString& file ) const; /** Returns a unique key for the album cover. */ QByteArray imageKey() const; /** Returns the path that the large scale image should have on the disk * Does not check if the file exists. * Note: not all large images have a disk cache, e.g. if they are set from outside * or embedded inside an audio file. * The largeDiskCache is only used for images set via setImage(QImage) */ QString largeDiskCachePath() const; /** Returns the path that the image should have on the disk * Does not check if the file exists. * @param size is the maximum width or height of the resulting image. * size==0 is the large image and the location of this file is completely different. * there should never be a scaled cached version of the large image. it dose not make * sense. */ QString scaledDiskCachePath( int size ) const; /** Returns the path to the large image * Queries the database for the path of the large scale image. */ QString largeImagePath(); /** Updates the database * Sets the current albums image to the given path. * The path should point to a valid image. * Note: setImage will not delete the already set image. */ void setImage( const QString &path ); /** Finds or creates a magic value in the database which tells Amarok not to auto fetch an image since it has been explicitly unset. */ int unsetImageId() const; Collections::SqlCollection* const m_collection; enum TracksLoadingStatus { NotLoaded, Loading, Loaded }; const QString m_name; const int m_id; // the id of this album in the database const int m_artistId; int m_imageId; mutable QString m_imagePath; // path read from the database mutable bool m_hasImage; // true if we have an original image mutable bool m_hasImageChecked; // true if hasImage was checked mutable int m_unsetImageId; // this is the id of the unset magic value in the image sql database static const QString AMAROK_UNSET_MAGIC; TracksLoadingStatus m_tracksLoaded; bool m_suppressAutoFetch; Meta::ArtistPtr m_artist; Meta::TrackList m_tracks; mutable QMutex m_mutex; //TODO: add album artist friend class ::SqlRegistry; // needs to call notifyObservers friend class Meta::SqlTrack; // needs to set images directly friend class ::SqlScanResultProcessor; // needs to set images directly }; class AMAROK_SQLCOLLECTION_EXPORT SqlComposer : public Meta::Composer { public: SqlComposer( Collections::SqlCollection* collection, int id, const QString &name ); QString name() const override { return m_name; } virtual void invalidateCache(); Meta::TrackList tracks() override; //SQL specific methods int id() const { return m_id; } private: Collections::SqlCollection* const m_collection; const int m_id; const QString m_name; bool m_tracksLoaded; bool m_tracksLoading; Meta::TrackList m_tracks; QMutex m_mutex; friend class ::SqlRegistry; // needs to call notifyObservers friend class Meta::SqlTrack; // needs to call notifyObservers }; class SqlGenre : public Meta::Genre { public: SqlGenre( Collections::SqlCollection* collection, int id, const QString &name ); QString name() const override { return m_name; } /** Invalidates the tracks cache */ /** Invalidates the tracks cache */ virtual void invalidateCache(); Meta::TrackList tracks() override; //SQL specific methods int id() const { return m_id; } private: Collections::SqlCollection* const m_collection; const int m_id; const QString m_name; bool m_tracksLoaded; Meta::TrackList m_tracks; QMutex m_mutex; friend class ::SqlRegistry; // needs to call notifyObservers friend class Meta::SqlTrack; // needs to call notifyObservers }; class AMAROK_SQLCOLLECTION_EXPORT SqlYear : public Meta::Year { public: SqlYear( Collections::SqlCollection* collection, int id, int year ); QString name() const override { return QString::number(m_year); } int year() const override { return m_year; } /** Invalidates the tracks cache */ virtual void invalidateCache(); Meta::TrackList tracks() override; //SQL specific methods int id() const { return m_id; } private: Collections::SqlCollection* const m_collection; const int m_id; const int m_year; bool m_tracksLoaded; Meta::TrackList m_tracks; QMutex m_mutex; friend class ::SqlRegistry; // needs to call notifyObservers friend class Meta::SqlTrack; // needs to call notifyObservers }; class AMAROK_SQLCOLLECTION_EXPORT SqlLabel : public Meta::Label { public: SqlLabel( Collections::SqlCollection *collection, int id, const QString &name ); QString name() const override { return m_name; } /** Invalidates the tracks cache */ virtual void invalidateCache(); virtual Meta::TrackList tracks(); //SQL specific methods int id() const { return m_id; } private: Collections::SqlCollection* const m_collection; const int m_id; const QString m_name; bool m_tracksLoaded; Meta::TrackList m_tracks; QMutex m_mutex; friend class ::SqlRegistry; // needs to call notifyObservers friend class Meta::SqlTrack; // needs to call notifyObservers }; typedef AmarokSharedPointer SqlTrackPtr; typedef AmarokSharedPointer SqlArtistPtr; typedef AmarokSharedPointer SqlAlbumPtr; typedef AmarokSharedPointer SqlComposerPtr; typedef AmarokSharedPointer SqlGenrePtr; typedef AmarokSharedPointer SqlYearPtr; } #endif /* SQLMETA_H */ diff --git a/src/core-impl/collections/db/sql/SqlQueryMaker.cpp b/src/core-impl/collections/db/sql/SqlQueryMaker.cpp index 4ae1fa6349..7733262c42 100644 --- a/src/core-impl/collections/db/sql/SqlQueryMaker.cpp +++ b/src/core-impl/collections/db/sql/SqlQueryMaker.cpp @@ -1,1191 +1,1191 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2008 Daniel Winter * * * * 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 . * ****************************************************************************************/ #define DEBUG_PREFIX "SqlQueryMaker" #include "SqlQueryMaker.h" #include "SqlCollection.h" #include "SqlQueryMakerInternal.h" #include #include "core/support/Debug.h" #include "core-impl/collections/db/MountPointManager.h" #include #include #include #include #include using namespace Collections; class SqlWorkerThread : public QObject, public ThreadWeaver::Job { Q_OBJECT public: SqlWorkerThread( SqlQueryMakerInternal *queryMakerInternal ) : QObject() , ThreadWeaver::Job() , m_queryMakerInternal( queryMakerInternal ) , m_aborted( false ) { //nothing to do } - virtual ~SqlWorkerThread() + ~SqlWorkerThread() override { delete m_queryMakerInternal; } void requestAbort() override { m_aborted = true; } SqlQueryMakerInternal* queryMakerInternal() const { return m_queryMakerInternal; } protected: void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override { Q_UNUSED(self); Q_UNUSED(thread); m_queryMakerInternal->run(); if( m_aborted ) setStatus(Status_Aborted); else setStatus(Status_Running); } void defaultBegin(const ThreadWeaver::JobPointer& self, ThreadWeaver::Thread *thread) override { Q_EMIT started(self); ThreadWeaver::Job::defaultBegin(self, thread); } void defaultEnd(const ThreadWeaver::JobPointer& self, ThreadWeaver::Thread *thread) override { ThreadWeaver::Job::defaultEnd(self, thread); if (!self->success()) { Q_EMIT failed(self); } Q_EMIT done(self); } private: SqlQueryMakerInternal *m_queryMakerInternal; bool m_aborted; Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); }; struct SqlQueryMaker::Private { enum { TAGS_TAB = 1, ARTIST_TAB = 2, ALBUM_TAB = 4, GENRE_TAB = 8, COMPOSER_TAB = 16, YEAR_TAB = 32, STATISTICS_TAB = 64, URLS_TAB = 128, ALBUMARTIST_TAB = 256, LABELS_TAB = 1024 }; int linkedTables; QueryMaker::QueryType queryType; QString query; QString queryReturnValues; QString queryFrom; QString queryMatch; QString queryFilter; QString queryOrderBy; bool withoutDuplicates; int maxResultSize; AlbumQueryMode albumMode; LabelQueryMode labelMode; SqlWorkerThread *worker; QStack andStack; QStringList blockingCustomData; Meta::TrackList blockingTracks; Meta::AlbumList blockingAlbums; Meta::ArtistList blockingArtists; Meta::GenreList blockingGenres; Meta::ComposerList blockingComposers; Meta::YearList blockingYears; Meta::LabelList blockingLabels; bool blocking; bool used; qint64 returnValueType; }; SqlQueryMaker::SqlQueryMaker( SqlCollection* collection ) : QueryMaker() , m_collection( collection ) , d( new Private ) { d->worker = 0; d->queryType = QueryMaker::None; d->linkedTables = 0; d->withoutDuplicates = false; d->albumMode = AllAlbums; d->labelMode = QueryMaker::NoConstraint; d->maxResultSize = -1; d->andStack.clear(); d->andStack.push( true ); //and is default d->blocking = false; d->used = false; d->returnValueType = 0; } SqlQueryMaker::~SqlQueryMaker() { disconnect(); abortQuery(); if( d->worker ) { d->worker->deleteLater(); } delete d; } void SqlQueryMaker::abortQuery() { if( d->worker ) { d->worker->requestAbort(); d->worker->disconnect( this ); if( d->worker->queryMakerInternal() ) d->worker->queryMakerInternal()->disconnect( this ); } } void SqlQueryMaker::run() { if( d->queryType == QueryMaker::None || (d->blocking && d->used) ) { debug() << "sql querymaker used without reset or initialization" << endl; return; //better error handling? } if( d->worker && !d->worker->isFinished() ) { //the worker thread seems to be running //TODO: wait or job to complete } else { SqlQueryMakerInternal *qmi = new SqlQueryMakerInternal( m_collection ); qmi->setQuery( query() ); qmi->setQueryType( d->queryType ); if ( !d->blocking ) { connect( qmi, &Collections::SqlQueryMakerInternal::newAlbumsReady, this, &SqlQueryMaker::newAlbumsReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newArtistsReady, this, &SqlQueryMaker::newArtistsReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newGenresReady, this, &SqlQueryMaker::newGenresReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newComposersReady, this, &SqlQueryMaker::newComposersReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newYearsReady, this, &SqlQueryMaker::newYearsReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newTracksReady, this, &SqlQueryMaker::newTracksReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newResultReady, this, &SqlQueryMaker::newResultReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newLabelsReady, this, &SqlQueryMaker::newLabelsReady, Qt::DirectConnection ); d->worker = new SqlWorkerThread( qmi ); connect( d->worker, &SqlWorkerThread::done, this, &SqlQueryMaker::done ); ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(d->worker) ); } else //use it blocking { connect( qmi, &Collections::SqlQueryMakerInternal::newAlbumsReady, this, &SqlQueryMaker::blockingNewAlbumsReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newArtistsReady, this, &SqlQueryMaker::blockingNewArtistsReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newGenresReady, this, &SqlQueryMaker::blockingNewGenresReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newComposersReady, this, &SqlQueryMaker::blockingNewComposersReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newYearsReady, this, &SqlQueryMaker::blockingNewYearsReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newTracksReady, this, &SqlQueryMaker::blockingNewTracksReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newResultReady, this, &SqlQueryMaker::blockingNewResultReady, Qt::DirectConnection ); connect( qmi, &Collections::SqlQueryMakerInternal::newLabelsReady, this, &SqlQueryMaker::blockingNewLabelsReady, Qt::DirectConnection ); qmi->run(); delete qmi; } } d->used = true; } void SqlQueryMaker::done( ThreadWeaver::JobPointer job ) { Q_UNUSED( job ) d->worker = 0; // d->worker *is* the job, prevent stale pointer Q_EMIT queryDone(); } QueryMaker* SqlQueryMaker::setQueryType( QueryType type ) { // we need the unchanged m_queryType in the blocking result methods so prevent // reseting queryType without reseting the QM if ( d->blocking && d->used ) return this; switch( type ) { case QueryMaker::Track: //make sure to keep this method in sync with handleTracks(QStringList) and the SqlTrack ctor if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Track; d->linkedTables |= Private::URLS_TAB; d->linkedTables |= Private::TAGS_TAB; d->linkedTables |= Private::GENRE_TAB; d->linkedTables |= Private::ARTIST_TAB; d->linkedTables |= Private::ALBUM_TAB; d->linkedTables |= Private::COMPOSER_TAB; d->linkedTables |= Private::YEAR_TAB; d->linkedTables |= Private::STATISTICS_TAB; d->queryReturnValues = Meta::SqlTrack::getTrackReturnValues(); } return this; case QueryMaker::Artist: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Artist; d->withoutDuplicates = true; d->linkedTables |= Private::ARTIST_TAB; //reading the ids from the database means we don't have to query for them later d->queryReturnValues = "artists.name, artists.id"; } return this; case QueryMaker::Album: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Album; d->withoutDuplicates = true; d->linkedTables |= Private::ALBUM_TAB; //add whatever is necessary to identify compilations d->queryReturnValues = "albums.name, albums.id, albums.artist"; } return this; case QueryMaker::AlbumArtist: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::AlbumArtist; d->withoutDuplicates = true; d->linkedTables |= Private::ALBUMARTIST_TAB; d->linkedTables |= Private::ALBUM_TAB; d->queryReturnValues = "albumartists.name, albumartists.id"; } return this; case QueryMaker::Composer: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Composer; d->withoutDuplicates = true; d->linkedTables |= Private::COMPOSER_TAB; d->queryReturnValues = "composers.name, composers.id"; } return this; case QueryMaker::Genre: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Genre; d->withoutDuplicates = true; d->linkedTables |= Private::GENRE_TAB; d->queryReturnValues = "genres.name, genres.id"; } return this; case QueryMaker::Year: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Year; d->withoutDuplicates = true; d->linkedTables |= Private::YEAR_TAB; d->queryReturnValues = "years.name, years.id"; } return this; case QueryMaker::Custom: if( d->queryType == QueryMaker::None ) d->queryType = QueryMaker::Custom; return this; case QueryMaker::Label: if( d->queryType == QueryMaker::None ) { d->queryType = QueryMaker::Label; d->withoutDuplicates = true; d->queryReturnValues = "labels.label,labels.id"; d->linkedTables |= Private::LABELS_TAB; } return this; case QueryMaker::None: return this; } return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::TrackPtr &track ) { QString url = track->uidUrl(); if( !url.isEmpty() ) /* QUrl kurl( url ); if( kurl.scheme() == "amarok-sqltrackuid" ) */ { d->queryMatch += QStringLiteral( " AND urls.uniqueid = '%1' " ).arg( url /*kurl.url()*/ ); } else { QString path; /* if( kurl.isLocalFile() ) { path = kurl.path(); } else */ { path = track->playableUrl().path(); } int deviceid = m_collection->mountPointManager()->getIdForUrl( QUrl::fromUserInput(path) ); QString rpath = m_collection->mountPointManager()->getRelativePath( deviceid, path ); d->queryMatch += QString( " AND urls.deviceid = %1 AND urls.rpath = '%2'" ) .arg( QString::number( deviceid ), escape( rpath ) ); } return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) { d->linkedTables |= Private::ARTIST_TAB; if( behaviour == AlbumArtists || behaviour == AlbumOrTrackArtists ) d->linkedTables |= Private::ALBUMARTIST_TAB; QString artistQuery; QString albumArtistQuery; if( artist && !artist->name().isEmpty() ) { artistQuery = QStringLiteral("artists.name = '%1'").arg( escape( artist->name() ) ); albumArtistQuery = QStringLiteral("albumartists.name = '%1'").arg( escape( artist->name() ) ); } else { artistQuery = "( artists.name IS NULL OR artists.name = '')"; albumArtistQuery = "( albumartists.name IS NULL OR albumartists.name = '')"; } switch( behaviour ) { case TrackArtists: d->queryMatch += " AND " + artistQuery; break; case AlbumArtists: d->queryMatch += " AND " + albumArtistQuery; break; case AlbumOrTrackArtists: d->queryMatch += " AND ( (" + artistQuery + " ) OR ( " + albumArtistQuery + " ) )"; break; } return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::AlbumPtr &album ) { d->linkedTables |= Private::ALBUM_TAB; // handle singles if( !album || album->name().isEmpty() ) d->queryMatch += QString( " AND ( albums.name IS NULL OR albums.name = '' )" ); else d->queryMatch += QString( " AND albums.name = '%1'" ).arg( escape( album->name() ) ); if( album ) { //handle compilations Meta::ArtistPtr albumArtist = album->albumArtist(); if( albumArtist ) { d->linkedTables |= Private::ALBUMARTIST_TAB; d->queryMatch += QString( " AND albumartists.name = '%1'" ).arg( escape( albumArtist->name() ) ); } else { d->queryMatch += " AND albums.artist IS NULL"; } } return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::GenrePtr &genre ) { d->linkedTables |= Private::GENRE_TAB; d->queryMatch += QString( " AND genres.name = '%1'" ).arg( escape( genre->name() ) ); return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::ComposerPtr &composer ) { d->linkedTables |= Private::COMPOSER_TAB; d->queryMatch += QString( " AND composers.name = '%1'" ).arg( escape( composer->name() ) ); return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::YearPtr &year ) { // handle tracks without a year if( !year ) { d->queryMatch += " AND year IS NULL"; } else { d->linkedTables |= Private::YEAR_TAB; d->queryMatch += QString( " AND years.name = '%1'" ).arg( escape( year->name() ) ); } return this; } QueryMaker* SqlQueryMaker::addMatch( const Meta::LabelPtr &label ) { AmarokSharedPointer sqlLabel = AmarokSharedPointer::dynamicCast( label ); QString labelSubQuery; if( sqlLabel ) { labelSubQuery = "SELECT url FROM urls_labels WHERE label = %1"; labelSubQuery = labelSubQuery.arg( sqlLabel->id() ); } else { labelSubQuery = "SELECT a.url FROM urls_labels a INNER JOIN labels b ON a.label = b.id WHERE b.label = '%1'"; labelSubQuery = labelSubQuery.arg( escape( label->name() ) ); } d->linkedTables |= Private::TAGS_TAB; QString match = " AND tracks.url in (%1)"; d->queryMatch += match.arg( labelSubQuery ); return this; } QueryMaker* SqlQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) { // special case for albumartist... if( value == Meta::valAlbumArtist && filter.isEmpty() ) { d->linkedTables |= Private::ALBUMARTIST_TAB; d->linkedTables |= Private::ALBUM_TAB; d->queryFilter += QString( " %1 ( albums.artist IS NULL or albumartists.name = '') " ).arg( andOr() ); } else if( value == Meta::valLabel ) { d->linkedTables |= Private::TAGS_TAB; QString like = likeCondition( filter, !matchBegin, !matchEnd ); QString filter = " %1 tracks.url IN (SELECT a.url FROM urls_labels a INNER JOIN labels b ON a.label = b.id WHERE b.label %2) "; d->queryFilter += filter.arg( andOr(), like ); } else { QString like = likeCondition( filter, !matchBegin, !matchEnd ); d->queryFilter += QString( " %1 %2 %3 " ).arg( andOr(), nameForValue( value ), like ); } return this; } QueryMaker* SqlQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) { // special case for album... if( value == Meta::valAlbumArtist && filter.isEmpty() ) { d->linkedTables |= Private::ALBUMARTIST_TAB; d->queryFilter += QString( " %1 NOT ( albums.artist IS NULL or albumartists.name = '') " ).arg( andOr() ); } else if( value == Meta::valLabel ) { d->linkedTables |= Private::TAGS_TAB; QString like = likeCondition( filter, !matchBegin, !matchEnd ); QString filter = " %1 tracks.url NOT IN (SELECT a.url FROM urls_labels a INNER JOIN labels b ON a.label = b.id WHERE b.label %2) "; d->queryFilter += filter.arg( andOr(), like ); } else { QString like = likeCondition( filter, !matchBegin, !matchEnd ); d->queryFilter += QString( " %1 NOT %2 %3 " ).arg( andOr(), nameForValue( value ), like ); } return this; } QueryMaker* SqlQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) { QString comparison; switch( compare ) { case QueryMaker::Equals: comparison = '='; break; case QueryMaker::GreaterThan: comparison = '>'; break; case QueryMaker::LessThan: comparison = '<'; break; } // note: a NULL value in the database means undefined and not 0! d->queryFilter += QString( " %1 %2 %3 %4 " ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) ); return this; } QueryMaker* SqlQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) { QString comparison; switch( compare ) { case QueryMaker::Equals: comparison = "!="; break; case QueryMaker::GreaterThan: //negating greater than is less or equal comparison = "<="; break; case QueryMaker::LessThan: //negating less than is greater or equal comparison = ">="; break; } // note: a NULL value in the database means undefined and not 0! // We can't exclude NULL values here because they are not defined! d->queryFilter += QString( " %1 (%2 %3 %4 or %2 is null)" ).arg( andOr(), nameForValue( value ), comparison, QString::number( filter ) ); return this; } QueryMaker* SqlQueryMaker::addReturnValue( qint64 value ) { if( d->queryType == QueryMaker::Custom ) { if ( !d->queryReturnValues.isEmpty() ) d->queryReturnValues += ','; d->queryReturnValues += nameForValue( value ); d->returnValueType = value; } return this; } QueryMaker* SqlQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) { if( d->queryType == QueryMaker::Custom ) { if( !d->queryReturnValues.isEmpty() ) d->queryReturnValues += ','; QString sqlfunction; switch( function ) { case QueryMaker::Count: sqlfunction = "COUNT"; break; case QueryMaker::Sum: sqlfunction = "SUM"; break; case QueryMaker::Max: sqlfunction = "MAX"; break; case QueryMaker::Min: sqlfunction = "MIN"; break; default: sqlfunction = "Unknown function in SqlQueryMaker::addReturnFunction, function was: " + QString::number( function ); } d->queryReturnValues += QString( "%1(%2)" ).arg( sqlfunction, nameForValue( value ) ); d->returnValueType = value; } return this; } QueryMaker* SqlQueryMaker::orderBy( qint64 value, bool descending ) { if ( d->queryOrderBy.isEmpty() ) d->queryOrderBy = " ORDER BY "; else d->queryOrderBy += ','; d->queryOrderBy += nameForValue( value ); d->queryOrderBy += QString( " %1 " ).arg( descending ? "DESC" : "ASC" ); return this; } QueryMaker* SqlQueryMaker::limitMaxResultSize( int size ) { d->maxResultSize = size; return this; } QueryMaker* SqlQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) { if( mode != AllAlbums ) { d->linkedTables |= Private::ALBUM_TAB; } d->albumMode = mode; return this; } QueryMaker* SqlQueryMaker::setLabelQueryMode( LabelQueryMode mode ) { d->labelMode = mode; return this; } QueryMaker* SqlQueryMaker::beginAnd() { d->queryFilter += andOr(); d->queryFilter += " ( 1 "; d->andStack.push( true ); return this; } QueryMaker* SqlQueryMaker::beginOr() { d->queryFilter += andOr(); d->queryFilter += " ( 0 "; d->andStack.push( false ); return this; } QueryMaker* SqlQueryMaker::endAndOr() { d->queryFilter += ')'; d->andStack.pop(); return this; } void SqlQueryMaker::linkTables() { switch( d->queryType ) { case QueryMaker::Track: { d->queryFrom += " tracks"; if( d->linkedTables & Private::TAGS_TAB ) d->linkedTables ^= Private::TAGS_TAB; break; } case QueryMaker::Artist: { d->queryFrom += " artists"; if( d->linkedTables != Private::ARTIST_TAB ) d->queryFrom += " JOIN tracks ON tracks.artist = artists.id"; if( d->linkedTables & Private::ARTIST_TAB ) d->linkedTables ^= Private::ARTIST_TAB; break; } case QueryMaker::Album: case QueryMaker::AlbumArtist: { d->queryFrom += " albums"; if( d->linkedTables != Private::ALBUM_TAB && d->linkedTables != ( Private::ALBUM_TAB | Private::ALBUMARTIST_TAB ) ) d->queryFrom += " JOIN tracks ON tracks.album = albums.id"; if( d->linkedTables & Private::ALBUM_TAB ) d->linkedTables ^= Private::ALBUM_TAB; break; } case QueryMaker::Genre: { d->queryFrom += " genres"; if( d->linkedTables != Private::GENRE_TAB ) d->queryFrom += " INNER JOIN tracks ON tracks.genre = genres.id"; if( d->linkedTables & Private::GENRE_TAB ) d->linkedTables ^= Private::GENRE_TAB; break; } case QueryMaker::Composer: { d->queryFrom += " composers"; if( d->linkedTables != Private::COMPOSER_TAB ) d->queryFrom += " JOIN tracks ON tracks.composer = composers.id"; if( d->linkedTables & Private::COMPOSER_TAB ) d->linkedTables ^= Private::COMPOSER_TAB; break; } case QueryMaker::Year: { d->queryFrom += " years"; if( d->linkedTables != Private::YEAR_TAB ) d->queryFrom += " JOIN tracks on tracks.year = years.id"; if( d->linkedTables & Private::YEAR_TAB ) d->linkedTables ^= Private::YEAR_TAB; break; } case QueryMaker::Label: { d->queryFrom += " labels"; if( d->linkedTables != Private::LABELS_TAB ) d->queryFrom += " INNER JOIN urls_labels ON labels.id = urls_labels.label" " INNER JOIN tracks ON urls_labels.url = tracks.url"; if( d->linkedTables & Private::LABELS_TAB ) d->linkedTables ^= Private::LABELS_TAB; break; } case QueryMaker::Custom: { switch( d->returnValueType ) { default: case Meta::valUrl: { d->queryFrom += " tracks"; if( d->linkedTables & Private::TAGS_TAB ) d->linkedTables ^= Private::TAGS_TAB; break; } case Meta::valAlbum: { d->queryFrom += " albums"; if( d->linkedTables & Private::ALBUM_TAB ) d->linkedTables ^= Private::ALBUM_TAB; if( d->linkedTables & Private::URLS_TAB ) d->linkedTables ^= Private::URLS_TAB; break; } case Meta::valArtist: { d->queryFrom += " artists"; if( d->linkedTables & Private::ARTIST_TAB ) d->linkedTables ^= Private::ARTIST_TAB; if( d->linkedTables & Private::URLS_TAB ) d->linkedTables ^= Private::URLS_TAB; break; } case Meta::valGenre: { d->queryFrom += " genres"; if( d->linkedTables & Private::GENRE_TAB ) d->linkedTables ^= Private::GENRE_TAB; if( d->linkedTables & Private::URLS_TAB ) d->linkedTables ^= Private::URLS_TAB; break; } } } case QueryMaker::None: { //??? break; } } if( !d->linkedTables ) return; if( d->linkedTables & Private::URLS_TAB ) d->queryFrom += " INNER JOIN urls ON tracks.url = urls.id"; if( d->linkedTables & Private::ARTIST_TAB ) d->queryFrom += " LEFT JOIN artists ON tracks.artist = artists.id"; if( d->linkedTables & Private::ALBUM_TAB ) d->queryFrom += " LEFT JOIN albums ON tracks.album = albums.id"; if( d->linkedTables & Private::ALBUMARTIST_TAB ) d->queryFrom += " LEFT JOIN artists AS albumartists ON albums.artist = albumartists.id"; if( d->linkedTables & Private::GENRE_TAB ) d->queryFrom += " LEFT JOIN genres ON tracks.genre = genres.id"; if( d->linkedTables & Private::COMPOSER_TAB ) d->queryFrom += " LEFT JOIN composers ON tracks.composer = composers.id"; if( d->linkedTables & Private::YEAR_TAB ) d->queryFrom += " LEFT JOIN years ON tracks.year = years.id"; if( d->linkedTables & Private::STATISTICS_TAB ) { if( d->linkedTables & Private::URLS_TAB ) { d->queryFrom += " LEFT JOIN statistics ON urls.id = statistics.url"; } else { d->queryFrom += " LEFT JOIN statistics ON tracks.url = statistics.url"; } } } void SqlQueryMaker::buildQuery() { //URLS is always required for dynamic collection d->linkedTables |= Private::URLS_TAB; linkTables(); QString query = "SELECT "; if ( d->withoutDuplicates ) query += "DISTINCT "; query += d->queryReturnValues; query += " FROM "; query += d->queryFrom; // dynamic collection (only mounted file systems are considered) if( (d->linkedTables & Private::URLS_TAB) && m_collection->mountPointManager() ) { query += " WHERE 1 "; IdList list = m_collection->mountPointManager()->getMountedDeviceIds(); if( !list.isEmpty() ) { QString commaSeparatedIds; foreach( int id, list ) { if( !commaSeparatedIds.isEmpty() ) commaSeparatedIds += ','; commaSeparatedIds += QString::number( id ); } query += QString( " AND urls.deviceid in (%1)" ).arg( commaSeparatedIds ); } } switch( d->albumMode ) { case OnlyNormalAlbums: query += " AND albums.artist IS NOT NULL "; break; case OnlyCompilations: query += " AND albums.artist IS NULL "; break; case AllAlbums: //do nothing break; } if( d->labelMode != QueryMaker::NoConstraint ) { switch( d->labelMode ) { case QueryMaker::OnlyWithLabels: query += " AND tracks.url IN "; break; case QueryMaker::OnlyWithoutLabels: query += " AND tracks.url NOT IN "; break; case QueryMaker::NoConstraint: //do nothing, will never be called break; } query += " (SELECT DISTINCT url FROM urls_labels) "; } query += d->queryMatch; if ( !d->queryFilter.isEmpty() ) { query += " AND ( 1 "; query += d->queryFilter; query += " ) "; } query += d->queryOrderBy; if ( d->maxResultSize > -1 ) query += QString( " LIMIT %1 OFFSET 0 " ).arg( d->maxResultSize ); query += ';'; d->query = query; } QString SqlQueryMaker::query() { if ( d->query.isEmpty() ) buildQuery(); return d->query; } QStringList SqlQueryMaker::runQuery( const QString &query ) { return m_collection->sqlStorage()->query( query ); } void SqlQueryMaker::setBlocking( bool enabled ) { d->blocking = enabled; } QStringList SqlQueryMaker::collectionIds() const { QStringList list; list << m_collection->collectionId(); return list; } Meta::TrackList SqlQueryMaker::tracks() const { return d->blockingTracks; } Meta::AlbumList SqlQueryMaker::albums() const { return d->blockingAlbums; } Meta::ArtistList SqlQueryMaker::artists() const { return d->blockingArtists; } Meta::GenreList SqlQueryMaker::genres() const { return d->blockingGenres; } Meta::ComposerList SqlQueryMaker::composers() const { return d->blockingComposers; } Meta::YearList SqlQueryMaker::years() const { return d->blockingYears; } QStringList SqlQueryMaker::customData() const { return d->blockingCustomData; } Meta::LabelList SqlQueryMaker::labels() const { return d->blockingLabels; } QString SqlQueryMaker::nameForValue( qint64 value ) { switch( value ) { case Meta::valUrl: d->linkedTables |= Private::URLS_TAB; return "urls.rpath"; //TODO figure out how to handle deviceid case Meta::valTitle: d->linkedTables |= Private::TAGS_TAB; return "tracks.title"; case Meta::valArtist: d->linkedTables |= Private::ARTIST_TAB; return "artists.name"; case Meta::valAlbum: d->linkedTables |= Private::ALBUM_TAB; return "albums.name"; case Meta::valGenre: d->linkedTables |= Private::GENRE_TAB; return "genres.name"; case Meta::valComposer: d->linkedTables |= Private::COMPOSER_TAB; return "composers.name"; case Meta::valYear: d->linkedTables |= Private::YEAR_TAB; return "years.name"; case Meta::valBpm: d->linkedTables |= Private::TAGS_TAB; return "tracks.bpm"; case Meta::valComment: d->linkedTables |= Private::TAGS_TAB; return "tracks.comment"; case Meta::valTrackNr: d->linkedTables |= Private::TAGS_TAB; return "tracks.tracknumber"; case Meta::valDiscNr: d->linkedTables |= Private::TAGS_TAB; return "tracks.discnumber"; case Meta::valLength: d->linkedTables |= Private::TAGS_TAB; return "tracks.length"; case Meta::valBitrate: d->linkedTables |= Private::TAGS_TAB; return "tracks.bitrate"; case Meta::valSamplerate: d->linkedTables |= Private::TAGS_TAB; return "tracks.samplerate"; case Meta::valFilesize: d->linkedTables |= Private::TAGS_TAB; return "tracks.filesize"; case Meta::valFormat: d->linkedTables |= Private::TAGS_TAB; return "tracks.filetype"; case Meta::valCreateDate: d->linkedTables |= Private::TAGS_TAB; return "tracks.createdate"; case Meta::valScore: d->linkedTables |= Private::STATISTICS_TAB; return "statistics.score"; case Meta::valRating: d->linkedTables |= Private::STATISTICS_TAB; return "statistics.rating"; case Meta::valFirstPlayed: d->linkedTables |= Private::STATISTICS_TAB; return "statistics.createdate"; case Meta::valLastPlayed: d->linkedTables |= Private::STATISTICS_TAB; return "statistics.accessdate"; case Meta::valPlaycount: d->linkedTables |= Private::STATISTICS_TAB; return "statistics.playcount"; case Meta::valUniqueId: d->linkedTables |= Private::URLS_TAB; return "urls.uniqueid"; case Meta::valAlbumArtist: d->linkedTables |= Private::ALBUMARTIST_TAB; //albumartist_tab means that the artist table is joined to the albums table //so add albums as well d->linkedTables |= Private::ALBUM_TAB; return "albumartists.name"; case Meta::valModified: d->linkedTables |= Private::TAGS_TAB; return "tracks.modifydate"; default: return "ERROR: unknown value in SqlQueryMaker::nameForValue(qint64): value=" + QString::number( value ); } } QString SqlQueryMaker::andOr() const { return d->andStack.top() ? " AND " : " OR "; } QString SqlQueryMaker::escape( const QString &text ) const //krazy:exclude=constref { return m_collection->sqlStorage()->escape( text ); } QString SqlQueryMaker::likeCondition( const QString &text, bool anyBegin, bool anyEnd ) const { if( anyBegin || anyEnd ) { QString escaped = text; //according to http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html //the escape character (\ as we are using the default) is escaped twice when using like. //mysql_real_escape will escape it once, so we have to escape it another time here escaped = escaped.replace( '\\', "\\\\" ); // "////" will result in two backslahes escaped = escape( escaped ); //as we are in pattern matching mode '_' and '%' have to be escaped //mysql_real_excape_string does not do that for us //see http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html //and http://dev.mysql.com/doc/refman/5.0/en/mysql-real-escape-string.html //replace those characters after calling escape(), which calls the mysql //function in turn, so that mysql does not escape the escape backslashes escaped.replace( '%', "\\%" ).replace( '_', "\\_" ); QString ret = " LIKE "; ret += '\''; if ( anyBegin ) ret += '%'; ret += escaped; if ( anyEnd ) ret += '%'; ret += '\''; //Case insensitive collation for queries ret += " COLLATE utf8_unicode_ci "; //Use \ as the escape character //ret += " ESCAPE '\\' "; return ret; } else { return QStringLiteral( " = '%1' COLLATE utf8_unicode_ci " ).arg( escape( text ) ); } } void SqlQueryMaker::blockingNewAlbumsReady(const Meta::AlbumList &albums) { d->blockingAlbums = albums; } void SqlQueryMaker::blockingNewArtistsReady(const Meta::ArtistList &artists) { d->blockingArtists = artists; } void SqlQueryMaker::blockingNewGenresReady(const Meta::GenreList &genres) { d->blockingGenres = genres; } void SqlQueryMaker::blockingNewComposersReady(const Meta::ComposerList &composers) { d->blockingComposers = composers; } void SqlQueryMaker::blockingNewYearsReady(const Meta::YearList &years) { d->blockingYears = years; } void SqlQueryMaker::blockingNewTracksReady(const Meta::TrackList &tracks) { d->blockingTracks = tracks; } void SqlQueryMaker::blockingNewResultReady(const QStringList &customData) { d->blockingCustomData = customData; } void SqlQueryMaker::blockingNewLabelsReady(const Meta::LabelList &labels ) { d->blockingLabels = labels; } #include "SqlQueryMaker.moc" diff --git a/src/core-impl/collections/db/sql/SqlQueryMaker.h b/src/core-impl/collections/db/sql/SqlQueryMaker.h index 97e3f66bbc..96e12f5506 100644 --- a/src/core-impl/collections/db/sql/SqlQueryMaker.h +++ b/src/core-impl/collections/db/sql/SqlQueryMaker.h @@ -1,135 +1,135 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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_COLLECTION_SQLQUERYMAKER_H #define AMAROK_COLLECTION_SQLQUERYMAKER_H #include "core/collections/QueryMaker.h" #include "amarok_sqlcollection_export.h" #include namespace Collections { class SqlCollection; class AMAROK_SQLCOLLECTION_EXPORT SqlQueryMaker : public QueryMaker { Q_OBJECT public: explicit SqlQueryMaker( SqlCollection* collection ); - virtual ~SqlQueryMaker(); + ~SqlQueryMaker() override; void abortQuery() override; void run() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::YearPtr &year ) override; QueryMaker* addMatch( const Meta::LabelPtr &label ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; QueryMaker* addReturnValue( qint64 value ) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy( qint64 value, bool descending = false ) override; QueryMaker* limitMaxResultSize( int size ) override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override; QueryMaker* beginAnd() override; QueryMaker* beginOr() override; QueryMaker* endAndOr() override; QString query(); QStringList runQuery( const QString &query ); void handleResult( const QStringList &result ); // for using it blocking (only for collection internal use) void setBlocking( bool enabled ); QStringList collectionIds() const; Meta::TrackList tracks() const; Meta::AlbumList albums() const; Meta::ArtistList artists() const; Meta::GenreList genres() const; Meta::ComposerList composers() const; Meta::YearList years() const; QStringList customData() const; Meta::LabelList labels() const; protected: virtual QString escape( const QString &text ) const; /** * returns a pattern for LIKE operator that will match given text with given options * @param text the text to match (should not be escape()'d, function does it itself) * @param anyBegin wildcard match the beginning of @p text (*text) * @param anyEnd wildcard match the end of @p text (text*) */ virtual QString likeCondition( const QString &text, bool anyBegin, bool anyEnd ) const; public Q_SLOTS: void done( ThreadWeaver::JobPointer job ); void blockingNewTracksReady( const Meta::TrackList& ); void blockingNewArtistsReady( const Meta::ArtistList& ); void blockingNewAlbumsReady( const Meta::AlbumList& ); void blockingNewGenresReady( const Meta::GenreList& ); void blockingNewComposersReady( const Meta::ComposerList& ); void blockingNewYearsReady( const Meta::YearList& ); void blockingNewResultReady( const QStringList& ); void blockingNewLabelsReady( const Meta::LabelList& ); private: void linkTables(); void buildQuery(); QString nameForValue( qint64 value ); QString andOr() const; SqlCollection *m_collection; struct Private; Private * const d; }; class SqlQueryMakerFactory { public: virtual SqlQueryMaker* createQueryMaker() const = 0; virtual ~SqlQueryMakerFactory() {} }; } //namespace Collections #endif /* AMAROK_COLLECTION_SQLQUERYMAKER_H */ diff --git a/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h b/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h index 7928ac7284..e7e5090852 100644 --- a/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h +++ b/src/core-impl/collections/db/sql/SqlQueryMakerInternal.h @@ -1,72 +1,72 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 SQLQUERYMAKERINTERNAL_H #define SQLQUERYMAKERINTERNAL_H #include "core/collections/QueryMaker.h" #include "core/meta/forward_declarations.h" #include #include #include namespace Collections { class SqlCollection; class SqlQueryMakerInternal : public QObject { Q_OBJECT public: explicit SqlQueryMakerInternal( SqlCollection *collection ); - virtual ~ SqlQueryMakerInternal(); + ~ SqlQueryMakerInternal() override; void run(); void setQuery( const QString &query ); void setQueryType( QueryMaker::QueryType type ); void setResultAsDataPtrs( bool value ); Q_SIGNALS: void newTracksReady( const Meta::TrackList& ); void newArtistsReady( const Meta::ArtistList& ); void newAlbumsReady( const Meta::AlbumList& ); void newGenresReady( const Meta::GenreList& ); void newComposersReady( const Meta::ComposerList& ); void newYearsReady( const Meta::YearList& ); void newResultReady( const QStringList& ); void newLabelsReady( const Meta::LabelList& ); private: void handleResult( const QStringList &result ); void handleTracks( const QStringList &result ); void handleArtists( const QStringList &result ); void handleAlbums( const QStringList &result ); void handleGenres( const QStringList &result ); void handleComposers( const QStringList &result ); void handleYears( const QStringList &result ); void handleLabels( const QStringList &result ); private: QPointer m_collection; QueryMaker::QueryType m_queryType; QString m_query; }; } //namespace Collections #endif // SQLQUERYMAKERINTERNAL_H diff --git a/src/core-impl/collections/db/sql/SqlRegistry.h b/src/core-impl/collections/db/sql/SqlRegistry.h index 0478b0617f..3dd04a85d9 100644 --- a/src/core-impl/collections/db/sql/SqlRegistry.h +++ b/src/core-impl/collections/db/sql/SqlRegistry.h @@ -1,246 +1,246 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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 SQLREGISTRY_H #define SQLREGISTRY_H #include "SqlMeta.h" #include "amarok_sqlcollection_export.h" #include #include #include #include #include #include class TestSqlAlbum; class TestSqlArtist; class TestSqlTrack; class TestSqlCollectionLocation; namespace Collections { class SqlCollection; class SqlQueryMakerInternal; } typedef QPair TrackPath; /** The SqlRegistry class buffers Meta objects from an Sql database. This class can be considered a memory cache for the Sql database. All requests for Meta objects like SqlTrack should go through here. Some notes regarding performance: Scanning of nearly 10000 tracks on my lokal disk takes over 2 minutes. The second time it only a little over 4 seconds. However I would not see the second scan as a valid usecase. Putting 10000 tracks from memory directly into the database with single inserts takes around 12 seconds. This time however increases dramatically with the amount of tracks. 50000 tracks take around 15 minutes. The reason is the many indices that need to be updated. The tracks table e.g. has around 15 indices. To increase the performance we are currently using two tricks. 1. Prevent queries. The SqlScanResultProcessor will query all tracks in the database. The SqlRegistry is caching them as usually but while the scanner is running it will not clean the cache. The SqlScanResultProcessor will also cache all urls entries. 2. Combine inserts and updates. All dirty tracks will be written in one big insert or with delayed updates. The ScanResultProcessor will block database access for five seconds at a time to collect dirty tracks for such a batch update. Have a look at the AbstractTrackTableCommitter to see how this is done. Note: updating tracks is not optimized for single changes. A single update is only done very seldom and does currently not need to be optimized. */ class AMAROK_SQLCOLLECTION_EXPORT SqlRegistry : public QObject { Q_OBJECT public: explicit SqlRegistry(Collections::SqlCollection *collection); - virtual ~SqlRegistry(); + ~SqlRegistry() override; /** Searches a directory entry in the scanned directories This function searches an existing directory entry. @param path the directory path @param mtime if mtime is != 0 then the mtime of the entry is updated @returns the directory id */ int getDirectory( const QString &path, uint mtime = 0 ); Meta::TrackPtr getTrack( int urlId ); Meta::TrackPtr getTrack( const QString &path ); /** Returns the track located at the given url or a new one if not existing. This is kind of dangerous because it can generate a new track in the database without a file on the filesystem, so don't call it unless you really want tracks to be generate. The new track must be committed by writing some other meta information. Use SqlCollection::trackForUrl instead. */ Meta::TrackPtr getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ); /** Returns a track from a specific uid. Returns a complete track or 0. */ Meta::TrackPtr getTrackFromUid( const QString &uid ); Meta::ArtistPtr getArtist( const QString &name ); Meta::ArtistPtr getArtist( int id ); Meta::GenrePtr getGenre( const QString &name ); Meta::GenrePtr getGenre( int id ); Meta::ComposerPtr getComposer( const QString &name ); Meta::ComposerPtr getComposer( int id ); Meta::YearPtr getYear( int year, int yearId = -1 ); Meta::AlbumPtr getAlbum( const QString &album, const QString &artist ); Meta::AlbumPtr getAlbum( int id ); Meta::LabelPtr getLabel( const QString &label ); Meta::LabelPtr getLabel( int id ); /** Call this function to collect changes for the sql database. This function can be called in preparation of larger updates. */ void blockDatabaseUpdate(); /** Unblocks one blockDatabaseUpdate call. */ void unblockDatabaseUpdate(); private Q_SLOTS: /** empytCache clears up the different hash tables by unrefing all pointers that are no longer ref'd by anyone else. SqlRegistry is calling this function periodically. This is no free ticket for modifying the database directly as parties holding Meta pointers will still have the old status. */ void emptyCache(); private: typedef QPair AlbumKey; // only SqlTrack can change this /** Updates the uid of an already cached track. @return true if the update was successful. */ bool updateCachedUrl( const QString &oldPath, const QString &newPath ); /** Updates the uid of an already cached track. @return true if the update was successful. */ bool updateCachedUid( const QString &oldUid, const QString &newUid ); /** * Removes the track and associated entries (url, statistics, lyrics, labels) * from the database and the cache (but not from the file system). This function * is normally called by SqlTrack. Do not call directly unless you know what you * do. */ void removeTrack( int urlId, const QString &uid ); // --- functions needed to commit a track /** Returns a string with all the values needed to be committed to the urls table */ QString getTrackUrlsValues( Meta::SqlTrack *track ); /** Returns a string with all the values needed to be committed to the tracks table */ QString getTrackTracksValues( Meta::SqlTrack *track ); /** Returns a string with all the values needed to be committed to the statistics table */ QString getTrackStatisticsValues( Meta::SqlTrack *track ); void commitDirtyTracks(); friend class Meta::SqlTrack; // only the query maker creates Metas like this Meta::TrackPtr getTrack( int id, const QStringList &rowData ); Meta::ArtistPtr getArtist( int id, const QString &name ); Meta::GenrePtr getGenre( int id, const QString &name ); Meta::ComposerPtr getComposer( int id, const QString &name ); Meta::AlbumPtr getAlbum( int id, const QString &album, int artistId ); Meta::LabelPtr getLabel( int id, const QString &label ); friend class Collections::SqlQueryMakerInternal; // we don't care about the ordering so use the faster QHash QHash m_trackMap; QHash m_uidMap; QHash m_artistMap; QHash m_artistIdMap; QHash m_composerMap; QHash m_genreMap; QHash m_yearMap; QHash m_albumMap; QHash m_albumIdMap; QHash m_labelMap; QMutex m_trackMutex; // guards access to m_trackMap, m_uidMap QMutex m_artistMutex; // guards access to m_artistMap, m_artistIdMap QMutex m_composerMutex; // guards access to m_composerMap QMutex m_genreMutex; // guards access to m_genreMap QMutex m_yearMutex; // guards access to m_yearMap QMutex m_albumMutex; // guards access to m_albumMap, m_albumIdMap QMutex m_labelMutex; // guards access to m_labelMap /** The timer is used for cleaning up the different caches. */ QTimer *m_timer; Collections::SqlCollection *m_collection; QMutex m_blockMutex; // protects the count and all the dirty sets. int m_blockDatabaseUpdateCount; /** A set of all tracks that need to be written to the database */ QSet< Meta::SqlTrackPtr > m_dirtyTracks; /** A set of all tracks that are dirty. Dirty years do not need to be written back as they are invariant. However we need to notice the observers and invalidate the cache. */ QSet< Meta::SqlYearPtr > m_dirtyYears; QSet< Meta::SqlGenrePtr > m_dirtyGenres; QSet< Meta::SqlAlbumPtr > m_dirtyAlbums; QSet< Meta::SqlArtistPtr > m_dirtyArtists; QSet< Meta::SqlComposerPtr > m_dirtyComposers; /** Set to true when something was added or removed form the database */ bool m_collectionChanged; friend class SqlScanResultProcessor; // all those classes need to call emptyCache friend class TestSqlScanManager; friend class TestSqlAlbum; friend class TestSqlArtist; friend class TestSqlTrack; friend class TestSqlCollectionLocation; }; #endif /* SQLREGISTRY_H */ diff --git a/src/core-impl/collections/db/sql/SqlRegistry_p.h b/src/core-impl/collections/db/sql/SqlRegistry_p.h index cd5dd132d7..b451989aca 100644 --- a/src/core-impl/collections/db/sql/SqlRegistry_p.h +++ b/src/core-impl/collections/db/sql/SqlRegistry_p.h @@ -1,99 +1,99 @@ /**************************************************************************************** * Copyright (c) 2010 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 SQLREGISTRY_P_H #define SQLREGISTRY_P_H #include "SqlMeta.h" #include #include #include class SqlStorage; /** A table committer will commit one table for a list of tracks. The table committer is a helper class that will batch insert/update one table for a list of tracks. */ class AbstractTrackTableCommitter { public: /** Will commit one table for all the tracks. This will insert all the values into one table or update all the values. The id will be updated. */ void commit( const QList &tracks ); virtual ~AbstractTrackTableCommitter() {} protected: virtual QString tableName() = 0; virtual int getId( Meta::SqlTrack *track ) = 0; virtual void setId( Meta::SqlTrack *track, int id ) = 0; virtual QStringList getFields() = 0; virtual QStringList getValues( Meta::SqlTrack *track ) = 0; QString nullString( const QString &str ) const; QString nullNumber( const qint64 number ) const; QString nullNumber( const int number ) const; QString nullNumber( const double number ) const; QString nullDate( const QDateTime &date ) const; QString escape( const QString &str ) const; QSharedPointer m_storage; }; class TrackUrlsTableCommitter: public AbstractTrackTableCommitter { public: - virtual ~TrackUrlsTableCommitter() {} + ~TrackUrlsTableCommitter() override {} protected: QString tableName() override; int getId( Meta::SqlTrack *track ) override; void setId( Meta::SqlTrack *track, int id ) override; QStringList getFields() override; QStringList getValues( Meta::SqlTrack *track ) override; }; class TrackTracksTableCommitter: public AbstractTrackTableCommitter { public: - virtual ~TrackTracksTableCommitter() {} + ~TrackTracksTableCommitter() override {} protected: QString tableName() override; int getId( Meta::SqlTrack *track ) override; void setId( Meta::SqlTrack *track, int id ) override; QStringList getFields() override; QStringList getValues( Meta::SqlTrack *track ) override; }; class TrackStatisticsTableCommitter: public AbstractTrackTableCommitter { public: - virtual ~TrackStatisticsTableCommitter() {} + ~TrackStatisticsTableCommitter() override {} protected: QString tableName() override; int getId( Meta::SqlTrack *track ) override; void setId( Meta::SqlTrack *track, int id ) override; QStringList getFields() override; QStringList getValues( Meta::SqlTrack *track ) override; }; #endif /* SQLREGISTRY_P_H */ diff --git a/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h b/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h index 994afc767f..823fba6eae 100644 --- a/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h +++ b/src/core-impl/collections/db/sql/device/massstorage/MassStorageDeviceHandler.h @@ -1,72 +1,72 @@ /**************************************************************************************** * Copyright (c) 2006-2007 Maximilian Kossick * * * * 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 MASSSTORAGEDEVICEHANDLER_H #define MASSSTORAGEDEVICEHANDLER_H #include "core-impl/collections/db/MountPointManager.h" class SqlStorage; class MassStorageDeviceHandlerFactory : public DeviceHandlerFactory { public: explicit MassStorageDeviceHandlerFactory( QObject *parent ) : DeviceHandlerFactory( parent ) {} - virtual ~MassStorageDeviceHandlerFactory(); + ~MassStorageDeviceHandlerFactory() override; bool canHandle( const Solid::Device &device ) const override; bool canCreateFromMedium() const override; DeviceHandler* createHandler( const Solid::Device &device, const QString &uuid, QSharedPointer s ) const override; bool canCreateFromConfig() const override; DeviceHandler* createHandler( const KSharedConfigPtr &c, QSharedPointer s ) const override; QString type() const override; private: bool excludedFilesystem( const QString &fstype ) const; }; /** @author Maximilian Kossick */ class MassStorageDeviceHandler : public DeviceHandler { public: MassStorageDeviceHandler(); MassStorageDeviceHandler(int deviceId, const QString &mountPoint, const QString &uuid ); - virtual ~MassStorageDeviceHandler(); + ~MassStorageDeviceHandler() override; bool isAvailable() const override; QString type() const override; int getDeviceID( ) override; const QString &getDevicePath() const override; void getURL( QUrl &absolutePath, const QUrl &relativePath ) override; void getPlayableURL( QUrl &absolutePath, const QUrl &relativePath ) override; bool deviceMatchesUdi( const QString &udi ) const override; private: int m_deviceID; const QString m_mountPoint; QString m_udi; }; #endif diff --git a/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h b/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h index 6bc991f05b..48d782bcff 100644 --- a/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h +++ b/src/core-impl/collections/db/sql/device/nfs/NfsDeviceHandler.h @@ -1,72 +1,72 @@ /**************************************************************************************** * Copyright (c) 2006-2007 Maximilian Kossick * * Copyright (c) 2011 Peter C. Ndikuwera * * * * 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 NFSDEVICEHANDLER_H #define NFSDEVICEHANDLER_H #include "core-impl/collections/db/MountPointManager.h" class NfsDeviceHandlerFactory : public DeviceHandlerFactory { public: explicit NfsDeviceHandlerFactory( QObject *parent ) : DeviceHandlerFactory( parent ) {} - virtual ~NfsDeviceHandlerFactory(); + ~NfsDeviceHandlerFactory() override; bool canHandle( const Solid::Device &device ) const override; bool canCreateFromMedium() const override; DeviceHandler* createHandler( const Solid::Device &device, const QString &uuid, QSharedPointer s ) const override; bool canCreateFromConfig() const override; DeviceHandler* createHandler( const KSharedConfigPtr &c, QSharedPointer s ) const override; QString type() const override; }; /** @author Maximilian Kossick */ class NfsDeviceHandler : public DeviceHandler { public: NfsDeviceHandler(); NfsDeviceHandler(int deviceId, const QString &mountPoint, const QString &udi ); NfsDeviceHandler(int deviceId, const QString &server, const QString &share, const QString &mountPoint, const QString &udi ); - virtual ~NfsDeviceHandler(); + ~NfsDeviceHandler() override; bool isAvailable() const override; QString type() const override; int getDeviceID( ) override; const QString &getDevicePath() const override; void getURL( QUrl &absolutePath, const QUrl &relativePath ) override; void getPlayableURL( QUrl &absoluteUrl, const QUrl &relativeUrl ) override; bool deviceMatchesUdi( const QString &udi ) const override; private: int m_deviceID; QString m_server; QString m_share; const QString m_mountPoint; QString m_udi; }; #endif diff --git a/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h b/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h index d729e33f2e..a8735e956a 100644 --- a/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h +++ b/src/core-impl/collections/db/sql/device/smb/SmbDeviceHandler.h @@ -1,72 +1,72 @@ /**************************************************************************************** * Copyright (c) 2006-2007 Maximilian Kossick * * Copyright (c) 2011 Peter C. Ndikuwera * * * * 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 SMBDEVICEHANDLER_H #define SMBDEVICEHANDLER_H #include "core-impl/collections/db/MountPointManager.h" class SmbDeviceHandlerFactory : public DeviceHandlerFactory { public: explicit SmbDeviceHandlerFactory( QObject *parent ) : DeviceHandlerFactory( parent ) {} ~SmbDeviceHandlerFactory() override; bool canHandle( const Solid::Device &device ) const override; bool canCreateFromMedium() const override; DeviceHandler* createHandler( const Solid::Device &device, const QString &uuid, QSharedPointer s ) const override; bool canCreateFromConfig() const override; DeviceHandler* createHandler( const KSharedConfigPtr &c, QSharedPointer s ) const override; QString type() const override; }; /** @author Maximilian Kossick */ class SmbDeviceHandler : public DeviceHandler { public: SmbDeviceHandler(); SmbDeviceHandler(int deviceId, const QString &mountPoint, const QString &udi ); SmbDeviceHandler(int deviceId, const QString &server, const QString &share, const QString &mountPoint, const QString &udi ); - virtual ~SmbDeviceHandler(); + ~SmbDeviceHandler() override; bool isAvailable() const override; QString type() const override; int getDeviceID( ) override; const QString &getDevicePath() const override; void getURL( QUrl &absolutePath, const QUrl &relativePath ) override; void getPlayableURL( QUrl &absolutePath, const QUrl &relativePath ) override; bool deviceMatchesUdi( const QString &udi ) const override; private: int m_deviceID; QString m_server; QString m_share; const QString m_mountPoint; QString m_udi; }; #endif diff --git a/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h b/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h index eab96e8472..68a5e54129 100644 --- a/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h +++ b/src/core-impl/collections/mediadevicecollection/MediaDeviceCollection.h @@ -1,172 +1,172 @@ /**************************************************************************************** * Copyright (c) 2008 Alejandro Wainzinger * * * * 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 MEDIADEVICECOLLECTION_H #define MEDIADEVICECOLLECTION_H #include "core/collections/Collection.h" #include "core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h" #include "core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h" #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" #include "core-impl/collections/support/MemoryCollection.h" #include #include #include namespace Collections { class MediaDeviceCollection; /** * HACK: Base and Factory are separate because Q_OBJECT does not work directly with templates. * Templates used to reduce duplicated code in subclasses. */ class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollectionFactoryBase : public Collections::CollectionFactory { Q_OBJECT public: - virtual ~MediaDeviceCollectionFactoryBase(); + ~MediaDeviceCollectionFactoryBase() override; void init() override; protected: MediaDeviceCollectionFactoryBase( ConnectionAssistant* assistant ); protected Q_SLOTS: virtual void slotDeviceDetected( MediaDeviceInfo* info ); // detected type of device, connect it private Q_SLOTS: void slotDeviceDisconnected( const QString &udi ); private: virtual MediaDeviceCollection* createCollection( MediaDeviceInfo* info ) = 0; ConnectionAssistant* m_assistant; QMap m_collectionMap; }; template class MediaDeviceCollectionFactory : public MediaDeviceCollectionFactoryBase { protected: MediaDeviceCollectionFactory( ConnectionAssistant *assistant ) : MediaDeviceCollectionFactoryBase( assistant ) {} - virtual ~MediaDeviceCollectionFactory() {} + ~MediaDeviceCollectionFactory() override {} private: MediaDeviceCollection* createCollection( MediaDeviceInfo* info ) override { return new CollType( info ); } }; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollection : public Collections::Collection { Q_OBJECT public: /** Collection-related methods */ - virtual ~MediaDeviceCollection(); + ~MediaDeviceCollection() override; /** * url-based methods can be abstracted via use of Amarok URLs * subclasses simply define a protocol prefix, e.g. ipod */ bool possiblyContainsTrack( const QUrl &url ) const override { Q_UNUSED(url); return false;} // TODO: NYI Meta::TrackPtr trackForUrl( const QUrl &url ) override { Q_UNUSED(url); return Meta::TrackPtr(); } // TODO: NYI QueryMaker* queryMaker() override; virtual void startFullScanDevice(); // NOTE: incrementalscan and stopscan not implemented, might be used by UMS later though /** The protocol of uids coming from this collection. @return A string of the protocol, without the :// This has to be overridden for every device type, e.g. ipod:// */ QString uidUrlProtocol() const override { return QString(); } // TODO: NYI QString collectionId() const override; // uses udi QString prettyName() const override = 0; // NOTE: must be overridden based on device type QIcon icon() const override = 0; // NOTE: must be overridden based on device type bool hasCapacity() const override; float usedCapacity() const override; float totalCapacity() const override; // NOTE: location will have same method calls always, no need to redo each time CollectionLocation* location() override { return new MediaDeviceCollectionLocation( this ); } /** Capability-related methods */ bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; /** MediaDeviceCollection methods */ QString udi() const { return m_udi; } /** MediaDeviceCollection-specific */ Meta::MediaDeviceHandler* handler(); void init() { m_handler->init(); } // tell handler to start connection void emitCollectionReady(); virtual QAction *ejectAction() const; QSharedPointer memoryCollection() const { return m_mc; } void collectionUpdated() { Q_EMIT updated(); } Q_SIGNALS: void collectionReady( Collections::Collection* ); /** collectionDisconnected is called when ConnectionAssistant is told it is to be disconnected. This could be because another part of Amarok (e.g. applet) told it to or because the MediaDeviceMonitor noticed it disconnect */ void collectionDisconnected( const QString &udi ); void deletingCollection(); void attemptConnectionDone( bool success ); void copyTracksCompleted( bool success ); public Q_SLOTS: void slotAttemptConnectionDone( bool success ); virtual void eject(); void deleteCollection(); protected: MediaDeviceCollection(); QString m_udi; Meta::MediaDeviceHandler *m_handler; mutable QAction *m_ejectAction; QSharedPointer m_mc; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h b/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h index e7df56f390..f8fa7cf1de 100644 --- a/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h +++ b/src/core-impl/collections/mediadevicecollection/MediaDeviceCollectionLocation.h @@ -1,64 +1,64 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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_MEDIADEVICECOLLECTIONLOCATION_H #define AMAROK_MEDIADEVICECOLLECTIONLOCATION_H #include "core/collections/CollectionLocation.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h" #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" #include #include #include namespace Collections { class MediaDeviceCollection; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollectionLocation : public CollectionLocation { Q_OBJECT public: explicit MediaDeviceCollectionLocation( MediaDeviceCollection *collection ); - virtual ~MediaDeviceCollectionLocation(); + ~MediaDeviceCollectionLocation() override; QString prettyLocation() const override; bool isWritable() const override; protected: void getKIOCopyableUrls( const Meta::TrackList &tracks ) override; /// Copies these tracks to the Collection using the Handler void copyUrlsToCollection( const QMap &sources, const Transcoding::Configuration &configuration ) override; void removeUrlsFromCollection( const Meta::TrackList &sources ) override; private Q_SLOTS: void copyOperationFinished( bool success ); void removeOperationFinished(); private: MediaDeviceCollection *m_collection; Meta::MediaDeviceHandler *m_handler; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h b/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h index 8417423cd3..2a2d0ac06e 100644 --- a/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h +++ b/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.h @@ -1,311 +1,311 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 MEDIADEVICEMETA_H #define MEDIADEVICEMETA_H #include "core/meta/Meta.h" #include "core/meta/Statistics.h" #include "core/support/Debug.h" #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" #include #include #include namespace Collections { class MediaDeviceCollection; } namespace Handler { class ArtworkCapability; } namespace Meta { class MediaDeviceTrack; class MediaDeviceAlbum; class MediaDeviceArtist; class MediaDeviceGenre; class MediaDeviceComposer; class MediaDeviceYear; typedef AmarokSharedPointer MediaDeviceTrackPtr; typedef AmarokSharedPointer MediaDeviceArtistPtr; typedef AmarokSharedPointer MediaDeviceAlbumPtr; typedef AmarokSharedPointer MediaDeviceGenrePtr; typedef AmarokSharedPointer MediaDeviceComposerPtr; typedef AmarokSharedPointer MediaDeviceYearPtr; typedef QList MediaDeviceTrackList; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceTrack : public Meta::Track, public Statistics { public: explicit MediaDeviceTrack( Collections::MediaDeviceCollection *collection ); - virtual ~MediaDeviceTrack(); + ~MediaDeviceTrack() override; QString name() const override; QUrl playableUrl() const override; QString uidUrl() const override; QString prettyUrl() const override; QString notPlayableReason() const override; bool isEditable() const; AlbumPtr album() const override; ArtistPtr artist() const override; GenrePtr genre() const override; ComposerPtr composer() const override; YearPtr year() const override; virtual void setAlbum ( const QString &newAlbum ); virtual void setAlbumArtist( const QString &newAlbumArtist ); virtual void setArtist ( const QString &newArtist ); virtual void setGenre ( const QString &newGenre ); virtual void setComposer ( const QString &newComposer ); virtual void setYear ( int newYear ); virtual QString title() const; virtual void setTitle( const QString &newTitle ); QString comment() const override; virtual void setComment ( const QString &newComment ); qint64 length() const override; void setFileSize( int newFileSize ); int filesize() const override; int bitrate() const override; virtual void setBitrate( int newBitrate ); int sampleRate() const override; virtual void setSamplerate( int newSamplerate ); qreal bpm() const override; virtual void setBpm( const qreal newBpm ); int trackNumber() const override; virtual void setTrackNumber ( int newTrackNumber ); int discNumber() const override; virtual void setDiscNumber ( int newDiscNumber ); qreal replayGain( ReplayGainTag mode ) const override; /* Set the track replay gain (other types unsupported) */ void setReplayGain( qreal newReplayGain ); QString type() const override; void prepareToPlay() override; bool inCollection() const override; Collections::Collection* collection() const override; TrackEditorPtr editor() override; StatisticsPtr statistics() override; // Meta::Statistics methods double score() const override; void setScore ( double newScore ) override; int rating() const override; void setRating ( int newRating ) override; QDateTime lastPlayed() const override; void setLastPlayed( const QDateTime &newTime ) override; // firstPlayed() not available in any media device int playCount() const override; void setPlayCount( const int newCount ) override; //MediaDeviceTrack specific methods // These methods are for Handler void setAlbum( MediaDeviceAlbumPtr album ); void setArtist( MediaDeviceArtistPtr artist ); void setComposer( MediaDeviceComposerPtr composer ); void setGenre( MediaDeviceGenrePtr genre ); void setYear( MediaDeviceYearPtr year ); void setType( const QString & type ); void setLength( qint64 length ); void setPlayableUrl( const QUrl &url) { m_playableUrl = url; } /** * Notifies observers about changes to metadata, one of the observers is media * device handler which writes the changes back to the device. */ void commitChanges(); private: QPointer m_collection; MediaDeviceArtistPtr m_artist; MediaDeviceAlbumPtr m_album; MediaDeviceGenrePtr m_genre; MediaDeviceComposerPtr m_composer; MediaDeviceYearPtr m_year; // For MediaDeviceTrack-specific use QImage m_image; QString m_comment; QString m_name; QString m_type; int m_bitrate; int m_filesize; qint64 m_length; int m_discNumber; int m_samplerate; int m_trackNumber; int m_playCount; QDateTime m_lastPlayed; int m_rating; qreal m_bpm; qreal m_replayGain; QString m_displayUrl; QUrl m_playableUrl; }; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceArtist : public Meta::Artist { public: explicit MediaDeviceArtist( const QString &name ); - virtual ~MediaDeviceArtist(); + ~MediaDeviceArtist() override; QString name() const override; TrackList tracks() override; //MediaDeviceArtist specific methods virtual void addTrack( MediaDeviceTrackPtr track ); virtual void remTrack( MediaDeviceTrackPtr track ); private: QString m_name; TrackList m_tracks; }; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceAlbum : public Meta::Album { public: MediaDeviceAlbum( Collections::MediaDeviceCollection *collection, const QString &name ); - virtual ~MediaDeviceAlbum(); + ~MediaDeviceAlbum() override; QString name() const override; bool isCompilation() const override; void setIsCompilation( bool compilation ); bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; bool hasImage( int size = 0 ) const override; QImage image( int size = 0 ) const override; bool canUpdateImage() const override; void setImage( const QImage &image ) override; virtual void setImagePath( const QString &path ); bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; //MediaDeviceAlbum specific methods void addTrack( MediaDeviceTrackPtr track ); void remTrack( MediaDeviceTrackPtr track ); void setAlbumArtist( MediaDeviceArtistPtr artist ); private: QPointer m_collection; QPointer m_artworkCapability; QString m_name; TrackList m_tracks; bool m_isCompilation; mutable bool m_hasImagePossibility; mutable bool m_hasImageChecked; mutable QImage m_image; MediaDeviceArtistPtr m_albumArtist; }; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceComposer : public Meta::Composer { public: explicit MediaDeviceComposer( const QString &name ); - virtual ~MediaDeviceComposer(); + ~MediaDeviceComposer() override; QString name() const override; TrackList tracks() override; //MediaDeviceComposer specific methods void addTrack( MediaDeviceTrackPtr track ); void remTrack( MediaDeviceTrackPtr track ); private: QString m_name; TrackList m_tracks; }; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceGenre : public Meta::Genre { public: explicit MediaDeviceGenre( const QString &name ); - virtual ~MediaDeviceGenre(); + ~MediaDeviceGenre() override; QString name() const override; TrackList tracks() override; //MediaDeviceGenre specific methods void addTrack( MediaDeviceTrackPtr track ); void remTrack( MediaDeviceTrackPtr track ); private: QString m_name; TrackList m_tracks; }; class MEDIADEVICECOLLECTION_EXPORT MediaDeviceYear : public Meta::Year { public: explicit MediaDeviceYear( const QString &name ); - virtual ~MediaDeviceYear(); + ~MediaDeviceYear() override; QString name() const override; TrackList tracks() override; //MediaDeviceYear specific methods void addTrack( MediaDeviceTrackPtr track ); void remTrack( MediaDeviceTrackPtr track ); private: QString m_name; TrackList m_tracks; }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h index dcf732c75a..3697fdc7cf 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h +++ b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.h @@ -1,509 +1,509 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 MEDIADEVICEHANDLER_H #define MEDIADEVICEHANDLER_H #include "core/meta/Observer.h" #include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" #include "core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h" #include "core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h" #include "core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h" #include "core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h" #include "core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h" #include "core-impl/collections/mediadevicecollection/playlist/MediaDeviceUserPlaylistProvider.h" #include "core-impl/collections/support/MemoryCollection.h" #include "core-impl/playlists/providers/user/UserPlaylistProvider.h" #include #include #include #include #include class QString; class QMutex; namespace Collections { class MediaDeviceCollection; } namespace Meta { typedef QMultiMap TitleMap; class MEDIADEVICECOLLECTION_EXPORT MetaHandlerCapability { public: virtual ~MetaHandlerCapability() {} virtual bool hasCapabilityInterface( Handler::Capability::Type type ) const; virtual Handler::Capability* createCapabilityInterface( Handler::Capability::Type type ); /** * Retrieves a specialized interface which represents a capability of this * object. * * @returns a pointer to the capability interface if it exists, 0 otherwise */ template CapIface *create() { Handler::Capability::Type type = CapIface::capabilityInterfaceType(); Handler::Capability *iface = createCapabilityInterface(type); return qobject_cast(iface); } /** * Tests if an object provides a given capability interface. * * @returns true if the interface is available, false otherwise */ template bool is() const { return hasCapabilityInterface( CapIface::capabilityInterfaceType() ); } }; /** The MediaDeviceHandler is the backend where all low-level library calls are made. It exists to leave a generic API in the other classes, while allowing for low-level calls to be isolated here. */ class MEDIADEVICECOLLECTION_EXPORT MediaDeviceHandler : public QObject, public Meta::MetaHandlerCapability, public Meta::Observer { Q_OBJECT public: /** * Destructor */ - virtual ~MediaDeviceHandler(); + ~MediaDeviceHandler() override; // Declare thread as friend class friend class ParseWorkerThread; /** * Begins an attempt to connect to the device, and emits * attemptConnectionDone when it finishes. */ virtual void init() = 0; // collection /** * Checks if the handler successfully connected * to the device. * @return * TRUE if the device was successfully connected to * FALSE if the device was not successfully connected to */ bool succeeded() const // collection { return m_success; } /// Methods provided for CollectionLocation /** * Checks if a device can be written to. * @return * TRUE if the device can be written to * FALSE if the device can not be written to */ virtual bool isWritable() const = 0; /** Given a list of tracks, get URLs for device tracks * of this type of device. If the device needs to * do some work to get URLs (e.g. copy tracks to a * temporary location) the overridden method in * the handler takes care of it, but must Q_EMIT * gotCopyableUrls when finished. * @param tracks The list of tracks for which to fetch urls */ virtual void getCopyableUrls( const Meta::TrackList &tracks ); /** * Fetches the human-readable name of the device. * This is often called from the Collection since * a library call is needed to get this name. * @return A QString with the name */ virtual QString prettyName() const = 0; /** * Copies a list of tracks to the device. * @param tracklist The list of tracks to copy. */ void copyTrackListToDevice( const Meta::TrackList tracklist ); /** * Removes a list of tracks from the device. * @param tracks The list of tracks to remove. */ void removeTrackListFromDevice( const Meta::TrackList &tracks ); /** This function is called just before a track in the playlist is to be played, and gives * a chance for e.g. MTP to copy the track to a temporary location, set a playable url, * to emulate the track actually being played off the device * @param track The track that needs to prepare to be played */ virtual void prepareToPlay( Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } // called by @param track virtual float usedcapacity(); virtual float totalcapacity(); Playlists::UserPlaylistProvider* provider(); // HACK: Used for device-specific actions, such as initialize for iPod virtual QList collectionActions() { return QList (); } Q_SIGNALS: void gotCopyableUrls( const QMap &urls ); void databaseWritten( bool succeeded ); void deleteTracksDone(); void incrementProgress(); void endProgressOperation( QObject *owner ); void copyTracksDone( bool success ); void removeTracksDone(); /* File I/O Methods */ public Q_SLOTS: /** * Parses the media device's database and creates a Meta::MediaDeviceTrack * for each track in the database. NOTE: only call once per device. */ void parseTracks(); // collection /** * Writes to the device's database if it has one, otherwise * simply calls slotDatabaseWritten to continue the workflow. */ virtual void writeDatabase() { slotDatabaseWritten( true ); } void savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ); void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); void deletePlaylists( const Playlists::MediaDevicePlaylistList &playlistlist ); bool privateParseTracks(); void copyNextTrackToDevice(); bool privateCopyTrackToDevice( const Meta::TrackPtr& track ); void removeNextTrackFromDevice(); void privateRemoveTrackFromDevice( const Meta::TrackPtr &track ); void slotCopyNextTrackFailed( ThreadWeaver::JobPointer job, const Meta::TrackPtr& track ); void slotCopyNextTrackDone( ThreadWeaver::JobPointer job, const Meta::TrackPtr& track ); protected: /** * Constructor * @param parent the Collection whose handler this is */ MediaDeviceHandler( QObject *parent ); /** * Creates a MediaDeviceTrack based on the latest track struct created as a * result of a copy to the device, and adds it into the collection to reflect * that it has been copied. * @param track The track to add to the collection */ void addMediaDeviceTrackToCollection( Meta::MediaDeviceTrackPtr &track ); /** * Removes the @param track from all the collection's maps to reflect that * it has been removed from the collection * @param track The track to remove from the collection */ void removeMediaDeviceTrackFromCollection( Meta::MediaDeviceTrackPtr &track ); /** * Uses wrapped libGet methods to fill a track with information from device * @param track The track from whose associated struct to get the information * @param destTrack The track that we want to fill with information */ void getBasicMediaDeviceTrackInfo( const Meta::MediaDeviceTrackPtr& track, Meta::MediaDeviceTrackPtr destTrack ); /** * Uses wrapped libSet methods to fill a track struct of the particular library * with information from a Meta::Track * @param srcTrack The track that has the source information * @param destTrack The track whose associated struct we want to fill with information */ void setBasicMediaDeviceTrackInfo( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr destTrack ); Collections::MediaDeviceCollection *m_memColl; ///< Associated collection bool m_success; bool m_copyingthreadsafe; ///< whether or not the handler's method of copying is threadsafe TitleMap m_titlemap; ///< Map of track titles to tracks, used to detect duplicates protected Q_SLOTS: void slotFinalizeTrackCopy( const Meta::TrackPtr & track ); void slotCopyTrackFailed( const Meta::TrackPtr & track ); void slotFinalizeTrackRemove( const Meta::TrackPtr & track ); void slotDatabaseWritten( bool success ); void enqueueNextCopyThread(); void slotDeletingHandler(); private: /** * Pulls out meta information (e.g. artist string) * from track struct, inserts into appropriate map * (e.g. ArtistMap). Sets track's meta info * (e.g. artist string) to that extracted from * track struct's. * @param track - track being written to * @param Map - map where meta information is * associated to appropriate meta pointer * (e.g. QString artist, ArtistPtr ) */ void setupArtistMap( Meta::MediaDeviceTrackPtr track, ArtistMap &artistMap ); void setupAlbumMap( Meta::MediaDeviceTrackPtr track, AlbumMap &albumMap, ArtistMap &artistMap ); void setupGenreMap( Meta::MediaDeviceTrackPtr track, GenreMap &genreMap ); void setupComposerMap( Meta::MediaDeviceTrackPtr track, ComposerMap &composerMap ); void setupYearMap( Meta::MediaDeviceTrackPtr track, YearMap &yearMap ); // Misc. Helper Methods /** * Tries to create read capability in m_rc * @return true if m_rc is valid read capability, false otherwise */ bool setupReadCapability(); /** * Tries to create write capability in m_rc * @return true if m_wc is valid write capability, false otherwise */ bool setupWriteCapability(); /** * @return free space on the device */ float freeSpace(); // Observer Methods /** These methods are called when the metadata of a track has changed. They invoke an MediaDevice DB update */ void metadataChanged( const Meta::TrackPtr &track ) override; void metadataChanged( const Meta::ArtistPtr &artist ) override; void metadataChanged( const Meta::AlbumPtr &album ) override; void metadataChanged( const Meta::GenrePtr &genre ) override; void metadataChanged( const Meta::ComposerPtr &composer ) override; void metadataChanged(const YearPtr &year ) override; /** * Handler Variables */ Playlists::MediaDeviceUserPlaylistProvider *m_provider; ///< Associated playlist provider bool m_copyFailed; ///< Indicates whether a copy failed or not bool m_isCopying; bool m_isDeleting; Meta::TrackList m_tracksToCopy; ///< List of tracks left to copy Meta::TrackList m_tracksCopying; ///< List of tracks currently copying Meta::TrackList m_tracksToDelete; ///< List of tracks left to delete int m_numTracksToCopy; ///< The number of tracks left to copy int m_numTracksToRemove; ///< The number of tracks left to remove QMap m_tracksFailed; ///< tracks that failed to copy QHash m_trackSrcDst; ///< points source to destTracks, for completion of addition to collection QMutex m_mutex; ///< A make certain operations atomic when threads are at play // Capability-related variables Handler::PlaylistCapability *m_pc; Handler::PodcastCapability *m_podcastCapability; Handler::ReadCapability *m_rc; Handler::WriteCapability *m_wc; }; /** * The ParseWorkerThread is used to run a full parse of the device's database in * a separate thread. Once done, it informs the Collection it is done */ class ParseWorkerThread : public QObject , public ThreadWeaver::Job { Q_OBJECT public: /** * The constructor. * @param handler The handler */ explicit ParseWorkerThread( MediaDeviceHandler* handler); /** * The destructor. */ - virtual ~ParseWorkerThread(); + ~ParseWorkerThread() override; /** * Sees the success variable, which says whether or not the copy completed successfully. * @return Whether or not the copy was successful, i.e. m_success */ bool success() const override; Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); private Q_SLOTS: /** * Is called when the job is done successfully, and simply * calls Collection's emitCollectionReady() * @param job The job that was done */ void slotDoneSuccess( ThreadWeaver::JobPointer ); protected: /** * Reimplemented, simply runs the parse method. */ void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; private: bool m_success; ///< Whether or not the parse was successful MediaDeviceHandler *m_handler; ///< The handler }; /** * The CopyWorkerThread is used to run a copy operation on a single track in a separate thread. * Copying is generally done one thread at a time so as to not hurt performance, and because * many copying mechanisms like that of libmtp can only copy one file at a time. Copying * methods that are not threadsafe should not use CopyWorkerThread, and should set the * Handler's m_copyingthreadsafe variable to false in the Handler's constructor. */ class CopyWorkerThread : public QObject, public ThreadWeaver::Job { Q_OBJECT public: /** * The constructor. * @param track The source track to copy from * @param handler The handler */ CopyWorkerThread( const Meta::TrackPtr &track, MediaDeviceHandler* handler ); /** * The destructor. */ - virtual ~CopyWorkerThread(); + ~CopyWorkerThread() override; /** * Sets the success variable, which says whether or not the copy completed successfully. * @return Whether or not the copy was successful, i.e. m_success */ bool success() const override; Q_SIGNALS: /** * Is emitted when the job is done successfully * Parameters: * The job that was done * @param track The source track used for the copy */ void copyTrackDone( ThreadWeaver::JobPointer, const Meta::TrackPtr& track ); /** * Is emitted when the job is done and has failed * Parameters: * The job that was done * @param track The source track used for the copy */ void copyTrackFailed( ThreadWeaver::JobPointer, const Meta::TrackPtr& track ); /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); private Q_SLOTS: /** * Is called when the job is done successfully, and simply * emits copyTrackDone * @param job The job that was done */ void slotDoneSuccess( ThreadWeaver::JobPointer ); /** * Is called when the job is done and failed, and simply * emits copyTrackFailed * @param job The job that was done */ void slotDoneFailed( ThreadWeaver::JobPointer ); protected: /** * Reimplemented, simply runs the copy track method. */ void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; private: bool m_success; ///< Whether or not the copy was successful Meta::TrackPtr m_track; ///< The source track to copy from MediaDeviceHandler *m_handler; ///< The handler }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h index b1219666bc..1a58a19e9a 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h +++ b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h @@ -1,74 +1,74 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 MEDIADEVICEHANDLER_CAPABILITY_H #define MEDIADEVICEHANDLER_CAPABILITY_H #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" #include /** * Base class for all media device Capabilities * * Following rules apply when working with capabilities: * * Capabilities get deleted along their media device handler. Therefore use * QPointer everywhere to detect that. * * the one who creates capability using create() must deleteLater() it when no * longer used. */ namespace Handler { class MEDIADEVICECOLLECTION_EXPORT Capability : public QObject { Q_OBJECT public: //add additional capabilities here enum Type { Unknown = 0 , Readable = 1 // can read from device , Writable = 2 // can write to device , Playlist = 3 // can read/write playlists , Artwork = 4 // can read/write artwork , Podcast = 5 // can read/write podcasts }; Q_ENUM( Type ) /** * @param handler should be set to associated MediaDeviceHandler or Collection. * * The capability sets its parent to handler, so that it can be guaranteed that * the handler is valid for Capability's lifetime. */ explicit Capability( QObject *handler ); - virtual ~Capability(); + ~Capability() override; Q_SIGNALS: /** * Signals that parent of this object should be set to @param parent */ void signalSetParent( QObject *parent ); private Q_SLOTS: /** * Simply calls setParent( parent ); needed for cases where moveToThread() is * called in constructor - setting parent needs to be done in the new thread. */ void slotSetParent( QObject *parent ); }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h b/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h index 2a80b1c267..5b08bf21ec 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h +++ b/src/core-impl/collections/mediadevicecollection/handler/capabilities/ArtworkCapability.h @@ -1,45 +1,45 @@ /**************************************************************************************** * Copyright (c) 2009 Seb Ruiz * * * * 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 MEDIADEVICEHANDLER_ARTWORK_CAPABILITY_H #define MEDIADEVICEHANDLER_ARTWORK_CAPABILITY_H #include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" namespace Handler { class MEDIADEVICECOLLECTION_EXPORT ArtworkCapability : public Handler::Capability { Q_OBJECT public: explicit ArtworkCapability( QObject *parent ) : Capability( parent ) {} - virtual ~ArtworkCapability(); + ~ArtworkCapability() override; virtual QImage getCover( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual void setCover( Meta::MediaDeviceAlbumPtr album, const QImage &image ) = 0; virtual void setCoverPath( const Meta::MediaDeviceAlbumPtr &album, const QString &path ); virtual bool canUpdateCover() const = 0; static Type capabilityInterfaceType() { return Handler::Capability::Artwork; } }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h b/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h index 64a71bbee9..b8edb37002 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h +++ b/src/core-impl/collections/mediadevicecollection/handler/capabilities/PlaylistCapability.h @@ -1,150 +1,150 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 MEDIADEVICEHANDLER_PLAYLISTCAPABILITY_H #define MEDIADEVICEHANDLER_PLAYLISTCAPABILITY_H #include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" #include "core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h" #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" namespace Handler { class MEDIADEVICECOLLECTION_EXPORT PlaylistCapability : public Handler::Capability { Q_OBJECT public: explicit PlaylistCapability( QObject *parent ) : Capability( parent ) {} - virtual ~PlaylistCapability(); + ~PlaylistCapability() override; /// Parsing of Tracks in Playlists on Device /// NOTE: not required by devices with no playlists, just reimplement empty functions /** * This method initializes iteration over some list of playlist structs * e.g. with libgpod, this initializes a GList to the beginning of * the list of playlists */ virtual void prepareToParsePlaylists() = 0; /** * This method runs a test to see if we have reached the end of * the list of playlists to be parsed on the device, e.g. in libgpod * this tests if cur != NULL, i.e. if(cur) */ virtual bool isEndOfParsePlaylistsList() = 0; /** * This method moves the iterator to the next playlist on the list of * playlist structs, e.g. with libgpod, cur = cur->next where cur * is a GList* */ virtual void prepareToParseNextPlaylist() = 0; /** * This method attempts to access the special struct of the * next playlist, so that information can then be parsed from it. * For libgpod, this is m_currplaylist = ( Itdb_Playlist * ) cur->data */ virtual void nextPlaylistToParse() = 0; /** * This method checks if the playlist should be parsed, or skipped. * Certain playlists, like the master playlist on the iPod, do not * need to be or should not be parsed. * @return true if should not parse, false otherwise. */ virtual bool shouldNotParseNextPlaylist() = 0; /** * This method initializes iteration over some list of track structs * that correspond to a playlist struct * e.g. with libgpod, this initializes a GList to the beginning of * the list of tracks */ virtual void prepareToParsePlaylistTracks() = 0; /** * This method runs a test to see if we have reached the end of * the list of tracks in the playlist to be parsed on the device, e.g. in libgpod * this tests if cur != NULL, i.e. if(cur) */ virtual bool isEndOfParsePlaylist() = 0; /** * This method moves the iterator to the next track on the playlist of * track structs, e.g. with libgpod, cur = cur->next where cur * is a GList* */ virtual void prepareToParseNextPlaylistTrack() = 0; /** * This method attempts to access the special struct of the * next track on the playlist, so that information can then be parsed from it. * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data */ virtual void nextPlaylistTrackToParse() = 0; /** * Returns a MediaDeviceTrackPtr that is associated with the currently parsed track struct. * @return A MediaDeviceTrackPtr to currently parsed track struct */ virtual Meta::MediaDeviceTrackPtr libGetTrackPtrForTrackStruct() = 0; /** * Returns a string containing the playlist name of the currently parsed playlist struct, if available. * @return A string with the name of the currently parsed playlist */ virtual QString libGetPlaylistName() = 0; /** * Saves a playlist of tracks, with a name. * @param playlist the playlist to be made * @param name the name of the playlist */ virtual void savePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ) = 0; /** * Deletes a particular playlist from the device * @param playlist the playlist to remove */ virtual void deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) = 0; /** * Renames a particular playlist on the device * @param playlist the playlist to rename */ virtual void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) = 0; /** * This method must create a two-way association of the current Meta::Playlist * to the special struct provided by the library to read/write information. * For example, for libgpod one would associate Itdb_Playlist*. It makes * the most sense to use a QHash since it is fastest lookup and order * does not matter. * @param playlist The list to two-way associate with a library list struct */ virtual void setAssociatePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ) { Q_UNUSED( playlist ) } static Type capabilityInterfaceType() { return Handler::Capability::Playlist; } }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h b/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h index 7ae004481e..311f511600 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h +++ b/src/core-impl/collections/mediadevicecollection/handler/capabilities/PodcastCapability.h @@ -1,139 +1,139 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * Copyright (c) 2010 Bart Cerneels * * * * 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 PODCASTCAPABILITY_H #define PODCASTCAPABILITY_H #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" #include "core-impl/collections/mediadevicecollection/podcast/MediaDevicePodcastMeta.h" namespace Handler { class MEDIADEVICECOLLECTION_EXPORT PodcastCapability : public Handler::Capability { public: - virtual ~PodcastCapability(); + ~PodcastCapability() override; /** * This method initializes iteration over some list of Podcast structs * e.g. with libgpod, this initializes a GList to the beginning of * the list of Podcasts */ virtual void prepareToParsePodcasts() = 0; /** * This method runs a test to see if we have reached the end of * the list of Podcasts to be parsed on the device, e.g. in libgpod * this tests if cur != NULL, i.e. if(cur) */ virtual bool isEndOfParsePodcastsList() = 0; /** * This method moves the iterator to the next Podcast on the list of * Podcast structs, e.g. with libgpod, cur = cur->next where cur * is a GList* */ virtual void prepareToParseNextPodcast() = 0; /** * This method attempts to access the special struct of the * next Podcast, so that information can then be parsed from it. * For libgpod, this is m_currPodcast = ( Itdb_Podcast * ) cur->data */ virtual void nextPodcastToParse() = 0; /** * This method checks if the Podcast should be parsed, or skipped. * Certain Podcasts, like the master Podcast on the iPod, do not * need to be or should not be parsed. * @return true if should not parse, false otherwise. */ virtual bool shouldNotParseNextPodcast() = 0; /** * This method initializes iteration over some list of track structs * that correspond to a Podcast struct * e.g. with libgpod, this initializes a GList to the beginning of * the list of tracks */ virtual void prepareToParsePodcastEpisode() = 0; /** * This method runs a test to see if we have reached the end of * the list of episode in the Podcast to be parsed on the device, e.g. in libgpod * this tests if cur != NULL, i.e. if(cur) */ virtual bool isEndOfParsePodcast() = 0; /** * This method moves the iterator to the next track on the Podcast of * track structs, e.g. with libgpod, cur = cur->next where cur * is a GList* */ virtual void prepareToParseNextPodcastEpisode() = 0; /** * This method attempts to access the special struct of the * next track on the Podcast, so that information can then be parsed from it. * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data */ virtual void nextPodcastEpisodeToParse() = 0; /** * Returns a MediaDeviceTrackPtr that is associated with the currently parsed track struct. * @return A MediaDeviceTrackPtr to currently parsed track struct */ virtual MediaDevicePodcastEpisodePtr libGetEpisodePtrForEpisodeStruct() = 0; /** * Returns a string containing the Podcast name of the currently parsed Podcast struct, if available. * @return A string with the name of the currently parsed Podcast */ virtual QString libGetPodcastName() = 0; /** * Adds a podcast */ virtual void addPodcast( const Podcasts::PodcastChannelPtr &channel ) = 0; /** * Deletes a particular Podcast from the device * @param channel the channel to remove */ virtual void removePodcast( const MediaDevicePodcastChannelPtr &channel ) = 0; /** * Deletes a particular Podcast Episode from the device * @param episode the episode to remove */ virtual void removePodcastEpisode( const MediaDevicePodcastEpisodePtr &episode ) = 0; /** * This method must create a two-way association of the current Podcasts::Podcast * to the special struct provided by the library to read/write information. * For example, for libgpod one would associate Itdb_Podcast*. It makes * the most sense to use a QHash since it is fastest lookup and order * does not matter. * @param channel The channel to two-way associate with a library list struct */ virtual void setAssociatePodcast( const MediaDevicePodcastChannelPtr &channel ) { Q_UNUSED( channel ) } static Type capabilityInterfaceType() { return Handler::Capability::Podcast; } }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h b/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h index 808f0644a1..967be4d252 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h +++ b/src/core-impl/collections/mediadevicecollection/handler/capabilities/ReadCapability.h @@ -1,126 +1,126 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * Copyright (c) 2011 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 MEDIADEVICEHANDLER_READCAPABILITY_H #define MEDIADEVICEHANDLER_READCAPABILITY_H #include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" #include namespace Handler { class MEDIADEVICECOLLECTION_EXPORT ReadCapability : public Handler::Capability { Q_OBJECT public: explicit ReadCapability( QObject *parent ) : Capability( parent ) {} - virtual ~ReadCapability(); + ~ReadCapability() override; static Type capabilityInterfaceType() { return Handler::Capability::Readable; } /* Parsing of Tracks on Device */ /** * Initializes iteration over some list of track structs * e.g. with libgpod, this initializes a GList to the beginning of * the list of tracks */ virtual void prepareToParseTracks() = 0; /** * Runs a test to see if we have reached the end of * the list of tracks to be parsed on the device, e.g. in libgpod * this tests if cur != NULL, i.e. if(cur) */ virtual bool isEndOfParseTracksList() = 0; /** * Moves the iterator to the next track on the list of * track structs, e.g. with libgpod, cur = cur->next where cur * is a GList* */ virtual void prepareToParseNextTrack() = 0; /** * This method attempts to access the special struct of the * next track, so that information can then be parsed from it. * For libgpod, this is m_currtrack = (Itdb_Track*) cur->data */ virtual void nextTrackToParse() = 0; /** * This method must create a two-way association of the current Meta::Track * to the special struct provided by the library to read/write information. * For example, for libgpod one would associate Itdb_Track*. It makes * the most sense to use a QHash since it is fastest lookup and order * does not matter. * @param track The track to two-way associate with a library track struct */ virtual void setAssociateTrack( const Meta::MediaDeviceTrackPtr track ) = 0; /* * Methods that wrap get/set of information using given library (e.g. libgpod) * Subclasses of MediaDeviceHandler must keep a pointer to the track struct * associated to the track parameter to get the information from the struct in libGet*, * and to set the struct's information to the passed metadata in libSet* */ virtual QString libGetAlbum( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetArtist( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetComposer( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetGenre( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetYear( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetTitle( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual qint64 libGetLength( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetComment( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetBitrate( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual qreal libGetBpm( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetFileSize( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QDateTime libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual int libGetRating( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QString libGetType( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual QUrl libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ) = 0; virtual bool libIsCompilation( const Meta::MediaDeviceTrackPtr &track ); virtual qreal libGetReplayGain( const Meta::MediaDeviceTrackPtr &track ); /** * Get used capacity on the device, in bytes. Returns 0.0 if capacity information * is not appropriate or not available. */ virtual float usedCapacity() const { return 0.0; } /** * Get total (used + free) capacity on the device, in bytes. Returns 0.0 if * capacity information is not appropriate or not available. */ virtual float totalCapacity() const { return 0.0; } }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h b/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h index a6922c0366..124552e1f1 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h +++ b/src/core-impl/collections/mediadevicecollection/handler/capabilities/WriteCapability.h @@ -1,164 +1,164 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 MEDIADEVICEHANDLER_WRITECAPABILITY_H #define MEDIADEVICEHANDLER_WRITECAPABILITY_H #include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" namespace Handler { class MEDIADEVICECOLLECTION_EXPORT WriteCapability : public Handler::Capability { Q_OBJECT public: explicit WriteCapability( QObject *parent ) : Capability( parent ) {} - virtual ~WriteCapability(); + ~WriteCapability() override; static Type capabilityInterfaceType() { return Handler::Capability::Writable; } /** * Returns a list of formats supported by the device, all in lowercase * For example mp3, mpeg, aac. This is used to avoid copying unsupported * types to a particular device. */ virtual QStringList supportedFormats() = 0; // md:write /** * Finds the place to copy the track to on the device, which * could be a url in the case of Ipods, or a folder in the * case of MTP devices. * @param srcTrack The source track of the copy * @param destTrack The destination track whose path we seek */ virtual void findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ) = 0; /** * libCopyTrack does the actual file copying. For Ipods, it uses KIO, * for MTPs this uses a libmtp call * Copy the file associate with srcTrack to destTrack * @param srcTrack The track being copied from * @param destTrack The track being copied to * @return Whether or not the track copy was successful */ virtual bool libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ) = 0; /** * libDeleteTrack does the actual file deleting. For Ipods, it uses KIO, * for MTPs this uses a libmtp call. Must Q_EMIT libRemoveTrackDone when finished. * @param track The track whose file is to be deleted * @return Whether or not the track removal was successful */ virtual bool libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ) = 0; /** * This function is called just before copying tracks begin and allows * a subclass to prepare to copy, e.g. for Ipods it would initialize * the job counter to 0. */ virtual void prepareToCopy() = 0; /** * This function is called just before deleting tracks begin and allows * a subclass to prepare to delete, e.g. for Ipods it would initialize * the m_tracksdeleting to keep track of urls it is deleting. */ virtual void prepareToDelete() = 0; /** * Tells subclass that it can update the track, usually because * the track's tags have changed. * @param track The track whose tags should be updated */ virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } /** * Creates a new track struct particular to the library of the device * e.g. LIBMTP_new_track_t(), and associates it with the track for * later use, in the same way that setAssociateTrack does it. * @param track The track for which to create a track struct and associate it to */ virtual void libCreateTrack( const Meta::MediaDeviceTrackPtr &track ) = 0; /** * Deletes the track struct associated with this track, freeing * any memory it occupied, and dissociating it from the track * @param track The track whose associated track struct is to be deleted. */ virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ) = 0; /** * Adds the newly created track struct now populated with info into the * database struct of the particular device, e.g. into the itdb for Ipods. * MTP devices automatically add the track into the database upon copying, * so MTP would do nothing. * @param track The track whose associated track struct is to be added * into the database. */ virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) = 0; /** * Remove all traces of the track struct associated with @param track from * the database struct, but do not delete the struct * @param track The track whose associated track struct is to be removed * from the database. */ virtual void removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ) = 0; /** * Indicates to the subclass that the database has been updated */ virtual void setDatabaseChanged() = 0; /* * Each libSet function sets the private track struct associated with @param track * to the second value passed into the function. */ virtual void libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ) = 0; virtual void libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ) = 0; virtual void libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ) = 0; virtual void libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString& albumArtist ) = 0; virtual void libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ) = 0; virtual void libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ) = 0; virtual void libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ) = 0; virtual void libSetLength( Meta::MediaDeviceTrackPtr &track, int length ) = 0; virtual void libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ) = 0; virtual void libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ) = 0; virtual void libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ) = 0; virtual void libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ) = 0; virtual void libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ) = 0; virtual void libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ) = 0; virtual void libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ) = 0; virtual void libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ) = 0; virtual void libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ) = 0; virtual void libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) = 0; virtual void libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ) = 0; virtual void libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ) = 0; virtual void libSetIsCompilation( Meta::MediaDeviceTrackPtr &track, bool isCompilation ); virtual void libSetReplayGain( Meta::MediaDeviceTrackPtr &track, qreal newReplayGain ); virtual void libSetCoverArt( Meta::MediaDeviceTrackPtr &track, const QImage &cover ) = 0; }; } #endif diff --git a/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h b/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h index 9f2b38772a..e3f6a07d7d 100644 --- a/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h +++ b/src/core-impl/collections/mediadevicecollection/playlist/MediaDevicePlaylist.h @@ -1,62 +1,62 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 METAMEDIADEVICEPLAYLIST_H #define METAMEDIADEVICEPLAYLIST_H #include "core/playlists/Playlist.h" #include "core/support/Debug.h" namespace Playlists { class MediaDevicePlaylist; typedef AmarokSharedPointer MediaDevicePlaylistPtr; typedef QList MediaDevicePlaylistList; class MediaDevicePlaylist : public Playlist { public: MediaDevicePlaylist( const QString &name, const Meta::TrackList &tracks ); - ~MediaDevicePlaylist(); + ~MediaDevicePlaylist() override; // Playlist Functions QString name() const override { return m_name; } QUrl uidUrl() const override { return QUrl(); } /**override showing just the filename */ void setName( const QString &name ) override; int trackCount() const override; Meta::TrackList tracks() override; void addTrack( const Meta::TrackPtr &track, int position = -1 ) override; void removeTrack( int position ) override; private: Meta::TrackList m_tracks; QString m_name; }; } Q_DECLARE_METATYPE( Playlists::MediaDevicePlaylistPtr ) Q_DECLARE_METATYPE( Playlists::MediaDevicePlaylistList ) #endif diff --git a/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h b/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h index 681084de52..47beab0ad1 100644 --- a/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h +++ b/src/core-impl/collections/mediadevicecollection/support/ConnectionAssistant.h @@ -1,104 +1,104 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 CONNECTIONASSISTANT_H #define CONNECTIONASSISTANT_H #include "mediadevicecollection_export.h" #include class MediaDeviceInfo; class QString; /** @class ConnectionAssistant The ConnectionAssistant (CA) serves as a way for MediaDeviceCollectionFactory to register its device type with the MediaDeviceMonitor (MDM). Once registered, the MDM can use the CA to attempt to identify a newly plugged-in device, and retrieve the MediaDeviceInfo object necessary for the Factory to connect to it. */ class MEDIADEVICECOLLECTION_EXPORT ConnectionAssistant : public QObject { Q_OBJECT public: - virtual ~ConnectionAssistant(); + ~ConnectionAssistant() override; /** identify checks if a device identified by @param udi matches the type of device described by this ConnectionAssistant */ virtual bool identify( const QString& udi ); /** deviceInfo returns a pointer to a new MediaDeviceInfo of the type of device described by this ConnectionAssistant */ virtual MediaDeviceInfo* deviceInfo( const QString& udi ); bool wait(); // Simply Q_EMIT identified( info ) virtual void tellIdentified( const QString &udi ); virtual void tellDisconnected( const QString &udi ); protected: /* * Constructor * @param wait whether or not to wait to identify this device, * to give other types of devices a chance to claim this device * type during autodetection */ ConnectionAssistant( bool wait = false ); Q_SIGNALS: /** identified is emitted when identify returns true, and the device type's Factory has a slot that then attempts to connect to the device */ void identified( MediaDeviceInfo* info ); /** disconnected is emitted when a device with a given @param udi has been disconnected. The device type's factory should then destroy the Collection appropriately */ void disconnected( const QString &udi ); private: bool m_wait; }; #endif // CONNECTIONASSISTANT_H diff --git a/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h b/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h index fb9b46cde0..75bf1435c4 100644 --- a/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h +++ b/src/core-impl/collections/mediadevicecollection/support/MediaDeviceInfo.h @@ -1,39 +1,39 @@ /**************************************************************************************** * Copyright (c) 2008 Alejandro Wainzinger * * * * 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 MEDIA_DEVICE_INFO_H #define MEDIA_DEVICE_INFO_H #include "mediadevicecollection_export.h" #include #include class MEDIADEVICECOLLECTION_EXPORT MediaDeviceInfo : public QObject { Q_OBJECT public: QString udi(); protected: MediaDeviceInfo(); - virtual ~MediaDeviceInfo(); + ~MediaDeviceInfo() override; QString m_udi; }; #endif diff --git a/src/core-impl/collections/mtpcollection/MtpCollection.h b/src/core-impl/collections/mtpcollection/MtpCollection.h index 94d989926d..8e10b849fd 100644 --- a/src/core-impl/collections/mtpcollection/MtpCollection.h +++ b/src/core-impl/collections/mtpcollection/MtpCollection.h @@ -1,65 +1,65 @@ /**************************************************************************************** * Copyright (c) 2008 Alejandro Wainzinger * * * * 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 MTPCOLLECTION_H #define MTPCOLLECTION_H #include "MtpHandler.h" #include "MediaDeviceCollection.h" #include "core/support/Debug.h" #include #include class MediaDeviceInfo; namespace Collections { class MtpCollection; class MtpCollectionFactory : public MediaDeviceCollectionFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-mtpcollection.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: MtpCollectionFactory(); - virtual ~MtpCollectionFactory(); + ~MtpCollectionFactory() override; }; class MtpCollection : public MediaDeviceCollection { Q_OBJECT public: explicit MtpCollection( MediaDeviceInfo* ); - virtual ~MtpCollection(); + ~MtpCollection() override; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override { return QIcon::fromTheme(QStringLiteral("multimedia-player")); } //void writeDatabase(); }; } //namespace Collections #endif diff --git a/src/core-impl/collections/mtpcollection/handler/MtpHandler.h b/src/core-impl/collections/mtpcollection/handler/MtpHandler.h index e56ac8275c..a7b8625a9c 100644 --- a/src/core-impl/collections/mtpcollection/handler/MtpHandler.h +++ b/src/core-impl/collections/mtpcollection/handler/MtpHandler.h @@ -1,288 +1,288 @@ /**************************************************************************************** * Copyright (c) 2006 Andy Kelk * * Copyright (c) 2008 Alejandro Wainzinger * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 MTPHANDLER_H #define MTPHANDLER_H #include #include "MtpPlaylistCapability.h" #include "MtpReadCapability.h" #include "MtpWriteCapability.h" #include "MediaDeviceMeta.h" #include "MediaDeviceHandler.h" #include #include #include #include #include #include #include #include #include #include class QString; class QMutex; class QStringList; namespace Collections { class MtpCollection; } namespace Meta { typedef QMultiMap TitleMap; class WorkerThread; /* The libmtp backend for all Mtp calls */ class MtpHandler : public MediaDeviceHandler { Q_OBJECT public: explicit MtpHandler( Collections::MtpCollection *mc ); - virtual ~MtpHandler(); + ~MtpHandler() override; friend class WorkerThread; void init() override; // collection bool isWritable() const override; void getCopyableUrls( const Meta::TrackList &tracks ) override; QString prettyName() const override; void prepareToPlay( Meta::MediaDeviceTrackPtr &track ) override; /// Capability-related methods bool hasCapabilityInterface( Handler::Capability::Type type ) const override; Handler::Capability* createCapabilityInterface( Handler::Capability::Type type ) override; friend class Handler::MtpPlaylistCapability; friend class Handler::MtpReadCapability; friend class Handler::MtpWriteCapability; protected: /* Parsing of Tracks on Device */ virtual void prepareToParseTracks(); virtual bool isEndOfParseTracksList(); virtual void prepareToParseNextTrack(); virtual void nextTrackToParse(); virtual void setAssociateTrack( const Meta::MediaDeviceTrackPtr track ); virtual void prepareToParsePlaylists(); virtual bool isEndOfParsePlaylistsList(); virtual void prepareToParseNextPlaylist(); virtual void nextPlaylistToParse(); virtual bool shouldNotParseNextPlaylist(); virtual void prepareToParsePlaylistTracks(); virtual bool isEndOfParsePlaylist(); virtual void prepareToParseNextPlaylistTrack(); virtual void nextPlaylistTrackToParse(); virtual QStringList supportedFormats(); virtual void findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ); virtual bool libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ); virtual bool libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ); virtual void libCreateTrack( const Meta::MediaDeviceTrackPtr &track ); virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ); virtual Meta::MediaDeviceTrackPtr libGetTrackPtrForTrackStruct(); virtual QString libGetPlaylistName(); virtual void setAssociatePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); virtual void libSavePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist, const QString& name ); virtual void deletePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); virtual void renamePlaylist( const Playlists::MediaDevicePlaylistPtr &playlist ); virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } virtual void removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ) { Q_UNUSED( track ) } virtual void setDatabaseChanged(); virtual QString libGetTitle( const Meta::MediaDeviceTrackPtr &track ); virtual QString libGetAlbum( const Meta::MediaDeviceTrackPtr &track ); virtual QString libGetArtist( const Meta::MediaDeviceTrackPtr &track ); virtual QString libGetAlbumArtist( const Meta::MediaDeviceTrackPtr &track ); virtual QString libGetComposer( const Meta::MediaDeviceTrackPtr &track ); virtual QString libGetGenre( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetYear( const Meta::MediaDeviceTrackPtr &track ); virtual qint64 libGetLength( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetTrackNumber( const Meta::MediaDeviceTrackPtr &track ); virtual QString libGetComment( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetDiscNumber( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetBitrate( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetSamplerate( const Meta::MediaDeviceTrackPtr &track ); virtual qreal libGetBpm( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetFileSize( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetPlayCount( const Meta::MediaDeviceTrackPtr &track ); virtual QDateTime libGetLastPlayed( const Meta::MediaDeviceTrackPtr &track ); virtual int libGetRating( const Meta::MediaDeviceTrackPtr &track ) ; virtual QString libGetType( const Meta::MediaDeviceTrackPtr &track ); virtual QUrl libGetPlayableUrl( const Meta::MediaDeviceTrackPtr &track ); virtual float usedCapacity() const; virtual float totalCapacity() const; virtual void libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ); virtual void libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ); virtual void libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ); virtual void libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString& albumArtist ); virtual void libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ); virtual void libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ); virtual void libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ); virtual void libSetLength( Meta::MediaDeviceTrackPtr &track, int length ); virtual void libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ); virtual void libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ); virtual void libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ); virtual void libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ); virtual void libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ); virtual void libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ); virtual void libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ); virtual void libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ); virtual void libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ); virtual void libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) ; virtual void libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ); virtual void libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ); virtual void prepareToCopy() {} virtual void prepareToDelete() {} /// libmtp-specific private Q_SLOTS: void slotDeviceMatchSucceeded( ThreadWeaver::JobPointer job ); void slotDeviceMatchFailed( ThreadWeaver::JobPointer job ); private: bool iterateRawDevices( int numrawdevices, LIBMTP_raw_device_t* rawdevices ); void getDeviceInfo(); void terminate(); int getTrackToFile( const uint32_t id, const QString & filename ); // Some internal stuff that must be public due to libmtp being in C static int progressCallback( uint64_t const sent, uint64_t const total, void const * const data ); // file-copying related functions uint32_t checkFolderStructure( const Meta::TrackPtr track, bool create ); uint32_t getDefaultParentId( void ); uint32_t folderNameToID( char *name, LIBMTP_folder_t *folderlist ); uint32_t subfolderNameToID( const char *name, LIBMTP_folder_t *folderlist, uint32_t parent_id ); uint32_t createFolder( const char *name, uint32_t parent_id ); void updateFolders( void ); QString setTempFile( Meta::MediaDeviceTrackPtr &track, const QString &format ); virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ); // mtp database LIBMTP_mtpdevice_t *m_device; float m_capacity; QMap mtpFileTypes; uint32_t m_default_parent_folder; LIBMTP_folder_t *m_folders; QString m_folderStructure; QString m_format; QString m_name; QStringList m_supportedFiles; QMutex m_critical_mutex; // KIO-related Vars (to be moved elsewhere eventually) bool m_isCanceled; bool m_wait; bool m_dbChanged; LIBMTP_track_t* m_currentTrackList; LIBMTP_track_t* m_currentTrack; LIBMTP_playlist_t* m_currentPlaylistList; LIBMTP_playlist_t* m_currentPlaylist; QHash m_mtpPlaylisthash; uint32_t m_trackcounter; // Hash that associates an LIBMTP_track_t* to every Track* QHash m_mtpTrackHash; // Keeps track of which tracks have been copied/cached for playing QHash m_cachedTracks; // Maps id's to tracks QHash m_idTrackHash; // parentid calculated for new track copied to device uint32_t m_copyParentId; // Used as temporary location for copying files from mtp QTemporaryDir *m_tempDir; }; class WorkerThread : public QObject, public ThreadWeaver::Job { Q_OBJECT public: WorkerThread( int numrawdevices, LIBMTP_raw_device_t* rawdevices, MtpHandler* handler ); - virtual ~WorkerThread(); + ~WorkerThread() override; bool success() const override; protected: void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); private: bool m_success; int m_numrawdevices; LIBMTP_raw_device_t* m_rawdevices; MtpHandler *m_handler; }; } #endif diff --git a/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h b/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h index de206290a8..1d0bbebb80 100644 --- a/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h +++ b/src/core-impl/collections/mtpcollection/support/MtpConnectionAssistant.h @@ -1,36 +1,36 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 MTPCONNECTIONASSISTANT_H #define MTPCONNECTIONASSISTANT_H #include "ConnectionAssistant.h" #include class MtpConnectionAssistant : public ConnectionAssistant { Q_OBJECT public: - virtual ~MtpConnectionAssistant(); + ~MtpConnectionAssistant() override; bool identify( const QString& udi ) override; MediaDeviceInfo* deviceInfo( const QString& udi ) override; }; #endif // MTPCONNECTIONASSISTANT_H diff --git a/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h b/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h index 03d084363e..3cff3d5ea9 100644 --- a/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h +++ b/src/core-impl/collections/mtpcollection/support/MtpDeviceInfo.h @@ -1,33 +1,33 @@ /**************************************************************************************** * Copyright (c) 2008 Alejandro Wainzinger * * * * 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 MTP_DEVICE_INFO_H #define MTP_DEVICE_INFO_H #include "MediaDeviceInfo.h" class MtpDeviceInfo : public MediaDeviceInfo { Q_OBJECT public: explicit MtpDeviceInfo(const QString &udi ); - ~MtpDeviceInfo(); + ~MtpDeviceInfo() override; private: }; #endif diff --git a/src/core-impl/collections/playdarcollection/PlaydarCollection.h b/src/core-impl/collections/playdarcollection/PlaydarCollection.h index f0fded47b9..dea11581df 100644 --- a/src/core-impl/collections/playdarcollection/PlaydarCollection.h +++ b/src/core-impl/collections/playdarcollection/PlaydarCollection.h @@ -1,112 +1,112 @@ /**************************************************************************************** * Copyright (c) 2010 Andrew Coder * * * * 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 PLAYDAR_COLLECTION_H #define PLAYDAR_COLLECTION_H #include "core/collections/Collection.h" #include "core-impl/collections/support/MemoryCollection.h" #include "PlaydarQueryMaker.h" #include "PlaydarMeta.h" #include "support/Controller.h" #include "support/ProxyResolver.h" #include #include #include #include namespace Playlists { class UserPlaylistProvider; } namespace Playdar { class ProxyResolver; } namespace Collections { class QueryMaker; class PlaydarCollectionFactory : public CollectionFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-playdarcollection.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: PlaydarCollectionFactory(); - virtual ~PlaydarCollectionFactory(); + ~PlaydarCollectionFactory() override; void init() override; private Q_SLOTS: void checkStatus(); void playdarReady(); void slotPlaydarError( Playdar::Controller::ErrorState error ); void collectionRemoved(); private: Playdar::Controller* m_controller; QPointer< PlaydarCollection > m_collection; bool m_collectionIsManaged; }; class PlaydarCollection : public Collection { Q_OBJECT public: PlaydarCollection(); - ~PlaydarCollection(); + ~PlaydarCollection() override; QueryMaker* queryMaker() override; Playlists::UserPlaylistProvider* userPlaylistProvider(); QString uidUrlProtocol() const override; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override; bool isWritable() const override; bool isOrganizable() const override; //Methods from Collections::TrackProvider bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; //Methods from Collections::CollectionBase bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; //PlaydarCollection-specific void addNewTrack( Meta::PlaydarTrackPtr track ); QSharedPointer< MemoryCollection > memoryCollection(); private Q_SLOTS: void slotPlaydarError( Playdar::Controller::ErrorState error ); private: QString m_collectionId; QSharedPointer< MemoryCollection > m_memoryCollection; QList< QPointer< Playdar::ProxyResolver > > m_proxyResolverList; }; } #endif diff --git a/src/core-impl/collections/playdarcollection/PlaydarMeta.h b/src/core-impl/collections/playdarcollection/PlaydarMeta.h index 982729c0de..a8140549d4 100644 --- a/src/core-impl/collections/playdarcollection/PlaydarMeta.h +++ b/src/core-impl/collections/playdarcollection/PlaydarMeta.h @@ -1,282 +1,282 @@ /**************************************************************************************** * Copyright (c) 2010 Andrew Coder * * * * 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 PLAYDAR_META_H #define PLAYDAR_META_H #include "core/meta/Meta.h" #include #include #include #include #include "AmarokSharedPointer.h" #include namespace Collections { class Collection; class PlaydarCollection; } namespace Meta { class PlaydarTrack; class PlaydarArtist; class PlaydarAlbum; class PlaydarGenre; class PlaydarComposer; class PlaydarYear; class PlaydarLabel; typedef AmarokSharedPointer< PlaydarTrack > PlaydarTrackPtr; typedef QList< PlaydarTrackPtr > PlaydarTrackList; typedef AmarokSharedPointer< PlaydarArtist > PlaydarArtistPtr; typedef QList< PlaydarArtistPtr > PlaydarArtistList; typedef AmarokSharedPointer< PlaydarAlbum > PlaydarAlbumPtr; typedef QList< PlaydarAlbumPtr > PlaydarAlbumList; typedef AmarokSharedPointer< PlaydarComposer > PlaydarComposerPtr; typedef QList< PlaydarComposerPtr > PlaydarComposerList; typedef AmarokSharedPointer< PlaydarGenre > PlaydarGenrePtr; typedef QList< PlaydarGenrePtr > PlaydarGenreList; typedef AmarokSharedPointer< PlaydarYear > PlaydarYearPtr; typedef QList< PlaydarYearPtr > PlaydarYearList; typedef AmarokSharedPointer< PlaydarLabel > PlaydarLabelPtr; typedef QList< PlaydarLabelPtr > PlaydarLabelList; class PlaydarTrack : public Track { public: PlaydarTrack( QString &sid, QString &playableUrl, QString &name, QString &artist, QString &album, QString &mimetype, double score, qint64 length, int bitrate, int filesize, QString &source ); ~PlaydarTrack() override; QString name() const override; QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; QString sid() const; QString notPlayableReason() const override; AlbumPtr album() const override; ArtistPtr artist() const override; ComposerPtr composer() const override; GenrePtr genre() const override; YearPtr year() const override; LabelList labels() const override; qreal bpm() const override; QString comment() const override; double score() const; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; QDateTime createDate() const override; int trackNumber() const override; int discNumber() const override; QString type() const override; bool inCollection() const override; Collections::Collection* collection() const override; QString cachedLyrics() const override; void setCachedLyrics( const QString &lyrics ) override; void addLabel( const QString &label ) override; void addLabel( const LabelPtr &label ) override; void removeLabel( const LabelPtr &label ) override; StatisticsPtr statistics() override; //PlaydarTrack-specific: QString source() const; QString mimetype() const; void addToCollection( Collections::PlaydarCollection *collection ); void setAlbum( const PlaydarAlbumPtr &album ); void setArtist( const PlaydarArtistPtr &artist ); void setComposer( const PlaydarComposerPtr &composer ); void setGenre( const PlaydarGenrePtr &genre ); void setYear( const PlaydarYearPtr &year ); PlaydarAlbumPtr playdarAlbum(); PlaydarArtistPtr playdarArtist(); PlaydarComposerPtr playdarComposer(); PlaydarGenrePtr playdarGenre(); PlaydarYearPtr playdarYear(); PlaydarLabelList playdarLabels(); private: QPointer< Collections::PlaydarCollection > m_collection; PlaydarAlbumPtr m_album; PlaydarArtistPtr m_artist; PlaydarComposerPtr m_composer; PlaydarGenrePtr m_genre; PlaydarYearPtr m_year; PlaydarLabelList m_labelList; Meta::StatisticsPtr m_statsStore; QString m_sid; QUrl m_uidUrl; QString m_playableUrl; QString m_name; QString m_mimetype; double m_score; qint64 m_length; int m_bitrate; int m_filesize; int m_trackNumber; int m_discNumber; QDateTime m_createDate; QString m_comment; QString m_source; }; class PlaydarArtist : public Artist { public: explicit PlaydarArtist( const QString &name ); - ~PlaydarArtist(); + ~PlaydarArtist() override; QString name() const override; TrackList tracks() override; AlbumList albums(); void addTrack( const PlaydarTrackPtr &newTrack ); void addAlbum( const PlaydarAlbumPtr &newAlbum ); private: QString m_name; TrackList m_tracks; AlbumList m_albums; }; class PlaydarAlbum : public Album { public: explicit PlaydarAlbum( const QString &name ); - ~PlaydarAlbum(); + ~PlaydarAlbum() override; bool isCompilation() const override; QString name() const override; bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; bool hasImage( int size = 0 ) const override; QImage image( int size = 0 ) const override; QUrl imageLocation( int size = 0 ) override; bool canUpdateImage() const override; void setImage( const QImage &image ) override; void removeImage() override; void setSuppressImageAutoFetch( const bool suppress ) override; bool suppressImageAutoFetch() const override; void addTrack( const PlaydarTrackPtr &newTrack ); void setAlbumArtist( const PlaydarArtistPtr &newAlbumArtist ); private: QString m_name; TrackList m_tracks; bool m_isCompilation; ArtistPtr m_albumArtist; bool m_suppressImageAutoFetch; mutable bool m_triedToFetchCover; mutable QImage m_cover; }; class PlaydarComposer : public Composer { public: explicit PlaydarComposer( const QString &name ); - ~PlaydarComposer(); + ~PlaydarComposer() override; QString name() const override; TrackList tracks() override; void addTrack( const PlaydarTrackPtr &newTrack ); private: QString m_name; TrackList m_tracks; }; class PlaydarGenre : public Genre { public: explicit PlaydarGenre( const QString &name ); - ~PlaydarGenre(); + ~PlaydarGenre() override; QString name() const override; TrackList tracks() override; void addTrack( const PlaydarTrackPtr &newTrack ); private: QString m_name; TrackList m_tracks; }; class PlaydarYear : public Year { public: explicit PlaydarYear( const QString &name ); - ~PlaydarYear(); + ~PlaydarYear() override; QString name() const override; TrackList tracks() override; void addTrack( const PlaydarTrackPtr &newTrack ); private: QString m_name; TrackList m_tracks; }; class PlaydarLabel : public Label { public: explicit PlaydarLabel( const QString &name ); - ~PlaydarLabel(); + ~PlaydarLabel() override; QString name() const override; void addTrack( const PlaydarTrackPtr &newTrack ); private: QString m_name; TrackList m_tracks; }; } #endif /* PLAYDARMETA_H */ diff --git a/src/core-impl/collections/playdarcollection/support/Controller.h b/src/core-impl/collections/playdarcollection/support/Controller.h index 28a461bf12..04de209166 100644 --- a/src/core-impl/collections/playdarcollection/support/Controller.h +++ b/src/core-impl/collections/playdarcollection/support/Controller.h @@ -1,157 +1,157 @@ /**************************************************************************************** * Copyright (c) 2010 Andrew Coder * * * * 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 PLAYDAR_CONTROLLER_H #define PLAYDAR_CONTROLLER_H #include #include class QUrl; class KJob; class QString; /** * @namespace Playdar contains the implementation of the Playdar API * in Amarok, so far as it is not specific to collection or context use. */ namespace Playdar { class Query; /** * This class provides a basic interface to Playdar's resolution * functionality. A user should initialize a Controller, wait for * playdarReady(), and proceed to use resolve( artist, album, title ) * as much as they'd like. Unless some error occurs, queryReady( QueryPtr ) * will provide a QueryPtr for each call to resolve(). Results will * be provided by the appropriate Query as they become available, and * the friendly relationship between Controller and Query ensures that * results are properly matched with Queries. */ class Controller : public QObject { Q_OBJECT public: /** * We invoke the private function status() here, return immediately, * and will Q_EMIT playdarReady() once things are actually set up. * @param queriesShouldWaitForSolutions * If true, Playdar::Queries created by this controller will * only use getResultsLongPoll instead of first using getResults. */ explicit Controller( bool queriesShouldWaitForSolutions = false ); /** * Controllers don't hold on to anything, so the deconstructor does nothing. */ - ~Controller(); + ~Controller() override; /** * Asks Playdar for status information, which eventually results in * the emission of playdarReady() if it does or error() otherwise. */ void status(); /** * Asks Playdar to resolve a query, which eventually results in the * emission of queryReady() if okay, or error() if something goes wrong. * @param artist Name of artist to search for. * @param album Name of album (by artist) to search for. * @param title Name of track on album to search for. * NOTE: Currently, for a query to have any chance of being solved, * both artist and title must be non-empty! */ void resolve( const QString &artist, const QString &album, const QString &title ); /** These errors are used when Playdar::Controller emits error(). */ enum ErrorState { /** Nothing bad happened yet! */ NoError, /** Indicates an error from KIO or the Playdar service itself. */ ExternalError, /** A request for status revealed a service claiming to not be Playdar. */ WrongServiceName, /** A service asked for status didn't identify itself. */ MissingServiceName, /** No "qid" field was found in a response to resolve() or getResults(). */ MissingQid, /** Results were delivered to the wrong query */ WrongQid, /** A response to getResults() didn't include a "results" array. */ MissingResults }; Q_SIGNALS: /** * Emitted once after construction, as long as some service responds * from where we think Playdar is, and identifies itself as "playdar". * Clients shouldn't try to resolve things until they get this signal. */ void playdarReady(); /** * Emitted after resolve() is invoked, as long as Playdar's response * includes a "qid" field. If the client object's looking for results, * the Query's where they'll be when Playdar's got back to us. The * controller doesn't keep any QueryPtrs around, so interested clients * should keep a QueryList for any QueryPtrs they'd like to have. */ void queryReady( Playdar::Query* ); /** * Emitted after something unfortunate happens, * along with the (hopefully) appropriate ErrorType */ void playdarError( Playdar::Controller::ErrorState ); public: /** * NOTE: Queries handle invoking these on their own. */ /** * Asks Playdar for the state of the query with @p qid. * If all goes well, resultsReady() is emitted, error() if something goes wrong. * @param query The query to get results for */ void getResults( Playdar::Query* query ); /** * Like getResults(), but Playdar will wait to respond until the query * has either been solved or enough time passes, (usually about 4000ms), * that the query would have been solved it was possible. * @param query The query to get results for */ void getResultsLongPoll( Playdar::Query* query ); /** * Makes a naive attempt to produce a QUrl that points to * a playable location of a query result. * @param sid The sid of the result desired. */ QUrl urlForSid( const QString &sid ) const; private Q_SLOTS: void processStatus( KJob* statusJob ); void processQuery( KJob* queryJob ); private: ErrorState m_errorState; bool m_queriesShouldWaitForSolutions; }; } #endif diff --git a/src/core-impl/collections/playdarcollection/support/ProxyResolver.h b/src/core-impl/collections/playdarcollection/support/ProxyResolver.h index f172600b2c..5318e8cea1 100644 --- a/src/core-impl/collections/playdarcollection/support/ProxyResolver.h +++ b/src/core-impl/collections/playdarcollection/support/ProxyResolver.h @@ -1,61 +1,61 @@ /**************************************************************************************** * Copyright (c) 2010 Andrew Coder * * * * 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 PLAYDAR_PROXY_RESOLVER_H #define PLAYDAR_PROXY_RESOLVER_H #include "Controller.h" #include "../PlaydarCollection.h" #include "../PlaydarMeta.h" #include "core-impl/meta/proxy/MetaProxy.h" #include class QUrl; namespace Playdar { /** * ProxyResolver takes a MetaProxy::Track and a playdar:// url, * and updates the Track with a PlaydarTrack if we can find it. */ class ProxyResolver : public QObject { Q_OBJECT public: ProxyResolver( Collections::PlaydarCollection *collection, const QUrl &url, const MetaProxy::TrackPtr &track ); - ~ProxyResolver(); + ~ProxyResolver() override; Q_SIGNALS: void playdarError( Playdar::Controller::ErrorState ); private Q_SLOTS: void slotPlaydarError( Playdar::Controller::ErrorState error ); void collectQuery( Playdar::Query *query ); void collectSolution( Meta::PlaydarTrackPtr track ); void slotQueryDone( Playdar::Query *query, const Meta::PlaydarTrackList & tracks ); private: QPointer< Collections::PlaydarCollection > m_collection; MetaProxy::TrackPtr m_proxyTrack; Playdar::Controller* m_controller; Playdar::Query* m_query; }; } #endif diff --git a/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h b/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h index 1bd6e5524a..55dd961c04 100644 --- a/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h +++ b/src/core-impl/collections/playdarcollection/support/QMFunctionTypes.h @@ -1,195 +1,195 @@ /**************************************************************************************** * Copyright (c) 2010 Andrew Coder * * * * 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 QM_FUNCTION_TYPES_H #define QM_FUNCTION_TYPES_H #include "core/collections/QueryMaker.h" using namespace Collections; /** * A CurriedQMFunction is a call to any of the member functions * of QueryMaker that return a QueryMaker*, which it's arguments * specified, but missing, (normally implicit), this pointer parameter. * * Subclasses provide a typedef named FunPtr as a convenience, which * provides a type equal to that of a pointer to a QueryMaker member * function which returns a QueryMaker* and accepts the number and * type of parameters that the CurriedQMFunction does. Having the * typedefs in the classes prevents issues with C++'s lack of support * for template typedefs. */ class CurriedQMFunction { public: virtual ~CurriedQMFunction() {} /** * Invokes the stored function, with the stored * parameters, providing @param qm as the this pointer. * @return qm */ virtual QueryMaker* operator()( QueryMaker *qm = 0 ) = 0; }; /** * The CurriedQMFunction for functions with no arguments. */ class CurriedZeroArityQMFunction : public CurriedQMFunction { public: typedef QueryMaker* ( QueryMaker::*FunPtr ) (); explicit CurriedZeroArityQMFunction( FunPtr function ) : m_function( function ) {} - virtual ~CurriedZeroArityQMFunction() {} + ~CurriedZeroArityQMFunction() override {} QueryMaker* operator()( QueryMaker *qm = 0 ) override { if( qm ) return ( qm->*m_function )(); return qm; }; private: FunPtr m_function; }; /** * The CurriedQMFunction for functions with one arguments. */ template< class Type > class CurriedUnaryQMFunction : public CurriedQMFunction { public: typedef QueryMaker* ( QueryMaker::*FunPtr ) ( Type ); CurriedUnaryQMFunction( FunPtr function, Type parameter ) : m_function( function ) , m_parameter( parameter ) {} - virtual ~CurriedUnaryQMFunction() {} + ~CurriedUnaryQMFunction() override {} QueryMaker* operator()( QueryMaker *qm ) override { if( qm ) return ( qm->*m_function )( m_parameter ); return qm; }; private: FunPtr m_function; Type m_parameter; }; /** * The CurriedQMFunction for functions with two arguments. */ template< class FirstType, class SecondType > class CurriedBinaryQMFunction : public CurriedQMFunction { public: typedef QueryMaker* ( QueryMaker::*FunPtr ) ( FirstType, SecondType ); CurriedBinaryQMFunction( FunPtr function, FirstType parameterOne, SecondType parameterTwo ) : m_function( function ) , m_parameterOne( parameterOne ) , m_parameterTwo( parameterTwo ) {} - virtual ~CurriedBinaryQMFunction() {} + ~CurriedBinaryQMFunction() override {} QueryMaker* operator()( QueryMaker *qm ) override { if( qm ) return ( qm->*m_function )( m_parameterOne, m_parameterTwo ); return qm; }; private: FunPtr m_function; FirstType m_parameterOne; SecondType m_parameterTwo; }; /** * The CurriedQMFunction for functions with three arguments. */ template< class FirstType, class SecondType, class ThirdType > class CurriedTrinaryQMFunction : public CurriedQMFunction { public: typedef QueryMaker* ( QueryMaker::*FunPtr ) ( FirstType, SecondType, ThirdType ); CurriedTrinaryQMFunction( FunPtr function, FirstType parameterOne, SecondType parameterTwo, ThirdType parameterThree ) : m_function( function ) , m_parameterOne( parameterOne ) , m_parameterTwo( parameterTwo ) , m_parameterThree( parameterThree ) {} - virtual ~CurriedTrinaryQMFunction() {} + ~CurriedTrinaryQMFunction() override {} QueryMaker* operator()( QueryMaker *qm ) override { if( qm ) return ( qm->*m_function )( m_parameterOne, m_parameterTwo, m_parameterThree ); return qm; }; private: FunPtr m_function; FirstType m_parameterOne; SecondType m_parameterTwo; ThirdType m_parameterThree; }; /** * The CurriedQMFunction for functions with four arguments. * Passing the QString as a reference to the constructor caused * some problems, so this one's specialized for the only two * members of QueryMaker that have four parameters, addFilter * and excludeFilter. */ class CurriedQMStringFilterFunction : public CurriedQMFunction { public: typedef QueryMaker* ( QueryMaker::*FunPtr ) ( qint64, const QString&, bool, bool ); CurriedQMStringFilterFunction( FunPtr function, qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) : m_function( function ) , m_value( value ) , m_filter( filter ) , m_matchBegin( matchBegin ) , m_matchEnd( matchEnd ) {} - virtual ~CurriedQMStringFilterFunction() {} + ~CurriedQMStringFilterFunction() override {} QueryMaker* operator()( QueryMaker *qm ) override { if( qm ) return ( qm->*m_function )( m_value, m_filter, m_matchBegin, m_matchEnd ); return qm; }; private: FunPtr m_function; qint64 m_value; QString m_filter; bool m_matchBegin; bool m_matchEnd; }; #endif diff --git a/src/core-impl/collections/playdarcollection/support/Query.h b/src/core-impl/collections/playdarcollection/support/Query.h index 3ed6d01c13..8fe86c6f00 100644 --- a/src/core-impl/collections/playdarcollection/support/Query.h +++ b/src/core-impl/collections/playdarcollection/support/Query.h @@ -1,120 +1,120 @@ /**************************************************************************************** * Copyright (c) 2010 Andrew Coder * * * * 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 PLAYDAR_QUERYOBJECT_H #define PLAYDAR_QUERYOBJECT_H #include "Controller.h" #include "core/meta/forward_declarations.h" #include "../PlaydarMeta.h" #include class KJob; class QString; namespace Playdar { /** * A Query provides an interface to a single Playdar query. * Clients should receive these from their Playdar::Controller, * rather than constructing them. After getting a Query, just * wait for newTrackAdded(), querySolved(), or queryDone(), * as appropriate. Using QueryPtr will make sure a neglected Query * gets deleted, and Controllers won't hold on to the reference, * so interested objects should be sure to store their QueryPtrs. * NOTE: artist(), album(), and title() are all empty until * the first round of results has come in from Playdar. * Queries are matched with results by qid(). */ class Query : public QObject { Q_OBJECT public: //Constructor and Destructor Query( const QString &qid, Playdar::Controller* controller, bool waitForSolution ); - ~Query(); + ~Query() override; /** @return UID for this query given by Playdar */ QString qid() const; /** @return Name of artist used in query */ QString artist() const; /** @return Name of album used in query */ QString album() const; /** @return Track title used in query */ QString title() const; /** * @return @c true A track has received a 1.00 score * @return @c false No track has a 1.00 score */ bool isSolved() const; /** * @return 0 if the query is unsolved, and an arbitrary track * with a perfect score of 1.00 if the query is solved. */ Meta::PlaydarTrackPtr getSolution() const; /** * @return The (possibly empty) PlaydarTrackList containing any * results found so far. */ Meta::PlaydarTrackList getTrackList() const; public Q_SLOTS: void receiveResults( KJob* ); Q_SIGNALS: /** * Emitted each time a new track is added to the list of results, * returning the latest result as a Meta::PlaydarTrack. */ void newTrackAdded( const Meta::PlaydarTrackPtr &); /** * Emitted once if a query is solved, and returns the first track * with a perfect score of 1.00. Will not be emitted if the query * ends otherwise. (Emitted alongside newTrackAdded). */ void querySolved( const Meta::PlaydarTrackPtr &); /** * Emitted once all results that may be found by our means have * been found, and returns the internal results list in its final state. */ void queryDone( Playdar::Query*, const Meta::PlaydarTrackList &); /** * Indicates an error. Don't bother connecting to this if you're * already connected to Controller::error, since the controller * will pass the signal along. */ void playdarError( Playdar::Controller::ErrorState ); private: QPointer< Playdar::Controller > m_controller; bool m_waitForSolution; QString m_qid; QString m_artist; QString m_album; QString m_title; bool m_solved; bool m_receivedFirstResults; Meta::PlaydarTrackList m_trackList; }; } #endif diff --git a/src/core-impl/collections/support/CollectionLocationDelegateImpl.h b/src/core-impl/collections/support/CollectionLocationDelegateImpl.h index f9acbf6436..70adad7261 100644 --- a/src/core-impl/collections/support/CollectionLocationDelegateImpl.h +++ b/src/core-impl/collections/support/CollectionLocationDelegateImpl.h @@ -1,52 +1,52 @@ /**************************************************************************************** * Copyright (c) 2012 Ryan McCoskrie * * Copyright (c) 2010 Maximilian Kossick * * Copyright (c) 2010 Casey Link * * * * 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 COLLECTIONLOCATIONDELEGATEIMPL_H #define COLLECTIONLOCATIONDELEGATEIMPL_H #include "amarok_export.h" #include "core/collections/CollectionLocationDelegate.h" #include namespace Collections { class AMAROK_EXPORT CollectionLocationDelegateImpl : public CollectionLocationDelegate { public: CollectionLocationDelegateImpl() {} - virtual ~ CollectionLocationDelegateImpl() {} + ~ CollectionLocationDelegateImpl() override {} bool reallyDelete( CollectionLocation *loc, const Meta::TrackList &tracks ) const override; bool reallyMove(CollectionLocation* loc, const Meta::TrackList& tracks) const override; bool reallyTrash( CollectionLocation *loc, const Meta::TrackList &tracks ) const override; void errorDeleting( CollectionLocation* loc, const Meta::TrackList& tracks ) const override; void notWriteable(CollectionLocation* loc) const override; bool deleteEmptyDirs(CollectionLocation* loc) const override; Transcoding::Configuration transcode( const QStringList &playableFileTypes, bool *remember, OperationType operation, const QString &destCollectionName, const Transcoding::Configuration &prevConfiguration ) const override; private: QStringList trackList( const Meta::TrackList &tracks ) const; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/support/CollectionManager.h b/src/core-impl/collections/support/CollectionManager.h index a12876daf9..da9fcd62f9 100644 --- a/src/core-impl/collections/support/CollectionManager.h +++ b/src/core-impl/collections/support/CollectionManager.h @@ -1,177 +1,177 @@ /**************************************************************************************** * Copyright (c) 2007-2008 Maximilian Kossick * * * * 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_COLLECTIONMANAGER_H #define AMAROK_COLLECTIONMANAGER_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include #include #include namespace Plugins { class PluginFactory; } namespace Collections { class Collection; class CollectionFactory; class TrackProvider; class QueryMaker; } /** Class managing the different collections. * * This singleton class is the main repository for all current collections. * The most useful functions are probably queryMaker and * viewableCollections */ class AMAROK_EXPORT CollectionManager : public QObject { Q_OBJECT public: /** * defines the status of a collection in respect to global queries (i.e. queries that query all known collections) * or the collection browser. */ enum CollectionStatus { CollectionDisabled = 1, ///< Collection neither viewable nor queryable (but might produce tracks that can be played) CollectionViewable = 2, ///< Collection will not be queried by CollectionManager::queryMaker CollectionQueryable= 4, ///< Collection wil not show up in the browser, but is queryable by global queries CollectionEnabled = CollectionViewable | CollectionQueryable ///< Collection viewable in the browser and queryable }; Q_ENUM( CollectionStatus ) static CollectionManager *instance(); /** Destroys the instance of the CollectionManager. */ static void destroy(); /** * Returns a query maker that queries all queryable the collections */ Collections::QueryMaker *queryMaker() const; /** * returns all viewable collections. */ QList viewableCollections() const; //TODO: Remove /** * Allows access to one of Amarok's collection. * * @deprecated DO NOT USE this method. This is legacy code from the early days of Amarok * when SqlCollection was the only working collection. If you are writing new code, make * sure that it is able to handle multiple collections, * e.g. multiple connected media devices. Using this method means you are lazy. An easy way * is to use CollectionManager::queryMaker(). Alternatively, access the available collections * using CollectionManager::queryableCollections() or CollectionManager::viewableCollections() * and do whatever you want to. * */ Collections::Collection* primaryCollection() const; /** This method will try to get a Track object for the given url. This method will return 0 if no Track object could be created for the url. */ Meta::TrackPtr trackForUrl( const QUrl &url ); CollectionStatus collectionStatus( const QString &collectionId ) const; QHash collections() const; /** * adds a TrackProvider to the list of TrackProviders, * which allows CollectionManager to create tracks in trackForUrl. * CollectionManager does not take ownership of the TrackProvider pointer * * Note: collections that CollectionManager knows about are automatically * added to the list of TrackProviders. * * @param provider the new TrackProvider */ void addTrackProvider( Collections::TrackProvider *provider ); /** * removes a TrackProvider. Does not do anything if * CollectionManager does not know the given TrackProvider. * * Note: collections will be automatically removed from * the list of available TrackProviders. * * @param provider the provider to be removed */ void removeTrackProvider( Collections::TrackProvider *provider ); /** * Set the list of current factories * * For every factory that is a CollectionFactory uses it to create new * collections and register with this manager. */ void setFactories( const QList > &factories ); public Q_SLOTS: /** Starts the full scan for each collection with CollectionScanCapability */ void startFullScan(); /** Starts the incremental scan for each collection with CollectionScanCapability */ void startIncrementalScan( const QString &directory = QString() ); void stopScan(); void checkCollectionChanges(); Q_SIGNALS: //deprecated, use collectionAdded( Collections::Collection*, CollectionStatus ) instead // void collectionAdded( Collections::Collection *newCollection ); void collectionAdded( Collections::Collection *newCollection, CollectionManager::CollectionStatus status ); void collectionRemoved( const QString &collectionId ); void trackProviderAdded( Collections::TrackProvider *provider ); //this signal will be emitted after major changes to the collection //e.g. new songs where added, or an album changed //from compilation to non-compilation (and vice versa) //it will not be emitted on minor changes (e.g. the tags of a song were changed) void collectionDataChanged( Collections::Collection *changedCollection ); private Q_SLOTS: /** Will be called whenever a registered collection factory creates a new collection */ void slotNewCollection( Collections::Collection *newCollection ); /** Will remove the collection that emitted the signal */ void slotRemoveCollection(); void slotCollectionChanged(); private: static CollectionManager* s_instance; CollectionManager(); - ~CollectionManager(); + ~CollectionManager() override; void init(); Q_DISABLE_COPY( CollectionManager ) struct Private; Private * const d; }; #endif /* AMAROK_COLLECTIONMANAGER_H */ diff --git a/src/core-impl/collections/support/FileCollectionLocation.h b/src/core-impl/collections/support/FileCollectionLocation.h index 44a0713bcb..6557031656 100644 --- a/src/core-impl/collections/support/FileCollectionLocation.h +++ b/src/core-impl/collections/support/FileCollectionLocation.h @@ -1,54 +1,54 @@ /**************************************************************************************** * Copyright (c) 2008-2010 Casey Link * * * * 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_FILECOLLECTIONLOCATION_H #define AMAROK_FILECOLLECTIONLOCATION_H #include "amarok_export.h" #include "core/collections/CollectionLocation.h" #include #include #include class KJob; namespace Collections { class AMAROK_EXPORT FileCollectionLocation : public CollectionLocation { Q_OBJECT public: FileCollectionLocation(); - virtual ~FileCollectionLocation(); + ~FileCollectionLocation() override; QString prettyLocation() const override; bool isWritable() const override; bool isOrganizable() const override; void removeUrlsFromCollection( const Meta::TrackList& sources ) override; void showRemoveDialog( const Meta::TrackList &tracks ) override; public Q_SLOTS: void slotRemoveJobFinished( KJob *job ); private: void startRemoveJobs(); QMap m_removejobs; Meta::TrackList m_removetracks; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/support/MemoryCustomValue.cpp b/src/core-impl/collections/support/MemoryCustomValue.cpp index 4e0f390302..099297adba 100644 --- a/src/core-impl/collections/support/MemoryCustomValue.cpp +++ b/src/core-impl/collections/support/MemoryCustomValue.cpp @@ -1,505 +1,505 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 . * ****************************************************************************************/ #include "MemoryCustomValue.h" #include "core/meta/Meta.h" #include "core/meta/Statistics.h" #include class SumReturnFunction : public CustomReturnFunction { public: SumReturnFunction( CustomReturnValue * rv ) : returnValue( rv ) {} - ~SumReturnFunction() { delete returnValue; } + ~SumReturnFunction() override { delete returnValue; } QString value( const Meta::TrackList &tracks ) const override { if( !returnValue ) return QString::number( 0 ); double sum = 0.0; foreach( const Meta::TrackPtr &track, tracks ) sum += returnValue->value( track ).toDouble(); return QString::number( sum ); } private: CustomReturnValue *returnValue; }; class MinimumReturnFunction : public CustomReturnFunction { public: MinimumReturnFunction( CustomReturnValue * rv ) : returnValue( rv ) {} - ~MinimumReturnFunction() { delete returnValue; } + ~MinimumReturnFunction() override { delete returnValue; } QString value( const Meta::TrackList &tracks ) const override { if( tracks.empty() || !returnValue ) return QString::number( 0 ); double min = returnValue->value( tracks.first() ).toDouble(); foreach( const Meta::TrackPtr &track, tracks ) min = qMin( min, returnValue->value( track ).toDouble() ); return QString::number( min ); } private: CustomReturnValue *returnValue; }; class MaximumReturnFunction : public CustomReturnFunction { public: MaximumReturnFunction( CustomReturnValue * rv ) : returnValue( rv ) {} - ~MaximumReturnFunction() { delete returnValue; } + ~MaximumReturnFunction() override { delete returnValue; } QString value( const Meta::TrackList &tracks ) const override { if( tracks.empty() || !returnValue ) return QString::number( 0 ); double max = returnValue->value( tracks.first() ).toDouble(); foreach( const Meta::TrackPtr &track, tracks ) max = qMax( max, returnValue->value( track ).toDouble() ); return QString::number( max ); } private: CustomReturnValue *returnValue; }; CustomReturnFunction* CustomValueFactory::returnFunction( Collections::QueryMaker::ReturnFunction function, qint64 value ) { switch( function ) { case Collections::QueryMaker::Count: { switch( value ) { case Meta::valUrl: case Meta::valTitle: { return new TrackCounter(); } case Meta::valArtist: { return new ArtistCounter(); } case Meta::valAlbum: { return new AlbumCounter(); } case Meta::valGenre: { return new GenreCounter(); } case Meta::valComposer: { return new ComposerCounter(); } case Meta::valYear: { return new YearCounter(); } default: return 0; } } case Collections::QueryMaker::Sum: { CustomReturnValue *crv = CustomValueFactory::returnValue( value ); return crv ? new SumReturnFunction( crv ) : 0; } case Collections::QueryMaker::Min: { CustomReturnValue *crv = CustomValueFactory::returnValue( value ); return crv ? new MinimumReturnFunction( crv ) : 0; } case Collections::QueryMaker::Max: { CustomReturnValue *crv = CustomValueFactory::returnValue( value ); return crv ? new MaximumReturnFunction( crv ) : 0; } default: return 0; } } CustomReturnFunction::CustomReturnFunction() { } CustomReturnFunction::~CustomReturnFunction() { } CustomReturnValue::CustomReturnValue() { } CustomReturnValue::~CustomReturnValue() { } TrackCounter::TrackCounter() { } TrackCounter::~TrackCounter() { } QString TrackCounter::value( const Meta::TrackList &tracks ) const { return QString::number( tracks.count() ); } ArtistCounter::ArtistCounter() { } ArtistCounter::~ArtistCounter() { } QString ArtistCounter::value( const Meta::TrackList &tracks ) const { QSet artists; foreach( const Meta::TrackPtr &track, tracks ) { if( track->artist() ) artists.insert( track->artist() ); } return QString::number( artists.count() ); } GenreCounter::GenreCounter() { } GenreCounter::~GenreCounter() { } QString GenreCounter::value( const Meta::TrackList &tracks ) const { QSet genres; foreach( const Meta::TrackPtr &track, tracks ) { if( track->genre() ) genres.insert( track->genre() ); } return QString::number( genres.count() ); } AlbumCounter::AlbumCounter() { } AlbumCounter::~AlbumCounter() { } QString AlbumCounter::value( const Meta::TrackList &tracks ) const { QSet albums; foreach( const Meta::TrackPtr &track, tracks ) { if( track->album() ) albums.insert( track->album() ); } return QString::number( albums.count() ); } ComposerCounter::ComposerCounter() { } ComposerCounter::~ComposerCounter() { } QString ComposerCounter::value( const Meta::TrackList &tracks ) const { QSet composers; foreach( const Meta::TrackPtr &track, tracks ) { if( track->composer() ) composers.insert( track->composer() ); } return QString::number( composers.count() ); } YearCounter::YearCounter() { } YearCounter::~YearCounter() { } QString YearCounter::value( const Meta::TrackList &tracks ) const { QSet years; foreach( const Meta::TrackPtr &track, tracks ) { if( track->year() ) years.insert( track->year() ); } return QString::number( years.count() ); } //CustomReturnValues TitleReturnValue::TitleReturnValue() { } TitleReturnValue::~TitleReturnValue() { } QString TitleReturnValue::value( const Meta::TrackPtr &track ) const { return track->name(); } UrlReturnValue::UrlReturnValue() { } UrlReturnValue::~UrlReturnValue() { } QString UrlReturnValue::value( const Meta::TrackPtr &track ) const { return track->playableUrl().url(); } class ArtistReturnValue : public CustomReturnValue { public: ArtistReturnValue() {} - virtual ~ArtistReturnValue() {} + ~ArtistReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return track->artist() ? track->artist()->name() : QString(); } }; class AlbumReturnValue : public CustomReturnValue { public: AlbumReturnValue() {} - virtual ~AlbumReturnValue() {} + ~AlbumReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return track->album() ? track->album()->name() : QString(); } }; class ComposerReturnValue : public CustomReturnValue { public: ComposerReturnValue() {} - virtual ~ComposerReturnValue() {} + ~ComposerReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return track->composer() ? track->composer()->name() : QString(); } }; class GenreReturnValue : public CustomReturnValue { public: GenreReturnValue() {} - virtual ~GenreReturnValue() {} + ~GenreReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return track->genre() ? track->genre()->name() : QString(); } }; class YearReturnValue : public CustomReturnValue { public: YearReturnValue() {} - virtual ~YearReturnValue() {} + ~YearReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return track->year() ? track->year()->name() : QString(); } }; class CommentReturnValue : public CustomReturnValue { public: CommentReturnValue() {} - virtual ~CommentReturnValue() {} + ~CommentReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return track->comment(); } }; class TrackNrReturnValue : public CustomReturnValue { public: TrackNrReturnValue() {} - virtual ~TrackNrReturnValue() {} + ~TrackNrReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->trackNumber() ); } }; class DiscNrReturnValue : public CustomReturnValue { public: DiscNrReturnValue() {} - virtual ~DiscNrReturnValue() {} + ~DiscNrReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->discNumber() ); } }; class ScoreReturnValue : public CustomReturnValue { public: ScoreReturnValue() {} - virtual ~ScoreReturnValue() {} + ~ScoreReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->statistics()->score() ); } }; class RatingReturnValue : public CustomReturnValue { public: RatingReturnValue() {} - virtual ~RatingReturnValue() {} + ~RatingReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->statistics()->rating() ); } }; class PlaycountReturnValue : public CustomReturnValue { public: PlaycountReturnValue() {} - virtual ~PlaycountReturnValue() {} + ~PlaycountReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->statistics()->playCount() ); } }; class LengthReturnValue : public CustomReturnValue { public: LengthReturnValue() {} - virtual ~LengthReturnValue() {} + ~LengthReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->length() / 1000 ); } }; class BitrateReturnValue : public CustomReturnValue { public: BitrateReturnValue() {} - virtual ~BitrateReturnValue() {} + ~BitrateReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->bitrate() ); } }; class FileSizeReturnValue : public CustomReturnValue { public: FileSizeReturnValue() {} - virtual ~FileSizeReturnValue() {} + ~FileSizeReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->filesize() ); } }; class SampleRateReturnValue : public CustomReturnValue { public: SampleRateReturnValue() {} - virtual ~SampleRateReturnValue() {} + ~SampleRateReturnValue() override {} QString value( const Meta::TrackPtr &track ) const override { return QString::number( track->sampleRate() ); } }; CustomReturnValue* CustomValueFactory::returnValue( qint64 value ) { switch( value ) { case Meta::valTitle: { return new TitleReturnValue(); } case Meta::valUrl: { return new UrlReturnValue(); } case Meta::valArtist: { return new ArtistReturnValue(); } case Meta::valAlbum: { return new AlbumReturnValue(); } case Meta::valGenre: { return new GenreReturnValue(); } case Meta::valComposer: { return new ComposerReturnValue(); } case Meta::valYear: { return new YearReturnValue(); } case Meta::valComment: { return new CommentReturnValue(); } case Meta::valTrackNr: { return new TrackNrReturnValue(); } case Meta::valDiscNr: { return new DiscNrReturnValue(); } case Meta::valScore: { return new ScoreReturnValue(); } case Meta::valRating: { return new RatingReturnValue(); } case Meta::valPlaycount: { return new PlaycountReturnValue(); } case Meta::valLength: { return new LengthReturnValue(); } case Meta::valBitrate: { return new BitrateReturnValue(); } case Meta::valFilesize: { return new FileSizeReturnValue(); } case Meta::valSamplerate: { return new SampleRateReturnValue(); } default: return 0; } } diff --git a/src/core-impl/collections/support/MemoryCustomValue.h b/src/core-impl/collections/support/MemoryCustomValue.h index 135a058f1a..3a6f45a422 100644 --- a/src/core-impl/collections/support/MemoryCustomValue.h +++ b/src/core-impl/collections/support/MemoryCustomValue.h @@ -1,125 +1,125 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 MEMORYCUSTOMVALUE_H #define MEMORYCUSTOMVALUE_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "core/collections/QueryMaker.h" #include #include class CustomReturnFunction; class CustomReturnValue; namespace CustomValueFactory { CustomReturnFunction* returnFunction( Collections::QueryMaker::ReturnFunction function, qint64 value ); CustomReturnValue* returnValue( qint64 value ); } class AMAROK_EXPORT CustomReturnFunction { public: CustomReturnFunction(); virtual ~CustomReturnFunction(); virtual QString value( const Meta::TrackList &tracks ) const = 0; }; class AMAROK_EXPORT TrackCounter : public CustomReturnFunction { public: TrackCounter(); - virtual ~TrackCounter(); + ~TrackCounter() override; QString value( const Meta::TrackList &tracks ) const override; }; class AMAROK_EXPORT ArtistCounter : public CustomReturnFunction { public: ArtistCounter(); - virtual ~ArtistCounter(); + ~ArtistCounter() override; QString value( const Meta::TrackList &tracks ) const override; }; class AMAROK_EXPORT GenreCounter : public CustomReturnFunction { public: GenreCounter(); - virtual ~GenreCounter(); + ~GenreCounter() override; QString value( const Meta::TrackList &tracks ) const override; }; class AMAROK_EXPORT ComposerCounter : public CustomReturnFunction { public: ComposerCounter(); - virtual ~ComposerCounter(); + ~ComposerCounter() override; QString value( const Meta::TrackList &tracks ) const override; }; class AMAROK_EXPORT AlbumCounter : public CustomReturnFunction { public: AlbumCounter(); - virtual ~AlbumCounter(); + ~AlbumCounter() override; QString value( const Meta::TrackList &tracks ) const override; }; class AMAROK_EXPORT YearCounter : public CustomReturnFunction { public: YearCounter(); - virtual ~YearCounter(); + ~YearCounter() override; QString value( const Meta::TrackList &tracks ) const override; }; class AMAROK_EXPORT CustomReturnValue { public: CustomReturnValue(); virtual ~CustomReturnValue(); virtual QString value( const Meta::TrackPtr &track ) const = 0; }; class AMAROK_EXPORT TitleReturnValue : public CustomReturnValue { public: TitleReturnValue(); - virtual ~TitleReturnValue(); + ~TitleReturnValue() override; QString value( const Meta::TrackPtr &track ) const override; }; class AMAROK_EXPORT UrlReturnValue : public CustomReturnValue { public: UrlReturnValue(); - virtual ~UrlReturnValue(); + ~UrlReturnValue() override; QString value( const Meta::TrackPtr &track ) const override; }; #endif diff --git a/src/core-impl/collections/support/MemoryFilter.h b/src/core-impl/collections/support/MemoryFilter.h index 177c92fc6d..fe38ad46b7 100644 --- a/src/core-impl/collections/support/MemoryFilter.h +++ b/src/core-impl/collections/support/MemoryFilter.h @@ -1,124 +1,124 @@ /**************************************************************************************** * Copyright (c) 2008 Maximilian Kossick * * * * 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 MEMORYFILTER_H #define MEMORYFILTER_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "core/collections/QueryMaker.h" #include #include #include class MemoryFilter; namespace FilterFactory { MemoryFilter* filter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ); MemoryFilter* numberFilter( qint64 value, qint64 filter, Collections::QueryMaker::NumberComparison compare ); } class AMAROK_EXPORT MemoryFilter { public: MemoryFilter(); virtual ~MemoryFilter(); virtual bool filterMatches( const Meta::TrackPtr &track ) const = 0; }; class AMAROK_EXPORT ContainerMemoryFilter : public MemoryFilter { public: ContainerMemoryFilter(); - virtual ~ContainerMemoryFilter(); + ~ContainerMemoryFilter() override; void addFilter( MemoryFilter *filter ); protected: QList m_filters; }; class AMAROK_EXPORT AndContainerMemoryFilter : public ContainerMemoryFilter { public: AndContainerMemoryFilter(); - virtual ~AndContainerMemoryFilter(); + ~AndContainerMemoryFilter() override; bool filterMatches( const Meta::TrackPtr &track ) const override; }; class AMAROK_EXPORT OrContainerMemoryFilter : public ContainerMemoryFilter { public: OrContainerMemoryFilter(); - virtual ~OrContainerMemoryFilter(); + ~OrContainerMemoryFilter() override; bool filterMatches( const Meta::TrackPtr &track ) const override; }; class AMAROK_EXPORT NegateMemoryFilter : public MemoryFilter { public: explicit NegateMemoryFilter( MemoryFilter *filter ); - virtual ~NegateMemoryFilter(); + ~NegateMemoryFilter() override; bool filterMatches( const Meta::TrackPtr &track ) const override; private: MemoryFilter *m_filter; }; class AMAROK_EXPORT StringMemoryFilter : public MemoryFilter { public: StringMemoryFilter(); - virtual ~StringMemoryFilter(); + ~StringMemoryFilter() override; bool filterMatches( const Meta::TrackPtr &track ) const override; void setFilter( const QString &filter, bool matchBegin, bool matchEnd ); protected: virtual QString value( const Meta::TrackPtr &track ) const = 0; private: QString m_filter; bool m_matchBegin; bool m_matchEnd; }; class AMAROK_EXPORT NumberMemoryFilter : public MemoryFilter { public: NumberMemoryFilter(); ~NumberMemoryFilter() override; void setFilter( qint64 filter, Collections::QueryMaker::NumberComparison compare ); bool filterMatches( const Meta::TrackPtr &track ) const override; protected: virtual qint64 value( const Meta::TrackPtr &track ) const = 0; private: qint64 m_filter; Collections::QueryMaker::NumberComparison m_compare; }; class AMAROK_EXPORT LabelFilter : public MemoryFilter { public: LabelFilter( const QString &filter, bool matchBegin, bool matchEnd ); ~ LabelFilter() override; bool filterMatches( const Meta::TrackPtr &track ) const override; private: QRegExp m_expression; }; #endif diff --git a/src/core-impl/collections/support/MemoryMeta.h b/src/core-impl/collections/support/MemoryMeta.h index 9eca9283b6..7ff18b84ba 100644 --- a/src/core-impl/collections/support/MemoryMeta.h +++ b/src/core-impl/collections/support/MemoryMeta.h @@ -1,357 +1,357 @@ /**************************************************************************************** * Copyright (c) 2011 Bart Cerneels * * * * 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 MEMORYMETA_H #define MEMORYMETA_H #include "amarok_export.h" #include "MemoryCollection.h" #include "core/meta/Meta.h" using namespace Collections; /** These classes can be used with a MemoryCollection to populate the meta-type maps */ namespace MemoryMeta { class Track; /** * Base class for all MemoryMeta:: entities that store a list of associated tracks: * Artist, Album, Composer, Genre, Year. * * All methods of this class are thread-safe. */ class Base { public: explicit Base( const QString &name ) : m_name( name ) {} virtual ~Base() {} // Meta::{Artist,Album,Composer,Genre,Year} methods: virtual QString name() const { return m_name; } virtual Meta::TrackList tracks(); // MemoryMeta::Base methods: void addTrack( Track *track ); void removeTrack( Track *track ); private: QString m_name; /* We cannot easily store AmarokSharedPointer to tracks, because it creates reference * counting cycle: MemoryMeta::Track::m_album -> MemoryMeta::Album::tracks() -> * MemoryMeta::Track. We therefore store plain pointers and rely on * MemoryMeta::Track to notify when it is destroyed. */ QList m_tracks; QReadWriteLock m_tracksLock; }; class Artist : public Meta::Artist, public Base { public: explicit Artist( const QString &name ) : MemoryMeta::Base( name ) {} QString name() const override { return MemoryMeta::Base::name(); } Meta::TrackList tracks() override { return MemoryMeta::Base::tracks(); } }; class Album : public Meta::Album, public Base { public: Album( const QString &name, const Meta::ArtistPtr &albumArtist ) : MemoryMeta::Base( name ) , m_albumArtist( albumArtist ) , m_isCompilation( false ) , m_canUpdateCompilation( false ) , m_canUpdateImage( false ) {} /** * Copy-like constructor for MapChanger */ explicit Album( const Meta::AlbumPtr &other ); /* Meta::MetaCapability virtual methods */ bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; /* Meta::Base virtual methods */ QString name() const override { return MemoryMeta::Base::name(); } /* Meta::Album virtual methods */ bool isCompilation() const override { return m_isCompilation; } bool canUpdateCompilation() const override { return m_canUpdateCompilation; } void setCompilation( bool isCompilation ) override; bool hasAlbumArtist() const override { return !m_albumArtist.isNull(); } Meta::ArtistPtr albumArtist() const override { return m_albumArtist; } Meta::TrackList tracks() override { return MemoryMeta::Base::tracks(); } bool hasImage( int /* size */ = 0 ) const override { return !m_image.isNull(); } QImage image( int size = 0 ) const override; bool canUpdateImage() const override { return m_canUpdateImage; } void setImage( const QImage &image ) override; void removeImage() override; /* MemoryMeta::Album methods: */ /** * Re-read isCompilation, canUpdateCompilation, image, canUpdateImage from all * underlying tracks. */ void updateCachedValues(); private: Meta::ArtistPtr m_albumArtist; bool m_isCompilation; bool m_canUpdateCompilation; QImage m_image; bool m_canUpdateImage; }; class Composer : public Meta::Composer, public Base { public: explicit Composer( const QString &name ) : MemoryMeta::Base( name ) {} QString name() const override { return MemoryMeta::Base::name(); } Meta::TrackList tracks() override { return MemoryMeta::Base::tracks(); } }; class Genre : public Meta::Genre, public Base { public: explicit Genre( const QString &name ) : MemoryMeta::Base( name ) {} QString name() const override { return MemoryMeta::Base::name(); } Meta::TrackList tracks() override { return MemoryMeta::Base::tracks(); } }; class Year : public Meta::Year, public Base { public: explicit Year( const QString &name ) : MemoryMeta::Base( name ) {} QString name() const override { return MemoryMeta::Base::name(); } Meta::TrackList tracks() override { return MemoryMeta::Base::tracks(); } }; class AMAROK_EXPORT Track : public Meta::Track { public: explicit Track( const Meta::TrackPtr &originalTrack ); - virtual ~Track(); + ~Track() override; /* Meta::MetaCapability methods */ bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return m_track->hasCapabilityInterface( type ); } Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ) override { return m_track->createCapabilityInterface( type ); } /* Meta::Base virtual methods */ QString name() const override { return m_track->name(); } /* Meta::Track virtual methods */ QUrl playableUrl() const override { return m_track->playableUrl(); } QString prettyUrl() const override { return m_track->prettyUrl(); } QString uidUrl() const override { return m_track->uidUrl(); } QString notPlayableReason() const override { return m_track->notPlayableReason(); } //these functions return the proxy track values Meta::AlbumPtr album() const override { return m_album; } Meta::ArtistPtr artist() const override { return m_artist; } Meta::ComposerPtr composer() const override { return m_composer; } Meta::GenrePtr genre() const override { return m_genre; } Meta::YearPtr year() const override { return m_year; } //TODO:implement labels Meta::LabelList labels() const override { return Meta::LabelList(); } qreal bpm() const override { return m_track->bpm(); } QString comment() const override { return m_track->comment(); } qint64 length() const override { return m_track->length(); } int filesize() const override { return m_track->filesize(); } int sampleRate() const override { return m_track->sampleRate(); } int bitrate() const override { return m_track->bitrate(); } QDateTime createDate() const override { return m_track->createDate(); } QDateTime modifyDate() const override { return m_track->modifyDate(); } int trackNumber() const override { return m_track->trackNumber(); } int discNumber() const override { return m_track->discNumber(); } qreal replayGain( Meta::ReplayGainTag mode ) const override { return m_track->replayGain( mode ); } QString type() const override { return m_track->type(); } void prepareToPlay() override { m_track->prepareToPlay(); } void finishedPlaying( double fraction ) override { m_track->finishedPlaying( fraction ); } bool inCollection() const override { return m_track->inCollection(); } Collections::Collection *collection() const override { return m_track->collection(); } QString cachedLyrics() const override { return m_track->cachedLyrics(); } void setCachedLyrics( const QString &lyrics ) override { m_track->setCachedLyrics( lyrics ); } //TODO: implement labels void addLabel( const QString &label ) override { Q_UNUSED( label ) } void addLabel( const Meta::LabelPtr &label ) override { Q_UNUSED( label ) } void removeLabel( const Meta::LabelPtr &label ) override { Q_UNUSED( label ) } Meta::TrackEditorPtr editor() override; Meta::StatisticsPtr statistics() override; // MemoryMeta::Track methods: /* All of these set* methods pass the pointer to AmarokSharedPointer (thus memory-manage it), * remove this track from previous {Album,Artist,Composer,Genre,Year} entity (if any) * and add this track to newly set entity. (if non-null) * All these methods are reentrant, but not thread-safe: caller must ensure that * only one of the following methods is called at a time on a single instance. */ void setAlbum( Album *album ); void setArtist( Artist *artist ); void setComposer( Composer *composer ); void setGenre( Genre *genre ); void setYear( Year *year ); /** * Return the original track this track proxies. */ Meta::TrackPtr originalTrack() const { return m_track; } /** * Make notifyObservers() public so that MapChanger can call this */ using Meta::Track::notifyObservers; private: Meta::TrackPtr m_track; Meta::AlbumPtr m_album; Meta::ArtistPtr m_artist; Meta::ComposerPtr m_composer; Meta::GenrePtr m_genre; Meta::YearPtr m_year; }; /** * Helper class that facilitates adding, removing and changing tracks that are in * MemoryCollection. This class locks underlying MemoryCollection upon construction for * writing and releases the lock in destructor. * * Typical usage: * { * MemoryMeta::MapChanger changer( memoryCollectionPtr ); * Meta::Track newTrack = changer.addTrack( trackPtr ); * ... * changer.removeTrack( newTrack ); * } * * All methods in this class are re-entrant and it operates on MemoryCollection in * a thread-safe way: you can run MapChangers from multiple threads on a single * MemoryCollection at once. (each thread constructing MapChanger when needed and deleting * it as soon as possible) * * All methods can be called multiple times on a single instance and can be combined. */ class AMAROK_EXPORT MapChanger { public: explicit MapChanger( MemoryCollection *memoryCollection ); ~MapChanger(); /** * Adds a track to MemoryCollection by proxying it using @see MemoryMeta::Track * track artist, album, genre, composer and year are replaced in MemoryMeta::Track * by relevant MemoryMeta entities, based on their value. Refuses to add a track * whose proxy is already in MemoryCollection (returns null pointer in this case) * * @return pointer to a newly created MemoryMeta::Track (may be null if not * successful) */ Meta::TrackPtr addTrack( Meta::TrackPtr track ); /** * Removes a track from MemoryCollection. Pays attention to remove artists, * albums, genres, composers and years that may become dangling in * MemoryCollection. * * @param track MemoryMeta track to remove, it doesn't matter if this is the track * returned by MapChanger::addTrack or the underlying one passed to * MapChanger::addTrack - the real track is looked up using its uidUrl in * MemoryCollection. * * @return shared pointer to underlying track of the deleted track, i.e. the track * that you passed to MapChanger::addTrack() originally. May be null pointer if * @param track is not found in collection or if it wasn't added using MapChanger. */ Meta::TrackPtr removeTrack( Meta::TrackPtr track ); /** * Reflects changes made to underlying track to its proxy track in * MemoryCollection and to MemoryCollection maps. * * The one who called MapChanger::addTrack() is responsible to call this method * every time it detects that some metadata of underlying track have changed * (perhaps by becoming its observer), even in minor fields such as comment. This * method instructs proxy track to call notifyObservers(). * * Please note that this method is currently unable to cope with changes * to track uidUrl(). If you really need it, change MemoryCollection's * trackMap manually _before_ calling this. * * @param track track whose metadata have changed, it doesn't matter if this is * the track returned by MapChanger::addTrack or the underlying one passed to * MapChanger::addTrack - the real track is looked up using its uidUrl in * MemoryCollection. Does nothing if @param track is not found in MemoryCollection. * * @return true if memory collection maps had to be changed, false for minor * changes where this is not required */ bool trackChanged( Meta::TrackPtr track ); private: /** * Worker for addTrack. * * @param track original underlying track - source of metadata * @param memoryTrack new track to add to MemoryCollection - target of metadata */ Meta::TrackPtr addExistingTrack( Meta::TrackPtr track, Track *memoryTrack ); /** * Return true if at least one of the tracks in @param needles is in * @param haystack, false otherwise. Comparison is done using track uidUrl. */ static bool hasTrackInMap( const Meta::TrackList &needles, const TrackMap &haystack ); /** * Return true if artist @param artist is referenced as albumArtist of one of the * albums from @param haystack. The match is done using Meta:ArtistPtr * operator==. */ static bool referencedAsAlbumArtist( const Meta::ArtistPtr &artist, const AlbumMap &haystack ); /** * Return true if @param first has different value than @param other. Specifically * returns true if one entity is null and the other non-null, but returns true if * both are null. */ static bool entitiesDiffer( const Meta::Base *first, const Meta::Base *second ); /** * Overload for albums, we compare album artist, isCollection and image too */ static bool entitiesDiffer( const Meta::Album *first, const Meta::Album *second ); MemoryCollection *m_mc; }; } #endif diff --git a/src/core-impl/collections/support/MemoryQueryMaker.cpp b/src/core-impl/collections/support/MemoryQueryMaker.cpp index 3a54499a6f..bb67822fce 100644 --- a/src/core-impl/collections/support/MemoryQueryMaker.cpp +++ b/src/core-impl/collections/support/MemoryQueryMaker.cpp @@ -1,519 +1,519 @@ /**************************************************************************************** * Copyright (c) 2007-2009 Maximilian Kossick * * Copyright (c) 2007-2009 Nikolaj Hald Nielsen * * * * 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 . * ****************************************************************************************/ #include "MemoryQueryMaker.h" #include "MemoryCustomValue.h" #include "MemoryFilter.h" #include "MemoryMatcher.h" #include "MemoryQueryMakerHelper.h" #include "MemoryQueryMakerInternal.h" #include "core/support/Debug.h" #include #include #include #include #include #include #include using namespace Collections; //QueryJob class QueryJob : public QObject, public ThreadWeaver::Job { Q_OBJECT public: QueryJob( MemoryQueryMakerInternal *qmInternal ) : QObject() , ThreadWeaver::Job() , queryMakerInternal( qmInternal ) { //nothing to do } - ~QueryJob() + ~QueryJob() override { delete queryMakerInternal; } protected: void defaultBegin(const ThreadWeaver::JobPointer& self, ThreadWeaver::Thread *thread) override { Q_EMIT started(self); ThreadWeaver::Job::defaultBegin(self, thread); } void defaultEnd(const ThreadWeaver::JobPointer& self, ThreadWeaver::Thread *thread) override { ThreadWeaver::Job::defaultEnd(self, thread); if (!self->success()) { Q_EMIT failed(self); } Q_EMIT done(self); } void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread=0) override { Q_UNUSED(self); Q_UNUSED(thread); queryMakerInternal->runQuery(); // setFinished( true ); setStatus(Status_Success); } public: MemoryQueryMakerInternal *queryMakerInternal; Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); }; struct MemoryQueryMaker::Private { QueryMaker::QueryType type; bool returnDataPtrs; MemoryMatcher* matcher; QueryJob *job; int maxsize; QStack containerFilters; QList returnFunctions; QList returnValues; bool usingFilters; KRandomSequence sequence; //do not reset qint64 orderByField; bool orderDescending; bool orderByNumberField; AlbumQueryMode albumQueryMode; LabelQueryMode labelQueryMode; QString collectionId; }; MemoryQueryMaker::MemoryQueryMaker( const QWeakPointer &mc, const QString &collectionId ) : QueryMaker() , m_collection( mc ) , d( new Private ) { d->collectionId = collectionId; d->matcher = 0; d->job = 0; d->type = QueryMaker::None; d->returnDataPtrs = false; d->job = 0; d->job = 0; d->maxsize = -1; d->containerFilters.push( new AndContainerMemoryFilter() ); d->usingFilters = false; d->orderByField = 0; d->orderDescending = false; d->orderByNumberField = false; d->albumQueryMode = AllAlbums; d->labelQueryMode = QueryMaker::NoConstraint; } MemoryQueryMaker::~MemoryQueryMaker() { disconnect(); abortQuery(); if( !d->containerFilters.isEmpty() ) delete d->containerFilters.first(); delete d; } void MemoryQueryMaker::run() { if ( d->type == QueryMaker::None ) //TODO error handling return; else if( d->job && !d->job->isFinished() ) { //the worker thread seems to be running //TODO: wait or job to complete } else { MemoryQueryMakerInternal *qmi = new MemoryQueryMakerInternal( m_collection ); if( d->usingFilters ) { qmi->setFilters( d->containerFilters.first() ); d->containerFilters.clear(); //will be deleted by MemoryQueryMakerInternal } qmi->setMatchers( d->matcher ); d->matcher = 0; //will be deleted by MemoryQueryMakerInternal qmi->setMaxSize( d->maxsize ); qmi->setType( d->type ); qmi->setCustomReturnFunctions( d->returnFunctions ); d->returnFunctions.clear(); //will be deleted by MemoryQueryMakerInternal qmi->setCustomReturnValues( d->returnValues ); d->returnValues.clear(); //will be deleted by MemoryQueryMakerInternal qmi->setAlbumQueryMode( d->albumQueryMode ); qmi->setLabelQueryMode( d->labelQueryMode ); qmi->setOrderDescending( d->orderDescending ); qmi->setOrderByNumberField( d->orderByNumberField ); qmi->setOrderByField( d->orderByField ); qmi->setCollectionId( d->collectionId ); connect( qmi, &Collections::MemoryQueryMakerInternal::newAlbumsReady, this, &MemoryQueryMaker::newAlbumsReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newArtistsReady, this, &MemoryQueryMaker::newArtistsReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newGenresReady, this, &MemoryQueryMaker::newGenresReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newComposersReady, this, &MemoryQueryMaker::newComposersReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newYearsReady, this, &MemoryQueryMaker::newYearsReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newTracksReady, this, &MemoryQueryMaker::newTracksReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newResultReady, this, &MemoryQueryMaker::newResultReady, Qt::DirectConnection ); connect( qmi, &Collections::MemoryQueryMakerInternal::newLabelsReady, this, &MemoryQueryMaker::newLabelsReady, Qt::DirectConnection ); d->job = new QueryJob( qmi ); connect( d->job, &QueryJob::done, this, &MemoryQueryMaker::done ); ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(d->job) ); } } void MemoryQueryMaker::abortQuery() { if( d->job ) { d->job->requestAbort(); d->job->disconnect( this ); if( d->job->queryMakerInternal ) d->job->queryMakerInternal->disconnect( this ); } } QueryMaker* MemoryQueryMaker::setQueryType( QueryType type ) { switch( type ) { case QueryMaker::Track: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Track; return this; case QueryMaker::Artist: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Artist; return this; case QueryMaker::Album: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Album; return this; case QueryMaker::AlbumArtist: if ( d->type == QueryMaker::None ) d->type = QueryMaker::AlbumArtist; return this; case QueryMaker::Composer: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Composer; return this; case QueryMaker::Genre: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Genre; return this; case QueryMaker::Year: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Year; return this; case QueryMaker::Custom: if ( d->type == QueryMaker::None ) d->type = QueryMaker::Custom; return this; case QueryMaker::Label: if( d->type == QueryMaker::None ) d->type = QueryMaker::Label; return this; case QueryMaker::None: return this; } return this; } QueryMaker* MemoryQueryMaker::addReturnValue( qint64 value ) { //MQM can not deliver sensible results if both a custom return value and a return function is selected if( d->returnFunctions.empty() ) { CustomReturnValue *returnValue = CustomValueFactory::returnValue( value ); if( returnValue ) d->returnValues.append( returnValue ); } return this; } QueryMaker* MemoryQueryMaker::addReturnFunction( ReturnFunction function, qint64 value ) { //MQM can not deliver sensible results if both a custom return value and a return function is selected if( d->returnValues.empty() ) { CustomReturnFunction *returnFunction = CustomValueFactory::returnFunction( function, value ); if( returnFunction ) d->returnFunctions.append( returnFunction ); } return this; } QueryMaker* MemoryQueryMaker::orderBy( qint64 value, bool descending ) { d->orderByField = value; d->orderDescending = descending; switch( value ) { case Meta::valYear: case Meta::valDiscNr: case Meta::valTrackNr: case Meta::valScore: case Meta::valRating: case Meta::valPlaycount: case Meta::valFilesize: case Meta::valSamplerate: case Meta::valBitrate: case Meta::valLength: { d->orderByNumberField = true; break; } //TODO: what about Meta::valFirstPlayed, Meta::valCreateDate or Meta::valLastPlayed?? default: d->orderByNumberField = false; } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::TrackPtr &track ) { MemoryMatcher *trackMatcher = new TrackMatcher( track ); if ( d->matcher == 0 ) d->matcher = trackMatcher; else { MemoryMatcher *tmp = d->matcher; while ( !tmp->isLast() ) tmp = tmp->next(); tmp->setNext( trackMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour ) { MemoryMatcher *artistMatcher = new ArtistMatcher( artist, behaviour ); if ( d->matcher == 0 ) d->matcher = artistMatcher; else { MemoryMatcher *tmp = d->matcher; while ( !tmp->isLast() ) tmp = tmp->next(); tmp->setNext( artistMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::AlbumPtr &album ) { MemoryMatcher *albumMatcher = new AlbumMatcher( album ); if ( d->matcher == 0 ) d->matcher = albumMatcher; else { MemoryMatcher *tmp = d->matcher; while ( !tmp->isLast() ) tmp = tmp->next(); tmp->setNext( albumMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::GenrePtr &genre ) { MemoryMatcher *genreMatcher = new GenreMatcher( genre ); if ( d->matcher == 0 ) d->matcher = genreMatcher; else { MemoryMatcher *tmp = d->matcher; while ( !tmp->isLast() ) tmp = tmp->next(); tmp->setNext( genreMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::ComposerPtr &composer ) { MemoryMatcher *composerMatcher = new ComposerMatcher( composer ); if ( d->matcher == 0 ) d->matcher = composerMatcher; else { MemoryMatcher *tmp = d->matcher; while ( !tmp->isLast() ) tmp = tmp->next(); tmp->setNext( composerMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::YearPtr &year ) { MemoryMatcher *yearMatcher = new YearMatcher( year ); if ( d->matcher == 0 ) d->matcher = yearMatcher; else { MemoryMatcher *tmp = d->matcher; while ( !tmp->isLast() ) tmp = tmp->next(); tmp->setNext( yearMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addMatch( const Meta::LabelPtr &label ) { MemoryMatcher *labelMatcher = new LabelMatcher( label ); if( d->matcher == 0 ) { d->matcher = labelMatcher; } else { MemoryMatcher *tmp = d->matcher; while( !tmp->isLast() ) { tmp = tmp->next(); } tmp->setNext( labelMatcher ); } return this; } QueryMaker* MemoryQueryMaker::addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) { d->containerFilters.top()->addFilter( FilterFactory::filter( value, filter, matchBegin, matchEnd ) ); d->usingFilters = true; return this; } QueryMaker* MemoryQueryMaker::excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) { MemoryFilter *tmp = FilterFactory::filter( value, filter, matchBegin, matchEnd ); d->containerFilters.top()->addFilter( new NegateMemoryFilter( tmp ) ); d->usingFilters = true; return this; } QueryMaker* MemoryQueryMaker::addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) { d->containerFilters.top()->addFilter( FilterFactory::numberFilter( value, filter, compare ) ); d->usingFilters = true; return this; } QueryMaker* MemoryQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) { MemoryFilter *tmp = FilterFactory::numberFilter( value, filter, compare ); d->containerFilters.top()->addFilter( new NegateMemoryFilter( tmp ) ); d->usingFilters = true; return this; } QueryMaker* MemoryQueryMaker::limitMaxResultSize( int size ) { d->maxsize = size; return this; } QueryMaker* MemoryQueryMaker::beginAnd() { ContainerMemoryFilter *filter = new AndContainerMemoryFilter(); d->containerFilters.top()->addFilter( filter ); d->containerFilters.push( filter ); return this; } QueryMaker* MemoryQueryMaker::beginOr() { ContainerMemoryFilter *filter = new OrContainerMemoryFilter(); d->containerFilters.top()->addFilter( filter ); d->containerFilters.push( filter ); return this; } QueryMaker* MemoryQueryMaker::endAndOr() { d->containerFilters.pop(); return this; } void MemoryQueryMaker::done( ThreadWeaver::JobPointer job ) { ThreadWeaver::Queue::instance()->dequeue( job ); d->job = 0; Q_EMIT queryDone(); } QueryMaker * MemoryQueryMaker::setAlbumQueryMode( AlbumQueryMode mode ) { d->albumQueryMode = mode; return this; } QueryMaker* MemoryQueryMaker::setLabelQueryMode( LabelQueryMode mode ) { d->labelQueryMode = mode; return this; } #include "MemoryQueryMaker.moc" diff --git a/src/core-impl/collections/support/MemoryQueryMaker.h b/src/core-impl/collections/support/MemoryQueryMaker.h index 1229ebbd6e..5044db79f7 100644 --- a/src/core-impl/collections/support/MemoryQueryMaker.h +++ b/src/core-impl/collections/support/MemoryQueryMaker.h @@ -1,94 +1,94 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 MEMORYQUERYMAKER_H #define MEMORYQUERYMAKER_H #include "amarok_export.h" #include "MemoryCollection.h" #include "core/collections/QueryMaker.h" #include #include namespace ThreadWeaver { class Job; } namespace Collections { class AMAROK_EXPORT MemoryQueryMaker : public QueryMaker { Q_OBJECT public: /** * Creates a new MemoryQueryMaker that will query a memory collection. * This class implements the QueryMaker interface and can be used as a generic * query maker for all collections that use MemoryCollection. * @param mc the MemoryCollection instance that the query should be run on. * @param collectionId the collectionid that has to be emitted by this querymaker. */ MemoryQueryMaker( const QWeakPointer &mc, const QString &collectionId ); - virtual ~MemoryQueryMaker(); + ~MemoryQueryMaker() override; void run() override; void abortQuery() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addReturnValue( qint64 value ) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy( qint64 value, bool descending = false ) override; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::YearPtr &year ) override; QueryMaker* addMatch( const Meta::LabelPtr &label ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; QueryMaker* limitMaxResultSize( int size ) override; QueryMaker* beginAnd() override; QueryMaker* beginOr() override; QueryMaker* endAndOr() override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override; private Q_SLOTS: void done( ThreadWeaver::JobPointer job ); protected: QWeakPointer m_collection; struct Private; Private * const d; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/support/MemoryQueryMakerInternal.h b/src/core-impl/collections/support/MemoryQueryMakerInternal.h index a08a6733a3..11130838ee 100644 --- a/src/core-impl/collections/support/MemoryQueryMakerInternal.h +++ b/src/core-impl/collections/support/MemoryQueryMakerInternal.h @@ -1,104 +1,104 @@ /**************************************************************************************** * Copyright (c) 2010 Maximilian Kossick * * * * 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 MEMORYQUERYMAKERINTERNAL_H #define MEMORYQUERYMAKERINTERNAL_H #include "core/collections/QueryMaker.h" #include "core/meta/forward_declarations.h" #include #include class CustomReturnFunction; class CustomReturnValue; class MemoryFilter; class MemoryMatcher; namespace Collections { class MemoryCollection; /** * A helper class for MemoryQueryMaker * This class will run in a dedicated thread. It exists so the actual MemoryQueryMaker * can be safely deleted in the original thread while the query is still running. * All relevant information is passed from MemoryQueryMaker to MemoryQueryMakerInternal * using the provided setter methods. */ class MemoryQueryMakerInternal : public QObject { Q_OBJECT public: /** * Creates a new MemoryQueryMakerInternal that will query collection. * This class will run in a dedicated thread. It exists so the actual MemoryQueryMaker * can be safely deleted in the original thread while the query is still running. * @param collection the MemoryCollection instance that the query should be run on. */ explicit MemoryQueryMakerInternal( const QWeakPointer &collection ); - ~MemoryQueryMakerInternal(); + ~MemoryQueryMakerInternal() override; void runQuery(); void handleResult(); void handleResult( const Meta::TrackList &tracks ); void setMatchers( MemoryMatcher *matchers ); void setFilters( MemoryFilter *filters ); void setMaxSize( int maxSize ); void setReturnAsDataPtrs( bool returnAsDataPtrs ); void setType( QueryMaker::QueryType ); void setCustomReturnFunctions( const QList &functions ); void setCustomReturnValues( const QList &values ); void setAlbumQueryMode( Collections::QueryMaker::AlbumQueryMode mode ) { m_albumQueryMode = mode; } void setOrderDescending( bool orderDescending ) { m_orderDescending = orderDescending; } void setOrderByNumberField( bool orderByNumberField ) { m_orderByNumberField = orderByNumberField; } void setOrderByField( qint64 orderByField ) { m_orderByField = orderByField; } void setCollectionId( const QString &collectionId ) { m_collectionId = collectionId; } void setLabelQueryMode( Collections::QueryMaker::LabelQueryMode mode ) { m_labelQueryMode = mode; } Q_SIGNALS: void newTracksReady( Meta::TrackList ); void newArtistsReady( Meta::ArtistList ); void newAlbumsReady( Meta::AlbumList ); void newGenresReady( Meta::GenreList ); void newComposersReady( Meta::ComposerList ); void newYearsReady( Meta::YearList ); void newResultReady( QStringList ); void newLabelsReady( Meta::LabelList ); void newDataReady( Meta::DataList ); private: QWeakPointer m_collection; MemoryMatcher *m_matchers; MemoryFilter *m_filters; int m_maxSize; bool m_returnAsDataPtrs; Collections::QueryMaker::QueryType m_type; Collections::QueryMaker::AlbumQueryMode m_albumQueryMode; Collections::QueryMaker::LabelQueryMode m_labelQueryMode; bool m_orderDescending; bool m_orderByNumberField; qint64 m_orderByField; QString m_collectionId; QList m_returnFunctions; QList m_returnValues; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/support/TrashCollectionLocation.h b/src/core-impl/collections/support/TrashCollectionLocation.h index 9dbf41a877..2e11705806 100644 --- a/src/core-impl/collections/support/TrashCollectionLocation.h +++ b/src/core-impl/collections/support/TrashCollectionLocation.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2010 Rick W. Chen * * * * 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 TRASHCOLLECTIONLOCATION_H #define TRASHCOLLECTIONLOCATION_H #include "core/collections/CollectionLocation.h" #include class KJob; namespace Collections { /** * Utility class that allows moving tracks to the KIO trash using standard * CollectionLocation API. It is not intended to be a collection, but more * as a black hole destination. */ class TrashCollectionLocation : public CollectionLocation { Q_OBJECT public: TrashCollectionLocation(); - ~TrashCollectionLocation(); + ~TrashCollectionLocation() override; QString prettyLocation() const override; bool isWritable() const override; protected: void copyUrlsToCollection( const QMap &sources, const Transcoding::Configuration &configuration ) override; void showDestinationDialog( const Meta::TrackList &tracks, bool removeSources, const Transcoding::Configuration &configuration ) override; private Q_SLOTS: void slotTrashJobFinished( KJob *job ); private: bool m_trashConfirmed; QHash m_trashJobs; }; } //namespace Collections #endif // TRASHCOLLECTIONLOCATION_H diff --git a/src/core-impl/collections/umscollection/UmsCollection.h b/src/core-impl/collections/umscollection/UmsCollection.h index 3cfdac7f6b..0cb95a0927 100644 --- a/src/core-impl/collections/umscollection/UmsCollection.h +++ b/src/core-impl/collections/umscollection/UmsCollection.h @@ -1,244 +1,244 @@ /**************************************************************************************** * Copyright (c) 2009 Alejandro Wainzinger * * * * 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 UMSCOLLECTION_H #define UMSCOLLECTION_H #include "collectionscanner/Directory.h" #include "core/collections/Collection.h" #include "core/meta/Observer.h" #include "core-impl/collections/support/MemoryCollection.h" #include #include #include #include #include #include class GenericScanManager; class UmsPodcastProvider; class UmsCollection; class QAction; using namespace Collections; class UmsCollectionFactory : public CollectionFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-umscollection.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: UmsCollectionFactory(); - virtual ~UmsCollectionFactory(); + ~UmsCollectionFactory() override; void init() override; private Q_SLOTS: /** * Called when solid notifier detects a new device has been added */ void slotAddSolidDevice( const QString &udi ); /** * Called when solid StorageAccess device we are interested in is mounted or * unmounted */ void slotAccessibilityChanged( bool accessible, const QString &udi ); /** * Called when solid notifier detects a device has been removed */ void slotRemoveSolidDevice( const QString &udi ); /** * Like @see slotRemoveSolidDevice(), but instructs Collection to eject the * device after it has performed necessary teardown operations. * * Called when user wants to unmount the device from for example Device Notifier */ void slotRemoveAndTeardownSolidDevice( const QString &udi ); /** * Called when "tracked" collection is destroyed */ void slotCollectionDestroyed( QObject *collection ); private: /** * Checks whether a solid device is a USB mass-storage one */ bool identifySolidDevice( const QString &udi ) const; /** * Attempts to create appropriate collection for already identified solid device * @param udi. Should Q_EMIT newCollection() if the collection was successfully * created and should become visible to the user. */ void createCollectionForSolidDevice( const QString &udi ); // maps device udi to active UMS collections QMap m_collectionMap; }; class UmsCollection : public Collection, public Meta::Observer { Q_OBJECT public: // inherited methods explicit UmsCollection( const Solid::Device &device ); - virtual ~UmsCollection(); + ~UmsCollection() override; /* TrackProvider methods */ bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; /* Collection methods */ QueryMaker *queryMaker() override; QString uidUrlProtocol() const override; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override; bool hasCapacity() const override; float usedCapacity() const override; float totalCapacity() const override; CollectionLocation *location() override; bool isOrganizable() const override; /* Capability-related methods */ bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ) override; /* Meta::Observer methods */ void metadataChanged( const Meta::TrackPtr &track ) override; using Meta::Observer::metadataChanged; // silence compiler warning about hidder overloads /* own methods */ const QUrl &musicUrl() const { return m_musicUrl; } const QUrl &podcastUrl() const { return m_podcastUrl; } /** * Get location where track @param track should be transferred to. * * @param fileExtension new extension to use. Leave empty if you don't wish to * change file extension */ QUrl organizedUrl( const Meta::TrackPtr &track, const QString &fileExtension = QString() ) const; QSharedPointer memoryCollection() const { return m_mc; } Q_SIGNALS: /** * Start a count-down that emits updated() signal after it expires. * Resets the timer to original timeout if already running. This is to ensure * that we Q_EMIT update() max. once per \ for batch updates. * * Timers can only be started from "their" thread so use signals & slots for that. */ void startUpdateTimer(); public Q_SLOTS: /** * Destroy the collection (by emitting remove) */ void slotDestroy(); /** * Destroy the collection and try to eject the device from system */ void slotEject(); void slotTrackAdded( const QUrl &trackLocation ); void slotTrackRemoved( const Meta::TrackPtr &track ); private Q_SLOTS: /** * Update m_lastUpdated timestamp and Q_EMIT updated() */ void collectionUpdated(); void slotParseTracks(); void slotParseActionTriggered(); void slotConfigure(); void slotDirectoryScanned( QSharedPointer dir ); /** * Starts a timer that ensures we Q_EMIT updated() signal sometime in future. */ void slotStartUpdateTimer(); private: /** extended constructor */ void init(); //static variables relating to the on-disk configuration file static QString s_settingsFileName; static QString s_musicFolderKey; static QString s_musicFilenameSchemeKey; static QString s_vfatSafeKey; static QString s_asciiOnlyKey; static QString s_postfixTheKey; static QString s_replaceSpacesKey; static QString s_regexTextKey; static QString s_replaceTextKey; static QString s_podcastFolderKey; static QString s_autoConnectKey; static QString s_collectionName; static QString s_transcodingGroup; Solid::Device m_device; QSharedPointer m_mc; bool m_tracksParsed; bool m_autoConnect; QString m_mountPoint; QUrl m_musicUrl; QUrl m_podcastUrl; QString m_musicFilenameScheme; bool m_vfatSafe; bool m_asciiOnly; bool m_postfixThe; bool m_replaceSpaces; QString m_regexText; QString m_replaceText; QString m_collectionName; QString m_collectionId; GenericScanManager *m_scanManager; KDirWatch m_watcher; QStringList m_supportedMimeTypes; UmsPodcastProvider *m_podcastProvider; QAction *m_parseAction; QAction *m_configureAction; QAction *m_ejectAction; QTimer m_updateTimer; qint64 m_lastUpdated; /* msecs since epoch */ }; #endif diff --git a/src/core-impl/collections/umscollection/UmsCollectionLocation.h b/src/core-impl/collections/umscollection/UmsCollectionLocation.h index df65a0b667..2f3c7e79ac 100644 --- a/src/core-impl/collections/umscollection/UmsCollectionLocation.h +++ b/src/core-impl/collections/umscollection/UmsCollectionLocation.h @@ -1,97 +1,97 @@ /**************************************************************************************** * Copyright (c) 2011 Bart Cerneels * * * * 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 UMSCOLLECTIONLOCATION_H #define UMSCOLLECTIONLOCATION_H #include "core/collections/CollectionLocation.h" #include "UmsCollection.h" #include #include #include #include class UmsTransferJob; class UmsCollectionLocation : public Collections::CollectionLocation { Q_OBJECT public: explicit UmsCollectionLocation( UmsCollection *umsCollection ); - ~UmsCollectionLocation(); + ~UmsCollectionLocation() override; /* CollectionLocation methods */ QString prettyLocation() const override; QStringList actualLocation() const override; bool isWritable() const override; bool isOrganizable() const override; void copyUrlsToCollection( const QMap &sources, const Transcoding::Configuration &configuration ) override; void removeUrlsFromCollection( const Meta::TrackList &sources ) override; protected Q_SLOTS: void slotRemoveOperationFinished(); // hides intentionally parent methods private Q_SLOTS: /** * Needed for removal of source tracks during move operation */ void slotTrackTransferred( const QUrl &sourceTrackUrl ); private: UmsCollection *m_umsCollection; QHash m_sourceUrlToTrackMap; }; class UmsTransferJob : public KCompositeJob { Q_OBJECT public: UmsTransferJob( UmsCollectionLocation *location, const Transcoding::Configuration &configuration ); void addCopy( const QUrl &from, const QUrl &to ); void addTranscode( const QUrl &from, const QUrl &to ); void start() override; Q_SIGNALS: void sourceFileTransferDone( const QUrl &source ); void fileTransferDone( const QUrl &destination ); public Q_SLOTS: void slotCancel(); private Q_SLOTS: void startNextJob(); void slotChildJobPercent( KJob *job, unsigned long percentage ); //reimplemented from KCompositeJob void slotResult( KJob *job ) override; private: UmsCollectionLocation *m_location; Transcoding::Configuration m_transcodingConfiguration; bool m_abort; typedef QPair KUrlPair; QList m_copyList; QList m_transcodeList; int m_totalTracks; // total number of tracks in whole transfer }; #endif // UMSCOLLECTIONLOCATION_H diff --git a/src/core-impl/collections/umscollection/UmsTranscodeCapability.h b/src/core-impl/collections/umscollection/UmsTranscodeCapability.h index f61b7cf9a4..9097bb36b0 100644 --- a/src/core-impl/collections/umscollection/UmsTranscodeCapability.h +++ b/src/core-impl/collections/umscollection/UmsTranscodeCapability.h @@ -1,41 +1,41 @@ /**************************************************************************************** * 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 UMSTRANSCODECAPABILITY_H #define UMSTRANSCODECAPABILITY_H #include "core/capabilities/TranscodeCapability.h" class UmsTranscodeCapability : public Capabilities::TranscodeCapability { Q_OBJECT public: UmsTranscodeCapability( const QString &configFilePath, const QString &groupName ); - virtual ~UmsTranscodeCapability(); + ~UmsTranscodeCapability() override; Transcoding::Configuration savedConfiguration() override; void setSavedConfiguration(const Transcoding::Configuration& configuration) override; private: Q_DISABLE_COPY( UmsTranscodeCapability ) QString m_configFilePath; QString m_groupName; }; #endif // UMSTRANSCODECAPABILITY_H diff --git a/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h b/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h index e77251e467..2ecb3813b0 100644 --- a/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h +++ b/src/core-impl/collections/umscollection/podcasts/UmsPodcastMeta.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2010 Bart Cerneels * * * * 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 UMSPODCASTMETA_H #define UMSPODCASTMETA_H #include "core-impl/playlists/types/file/PlaylistFile.h" #include "core/podcasts/PodcastMeta.h" #include "core-impl/meta/file/File.h" class QUrl; namespace Podcasts { class UmsPodcastEpisode; class UmsPodcastChannel; class UmsPodcastProvider; typedef AmarokSharedPointer UmsPodcastEpisodePtr; typedef AmarokSharedPointer UmsPodcastChannelPtr; typedef QList UmsPodcastEpisodeList; typedef QList UmsPodcastChannelList; class UmsPodcastEpisode : public Podcasts::PodcastEpisode { friend class UmsPodcastProvider; public: static UmsPodcastEpisodePtr fromPodcastEpisodePtr( const Podcasts::PodcastEpisodePtr &episode ); static UmsPodcastEpisodePtr fromTrackPtr( const Meta::TrackPtr &track ); static Podcasts::PodcastEpisodePtr toPodcastEpisodePtr( const UmsPodcastEpisodePtr &episode ); static Podcasts::PodcastEpisodeList toPodcastEpisodeList( UmsPodcastEpisodeList episodes ); explicit UmsPodcastEpisode( const UmsPodcastChannelPtr &channel ); - ~UmsPodcastEpisode(); + ~UmsPodcastEpisode() override; void setLocalFile( const MetaFile::TrackPtr &localFile ); //PodcastEpisode methods QString title() const override; void setLocalUrl( const QUrl &localUrl ) override; //Track Methods QString name() const override { return title(); } QUrl playableUrl() const override; QString notPlayableReason() const override; QString prettyName() const override { return name(); } void setTitle( const QString &title ) override; QDateTime createDate() const override; Meta::AlbumPtr album() const override; Meta::ArtistPtr artist() const override; Meta::ComposerPtr composer() const override; Meta::GenrePtr genre() const override; Meta::YearPtr year() const override; private: MetaFile::TrackPtr m_localFile; UmsPodcastChannelPtr m_umsChannel; }; class UmsPodcastChannel : public Podcasts::PodcastChannel { friend class UmsPodcastProvider; public: static UmsPodcastChannelPtr fromPodcastChannelPtr( const Podcasts::PodcastChannelPtr &channel ); static Podcasts::PodcastChannelPtr toPodcastChannelPtr( const UmsPodcastChannelPtr &channel ); static Podcasts::PodcastChannelList toPodcastChannelList( UmsPodcastChannelList umsChannels ); explicit UmsPodcastChannel( UmsPodcastProvider *provider ); UmsPodcastChannel( Podcasts::PodcastChannelPtr channel, UmsPodcastProvider *provider ); ~UmsPodcastChannel() override; Podcasts::PodcastEpisodePtr addEpisode( const Podcasts::PodcastEpisodePtr &episode ) override; UmsPodcastEpisodeList umsEpisodes() { return m_umsEpisodes; } void addUmsEpisode( UmsPodcastEpisodePtr episode ); void setPlaylistFileSource( const QUrl &playlistFilePath ); QUrl playlistFilePath() const { return m_playlistFilePath; } Podcasts::PodcastEpisodeList episodes() const override { return UmsPodcastEpisode::toPodcastEpisodeList( m_umsEpisodes ); } Playlists::PlaylistProvider *provider() const override; protected: void removeEpisode( const UmsPodcastEpisodePtr &episode ); private: UmsPodcastProvider *m_provider; QUrl m_playlistFilePath; Playlists::PlaylistFilePtr m_playlistFile; //used to keep track of episodes. UmsPodcastEpisodeList m_umsEpisodes; }; } //namespace Podcasts Q_DECLARE_METATYPE( Podcasts::UmsPodcastEpisodePtr ) Q_DECLARE_METATYPE( Podcasts::UmsPodcastEpisodeList ) Q_DECLARE_METATYPE( Podcasts::UmsPodcastChannelPtr ) Q_DECLARE_METATYPE( Podcasts::UmsPodcastChannelList ) #endif // UMSPODCASTMETA_H diff --git a/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h b/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h index ae8047735b..7c6ac1ce46 100644 --- a/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h +++ b/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.h @@ -1,119 +1,119 @@ /**************************************************************************************** * Copyright (c) 2010 Nikhil Marathe * * * * 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 UPNPBROWSECOLLECTION_H #define UPNPBROWSECOLLECTION_H #include "UpnpCollectionBase.h" #include "MemoryCollection.h" #include "core/capabilities/CollectionScanCapability.h" #include #include #include #include #include #include #include #include #include #include namespace KIO { class Job; } class KJob; class QTimer; namespace Collections { class UpnpCache; class UpnpBrowseCollection : public UpnpCollectionBase { Q_OBJECT public: explicit UpnpBrowseCollection( const DeviceInfo& ); - virtual ~UpnpBrowseCollection(); + ~UpnpBrowseCollection() override; QueryMaker* queryMaker() override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; QIcon icon() const override { return QIcon::fromTheme("network-server"); } QSharedPointer memoryCollection() const { return m_mc; } Q_SIGNALS: void incrementProgress(); void totalSteps( int ); void endProgressOperation( QObject * ); public Q_SLOTS: virtual void startFullScan(); virtual void startIncrementalScan( const QString &directory = QString() ); private Q_SLOTS: void entries( KIO::Job *, const KIO::UDSEntryList& ); void done( KJob * ); void createTrack( const KIO::UDSEntry &, const QString &baseUrl ); void removeTrack( const Meta::TrackPtr &t ); void invalidateTracksIn( const QString &dir ); void updateMemoryCollection(); void slotFilesChanged(const QStringList &); void processUpdates(); private: QSharedPointer m_mc; QTimer *m_fullScanTimer; bool m_fullScanInProgress; // associates each track with its UPNP Parent // when a update occurs on a // invalidate all tracks, and rescan // it remains to be seen how badly this // affects performance or memory QHash m_tracksInContainer; QQueue m_updateQueue; UpnpCache *m_cache; }; class UpnpBrowseCollectionScanCapability : public Capabilities::CollectionScanCapability { Q_OBJECT public: explicit UpnpBrowseCollectionScanCapability( UpnpBrowseCollection* collection ); - virtual ~UpnpBrowseCollectionScanCapability(); + ~UpnpBrowseCollectionScanCapability() override; void startFullScan() override; void startIncrementalScan( const QString &directory = QString() ) override; void stopScan() override; private: UpnpBrowseCollection *m_collection; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h b/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h index c36eb184b1..0bb11c2d83 100644 --- a/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h +++ b/src/core-impl/collections/upnpcollection/UpnpCollectionBase.h @@ -1,83 +1,83 @@ /**************************************************************************************** * Copyright (c) 2010 Nikhil Marathe * * * * 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 UPNPCOLLECTIONBASE_H #define UPNPCOLLECTIONBASE_H #include "core/collections/Collection.h" #include #include #include #include #include #include #include #include #include "deviceinfo.h" namespace KIO { class Slave; class Job; class SimpleJob; } class KJob; namespace Collections { /** * UPnP Collections are of two types. * If a MediaServer only supports the Browse() action * a directory walking, recursive listing UpnpBrowseCollection * is used. * If a server also supports Search(), a more efficient, * UpnpSearchCollection is used. * Certain things are common to both, removal, * track creation from the UDSEntry, collection identification, */ class UpnpCollectionBase : public Collections::Collection { Q_OBJECT public: explicit UpnpCollectionBase( const DeviceInfo& dev ); - virtual ~UpnpCollectionBase(); + ~UpnpCollectionBase() override; void removeCollection() { Q_EMIT remove(); } QString collectionId() const override; QString prettyName() const override; bool possiblyContainsTrack( const QUrl &url ) const override; private Q_SLOTS: void slotSlaveError( KIO::Slave *slave, int err, const QString &msg ); void slotSlaveConnected( KIO::Slave *slave ); void slotRemoveJob( KJob *job ); protected: void addJob( KIO::SimpleJob *job ); //const Solid::Device m_device; const DeviceInfo m_device; KIO::Slave *m_slave; bool m_slaveConnected; QSet m_jobSet; int m_continuousJobFailureCount; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h b/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h index 6ca14ecd63..e802075cfa 100644 --- a/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h +++ b/src/core-impl/collections/upnpcollection/UpnpCollectionFactory.h @@ -1,77 +1,77 @@ /**************************************************************************************** * Copyright (c) 2010 Nikhil Marathe * * * * 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 UPNPCOLLECTIONFACTORY_H #define UPNPCOLLECTIONFACTORY_H #include "core/collections/Collection.h" #include "core-impl/collections/upnpcollection/deviceinfo.h" #include #include #include namespace KIO { class Job; } class KJob; class QDBusInterface; typedef QHash DeviceTypeMap; Q_DECLARE_METATYPE( DeviceTypeMap ) namespace Collections { class UpnpCollectionBase; class UpnpCollectionFactory : public Collections::CollectionFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-upnpcollection.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: UpnpCollectionFactory(); - virtual ~UpnpCollectionFactory(); + ~UpnpCollectionFactory() override; void init() override; private: private Q_SLOTS: void slotDeviceAdded( const DeviceTypeMap &udi ); void slotDeviceRemoved( const DeviceTypeMap &udi ); void createCollection( const QString& ); void slotSearchEntries( KIO::Job *job, const KIO::UDSEntryList &list ); void slotSearchCapabilitiesDone( KJob * ); private: bool cagibi0_1_0Init( QDBusConnection bus ); bool cagibi0_2_0Init( QDBusConnection bus ); bool cagibi0_1_0DeviceDetails( const QString &udn, DeviceInfo *info ); bool cagibi0_2_0DeviceDetails( const QString &udn, DeviceInfo *info ); QHash m_devices; QHash m_capabilities; QDBusInterface *m_iface; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h b/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h index 3df2bebbbb..dcbd81fe0e 100644 --- a/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h +++ b/src/core-impl/collections/upnpcollection/UpnpMemoryQueryMaker.h @@ -1,53 +1,53 @@ /**************************************************************************************** * Copyright (c) 2010 Nikhil Marathe * * * * 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 UPNP_MEMORYQUERYMAKER_H #define UPNP_MEMORYQUERYMAKER_H #include "amarok_export.h" #include "MemoryCollection.h" #include "core-impl/collections/support/MemoryQueryMaker.h" #include namespace Collections { class UpnpMemoryQueryMaker : public MemoryQueryMaker { Q_OBJECT public: UpnpMemoryQueryMaker( const QWeakPointer &mc, const QString &collectionId ); - virtual ~UpnpMemoryQueryMaker(); + ~UpnpMemoryQueryMaker() override; void run() override; Q_SIGNALS: void startFullScan(); private: /* * On the first run we need to tell the collection * to start scanning. So we need to know when its * the first run. Is this crude? I don't know now */ static bool m_firstRun; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/upnpcollection/UpnpMeta.h b/src/core-impl/collections/upnpcollection/UpnpMeta.h index 78dbcbe671..b44a3e1a4a 100644 --- a/src/core-impl/collections/upnpcollection/UpnpMeta.h +++ b/src/core-impl/collections/upnpcollection/UpnpMeta.h @@ -1,238 +1,238 @@ /**************************************************************************************** * Copyright (c) 2010 Nikhil Marathe * * * * 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 UPNPMETA_H #define UPNPMETA_H #include "core/meta/Meta.h" namespace Collections { class UpnpCollectionBase; } namespace Meta { class UpnpTrack; class UpnpAlbum; class UpnpArtist; class UpnpGenre; class UpnpComposer; class UpnpYear; typedef AmarokSharedPointer UpnpTrackPtr; typedef AmarokSharedPointer UpnpArtistPtr; typedef AmarokSharedPointer UpnpAlbumPtr; typedef AmarokSharedPointer UpnpGenrePtr; typedef AmarokSharedPointer UpnpComposerPtr; typedef AmarokSharedPointer UpnpYearPtr; class UpnpTrack : public Meta::Track { public: explicit UpnpTrack( Collections::UpnpCollectionBase *collection ); - virtual ~UpnpTrack(); + ~UpnpTrack() override; QString name() const override; QUrl playableUrl() const override; QString uidUrl() const override; QString prettyUrl() const override; QString notPlayableReason() const override; AlbumPtr album() const override; ArtistPtr artist() const override; GenrePtr genre() const override; ComposerPtr composer() const override; YearPtr year() const override; virtual void setAlbum ( const QString &newAlbum ); virtual void setArtist ( const QString &newArtist ); virtual void setGenre ( const QString &newGenre ); virtual void setComposer ( const QString &newComposer ); virtual void setYear ( int year ); virtual void setTitle( const QString &newTitle ); virtual void setUidUrl( const QString &url ); qreal bpm() const override; QString comment() const override; virtual void setComment ( const QString &newComment ); qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; int trackNumber() const override; virtual void setTrackNumber ( int newTrackNumber ); int discNumber() const override; virtual void setDiscNumber ( int newDiscNumber ); QString type() const override; bool inCollection() const override; Collections::Collection* collection() const override; //UpnpTrack specific methods void setAlbum( const UpnpAlbumPtr &album ); void setArtist( const UpnpArtistPtr &artist ); void setComposer( const UpnpComposerPtr &composer ); void setGenre( const UpnpGenrePtr &genre ); void setYear( const UpnpYearPtr &year ); void setPlayableUrl( const QString &url ); void setLength( qint64 length ); void setBitrate( int rate ); private: Collections::UpnpCollectionBase *m_collection; UpnpArtistPtr m_artist; UpnpAlbumPtr m_album; UpnpGenrePtr m_genre; UpnpComposerPtr m_composer; UpnpYearPtr m_year; QString m_name; QString m_type; qint64 m_length; int m_bitrate; int m_trackNumber; QString m_displayUrl; QString m_playableUrl; QString m_uidUrl; }; class UpnpArtist : public Meta::Artist { public: explicit UpnpArtist( const QString &name ); ~UpnpArtist() override; QString name() const override; TrackList tracks() override; //UpnpArtist specific methods void addTrack( const UpnpTrackPtr &track ); void removeTrack( const UpnpTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class UpnpAlbum : public QObject, public Meta::Album { Q_OBJECT public: explicit UpnpAlbum( const QString &name ); - virtual ~UpnpAlbum(); + ~UpnpAlbum() override; QString name() const override; bool isCompilation() const override; bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; bool hasImage( int size = 0 ) const override; QImage image( int size = 0 ) const override; QUrl imageLocation( int size = 0 ) override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; //UpnpAlbum specific methods void addTrack( const UpnpTrackPtr &track ); void removeTrack( const UpnpTrackPtr &track ); void setAlbumArtist( const UpnpArtistPtr &artist ); void setAlbumArtUrl( const QUrl &url ); private: QString m_name; mutable QImage m_image; TrackList m_tracks; bool m_isCompilation; UpnpArtistPtr m_albumArtist; QUrl m_albumArtUrl; }; class UpnpGenre : public Meta::Genre { public: explicit UpnpGenre( const QString &name ); - virtual ~UpnpGenre(); + ~UpnpGenre() override; QString name() const override; TrackList tracks() override; //UpnpGenre specific methods void addTrack( const UpnpTrackPtr &track ); void removeTrack( const UpnpTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class UpnpComposer : public Meta::Composer { public: explicit UpnpComposer( const QString &name ); - virtual ~UpnpComposer(); + ~UpnpComposer() override; QString name() const override; TrackList tracks() override; //UpnpComposer specific methods void addTrack( const UpnpTrackPtr &track ); void removeTrack( const UpnpTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class UpnpYear : public Meta::Year { public: explicit UpnpYear( int year ); - virtual ~UpnpYear(); + ~UpnpYear() override; QString name() const override; TrackList tracks() override; //UpnpYear specific methods void addTrack( const UpnpTrackPtr &track ); void removeTrack( const UpnpTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; } #endif diff --git a/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h b/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h index 920f931500..e5d4526c22 100644 --- a/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h +++ b/src/core-impl/collections/upnpcollection/UpnpQueryMaker.h @@ -1,141 +1,141 @@ /**************************************************************************************** * Copyright (c) 2010 Nikhil Marathe * * * * 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 UPNP_QUERYMAKER_H #define UPNP_QUERYMAKER_H #include "core/collections/QueryMaker.h" #include #include #include #include #include "UpnpQuery.h" namespace KIO { class UDSEntry; typedef QList UDSEntryList; class Job; } namespace Collections { class UpnpSearchCollection; class UpnpQueryMakerInternal; class UpnpQueryMaker : public QueryMaker { Q_OBJECT public: explicit UpnpQueryMaker( UpnpSearchCollection * ); - ~UpnpQueryMaker(); + ~UpnpQueryMaker() override; QueryMaker* reset(); void run() override; void abortQuery() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addReturnValue( qint64 value ) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy( qint64 value, bool descending = false ) override; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::YearPtr &year ) override; QueryMaker* addMatch( const Meta::LabelPtr &label ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) override; QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; QueryMaker* limitMaxResultSize( int size ) override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override; QueryMaker* beginAnd() override; QueryMaker* beginOr() override; QueryMaker* endAndOr() override; QueryMaker* setAutoDelete( bool autoDelete ); int validFilterMask() override; Q_SIGNALS: void newTracksReady( const Meta::TrackList& ); void newArtistsReady( const Meta::ArtistList &); void newAlbumsReady( const Meta::AlbumList& ); void newGenresReady( const Meta::GenreList& ); void newComposersReady( const Meta::ComposerList& ); void newYearsReady( const Meta::YearList& ); void newResultReady( const QStringList& ); void newLabelsReady( const Meta::LabelList& ); void queryDone(); private Q_SLOTS: void slotDone(); void handleArtists( const Meta::ArtistList &); void handleAlbums( const Meta::AlbumList &); void handleTracks( const Meta::TrackList &); private: /* * apply numeric filters and such which UPnP doesn't handle. */ bool postFilter( const KIO::UDSEntry& entry ); QString propertyForValue( qint64 value ); UpnpSearchCollection *m_collection; UpnpQueryMakerInternal *m_internalQM; QueryType m_queryType; AlbumQueryMode m_albumMode; bool m_asDataPtrs; UpnpQuery m_query; bool m_noResults; int m_jobCount; Meta::DataList m_cacheEntries; ReturnFunction m_returnFunction; qint64 m_returnValue; struct NumericFilter { qint64 type; qint64 value; NumberComparison compare; }; QList m_numericFilters; }; } //namespace Collections #endif diff --git a/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h b/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h index f817a19d00..5b0168c64a 100644 --- a/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h +++ b/src/core-impl/collections/upnpcollection/UpnpQueryMakerInternal.h @@ -1,82 +1,82 @@ /* Copyright (C) 2010 Nikhil Marathe 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef UPNPQUERYMAKERINTERNAL_H #define UPNPQUERYMAKERINTERNAL_H #include #include #include #include "core/collections/QueryMaker.h" class KJob; namespace KIO { class Job; class SimpleJob; } namespace Collections { class UpnpSearchCollection; class UpnpQueryMakerInternal : public QObject { Q_OBJECT public: explicit UpnpQueryMakerInternal( UpnpSearchCollection *collection ); - ~UpnpQueryMakerInternal(); + ~UpnpQueryMakerInternal() override; void setQueryType( Collections::QueryMaker::QueryType type ) { m_queryType = type; } void reset(); void runQuery( QUrl query, bool filter=true ); Q_SIGNALS: void results( bool error, const KIO::UDSEntryList &list ); void done(); void newTracksReady( const Meta::TrackList &); void newArtistsReady( const Meta::ArtistList &); void newAlbumsReady( const Meta::AlbumList &); void newGenresReady( const Meta::GenreList &); void newResultReady( const KIO::UDSEntryList & ); private Q_SLOTS: void slotEntries( KIO::Job *, const KIO::UDSEntryList & ); void slotDone( KJob * ); void slotStatDone( KJob * ); private: void handleArtists( const KIO::UDSEntryList &list ); void handleAlbums( const KIO::UDSEntryList &list ); void handleTracks( const KIO::UDSEntryList &list ); void handleCustom( const KIO::UDSEntryList &list ); void queueJob( KIO::SimpleJob *job ); void runStat( const QString &id ); private: UpnpSearchCollection *m_collection; QueryMaker::QueryType m_queryType; int m_jobCount; }; } #endif // UPNPQUERYMAKERINTERNAL_H diff --git a/src/core-impl/meta/default/DefaultMetaTypes.h b/src/core-impl/meta/default/DefaultMetaTypes.h index e097fa025b..90e8121610 100644 --- a/src/core-impl/meta/default/DefaultMetaTypes.h +++ b/src/core-impl/meta/default/DefaultMetaTypes.h @@ -1,114 +1,114 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 DEFAULTMETATYPES_H #define DEFAULTMETATYPES_H #include "amarok_export.h" #include "core/support/Debug.h" #include "core/meta/Meta.h" #include namespace Meta { class AMAROK_EXPORT DefaultArtist : public Meta::Artist { public: DefaultArtist() {} - virtual ~DefaultArtist() {} + ~DefaultArtist() override {} QString name() const override { return i18nc( "The value is not known", "Unknown" ); } TrackList tracks() override { return TrackList(); } }; class AMAROK_EXPORT DefaultAlbum : public Meta::Album { public: DefaultAlbum() : Meta::Album() , m_albumArtist( new DefaultArtist() ) {} - virtual ~DefaultAlbum() {} + ~DefaultAlbum() override {} bool hasAlbumArtist() const override { return true; } ArtistPtr albumArtist() const override { return m_albumArtist; } bool isCompilation() const override { return false; } QString name() const override { return i18nc( "The Value is not known", "Unknown" ); } TrackList tracks() override { return TrackList(); } private: Meta::ArtistPtr m_albumArtist; }; class AMAROK_EXPORT DefaultComposer : public Meta::Composer { public: DefaultComposer() {} - virtual ~DefaultComposer() {} + ~DefaultComposer() override {} QString name() const override { return i18nc( "The value is not known", "Unknown" ); } TrackList tracks() override { return TrackList(); } private: static ComposerPtr s_instance; }; class AMAROK_EXPORT DefaultGenre : public Meta::Genre { public: DefaultGenre() {} - virtual ~DefaultGenre() {} + ~DefaultGenre() override {} QString name() const override { return i18nc( "The value is not known", "Unknown" ); } TrackList tracks() override { return TrackList(); } }; class AMAROK_EXPORT DefaultYear : public Meta::Year { public: DefaultYear() {} - virtual ~DefaultYear() {} + ~DefaultYear() override {} QString name() const override { return QStringLiteral("0"); } TrackList tracks() override { return TrackList(); } }; } #endif diff --git a/src/core-impl/meta/file/File.h b/src/core-impl/meta/file/File.h index 37d48a09f4..21129eb752 100644 --- a/src/core-impl/meta/file/File.h +++ b/src/core-impl/meta/file/File.h @@ -1,137 +1,137 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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_META_FILE_H #define AMAROK_META_FILE_H #include "amarok_export.h" #include "core/meta/Meta.h" #include "core/meta/Statistics.h" #include "core/meta/TrackEditor.h" namespace MetaFile { class Track; typedef AmarokSharedPointer TrackPtr; class AMAROK_EXPORT Track : public Meta::Track, public Meta::Statistics, Meta::TrackEditor { public: explicit Track( const QUrl &url ); - virtual ~Track(); + ~Track() override; //methods inherited from Meta::Base QString name() const override; //methods inherited from Meta::Track QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; QString notPlayableReason() const override; 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; qreal bpm() const override; QString comment() const override; int trackNumber() const override; int discNumber() const override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; QDateTime createDate() const override; qreal replayGain( Meta::ReplayGainTag mode ) const override; QString type() const override; bool inCollection() const override; Collections::Collection *collection() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; Meta::TrackEditorPtr editor() override; Meta::StatisticsPtr statistics() override; // Meta::TrackEditor methods: void setAlbum( const QString &newAlbum ) override; void setAlbumArtist( const QString &newAlbumArtist ) override; void setArtist( const QString &newArtist ) override; void setComposer( const QString &newComposer ) override; void setGenre( const QString &newGenre ) override; void setYear( int newYear ) override; void setTitle( const QString &newTitle ) override; void setComment( const QString &newComment ) override; void setTrackNumber( int newTrackNumber ) override; void setDiscNumber( int newDiscNumber ) override; void setBpm( const qreal newBpm ) override; // Meta::Statistics methods: double score() const override; void setScore( double newScore ) override; int rating() const override; void setRating( int newRating ) override; int playCount() const override; void setPlayCount( int newPlayCount ) override; // combined Meta::TrackEditor, Meta::Statistics methods: void beginUpdate() override; void endUpdate() override; // MetaFile::Track own methods: bool isEditable() const; /** * Return true if file at @param url is a track. * * This method does only basic checking of the mime type and is pretty * optimistic, so it may be possible that is the song is not playable with * current backend even if isTrack() returns true. */ static bool isTrack( const QUrl &url ); virtual QImage getEmbeddedCover() const; virtual void setCollection( Collections::Collection *newCollection ); // publish method so that it can be called by Private. using Meta::Track::notifyObservers; class Private; private: Private * const d; /** * Must be called at end of every set*() method, with d->lock locked for * writing. Takes care of writing back the fields, re-reading them and * notifying observers. */ void commitIfInNonBatchUpdate( qint64 field, const QVariant &value ); void commitIfInNonBatchUpdate(); }; } #endif diff --git a/src/core-impl/meta/file/FileTrackProvider.h b/src/core-impl/meta/file/FileTrackProvider.h index 5b4580d6ec..d52566a010 100644 --- a/src/core-impl/meta/file/FileTrackProvider.h +++ b/src/core-impl/meta/file/FileTrackProvider.h @@ -1,40 +1,40 @@ /**************************************************************************************** * 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 FILETRACKPROVIDER_H #define FILETRACKPROVIDER_H #include "amarok_export.h" #include "core/collections/Collection.h" /** * A simple track provider that constructs MetaFile::Tracks for local and * existing urls. (no remote protocols supported, just "file" protocol.) */ class AMAROK_EXPORT FileTrackProvider : public Collections::TrackProvider { public: FileTrackProvider(); - virtual ~FileTrackProvider(); + ~FileTrackProvider() override; bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; private: Q_DISABLE_COPY( FileTrackProvider ) }; #endif // FILETRACKPROVIDER_H diff --git a/src/core-impl/meta/multi/MultiTrack.h b/src/core-impl/meta/multi/MultiTrack.h index 2489074d49..f6017ee620 100644 --- a/src/core-impl/meta/multi/MultiTrack.h +++ b/src/core-impl/meta/multi/MultiTrack.h @@ -1,108 +1,108 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 METAMULTITRACK_H #define METAMULTITRACK_H #include "core/capabilities/MultiSourceCapability.h" #include "core/meta/Meta.h" #include "core/meta/Observer.h" #include "core/playlists/Playlist.h" #include "core-impl/meta/default/DefaultMetaTypes.h" namespace Meta { /** * A track that wraps a playlist. This is useful, for instance, for adding radio * streams with multiple fallback streams to the playlist as a single item. * * @author Nikolaj Hald Nielsen */ class MultiTrack : public QObject, public Track, private Meta::Observer, private Playlists::PlaylistObserver { Q_OBJECT public: explicit MultiTrack( Playlists::PlaylistPtr playlist ); - ~MultiTrack(); + ~MultiTrack() override; QStringList sources() const; void setSource( int source ); int current() const; QUrl nextUrl() const; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ) override; // forward lots of stuff: #define FORWARD( Type, method, default ) Type method() const override { return m_currentTrack ? m_currentTrack->method() : default; } FORWARD( QString, name, QString() ) FORWARD( QString, prettyName, QString() ) FORWARD( QUrl, playableUrl, QUrl() ) FORWARD( QString, prettyUrl, m_playlist->uidUrl().toDisplayString() ) // TODO: change to m_playlist->uidUrl() unconditionally once playlist restorer can cope with it: FORWARD( QString, uidUrl, m_playlist->uidUrl().url() ) FORWARD( QString, notPlayableReason, i18nc( "Reason why a track is not playable", "Underlying playlist is empty" ) ) FORWARD( AlbumPtr, album, AlbumPtr( new DefaultAlbum() ) ); FORWARD( ArtistPtr, artist, ArtistPtr( new DefaultArtist() ) ); FORWARD( ComposerPtr, composer, ComposerPtr( new DefaultComposer() ) ); FORWARD( GenrePtr, genre, GenrePtr( new DefaultGenre() ) ); FORWARD( YearPtr, year, YearPtr( new DefaultYear() ) ); FORWARD( qreal, bpm, -1 ) FORWARD( QString, comment, QString() ) FORWARD( qint64, length, 0 ) FORWARD( int, filesize, 0 ) FORWARD( int, sampleRate, 0 ) FORWARD( int, bitrate, 0 ) FORWARD( int, trackNumber, 0 ) FORWARD( int, discNumber, 0 ) FORWARD( QString, type, QString() ) #undef FORWARD void prepareToPlay() override; StatisticsPtr statistics() override; Q_SIGNALS: void urlChanged( const QUrl &url ); private: using Observer::metadataChanged; void metadataChanged( const Meta::TrackPtr &track ) override; using PlaylistObserver::metadataChanged; void trackAdded( const Playlists::PlaylistPtr &playlist, const TrackPtr &track, int position ) override; /** * Implementation for setSource. Must be called with m_lock held for writing. */ void setSourceImpl( int source ); // marked as mutable because many Playlist methods aren't const while they should be mutable Playlists::PlaylistPtr m_playlist; TrackPtr m_currentTrack; /** * Guards access to data members; note that m_playlist methods are considered * thread-safe and the pointer itself does not change throughout life of this * object, so mere m_playlist->someMethod() doesn't have to be guarded. */ mutable QReadWriteLock m_lock; }; } #endif diff --git a/src/core-impl/meta/proxy/MetaProxy.h b/src/core-impl/meta/proxy/MetaProxy.h index 4b7091519c..639a516b3b 100644 --- a/src/core-impl/meta/proxy/MetaProxy.h +++ b/src/core-impl/meta/proxy/MetaProxy.h @@ -1,167 +1,167 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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_METAPROXY_H #define AMAROK_METAPROXY_H #include "amarok_export.h" #include "core/capabilities/Capability.h" #include "core/meta/Meta.h" #include "core/meta/TrackEditor.h" #include "core-impl/meta/proxy/MetaProxyWorker.h" #include namespace Collections { class TrackProvider; } namespace MetaProxy { class Track; typedef AmarokSharedPointer TrackPtr; class AMAROK_EXPORT Track : public Meta::Track, public Meta::TrackEditor { public: class Private; enum LookupType { AutomaticLookup, ManualLookup }; /** * Construct a lazy-loading proxying track. You must assign this track to a * AmarokSharedPointer right after constructing it. * * If @p lookupType is AutomaticLookup (the default), an asynchronous * job employing CollectionManager to lookup the track in TrackProviders is * enqueued and started right from this constructor. * * If @p lookupType is ManualLookup, lookup is not done automatically * and you are responsible to call lookupTrack() once it is feasible. This way * you can also optionally define which TrackProvider will be used. * * @param url th URL * @param lookupType lookup type */ explicit Track( const QUrl &url, LookupType lookupType = AutomaticLookup ); - virtual ~Track(); + ~Track() override; /** * Tell MetaProxy::Track to start looking up the real track. Only valid if * this Track is constructed with lookupType = ManualLookup. This method * returns quickly and the lookup happens asynchronously in a thread (in * other words, @p provider, id supplied, must be thread-safe). * * If @p provider is null (the default), lookup happens in all * registered providers by employing CollectionManager. Otherwise lookup * only checks @param provider (still asynchronously). */ void lookupTrack( Collections::TrackProvider *provider = 0 ); // methods inherited from Meta::MetaCapability bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; // methods inherited from Meta::Base QString name() const override; QString prettyName() const override; QString sortableName() const override; // methods inherited from Meta::Track QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; QString notPlayableReason() const override; 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; Meta::LabelList labels() const override; qreal bpm() const override; QString comment() const override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; QDateTime createDate() const override; QDateTime modifyDate() const override; int trackNumber() const override; int discNumber() const override; qreal replayGain( Meta::ReplayGainTag mode ) const override; QString type() const override; void prepareToPlay() override; void finishedPlaying( double playedFraction ) override; bool inCollection() const override; Collections::Collection *collection() const override; QString cachedLyrics() const override; void setCachedLyrics( const QString &lyrics ) override; void addLabel( const QString &label ) override; void addLabel( const Meta::LabelPtr &label ) override; void removeLabel( const Meta::LabelPtr &label ) override; Meta::TrackEditorPtr editor() override; Meta::StatisticsPtr statistics() override; bool operator==( const Meta::Track &track ) const override; // Meta::TrackEditor methods: void setAlbum( const QString &album ) override; void setAlbumArtist( const QString &artist ) override; void setArtist( const QString &artist ) override; void setComposer( const QString &composer ) override; void setGenre( const QString &genre ) override; void setYear( int year ) override; void setComment( const QString &comment ) override; void setTitle( const QString &name ) override; void setTrackNumber( int number ) override; void setDiscNumber( int discNumber ) override; void setBpm( const qreal bpm ) override; void beginUpdate() override; void endUpdate() override; // custom MetaProxy methods /** * Return true if underlying track has already been found, false otherwise. */ bool isResolved() const; void setLength( qint64 length ); /** * MetaProxy will update the proxy with the track. */ void updateTrack( const Meta::TrackPtr &track ); private: Q_DISABLE_COPY( Track ) Private *const d; // constant pointer to non-constant object }; } #endif diff --git a/src/core-impl/meta/stream/Stream.h b/src/core-impl/meta/stream/Stream.h index d88f5a7452..a79a6054f1 100644 --- a/src/core-impl/meta/stream/Stream.h +++ b/src/core-impl/meta/stream/Stream.h @@ -1,84 +1,84 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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_STREAM_H #define AMAROK_STREAM_H #include "amarok_export.h" #include "core/meta/Meta.h" namespace MetaStream { class AMAROK_EXPORT Track : public Meta::Track { public: class Private; explicit Track( const QUrl &url ); - virtual ~Track(); + ~Track() override; // methods inherited from Meta::Base QString name() const override; // methods inherited from Meta::Track QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; QString notPlayableReason() const override; 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; qreal bpm() const override; QString comment() const override; int trackNumber() const override; int discNumber() const override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; void finishedPlaying( double playedFraction ) override; QString type() const override; // MetaStream::Track methods, used to restore initial stream info /** * Set initial values to display before more accurate info can be fetched. * This method doesn't call notifyObservers(), it is the caller's * responsibility; it also doesn't overwrite already filled entries. * * @param artist track artist * @param album track album * @param title track title * @param length is in milliseconds * @param trackNumber track number */ void setInitialInfo( const QString &artist, const QString &album, const QString &title, qint64 length, int trackNumber ); private: Private * const d; }; } #endif diff --git a/src/core-impl/meta/stream/Stream_p.h b/src/core-impl/meta/stream/Stream_p.h index c36be2edd5..26cee38c45 100644 --- a/src/core-impl/meta/stream/Stream_p.h +++ b/src/core-impl/meta/stream/Stream_p.h @@ -1,202 +1,202 @@ /**************************************************************************************** * Copyright (c) 2007-2008 Maximilian Kossick * * Copyright (c) 2008 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 AMAROK_STREAM_P_H #define AMAROK_STREAM_P_H #include "EngineController.h" #include "core/meta/Meta.h" #include "core/meta/support/MetaConstants.h" #include "core/support/Debug.h" #include "core-impl/meta/default/DefaultMetaTypes.h" #include "covermanager/CoverCache.h" #include using namespace MetaStream; class MetaStream::Track::Private : public QObject { Q_OBJECT public: Private( Track *t ) : trackNumber( 0 ) , length( 0 ) , track( t ) { EngineController *engine = The::engineController(); if( !engine ) return; // engine might not be available during tests, silence the warning // force a direct connection or slot might not be called because of thread // affinity. (see BUG 300334) connect( engine, &EngineController::currentMetadataChanged, this, &Private::currentMetadataChanged, Qt::DirectConnection ); } public Q_SLOTS: void currentMetadataChanged( const QVariantMap &metaData ) { const QUrl metaDataUrl = metaData.value( Meta::Field::URL ).toUrl(); if( metaDataUrl == url ) { // keep synchronized to EngineController::slotMetaDataChanged() if( metaData.contains( Meta::Field::ARTIST ) ) artist = metaData.value( Meta::Field::ARTIST ).toString(); if( metaData.contains( Meta::Field::TITLE ) ) title = metaData.value( Meta::Field::TITLE ).toString(); if( metaData.contains( Meta::Field::ALBUM ) ) album = metaData.value( Meta::Field::ALBUM ).toString(); if( metaData.contains( Meta::Field::GENRE ) ) genre = metaData.value( Meta::Field::GENRE ).toString(); if( metaData.contains( Meta::Field::TRACKNUMBER ) ) trackNumber = metaData.value( Meta::Field::TRACKNUMBER ).toInt(); if( metaData.contains( Meta::Field::COMMENT ) ) comment = metaData.value( Meta::Field::COMMENT ).toString(); if( metaData.contains( Meta::Field::LENGTH ) ) length = metaData.value( Meta::Field::LENGTH ).value(); //TODO: move special handling to subclass or using some configurable XSPF // Special demangling of artist/title for Shoutcast streams, which usually // have "Artist - Title" in the title tag: if( artist.isEmpty() && title.contains( QLatin1String(" - ") ) ) { const QStringList artist_title = title.split( QStringLiteral(" - ") ); if( artist_title.size() >= 2 ) { artist = artist_title[0]; title = title.remove( 0, artist.length() + 3 ); } } track->notifyObservers(); } } public: QUrl url; QString title; QString artist; QString album; QString genre; int trackNumber; QString comment; qint64 length; Meta::ArtistPtr artistPtr; Meta::AlbumPtr albumPtr; Meta::GenrePtr genrePtr; Meta::ComposerPtr composerPtr; Meta::YearPtr yearPtr; private: Track *track; }; // internal helper classes class StreamArtist : public Meta::DefaultArtist { public: explicit StreamArtist( MetaStream::Track::Private *dptr ) : DefaultArtist() , d( dptr ) {} QString name() const override { if( d && !d->artist.isEmpty() ) return d->artist; return DefaultArtist::name(); } MetaStream::Track::Private * const d; }; class StreamAlbum : public Meta::DefaultAlbum { public: explicit StreamAlbum( MetaStream::Track::Private *dptr ) : DefaultAlbum() , d( dptr ) {} - ~StreamAlbum() + ~StreamAlbum() override { CoverCache::invalidateAlbum( this ); } bool hasAlbumArtist() const override { return false; } QString name() const override { if( d && !d->album.isEmpty() ) return d->album; return DefaultAlbum::name(); } bool hasImage( int size ) const override { if( m_cover.isNull() ) return Meta::Album::hasImage( size ); else return true; } QImage image( int size ) const override { if( m_cover.isNull() ) return Meta::Album::image( size ); else return m_cover.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); } void setImage( const QImage &image ) override { m_cover = image; CoverCache::invalidateAlbum( this ); } MetaStream::Track::Private * const d; QImage m_cover; }; class StreamGenre : public Meta::DefaultGenre { public: explicit StreamGenre( MetaStream::Track::Private *dptr ) : DefaultGenre() , d( dptr ) {} QString name() const override { if( d && !d->genre.isEmpty() ) return d->genre; return DefaultGenre::name(); } MetaStream::Track::Private * const d; }; #endif diff --git a/src/core-impl/meta/timecode/TimecodeMeta.h b/src/core-impl/meta/timecode/TimecodeMeta.h index 3a5bfb9335..160975f193 100644 --- a/src/core-impl/meta/timecode/TimecodeMeta.h +++ b/src/core-impl/meta/timecode/TimecodeMeta.h @@ -1,275 +1,275 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 TIMECODEMETA_H #define TIMECODEMETA_H #include "core/meta/Meta.h" #include "core/meta/TrackEditor.h" namespace Meta { class TimecodeTrack; class TimecodeAlbum; class TimecodeArtist; class TimecodeGenre; class TimecodeComposer; class TimecodeYear; typedef AmarokSharedPointer TimecodeTrackPtr; typedef AmarokSharedPointer TimecodeArtistPtr; typedef AmarokSharedPointer TimecodeAlbumPtr; typedef AmarokSharedPointer TimecodeGenrePtr; typedef AmarokSharedPointer TimecodeComposerPtr; typedef AmarokSharedPointer TimecodeYearPtr; class TimecodeTrack : public Track, public TrackEditor { public: TimecodeTrack( const QString &name, const QUrl &url, qint64 start, qint64 end ); - virtual ~TimecodeTrack(); + ~TimecodeTrack() override; QString name() const override; QUrl playableUrl() const override; QString uidUrl() const override; QString prettyUrl() const override; QString notPlayableReason() const override; AlbumPtr album() const override; ArtistPtr artist() const override; GenrePtr genre() const override; ComposerPtr composer() const override; YearPtr year() const override; qreal bpm() const override; QString comment() const override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; int trackNumber() const override; int discNumber() const override; QString type() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability *createCapabilityInterface( Capabilities::Capability::Type type ) override; TrackEditorPtr editor() override; // TrackEditor methods void setAlbum( const QString &newAlbum ) override; void setAlbumArtist( const QString &newAlbumArtist ) override; void setArtist( const QString &newArtist ) override; void setComposer( const QString &newComposer ) override; void setGenre( const QString &newGenre ) override; void setYear( int newYear ) override; void setTitle( const QString &newTitle ) override; void setComment( const QString &newComment ) override; void setTrackNumber( int newTrackNumber ) override; void setDiscNumber( int newDiscNumber ) override; void setBpm( const qreal newBpm ) override; void beginUpdate() override; void endUpdate() override; //TimecodeTrack specific methods void setAlbum( const TimecodeAlbumPtr &album ); void setArtist( const TimecodeArtistPtr &artist ); void setComposer( const TimecodeComposerPtr &composer ); void setGenre( const TimecodeGenrePtr &genre ); void setYear( const TimecodeYearPtr &year ); qint64 start(); qint64 end(); private: //TimecodeCollection *m_collection; TimecodeArtistPtr m_artist; TimecodeAlbumPtr m_album; TimecodeGenrePtr m_genre; TimecodeComposerPtr m_composer; TimecodeYearPtr m_year; QString m_name; QString m_type; qint64 m_start; qint64 m_end; qint64 m_length; qreal m_bpm; int m_trackNumber; int m_discNumber; QString m_comment; QString m_displayUrl; QUrl m_playableUrl; int m_updatedFields; QMap m_fields; enum { ALBUM_UPDATED = 1 << 0, ARTIST_UPDATED = 1 << 1, COMPOSER_UPDATED = 1 << 2, GENRE_UPDATED = 1 << 3, YEAR_UPDATED = 1 << 4, TITLE_UPDATED = 1 << 5, COMMENT_UPDATED = 1 << 6, TRACKNUMBER_UPDATED = 1 << 7, DISCNUMBER_UPDATED = 1 << 8, BPM_UPDATED = 1 << 9 }; }; class TimecodeArtist : public Meta::Artist { public: explicit TimecodeArtist( const QString &name ); - virtual ~TimecodeArtist(); + ~TimecodeArtist() override; QString name() const override; TrackList tracks() override; virtual AlbumList albums(); bool operator==( const Meta::Artist &other ) const override { return name() == other.name(); } //TimecodeArtist specific methods void addTrack( const TimecodeTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class TimecodeAlbum : public QObject, public Meta::Album { Q_OBJECT public: explicit TimecodeAlbum( const QString &name ); - virtual ~TimecodeAlbum(); + ~TimecodeAlbum() override; QString name() const override; bool isCompilation() const override; bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; QImage image( int size = 0 ) const override; bool canUpdateImage() const override; void setImage( const QImage &image ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; //TimecodeAlbum specific methods void addTrack( const TimecodeTrackPtr &track ); void setAlbumArtist( const TimecodeArtistPtr &artist ); bool operator==( const Meta::Album &other ) const override { return name() == other.name(); } private: QString m_name; TrackList m_tracks; bool m_isCompilation; TimecodeArtistPtr m_albumArtist; QImage m_cover; }; class TimecodeGenre : public Meta::Genre { public: explicit TimecodeGenre( const QString &name ); - virtual ~TimecodeGenre(); + ~TimecodeGenre() override; QString name() const override; TrackList tracks() override; bool operator==( const Meta::Genre &other ) const override { return name() == other.name(); } //TimecodeGenre specific methods void addTrack( const TimecodeTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class TimecodeComposer : public Meta::Composer { public: explicit TimecodeComposer( const QString &name ); - virtual ~TimecodeComposer(); + ~TimecodeComposer() override; QString name() const override; TrackList tracks() override; bool operator==( const Meta::Composer &other ) const override { return name() == other.name(); } //TimecodeComposer specific methods void addTrack( const TimecodeTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class TimecodeYear : public Meta::Year { public: explicit TimecodeYear( const QString &name ); - virtual ~TimecodeYear(); + ~TimecodeYear() override; QString name() const override; TrackList tracks() override; bool operator==( const Meta::Year &other ) const override { return name() == other.name(); } //TimecodeYear specific methods void addTrack( const TimecodeTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; } #endif diff --git a/src/core-impl/meta/timecode/TimecodeObserver.h b/src/core-impl/meta/timecode/TimecodeObserver.h index ea535943d3..2b32abe052 100644 --- a/src/core-impl/meta/timecode/TimecodeObserver.h +++ b/src/core-impl/meta/timecode/TimecodeObserver.h @@ -1,49 +1,49 @@ /**************************************************************************************** * Copyright (c) 2009 Casey Link * * * * 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 TIMECODEOBSERVER_H #define TIMECODEOBSERVER_H #include #include "EngineController.h" /** * This class handles auto timecoding (position bookmarking) of tracks. * After the current track's position has crossed an arbitrary threshold * when the user stops playing the track (before the ending) a timecode * will be created. */ class TimecodeObserver : public QObject { Q_OBJECT public: explicit TimecodeObserver( QObject *parent = nullptr ); - virtual ~TimecodeObserver(); + ~TimecodeObserver() override; protected Q_SLOTS: void stopped( qint64 finalPosition, qint64 trackLength ); void trackPlaying( Meta::TrackPtr track ); void trackPositionChanged( qint64 position, bool userSeek ); private: bool m_trackTimecodeable; //!< stores if current track has the writetimecode capability static const qint64 m_threshold; //!< the arbitrary minum tracklength threshold in milliseconds Meta::TrackPtr m_currentTrack; //!< The current/just played track qint64 m_currPos; //!< the position the current track is at }; #endif // TIMECODEOBSERVER_H diff --git a/src/core-impl/meta/timecode/TimecodeTrackProvider.h b/src/core-impl/meta/timecode/TimecodeTrackProvider.h index 34401ea2c3..7b0c9a43b2 100644 --- a/src/core-impl/meta/timecode/TimecodeTrackProvider.h +++ b/src/core-impl/meta/timecode/TimecodeTrackProvider.h @@ -1,38 +1,38 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 TIMECODETRACKPROVIDER_H #define TIMECODETRACKPROVIDER_H #include "core/collections/Collection.h" /** A track provider that recognizes timecode track urls @author Nikolaj Hald Nielsen */ class TimecodeTrackProvider : public Collections::TrackProvider{ public: TimecodeTrackProvider(); - ~TimecodeTrackProvider(); + ~TimecodeTrackProvider() override; bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; }; #endif diff --git a/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h b/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h index f03a908887..5b4f3f8545 100644 --- a/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h +++ b/src/core-impl/playlists/types/file/xspf/XSPFPlaylist.h @@ -1,137 +1,137 @@ /**************************************************************************************** * Copyright (c) 2007 Bart Cerneels * * Copyright (c) 2006 Mattias Fliesberg * * * * 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 XSPFPLAYLIST_H #define XSPFPLAYLIST_H #include "core-impl/playlists/types/file/PlaylistFile.h" #include #include namespace Playlists { /* convenience struct for internal use */ struct XSPFTrack { // initialize primitive types, don't give stochasticity a chance! XSPFTrack() : trackNum( 0 ), duration( 0 ) {} QUrl location; QString identifier; QString title; QString creator; QString annotation; QUrl info; QUrl image; QString album; uint trackNum; uint duration; QUrl link; }; typedef QList XSPFTrackList; /** * @author Bart Cerneels */ class AMAROK_EXPORT XSPFPlaylist : public PlaylistFile, public QDomDocument { public: enum OnLoadAction { NoAction, // do nothing on playlist load AppendToPlaylist, // apped this playlist to play queue on load }; /** * Creates a new XSPFPlaylist * * @param url The Url of the xspf file to load. * @param provider The playlist provider. * @param onLoad Should this playlist automatically append itself to the playlist when loaded (useful when loading a remote url as it * allows the caller to do it in a "one shot" way and not have to worry about waiting until download and parsing is completed. */ explicit XSPFPlaylist( const QUrl &url, PlaylistProvider *provider = 0, OnLoadAction onLoad = NoAction ); - ~XSPFPlaylist(); + ~XSPFPlaylist() override; QString name() const override; /* convenience functions */ QString title() const; QString creator() const; QString annotation() const; QUrl info() const; QUrl location() const; QString identifier() const; QUrl image() const; QDateTime date() const; QUrl license() const; QList attribution() const; QUrl link() const; /* Extra XSPF setter methods: */ void setTitle( const QString &title ); void setCreator( const QString &creator ); void setAnnotation( const QString &annotation ); void setInfo( const QUrl &info ); void setLocation( const QUrl &location ); void setIdentifier( const QString &identifier ); void setImage( const QUrl &image ); void setDate( const QDateTime &date ); void setLicense( const QUrl &license ); void setAttribution( const QUrl &attribution, bool append = true ); void setLink( const QUrl &link ); void setTrackList( Meta::TrackList trackList, bool append = false ); /* PlaylistFile methods */ bool load( QTextStream &stream ) override { return loadXSPF( stream ); } bool load( QByteArray &content ) override { return loadXSPF( content ); } /* Overrides filename and title */ void setName(const QString &name) override; QString extension() const override { return QStringLiteral("xspf"); } QString mimetype() const override { return QStringLiteral("application/xspf+xml"); } virtual bool save( bool relative ) { return PlaylistFile::save( relative ); } void setQueue( const QList &queue ) override; QList queue() override; protected: void savePlaylist( QFile &file ) override; private: XSPFTrackList trackList(); /** * Load file after content was set */ void load(); /** * Sets content in terms of xml document * @return true is xml-document is correct, false overwise */ bool processContent( QByteArray &content ); bool loadXSPF( QTextStream &stream ); bool loadXSPF( QByteArray &content ); bool m_autoAppendAfterLoad; }; } #endif diff --git a/src/core-impl/podcasts/sql/SqlPodcastMeta.h b/src/core-impl/podcasts/sql/SqlPodcastMeta.h index c100dc5408..161bdea120 100644 --- a/src/core-impl/podcasts/sql/SqlPodcastMeta.h +++ b/src/core-impl/podcasts/sql/SqlPodcastMeta.h @@ -1,172 +1,172 @@ /**************************************************************************************** * Copyright (c) 2008 Bart Cerneels * * * * 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 SQLPODCASTMETA_H #define SQLPODCASTMETA_H #include "core/podcasts/PodcastMeta.h" #include "core-impl/meta/file/File.h" #include "core/playlists/PlaylistProvider.h" #include namespace Podcasts { class SqlPodcastEpisode; class SqlPodcastChannel; class SqlPodcastProvider; typedef AmarokSharedPointer SqlPodcastEpisodePtr; typedef AmarokSharedPointer SqlPodcastChannelPtr; typedef QList SqlPodcastEpisodeList; typedef QList SqlPodcastChannelList; class SqlPodcastEpisode : public Podcasts::PodcastEpisode { public: static Meta::TrackList toTrackList( SqlPodcastEpisodeList episodes ); static PodcastEpisodeList toPodcastEpisodeList( SqlPodcastEpisodeList episodes ); SqlPodcastEpisode( const QStringList &queryResult, const SqlPodcastChannelPtr &sqlChannel ); /** Copy from another PodcastEpisode */ explicit SqlPodcastEpisode( PodcastEpisodePtr episode ); SqlPodcastEpisode( const PodcastChannelPtr &channel, PodcastEpisodePtr episode ); - ~SqlPodcastEpisode(); + ~SqlPodcastEpisode() override; //PodcastEpisode methods PodcastChannelPtr channel() const override { return PodcastChannelPtr::dynamicCast( m_channel ); } virtual bool isKeep() const { return m_isKeep; } void setNew( bool isNew ) override; virtual void setKeep( bool isKeep ); void setLocalUrl( const QUrl &url ) override; //Track Methods QString name() const override; QString prettyName() const override; void setTitle( const QString &title ) override; qint64 length() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; void finishedPlaying( double playedFraction ) override; Meta::ArtistPtr artist() const override; Meta::ComposerPtr composer() const override; Meta::GenrePtr genre() const override; Meta::YearPtr year() const override; Meta::TrackEditorPtr editor() override; //SqlPodcastEpisode specific methods bool writeTagsToFile(); int dbId() const { return m_dbId; } void updateInDb(); void deleteFromDb(); private: /** * Establishes m_localFile using MetaProxy::Track if m_localUrl is valid. */ void setupLocalFile(); int m_dbId; //database ID bool m_isKeep; //Keep the download after purge or not? SqlPodcastChannelPtr m_channel; //the parent of this episode Meta::TrackPtr m_localFile; }; class SqlPodcastChannel : public Podcasts::PodcastChannel { public: static Playlists::PlaylistPtr toPlaylistPtr( const SqlPodcastChannelPtr &sqlChannel ); static SqlPodcastChannelPtr fromPlaylistPtr( const Playlists::PlaylistPtr &playlist ); SqlPodcastChannel( SqlPodcastProvider *provider, const QStringList &queryResult ); /** Copy a PodcastChannel */ SqlPodcastChannel( SqlPodcastProvider *provider, PodcastChannelPtr channel ); ~SqlPodcastChannel() override; // Playlists::Playlist methods void syncTrackStatus( int position, const Meta::TrackPtr &otherTrack ) override; int trackCount() const override; virtual QString filenameLayout() const { return m_filenameLayout; } Meta::TrackList tracks() override; void addTrack( const Meta::TrackPtr &track, int position = -1 ) override; void triggerTrackLoad() override; Playlists::PlaylistProvider *provider() const override; QStringList groups() override; void setGroups( const QStringList &groups ) override; //Podcasts::PodcastChannel methods QUrl uidUrl() const override; void setTitle( const QString &title ) override; Podcasts::PodcastEpisodeList episodes() const override; bool hasImage() const override { return !m_image.isNull(); } void setImage( const QImage &image ) override; QImage image() const override { return m_image; } QUrl imageUrl() const override { return m_imageUrl; } void setImageUrl( const QUrl &imageUrl ) override; virtual void setFilenameLayout( const QString &filenameLayout ) { m_filenameLayout = filenameLayout; } PodcastEpisodePtr addEpisode( const PodcastEpisodePtr &episode ) override; //SqlPodcastChannel specific methods int dbId() const { return m_dbId; } //void addEpisode( SqlPodcastEpisodePtr episode ) { m_episodes << episode; } bool writeTags() const { return m_writeTags; } void setWriteTags( bool writeTags ) { m_writeTags = writeTags; } void updateInDb(); void deleteFromDb(); const SqlPodcastEpisodeList sqlEpisodes() { return m_episodes; } void loadEpisodes(); void applyPurge(); private: bool m_writeTags; int m_dbId; //database ID bool m_episodesLoaded; SqlPodcastEpisodeList m_episodes; bool m_trackCacheIsValid; Meta::TrackList m_episodesAsTracksCache; SqlPodcastProvider *m_provider; QString m_filenameLayout; //specifies filename layout for episodes }; } //namespace Podcasts Q_DECLARE_METATYPE( Podcasts::SqlPodcastEpisodePtr ) Q_DECLARE_METATYPE( Podcasts::SqlPodcastEpisodeList ) Q_DECLARE_METATYPE( Podcasts::SqlPodcastChannelPtr ) Q_DECLARE_METATYPE( Podcasts::SqlPodcastChannelList ) #endif diff --git a/src/core-impl/storage/StorageManager.cpp b/src/core-impl/storage/StorageManager.cpp index 2caa308ec6..e0c26983d9 100644 --- a/src/core-impl/storage/StorageManager.cpp +++ b/src/core-impl/storage/StorageManager.cpp @@ -1,202 +1,202 @@ /**************************************************************************************** * Copyright (c) 2014 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 . * ****************************************************************************************/ #define DEBUG_PREFIX "StorageManager" #include "StorageManager.h" #include #include #include #include #include #include /** A SqlStorage that doesn't do anything. * * An object of this type is used whenever we couldn't * load a better SqlStorage. * * The reason is that plugins don't have to check for * a null pointer as SqlStorage every time. */ class EmptySqlStorage : public SqlStorage { public: EmptySqlStorage() {} - virtual ~EmptySqlStorage() {} + ~EmptySqlStorage() override {} virtual int sqlDatabasePriority() const { return 10; } virtual QString type() const { return QStringLiteral("Empty"); } QString escape( const QString &text) const override { return text; } QStringList query( const QString &) override { return QStringList(); } int insert( const QString &, const QString &) override { return 0; } QString boolTrue() const override { return QString(); } QString boolFalse() const override { return QString(); } QString idType() const override { return QString(); } QString textColumnType( int ) const override { return QString(); } QString exactTextColumnType( int ) const override { return QString(); } QString exactIndexableTextColumnType( int ) const override { return QString(); } QString longTextColumnType() const override { return QString(); } QString randomFunc() const override { return QString(); } QStringList getLastErrors() const override { return QStringList(); } /** Clears the list of the last errors. */ void clearLastErrors() override { } }; struct StorageManager::Private { QSharedPointer sqlDatabase; /** A list that collects errors from database plugins * * StoragePlugin factories can report errors that * prevent the storage from even being created. * * This list collects them. */ QStringList errorList; }; StorageManager *StorageManager::s_instance = nullptr; StorageManager * StorageManager::instance() { if( !s_instance ) { s_instance = new StorageManager(); s_instance->init(); } return s_instance; } void StorageManager::destroy() { if( s_instance ) { delete s_instance; s_instance = nullptr; } } StorageManager::StorageManager() : QObject() , d( new Private ) { DEBUG_BLOCK setObjectName( QStringLiteral("StorageManager") ); qRegisterMetaType( "SqlStorage*" ); d->sqlDatabase = QSharedPointer( new EmptySqlStorage ); } StorageManager::~StorageManager() { DEBUG_BLOCK delete d; } QSharedPointer StorageManager::sqlStorage() const { return d->sqlDatabase; } void StorageManager::init() { } void StorageManager::setFactories( const QList > &factories ) { for( const auto &pFactory : factories ) { auto factory = qobject_cast( pFactory ); if( !factory ) continue; connect( factory.data(), &StorageFactory::newStorage, this, &StorageManager::slotNewStorage ); connect( factory.data(), &StorageFactory::newError, this, &StorageManager::slotNewError ); } } QStringList StorageManager::getLastErrors() const { if( !d->errorList.isEmpty() ) return d->errorList; if( d->sqlDatabase.dynamicCast() ) { QStringList list; list << i18n( "The configured database plugin could not be loaded." ); return list; } return d->errorList; } void StorageManager::clearLastErrors() { d->errorList.clear(); } void StorageManager::slotNewStorage( QSharedPointer newStorage ) { DEBUG_BLOCK if( !newStorage ) { warning() << "Warning, newStorage in slotNewStorage is 0"; return; } if( d->sqlDatabase && !d->sqlDatabase.dynamicCast() ) { warning() << "Warning, newStorage when we already have a storage"; return; // once we have the database set we can't change it since // plugins might have already created their tables in the old database // or caching data from it. } d->sqlDatabase = newStorage; } void StorageManager::slotNewError( const QStringList &errorMessageList ) { d->errorList << errorMessageList; } diff --git a/src/core-impl/storage/StorageManager.h b/src/core-impl/storage/StorageManager.h index 2ac781f8d1..41343812d0 100644 --- a/src/core-impl/storage/StorageManager.h +++ b/src/core-impl/storage/StorageManager.h @@ -1,121 +1,121 @@ /**************************************************************************************** * Copyright (c) 2014 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 AMAROK_STORAGEMANAGER_H #define AMAROK_STORAGEMANAGER_H #include "amarok_export.h" #include #include #include #include namespace Plugins { class PluginFactory; } class SqlStorage; /** Class managing the Amarok SqlStorage * * This singleton class is the main responsible for providing everybody * with the current SqlStorage. */ class AMAROK_EXPORT StorageManager : public QObject { Q_OBJECT public: /** Get THE instance of the storage manager. * * This function will return the storage manager * that returns the sql storage to be used for Amarok. * * In addition to the SqlCollection a lot of other components * use a sql storage to persist data. * */ static StorageManager *instance(); /** Destroys the instance of the StorageManager. */ static void destroy(); /** retrieve an interface which allows client-code to store/load data in a relational database. Note: You should never modify the database unless you really really know what you do. Using the SqlMeta (e.g. SqlRegistry or SqlTrack) is much better. @return Returns a pointer to the amarok wide SqlStorage or to an internal dummy SqlStorage if that cannot be found. It never returns a null pointer. */ QSharedPointer sqlStorage() const; /** * Set the list of current factories * * For every factory that is a CollectionFactory uses it to create new * collections and register with this manager. */ void setFactories( const QList > &factories ); /** Returns a list of the last sql errors. The list might not include every one error if the number is beyond a sensible limit. */ QStringList getLastErrors() const; /** Clears the list of the last errors. */ void clearLastErrors(); private Q_SLOTS: /** Will be called whenever a factory emits a newStorage signal. * * The first factory to Q_EMIT this signal will get it's storage * registered as "the" storage. * * StorageManager will take ownership of the pointer and free it * after all other plugins are done. */ void slotNewStorage( QSharedPointer newStorage ); /** Will be called whenever a factory emits a newError signal. * * The factories will not Q_EMIT the newStorage signal in case * of initialization problems. * In order to report their issues they will instead Q_EMIT * newError with the list of errors. */ void slotNewError( const QStringList &errorMessageList ); private: static StorageManager* s_instance; StorageManager(); - ~StorageManager(); + ~StorageManager() override; void init(); Q_DISABLE_COPY( StorageManager ) struct Private; Private * const d; }; #endif /* AMAROK_STORAGEMANAGER_H */ diff --git a/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h b/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h index 8b91d78272..657ff00dbb 100644 --- a/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h +++ b/src/core-impl/storage/sql/mysql-shared/MySqlStorage.h @@ -1,96 +1,96 @@ /**************************************************************************************** * Copyright (c) 2008 Edward Toroshchin * * Copyright (c) 2009 Jeff Mitchell * * * * 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_STORAGE_MYSQLSTORAGE_H #define AMAROK_STORAGE_MYSQLSTORAGE_H #include "core/storage/SqlStorage.h" #include #include #include #ifdef Q_WS_WIN #include #endif #if !defined(MARIADB_VERSION_ID) && MYSQL_VERSION_ID >= 80000 using my_bool = bool; #endif /** * Implements a SqlStorage using a MySQL backend */ class MySqlStorage: public SqlStorage { public: MySqlStorage(); - virtual ~MySqlStorage(); + ~MySqlStorage() override; QStringList query( const QString &query ) override; int insert( const QString &statement, const QString &table = QString() ) override; QString escape( const QString &text ) const override; QString randomFunc() const override; QString boolTrue() const override; QString boolFalse() const override; QString idType() const override; QString textColumnType( int length = 255 ) const override; QString exactTextColumnType( int length = 1000 ) const override; //the below value may have to be decreased even more for different indexes; only time will tell QString exactIndexableTextColumnType( int length = 324 ) const override; QString longTextColumnType() const override; /** Returns a list of the last sql errors. The list might not include every one error if the number is beyond a sensible limit. */ QStringList getLastErrors() const override; /** Clears the list of the last errors. */ void clearLastErrors() override; protected: /** Adds an error message to the m_lastErrors. * * Adds a message including the mysql error number and message * to the last error messages. * @param message Usually the query statement being executed. */ void reportError( const QString &message ); void initThreadInitializer(); /** Sends the first sql commands to setup the connection. * * Sets things like the used database and charset. * @returns false if something fatal was wrong. */ bool sharedInit( const QString &databaseName ); MYSQL* m_db; /** Mutex protecting the m_lastErrors list */ mutable QMutex m_mutex; QString m_debugIdent; QStringList m_lastErrors; }; #endif diff --git a/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h b/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h index 29963d92d4..567c18a0d3 100644 --- a/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h +++ b/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h @@ -1,45 +1,45 @@ /**************************************************************************************** * Copyright (c) 2008 Edward Toroshchin * * Copyright (c) 2009 Jeff Mitchell * * * * 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 MYSQLEMBEDDEDSTORAGE_H #define MYSQLEMBEDDEDSTORAGE_H #include "../amarok_sqlstorage_export.h" #include "../mysql-shared/MySqlStorage.h" /** * Implements a MySqlStorage using a MySQL Embedded Server */ class AMAROK_SQLSTORAGE_MYSQLE_EXPORT MySqlEmbeddedStorage : public MySqlStorage { public: /** Creates a new SqlStorage. * * Note: Currently it is not possible to open two storages to different locations * in one process. * The first caller wins. */ MySqlEmbeddedStorage(); - virtual ~MySqlEmbeddedStorage(); + ~MySqlEmbeddedStorage() override; /** Initializes the storage. * @param storageLocation The directory for storing the mysql database, will use the default defined by Amarok/KDE if not set. */ bool init( const QString &storageLocation = QString() ); }; #endif // MYSQLEMBEDDEDSTORAGE_H diff --git a/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h b/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h index 633e40e373..14cafa9c9c 100644 --- a/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h +++ b/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.h @@ -1,36 +1,36 @@ /**************************************************************************************** * Copyright (c) 2014 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 AMAROK_STORAGE_MYSQLEMBEDDEDSTORAGEFACTORY_H #define AMAROK_STORAGE_MYSQLEMBEDDEDSTORAGEFACTORY_H #include "core/storage/StorageFactory.h" class MySqleStorageFactory : public StorageFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_storage-mysqlestorage.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: MySqleStorageFactory(); - virtual ~MySqleStorageFactory(); + ~MySqleStorageFactory() override; void init() override; }; #endif diff --git a/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h b/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h index 849c5b3f00..05c197ecc4 100644 --- a/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h +++ b/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorage.h @@ -1,48 +1,48 @@ /**************************************************************************************** * Copyright (c) 2008 Edward Toroshchin * * Copyright (c) 2009 Jeff Mitchell * * * * 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_STORAGE_MYSQLSERVERSTORAGE_H #define AMAROK_STORAGE_MYSQLSERVERSTORAGE_H #include "../amarok_sqlstorage_export.h" #include "../mysql-shared/MySqlStorage.h" /** * Implements a MySqlStorage using a MySQL Server */ class AMAROK_SQLSTORAGE_MYSQLE_EXPORT MySqlServerStorage: public MySqlStorage { public: /** Constructor for the server based mysql storage. */ MySqlServerStorage(); - virtual ~MySqlServerStorage(); + ~MySqlServerStorage() override; /** Try to connect to the server indicated by the options. * * Error messages are in the store error log. * * @return true if connection works. */ virtual bool init( const QString &host, const QString &user, const QString &password, int port, const QString &databaseName ); QStringList query( const QString &query ) override; private: QString m_databaseName; ///< remember the name given at init for reconnects }; #endif diff --git a/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h b/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h index f57a76dd3d..1eee5da542 100644 --- a/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h +++ b/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.h @@ -1,43 +1,43 @@ /**************************************************************************************** * Copyright (c) 2014 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 AMAROK_STORAGE_MYSQLSERVERSTORAGEFACTORY_H #define AMAROK_STORAGE_MYSQLSERVERSTORAGEFACTORY_H #include "core/storage/StorageFactory.h" class MySqlServerStorageFactory : public StorageFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_storage-mysqlserverstorage.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: MySqlServerStorageFactory(); - virtual ~MySqlServerStorageFactory(); + ~MySqlServerStorageFactory() override; void init() override; public Q_SLOTS: /** Returns the error messages created during establishing the connection. */ QStringList testSettings( const QString &host, const QString &user, const QString &password, int port, const QString &databaseName ); }; #endif diff --git a/src/core-impl/support/PersistentStatisticsStore.h b/src/core-impl/support/PersistentStatisticsStore.h index 46b9710c88..d61442200a 100644 --- a/src/core-impl/support/PersistentStatisticsStore.h +++ b/src/core-impl/support/PersistentStatisticsStore.h @@ -1,101 +1,101 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * Copyright (c) 2012 Matěj Lait * * * * 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 PERSISTENTSTATISTICSSTORE_H #define PERSISTENTSTATISTICSSTORE_H #include "amarok_export.h" #include "core/meta/Observer.h" #include "core/meta/Statistics.h" #include #include /** * Base class for all permanent statistics storage providers. Use one of the subclassed if * your collection cannot store statistics (rating, play count..) natively, but you still * want to provide the functionality. * * All subclasses automatically call notifyObservers() on your track when the statistics * change. PersistentStatisticsStore uses some trickery not to hold reference to your * track to avoid circular reference counting. PersistentStatisticsStore can even deal * with your track being destroyed and is implemented in thread-safe way. You should * store is as StatisticsPtr (a AmarokSharedPointer) in your Track class. */ class AMAROK_EXPORT PersistentStatisticsStore : public Meta::Statistics, private Meta::Observer { public: /** * Create persistent statistics store of @param track statistics. @p track may * not be null. * * This methods takes plain pointer so that you can call it in the Track * constructor without AmarokSharedPointer deleting it right away. */ explicit PersistentStatisticsStore( Meta::Track *track ); - virtual ~PersistentStatisticsStore(); + ~PersistentStatisticsStore() override; // Meta::Statistics methods double score() const override; void setScore( double newScore ) override; int rating() const override; void setRating( int newRating ) override; QDateTime lastPlayed() const override; void setLastPlayed( const QDateTime &dt ) override; QDateTime firstPlayed() const override; void setFirstPlayed( const QDateTime &dt ) override; int playCount() const override; void setPlayCount( int playCount ) override; void beginUpdate() override; void endUpdate() override; // Meta::Observer methods /** * Notice that the linked track was destroyed. */ void entityDestroyed() override; protected: virtual void save() = 0; // called with m_lock locked for writing! static const QString s_sqlDateFormat; Meta::Track *m_track; // plain pointer not to hold reference QDateTime m_lastPlayed; QDateTime m_firstPlayed; double m_score; int m_rating; int m_playCount; mutable QReadWriteLock m_lock; // lock protecting access to fields. private: void commitIfInNonBatchUpdate(); // must be called with the m_lock locked for writing /** * Number of current batch operations started by @see beginUpdate() and not * yet ended by @see endUpdate(). Must only be accessed with m_track held. */ int m_batch; }; #endif // PERSISTENTSTATISTICSSTORE_H diff --git a/src/core-impl/support/TrackLoader.h b/src/core-impl/support/TrackLoader.h index f2d1da73ce..9ece0f0364 100644 --- a/src/core-impl/support/TrackLoader.h +++ b/src/core-impl/support/TrackLoader.h @@ -1,144 +1,144 @@ /**************************************************************************************** * Copyright (c) 2008 Ian Monroe * * Copyright (c) 2013 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_TRACKLOADER_H #define AMAROK_TRACKLOADER_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "core/meta/Observer.h" #include "core/playlists/Playlist.h" namespace KIO { class Job; class UDSEntry; typedef QList UDSEntryList; } /** * Helper class that helps with loading of urls (with local and remote tracks, * playlists and local directories) to tracks. * * Only explicitly listed playlists are loaded, not the ones found in subdirectories. * TrackLoader takes care to preserve order of urls you pass, and it sorts tracks in * directories you pass it using directory- and locale-aware sort. */ class AMAROK_EXPORT TrackLoader : public QObject, public Playlists::PlaylistObserver, public Meta::Observer { Q_OBJECT public: /** * FullMetadataRequired: signal TrackLoader that it should postpone the finished() * signal until the any possible proxy tracks have resolved and their full * metadata is available. Also use this flag when you need to immediately play * the tracks. This no longer implies any blocking behaviour, you'll just get the * finished signal a bit later. * * RemotePlaylistsAreStreams: treat playlists with remote urls as Streams with * multiple alternative download locations (Meta::MultiTracks). Works even when * you pass playlists. */ enum Flag { FullMetadataRequired = 1 << 0, RemotePlaylistsAreStreams = 1 << 1, }; Q_DECLARE_FLAGS( Flags, Flag ) /** * Construct TrackLoader. You must construct it on the heap, it will auto-delete * itself. * * @param flags binary or of flags, see TrackLoader::Flags enum * @param timeout if FullMetadataRequired is in flags, this is the timeout in * milliseconds for waiting on track to resolve. Ignored otherwise. */ explicit TrackLoader( Flags flags = 0, int timeout = 2000 ); - ~TrackLoader(); + ~TrackLoader() override; /** * Convenience overload for init( const QList &urls ) */ void init( const QUrl &url ); /** * Starts TrackLoader's job, you'll get finished() signal in the end and * TrackLoader will auto-delete itself. * * @param urls list of urls to load tracks from, you can pass local and remote urls * pointing to directories, tracks and playlists. */ void init( const QList &urls ); /** * Short-hand if you already have a list of playlists and want a convenient way * to get notified of their loaded tracks. See init( const QList ) and * class description. */ void init( const Playlists::PlaylistList &playlists ); /* PlaylistObserver methods */ using PlaylistObserver::metadataChanged; void tracksLoaded( Playlists::PlaylistPtr playlist ) override; /* Meta::Observer methods */ using Observer::metadataChanged; void metadataChanged( const Meta::TrackPtr &track ) override; Q_SIGNALS: void finished( const Meta::TrackList &tracks ); private Q_SLOTS: void processNextSourceUrl(); void directoryListResults( KIO::Job *job, const KIO::UDSEntryList &list ); void processNextResultUrl(); /** * Emits the result and auto-destroys the TrackLoader */ void finish(); private: enum Status { LoadingTracks, MayFinish, Finished }; void mayFinish(); static bool directorySensitiveLessThan( const QUrl &left, const QUrl &right ); Status m_status; const Flags m_flags; int m_timeout; /// passed urls, may contain urls of directories QList m_sourceUrls; /// contains just urls of tracks and playlists QList m_resultUrls; /// a list of playlists directly passed, same semantics as m_resultUrls Playlists::PlaylistList m_resultPlaylists; /// the tracks found Meta::TrackList m_tracks; /// set of unresolved MetaProxy::Tracks that we wait for QSet m_unresolvedTracks; QMutex m_unresolvedTracksMutex; }; Q_DECLARE_OPERATORS_FOR_FLAGS( TrackLoader::Flags ) #endif // AMAROK_TRACKLOADER_H diff --git a/src/core/capabilities/ActionsCapability.h b/src/core/capabilities/ActionsCapability.h index 77278165bf..ba5838223e 100644 --- a/src/core/capabilities/ActionsCapability.h +++ b/src/core/capabilities/ActionsCapability.h @@ -1,79 +1,79 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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_ACTIONSCAPABILITY_H #define AMAROK_ACTIONSCAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" #include #include namespace Capabilities { /** * This capability allows different meta types to display custom actions in the right click menu in the tree view * or anywhere else where the actions are shown. This is useful for purchasing from stores, downloading from services * banning a genre or whatever we can think of in the future. * * If you want to provide this capability for an album, consider using * @see AlbumActionsCapability that provides you with common album actions such as * show cover etc. for free. * * @author Nikolaj Hald Nielsen */ class AMAROKCORE_EXPORT ActionsCapability : public Capabilities::Capability { Q_OBJECT public: /** * Constructor * Note: The actions are not freed after usage * @param actions A list of actions to use. */ explicit ActionsCapability( const QList< QAction* > &actions ); /** * Destructor */ - virtual ~ActionsCapability(); + ~ActionsCapability() override; /** * Get the custom actions for this capability * The caller must free actions that have no parent after use. * Actions with a parent are freed by the parent (obviously) * @return The list of actions */ virtual QList actions() const; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::Actions; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::Actions; } protected: /** * No-action constructor has sense only for subclasses. */ ActionsCapability(); QList< QAction* > m_actions; }; } #endif diff --git a/src/core/capabilities/BookmarkThisCapability.h b/src/core/capabilities/BookmarkThisCapability.h index 570936f154..70e5703292 100644 --- a/src/core/capabilities/BookmarkThisCapability.h +++ b/src/core/capabilities/BookmarkThisCapability.h @@ -1,63 +1,63 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 METABOOKMARKTHISCAPABILITY_H #define METABOOKMARKTHISCAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" #include namespace Capabilities { /** This capability determines whether a meta item in a collection can be directly bookmarked. Not all collections/services supports bookmarks on all levels, and some might not support Item level bookmarks at all as they have no query field and some might only support simple queries. @author Nikolaj Hald Nielsen */ class AMAROKCORE_EXPORT BookmarkThisCapability : public Capability { Q_OBJECT public: explicit BookmarkThisCapability( QAction* action ); - virtual ~BookmarkThisCapability(); + ~BookmarkThisCapability() override; virtual bool isBookmarkable() { return true; } virtual QString browserName() { return QStringLiteral("collections"); } virtual QString collectionName() { return QString(); } virtual bool simpleFiltering() { return false; } /** The caller must free actions that have no parent after use. Actions with a parent are freed by the parent (obviously) @return the bookmarkAction itself (or 0). */ virtual QAction * bookmarkAction() const { return m_action; } /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::BookmarkThis; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::BookmarkThis; } protected: QAction* m_action; }; } #endif diff --git a/src/core/capabilities/BoundedPlaybackCapability.h b/src/core/capabilities/BoundedPlaybackCapability.h index 6f5b04273d..d056f8da6e 100644 --- a/src/core/capabilities/BoundedPlaybackCapability.h +++ b/src/core/capabilities/BoundedPlaybackCapability.h @@ -1,49 +1,49 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 METABOUNDEDPLAYBACKCAPABILITY_H #define METABOUNDEDPLAYBACKCAPABILITY_H #include "core/capabilities/Capability.h" namespace Capabilities { /** A capability for tracks that represents a given, bounded, interval of a url, for instance a single track in a long podcast. @author Nikolaj Hald Nielsen */ class AMAROKCORE_EXPORT BoundedPlaybackCapability : public Capability { Q_OBJECT public: BoundedPlaybackCapability(); - ~BoundedPlaybackCapability(); + ~BoundedPlaybackCapability() override; virtual qint64 startPosition() = 0; virtual qint64 endPosition() = 0; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::BoundedPlayback; ) */ static Type capabilityInterfaceType() { return Capability::BoundedPlayback; } }; } #endif diff --git a/src/core/capabilities/Capability.h b/src/core/capabilities/Capability.h index 3f04feca80..641ce15300 100644 --- a/src/core/capabilities/Capability.h +++ b/src/core/capabilities/Capability.h @@ -1,76 +1,76 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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_CAPABILITY_H #define AMAROK_CAPABILITY_H #include "amarokcore_export.h" #include namespace Capabilities { /** The capabilities are used by several amarok objects to express add on functionality. Capabilities are used inside Amarok to implement a Java-like interface pattern. Several object (Collection, Track, Album) can return capability object. Since the implementation of these objects is in a library usually it would be otherwise difficult to implement something like this. Please note that the capability object will be created on demand and also destroyed. */ class AMAROKCORE_EXPORT Capability : public QObject { Q_OBJECT public: //add additional capabilities here enum Type { Unknown = 0 // not longer used // not longer used , Buyable = 3 , Actions = 4 , EditablePlaylist = 5 , MultiPlayable = 6 , Organisable = 7 , SourceInfo = 8 // not longer used , StreamInfo = 10 // not longer used // not longe used // not longer used , BookmarkThis = 14 , WriteTimecode = 15 , LoadTimecode = 16 , MultiSource = 17 , BoundedPlayback = 18 // not longer used , ReadLabel = 20 , WriteLabel = 21 , FindInSource = 22 , CollectionImport = 23 , CollectionScan = 24 , Transcode = 25 }; Q_ENUM( Type ) - virtual ~Capability(); + ~Capability() override; }; } #endif diff --git a/src/core/capabilities/CollectionImportCapability.h b/src/core/capabilities/CollectionImportCapability.h index 7137cad179..bfc54bb892 100644 --- a/src/core/capabilities/CollectionImportCapability.h +++ b/src/core/capabilities/CollectionImportCapability.h @@ -1,64 +1,64 @@ /**************************************************************************************** * Copyright (c) 2010 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 AMAROK_COLLECTIONIMPORTCAPABILITY_H #define AMAROK_COLLECTIONIMPORTCAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" #include namespace Capabilities { /** * This capability allows the collection to import it's content form a file. * Currently this is only used by the SqlCollection and it's scanner * * @author Ralf Engels */ class AMAROKCORE_EXPORT CollectionImportCapability : public Capabilities::Capability { Q_OBJECT public: CollectionImportCapability(); - virtual ~CollectionImportCapability(); + ~CollectionImportCapability() override; /** Starts importing the given file into the collection. @param input is an already opened input device. The importer will take ownership. @param listener An object that will listen on import signals. Those signals are: trackAdded( Meta::TrackPtr ) trackDiscarded( QString ) trackMatchFound( Meta::TrackPtr, QString ) trackMatchMultiple( Meta::TrackList, QString ) importError( QString ) done( ThreadWeaver::Job* ) showMessage( QString ) @return A QObject that can be used to connect several status signals from. */ virtual void import( QIODevice *input, QObject *listener ) = 0; /** Get the capabilityInterfaceType of this capability @return The capabilityInterfaceType ( always Capabilities::Capability::CollectionImport; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::CollectionImport; } }; } #endif diff --git a/src/core/capabilities/CollectionScanCapability.h b/src/core/capabilities/CollectionScanCapability.h index 7116184670..f1d5ffe475 100644 --- a/src/core/capabilities/CollectionScanCapability.h +++ b/src/core/capabilities/CollectionScanCapability.h @@ -1,69 +1,69 @@ /**************************************************************************************** * Copyright (c) 2010 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 AMAROK_COLLECTIONSCANCAPABILITY_H #define AMAROK_COLLECTIONSCANCAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" namespace Capabilities { /** * This capability allows to initiate a scan on a collection. * Currently only a few collections have this capability and even then it's unclear * Which collections uses the collection folders. * * @author Ralf Engels */ class AMAROKCORE_EXPORT CollectionScanCapability : public Capabilities::Capability { Q_OBJECT public: /** * Constructor */ CollectionScanCapability(); /** * Destructor */ - virtual ~CollectionScanCapability(); + ~CollectionScanCapability() override; /** Begin a full scan on the collection. */ virtual void startFullScan() = 0; /** Begin an incremental scan on the collection. @p directory An optional specification of which directory to scan. If empty the scanner will check all the collections directories set in the Amarok settings */ virtual void startIncrementalScan( const QString &directory = QString() ) = 0; /** Stop a scan on this collection. */ virtual void stopScan() = 0; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::CollectionScan; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::CollectionScan; } }; } #endif diff --git a/src/core/capabilities/FindInSourceCapability.h b/src/core/capabilities/FindInSourceCapability.h index f30c4e1b05..4c1053f9a2 100644 --- a/src/core/capabilities/FindInSourceCapability.h +++ b/src/core/capabilities/FindInSourceCapability.h @@ -1,64 +1,64 @@ /**************************************************************************************** * Copyright (c) 2010 Nikolaj Hald Nielsen * * * * 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 FINDINSOURCECAPABILITY_H #define FINDINSOURCECAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" namespace Capabilities { /** This capability exposes a method that shows this track (or the closest possible parent, such as album) in the source where it was added from. @author Nikolaj Hald Nielsen */ class AMAROKCORE_EXPORT FindInSourceCapability : public Capabilities::Capability { Q_OBJECT Q_FLAGS( TargetTag TargetTags ) public: enum TargetTag { Artist = 0x01, Album = 0x02, Composer = 0x04, Genre = 0x08, Track = 0x10, Year = 0x20 }; - virtual ~FindInSourceCapability(); + ~FindInSourceCapability() override; virtual void findInSource( QFlags tag = Album ) = 0; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::FindInSource; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::FindInSource; } Q_DECLARE_FLAGS( TargetTags, TargetTag ) }; } // namespace Capabilities Q_DECLARE_OPERATORS_FOR_FLAGS( Capabilities::FindInSourceCapability::TargetTags ) #endif // FINDINSOURCECAPABILITY_H diff --git a/src/core/capabilities/MultiPlayableCapability.h b/src/core/capabilities/MultiPlayableCapability.h index 4a164b8253..66f1b4608d 100644 --- a/src/core/capabilities/MultiPlayableCapability.h +++ b/src/core/capabilities/MultiPlayableCapability.h @@ -1,44 +1,44 @@ /**************************************************************************************** * 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_MULTIPLAYABLECAPABILITY_H #define AMAROK_MULTIPLAYABLECAPABILITY_H #include "core/capabilities/Capability.h" #include namespace Capabilities { class AMAROKCORE_EXPORT MultiPlayableCapability : public Capability { Q_OBJECT public: - virtual ~MultiPlayableCapability(); + ~MultiPlayableCapability() override; static Type capabilityInterfaceType() { return Capabilities::Capability::MultiPlayable; } virtual void fetchFirst() = 0; virtual void fetchNext() = 0; Q_SIGNALS: void playableUrlFetched( const QUrl &url ); }; } #endif // AMAROK_MULTIPLAYABLECAPABILITY_H diff --git a/src/core/capabilities/MultiSourceCapability.h b/src/core/capabilities/MultiSourceCapability.h index bf947959cc..56b604de1a 100644 --- a/src/core/capabilities/MultiSourceCapability.h +++ b/src/core/capabilities/MultiSourceCapability.h @@ -1,72 +1,72 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * 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 METAMULTISOURCECAPABILITY_H #define METAMULTISOURCECAPABILITY_H #include "core/capabilities/Capability.h" class QUrl; namespace Capabilities { /** * A capability for tracks that can have several different source urls, such as * multiple fallback streams for a radio station. If one source url fails or finishes, * the track will automatically use the next one. It is also possible to get a list * of all urls that can be presented to the user so tha she can choose. * * @author Nikolaj Hald Nielsen */ class AMAROKCORE_EXPORT MultiSourceCapability : public Capability { Q_OBJECT public: MultiSourceCapability(); - virtual ~MultiSourceCapability(); + ~MultiSourceCapability() override; static Type capabilityInterfaceType() { return MultiSource; } /** * Return list of displayable urls in this MultiSource. Only for display * purposes, don't attempt to play these urls. */ virtual QStringList sources() const = 0; /** * Set current source. Does nothing if @param source is out of bounds. */ virtual void setSource( int source ) = 0; /** * Get index of the current source */ virtual int current() const = 0; /** * Return the url of the next source without actually advancing to it. * Returns empty url if the current source is the last one. */ virtual QUrl nextUrl() const = 0; Q_SIGNALS: void urlChanged( const QUrl &url ); }; } #endif diff --git a/src/core/capabilities/OrganiseCapability.h b/src/core/capabilities/OrganiseCapability.h index 97a141b073..280ed89a9f 100644 --- a/src/core/capabilities/OrganiseCapability.h +++ b/src/core/capabilities/OrganiseCapability.h @@ -1,41 +1,41 @@ /**************************************************************************************** * Copyright (c) 2008 Maximilian Kossick * * * * 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_ORGANISECAPABILITY_H #define AMAROK_ORGANISECAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" namespace Capabilities { class AMAROKCORE_EXPORT OrganiseCapability : public Capabilities::Capability { Q_OBJECT public: - virtual ~OrganiseCapability(); + ~OrganiseCapability() override; static Type capabilityInterfaceType() { return Capabilities::Capability::Organisable; } /** * delete this track from the collection */ virtual void deleteTrack() = 0; //virtual void organiseTrack() = 0; }; } #endif diff --git a/src/core/capabilities/SourceInfoCapability.h b/src/core/capabilities/SourceInfoCapability.h index 837e6bd848..00b780624e 100644 --- a/src/core/capabilities/SourceInfoCapability.h +++ b/src/core/capabilities/SourceInfoCapability.h @@ -1,77 +1,77 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 SOURCEINFOCAPABILITY_H #define SOURCEINFOCAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" class QPixmap; namespace Capabilities { /** This capability allows getting additional information about the source of a meta item. For now, it is intended for allowing the playlist to display a little emblem to let users know if a track is a Magnatune preview track, a lastfm stream or so on... @author Nikolaj Hald Nielsen */ class AMAROKCORE_EXPORT SourceInfoCapability : public Capabilities::Capability{ public: Q_OBJECT public: /** * Constructor */ SourceInfoCapability(); /** * Destructor */ - virtual ~SourceInfoCapability(); + ~SourceInfoCapability() override; /** * Get the human readable name of the source, for instance "Magnatune.com" * @return The name of the source */ virtual QString sourceName() = 0; /** * Get a brief human readable description or the source * @return The source description */ virtual QString sourceDescription() = 0; /** * Get a small 16x16 pixle emblem that represents the source. * @return The source emblem */ virtual QPixmap emblem() = 0; /** * Get a path to a scalable (svg) version of the source emblem. */ virtual QString scalableEmblem() = 0; /** * Get the capabilityInterfaceType of this capability * @return The capabilityInterfaceType ( always Capabilities::Capability::SourceInfo; ) */ static Type capabilityInterfaceType() { return Capabilities::Capability::SourceInfo; } }; } #endif diff --git a/src/core/capabilities/StreamInfoCapability.h b/src/core/capabilities/StreamInfoCapability.h index 04dadd6fa8..3075f9ed2d 100644 --- a/src/core/capabilities/StreamInfoCapability.h +++ b/src/core/capabilities/StreamInfoCapability.h @@ -1,60 +1,60 @@ /**************************************************************************************** * 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 STREAMINFOCAPABILITY_H #define STREAMINFOCAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" #include namespace Capabilities { /** * This capability is designed to provide additional information * about streaming metadata. For meta types that provide multiple * tracks within the same stream (lastfm, shoutcast, etc ) * this capability is designed to return stream metadata, * where the properties in the Meta::Track class refers to the track * being played within the stream. @author Dan Meltzer */ class AMAROKCORE_EXPORT StreamInfoCapability : public Capabilities::Capability { Q_OBJECT public: StreamInfoCapability() {} - virtual ~StreamInfoCapability() {} + ~StreamInfoCapability() override {} /** * The human readable name of this stream * @return A string representing the name of this stream. */ virtual QString streamName() const = 0; /** * The source this stream belongs to. * @return The name of the owning source. */ virtual QString streamSource() const { return QString(); } static Type capabilityInterfaceType() { return Capabilities::Capability::StreamInfo; } }; } #endif diff --git a/src/core/capabilities/TranscodeCapability.h b/src/core/capabilities/TranscodeCapability.h index 46194fbbab..4fb752be74 100644 --- a/src/core/capabilities/TranscodeCapability.h +++ b/src/core/capabilities/TranscodeCapability.h @@ -1,86 +1,86 @@ /**************************************************************************************** * 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 TRANSCODECAPABILITY_H #define TRANSCODECAPABILITY_H #include "core/amarokcore_export.h" #include "core/capabilities/Capability.h" #include "core/transcoding/TranscodingConfiguration.h" #include namespace Capabilities { /** * Collections whose CollectionLocation supports transcoding (e.g. it doesn't ignore * Transcoding::Configuration configuration parameter in copyUrlsToCollection()) * can and should provide this capability so that core CollectionLocation methods can * ask user whether she wants to just copy/move or transcode tracks when * copying/moving/dragging them to destination collection. * * If your collection doesn't support transcoding (not implemented or just * temporarily), you should not (temporarily) provide this capability. * * @author Matěj Laitl */ class AMAROKCORE_EXPORT TranscodeCapability : public Capability { Q_OBJECT public: - virtual ~TranscodeCapability(); + ~TranscodeCapability() override; /** * Return a list of file types (should be compatible with Meta::Track::type()) * that your collection is able to play. This is used to disable transcoding * to formats that wouldn't be playable; if your collection is a portable player * that can only play ogg vorbis and flac, you would return * QStringList() << "ogg" << "flac"; * * In order not to suck users, "plain copy" option is always available * regardless of what this method returns. * * Return value of empty QStringList() is special and means that there should * be no restriction on enabled transcoders. Default implementation returns * this value. */ virtual QStringList playableFileTypes() { return QStringList(); } /** * Return configuration previously saved using setSavedConfiguration() or invalid * configuration if there is no configuration saved. */ virtual Transcoding::Configuration savedConfiguration() = 0; /** * Set saved configuration to @p configuration. An invalid configuration * should be interpreted as an action to unset saved configuration. * * @param configuration the transcoding configuration */ virtual void setSavedConfiguration( const Transcoding::Configuration &configuration ) = 0; /** * Type of this capability */ static Type capabilityInterfaceType() { return Capability::Transcode; } }; } // napespace Capabilities #endif // TRANSCODECAPABILITY_H diff --git a/src/core/collections/Collection.h b/src/core/collections/Collection.h index 3639a6318d..759228b65d 100644 --- a/src/core/collections/Collection.h +++ b/src/core/collections/Collection.h @@ -1,181 +1,181 @@ /**************************************************************************************** * Copyright (c) 2007-2008 Maximilian Kossick * * 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 AMAROK_COLLECTION_H #define AMAROK_COLLECTION_H #include "core/amarokcore_export.h" #include "core/interfaces/MetaCapability.h" #include "core/support/PluginFactory.h" #include "AmarokSharedPointer.h" #include namespace Meta { class Track; typedef AmarokSharedPointer TrackPtr; } namespace Playlists { } class QIcon; namespace Collections { class Collection; class CollectionLocation; class QueryMaker; typedef QList CollectionList; /** A plugin that creates new collections. */ class AMAROKCORE_EXPORT CollectionFactory : public Plugins::PluginFactory { Q_OBJECT public: CollectionFactory(); - virtual ~CollectionFactory(); + ~CollectionFactory() override; Q_SIGNALS: void newCollection( Collections::Collection *newCollection ); }; /** A TrackProvider is a class that can lookup urls and return Track objects. * * A track provider is implemented by every collection, but there * are also a couple of other track providers. * All TrackProvider are managed by the CollectionManager. */ class AMAROKCORE_EXPORT TrackProvider { public: TrackProvider(); virtual ~TrackProvider(); /** * Returns true if this track provider has a chance of providing the * track specified by @p url. * This should do a minimal amount of checking, and return quickly. */ virtual bool possiblyContainsTrack( const QUrl &url ) const; /** * Creates a TrackPtr object for url @p url. Returns a null track Ptr if * it cannot be done. * If asynchronysity is desired it is suggested to return a MetaProxy track here * and have the proxy watch for the real track. */ virtual Meta::TrackPtr trackForUrl( const QUrl &url ); }; class AMAROKCORE_EXPORT Collection : public QObject, public TrackProvider, public MetaCapability { Q_OBJECT public: - virtual ~Collection(); + ~Collection() override; /** * The collection's querymaker * @return A querymaker that belongs to this collection. */ virtual QueryMaker *queryMaker() = 0; /** * The protocol of uids coming from this collection. * @return A string of the protocol, without the :// */ virtual QString uidUrlProtocol() const; /** * @return A unique identifier for this collection */ virtual QString collectionId() const = 0; /** * @return a user visible name for this collection, to be displayed in the collectionbrowser and elsewhere */ virtual QString prettyName() const = 0; /** * @return an icon representing this collection */ virtual QIcon icon() const = 0; virtual bool hasCapacity() const { return false; } virtual float usedCapacity() const { return 0.0; } virtual float totalCapacity() const { return 0.0; } /** * Create collection location that can be used to copy track to this * collection or to delete collection tracks. If you don't call * prepare{Move,Copy,Remove} on it, you must delete it after use. */ virtual Collections::CollectionLocation *location(); /** * Return true if this collection can be written to (tracks added, removed). * Convenience short-cut for calling CollectionLocation's isWritable. */ virtual bool isWritable() const; /** * Return true if user can choose track file path within this collection. * Convenience short-cut for calling CollectionLocation's isOrganizable. */ virtual bool isOrganizable() const; Q_SIGNALS: /** * Once you register a collection with CollectionManager, this signal is the * only way to safely destroy it. CollectionManger will remove this collection * from the list of active ones and will destroy this collection after some * time. */ void remove(); /** * This signal must be emitted when the collection contents has changed * significantly. * * More specifically, you must Q_EMIT this signal (only) in such situations: * a) the set of entities (tracks, albums, years, ...) in this collection has * changed: a track was added, album is renamed, year was removed... * b) the relationship between the entities has changed: the track changed * album, album is no longer associated to an album artist and became a * compilation, an alum changed its year... * * You should not Q_EMIT this signal when some minor data of an entity change, * for example when a track comment changes, etc. * * Also note there are \::notifyObservers() methods of various entities. * \::notifyObservers() and Collection::updated() are perpendicular and * responsibility to call one of these may and may not mean need to call the * other. * * This signal specifically this means that previous done searches can no * longer be considered valid. */ void updated(); }; } Q_DECLARE_METATYPE( Collections::Collection* ) Q_DECLARE_METATYPE( Collections::CollectionList ) #endif /* AMAROK_COLLECTION_H */ diff --git a/src/core/collections/CollectionLocation.h b/src/core/collections/CollectionLocation.h index c0eaf406a7..96e5cbeb47 100644 --- a/src/core/collections/CollectionLocation.h +++ b/src/core/collections/CollectionLocation.h @@ -1,439 +1,439 @@ /**************************************************************************************** * Copyright (c) 2007-2008 Maximilian Kossick * * Copyright (c) 2008 Jason A. Donenfeld * * Copyright (c) 2010 Casey Link * * * * 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_COLLECTIONLOCATION_H #define AMAROK_COLLECTIONLOCATION_H #include "core/amarokcore_export.h" #include "core/meta/forward_declarations.h" #include "core/transcoding/TranscodingConfiguration.h" #include #include #include namespace Collections { class Collection; class QueryMaker; /** This base class defines the methods necessary to allow the copying and moving of tracks between different collections in a generic way. This class should be used as follows in client code: - select a source and a destination CollectionLocation - call prepareCopy or prepareMove on the source CollectionLocation - forget about the rest of the workflow Implementations which are writable must reimplement the following methods - prettyLocation() - isWritable() - remove( Meta::Track ) - copyUrlsToCollection( QMap ) Writable collections that are also organizable should reimplement isOrganizable(). Organizable means that the user is able to decide (to varying degrees, the details depend on the actual collection) where the files are stored in the filesystem (or some kind of VFS). An example would be the local collection, where the user can select the directory structure that Amarok uses to store the files. An example for a writable collection that is not organizable are ipods, where the user has no control about the actual location of the music files (they are automatically stored in a not human-readable form). Implementations which are only readable can reimplement getKIOCopyableUrls( Meta::TrackList ) if it is necessary, but can use the default implementations if possible. Implementations that have a string expressable location(s), such as a URL or path on disk should reimplement actualLocation(). Implementations that need additional information provided by the user have to implement showSourceDialog() and showDestinationDialog(), depending on whether the information is required in the source, the destination, or both. The methods will be called in the following order: startWorkflow (source) showSourceDialog (source) (reimplementable) slotShowSourceDialogDone (source) slotPrepareOperation (destination) showDestinationDialog (destination) (reimplementable) slotShowDestinationDialogDone (destination) slotOperationPrepared (source) getKIOCopyableUrls (source) (reimplementable) slotGetKIOCopyableUrlsDone (source) slotStartCopy (destination) copyUrlsToCollection (destination) (reimplementable) slotCopyOperationFinished (destination) slotFinishCopy (source) To provide removal ability, it is required to reimplement removeUrlsFromCollection, and this function must call slotRemoveOperationFinished() when it is done. Optionally, showRemoveDialog can be reimplemented to customize the warning displayed before a removal, and this function must call slotShowRemoveDialogDone when finished. The methods for remove will be called in the following order: startRemoveWorkflow showRemoveDialog (reimplementable) slotShowRemoveDialogDone slotStartRemove removeUrlsFromCollection (reimplementable) slotRemoveOperationFinished slotFinishRemove */ class AMAROKCORE_EXPORT CollectionLocation : public QObject { Q_OBJECT //testing only do not use these properties in anything but tests Q_PROPERTY( bool removeSources READ getRemoveSources WRITE setRemoveSources DESIGNABLE false SCRIPTABLE false ) public: CollectionLocation(); explicit CollectionLocation( Collections::Collection *parentCollection ); - virtual ~CollectionLocation(); + ~CollectionLocation() override; /** Returns a pointer to the collection location's corresponding collection. @return a pointer to the collection location's corresponding collection */ virtual Collections::Collection *collection() const; /** a displayable string representation of the collection location. use the return value of this method to display the collection location to the user. @return a string representation of the collection location */ virtual QString prettyLocation() const; /** Returns a list of machine usable strings representing the collection location. For example, a local collection would return a list of paths where tracks are stored, while an Ampache collection would return a list with one string containing the URL of an ampache server. An iPod collection and a MTP device collection are examples of collections that do not need to reimplement this method. */ virtual QStringList actualLocation() const; /** Returns whether the collection location is writable or not. For example, a local collection or an ipod collection would return true, a daap collection or a service collection false. The value returned by this method indicates if it is possible to copy tracks to the collection, and if it is generally possible to remove/delete files from the collection. @return @c true if the collection location is writable @return @c false if the collection location is not writable */ virtual bool isWritable() const; /** Returns whether the collection is organizable or not. Organizable collections allow move operations where the source and destination collection are the same. @return @c true if the collection location is organizable, false otherwise */ virtual bool isOrganizable() const; /** Convenience method for copying a single track. @see prepareCopy( Meta::TrackList, CollectionLocation* ) */ void prepareCopy( const Meta::TrackPtr &track, CollectionLocation *destination ); /** Schedule copying of @p tracks to collection location @p destination. This method takes ownership of the @p destination, you may not reference or delete it after this call. This method returns immediately and the actual copy is performed in the event loop and/or another thread. @param tracks tracks @param destination the collection location destination */ void prepareCopy( const Meta::TrackList &tracks, CollectionLocation *destination ); /** Convenience method for copying tracks based on QueryMaker results, takes ownership of the @p qm. @param qm the QueryMaker query @param destination the collection destination @see prepareCopy( Meta::TrackList, CollectionLocation* ) */ void prepareCopy( Collections::QueryMaker *qm, CollectionLocation *destination ); /** * Convenience method for moving a single track. * @see prepareMove( Meta::TrackList, CollectionLocation* ) */ void prepareMove( const Meta::TrackPtr &track, CollectionLocation *destination ); /** Schedule moving of @p tracks to collection location @p destination. This method takes ownership of the @p destination, you may not reference or delete it after this call. This method returns immediately and the actual move is performed in the event loop and/or another thread. @param tracks tracks @param destination the collection location destination */ void prepareMove( const Meta::TrackList &tracks, CollectionLocation *destination ); /** Convenience method for moving tracks based on QueryMaker results, takes ownership of the @p qm. @param qm the QueryMaker query @param destination the collection destination @see prepareMove( Meta::TrackList, CollectionLocation* ) */ void prepareMove( Collections::QueryMaker *qm, CollectionLocation *destination ); /** Starts workflow for removing tracks. */ void prepareRemove( const Meta::TrackList &tracks ); /** Convenience method for removing tracks selected by QueryMaker, takes ownership of the @p qm. @param qm the QueryMaker query @see prepareRemove( Meta::TrackList ) */ void prepareRemove( Collections::QueryMaker *qm ); /** * Adds or merges a track to the collection (not to the disk) * Inserts a set of TrackPtrs directly into the database without needing to actual move any files * @param track track * @param path path * This is a hack required by the DatabaseImporter * TODO: Remove this hack * @return true if the database entry was inserted, false otherwise */ virtual bool insert( const Meta::TrackPtr &track, const QString &path ); /** explicitly inform the source collection of successful transfer. The source collection will only remove files (if necessary) for which this method was called. @param track track */ void transferSuccessful( const Meta::TrackPtr &track ); /** * tells the source location that an error occurred during the transfer of the file * @param track track * @param error error */ virtual void transferError( const Meta::TrackPtr &track, const QString &error ); Q_SIGNALS: void startCopy( const QMap &sources, const Transcoding::Configuration & ); void finishCopy(); void startRemove(); void finishRemove(); void prepareOperation( const Meta::TrackList &tracks, bool removeSources, const Transcoding::Configuration & ); void operationPrepared(); void aborted(); protected: /** * aborts the workflow */ void abort(); /** * allows the destination location to access the source CollectionLocation. * note: subclasses do not take ownership of the pointer */ CollectionLocation* source() const; /** * allows the source location to access the destination CollectionLocation. * Pointer may be null! * note: subclasses do not take ownership of the pointer */ CollectionLocation* destination() const; /** this method is called on the source location, and should return a list of urls which the destination location can copy using KIO. You must call slotGetKIOCopyableUrlsDone( QMap ) after retrieving the urls. The order of urls passed to that method has to be the same as the order of the tracks passed to this method. */ virtual void getKIOCopyableUrls( const Meta::TrackList &tracks ); /** this method is called on the destination. reimplement it if your implementation is writable. You must call slotCopyOperationFinished() when you are done copying the files. Before calling slotCopyOperationFinished(), you should call source()->transferSuccessful() for every source track that was for sure successfully copied to destination collection. Only such marked tracks are then removed in case of a "move" action. */ virtual void copyUrlsToCollection( const QMap &sources, const Transcoding::Configuration &configuration ); /** this method is called on the collection you want to remove tracks from. it must be reimplemented if your collection is writable and you wish to implement removing tracks. You must call slotRemoveOperationFinished() when you are done removing the files. Before calling slotRemoveOperationFinished(), you should call transferSuccessful() for every track that was successfully deleted. CollectionLocation then scans directories of such tracks and allows user to remove empty ones. */ virtual void removeUrlsFromCollection( const Meta::TrackList &sources ); /** * this method is called on the source. It allows the source CollectionLocation to * show a dialog. Classes that reimplement this method must call * slotShowSourceDialogDone() after they have acquired all necessary information from the user. * * Default implementation calls getDestinationTranscodingConfig() which may ask * user. If you reimplement this you may (or not) call this base method instead * of calling slotShowDestinationDialogDone() to support transcoding. */ virtual void showSourceDialog( const Meta::TrackList &tracks, bool removeSources ); /** * Get transcoding configuration to use when transferring tracks to destination. * If destination collection doesn't support transcoding, JUST_COPY configuration * is returned, otherwise preferred configuration is read or user is asked. * Returns invalid configuration in case user has hit cancel or closed the dialog. * * This method is meant to be called by source collection. */ virtual Transcoding::Configuration getDestinationTranscodingConfig(); /** * This method is called on the destination. It allows the destination * CollectionLocation to show a dialog. Classes that reimplement this method * must call slotShowDestinationDialogDone() after they have acquired all necessary * information from the user. * * Default implementation calls setGoingToRemoveSources( removeSources ) so that * isGoingToRemoveSources() is available on destination, too and then calls * slotShowDestinationDialogDone() */ virtual void showDestinationDialog( const Meta::TrackList &tracks, bool removeSources, const Transcoding::Configuration &configuration ); /** * this methods allows the collection to show a warning dialog before tracks are removed, * rather than using the default provided. Classes that reimplement this method must call * slotShowRemoveDialogDone() after they are finished. */ virtual void showRemoveDialog( const Meta::TrackList &tracks ); /** * Get nice localised string describing the current operation based on transcoding * configuration and isGoingToRemoveSources(); meant to be called by destination * collection. * * @return "Copy Tracks", "Transcode and Organize Tracks" etc. */ QString operationText( const Transcoding::Configuration &configuration ); /** * Get nice localised string that can be used as progress bar text for the current * operation; meant to be called by the destination collection. * * @param configuration the transcoding configuration * @param trackCount number of tracks in the transfer * @param destinationName pretty localised name of the destination collection; * prettyLocation() is used if the string is empty or not specified * * @return "Transcoding and moving tracks to " etc. */ QString operationInProgressText( const Transcoding::Configuration &configuration, int trackCount, QString destinationName = QString() ); /** * Sets or gets whether some source files may be removed */ virtual bool isGoingToRemoveSources() const; virtual void setGoingToRemoveSources( bool removeSources ); /** * Sets or gets whether to stifle the removal confirmation */ virtual bool isHidingRemoveConfirm() const; virtual void setHidingRemoveConfirm( bool hideRemoveConfirm ); protected Q_SLOTS: /** * this slot has to be called from getKIOCopyableUrls( Meta::TrackList ) * Please note: the order of urls in the argument has to be the same as in the * tracklist */ void slotGetKIOCopyableUrlsDone( const QMap &sources ); void slotCopyOperationFinished(); void slotRemoveOperationFinished(); void slotShowSourceDialogDone(); void slotShowRemoveDialogDone(); void slotShowDestinationDialogDone(); private Q_SLOTS: void slotShowSourceDialog(); // trick to show dialog in next mainloop iteration void slotPrepareOperation( const Meta::TrackList &tracks, bool removeSources, const Transcoding::Configuration &configuration ); void slotOperationPrepared(); void slotStartCopy( const QMap &sources, const Transcoding::Configuration &configuration ); void slotFinishCopy(); void slotStartRemove(); void slotFinishRemove(); void slotAborted(); void resultReady( const Meta::TrackList &tracks ); void queryDone(); private: void setupConnections(); void setupRemoveConnections(); void startWorkflow( const Meta::TrackList &tracks, bool removeSources ); void startRemoveWorkflow( const Meta::TrackList &tracks ); void removeSourceTracks( const Meta::TrackList &tracks ); void setSource( CollectionLocation *source ); //only used in the source CollectionLocation CollectionLocation *m_destination; //only used in destination CollectionLocation CollectionLocation *m_source; Meta::TrackList getSourceTracks() const { return m_sourceTracks; } void setSourceTracks( const Meta::TrackList &tracks ) { m_sourceTracks = tracks; } Meta::TrackList m_sourceTracks; Collections::Collection *m_parentCollection; bool getRemoveSources() const { return m_removeSources; } void setRemoveSources( bool removeSources ) { m_removeSources = removeSources; } bool m_removeSources; bool m_isRemoveAction; bool m_noRemoveConfirmation; Transcoding::Configuration m_transcodingConfiguration; //used by the source collection to store the tracks that were successfully //copied by the destination and can be removed as part of a move Meta::TrackList m_tracksSuccessfullyTransferred; QMap m_tracksWithError; }; } //namespace Collections #endif diff --git a/src/core/collections/MetaQueryMaker.h b/src/core/collections/MetaQueryMaker.h index 293e9d45cc..caf1cbb435 100644 --- a/src/core/collections/MetaQueryMaker.h +++ b/src/core/collections/MetaQueryMaker.h @@ -1,81 +1,81 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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 COLLECTION_METAQUERYMAKER_H #define COLLECTION_METAQUERYMAKER_H #include "core/collections/QueryMaker.h" #include "core/collections/Collection.h" #include #include namespace Collections { class AMAROKCORE_EXPORT MetaQueryMaker : public QueryMaker { Q_OBJECT public: explicit MetaQueryMaker( const QList &collections ); explicit MetaQueryMaker( const QList &queryMakers ); - ~MetaQueryMaker(); + ~MetaQueryMaker() override; void run() override; void abortQuery() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addReturnValue( qint64 value) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy( qint64 value, bool descending = false ) override; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::YearPtr &year ) override; QueryMaker* addMatch( const Meta::LabelPtr &label ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* limitMaxResultSize( int size ) override; QueryMaker* beginAnd() override; QueryMaker* beginOr() override; QueryMaker* endAndOr() override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override; private Q_SLOTS: void slotQueryDone(); private: QList builders; int m_queryDoneCount; QMutex m_queryDoneCountMutex; }; } //namespace Collections #endif /* COLLECTION_METAQUERYMAKER_H */ diff --git a/src/core/collections/QueryMaker.h b/src/core/collections/QueryMaker.h index 1c07af32a8..50050644c3 100644 --- a/src/core/collections/QueryMaker.h +++ b/src/core/collections/QueryMaker.h @@ -1,249 +1,249 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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_COLLECTION_QUERYMAKER_H #define AMAROK_COLLECTION_QUERYMAKER_H #include "core/amarokcore_export.h" #include "core/meta/forward_declarations.h" #include "core/meta/support/MetaConstants.h" #include #include #include namespace Collections { class AMAROKCORE_EXPORT QueryMaker : public QObject { Q_OBJECT public: enum AlbumQueryMode { AllAlbums, OnlyCompilations , OnlyNormalAlbums }; enum LabelQueryMode { NoConstraint, OnlyWithLabels, OnlyWithoutLabels }; enum ArtistMatchBehaviour { TrackArtists, AlbumArtists, AlbumOrTrackArtists }; /** * Filters that the QueryMaker accepts for searching. * not all implementations will accept all filter levels, so make it possible to * specify which ones make sense for a given qm. Add to this as needed */ enum ValidFilters { TitleFilter = 1, AlbumFilter = 2, ArtistFilter = 4, AlbumArtistFilter = 8, GenreFilter = 16, ComposerFilter = 32, YearFilter = 64, UrlFilter = 128, AllFilters = 65535 }; enum ReturnFunction { Count, Sum, Max, Min }; enum NumberComparison { Equals, GreaterThan, LessThan }; enum QueryType { None, // Set to facilitate using this in subclasses Track, Artist, Album, AlbumArtist, Genre, Composer, Year, Custom, Label }; QueryMaker(); - virtual ~QueryMaker(); + ~QueryMaker() override; /** * starts the query. This method returns immediately. All processing is done in one or more * separate worker thread(s). One of the newResultReady signals will be emitted at least once, * followed by the queryDone() signal exactly once. */ virtual void run() = 0; /** * aborts a running query. Calling this method aborts a running query as soon as possible. * This method returns immediately. No signals will be emitted after calling this method. * This method has no effect if no query is running. */ virtual void abortQuery() = 0; /** * Sets the type of objects the querymaker will query for. These are mutually * exclusive. The results of the query will be returned as objects of the * appropriate type, therefore it is necessary to connect the client to the * newResultReady( Meta::Type ) signal * * if you set QueryType custom, this starts a custom query. Unlike other query types, you have to set up the return * values yourself using addReturnValue( qint64 ) and addReturnFunction(). The results will * be returned as a QStringList. Therefore you have to connect to the * newResultReady( QStringList ) signal to receive the results. * @return this */ virtual QueryMaker* setQueryType( QueryType type ) = 0; /** * only works after starting a custom query with setQueryType( Custom ) * Use this to inform the query maker you are looking for results of type @p value. * @param value the type of the results * @return this */ virtual QueryMaker* addReturnValue( qint64 value ) = 0; /** * Returns the output of the function specified by function. * Only works after starting a custom query * @return this */ virtual QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) = 0; /** * Return results sorted by @p value. * @return this */ virtual QueryMaker* orderBy( qint64 value, bool descending = false ) = 0; virtual QueryMaker* addMatch( const Meta::TrackPtr &track ) = 0; /** * Match given artist. Depending on @param behaviour matches: * @p track artist if TrackArtists is given, * @p album artist if AlbumArtists is given, * any of track or album artist if AlbumOrTrackArtists is given. * * By default matches only track artist. * @param artist the track artist. */ virtual QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) = 0; virtual QueryMaker* addMatch( const Meta::AlbumPtr &album ) = 0; virtual QueryMaker* addMatch( const Meta::ComposerPtr &composer ) = 0; virtual QueryMaker* addMatch( const Meta::GenrePtr &genre ) = 0; virtual QueryMaker* addMatch( const Meta::YearPtr &year ) = 0; virtual QueryMaker* addMatch( const Meta::LabelPtr &label ); /** * Add a filter of type @p value and value @p filter. The querymaker applies this to all queries. * @param value the type of the filter * @param filter the text to match * @param matchBegin If set then wildcard match the beginning of @p text (*text) * @param matchEnd If set then wildcard match the end of @p text (text*) * @return this */ virtual QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) = 0; /** * Exclude filter of type @p value and value @p filter. The querymaker applies this to all queries. * @param value the type of the filter * @param filter the text to match * @param matchBegin If set then wildcard match the beginning of @p text (*text) * @param matchEnd If set then wildcard match the end of @p text (text*) * @return this */ virtual QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) = 0; virtual QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) = 0; virtual QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) = 0; /** * limit the maximum number of items in a result. the result will have [0..@p size ] items. When this function * is not used, the result size is unbounded. Note: the maximum size applies to each result individually, so if * the newResultReady signal is emitted multiple times, each result may have up to @p size items. */ virtual QueryMaker* limitMaxResultSize( int size ) = 0; /** * select the mode for querying albums. If this method is not called, * QueryMaker defaults to AlbumQueryMode::AllAlbums. */ virtual QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ); /** * Sets the label query mode. This method restricts a query to tracks * that have labels assigned to them, no labels assigned to them, or no constraint. * The default is no constraint. * @param mode The LabelQueryMode that will be used by the query. * @see LabelQueryMode */ virtual QueryMaker* setLabelQueryMode( LabelQueryMode mode ); virtual QueryMaker* beginAnd() = 0; virtual QueryMaker* beginOr() = 0; virtual QueryMaker* endAndOr() = 0; /** * Choose whether the query maker instance should delete itself after the query. * By passing true the query maker instance will delete itself after emitting queryDone(). * Otherwise it is the responsibility of the owner (the code which called \::queryMaker() usually) to delete the instance * when it is not needed anymore. * * Defaults to false, i.e. the querymaker instance will not delete itself. */ QueryMaker* setAutoDelete( bool autoDelete ); virtual int validFilterMask(); Q_SIGNALS: /** * newResultReady will be emitted every time new results from the query maker are received. * This signal can be emitted zero times (in case of no results) one (the usual case) or multiple times * (e.g. in case when the result is received in several batches). * The results will be terminated by a queryDone signal. */ void newResultReady( const QStringList &); void newTracksReady( const Meta::TrackList &); void newArtistsReady( const Meta::ArtistList &); void newAlbumsReady( const Meta::AlbumList &); void newGenresReady( const Meta::GenreList &); void newComposersReady( const Meta::ComposerList &); void newYearsReady( const Meta::YearList &); void newLabelsReady( const Meta::LabelList &); void newDataReady( const Meta::DataList &); /** * This signal is emitted after all the results have been submitted via zero or more newResultReady signals. */ void queryDone(); }; } //namespace Collections Q_DECLARE_METATYPE( Collections::QueryMaker* ) #endif /* AMAROK_COLLECTION_QUERYMAKER_H */ diff --git a/src/core/meta/Base.h b/src/core/meta/Base.h index 4210825278..3069ad3c8b 100644 --- a/src/core/meta/Base.h +++ b/src/core/meta/Base.h @@ -1,121 +1,121 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Ian Monroe * * Copyright (c) 2008 Mark Kretschmann * * Copyright (c) 2013 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 META_BASE_H #define META_BASE_H #include "core/amarokcore_export.h" #include "core/interfaces/MetaCapability.h" #include "core/meta/forward_declarations.h" #include #include #include namespace Meta { class Observer; class AMAROKCORE_EXPORT Base : public virtual QSharedData, public MetaCapability // virtual inherit. so that implementations can be both Meta::Track and Meta::Statistics { public: Base(); - virtual ~Base(); + ~Base() override; /** * The textual label for this object. * * For a track this is the track title, for an album it is the album name. * If the name is unknown or unset then this returns an empty string. */ virtual QString name() const = 0; /** * This is a nicer representation of the object. * * We will try to prevent this name from being empty. E.g. a track will fall * back to the filename if possible. */ virtual QString prettyName() const { return name(); } /** * A name that can be used for sorting. * * This should usually mean that "The Beatles" is returned as "Beatles, The" */ virtual QString sortableName() const { return name(); } protected: /** * Helper so that notifyObservers() implementation can be shared. Template * parameter Obs is just Observer, we add it so that Observer.h doesn't need * to be included in this header. */ template void notifyObserversHelper( const T *self ) const; private: // no copy allowed, since it's not safe with observer list Q_DISABLE_COPY( Base ) friend class Observer; // so that Observer can call (un)subscribe() /** * Subscribe @param observer for change updates. Don't ever think of calling * this method yourself or overriding it, it's highly coupled with Observer. */ void subscribe( Observer *observer ); /** * Unsubscribe @param observer from change updates. Don't ever think of * calling this method yourself or overriding it, it's highly coupled with * Observer. */ void unsubscribe( Observer *observer ); QSet m_observers; mutable QReadWriteLock m_observersLock; // guards access to m_observers }; template void Base::notifyObserversHelper( const T *self ) const { // observers ale allowed to remove themselves during metadataChanged() call. That's // why the lock needs to be recursive AND the lock needs to be for writing, because // a lock for reading cannot be recursively relocked for writing. QWriteLocker locker( &m_observersLock ); foreach( Obs *observer, m_observers ) { // observers can potentially remove or even destroy other observers during // metadataChanged() call. Guard against it. The guarding doesn't need to be // thread-safe, because we already hold m_observersLock (which is recursive), // so other threads wait on potential unsubscribe(). if( m_observers.contains( observer ) ) observer->metadataChanged( AmarokSharedPointer( const_cast( self ) ) ); } } } Q_DECLARE_METATYPE( Meta::DataPtr ) Q_DECLARE_METATYPE( Meta::DataList ) AMAROKCORE_EXPORT QDebug operator<<( QDebug dbg, const Meta::Base &base ); #endif // META_BASE_H diff --git a/src/core/podcasts/PodcastReader.h b/src/core/podcasts/PodcastReader.h index 7c6bfc0952..f3584e36a1 100644 --- a/src/core/podcasts/PodcastReader.h +++ b/src/core/podcasts/PodcastReader.h @@ -1,389 +1,389 @@ /**************************************************************************************** * Copyright (c) 2007 Bart Cerneels * * 2009 Mathias Panzenböck * * 2013 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 PODCASTREADER_H #define PODCASTREADER_H #include "core/podcasts/PodcastProvider.h" #include "core/podcasts/PodcastMeta.h" #include #include #include #include #include #include class QUrl; class KJob; namespace Podcasts { /** Class that parses a podcast xml file and provides the results to a PodcastProvider. @author Bart Cerneels Mathias Panzenböck */ class AMAROKCORE_EXPORT PodcastReader : public QObject { Q_OBJECT public: /** Create a new PodcastReader that delivers the result to the podcastProvider. Note: the PodcastProvider pointer is not owned by the PodcastReader and must remain valid throughout the lifetime of this object. */ explicit PodcastReader( PodcastProvider *podcastProvider, QObject *parent = nullptr ); - ~PodcastReader(); + ~PodcastReader() override; bool read( QIODevice *device ); bool read( const QUrl &url ); bool update(const PodcastChannelPtr &channel ); QUrl & url() { return m_url; } Podcasts::PodcastChannelPtr channel() { return m_channel; } QXmlStreamReader::Error error () const { return m_xmlReader.error(); } QString errorString () const { return m_xmlReader.errorString(); } Q_SIGNALS: void finished( PodcastReader *podcastReader ); void statusBarSorryMessage( const QString &message ); void statusBarNewProgressOperation( KIO::TransferJob *, const QString &, Podcasts::PodcastReader* ); public Q_SLOTS: virtual void slotAbort(); private Q_SLOTS: void slotRedirection( KIO::Job *job, const QUrl &url ); void slotPermanentRedirection ( KIO::Job * job, const QUrl &fromUrl, const QUrl &toUrl ); void slotAddData( KIO::Job *, const QByteArray & data ); void downloadResult( KJob * ); private: /** these are the keys used by the automata */ enum ElementType { Unknown = 0, Any, Document, CharacterData, Rss, Rdf, Feed, Channel, Item, NewFeedUrl, Image, Link, Author, ItunesAuthor, Url, Title, EnclosureElement, Guid, PubDate, Description, Body, Html, Entry, Subtitle, ItunesSubtitle, Updated, Published, Summary, ItunesSummary, Keywords, ItunesKeywords, Content, SupportedContent, Name, Id, Logo, Icon, Creator, Encoded }; class Action; typedef void (PodcastReader::*ActionCallback)(); typedef QHash ActionMap; class Action { public: explicit Action( ActionMap &actionMap ) : m_actionMap( actionMap ) , m_begin( 0 ) , m_end( 0 ) , m_characters( 0 ) {} Action(ActionMap &actionMap, ActionCallback begin) : m_actionMap( actionMap ) , m_begin( begin ) , m_end( 0 ) , m_characters( 0 ) {} Action(ActionMap &actionMap, ActionCallback begin, ActionCallback end) : m_actionMap( actionMap ) , m_begin( begin ) , m_end( end ) , m_characters( 0 ) {} Action(ActionMap &actionMap, ActionCallback begin, ActionCallback end, ActionCallback characters) : m_actionMap( actionMap ) , m_begin( begin ) , m_end( end ) , m_characters( characters ) {} void begin(PodcastReader *podcastReader) const; void end(PodcastReader *podcastReader) const; void characters(PodcastReader *podcastReader) const; const ActionMap &actionMap() const { return m_actionMap; } private: ActionMap &m_actionMap; ActionCallback m_begin; ActionCallback m_end; ActionCallback m_characters; }; static bool mightBeHtml( const QString& text ); ElementType elementType() const; bool read(); bool continueRead(); void createChannel(); // callback methods for feed parsing: void beginRss(); void beginRdf(); void beginFeed(); void beginHtml(); void beginUnknownFeedType(); void beginEnclosure(); void beginText(); void beginChannel(); void beginItem(); void beginImage(); void beginXml(); void beginNoElement(); void beginAtomText(); void beginAtomFeedLink(); void beginAtomEntryLink(); void beginAtomTextChild(); void endDocument(); void endTitle(); void endSubtitle(); void endDescription(); void endEncoded(); void endBody(); void endLink(); void endGuid(); void endPubDate(); void endItem(); void endImageUrl(); void endKeywords(); void endNewFeedUrl(); void endAuthor(); void endCreator(); void endXml(); void endAtomLogo(); void endAtomIcon(); void endAtomTitle(); void endAtomSubtitle(); void endAtomPublished(); void endAtomUpdated(); void endAtomSummary(); void endAtomContent(); void endAtomTextChild(); // TODO: maybe I can remove readCharacters() and readEscapedCharacters() // and use readAtomTextCharacters() plus setting m_contentType even // in Rss 1.0/2.0 parsers instead. void readCharacters(); void readNoCharacters(); void readEscapedCharacters(); void readAtomTextCharacters(); QDateTime parsePubDate( const QString &datestring ); void stopWithError(const QString &message); static QString unescape( const QString &text ); static QString textToHtml( const QString &text ); QString atomTextAsText(); QString atomTextAsHtml(); QStringRef attribute(const char *namespaceUri, const char *name) const; bool hasAttribute(const char *namespaceUri, const char *name) const; void setDescription(const QString &description); void setSummary(const QString &description); /** podcastEpisodeCheck * Check if this PodcastEpisode has been fetched before. Uses a scoring algorithm. * @return A pointer to a PodcastEpisode that has been fetched before or the \ * same pointer as the argument. */ Podcasts::PodcastEpisodePtr podcastEpisodeCheck( Podcasts::PodcastEpisodePtr episode ); // TODO: move this to PodcastMeta and add a field // descriptionType to PodcastCommonMeta. enum ContentType { TextContent, HtmlContent, XHtmlContent }; class Enclosure { public: Enclosure(const QUrl &url, int filesize, const QString& mimeType) : m_url( url ), m_filesize( filesize ), m_mimeType( mimeType ) {} const QUrl &url() const { return m_url; } int fileSize() const { return m_filesize; } const QString &mimeType() const { return m_mimeType; } private: QUrl m_url; int m_filesize; QString m_mimeType; }; class StaticData { public: StaticData(); // This here basically builds an automata. // This way feed parsing can be paused after any token, // thus enabling paralell download and parsing of multiple // feeds without the need for threads. QHash knownElements; QRegExp removeScripts; QRegExp mightBeHtml; QRegExp linkify; // Actions Action startAction; Action docAction; Action xmlAction; Action skipAction; Action noContentAction; Action rdfAction; // RSS 1.0 Action rssAction; // RSS 2.0 Action feedAction; // Atom Action htmlAction; Action unknownFeedTypeAction; // RSS 1.0+2.0 Action rss10ChannelAction; Action rss20ChannelAction; Action titleAction; Action subtitleAction; Action descriptionAction; Action encodedAction; Action bodyAction; Action linkAction; Action imageAction; Action itemAction; Action urlAction; Action authorAction; Action creatorAction; Action enclosureAction; Action guidAction; Action pubDateAction; Action keywordsAction; Action newFeedUrlAction; // Atom Action atomLogoAction; Action atomIconAction; Action atomEntryAction; Action atomTitleAction; Action atomSubtitleAction; Action atomAuthorAction; Action atomFeedLinkAction; Action atomEntryLinkAction; Action atomIdAction; Action atomPublishedAction; Action atomUpdatedAction; Action atomSummaryAction; Action atomContentAction; Action atomTextAction; // ActionMaps ActionMap rootMap; ActionMap skipMap; ActionMap noContentMap; ActionMap xmlMap; ActionMap docMap; ActionMap rssMap; ActionMap rdfMap; ActionMap feedMap; ActionMap rss10ChannelMap; ActionMap rss20ChannelMap; ActionMap imageMap; ActionMap itemMap; ActionMap textMap; ActionMap atomEntryMap; ActionMap atomAuthorMap; ActionMap atomTextMap; }; static const StaticData sd; QXmlStreamReader m_xmlReader; QUrl m_url; PodcastProvider *m_podcastProvider; KIO::TransferJob *m_transferJob; Podcasts::PodcastChannelPtr m_channel; Podcasts::PodcastEpisodePtr m_item; /** This points to the data of the current channel or (if parsing an item) the data of the current item */ Podcasts::PodcastMetaCommon *m_current; // this somewhat emulates a callstack (without local variables): QStack m_actionStack; ContentType m_contentType; QString m_buffer; QList m_enclosures; }; } //namespace Podcasts #endif diff --git a/src/core/storage/StorageFactory.h b/src/core/storage/StorageFactory.h index 9a65c2852e..2d7696819b 100644 --- a/src/core/storage/StorageFactory.h +++ b/src/core/storage/StorageFactory.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2014 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 AMAROK_STORAGE_FACTORY_H #define AMAROK_STORAGE_FACTORY_H #include "core/amarokcore_export.h" #include "core/support/PluginFactory.h" #include #include class SqlStorage; /** A plugin that provides a Storage object. * * The storage plugin is the only part of Amarok that actually needs to be * a plugin since we are linking two libraries (MySqlClient and MySqlEmbedded) * that have the same symbols. * */ class AMAROKCORE_EXPORT StorageFactory : public Plugins::PluginFactory { Q_OBJECT public: StorageFactory(); - virtual ~StorageFactory(); + ~StorageFactory() override; Q_SIGNALS: /** Emitted whenever the factory produces a new storage. * */ void newStorage( QSharedPointer newStorage ); /** * The factories will not Q_EMIT the newStorage signal in case * of initialization problems. * In order to report their issues they will instead Q_EMIT * newError with the list of errors. */ void newError( const QStringList &errorMessageList ); }; #endif /* AMAROK_STORAGE_FACTORY_H */ diff --git a/src/core/support/PluginFactory.h b/src/core/support/PluginFactory.h index b33e449cd3..92471a70e1 100644 --- a/src/core/support/PluginFactory.h +++ b/src/core/support/PluginFactory.h @@ -1,65 +1,65 @@ /**************************************************************************************** * Copyright (c) 2010 Rick W. Chen * * * * 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_PLUGINFACTORY_H #define AMAROK_PLUGINFACTORY_H #include "core/amarokcore_export.h" #include #include namespace Plugins { /** Baseclass for Amarok plugins. * * This class is subclassed for the different type of Amarok plugins. * - CollectionPlugin * - ServicePlugin * - ImportPlugin * - StoragePlugin * */ class AMAROKCORE_EXPORT PluginFactory : public QObject { Q_OBJECT public: PluginFactory(); - virtual ~PluginFactory() = 0; + ~PluginFactory() override = 0; /** Initialize the service plugin of this type. * * Reimplemented by subclasses, which must set * m_initialized = true when the function has finished. * * This function is called by the PluginManager after * setting the plugin in the different sub-plugin managers * */ virtual void init() = 0; protected: bool m_initialized; }; } // namespace Plugins #define AmarokPluginFactory_iid "org.kde.amarok.plugin_factory" Q_DECLARE_INTERFACE( Plugins::PluginFactory, AmarokPluginFactory_iid ) #endif /* AMAROK_PLUGINFACTORY_H */ diff --git a/src/core/transcoding/TranscodingController.h b/src/core/transcoding/TranscodingController.h index 7d9de57b23..5cb8f9d747 100644 --- a/src/core/transcoding/TranscodingController.h +++ b/src/core/transcoding/TranscodingController.h @@ -1,75 +1,75 @@ /**************************************************************************************** * Copyright (c) 2010 Téo Mrnjavac * * * * 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 TRANSCODING_CONTROLLER_H #define TRANSCODING_CONTROLLER_H #include "core/amarokcore_export.h" #include "core/support/Components.h" #include "core/transcoding/TranscodingDefines.h" #include "core/transcoding/TranscodingFormat.h" #include #include #include #include #include namespace Transcoding { /** * Singleton class that handles and wraps around the Transcoding architecture. * @author Téo Mrnjavac */ class AMAROKCORE_EXPORT Controller : public QObject { Q_OBJECT public: explicit Controller( QObject *parent = nullptr ); - ~Controller(); + ~Controller() override; /** * Return set of all encoders, available or not. */ QSet allEncoders() const { return m_formats.uniqueKeys().toSet(); } /** * Return a set of all available encoders. You can use @see format() to get all * available formats. */ QSet availableEncoders() const { return m_availableEncoders; } /** * Return pointer to format that encodes using @p encoder. You must ensure that * @param encoder is in @see allEncoders(). Always returns non-null pointer which * remains owned by Transcoding::Controller. */ Format *format( Encoder encoder ) const; private Q_SLOTS: void onAvailabilityVerified( int exitCode, QProcess::ExitStatus exitStatus ); private: QMap m_formats; // due to Format being polymorphic, we must store pointers QSet m_availableEncoders; }; } //namespace Transcoding #endif //TRANSCODING_CONTROLLER_H diff --git a/src/covermanager/CoverFetchQueue.h b/src/covermanager/CoverFetchQueue.h index a1f3348983..e6246c0509 100644 --- a/src/covermanager/CoverFetchQueue.h +++ b/src/covermanager/CoverFetchQueue.h @@ -1,104 +1,104 @@ /**************************************************************************************** * Copyright (c) 2009 Rick W. Chen * * * * 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_COVERFETCHQUEUE_H #define AMAROK_COVERFETCHQUEUE_H #include "core/meta/forward_declarations.h" #include "CoverFetchUnit.h" #include #include #include #include #include typedef QList< CoverFetchUnit::Ptr > CoverFetchUnitList; /** * A queue that creates and keeps track of cover fetching units. * This queue creates cover fetch units with suitable payloads as requested by * the cover fetcher. It does not manage the state of those units, as in, what * to do next after each of those units is completed. The cover fetcher is * responsible for coordinating that. */ class CoverFetchQueue : public QObject { Q_OBJECT public: explicit CoverFetchQueue( QObject *parent = nullptr ); - ~CoverFetchQueue(); + ~CoverFetchQueue() override; /** * Add an album-associated work unit to the queue. * @param album album to fetch cover for. * @param opt cover fetch option. * @param src cover image source. * @param xml xml document from the cover provider. Can be empty on first * pass of the fetching process. */ void add( const Meta::AlbumPtr &album, const CoverFetch::Option opt = CoverFetch::Automatic, const CoverFetch::Source src = CoverFetch::LastFm, const QByteArray &xml = QByteArray() ); /** * Add a work unit to the queue that does not need to associate with any album. * @param opt cover fetch option. * @param src cover image source. * @param xml xml document from the cover provider. Can be empty on first * pass of the fetching process. */ void add( const CoverFetch::Option opt = CoverFetch::WildInteractive, const CoverFetch::Source src = CoverFetch::LastFm, const QByteArray &xml = QByteArray() ); /** * Add a string query to the queue. * @param query text to be used for image search. * @param src the image provider to search. * @param page the page number to jump to. * @param album optional album this query is associated with */ void addQuery( const QString &query, const CoverFetch::Source src = CoverFetch::LastFm, unsigned int page = 0, const Meta::AlbumPtr &album = Meta::AlbumPtr(0) ); void clear(); public Q_SLOTS: void remove( const CoverFetchUnit::Ptr &unit ); void remove( const Meta::AlbumPtr &album ); Q_SIGNALS: void fetchUnitAdded( CoverFetchUnit::Ptr ); private: void add( const CoverFetchUnit::Ptr &unit ); bool contains( const Meta::AlbumPtr &album ) const; int index( const Meta::AlbumPtr &album ) const; const CoverFetchUnit::Ptr take( const Meta::AlbumPtr &album ); CoverFetchUnitList m_queue; Q_DISABLE_COPY( CoverFetchQueue ) }; #endif /* AMAROK_COVERFETCHQUEUE_H */ diff --git a/src/covermanager/CoverFetchUnit.h b/src/covermanager/CoverFetchUnit.h index ae03723775..6b735d6292 100644 --- a/src/covermanager/CoverFetchUnit.h +++ b/src/covermanager/CoverFetchUnit.h @@ -1,227 +1,227 @@ /**************************************************************************************** * Copyright (c) 2009 Rick W. Chen * * * * 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_COVERFETCHUNIT_H #define AMAROK_COVERFETCHUNIT_H #include "core/meta/Meta.h" // for AlbumPtr default argument #include "AmarokSharedPointer.h" #include #include #include class CoverFetchPayload; class CoverFetchSearchPayload; namespace CoverFetch { enum Option { Automatic, //!< Automatically save cover for the specified album, if one is found Interactive, //!< Opens a dialog for the user to decide, and add more searches if desired WildInteractive //!< As @ref Interactive, but without filtering results (used for web search) }; enum ImageSize { NormalSize, //!< Normal cover size, for storage and display ThumbSize //!< Thumbnail size, for icon views }; enum Source { Discogs, //!< Use Discogs as provider for cover images Google, //!< Use Google image search as provider LastFm, //!< Use Last.fm as provider for cover images }; typedef QHash Metadata; typedef QHash Urls; } /** * A work unit for the cover fetcher queue. */ class CoverFetchUnit : public QSharedData { public: typedef AmarokSharedPointer< CoverFetchUnit > Ptr; CoverFetchUnit( const Meta::AlbumPtr &album, const CoverFetchPayload *payload, CoverFetch::Option opt = CoverFetch::Automatic ); CoverFetchUnit( const CoverFetchPayload *payload, CoverFetch::Option opt ); explicit CoverFetchUnit( const CoverFetchSearchPayload *payload ); ~CoverFetchUnit(); Meta::AlbumPtr album() const; const QStringList &errors() const; CoverFetch::Option options() const; const CoverFetchPayload *payload() const; bool isInteractive() const; template< typename T > void addError( const T &error ); bool operator==( const CoverFetchUnit &other ) const; bool operator!=( const CoverFetchUnit &other ) const; private: Meta::AlbumPtr m_album; QStringList m_errors; CoverFetch::Option m_options; const CoverFetchPayload *m_payload; Q_DISABLE_COPY( CoverFetchUnit ) }; /** * An abstract class for preparing URLs suitable for fetching album covers from * Last.fm. */ class CoverFetchPayload { public: enum Type { Info, Search, Art }; CoverFetchPayload( const Meta::AlbumPtr &album, enum Type type, const CoverFetch::Source src ); virtual ~CoverFetchPayload(); Meta::AlbumPtr album() const; CoverFetch::Source source() const; enum Type type() const; const CoverFetch::Urls &urls() const; protected: const CoverFetch::Source m_src; CoverFetch::Urls m_urls; QString sanitizeQuery( const QString &query ); const QString sourceString() const; const QString &method() const { return m_method; } bool isPrepared() const; virtual void prepareUrls() = 0; private: Meta::AlbumPtr m_album; const QString m_method; enum Type m_type; Q_DISABLE_COPY( CoverFetchPayload ) }; /** * Prepares URL suitable for getting an album's info from Last.fm. */ class CoverFetchInfoPayload : public CoverFetchPayload { public: explicit CoverFetchInfoPayload( const Meta::AlbumPtr &album, const CoverFetch::Source src ); explicit CoverFetchInfoPayload( const CoverFetch::Source src, const QByteArray &xml ); ~CoverFetchInfoPayload() override; protected: void prepareUrls() override; private: void prepareDiscogsUrls( const QByteArray &data ); Q_DISABLE_COPY( CoverFetchInfoPayload ) }; /** * Prepares URL for searching albums on Last.fm using wild mode. * See \ref CoverFetch::WildInteractive mode. */ class CoverFetchSearchPayload : public CoverFetchPayload { public: explicit CoverFetchSearchPayload( const QString &query = QString(), const CoverFetch::Source src = CoverFetch::LastFm, unsigned int page = 0, const Meta::AlbumPtr &album = Meta::AlbumPtr() ); - ~CoverFetchSearchPayload(); + ~CoverFetchSearchPayload() override; QString query() const; protected: void prepareUrls() override; private: const unsigned int m_page; const QString m_query; Q_DISABLE_COPY( CoverFetchSearchPayload ) }; /** * Prepares URL suitable for getting an album's cover from Last.fm. */ class CoverFetchArtPayload : public CoverFetchPayload { public: explicit CoverFetchArtPayload( const Meta::AlbumPtr &album, const CoverFetch::ImageSize size = CoverFetch::NormalSize, const CoverFetch::Source src = CoverFetch::LastFm, bool wild = false ); explicit CoverFetchArtPayload( const CoverFetch::ImageSize size, const CoverFetch::Source src = CoverFetch::LastFm, bool wild = false ); - ~CoverFetchArtPayload(); + ~CoverFetchArtPayload() override; bool isWild() const; CoverFetch::ImageSize imageSize() const; void setXml( const QByteArray &xml ); protected: void prepareUrls() override; private: CoverFetch::ImageSize m_size; QString m_xml; /// search is wild mode? bool m_wild; /// lower, remove whitespace, and do Unicode normalization on a QString QString normalize( const QString &raw ); /// lower, remove whitespace, and do Unicode normalization on a QStringList QStringList normalize( const QStringList &rawList ); /// prepare urls from xml provided by Discogs void prepareDiscogsUrls( QXmlStreamReader &xml ); /// prepare urls from xml provided by Last.fm void prepareLastFmUrls( QXmlStreamReader &xml ); /// prepare urls from xml provided by Google Image Search void prepareGoogleUrls(); /// gets the value of the first available key from hash QString firstAvailableValue( const QStringList &keys, const QHash &hash ); Q_DISABLE_COPY( CoverFetchArtPayload ) }; Q_DECLARE_METATYPE( CoverFetchUnit::Ptr ) #endif /* AMAROK_COVERFETCHUNIT_H */ diff --git a/src/covermanager/CoverFetcher.h b/src/covermanager/CoverFetcher.h index f985d093ae..8b1b35efc3 100644 --- a/src/covermanager/CoverFetcher.h +++ b/src/covermanager/CoverFetcher.h @@ -1,116 +1,116 @@ /**************************************************************************************** * Copyright (c) 2004 Mark Kretschmann * * Copyright (c) 2004 Stefan Bogner * * Copyright (c) 2007 Dan Meltzer * * Copyright (c) 2009 Martin Sandsmark * * * * 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_COVERFETCHER_H #define AMAROK_COVERFETCHER_H #include "core/meta/forward_declarations.h" #include "CoverFetchUnit.h" #include "network/NetworkAccessManagerProxy.h" #include #include //baseclass #include #include //stack allocated class CoverFetchQueue; class CoverFoundDialog; class QThread; namespace KIO { class Job; } class CoverFetcher : public QObject { Q_OBJECT public: AMAROK_EXPORT static CoverFetcher* instance(); AMAROK_EXPORT static void destroy(); AMAROK_EXPORT void manualFetch( Meta::AlbumPtr album ); AMAROK_EXPORT void queueAlbum( Meta::AlbumPtr album ); AMAROK_EXPORT void queueAlbums( Meta::AlbumList albums ); QStringList errors() const { return m_errors; } enum FinishState { Success, Error, NotFound, Cancelled }; public Q_SLOTS: AMAROK_EXPORT void queueQuery( const Meta::AlbumPtr &album, const QString &query, int page = 0 ); Q_SIGNALS: void finishedSingle( int state ); private Q_SLOTS: /// Fetch a cover void slotFetch( CoverFetchUnit::Ptr unit ); /// Handle result of a fetch job void slotResult( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); /// Cover found dialog is closed by the user void slotDialogFinished(); /// The fetch request was redirected. void fetchRequestRedirected( QNetworkReply *oldReply, QNetworkReply *newReply ); private: static CoverFetcher* s_instance; CoverFetcher(); - ~CoverFetcher(); + ~CoverFetcher() override; /// Remove a fetch unit from the queue, and clean up any running jobs void abortFetch( const CoverFetchUnit::Ptr &unit ); void queueQueryForAlbum( Meta::AlbumPtr album ); CoverFetchQueue *m_queue; //!< current fetch queue QThread *m_queueThread; QHash< QUrl, CoverFetchUnit::Ptr > m_urls; QHash< const CoverFetchUnit::Ptr, QImage > m_selectedImages; QStringList m_errors; QPointer m_dialog; /// cleanup depending on the fetch result void finish( const CoverFetchUnit::Ptr &unit, FinishState state = Success, const QString &message = QString() ); /// Show the cover that has been found void showCover( const CoverFetchUnit::Ptr &unit, const QImage &cover = QImage(), const CoverFetch::Metadata &data = CoverFetch::Metadata() ); void handleCoverPayload( const CoverFetchUnit::Ptr &unit, const QByteArray &data, const QUrl &url ); CoverFetch::Source fetchSource() const; }; namespace The { inline CoverFetcher *coverFetcher() { return CoverFetcher::instance(); } } #endif /* AMAROK_COVERFETCHER_H */ diff --git a/src/covermanager/CoverFoundDialog.h b/src/covermanager/CoverFoundDialog.h index 12703d9eb9..4d6523fc35 100644 --- a/src/covermanager/CoverFoundDialog.h +++ b/src/covermanager/CoverFoundDialog.h @@ -1,187 +1,187 @@ /**************************************************************************************** * Copyright (c) 2004 Mark Kretschmann * * Copyright (c) 2004 Stefan Bogner * * Copyright (c) 2007 Dan Meltzer * * Copyright (c) 2009 Martin Sandsmark * * * * 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_COVERFOUNDDIALOG_H #define AMAROK_COVERFOUNDDIALOG_H #include "core/meta/forward_declarations.h" #include "covermanager/CoverFetchUnit.h" #include "network/NetworkAccessManagerProxy.h" #include "widgets/BoxWidget.h" #include #include #include #include #include #include class CoverFoundItem; class CoverFoundSideBar; class QDialog; class KJob; class KComboBox; class QListWidget; class QPushButton; class BoxWidget; class QTabWidget; class CoverFoundDialog : public QDialog { Q_OBJECT public: explicit CoverFoundDialog( const CoverFetchUnit::Ptr &unit, const CoverFetch::Metadata &data = CoverFetch::Metadata(), QWidget *parent = nullptr ); - ~CoverFoundDialog(); + ~CoverFoundDialog() override; /** * @returns the currently selected cover image */ const QImage image() const { return m_image; } void setQueryPage( int page ); const CoverFetchUnit::Ptr unit() const { return m_unit; } Q_SIGNALS: void newCustomQuery( Meta::AlbumPtr album, const QString &query, int page ); public Q_SLOTS: void add( const QImage &cover, const CoverFetch::Metadata &metadata, const CoverFetch::ImageSize imageSize = CoverFetch::NormalSize ); protected: void hideEvent( QHideEvent *event ) override; protected Q_SLOTS: void slotButtonClicked( int button ); private Q_SLOTS: void addToCustomSearch( const QString &text ); void clearQueryButtonClicked(); void clearView(); void downloadProgressed( qint64 bytesReceived, qint64 bytesTotal ); void fetchRequestRedirected( QNetworkReply *oldReply, QNetworkReply *newReply ); void handleFetchResult( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void insertComboText( const QString &text ); void currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous ); void itemDoubleClicked( QListWidgetItem *item ); void itemMenuRequested( const QPoint &pos ); void processCurrentQuery(); // Same as processQuery( QString() ) void display(); ///< Opens a pixmap viewer void processQuery( const QString &input = QString() ); void saveAs(); void selectDiscogs(); void selectLastFm(); void selectGoogle(); void sortingTriggered( bool checked ); void updateSearchButton( const QString &text ); private: void addToView( CoverFoundItem *item ); bool contains( const CoverFetch::Metadata &metadata ) const; bool fetchBigPix(); ///< returns true if full-size image is fetched successfully void sortCoversBySize(); void updateGui(); void updateTitle(); CoverFoundSideBar *m_sideBar; //!< View of selected cover and its metadata KComboBox *m_search; //!< Custom search input QListWidget *m_view; //!< View of retrieved covers QPushButton *m_save; //!< Save Button QPushButton *m_searchButton; //!< Button to start search or get more results for last query Meta::AlbumPtr m_album; //!< Album associated with @ref m_unit; QAction *m_sortAction; //!< Action to sort covers by size QList< int > m_sortSizes; //!< List of sorted cover sizes used for indexing QImage m_image; //!< Currently selected cover image QString m_query; //!< Cache for the last entered custom query bool m_isSorted; //!< Are the covers sorted in the view? bool m_sortEnabled; //!< Sort covers by size const CoverFetchUnit::Ptr m_unit; //!< Cover fetch unit that initiated this dialog int m_queryPage; //!< Cache for the page number associated with @ref m_query QHash m_urls; //!< Urls hash for network access manager proxy QPointer m_dialog; //!< Progress dialog for fetching big pix Q_DISABLE_COPY( CoverFoundDialog ) }; class CoverFoundSideBar : public BoxWidget { Q_OBJECT public: explicit CoverFoundSideBar( const Meta::AlbumPtr &album, QWidget *parent = nullptr ); - ~CoverFoundSideBar(); + ~CoverFoundSideBar() override; public Q_SLOTS: void clear(); void setPixmap( const QPixmap &pixmap, const CoverFetch::Metadata &metadata ); void setPixmap( const QPixmap &pixmap ); private: Meta::AlbumPtr m_album; QLabel *m_notes; QLabel *m_cover; QPixmap m_pixmap; QTabWidget *m_tabs; QWidget *m_metaTable; CoverFetch::Metadata m_metadata; void updateNotes(); void updateMetaTable(); void clearMetaTable(); Q_DISABLE_COPY( CoverFoundSideBar ) }; class CoverFoundItem : public QListWidgetItem { public: explicit CoverFoundItem( const QImage &cover, const CoverFetch::Metadata &data, const CoverFetch::ImageSize imageSize = CoverFetch::NormalSize, QListWidget *parent = nullptr ); - ~CoverFoundItem(); + ~CoverFoundItem() override; const CoverFetch::Metadata metadata() const { return m_metadata; } const QImage bigPix() const { return m_bigPix; } const QImage thumb() const { return m_thumb; } bool hasBigPix() const { return !m_bigPix.isNull(); } void setBigPix( const QImage &image ) { m_bigPix = image; } bool operator==( const CoverFoundItem &other ) const; bool operator!=( const CoverFoundItem &other ) const; private: void setCaption(); CoverFetch::Metadata m_metadata; QImage m_thumb; QImage m_bigPix; Q_DISABLE_COPY( CoverFoundItem ) }; #endif /* AMAROK_COVERFOUNDDIALOG_H */ diff --git a/src/covermanager/CoverManager.h b/src/covermanager/CoverManager.h index e80bbdc196..ff223226a4 100644 --- a/src/covermanager/CoverManager.h +++ b/src/covermanager/CoverManager.h @@ -1,188 +1,188 @@ /**************************************************************************************** * Copyright (c) 2004 Pierpaolo Di Panfilo * * Copyright (c) 2007 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 COVERMANAGER_H #define COVERMANAGER_H #include "core/meta/Observer.h" #include "covermanager/CoverFetcher.h" #include #include #include #include #include #include namespace Amarok { class LineEdit; } class CompoundProgressBar; class CoverViewItem; class QTreeWidget; class QTreeWidgetItem; class KSqueezedTextLabel; class QPushButton; class QMenu; class QLabel; class CoverView; class QHBoxLayout; class QHBoxLayout; class QColorGroup; class QSplitter; class CoverManager : public QDialog, public Meta::Observer { Q_OBJECT static CoverManager *s_instance; static bool s_constructed; public: explicit CoverManager( QWidget *parent = nullptr ); - ~CoverManager(); + ~CoverManager() override; static bool isConstructed() { return s_constructed; } static CoverManager *instance() { return s_instance; } static void showOnce( const QString &artist = QString(), QWidget* parent = nullptr ); static void viewCover( const Meta::AlbumPtr &album, QWidget* parent = nullptr ); void setStatusText(const QString &text ); // Reimplemented from Meta::Observer using Observer::metadataChanged; void metadataChanged( const Meta::AlbumPtr &album ) override; public Q_SLOTS: void updateStatusBar(); void delayedDestruct(); private: enum View { AllAlbums = 0, AlbumsWithCover, AlbumsWithoutCover }; private Q_SLOTS: void slotArtistQueryResult( Meta::ArtistList artists ); void slotContinueConstruction(); void slotArtistSelected(); void slotAlbumQueryResult( const Meta::AlbumList &albums ); void slotAlbumFilterTriggered( QAction *action ); void slotArtistQueryDone(); void coverItemClicked( QListWidgetItem *item ); void slotSetFilter(); void slotSetFilterTimeout(); void slotShowAllAlbums() { changeView( AllAlbums ); } void slotShowAlbumsWithCover() { changeView( AlbumsWithCover ); } void slotShowAlbumsWithoutCover() { changeView( AlbumsWithoutCover ); } void changeView( View id, bool force = false ); void fetchMissingCovers(); void updateFetchingProgress( int state ); void stopFetching(); void progressAllDone(); void cancelCoverViewLoading(); private: void loadCover( const QString &, const QString & ); QSplitter *m_splitter; QTreeWidget *m_artistView; CoverView *m_coverView; //hack to have something to show while the real list is hidden when loading thumbnails CoverView *m_coverViewSpacer; Amarok::LineEdit *m_searchEdit; QPushButton *m_fetchButton; QPushButton *m_viewButton; QMenu *m_viewMenu; View m_currentView; Meta::ArtistList m_artistList; QList< QTreeWidgetItem* > m_items; Meta::AlbumList m_albumList; CoverFetcher *m_fetcher; QAction *m_selectAllAlbums; QAction *m_selectAlbumsWithCover; QAction *m_selectAlbumsWithoutCover; //status bar widgets CompoundProgressBar *m_progress; KSqueezedTextLabel *m_statusLabel; QString m_oldStatusText; QTimer *m_timer; //search filter timer QList m_coverItems; //used for filtering QString m_filter; // Used by fetchCoversLoop() for temporary storage Meta::AlbumList m_fetchCovers; //used to display information about cover fetching in the status bar bool m_fetchingCovers; int m_coversFetched; int m_coverErrors; bool m_isLoadingCancelled; }; class CoverView : public QListWidget { Q_OBJECT public: explicit CoverView( QWidget *parent = nullptr, const char *name = 0, Qt::WindowFlags f = {} ); protected: void contextMenuEvent( QContextMenuEvent *event ) override; private Q_SLOTS: void setStatusText( QListWidgetItem *item ); }; class CoverViewItem : public QListWidgetItem { public: CoverViewItem( QListWidget *parent, Meta::AlbumPtr album ); - ~CoverViewItem(); + ~CoverViewItem() override; void loadCover(); bool hasCover() const; bool canRemoveCover() const { return !m_embedded && hasCover(); } QString artist() const { return m_artist; } QString album() const { return m_album; } Meta::AlbumPtr albumPtr() const { return m_albumPtr; } protected: void paintFocus(QPainter *, const QColorGroup &) { } void dragEntered(); void dragLeft(); private: Meta::AlbumPtr m_albumPtr; QString m_artist; QString m_album; QString m_coverImagePath; bool m_embedded; }; #endif diff --git a/src/databaseimporter/SqlBatchImporter.h b/src/databaseimporter/SqlBatchImporter.h index a24c5ae40c..dca8a2a711 100644 --- a/src/databaseimporter/SqlBatchImporter.h +++ b/src/databaseimporter/SqlBatchImporter.h @@ -1,79 +1,79 @@ /**************************************************************************************** * Copyright (c) 2010 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 AMAROK_SQLBATCH_IMPORTER_H #define AMAROK_SQLBATCH_IMPORTER_H #include #include "core/meta/forward_declarations.h" class SqlBatchImporterConfig; /** * This importer will use the CollectionImportCapability to import a file. * Currently only used for the SqlCollection. */ class SqlBatchImporter : public QObject { Q_OBJECT public: explicit SqlBatchImporter( QObject *parent ); - ~SqlBatchImporter(); + ~SqlBatchImporter() override; SqlBatchImporterConfig *configWidget( QWidget *parent ); /** * @return whether the importer is running */ bool importing() const; /** * Starts the importing process */ void startImporting(); /** * @returns the number of tracks imported */ int importedCount() const; Q_SIGNALS: void importFailed(); void importSucceeded(); void importError( const QString& ); void showMessage( const QString& ); void trackAdded( Meta::TrackPtr ); void trackDiscarded( const QString& ); void trackMatchFound( Meta::TrackPtr, const QString& ); void trackMatchMultiple( Meta::TrackList, const QString& ); protected: void import(); protected Q_SLOTS: void importingFinished(); void trackImported( const Meta::TrackPtr &track ); void trackMatched( const Meta::TrackPtr &track, const QString &oldUrl ); private: SqlBatchImporterConfig *m_config; int m_count; bool m_importing; }; #endif // multiple inclusion guard diff --git a/src/databaseimporter/SqlBatchImporterConfig.h b/src/databaseimporter/SqlBatchImporterConfig.h index e806ca8e26..259d5e599d 100644 --- a/src/databaseimporter/SqlBatchImporterConfig.h +++ b/src/databaseimporter/SqlBatchImporterConfig.h @@ -1,41 +1,41 @@ /**************************************************************************************** * Copyright (c) 2010 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 AMAROK_SQLBATCH_IMPORTER_CONFIG_H #define AMAROK_SQLBATCH_IMPORTER_CONFIG_H #include "widgets/BoxWidget.h" #include #include class QLineEdit; class SqlBatchImporterConfig : public BoxWidget { Q_OBJECT public: explicit SqlBatchImporterConfig( QWidget *parent = nullptr ); - virtual ~SqlBatchImporterConfig() { } + ~SqlBatchImporterConfig() override { } QString inputFilePath() const; private: QLineEdit *m_inputFilePathInput; }; #endif diff --git a/src/dbus/mpris2/DBusAmarokApp.h b/src/dbus/mpris2/DBusAmarokApp.h index a79b593878..ebffb4582c 100644 --- a/src/dbus/mpris2/DBusAmarokApp.h +++ b/src/dbus/mpris2/DBusAmarokApp.h @@ -1,47 +1,47 @@ /*********************************************************************** * Copyright 2012 Alex Merry * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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_DBUS_AMAROKAPP_H #define AMAROK_DBUS_AMAROKAPP_H #include "DBusAbstractAdaptor.h" #include #include namespace Amarok { class DBusAmarokApp : public DBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.amarok.App") public: explicit DBusAmarokApp( QObject* parent ); - ~DBusAmarokApp(); + ~DBusAmarokApp() override; public Q_SLOTS: void ShowOSD() const; void LoadThemeFile( const QString &path ); }; } #endif // AMAROK_DBUS_AMAROKAPP_H diff --git a/src/dbus/mpris2/MediaPlayer2.h b/src/dbus/mpris2/MediaPlayer2.h index ab746011f1..a1db2358dc 100644 --- a/src/dbus/mpris2/MediaPlayer2.h +++ b/src/dbus/mpris2/MediaPlayer2.h @@ -1,69 +1,69 @@ /*********************************************************************** * Copyright 2012 Eike Hein * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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_MEDIAPLAYER2_H #define AMAROK_MEDIAPLAYER2_H #include "DBusAbstractAdaptor.h" #include namespace Amarok { class MediaPlayer2 : public DBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2") // Docs: http://www.mpris.org/2.1/spec/Root_Node.html Q_PROPERTY(bool CanRaise READ CanRaise) Q_PROPERTY(bool CanQuit READ CanQuit) Q_PROPERTY(bool CanSetFullscreen READ CanSetFullscreen) Q_PROPERTY(bool Fullscreen READ Fullscreen) Q_PROPERTY(bool HasTrackList READ HasTrackList) Q_PROPERTY(QString Identity READ Identity) Q_PROPERTY(QString DesktopEntry READ DesktopEntry) Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes) Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes) public: explicit MediaPlayer2(QObject* parent); - ~MediaPlayer2(); + ~MediaPlayer2() override; bool CanRaise() const; bool CanQuit() const; bool CanSetFullscreen() const; bool Fullscreen() const; bool HasTrackList() const; QString Identity() const; QString DesktopEntry() const; QStringList SupportedUriSchemes() const; QStringList SupportedMimeTypes() const; public Q_SLOTS: void Raise() const; void Quit() const; }; } #endif // AMAROK_MEDIAPLAYER2_H diff --git a/src/dbus/mpris2/MediaPlayer2AmarokExtensions.h b/src/dbus/mpris2/MediaPlayer2AmarokExtensions.h index 069c10ce05..5778556fd7 100644 --- a/src/dbus/mpris2/MediaPlayer2AmarokExtensions.h +++ b/src/dbus/mpris2/MediaPlayer2AmarokExtensions.h @@ -1,54 +1,54 @@ /*********************************************************************** * Copyright 2012 Alex Merry * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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_MEDIAPLAYER2AMAROKEXTENSIONS_H #define AMAROK_MEDIAPLAYER2AMAROKEXTENSIONS_H #include "DBusAbstractAdaptor.h" #include #include namespace Amarok { class MediaPlayer2AmarokExtensions : public DBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.amarok.Mpris2Extensions.Player") Q_PROPERTY( bool Muted READ Muted WRITE setMuted ) public: explicit MediaPlayer2AmarokExtensions( QObject* parent ); - ~MediaPlayer2AmarokExtensions(); + ~MediaPlayer2AmarokExtensions() override; bool Muted() const; void setMuted( bool muted ); public Q_SLOTS: void StopAfterCurrent(); void AdjustVolume( double IncreaseBy ); private Q_SLOTS: void mutedChanged( bool newValue ); }; } #endif // AMAROK_MEDIAPLAYER2AMAROKEXTENSIONS_H diff --git a/src/dbus/mpris2/MediaPlayer2Player.h b/src/dbus/mpris2/MediaPlayer2Player.h index 03a95dd2da..f57385b022 100644 --- a/src/dbus/mpris2/MediaPlayer2Player.h +++ b/src/dbus/mpris2/MediaPlayer2Player.h @@ -1,116 +1,116 @@ /*********************************************************************** * Copyright 2012 Eike Hein * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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_MEDIAPLAYER2PLAYER_H #define AMAROK_MEDIAPLAYER2PLAYER_H #include "DBusAbstractAdaptor.h" #include "core/meta/forward_declarations.h" #include #include #include namespace Amarok { class MediaPlayer2Player : public DBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.Player") // Docs: http://www.mpris.org/2.1/spec/Player_Node.html Q_PROPERTY( QString PlaybackStatus READ PlaybackStatus ) Q_PROPERTY( QString LoopStatus READ LoopStatus WRITE setLoopStatus ) Q_PROPERTY( double Rate READ Rate WRITE setRate ) Q_PROPERTY( bool Shuffle READ Shuffle WRITE setShuffle ) Q_PROPERTY( QVariantMap Metadata READ Metadata ) Q_PROPERTY( double Volume READ Volume WRITE setVolume ) Q_PROPERTY( qlonglong Position READ Position ) Q_PROPERTY( double MinimumRate READ MinimumRate ) Q_PROPERTY( double MaximumRate READ MaximumRate ) Q_PROPERTY( bool CanGoNext READ CanGoNext ) Q_PROPERTY( bool CanGoPrevious READ CanGoPrevious ) Q_PROPERTY( bool CanPlay READ CanPlay ) Q_PROPERTY( bool CanPause READ CanPause ) Q_PROPERTY( bool CanSeek READ CanSeek ) Q_PROPERTY( bool CanControl READ CanControl ) public: explicit MediaPlayer2Player( QObject* parent ); - ~MediaPlayer2Player(); + ~MediaPlayer2Player() override; QString PlaybackStatus() const; QString LoopStatus() const; void setLoopStatus( const QString& loopStatus ) const; double Rate() const; void setRate( double rate ) const; bool Shuffle() const; void setShuffle( bool shuffle ) const; QVariantMap Metadata() const; double Volume() const; void setVolume( double volume ) const; qlonglong Position() const; double MinimumRate() const; double MaximumRate() const; bool CanGoNext() const; bool CanGoPrevious() const; bool CanPlay() const; bool CanPause() const; bool CanSeek() const; bool CanControl() const; Q_SIGNALS: void Seeked( qlonglong Position ) const; public Q_SLOTS: void Next() const; void Previous() const; void Pause() const; void PlayPause() const; void Stop() const; void Play() const; void Seek( qlonglong Offset ) const; void SetPosition( const QDBusObjectPath& TrackId, qlonglong Position ) const; void OpenUri( const QString &Uri ) const; private Q_SLOTS: void trackPositionChanged( qint64 position, bool userSeek ); void trackChanged( const Meta::TrackPtr &track ); void trackMetadataChanged( const Meta::TrackPtr &track ); void albumMetadataChanged( const Meta::AlbumPtr &album ); void seekableChanged( bool seekable ); void volumeChanged( int newVolPercent ); void trackLengthChanged( qint64 milliseconds ); void playbackStateChanged(); void playlistNavigatorChanged(); void playlistRowsInserted(const QModelIndex &, int, int ); void playlistRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int ); void playlistRowsRemoved(const QModelIndex &, int, int ); void playlistReplaced(); void playlistActiveTrackChanged( quint64 ); private: QVariantMap metadataForTrack( const Meta::TrackPtr &track ) const; qint64 m_lastPosition; }; } #endif // AMAROK_MEDIAPLAYER2PLAYER_H diff --git a/src/dbus/mpris2/Mpris2.h b/src/dbus/mpris2/Mpris2.h index 10f8681824..c5c7b59156 100644 --- a/src/dbus/mpris2/Mpris2.h +++ b/src/dbus/mpris2/Mpris2.h @@ -1,38 +1,38 @@ /*********************************************************************** * Copyright 2012 Eike Hein * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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_MPRIS2_H #define AMAROK_MPRIS2_H #include namespace Amarok { class Mpris2 : public QObject { Q_OBJECT public: explicit Mpris2( QObject *parent = nullptr ); - ~Mpris2(); + ~Mpris2() override; }; } #endif // AMAROK_MPRIS2_H diff --git a/src/dialogs/CollectionSetup.h b/src/dialogs/CollectionSetup.h index 5ac83d8818..b53af82372 100644 --- a/src/dialogs/CollectionSetup.h +++ b/src/dialogs/CollectionSetup.h @@ -1,145 +1,145 @@ /**************************************************************************************** * Copyright (c) 2003 Scott Wheeler * * Copyright (c) 2004 Max Howell * * Copyright (c) 2004-2008 Mark Kretschmann * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2013 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 AMAROK_COLLECTIONSETUP_H #define AMAROK_COLLECTIONSETUP_H #include #include "core/support/Debug.h" #include "ui_CollectionConfig.h" class QAction; class QCheckBox; namespace CollectionFolder { class Model; } class CollectionSetup : public QWidget { Q_OBJECT friend class CollectionFolder::Model; public: static CollectionSetup* instance() { return s_instance; } explicit CollectionSetup( QWidget* ); - virtual ~CollectionSetup() {} + ~CollectionSetup() override {} void writeConfig(); bool hasChanged() const; bool recursive() const; bool monitor() const; const QString modelFilePath( const QModelIndex &index ) const; Transcoding::SelectConfigWidget *transcodingConfig() const { return m_ui.transcodingConfig; } Q_SIGNALS: void changed(); private Q_SLOTS: void importCollection(); /** Shows a context menu if the right mouse button is pressed over a directory. */ void slotPressed( const QModelIndex &index ); void slotRescanDirTriggered(); private: /** Returns true if the given path is contained in the primary collection * @author Peter Zhou */ bool isDirInCollection( const QString& path ) const; static CollectionSetup* s_instance; Ui::CollectionConfig m_ui; CollectionFolder::Model *m_model; QAction *m_rescanDirAction; /** This is the directory where the rescanDirAction was triggered */ QString m_currDir; QCheckBox *m_recursive; QCheckBox *m_monitor; }; namespace CollectionFolder //just to keep it out of the global namespace { class Model : public QFileSystemModel { public: explicit Model( QObject *parent ); Qt::ItemFlags flags( const QModelIndex &index ) const override; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override; int columnCount( const QModelIndex& ) const override { return 1; } /** Set the currently checked directories according to dirs */ void setDirectories(const QStringList &dirs ); /** Returns the currently checked directories in this model. */ QStringList directories() const; private: bool isForbiddenPath( const QString &path ) const; /** Returns true if one of the parent paths is checked. */ bool ancestorChecked( const QString &path ) const; /** * Get a list of all checked paths that are an ancestor of * the given path. */ QStringList allCheckedAncestors( const QString &path ) const; /** Returns true if at least one of the subpaths are checked */ bool descendantChecked( const QString &path ) const; /** * Check the logical recursive difference of root and excludePath and * updates m_checked. * For example, if excludePath is a grandchild of root, then this method * will check all of the children of root except the one that is the * parent of excludePath, as well as excludePath's siblings. */ void checkRecursiveSubfolders( const QString &root, const QString &excludePath ); inline bool recursive() const { // Simply for convenience return CollectionSetup::instance() && CollectionSetup::instance()->recursive(); } static inline QString normalPath( const QString &path ) { return path.endsWith( QLatin1Char('/') ) ? path : path + QLatin1Char('/'); } QSet m_checked; }; } // end namespace CollectionFolder #endif diff --git a/src/dialogs/DatabaseImporterDialog.h b/src/dialogs/DatabaseImporterDialog.h index 57d99817df..b83f212045 100644 --- a/src/dialogs/DatabaseImporterDialog.h +++ b/src/dialogs/DatabaseImporterDialog.h @@ -1,64 +1,64 @@ /**************************************************************************************** * Copyright (c) 2008 Seb Ruiz * * * * 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_DATABASEIMPORTERDIALOG_H #define AMAROK_DATABASEIMPORTERDIALOG_H #include //baseclass #include "core/meta/forward_declarations.h" #include #include class QPlainTextEdit; class KPageWidgetItem; class BoxWidget; class SqlBatchImporter; class SqlBatchImporterConfig; class DatabaseImporterDialog : public KAssistantDialog { Q_OBJECT public: explicit DatabaseImporterDialog( QWidget *parent = nullptr ); - ~DatabaseImporterDialog(); + ~DatabaseImporterDialog() override; private Q_SLOTS: void importFailed(); void importSucceeded(); void importError( const QString &error ); void importedTrack( Meta::TrackPtr track ); void discardedTrack( const QString &url ); void matchedTrack(Meta::TrackPtr track, const QString &oldUrl ); void ambigousTrack( const Meta::TrackList &tracks, const QString &oldUrl ); void pageChanged( KPageWidgetItem *current, KPageWidgetItem *before ); void showMessage( const QString &message ); private: SqlBatchImporter *m_importer; SqlBatchImporterConfig *m_importerConfig; BoxWidget *m_configBox; KPageWidgetItem *m_selectImporterPage; KPageWidgetItem *m_configPage; KPageWidgetItem *m_resultsPage; QPlainTextEdit *m_results; }; #endif diff --git a/src/dialogs/EditFilterDialog.h b/src/dialogs/EditFilterDialog.h index 26bf8eef20..ff96ea8050 100644 --- a/src/dialogs/EditFilterDialog.h +++ b/src/dialogs/EditFilterDialog.h @@ -1,86 +1,86 @@ /**************************************************************************************** * Copyright (c) 2006 Giovanni Venturi * * Copyright (c) 2010 Ralf Engels * * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * * * * 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_EDITFILTERDIALOG_H #define AMAROK_EDITFILTERDIALOG_H #include "core/meta/forward_declarations.h" #include "widgets/MetaQueryWidget.h" #include "widgets/TokenPool.h" #include #include namespace Ui { class EditFilterDialog; } class EditFilterDialog : public QDialog { Q_OBJECT public: explicit EditFilterDialog( QWidget* parent, const QString &text = QString() ); - virtual ~EditFilterDialog(); + ~EditFilterDialog() override; QString filter(); Q_SIGNALS: void filterChanged( const QString &filter ); private Q_SLOTS: void slotTokenSelected( Token *token ); void slotTokenDestroyed( QObject *token ); void slotAttributeChanged( const MetaQueryWidget::Filter &filter ); void slotInvert( bool checked ); void slotSeparatorChange(); void slotSearchEditChanged( const QString &filterText ); void slotReset(); void accept() override; void updateAttributeEditor(); void updateSearchEdit(); /** Parses the given text and set's the dropTarget accordingly. */ void updateDropTarget( const QString &filterText ); private: void initTokenPool(); Token *tokenForField( const qint64 field ); struct Filter { MetaQueryWidget::Filter filter; bool inverted; }; Filter &filterForToken( Token *token ); Ui::EditFilterDialog *m_ui; Token *m_curToken; QMap< Token *, Filter > m_filters; QString m_separator; /** True if we are already updating the status. This blocks recursive calls to updateWidgets or parsteTextFilters. */ bool m_isUpdating; }; #endif /* AMAROK_EDITFILTERDIALOG_H */ diff --git a/src/dialogs/EqualizerDialog.h b/src/dialogs/EqualizerDialog.h index 621c17d371..3d8cd971fa 100644 --- a/src/dialogs/EqualizerDialog.h +++ b/src/dialogs/EqualizerDialog.h @@ -1,85 +1,85 @@ /**************************************************************************************** * Copyright (c) 2004-2009 Mark Kretschmann * * Copyright (c) 2009 Artur Szymiec * * Copyright (c) 2013 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 EQUALIZERDIALOG_H #define EQUALIZERDIALOG_H #include "ui_EqualizerDialog.h" #include #include class EqualizerDialog : public QDialog, public Ui_EqualizerDialog { Q_OBJECT public: - ~EqualizerDialog(); + ~EqualizerDialog() override; static void showOnce( QWidget *parent = nullptr ); /** Returns the untranslated current preset name. */ QString selectedPresetName() const; /** Returns the current gain settings */ QList gains() const; private Q_SLOTS: /** Updates the enabled states of different ui components. */ void updateUi(); /** Set the index of the current preset. Will update the UI */ void presetApplied( int index ); /** Updates the tool tips, labels, configuration and engine */ void bandsChanged(); void updatePresets(); void savePreset(); void deletePreset(); void restorePreset(); void restoreOriginalSettings(); void gainsChanged( const QList &gains ); void presetsChanged( const QString &name ); void toggleEqualizer( bool enabled ); private: explicit EqualizerDialog( QWidget *parent = nullptr ); void updateToolTips(); void updateLabels(); void storeOriginalSettings(); double mValueScale; QVector m_bands; QVector m_bandValues; QVector m_bandLabels; /** The preset and gains at the time "showOnce" was called. */ bool m_originalActivated; QString m_originalPreset; QList m_originalGains; static EqualizerDialog *s_instance; }; #endif // EQUALIZERDIALOG_H diff --git a/src/dialogs/MusicBrainzTagger.h b/src/dialogs/MusicBrainzTagger.h index 71517ac20c..de8aa3529d 100644 --- a/src/dialogs/MusicBrainzTagger.h +++ b/src/dialogs/MusicBrainzTagger.h @@ -1,81 +1,81 @@ /**************************************************************************************** * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * * Copyright (c) 2013 Alberto Villa * * * * 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 MUSICBRAINZTAGGER_H #define MUSICBRAINZTAGGER_H #include #include "core/meta/forward_declarations.h" #include namespace Ui { class MusicBrainzTagger; } class MusicBrainzFinder; class MusicBrainzTagsModel; class MusicBrainzTagsModelDelegate; #ifdef HAVE_LIBOFA class MusicDNSFinder; #endif class QSortFilterProxyModel; class MusicBrainzTagger : public QDialog { Q_OBJECT public: /** * @arg tracks Track list for search */ explicit MusicBrainzTagger( const Meta::TrackList &tracks, QWidget *parent = nullptr ); - virtual ~MusicBrainzTagger(); + ~MusicBrainzTagger() override; Q_SIGNALS: void sendResult( const QMap &result ); private Q_SLOTS: void search(); void progressStep(); void searchDone(); #ifdef HAVE_LIBOFA void mdnsSearchDone(); #endif void saveAndExit(); private: void init(); Ui::MusicBrainzTagger *ui; Meta::TrackList m_tracks; MusicBrainzFinder *mb_finder; #ifdef HAVE_LIBOFA MusicDNSFinder *mdns_finder; bool mdns_searchDone; #endif MusicBrainzTagsModel *m_resultsModel; MusicBrainzTagsModelDelegate *m_resultsModelDelegate; QSortFilterProxyModel *m_resultsProxyModel; }; #endif // MUSICBRAINZTAGGER_H diff --git a/src/dialogs/OrganizeCollectionDialog.h b/src/dialogs/OrganizeCollectionDialog.h index 7d94a34449..51e4e5d5f4 100644 --- a/src/dialogs/OrganizeCollectionDialog.h +++ b/src/dialogs/OrganizeCollectionDialog.h @@ -1,128 +1,128 @@ /**************************************************************************************** * Copyright (c) 2006 Mike Diehl * * Copyright (c) 2008 Téo Mrnjavac * * * * 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_ORGANIZECOLLECTIONDIALOG_H #define AMAROK_ORGANIZECOLLECTIONDIALOG_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "widgets/FilenameLayoutWidget.h" #include "ui_OrganizeCollectionOptions.h" #include #include #include namespace Ui { class OrganizeCollectionDialogBase; } class TrackOrganizer; /** A couple of options used in the filename layout dialog and the UmsCollection configuration dialog. */ class AMAROK_EXPORT OrganizeCollectionOptionWidget : public QGroupBox, public Ui::OrganizeCollectionsOptions { Q_OBJECT public: explicit OrganizeCollectionOptionWidget( QWidget *parent = nullptr ); bool asciiOnly() const { return asciiCheck->isChecked(); } void setAsciiOnly( bool enable ) { asciiCheck->setChecked( enable ); } bool vfatCompatible() const { return vfatCheck->isChecked(); } void setVfatCompatible( bool enable ) { vfatCheck->setChecked( enable ); } bool postfixThe() const { return ignoreTheCheck->isChecked(); } void setPostfixThe( bool enable ) { ignoreTheCheck->setChecked( enable ); } bool replaceSpaces() const { return spaceCheck->isChecked(); } void setReplaceSpaces( bool enable ) { spaceCheck->setChecked( enable ); } QString regexpText() const { return regexpEdit->text(); } void setRegexpText( const QString &text ) { regexpEdit->setText( text ); } QString replaceText() const { return replaceEdit->text(); } void setReplaceText( const QString &text ) { replaceEdit->setText( text ); } Q_SIGNALS: void optionsChanged(); }; /** A FilenameLayoutWidget that set's the needed tokens for organizing a collection. Note: This widget is also used in the UmsCollection dialog at src/core-impl/collections/umsCollection/UmsCollection.cpp */ class AMAROK_EXPORT OrganizeCollectionWidget : public FilenameLayoutWidget { Q_OBJECT public: explicit OrganizeCollectionWidget( QWidget *parent = nullptr ); - virtual ~OrganizeCollectionWidget() {} + ~OrganizeCollectionWidget() override {} protected: QString buildFormatTip() const; }; class AMAROK_EXPORT OrganizeCollectionDialog : public QDialog { Q_OBJECT public: explicit OrganizeCollectionDialog( const Meta::TrackList &tracks, const QStringList &folders, const QString &targetExtension = QString(), QWidget *parent = nullptr, const char *name = nullptr, bool modal = true, const QString &caption = QString(), QFlags buttonMask = QDialogButtonBox::Ok|QDialogButtonBox::Cancel ); - ~OrganizeCollectionDialog(); + ~OrganizeCollectionDialog() override; QMap getDestinations() const; bool overwriteDestinations() const; public Q_SLOTS: void slotUpdatePreview(); void slotDialogAccepted(); private Q_SLOTS: void processPreviewPaths(); void previewNextBatch(); void slotOverwriteModeChanged(); private: QString buildFormatString() const; Ui::OrganizeCollectionDialogBase *ui; TrackOrganizer *m_trackOrganizer; Meta::TrackList m_allTracks; QString m_targetFileExtension; QStringList m_originals; QStringList m_previews; QString m_previewPrefix; bool m_conflict; private Q_SLOTS: void slotEnableOk( const QString & currentCollectionRoot ); }; #endif //AMAROK_ORGANIZECOLLECTIONDIALOG_H diff --git a/src/dialogs/TagGuesserDialog.h b/src/dialogs/TagGuesserDialog.h index 2a4fe66cca..6b954dee68 100644 --- a/src/dialogs/TagGuesserDialog.h +++ b/src/dialogs/TagGuesserDialog.h @@ -1,124 +1,124 @@ /**************************************************************************************** * Copyright (c) 2008 Téo Mrnjavac * * Copyright (c) 2009 Nikolaj Hald Nielsen * * Copyright (c) 2009 Daniel Dewald * * Copyright (c) 2012 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 TAGGUESSERDIALOG_H #define TAGGUESSERDIALOG_H #include "amarok_export.h" #include "widgets/FilenameLayoutWidget.h" #include "ui_TagGuessOptions.h" #include #include #include class QLabel; class QFileInfo; class TagGuessOptionWidget : public QWidget, public Ui::TagGuessOptions { Q_OBJECT public: explicit TagGuessOptionWidget( QWidget *parent = nullptr ); int getCaseOptions(); bool getWhitespaceOptions(); bool getUnderscoreOptions(); Q_SIGNALS: void changed(); private Q_SLOTS: // Handles the radiobuttons void editStateEnable( bool checked ); private: QList m_caseEditRadioButtons; }; /** This widget allows the user to define a filename scheme from which to guess tags. */ class AMAROK_EXPORT TagGuesserWidget : public FilenameLayoutWidget { Q_OBJECT public: explicit TagGuesserWidget( QWidget *parent = nullptr ); - virtual ~TagGuesserWidget() {} + ~TagGuesserWidget() override {} protected: Token* createToken(qint64 value) const override; }; class AMAROK_EXPORT TagGuesserDialog : public QDialog { Q_OBJECT public: explicit TagGuesserDialog( const QString &fileName, QWidget *parent = nullptr ); QMap guessedTags(); /** Sets the filename to show colored preview from. */ void setFileName( const QString& fileName ); public Q_SLOTS: virtual void onAccept(); private Q_SLOTS: /** Updates the result texts and the colored filename. */ void updatePreview(); private: /** @Returns a filename with the same number of directory levels as the scheme. Also removes the extension. */ QString parsableFileName( const QFileInfo &fileInfo ) const; /** @Returns the fileName with added path. */ QString getParsableFileName(); /** * @Returns a colored version of the filename */ QString coloredFileName(const QMap &tags ); /** * @Returns color name for specified metadata field */ static QString fieldColor( qint64 field ); /** Filename to guess from. */ QString m_fileName; TagGuesserWidget* m_layoutWidget; QLabel* m_filenamePreview; TagGuessOptionWidget* m_optionsWidget; }; #endif /* TAGGUESSERDIALOG_H */ diff --git a/src/dynamic/Bias.h b/src/dynamic/Bias.h index 19445c6d7f..76236f3a02 100644 --- a/src/dynamic/Bias.h +++ b/src/dynamic/Bias.h @@ -1,279 +1,279 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Jones * * Copyright (c) 2009 Leo Franchi * * Copyright (c) 2010, 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_BIAS_H #define AMAROK_BIAS_H #include "amarok_export.h" #include "dynamic/TrackSet.h" #include #include #include #include #include #include class QPainter; class QXmlStreamReader; class QXmlStreamWriter; namespace Collections { class Collection; } namespace Dynamic { class AbstractBias; typedef QExplicitlySharedDataPointer BiasPtr; typedef QList BiasList; /** A bias is essentially just a function that evaluates the suitability of a playlist in some arbitrary way. It's function is to return new tracks for a playlist. For this it can only rely on previous tracks in the playlist (because of the way the playlists are generated). All biases are shared data to prevent problems when they are removed while the BiasSolver is running at the same time. */ class AMAROK_EXPORT AbstractBias : public QObject, public QSharedData { Q_OBJECT public: AbstractBias(); - virtual ~AbstractBias(); + ~AbstractBias() override; /** Reads the contents of this object from an xml stream */ virtual void fromXml( QXmlStreamReader *reader ); /** Writes the contents of this object to an xml stream. Only the content is written and no enclosing tags. This is done to make it mirror the constructor which does not read those tags either. */ virtual void toXml( QXmlStreamWriter *writer ) const; /** Creates a new bias (with all sub-biases) that is a copy of this. * * This function does a deep copy by writing and reading back from xml. * Should work for all biases. */ BiasPtr clone() const; /** Returns the name of this bias. The name is used for reading and writing to xml. */ static QString sName(); /** The same as sName just not static */ virtual QString name() const; /** The textual representation of this bias (localized) */ virtual QString toString() const = 0; /** Create a widget appropriate for editing the bias. */ virtual QWidget* widget( QWidget* parent = nullptr ); /** Paints an operator (like "and" or a progress bar") in front of a bias item */ virtual void paintOperator( QPainter* painter, const QRect &rect, Dynamic::AbstractBias* bias ); /** Returns the tracks that would fit at the end of the given playlist. The function can also return an "outstanding" Track set and return later with a resultReady signal. In such a case "matchingTracks" cannot be called again until the result was received or invalidate called. @param playlist The current playlist context for the track. @param contextCount The number of songs that are already fixed. @param finalCount The number of tracks that the playlist should finally contain (including the contextCount) @param universe A TrackCollectionPtr to be used for the resulting TrackSet */ virtual TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, const TrackCollectionPtr &universe ) const = 0; /** Returns true if indicated track fits that position. The function might block until a result is ready. @param position The position inside the playlist that we search a track for. The position can be larger than the number of playlist entries if we search a track for the end of the playlist. @param playlist The current playlist context for the track. @param contextCount The number of songs that are already fixed. */ virtual bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const = 0; Q_SIGNALS: /** This signal is emitted when the bias is changed. e.g. an internal variable is set so that the bias will return different tracks. this can also happen if the bias depends on the current track and this track changed. */ void changed( Dynamic::BiasPtr thisBias ); /** This signal is emitted when this bias should be replaced by a new one. */ void replaced( Dynamic::BiasPtr oldBias, Dynamic::BiasPtr newBias ); /** Emitted when the result to a previously called matchingTracks is ready */ void resultReady( const Dynamic::TrackSet &set ); public Q_SLOTS: /** This slot is called when the bias should discard cached results. This will be done in case a new playlist is requested for an updated collection. */ virtual void invalidate(); /** Call this function when this bias should be replaced by a new one. @param newBias The bias that replaces this bias. If you give an empty BiasPtr as argument the bias will be removed. */ virtual void replace( const Dynamic::BiasPtr &newBias ); }; /** A bias that returns all the tracks in the universe as possible tracks */ class AMAROK_EXPORT RandomBias : public AbstractBias { Q_OBJECT public: RandomBias(); - virtual ~RandomBias(); + ~RandomBias() override; static QString sName(); QString name() const override; QString toString() const override; QWidget* widget( QWidget* parent = nullptr ) override; TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, const TrackCollectionPtr &universe ) const override; bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const override; private: Q_DISABLE_COPY(RandomBias) }; /** An and bias The And Bias currently serves as a base class for all biases with children. */ class AMAROK_EXPORT AndBias : public AbstractBias { Q_OBJECT public: /** Create a new And bias. */ AndBias(); ~AndBias() override; void fromXml( QXmlStreamReader *reader ) override; void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); QString name() const override; QString toString() const override; QWidget* widget( QWidget* parent = nullptr ) override; void paintOperator( QPainter* painter, const QRect &rect, Dynamic::AbstractBias* bias ) override; TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, const TrackCollectionPtr &universe ) const override; bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const override; /** Appends a bias to this bias. This object will take ownership of the bias and free it when destroyed. */ virtual void appendBias( const Dynamic::BiasPtr &bias ); virtual void moveBias( int from, int to ); BiasList biases() const { return m_biases; } Q_SIGNALS: void biasAppended( Dynamic::BiasPtr bias ); void biasRemoved( int pos ); void biasMoved( int from, int to ); public Q_SLOTS: void invalidate() override; protected Q_SLOTS: virtual void resultReceived( const Dynamic::TrackSet &tracks ); virtual void biasReplaced( const Dynamic::BiasPtr &oldBias, const Dynamic::BiasPtr &newBias ); virtual void biasChanged( const Dynamic::BiasPtr &bias ); protected: BiasList m_biases; mutable TrackSet m_tracks; mutable int m_outstandingMatches; private: Q_DISABLE_COPY(AndBias) }; class AMAROK_EXPORT OrBias : public AndBias { Q_OBJECT public: OrBias(); static QString sName(); QString name() const override; QString toString() const override; void paintOperator( QPainter* painter, const QRect &rect, Dynamic::AbstractBias* bias ) override; TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, const TrackCollectionPtr &universe ) const override; bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const override; protected Q_SLOTS: void resultReceived( const Dynamic::TrackSet &tracks ) override; private: Q_DISABLE_COPY(OrBias) }; } Q_DECLARE_METATYPE( Dynamic::BiasPtr ) #endif diff --git a/src/dynamic/BiasFactory.h b/src/dynamic/BiasFactory.h index 604b7c08ec..f3453f3195 100644 --- a/src/dynamic/BiasFactory.h +++ b/src/dynamic/BiasFactory.h @@ -1,142 +1,142 @@ /**************************************************************************************** * Copyright (c) 2010 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_BIAS_FACTORY_H #define AMAROK_BIAS_FACTORY_H #include "amarok_export.h" #include "dynamic/Bias.h" #include #include class QXmlStreamReader; class QXmlStreamWriter; namespace Dynamic { /** A bias that will be used when a "real" bias could not be found. This bias will listen to the BiasFactory and present a "stand in" bias until a new factory with it's name becomes available. This will allow services with a bias to be switched off without their bias getting removed or otherwise corrupted. */ class ReplacementBias : public RandomBias { Q_OBJECT public: explicit ReplacementBias( const QString &n ); ReplacementBias( const QString &n, QXmlStreamReader *reader ); void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); QString name() const override; QString toString() const override; QWidget* widget( QWidget* parent = nullptr ) override; protected Q_SLOTS: void factoryChanged(); private: QString m_name; QByteArray m_html; Q_DISABLE_COPY(ReplacementBias) }; /** * The factory which creates bias entries on demand. As the user can create any number * of biases from from the bias addition widget, new custom biass types need to be able to be * generated on command and at runtime. **/ class AMAROK_EXPORT AbstractBiasFactory { public: AbstractBiasFactory() {} virtual ~AbstractBiasFactory() {} /** Returns the translated name of the type of bias. This one is used in the combo boxes when selecting the bias. It could be eg. "Last.fm Similar Artists" */ virtual QString i18nName() const = 0; /** Returns an internal non-translatable name for this custom bias type. This name must be unique over all biases and will also be used when reading and writing a bias to xml. */ virtual QString name() const = 0; /** Returns the translated description of the bias */ virtual QString i18nDescription() const = 0; /** Create the custom bias. The caller takes owner of the pointer */ virtual BiasPtr createBias() = 0; /** Creates a new custom bias from xml data */ virtual BiasPtr createFromXml( QXmlStreamReader *reader ); }; class AMAROK_EXPORT BiasFactory : public QObject { Q_OBJECT public: static BiasFactory* instance(); /** Add a new CustomBiasEntry to the registry. It will show up for users when then select the type of bias they want. */ static void registerNewBiasFactory( AbstractBiasFactory* factory ); /** Remove CustomBiasEntry from the list of bias types that the user can select. */ static void removeBiasFactory( AbstractBiasFactory* factory ); /** Helper function to get a bias from an xml tag */ static BiasPtr fromXml( QXmlStreamReader *reader ); /** Helper function to get a bias from an name */ static BiasPtr fromName( const QString &name ); /** * Returns all the current registered factories for this CustomBias */ static QList factories(); Q_SIGNALS: /** Emitted when the list of bias factories was changed. */ void changed(); private: BiasFactory( QObject *parent = nullptr ); - ~BiasFactory(); + ~BiasFactory() override; void emitChanged(); static BiasFactory* s_instance; static QList s_biasFactories; }; } #endif diff --git a/src/dynamic/BiasSolver.h b/src/dynamic/BiasSolver.h index 61935265a8..0145b589aa 100644 --- a/src/dynamic/BiasSolver.h +++ b/src/dynamic/BiasSolver.h @@ -1,229 +1,229 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Caleb Jones * * Copyright (c) 2010, 2013 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_BIASSOLVER_H #define AMAROK_BIASSOLVER_H #include "Bias.h" #include "core/meta/forward_declarations.h" #include "dynamic/TrackSet.h" #include #include #include #include namespace Dynamic { /** A playlist helper class */ class SolverList; /** * A class to implement the optimization algorithm used to generate * playlists from a set of biases. The method used here is slightly * complicated. It uses a a combination of heuristics, genetic algorithms, * and simulated annealing. The steps involved are documented in the source * code of BiasSolver::run. The whole operation is a little bit tricky since the bias solver runs as separate job without it's own event queue. The signals and slots are all handled via the UI threads event queue. Since the BiasSolver and all biases are created from the UI thread this is also the event queue of all objects. Bottom line: don't create objects in the bias solver that use signals. * Playlist generation is now done by adding tracks until we run out of time * or out of candidates. * We are back stepping a couple of times in such a case. * * The old bias solver that tried different optimization solutions is * not longer used. If you want to see the old code and/or re-use parts * of it see Amarok 2.7 * * To use the solver: * Create an instance * enqueue the job. When the job is finished, call solution to get the * playlist produced. */ class BiasSolver : public QObject, public ThreadWeaver::Job { Q_OBJECT public: /** * Create and prepare the solver. The constructor returns * * @param n The size of the playlist to generate. * @param bias The system of biases being applied. * @param context The tracks (if any) that precede the playlist * being generated. */ BiasSolver( int n, const BiasPtr &bias, const Meta::TrackList &context ); - ~BiasSolver(); + ~BiasSolver() override; /// Returns the playlist generated after the job has finished. Meta::TrackList solution(); /// Politely asks the thread to give up and finish ASAP. void requestAbort() override; /** * Returns true if the solver was successful, false if it was * aborted or encountered some other error. */ bool success() const override; /** * Choose whether the BiasSolver instance should delete itself after the query. * By passing true the instance will delete itself after emitting done, failed. * Otherwise it is the responsibility of the owner to delete the instance * when it is not needed anymore. * * Defaults to false, i.e. the BiasSolver instance will not delete itself. */ void setAutoDelete( bool autoDelete ); /** * Return the universe set (a list of the uid of every track being * considered) being used. */ static const QList& universe(); /** * Mark the universe set as out of date (i.e. it needs to be * updated). */ static void outdateUniverse(); protected: void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; Q_SIGNALS: /** a job must implement the following signals for the progress bar BiasedPlaylist set's us as progress sender in startSolver. */ /** Sets the total steps for the progress bar (which is always 100 for the bias solver). This signal is never emitted as the BiasedPlaylist already registers us with 100 steps. */ void totalSteps( int ); void incrementProgress(); void endProgressOperation( QObject * ); /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); private Q_SLOTS: void biasResultReady( const Dynamic::TrackSet &set ); void trackCollectionResultsReady( const QStringList &); void trackCollectionDone(); private: /** Returns the TrackSet that would match the end of the given playlist The function blocks until the result is received */ TrackSet matchingTracks( const Meta::TrackList& playlist ) const; /** Query for the universe set (the set of all tracks in the collection being considered. This function needs to be called from a thread with an event loop. */ void getTrackCollection(); /** Try to recursive add tracks to the current solver list up to m_n tracks. * The function will return with partly filled lists. */ void addTracks( SolverList *list ); /** * Get the track referenced by the uid stored in the given * QByteArray. * @param uid The uid */ Meta::TrackPtr trackForUid( const QString& uid ) const; /** * Return a random track from the domain. */ Meta::TrackPtr getMutation(); /** * Return a random track from the given subset. * @param subset A list (representing a set) of uids stored in * QByteArrays. */ Meta::TrackPtr getRandomTrack( const TrackSet& subset ) const; /** Returns a TrackSet with all duplicates removed (except the one at "position") This helper function can be used in special cases if needed and AmarokConfig::dynamicDuplicates() == false Normally the BiasSolver will call it at for the top most bias. */ static TrackSet withoutDuplicate( int position, const Meta::TrackList& playlist, const Dynamic::TrackSet& oldSet ); /** Emits the required progress signals */ void updateProgress( const SolverList* list ); int m_n; //!< size of playlist to generate Dynamic::BiasPtr m_bias; // bias used to determine tracks. not owned by solver Meta::TrackList m_context; //!< tracks that precede the playlist Meta::TrackList m_solution; bool m_abortRequested; //!< flag set when the thread is aborted QDateTime m_startTime; mutable QMutex m_biasResultsMutex; mutable QWaitCondition m_biasResultsReady; mutable Dynamic::TrackSet m_tracks; // tracks just received from the bias. mutable QMutex m_collectionResultsMutex; mutable QWaitCondition m_collectionResultsReady; /** All uids of all the tracks in the collection */ QStringList m_collectionUids; TrackCollectionPtr m_trackCollection; bool m_allowDuplicates; int m_currentProgress; /** The maximum time we should try to spend generating the playlist */ static const int MAX_TIME_MS = 5000; }; } #endif diff --git a/src/dynamic/BiasedPlaylist.h b/src/dynamic/BiasedPlaylist.h index 7c714d73e8..0e0652ad7a 100644 --- a/src/dynamic/BiasedPlaylist.h +++ b/src/dynamic/BiasedPlaylist.h @@ -1,89 +1,89 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Caleb Jones * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_BIASEDPLAYLIST_H #define AMAROK_BIASEDPLAYLIST_H #include "Bias.h" #include "DynamicPlaylist.h" #include "core/meta/forward_declarations.h" #include "amarok_export.h" // we are exporting it for the tests #include #include #include #include class QXmlStreamWriter; class QXmlStreamReader; namespace Dynamic { class BiasSolver; /** A concrete implementation of the DynamicPlaylist that uses a bias structure to determine new tracks. */ class AMAROK_EXPORT BiasedPlaylist : public DynamicPlaylist { Q_OBJECT public: /** Creates a new random playlist */ explicit BiasedPlaylist( QObject *parent = nullptr ); /** Creates a new playlist from an xml stream */ explicit BiasedPlaylist( QXmlStreamReader *reader, QObject *parent = nullptr ); - ~BiasedPlaylist(); + ~BiasedPlaylist() override; void toXml( QXmlStreamWriter *writer ) const override; void requestTracks(int) override; BiasPtr bias() const; public Q_SLOTS: void requestAbort() override; private Q_SLOTS: void solverFinished(); void biasChanged(); void biasReplaced( const Dynamic::BiasPtr &oldBias, const Dynamic::BiasPtr &newBias ); private: /** Starts the BiasSolver (if not already running) and requests a couple of new tracks. */ void startSolver( int numRequested ); /** Returns all the tracks that will come before the newly generated ones. */ Meta::TrackList getContext(); /** The bias this playlist uses */ BiasPtr m_bias; /** A currently running BiasSolver */ BiasSolver* m_solver; static const int BUFFER_SIZE; }; } // Q_DECLARE_METATYPE( Dynamic::BiasedPlaylistPtr ) #endif diff --git a/src/dynamic/DynamicModel.h b/src/dynamic/DynamicModel.h index 500810a038..ea1eb29e45 100644 --- a/src/dynamic/DynamicModel.h +++ b/src/dynamic/DynamicModel.h @@ -1,188 +1,188 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Jones * * Copyright (c) 2009-2010 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 DYNAMICMODEL_H #define DYNAMICMODEL_H #include "Bias.h" #include "DynamicPlaylist.h" #include "amarok_export.h" // we are exporting it for the tests #include #include #include class TestDynamicModel; namespace Dynamic { class BiasedPlaylist; class AMAROK_EXPORT DynamicModel : public QAbstractItemModel { Q_OBJECT public: // role used for the model enum Roles { // WidgetRole = 0xf00d, PlaylistRole = 0xf00e, BiasRole = 0xf00f, BiasPercentage = 0xf010, // for sub-biases underneath a part bias BiasOperation = 0xf011 // for sub-biases underneath a and-bias }; static DynamicModel* instance(); - ~DynamicModel(); + ~DynamicModel() override; // void changePlaylist( int i ); /** Returns the currently active playlist. Don't free this pointer */ Dynamic::DynamicPlaylist* activePlaylist() const; int activePlaylistIndex() const; /** Find the playlist with name, make it active and return it */ Dynamic::DynamicPlaylist* setActivePlaylist( int ); int playlistIndex( Dynamic::DynamicPlaylist* playlist ) const; /** Inserts a playlist at the given index. If the playlist is already in the model it will be moved to the position */ QModelIndex insertPlaylist( int index, Dynamic::DynamicPlaylist* playlist ); /** Inserts a bias at the given index. The bias must not be part of a model. When in doubt call bias->replace(BiasPtr()) to remove the bias from it's current position. */ QModelIndex insertBias( int row, const QModelIndex &parentIndex, const Dynamic::BiasPtr &bias ); Qt::DropActions supportedDropActions() const override; // --- QAbstractItemModel functions --- QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override; Qt::ItemFlags flags( const QModelIndex& index ) const override; QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override; QModelIndex parent(const QModelIndex& index) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; int columnCount( const QModelIndex& parent = QModelIndex() ) const override; QStringList mimeTypes() const override; QMimeData* mimeData(const QModelIndexList &indexes) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; // --- /** Returns the index for the bias @return Returns an invalid index if the bias is not in the model. */ QModelIndex index( const Dynamic::BiasPtr &bias ) const; /** Returns the index for the playlist @return Returns an invalid index if the playlist is not in the model. */ QModelIndex index( Dynamic::DynamicPlaylist* playlist ) const; /** Returns a representation of the whole model for debugging */ QString toString(); Q_SIGNALS: void activeChanged( int index ); // active row changed public Q_SLOTS: /** Saves all playlists to disk */ void savePlaylists(); /** Loads the last saved playlists form disk */ void loadPlaylists(); /** Removes the playlist or bias at the given index. */ void removeAt( const QModelIndex& index ); /** Clone the playlist or bias at the given index. */ QModelIndex cloneAt( const QModelIndex& index ); /** Creates a new playlist and returns the index to it. */ QModelIndex newPlaylist(); private: // two functions to search for parents QModelIndex parent( int row, Dynamic::BiasedPlaylist* list, const Dynamic::BiasPtr &bias ) const; QModelIndex parent( int row, const Dynamic::BiasPtr &parent, const Dynamic::BiasPtr &bias ) const; /** Writes the index to the data stream */ void serializeIndex( QDataStream *stream, const QModelIndex& index ) const; /** Gets an index from the data stream */ QModelIndex unserializeIndex( QDataStream *stream ) const; Dynamic::BiasedPlaylist* cloneList( Dynamic::BiasedPlaylist* list ); Dynamic::BiasPtr cloneBias( Dynamic::BiasPtr bias ); // -- model change signals --- // The following functions are called by the biases to // notify the model about changes. void playlistChanged( Dynamic::DynamicPlaylist* playlist ); void biasChanged( const Dynamic::BiasPtr &bias ); void beginRemoveBias( Dynamic::BiasedPlaylist* parent ); void beginRemoveBias( const Dynamic::BiasPtr &parent, int index ); void endRemoveBias(); void beginInsertBias( Dynamic::BiasedPlaylist* parent ); void beginInsertBias( const Dynamic::BiasPtr &parent, int index ); void endInsertBias(); void beginMoveBias( const Dynamic::BiasPtr &parent, int from, int to ); void endMoveBias(); // ---- bool savePlaylists( const QString &filename ); bool loadPlaylists( const QString &filename ); void initPlaylists(); DynamicModel(QObject* parent = nullptr); static DynamicModel* s_instance; int m_activePlaylistIndex; /** Contains all the dynamic playlists. */ QList m_playlists; friend class Dynamic::DynamicPlaylist; friend class Dynamic::BiasedPlaylist; friend class Dynamic::AndBias; friend class ::TestDynamicModel; }; } #endif diff --git a/src/dynamic/DynamicPlaylist.h b/src/dynamic/DynamicPlaylist.h index a4740dc407..9ae2775b12 100644 --- a/src/dynamic/DynamicPlaylist.h +++ b/src/dynamic/DynamicPlaylist.h @@ -1,80 +1,80 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Jones * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_DYNAMICPLAYLIST_H #define AMAROK_DYNAMICPLAYLIST_H #include "core/meta/forward_declarations.h" #include "core/collections/QueryMaker.h" #include "amarok_export.h" // we are exporting it for the tests namespace Collections { class Collection; } class QXmlStreamReader; class QXmlStreamWriter; namespace Dynamic { /** Provides a basis for dynamic playlists. The DynamicPlaylist is used by the DynamicTrackNavigator. Currently the only implementation of this abstract class is the BiasedPlaylist. */ class AMAROK_EXPORT DynamicPlaylist : public QObject { Q_OBJECT public: explicit DynamicPlaylist( QObject *parent = nullptr ); explicit DynamicPlaylist( QXmlStreamReader *reader, QObject *parent = nullptr ); - virtual ~DynamicPlaylist(); + ~DynamicPlaylist() override; virtual void toXml( QXmlStreamWriter *writer ) const = 0; virtual void requestTracks(int) = 0; QString title() const; void setTitle( const QString &); Q_SIGNALS: void tracksReady( Meta::TrackList ); /** Emitted when this playlist has been modified in some way. The DynamicModel will listen to it to detect if it needs to save it. */ void changed( Dynamic::DynamicPlaylist* playlist ); public Q_SLOTS: /** Start recalculating all tracks after the currently played track */ // virtual void repopulate(); /** Aborts the current playlist generation operation */ virtual void requestAbort() {} protected: Collections::Collection* m_collection; QString m_title; }; } #endif diff --git a/src/dynamic/biases/EchoNestBias.h b/src/dynamic/biases/EchoNestBias.h index 8ae5c97ce8..413cdb33d0 100644 --- a/src/dynamic/biases/EchoNestBias.h +++ b/src/dynamic/biases/EchoNestBias.h @@ -1,126 +1,126 @@ /**************************************************************************************** * Copyright (c) 2009 Leo Franchi * * Copyright (c) 2010, 2011, 2013 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 ECHO_NEST_BIAS_H #define ECHO_NEST_BIAS_H #include "dynamic/biases/TagMatchBias.h" #include namespace KIO { class StoredTransferJob; } class KJob; class QUrl; namespace Dynamic { /** * This is a bias which adds the suggested songs to the playlist. */ class EchoNestBias : public SimpleMatchBias { Q_OBJECT public: /** The tracks that are used for the matching */ enum MatchType { PreviousTrack, Playlist }; EchoNestBias(); - ~EchoNestBias(); + ~EchoNestBias() override; void fromXml( QXmlStreamReader *reader ) override; void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); QString name() const override; QString toString() const override; QWidget* widget( QWidget* parent = nullptr ) override; Dynamic::TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, const Dynamic::TrackCollectionPtr &universe ) const override; bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const override; MatchType match() const; void setMatch( MatchType value ); public Q_SLOTS: void invalidate() override; private Q_SLOTS: void newQuery() override; virtual void newSimilarArtistQuery(); void similarArtistQueryDone( KJob* ); void updateFinished() override; void setMatchTypePlaylist( bool ); private: /** Returns the artists we should lookup */ QStringList currentArtists( int position, const Meta::TrackList& playlist ) const; static QUrl createUrl( const QString &method, QMultiMap< QString, QString > params ); static QString nameForMatch( MatchType match ); static MatchType matchForName( const QString &name ); /** Returns the key used for m_tracksMap */ static QString tracksMapKey( const QStringList &artists ); void saveDataToFile() const; void readSimilarArtists( QXmlStreamReader *reader ); void loadDataFromFile(); /** The artist we are currently querying. */ mutable QStringList m_currentArtists; mutable QMap< KIO::StoredTransferJob*, QString> m_artistNameQueries; mutable KIO::StoredTransferJob* m_artistSuggestedQuery; MatchType m_match; mutable QMutex m_mutex; // mutex protecting all of the below structures mutable QMap< QString, QStringList> m_similarArtistMap; mutable QMap< QString, TrackSet> m_tracksMap; private: Q_DISABLE_COPY(EchoNestBias) }; class AMAROK_EXPORT EchoNestBiasFactory : public Dynamic::AbstractBiasFactory { public: QString i18nName() const override; QString name() const override; QString i18nDescription() const override; BiasPtr createBias() override; }; } #endif diff --git a/src/importers/ImporterProvider.h b/src/importers/ImporterProvider.h index 64f684cbb5..4ad9e6c39f 100644 --- a/src/importers/ImporterProvider.h +++ b/src/importers/ImporterProvider.h @@ -1,112 +1,112 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_IMPORTER_PROVIDER_H #define STATSYNCING_IMPORTER_PROVIDER_H #include "statsyncing/Provider.h" #include "amarok_export.h" namespace StatSyncing { class ImporterManager; /** * The ImporterProvider class is a base class for every @see StatSyncing::Provider * derived statistic importer. It serves to reduce boilerplate by offering a common * implementation of some StatSyncing::Provider methods. * * For details about methods' purpose, and other methods that need to be implemented * in a concrete ImporterProvider, see StatSyncing::Provider documentation. */ class AMAROK_EXPORT ImporterProvider : public Provider { Q_OBJECT /// Give ImporterManager access to config field in order to save and restore state. friend class ImporterManager; public: /** * The constructor stores @param config as a protected @see m_config variable, and * @param manager as @see m_manager. If config["uid"] isn't set, it's generated here. */ ImporterProvider( const QVariantMap &config, ImporterManager *manager ); - virtual ~ImporterProvider(); + ~ImporterProvider() override; /** * Provider's unique id which may be used as a key for configuration storage. * Returns m_config["uid"] by default. */ QString id() const override; /** * Description of the provider. Returns m_importer->description() by default. */ QString description() const override; /** * Provider's icon. Returns m_importer->icon() by default. */ QIcon icon() const override; /** * Provider's name as displayed in Amarok's Metadata Configuration tab. Returns * m_config["name"] by default. */ QString prettyName() const override; /** * Returns true if provider is configurable. Returns true by default. */ bool isConfigurable() const override; /** * Returns configuration widget used to reconfigure this provider. By default * delegates to m_importer->getConfigWidget( m_config ). */ ProviderConfigWidget *configWidget() override; /** * Reconfigures current provider. An ImporterManager subclass handles the * task, _recreating_ this provider with new configuration. Please note that * m_config["uid"] is not subject to reconfiguration. */ void reconfigure( const QVariantMap &config ) override; /** * Determines if this provider should participate in statistics synchronization * by default. By default returns StatSyncing::Provider::NoByDefault . */ Preference defaultPreference() override; Q_SIGNALS: void reconfigurationRequested( const QVariantMap &config ); protected: /** * Configuration of this provider. It is saved and restored by an ImporterManager * subclass. */ QVariantMap m_config; ImporterManager *m_manager; }; } // namespace StatSyncing #endif // STATSYNCING_IMPORTER_PROVIDER_H diff --git a/src/importers/ImporterSqlConnection.h b/src/importers/ImporterSqlConnection.h index 074d8747ff..8b8d263348 100644 --- a/src/importers/ImporterSqlConnection.h +++ b/src/importers/ImporterSqlConnection.h @@ -1,148 +1,148 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_IMPORTER_SQL_CONNECTION_H #define STATSYNCING_IMPORTER_SQL_CONNECTION_H #include #include "amarok_export.h" #include #include #include #include #include #include #include #include #include namespace StatSyncing { /** * A helper class encapsulating communication with the database. It guarantees that * a connection is only used in thread that created it, as per * http://doc.qt.io/qt-5/threads-modules.html#threads-and-the-sql-module * This class is very basic, e.g. returns a whole query result as a list of lists, * so it may not be suitable for more advanced usage. */ class AMAROK_EXPORT ImporterSqlConnection : public QObject { Q_OBJECT public: /** * Constructor. Creates a new external database connection characterized by parameters * given. See @see QSqlDatabase class for details. */ ImporterSqlConnection( const QString &driver, const QString &hostname, const quint16 port, const QString &dbName, const QString &user, const QString &password ); /** * Constructor. Overload for creating a connection to SQLite database. */ explicit ImporterSqlConnection( const QString &dbPath ); /** * Destructor. Removes connection created in the constructor. If a transaction was * in progress it is rolled back. */ - virtual ~ImporterSqlConnection(); + ~ImporterSqlConnection() override; /** * Executes a query given in QString @p query, first using QSqlQuery::bindValue * to bind parameters given in @p bindValues. If @p ok is not null the bool * it points at is set to true if the query was successful and false if error occurred. * Note that if no transaction is started, the connection is opened for the query and * then closed again. * @param query the query * @param bindValues the bind parameters * @param ok whether the query was successful * * @returns The result of the query. */ QList query( const QString &query, const QVariantMap &bindValues = QVariantMap(), bool* const ok = 0 ); /** * Starts a transaction. Transaction is not started if the underlying driver has no * support for it. While transaction is started, the connection to the database * remains open and no other thread can use the ImporterSqlConnection object's api. */ void transaction(); /** * Rolls the transaction back. Nothing happens if the transaction was not started. * This method must be used from the same thread that called @see transaction() . */ void rollback(); /** * Commits the transaction. Nothing happens if the transaction was not started. * This method must be used from the same thread that called @see transaction() . */ void commit(); protected: /** * Constructor. Use this overload if you don't want to create a new connection in * constructor of a derived class. */ ImporterSqlConnection(); /** * Opens and returns current QSqlDatabase connection. Override this method if you need * to do something before the connection is used. This method should only be called * from object's main thread. */ virtual QSqlDatabase connection(); /** * Returns true if transaction is in progress. This method should only be called * from object's main thread. */ bool isTransaction() const; /** * Name of the current connection. */ const QString m_connectionName; private: Q_DISABLE_COPY( ImporterSqlConnection ) Qt::ConnectionType blockingConnectionType() const; QMutex m_apiMutex; bool m_openTransaction; QList m_result; private Q_SLOTS: void slotQuery( const QString &query, const QVariantMap &bindValues, bool* const ok ); void slotTransaction(); void slotRollback(); void slotCommit(); }; typedef QSharedPointer ImporterSqlConnectionPtr; } // namespace StatSyncing #endif // STATSYNCING_IMPORTER_SQL_CONNECTION_H diff --git a/src/importers/SimpleImporterConfigWidget.h b/src/importers/SimpleImporterConfigWidget.h index d184dd2b15..8bc4bf8e3a 100644 --- a/src/importers/SimpleImporterConfigWidget.h +++ b/src/importers/SimpleImporterConfigWidget.h @@ -1,79 +1,79 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_SIMPLE_IMPORTER_CONFIG_WIDGET #define STATSYNCING_SIMPLE_IMPORTER_CONFIG_WIDGET #include "statsyncing/Provider.h" #include class QGridLayout; namespace StatSyncing { /** * SimpleImporterConfigWidget is a helper class for creating non-sophisticated config * widgets for importers. */ class AMAROK_EXPORT SimpleImporterConfigWidget : public ProviderConfigWidget { public: /** * Constructor. Creates a widget with one label: "Target name," and one text field * with its default value specified in @p targetName . @p config contains * configuration for this widget. * @param targetName the target name * @param config configuration for the created widget * @param parent the parent widget * @param f Qt window flags */ SimpleImporterConfigWidget( const QString &targetName, const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); /** * Destructor. */ - ~SimpleImporterConfigWidget(); + ~SimpleImporterConfigWidget() override; /** * addField adds a new row to the widget. @param configName is the name of the config * value associated with this field. The row contains a label initialized with * @param label and a QWidget @param field initialized with config[configName] * (if set). @param property must specify the name of field's property that contains * value we want to configure; e.g. for a text field property will be "text", and for * a combo box the property may be "currentText" . * * The ownership of field is transferred to SimpleImporterConfigWidget. */ void addField( const QString &configName, const QString &label, QWidget * const field, const QString &property ); /** * Returns a config generated from this widget's fields. */ QVariantMap config() const override; private: const QVariantMap m_config; QMap > m_fieldForName; QGridLayout *m_layout; }; } // namespace StatSyncing #endif // STATSYNCING_SIMPLE_IMPORTER_CONFIG_WIDGET diff --git a/src/importers/amarok/AmarokConfigWidget.h b/src/importers/amarok/AmarokConfigWidget.h index c7bb9e3eae..f699fc7c01 100644 --- a/src/importers/amarok/AmarokConfigWidget.h +++ b/src/importers/amarok/AmarokConfigWidget.h @@ -1,57 +1,57 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_AMAROK_CONFIG_WIDGET_H #define STATSYNCING_AMAROK_CONFIG_WIDGET_H #include "statsyncing/Provider.h" #include "ui_AmarokConfigWidget.h" namespace StatSyncing { class AmarokConfigWidget : public ProviderConfigWidget, public Ui::AmarokConfigWidget { Q_OBJECT public: explicit AmarokConfigWidget( const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - ~AmarokConfigWidget(); + ~AmarokConfigWidget() override; QVariantMap config() const override; enum ConnectionType { Embedded, External }; private: void populateFields(); const QVariantMap m_config; QList m_externalDbSettings; QList m_embeddedDbSettings; private Q_SLOTS: void connectionTypeChanged( const int index ); }; } // namespace StatSyncing #endif // STATSYNCING_AMAROK_CONFIG_WIDGET_H diff --git a/src/importers/amarok/AmarokEmbeddedSqlConnection.h b/src/importers/amarok/AmarokEmbeddedSqlConnection.h index e0438aa9a1..cfe00a5f7a 100644 --- a/src/importers/amarok/AmarokEmbeddedSqlConnection.h +++ b/src/importers/amarok/AmarokEmbeddedSqlConnection.h @@ -1,63 +1,63 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_AMAROK_EMBEDDED_SQL_CONNECTION_H #define STATSYNCING_AMAROK_EMBEDDED_SQL_CONNECTION_H #include "importers/ImporterSqlConnection.h" #include #include #include #include #include namespace StatSyncing { class AmarokEmbeddedSqlConnection : public ImporterSqlConnection { Q_OBJECT public: AmarokEmbeddedSqlConnection( const QFileInfo &mysqld, const QDir &datadir ); - ~AmarokEmbeddedSqlConnection(); + ~AmarokEmbeddedSqlConnection() override; protected: QSqlDatabase connection() override; private: bool startServer( const int port, const QString &socketPath, const QString &pidPath ); const QFileInfo m_mysqld; const QDir m_datadir; QProcess m_srv; QMutex m_srvMutex; QTimer m_shutdownTimer; /// Number of msecs after which server will shut down static const int SERVER_SHUTDOWN_AFTER = 30000; /// Number of msecs to wait for server to start up static const int SERVER_START_TIMEOUT = 30000; private Q_SLOTS: void stopServer(); }; } // namespace StatSyncing #endif // STATSYNCING_AMAROK_EMBEDDED_SQL_CONNECTION_H diff --git a/src/importers/amarok/AmarokProvider.h b/src/importers/amarok/AmarokProvider.h index 08a8a4007b..6eefacc032 100644 --- a/src/importers/amarok/AmarokProvider.h +++ b/src/importers/amarok/AmarokProvider.h @@ -1,46 +1,46 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_AMAROK_PROVIDER_H #define STATSYNCING_AMAROK_PROVIDER_H #include "importers/ImporterProvider.h" namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class AmarokProvider : public ImporterProvider { public: AmarokProvider( const QVariantMap &config, ImporterManager *importer ); - ~AmarokProvider(); + ~AmarokProvider() override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; QSet artists() override; TrackList artistTracks( const QString &artistName ) override; private: ImporterSqlConnectionPtr m_connection; }; } // namespace StatSyncing #endif // STATSYNCING_AMAROK_PROVIDER_H diff --git a/src/importers/amarok/AmarokTrack.h b/src/importers/amarok/AmarokTrack.h index 59e57ac288..a1a6aebd4d 100644 --- a/src/importers/amarok/AmarokTrack.h +++ b/src/importers/amarok/AmarokTrack.h @@ -1,47 +1,47 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_AMAROK_TRACK_H #define STATSYNCING_AMAROK_TRACK_H #include "statsyncing/SimpleWritableTrack.h" #include namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class AmarokTrack : public SimpleWritableTrack { public: AmarokTrack( const qint64 urlId, const ImporterSqlConnectionPtr &connection, const Meta::FieldHash &metadata, const QSet &labels ); - ~AmarokTrack(); + ~AmarokTrack() override; protected: void doCommit( const qint64 fields ) override; private: const ImporterSqlConnectionPtr m_connection; const qint64 m_urlId; }; } // namespace StatSyncing #endif // STATSYNCING_AMAROK_TRACK_H diff --git a/src/importers/banshee/BansheeConfigWidget.h b/src/importers/banshee/BansheeConfigWidget.h index a5c5c7e72d..3f5e634c0d 100644 --- a/src/importers/banshee/BansheeConfigWidget.h +++ b/src/importers/banshee/BansheeConfigWidget.h @@ -1,35 +1,35 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_BANSHEE_CONFIG_WIDGET_H #define STATSYNCING_BANSHEE_CONFIG_WIDGET_H #include "importers/SimpleImporterConfigWidget.h" namespace StatSyncing { class BansheeConfigWidget : public SimpleImporterConfigWidget { public: explicit BansheeConfigWidget( const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - ~BansheeConfigWidget(); + ~BansheeConfigWidget() override; }; } // namespace StatSyncing #endif // STATSYNCING_BANSHEE_CONFIG_WIDGET_H diff --git a/src/importers/banshee/BansheeProvider.h b/src/importers/banshee/BansheeProvider.h index 176d484a46..c938490172 100644 --- a/src/importers/banshee/BansheeProvider.h +++ b/src/importers/banshee/BansheeProvider.h @@ -1,48 +1,48 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_BANSHEE_PROVIDER_H #define STATSYNCING_BANSHEE_PROVIDER_H #include "importers/ImporterProvider.h" #include namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class BansheeProvider : public ImporterProvider { public: BansheeProvider( const QVariantMap &config, ImporterManager *importer ); - ~BansheeProvider(); + ~BansheeProvider() override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; QSet artists() override; TrackList artistTracks( const QString &artistName ) override; private: const ImporterSqlConnectionPtr m_connection; }; } // namespace StatSyncing #endif // STATSYNCING_BANSHEE_PROVIDER_H diff --git a/src/importers/banshee/BansheeTrack.h b/src/importers/banshee/BansheeTrack.h index d7de5e3d62..4dee98bf48 100644 --- a/src/importers/banshee/BansheeTrack.h +++ b/src/importers/banshee/BansheeTrack.h @@ -1,50 +1,50 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_BANSHEE_TRACK_H #define STATSYNCING_BANSHEE_TRACK_H #include "statsyncing/SimpleWritableTrack.h" #include namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class BansheeTrack : public SimpleWritableTrack { public: BansheeTrack( const qint64 trackId, const ImporterSqlConnectionPtr &connection, const Meta::FieldHash &metadata ); - ~BansheeTrack(); + ~BansheeTrack() override; int rating() const override; void setRating( int rating ) override; protected: void doCommit( const qint64 fields ) override; private: const ImporterSqlConnectionPtr m_connection; const qint64 m_trackId; }; } // namespace StatSyncing #endif // STATSYNCING_BANSHEE_TRACK_H diff --git a/src/importers/clementine/ClementineConfigWidget.h b/src/importers/clementine/ClementineConfigWidget.h index c883f4a3c5..fe91d435a0 100644 --- a/src/importers/clementine/ClementineConfigWidget.h +++ b/src/importers/clementine/ClementineConfigWidget.h @@ -1,35 +1,35 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_CLEMENTINE_CONFIG_WIDGET_H #define STATSYNCING_CLEMENTINE_CONFIG_WIDGET_H #include "importers/SimpleImporterConfigWidget.h" namespace StatSyncing { class ClementineConfigWidget : public SimpleImporterConfigWidget { public: explicit ClementineConfigWidget( const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - ~ClementineConfigWidget(); + ~ClementineConfigWidget() override; }; } // namespace StatSyncing #endif // STATSYNCING_CLEMENTINE_CONFIG_WIDGET_H diff --git a/src/importers/clementine/ClementineProvider.h b/src/importers/clementine/ClementineProvider.h index 8ff7a7acb1..0d596abc34 100644 --- a/src/importers/clementine/ClementineProvider.h +++ b/src/importers/clementine/ClementineProvider.h @@ -1,46 +1,46 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_CLEMENTINE_PROVIDER_H #define STATSYNCING_CLEMENTINE_PROVIDER_H #include "importers/ImporterProvider.h" namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class ClementineProvider : public ImporterProvider { public: ClementineProvider( const QVariantMap &config, ImporterManager *importer ); - ~ClementineProvider(); + ~ClementineProvider() override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; QSet artists() override; TrackList artistTracks( const QString &artistName ) override; private: const ImporterSqlConnectionPtr m_connection; }; } // namespace StatSyncing #endif // STATSYNCING_CLEMENTINE_PROVIDER_H diff --git a/src/importers/clementine/ClementineTrack.h b/src/importers/clementine/ClementineTrack.h index 01f0f5fe0e..4f0d9b9015 100644 --- a/src/importers/clementine/ClementineTrack.h +++ b/src/importers/clementine/ClementineTrack.h @@ -1,58 +1,58 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_CLEMENTINE_TRACK_H #define STATSYNCING_CLEMENTINE_TRACK_H #include "statsyncing/SimpleWritableTrack.h" #include namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class ClementineTrack : public SimpleWritableTrack { public: ClementineTrack( const QVariant &filename, const ImporterSqlConnectionPtr &connection, const Meta::FieldHash &metadata ); - ~ClementineTrack(); + ~ClementineTrack() override; int year() const override; int trackNumber() const override; int discNumber() const override; QDateTime lastPlayed() const override; void setLastPlayed( const QDateTime &lastPlayed ) override; int playCount() const override; void setPlayCount( int playCount ) override; int rating() const override; void setRating( int rating ) override; protected: void doCommit( const qint64 fields ) override; private: const ImporterSqlConnectionPtr m_connection; const QVariant m_filename; }; } #endif // STATSYNCING_CLEMENTINE_TRACK_H diff --git a/src/importers/fastforward/FastForwardConfigWidget.h b/src/importers/fastforward/FastForwardConfigWidget.h index f25f5af6d1..c307a43fb9 100644 --- a/src/importers/fastforward/FastForwardConfigWidget.h +++ b/src/importers/fastforward/FastForwardConfigWidget.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_FAST_FORWARD_CONFIG_WIDGET_H #define STATSYNCING_FAST_FORWARD_CONFIG_WIDGET_H #include "statsyncing/Provider.h" #include "ui_FastForwardConfigWidget.h" namespace StatSyncing { class FastForwardConfigWidget : public ProviderConfigWidget, public Ui::FastForwardConfigWidget { Q_OBJECT public: explicit FastForwardConfigWidget( const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - ~FastForwardConfigWidget(); + ~FastForwardConfigWidget() override; QVariantMap config() const override; enum Driver { QMYSQL, QPSQL, QSQLITE }; Q_ENUM( Driver ) private: void populateFields(); const QVariantMap m_config; QList m_externalDbSettings; QList m_embeddedDbSettings; private Q_SLOTS: void connectionTypeChanged( const int index ); }; } // namespace StatSyncing #endif // STATSYNCING_FAST_FORWARD_CONFIG_WIDGET_H diff --git a/src/importers/fastforward/FastForwardProvider.h b/src/importers/fastforward/FastForwardProvider.h index fe8f261033..25f0f1b410 100644 --- a/src/importers/fastforward/FastForwardProvider.h +++ b/src/importers/fastforward/FastForwardProvider.h @@ -1,46 +1,46 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_FAST_FORWARD_PROVIDER_H #define STATSYNCING_FAST_FORWARD_PROVIDER_H #include "importers/ImporterProvider.h" namespace StatSyncing { class ImporterSqlConnection; typedef QSharedPointer ImporterSqlConnectionPtr; class FastForwardProvider : public ImporterProvider { public: FastForwardProvider( const QVariantMap &config, ImporterManager *importer ); - ~FastForwardProvider(); + ~FastForwardProvider() override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; QSet artists() override; TrackList artistTracks( const QString &artistName ) override; private: ImporterSqlConnectionPtr m_connection; }; } // namespace StatSyncing #endif // STATSYNCING_FAST_FORWARD_PROVIDER_H diff --git a/src/importers/itunes/ITunesConfigWidget.h b/src/importers/itunes/ITunesConfigWidget.h index 490b26275a..9099ff1179 100644 --- a/src/importers/itunes/ITunesConfigWidget.h +++ b/src/importers/itunes/ITunesConfigWidget.h @@ -1,35 +1,35 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_ITUNES_CONFIG_WIDGET_H #define STATSYNCING_ITUNES_CONFIG_WIDGET_H #include "importers/SimpleImporterConfigWidget.h" namespace StatSyncing { class ITunesConfigWidget : public SimpleImporterConfigWidget { public: explicit ITunesConfigWidget( const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - ~ITunesConfigWidget(); + ~ITunesConfigWidget() override; }; } // namespace StatSyncing #endif // STATSYNCING_ITUNES_CONFIG_WIDGET_H diff --git a/src/importers/itunes/ITunesProvider.h b/src/importers/itunes/ITunesProvider.h index 43d0c58471..b32fbc4cf2 100644 --- a/src/importers/itunes/ITunesProvider.h +++ b/src/importers/itunes/ITunesProvider.h @@ -1,70 +1,70 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_ITUNES_PROVIDER_H #define STATSYNCING_ITUNES_PROVIDER_H #include "importers/ImporterProvider.h" #include "MetaValues.h" #include class QXmlStreamReader; class QXmlStreamWriter; namespace StatSyncing { class ITunesProvider : public ImporterProvider { Q_OBJECT public: ITunesProvider( const QVariantMap &config, ImporterManager *importer ); - ~ITunesProvider(); + ~ITunesProvider() override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; QSet artists() override; TrackList artistTracks( const QString &artistName ) override; void commitTracks() override; private: void readXml( const QString &byArtist ); void readPlist( QXmlStreamReader &xml, const QString &byArtist ); void readTracks( QXmlStreamReader &xml, const QString &byArtist ); void readTrack( QXmlStreamReader &xml, const QString &byArtist ); QString readValue( QXmlStreamReader &xml ); void writeTracks( QXmlStreamReader &reader, QXmlStreamWriter &writer, const QMap &dirtyData ); void writeTrack( QXmlStreamReader &reader, QXmlStreamWriter &writer, const Meta::FieldHash &dirtyData ); QSet m_artists; TrackList m_artistTracks; QMap m_dirtyData; QMutex m_dirtyMutex; private Q_SLOTS: void trackUpdated( const int trackId, const Meta::FieldHash &statistics ); }; } // namespace StatSyncing #endif // STATSYNCING_ITUNES_PROVIDER_H diff --git a/src/importers/itunes/ITunesTrack.h b/src/importers/itunes/ITunesTrack.h index ed433093a9..36ac6cfc3c 100644 --- a/src/importers/itunes/ITunesTrack.h +++ b/src/importers/itunes/ITunesTrack.h @@ -1,51 +1,51 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_ITUNES_TRACK_H #define STATSYNCING_ITUNES_TRACK_H #include "statsyncing/SimpleWritableTrack.h" #include namespace StatSyncing { class ITunesTrack : public QObject, public SimpleWritableTrack { Q_OBJECT public: explicit ITunesTrack( const int trackId, const Meta::FieldHash &metadata ); - ~ITunesTrack(); + ~ITunesTrack() override; int rating() const override; void setRating( int rating ) override; QDateTime lastPlayed() const override; Q_SIGNALS: void commitCalled( const int trackId, const Meta::FieldHash &statistics ); protected: void doCommit( const qint64 changes ) override; private: const int m_trackId; }; } // namespace StatSyncing #endif // STATSYNCING_ITUNES_TRACK_H diff --git a/src/importers/rhythmbox/RhythmboxConfigWidget.h b/src/importers/rhythmbox/RhythmboxConfigWidget.h index 2fb1efb0e9..0ea17d97bc 100644 --- a/src/importers/rhythmbox/RhythmboxConfigWidget.h +++ b/src/importers/rhythmbox/RhythmboxConfigWidget.h @@ -1,35 +1,35 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_RHYTHMBOX_CONFIG_WIDGET_H #define STATSYNCING_RHYTHMBOX_CONFIG_WIDGET_H #include "importers/SimpleImporterConfigWidget.h" namespace StatSyncing { class RhythmboxConfigWidget : public SimpleImporterConfigWidget { public: explicit RhythmboxConfigWidget( const QVariantMap &config, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - ~RhythmboxConfigWidget(); + ~RhythmboxConfigWidget() override; }; } // namespace StatSyncing #endif // STATSYNCING_RHYTHMBOX_CONFIG_WIDGET_H diff --git a/src/importers/rhythmbox/RhythmboxProvider.h b/src/importers/rhythmbox/RhythmboxProvider.h index 21f7d36976..e116a74268 100644 --- a/src/importers/rhythmbox/RhythmboxProvider.h +++ b/src/importers/rhythmbox/RhythmboxProvider.h @@ -1,67 +1,67 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_RHYTHMBOX_PROVIDER_H #define STATSYNCING_RHYTHMBOX_PROVIDER_H #include "importers/ImporterProvider.h" #include "MetaValues.h" #include class QXmlStreamReader; class QXmlStreamWriter; namespace StatSyncing { class RhythmboxProvider : public ImporterProvider { Q_OBJECT public: RhythmboxProvider( const QVariantMap &config, ImporterManager *importer ); - ~RhythmboxProvider(); + ~RhythmboxProvider() override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; QSet artists() override; TrackList artistTracks( const QString &artistName ) override; void commitTracks() override; private: void readXml( const QString &byArtist ); void readRhythmdb( QXmlStreamReader &xml, const QString &byArtist ); void readSong( QXmlStreamReader &xml, const QString &byArtist ); QString readValue( QXmlStreamReader &xml ); void writeSong( QXmlStreamReader &reader, QXmlStreamWriter &writer, const QMap &dirtyData ); QSet m_artists; TrackList m_artistTracks; QMap m_dirtyData; QMutex m_dirtyMutex; private Q_SLOTS: void trackUpdated( const QString &location, const Meta::FieldHash &statistics ); }; } // namespace StatSyncing #endif // STATSYNCING_RHYTHMBOX_PROVIDER_H diff --git a/src/importers/rhythmbox/RhythmboxTrack.h b/src/importers/rhythmbox/RhythmboxTrack.h index a0293f7ab3..5741c0b2c6 100644 --- a/src/importers/rhythmbox/RhythmboxTrack.h +++ b/src/importers/rhythmbox/RhythmboxTrack.h @@ -1,49 +1,49 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_RHYTHMBOX_TRACK_H #define STATSYNCING_RHYTHMBOX_TRACK_H #include "statsyncing/SimpleWritableTrack.h" #include namespace StatSyncing { class RhythmboxTrack : public QObject, public SimpleWritableTrack { Q_OBJECT public: RhythmboxTrack( const QString &location, const Meta::FieldHash &metadata ); - ~RhythmboxTrack(); + ~RhythmboxTrack() override; int rating() const override; void setRating( int rating ) override; protected: void doCommit( const qint64 fields ) override; Q_SIGNALS: void commitCalled( const QString &location, const Meta::FieldHash &statistics ); private: const QString m_location; }; } // namespace StatSyncing #endif // STATSYNCING_RHYTHMBOX_TRACK_H diff --git a/src/moodbar/MoodbarManager.h b/src/moodbar/MoodbarManager.h index f22c54ca0b..a9601ab92d 100644 --- a/src/moodbar/MoodbarManager.h +++ b/src/moodbar/MoodbarManager.h @@ -1,86 +1,86 @@ /**************************************************************************************** * 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 Pulic License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef MOODBARMANAGER_H #define MOODBARMANAGER_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include #include #include #include class QUrl; class QPalette; class MoodbarManager; namespace The { AMAROK_EXPORT MoodbarManager* moodbarManager(); } typedef QVector MoodbarColorList; class AMAROK_EXPORT MoodbarManager : public QObject { Q_OBJECT friend MoodbarManager* The::moodbarManager(); public: enum Style { SystemColours, Angry, Frozen, Happy, Normal }; - ~MoodbarManager(); + ~MoodbarManager() override; bool hasMoodbar( Meta::TrackPtr track ); QPixmap getMoodbar( Meta::TrackPtr track, int width, int height, bool rtl = false ); Q_SIGNALS: void moodbarReady( const QPixmap &pixmap ); void moodbarCreationFailed( const QString &error ); void moodbarStyleChanged(); private Q_SLOTS: void paletteChanged( const QPalette &palette ); private: MoodbarManager(); MoodbarColorList readMoodFile( const QUrl &moodFileUrl ); QPixmap drawMoodbar( const MoodbarColorList &data, int width, int height, bool rtl ); QString moodPath( const QString &trackPath ) const; //let this class take care of caching everything as needed, otherwise things get pretty complex pretty fast. QMap m_hasMoodMap; QMap m_moodFileMap; QMap m_moodDataMap; KImageCache * m_cache; int m_lastPaintMode; }; #endif // MOODBARMANAGER_H diff --git a/src/musicbrainz/MusicBrainzTagsModel.h b/src/musicbrainz/MusicBrainzTagsModel.h index d0ff1e32c1..af7f30a3fa 100644 --- a/src/musicbrainz/MusicBrainzTagsModel.h +++ b/src/musicbrainz/MusicBrainzTagsModel.h @@ -1,76 +1,76 @@ /**************************************************************************************** * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * * Copyright (c) 2013 Alberto Villa * * * * 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 MUSICBRAINZTAGSMODEL_H #define MUSICBRAINZTAGSMODEL_H #include "core/meta/forward_declarations.h" #include #include class MusicBrainzTagsItem; class MusicBrainzTagsModel : public QAbstractItemModel { Q_OBJECT public: enum { SortRole = Qt::UserRole, TracksRole, ArtistsRole, ReleasesRole, ChosenStateRole }; enum ChosenState { Unchosen, Chosen }; explicit MusicBrainzTagsModel( QObject *parent = nullptr ); - ~MusicBrainzTagsModel(); + ~MusicBrainzTagsModel() override; QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex &index ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role ) override; Qt::ItemFlags flags( const QModelIndex &index ) const override; QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; QMap chosenItems() const; void chooseBestMatchesFromRelease( const QStringList &releases ); public Q_SLOTS: void addTrack( const Meta::TrackPtr &track, const QVariantMap &tags ); void chooseBestMatches(); void clearChoices(); private: MusicBrainzTagsItem *m_rootItem; mutable QMutex m_modelLock; }; #endif // MUSICBRAINZTAGSMDOEL_H diff --git a/src/musicbrainz/MusicDNSAudioDecoder.h b/src/musicbrainz/MusicDNSAudioDecoder.h index cf630adffe..52efaa6802 100644 --- a/src/musicbrainz/MusicDNSAudioDecoder.h +++ b/src/musicbrainz/MusicDNSAudioDecoder.h @@ -1,90 +1,90 @@ /**************************************************************************************** * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * * * * 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 MUSICDNSAUDIODECODER_H #define MUSICDNSAUDIODECODER_H #include "core/meta/forward_declarations.h" #include #define DEFAULT_SAMPLE_LENGTH 135000 #define MIN_SAMPLE_LENGTH 10000 class DecodedAudioData { public: DecodedAudioData(); ~DecodedAudioData(); int sRate(); void setSampleRate( const int sampleRate ); quint8 channels(); void setChannels( const quint8 channels ); int length(); qint64 duration(); void addTime( const qint64 ms ); const char *data(); void appendData( const quint8 *data, int length ); DecodedAudioData &operator<< ( const quint8 &byte ); void flush(); private: int m_sRate; quint8 m_channels; qint64 m_duration; QByteArray *m_data; }; class MusicDNSAudioDecoder : public QObject, public ThreadWeaver::Job { Q_OBJECT public: explicit MusicDNSAudioDecoder( const Meta::TrackList &tracks, const int sampleLength = DEFAULT_SAMPLE_LENGTH ); - virtual ~MusicDNSAudioDecoder(); + ~MusicDNSAudioDecoder() override; void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; Q_SIGNALS: void trackDecoded( const Meta::TrackPtr, const QString ); /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); private: int decode( const QString &fileName, DecodedAudioData *data, const int length ); Meta::TrackList m_tracks; int m_sampleLength; protected: void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; }; #endif // MUSICDNSAUDIODECODER_H diff --git a/src/network/NetworkAccessManagerProxy.h b/src/network/NetworkAccessManagerProxy.h index 001bd20975..33794a77a8 100644 --- a/src/network/NetworkAccessManagerProxy.h +++ b/src/network/NetworkAccessManagerProxy.h @@ -1,189 +1,189 @@ /**************************************************************************************** * Copyright (c) 2008 Urs Wolfer * * * * 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_NETWORKACCESSMANAGERPROXY #define AMAROK_NETWORKACCESSMANAGERPROXY #include "amarok_export.h" #include #include "core/support/Debug.h" #include #include #include #include #include #include class NetworkAccessManagerProxy; #ifdef DEBUG_BUILD_TYPE class NetworkAccessViewer; #endif // DEBUG_BUILD_TYPE namespace The { AMAROK_EXPORT NetworkAccessManagerProxy *networkAccessManager(); } class AMAROK_EXPORT NetworkAccessManagerProxy : public KIO::Integration::AccessManager { Q_OBJECT public: static NetworkAccessManagerProxy *instance(); static void destroy(); - virtual ~NetworkAccessManagerProxy(); + ~NetworkAccessManagerProxy() override; struct Error { QNetworkReply::NetworkError code; QString description; }; /** * Gets the contents of the target @p url. It is a convenience wrapper * around QNetworkAccessManager::get() where the user supplies a * slot @p method to be called when the content is retrieved. * NOTE: On redirects requestRedirected is emitted. * * @param url the url to get the content from. * @param receiver the receiver object to call @p method on. * @param method the method to call when content is retrieved. * @param type the Qt::ConnectionType used for calling the @p method. * @return a QNetworkReply object for custom monitoring. */ template QNetworkReply *getData( const QUrl &url, Object *receiver, Return ( Object::*method )( Args... ), Qt::ConnectionType type = Qt::AutoConnection ) { if( !url.isValid() ) { const QMetaObject *mo = receiver->metaObject(); debug() << QStringLiteral( "Error: URL '%1' is invalid (from %2)" ).arg( url.url(), mo->className() ); return 0; } QNetworkReply *r = get( QNetworkRequest(url) ); m_urlMap.insert( url, r ); auto lambda = [this, r, receiver, method, type] () { replyFinished( r, QPointer( receiver ), method, type ); }; connect( r, &QNetworkReply::finished, this, lambda ); return r; } int abortGet( const QUrl &url ); int abortGet( const QList &urls ); /** * Gets the URL to which a server redirects the request. * An empty QUrl will be returned if the request was not redirected. * * @param reply The QNetworkReply which contains all information about * the reply from the server. * * @return The URL to which the server redirected the request or an empty * URL if there was no redirect. */ QUrl getRedirectUrl( QNetworkReply *reply ); #ifdef DEBUG_BUILD_TYPE NetworkAccessViewer *networkAccessViewer(); void setNetworkAccessViewer( NetworkAccessViewer *viewer ); #endif // DEBUG_BUILD_TYPE Q_SIGNALS: void requestRedirectedUrl( const QUrl &sourceUrl, const QUrl &targetUrl ); void requestRedirectedReply( QNetworkReply* oldReply, QNetworkReply *newReply ); public Q_SLOTS: void slotError( QObject *reply ); protected: QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData = 0) override; private: NetworkAccessManagerProxy( QObject *parent = nullptr ); template void replyFinished( QNetworkReply *reply, QPointer receiver, Return ( Object::*method )( Args... ), Qt::ConnectionType type ) { if( !reply || !receiver ) return; QUrl url = reply->request().url(); QByteArray data = reply->readAll(); data.detach(); // detach so the bytes are not deleted before methods are invoked // There may have been a redirect. QUrl redirectUrl = getRedirectUrl( reply ); // Check if there's no redirect. if( redirectUrl.isEmpty() ) { Error err = { reply->error(), reply->errorString() }; if( type == Qt::AutoConnection ) { if( QThread::currentThread() == receiver->thread() ) type = Qt::DirectConnection; else type = Qt::QueuedConnection; } if( type == Qt::DirectConnection ) ( receiver->*method )( url, data, err ); else { auto lambda = [receiver, method, url, data, err] () { ( receiver->*method )( url, data, err ); }; QTimer::singleShot( 0, receiver, lambda ); } } else { debug() << "the server is redirecting the request to: " << redirectUrl; // Let's try to fetch the data again, but this time from the new url. QNetworkReply *newReply = getData( redirectUrl, receiver.data(), method, type ); Q_EMIT requestRedirectedUrl( url, redirectUrl ); Q_EMIT requestRedirectedReply( reply, newReply ); } reply->deleteLater(); } static NetworkAccessManagerProxy *s_instance; QMultiHash m_urlMap; QString m_userAgent; #ifdef DEBUG_BUILD_TYPE NetworkAccessViewer *m_viewer; #endif // DEBUG_BUILD_TYPE Q_DISABLE_COPY( NetworkAccessManagerProxy ) }; Q_DECLARE_METATYPE( NetworkAccessManagerProxy::Error ) #endif // AMAROK_NETWORKACCESSMANAGERPROXY diff --git a/src/playback/EqualizerController.h b/src/playback/EqualizerController.h index fc98df19f8..e5939f1b9d 100644 --- a/src/playback/EqualizerController.h +++ b/src/playback/EqualizerController.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2004 Frederik Holljen * * Copyright (c) 2004,2005 Max Howell * * Copyright (c) 2004-2013 Mark Kretschmann * * Copyright (c) 2008 Jason A. Donenfeld * * Copyright (c) 2009 Artur Szymiec * * Copyright (c) 2013 Anmol Ahuja * * * * 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_EQUALIZERCONTROLLER_H #define AMAROK_EQUALIZERCONTROLLER_H #include "amarok_export.h" #include #include #include static const int s_equalizerBandsNum = 10; // Number of equalizer parameters excluding Preamp class AMAROK_EXPORT EqualizerController : public QObject { Q_OBJECT public: explicit EqualizerController( QObject *object ); - ~EqualizerController(); + ~EqualizerController() override; void initialize( const Phonon::Path &path ); /** * Phonon equalizer support is required for Amarok to enable equalizer * this method return whatever phonon support equalizer effect. * * @return @c true if the phonon support equalizer effect, @c false otherwise */ bool isEqSupported() const; /** * Equalizer implementation for different backends may have different * gain scale. To properly display it we need to get a scale from effect * * @return maximum gain value for equalizer parameters. */ double eqMaxGain() const; /** * Equalizer implementation for different backends may have different * frequency bands. For proper display this will try to extract frequency values * from effect parameters info. * * @return QStringList with band labels (form xxx Hz or xxx kHz). */ QStringList eqBandsFreq() const; /** * @return the name of the equalizer preset being currently used. */ QString equalizerPreset() const; /** * Changes equaliser preset to preset @param name if it exists. */ void applyEqualizerPresetByName( const QString &name ); QList gains() const; void setGains( const QList &gains ); void savePreset( const QString &name, const QList &gains ); bool deletePreset( const QString &name ); bool enabled(); public Q_SLOTS: /** * Update equalizer status - enabled,disabled,set values */ void eqUpdate(); /** * Change equalizer to preset with index @param index in the global equalizer list. * Pass -1 to disable. */ void applyEqualizerPresetByIndex( int index ); Q_SIGNALS: /** * Emitted when preset with index @param index is applied or the equalizer is disabled. * index is \<0 when disabled. */ void presetApplied( int index ); /** * Emitted when the current gains are changed. */ void gainsChanged( const QList &gains ); /** * Emitted when preset @param name is added, removed or modified. */ void presetsChanged( const QString &name ); private: QPointer m_equalizer; Phonon::Path m_path; }; #endif diff --git a/src/playback/Fadeouter.h b/src/playback/Fadeouter.h index f2982bc93d..221ad53398 100644 --- a/src/playback/Fadeouter.h +++ b/src/playback/Fadeouter.h @@ -1,70 +1,70 @@ /**************************************************************************************** * Copyright (c) 2013 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 FADEOUTER_H #define FADEOUTER_H #include #include #include namespace Phonon { class MediaObject; class VolumeFaderEffect; } /** * A RAII approach to fadeout on track stop. Once created, it automatically * initiates fadeout. Fadeouter ensures that fadeoutFinished() is signalled when * fadeout is done. It also handles well situations where different track is played * while fadeout is still active. * * In each case, Fadeouter auto-deletes itself. */ class AMAROK_EXPORT Fadeouter : public QObject { Q_OBJECT public: Fadeouter( const QPointer &media, const QPointer &fader, int fadeOutLength ); /** * Destructor ensures that fader volume is set back to normal */ - virtual ~Fadeouter(); + ~Fadeouter() override; Q_SIGNALS: /** * This signal is emitted when the fade-out is done. This signal may not * be emitted at all when Fadeouter is interrupted by new track playing. * Yuu should connect your track-finished-playing logic to this. */ void fadeoutFinished(); private Q_SLOTS: /** * Emits fadeoutFinished() and commits Fadeouter suicide. */ void slotFinalizeFadeout(); private: QPointer m_fader; }; #endif // FADEOUTER_H diff --git a/src/playback/PowerManager.h b/src/playback/PowerManager.h index cef06254b4..131358f5ae 100644 --- a/src/playback/PowerManager.h +++ b/src/playback/PowerManager.h @@ -1,50 +1,50 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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_POWERMANAGER_H #define AMAROK_POWERMANAGER_H #include class EngineController; class QDBusInterface; /** * Handle Amarok behavior on system suspend */ class PowerManager : public QObject { Q_OBJECT public: explicit PowerManager( EngineController *engine ); - ~PowerManager(); + ~PowerManager() override; private Q_SLOTS: void slotSettingsChanged(); void slotHandleSuspend(); void slotPlaying(); void slotNotPlaying(); private: void startInhibitingSuspend(); void stopInhibitingSuspend(); int m_inhibitionCookie; QDBusInterface *m_interface; }; #endif // AMAROK_POWERMANAGER_H diff --git a/src/playlist/PlaylistActions.h b/src/playlist/PlaylistActions.h index c8539618bb..a7f09066fa 100644 --- a/src/playlist/PlaylistActions.h +++ b/src/playlist/PlaylistActions.h @@ -1,183 +1,183 @@ /**************************************************************************************** * Copyright (c) 2007 Ian Monroe * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2008 Soren Harward * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_PLAYLISTACTIONS_H #define AMAROK_PLAYLISTACTIONS_H #include "amarok_export.h" #include "core/support/Debug.h" #include "core/playlists/Playlist.h" #include #include #include #include namespace Playlist { class Actions; } namespace The { AMAROK_EXPORT Playlist::Actions* playlistActions(); } namespace Playlist { class TrackNavigator; /** * This class is a central hub between the playlist model stack, the playlist navigators, * and the track playback engine. It ties them together to provide simple "Play", "Play * Next", etc. commands to the GUI code. */ class AMAROK_EXPORT Actions : public QObject { Q_OBJECT public: static Actions* instance(); static void destroy(); Meta::TrackPtr likelyNextTrack(); Meta::TrackPtr likelyPrevTrack(); /** * This is called by the engine before the current track ends. It * will figure out the next track and enqueue it. This won't * actually change the track. That happens in the engine when the * current track ends. */ void requestNextTrack(); /** * Figure out the next track, and start playing it immediately. */ void requestUserNextTrack(); /** * Figure out the previous track and start playing it immediately. */ void requestPrevTrack(); /** * Set next track from track id, but don't start playing immediately */ void requestTrack( quint64 id ); /** * Request that Amarok stops playback after playing certain track. * @param id playlist id of a track to stop playing after or 0 to disable * stopping after some track. If not specified, enable stopping * after currently playing track. */ void stopAfterPlayingTrack( quint64 id = -1 ); bool willStopAfterTrack( const quint64 id ) const; // This shouldn't be in Actions, it doesn't make sense int queuePosition( quint64 id ); // nor should this, ideally this and queuePosition // should be in TrackNavigator and TrackNavigator // should be publicly accessible QQueue queue(); bool queueMoveUp( quint64 id ); bool queueMoveDown( quint64 id ); void dequeue( quint64 id ); public Q_SLOTS: void play(); void play( const int row ); void play( const QModelIndex& index ); void play( const quint64 id, bool now = true ); void next(); void back(); void enableDynamicMode( bool enable ); /** Changes the tracknavigator depending on the current configuration */ void playlistModeChanged(); void repopulateDynamicPlaylist(); /** * Shuffles tracks (that are visible in the top model) at the bottom model level */ void shuffle(); /** * Adds a list of top playlist model rows to the queue. */ void queue( const QList &rows ); /** * Adds a list of playlist item unique ids to the queue. */ void queue( const QList &ids ); void dequeue( const QList &rows ); void restoreDefaultPlaylist(); /** * Make sure that there are enough tracks in the current playlist * if it is dynamic and the user removed tracks. */ void normalizeDynamicPlaylist(); /** * Repaint the playlist. * Useful when triggering a change that will modify the visual appearance of one or more items in the playlist */ void repaintPlaylist(); Q_SIGNALS: void navigatorChanged(); private Q_SLOTS: void slotTrackPlaying( Meta::TrackPtr engineTrack ); void slotPlayingStopped( qint64 finalPosition, qint64 trackLength ); private: Actions(); - ~Actions(); + ~Actions() override; void init(); quint64 m_nextTrackCandidate; /** * Playlist id if a track where the playback should be stopped or 0 if playback * shouldn't be stopped after certain track */ quint64 m_stopAfterPlayingTrackId; TrackNavigator* m_navigator; //!< the strategy of what to do when a track finishes playing bool m_waitingForNextTrack; static Actions* s_instance; //!< instance variable }; } // namespace Playlist #endif diff --git a/src/playlist/PlaylistBreadcrumbItem.h b/src/playlist/PlaylistBreadcrumbItem.h index c4f2de985b..4f9fcbb39c 100644 --- a/src/playlist/PlaylistBreadcrumbItem.h +++ b/src/playlist/PlaylistBreadcrumbItem.h @@ -1,182 +1,182 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * Copyright (c) 2009 Téo Mrnjavac * * * * 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 PLAYLISTBREADCRUMBITEM_H #define PLAYLISTBREADCRUMBITEM_H #include "PlaylistBreadcrumbItemSortButton.h" #include "PlaylistBreadcrumbLevel.h" #include "PlaylistDefines.h" #include "widgets/BoxWidget.h" #include #include namespace Playlist { /** * A menu that is filled with elements consisting of sortable columns * and shuffle action. */ class BreadcrumbItemMenu : public QMenu { Q_OBJECT public: /** * Constructor. * @param currentColumn The column corresponding to the current sort level * @param parent The parent QWidget */ explicit BreadcrumbItemMenu( Column currentColumn, QWidget *parent = nullptr ); /** * Destructor. */ - virtual ~BreadcrumbItemMenu(); + ~BreadcrumbItemMenu() override; Q_SIGNALS: /** * Emitted when a non-Shuffle item is triggered from the menu. * @param internalColName the internal name of the column in which the menu has been triggered. */ void actionClicked( QString internalColName ); /** * Emitted when the Shuffle item is triggered from the menu. */ void shuffleActionClicked(); private Q_SLOTS: /** * Handles the selection of an item from the menu. * @param action the action in the menu that has been triggered. */ void actionTriggered( QAction *action ); }; /** * A single item that represents a level of a general-purpose breadcrumb ribbon. * @author Téo Mrnjavac */ class BreadcrumbItem : public BoxWidget { Q_OBJECT public: /** * Constructor. * @param level The BreadcrumbLevel assigned to this item. * @param parent The parent QWidget. */ explicit BreadcrumbItem( BreadcrumbLevel *level, QWidget *parent = nullptr ); /** * Destructor. */ - ~BreadcrumbItem(); + ~BreadcrumbItem() override; /** * Returns the internal name of this item. * @return the name; */ QString name() const; /** * Returns the user visible name of this item. * @return the name; */ QString prettyName() const { return m_prettyName; } /** * Returns the state of the sort order. * @return the sort order. */ Qt::SortOrder sortOrder() const; /** * Flips the Qt::SortOrder state of the main button. */ void invertOrder(); /** * Menu accessor for the purpose of connecting to menu's signals. * @return a pointer to the constant menu object. */ const BreadcrumbItemMenu *menu(); Q_SIGNALS: /** * Emitted when the item has been clicked. */ void clicked(); /** * Emitted when the sort order of this item has been inverted. */ void orderInverted(); protected Q_SLOTS: void updateSizePolicy(); private: BreadcrumbItemMenu *m_menu; BreadcrumbItemMenuButton *m_menuButton; BreadcrumbItemSortButton *m_mainButton; QString m_name; QString m_prettyName; }; /** * A button with a tiny "+" icon in it which spawns a menu to add a sort level. * @author Téo Mrnjavac */ class BreadcrumbAddMenuButton : public BreadcrumbItemMenuButton { Q_OBJECT public: /** * Constructor. */ explicit BreadcrumbAddMenuButton( QWidget *parent ); /** * Destructor. */ - virtual ~BreadcrumbAddMenuButton(); + ~BreadcrumbAddMenuButton() override; /** * Menu accessor for the purpose of connecting to menu's signals. * @return a pointer to the constant menu object. */ const BreadcrumbItemMenu *menu(); /** * Updates the menu when the breadcrumb path changes. * @param usedBreadcrumbLevels the levels used in the path. */ void updateMenu( const QStringList &usedBreadcrumbLevels ); private: BreadcrumbItemMenu *m_menu; }; } //namespace Playlist #endif //PLAYLISTBREADCRUMBITEM_H diff --git a/src/playlist/PlaylistBreadcrumbItemSortButton.h b/src/playlist/PlaylistBreadcrumbItemSortButton.h index d85855a55d..bca6c031c9 100644 --- a/src/playlist/PlaylistBreadcrumbItemSortButton.h +++ b/src/playlist/PlaylistBreadcrumbItemSortButton.h @@ -1,127 +1,127 @@ /**************************************************************************************** * Copyright (c) 2009 Téo Mrnjavac * * * * 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 PLAYLISTBREADCRUMBITEMSORTBUTTON_H #define PLAYLISTBREADCRUMBITEMSORTBUTTON_H #include "widgets/BreadcrumbItemButton.h" #include namespace Playlist { /** * A button that implements the non-menu part of the playlist breadcrumb item. * @author Téo Mrnjavac */ class BreadcrumbItemSortButton : public BreadcrumbItemButton { Q_OBJECT public: /** * Constructor. * @param parent the parent QWidget. */ explicit BreadcrumbItemSortButton( QWidget *parent ); /** * Constructor, nontrivial. * @param icon the icon to paint on the button. * @param text the text to show on the button. * @param parent the parent QWidget. */ BreadcrumbItemSortButton( const QIcon &icon, const QString &text, QWidget *parent ); /** * Destructor. */ - virtual ~BreadcrumbItemSortButton(); + ~BreadcrumbItemSortButton() override; /** * Returns the recommended size for the button depending on the contents. * @return the recommended size. */ QSize sizeHint() const override; /** * Returns the state of the sort order defined by the order inversion arrow. * @return the sort order. */ Qt::SortOrder orderState() const; /** * Flips the Qt::SortOrder. */ void invertOrder(); Q_SIGNALS: /** * Emitted when the order inversion arrow has been toggled. * @p sortOrder the new sort order based on the position of the arrow. */ void arrowToggled( Qt::SortOrder ); protected: /** * Repaints the widget. * @param event the triggered QPaintEvent as provided by Qt. */ void paintEvent( QPaintEvent *event ) override; /** * Checks if the mouse is hovering the arrow rectangle. * @param e the triggered QMouseEvent as provided by Qt. */ void mouseMoveEvent( QMouseEvent *e ) override; /** * Handles the beginning of a mouse click. * @param e the triggered QMouseEvent as provided by Qt. */ void mousePressEvent( QMouseEvent *e ) override; /** * Handles the release of the mouse button which completes a click action. * @param e the triggered QMouseEvent as provided by Qt. */ void mouseReleaseEvent( QMouseEvent *e ) override; /** * Reimplemented from BreadcrumbItemButton, handles the painting of the widget's * background, used by paintEvent(). * @param painter the QPainter object used by paintEvent(). */ void drawHoverBackground( QPainter *painter ) override; private: /** * Common initialization method, called by every constructor. */ void init(); Qt::SortOrder m_order; QRect m_arrowRect; //!< the QRect that contains the order inversion arrow primitive. QPoint m_pressedPos; //!< the position of the last mousePressEvent, for handling clicks. bool m_arrowPressed; bool m_arrowHovered; //!< is the arrow rect hovered? int m_arrowWidth; int m_arrowHeight; }; } //namespace Playlist #endif //PLAYLISTBREADCRUMBITEMSORTBUTTON_H diff --git a/src/playlist/PlaylistController.h b/src/playlist/PlaylistController.h index 1cfc9c68aa..a02d89f735 100644 --- a/src/playlist/PlaylistController.h +++ b/src/playlist/PlaylistController.h @@ -1,248 +1,248 @@ /**************************************************************************************** * Copyright (c) 2007 Ian Monroe * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2008 Soren Harward * * Copyright (c) 2009,2010 Téo Mrnjavac * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_PLAYLISTCONTROLLER_H #define AMAROK_PLAYLISTCONTROLLER_H #include "UndoCommands.h" #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "core/playlists/Playlist.h" #include class QUndoStack; namespace Playlist { class AbstractModel; /** * No options means: append at the end of the playlist (without touching playing * state) */ enum AddOption { Replace = 1, ///< replaces the playlist instead of default appending (or queueing) Queue = 2, ///< inserts media into the queue after the currentTrack instead of default /// appending to the end of the playlist PrependToQueue = Queue | 4, ///< prepends media to the queue (after current track), implies Queue DirectPlay = PrependToQueue | 8, ///< start playback of the first item in the list, implies PrependToQueue RemotePlaylistsAreStreams = 16, ///< treat remote urls pointing to playlists as streams. /// only has sense for methods that accept urls or playlists StartPlayIfConfigured = 32, ///< start playing the first added track if Amarok is /// configured so and nothing else is already playing // following are "consistency convenience enums" so that it is easy for us to make the // bahaviour of similarly-looking UI elements the same. These enums are the preferred // ones on calling sites. Feel free to add a new one if you find another UI element // that appears on multiple places. Prefix these with On*. OnDoubleClickOnSelectedItems = StartPlayIfConfigured, OnMiddleClickOnSelectedItems = DirectPlay, OnReturnPressedOnSelectedItems = StartPlayIfConfigured, // append, should be kept same as double-click OnPlayMediaAction = DirectPlay, OnAppendToPlaylistAction = 0, // double-click is always available, so don't add StartPlayIfConfigured here OnReplacePlaylistAction = Replace | StartPlayIfConfigured, OnQueueToPlaylistAction = Queue | StartPlayIfConfigured, }; Q_DECLARE_FLAGS( AddOptions, AddOption ) /** The Playlist::Controller allows to add, remove or otherwise change tracks to the playlist. Instead of directly talking to The::Playlist or PlaylistModelStack this object should be used. It will take care of correctly placing the tracks (even if the playlist is sorted) and will handle undo and redo operations. */ class AMAROK_EXPORT Controller : public QObject { Q_OBJECT public: /** * Accessor for the singleton pattern. * @return a pointer to the only instance of Playlist::Controller. */ static Controller *instance(); /** * Singleton destructor. */ static void destroy(); public Q_SLOTS: /** * Handles the insertion of one single track into the playlist, considering a set of * options that handle the specifics of the operation. * @param track the track to be inserted. * @param options the set of options to be applied to the operation. * @see enum AddOptions. */ void insertOptioned( Meta::TrackPtr track, AddOptions options = 0 ); /** * Handles the insertion of one or more tracks into the playlist, considering a set of * options that handle the specifics of the operation. * @param list the list of tracks to be inserted. * @param options the set of options to be applied to the operation. * @see enum AddOptions. */ void insertOptioned( Meta::TrackList list, AddOptions options = 0 ); void insertOptioned( Playlists::PlaylistPtr playlist, AddOptions options = 0 ); void insertOptioned( Playlists::PlaylistList list, AddOptions options = 0 ); void insertOptioned( const QUrl &url, AddOptions options = 0 ); void insertOptioned( QList &urls, AddOptions options = 0 ); /** * Handles the insertion of one or more tracks into the playlist on a specific row. * The rows are always considered as topmost playlist model rows. * @param topModelRow the insertion row in the topmost model. * @param track the track to be inserted. */ void insertTrack( int topModelRow, Meta::TrackPtr track ); void insertTracks( int topModelRow, Meta::TrackList list ); void insertPlaylist( int topModelRow, Playlists::PlaylistPtr playlist ); void insertPlaylists( int topModelRow, Playlists::PlaylistList playlists ); void insertUrls( int topModelRow, QList &urls ); /** * Handles the removal of a single track from the playlist. * The rows are considered as topmost playlist model rows. * @param topModelRow the row to remove in the topmost model. */ void removeRow( int topModelRow ); /** * Handles the removal of tracks from the playlist. * The rows are considered as topmost playlist model rows. * @param topModelRow the row to remove in the topmost model. * @param count the number of rows to remove. */ void removeRows( int topModelRow, int count ); /** * Handles the removal of a list of tracks from the playlist. * The rows are considered as topmost playlist model rows. * @param topModelRows the list of row numbers to remove. */ void removeRows( QList& topModelRows ); /** * Removes unplayable and duplicate entries in the topmost playlist model, i.e. * respects playlist filters. */ void removeDeadAndDuplicates(); /** * Moves a track from one row to another in the playlist. * @param topModelFrom the row containing the track that is about to be moved. * @param topModelTo the target row where the track should be moved. */ void moveRow( int topModelFrom, int topModelTo ); /** * Moves a list of tracks to a specified row in the playlist. * This function returns the real starting location where the rows ended up. * For example, if you start with the following playlist: * 0 Alpha * 1 Bravo * 2 Charlie * 3 Delta * 4 Echo * 5 Foxtrot * and you call moveRows( [0,1,2], 4 ) then the playlist will end up with * 0 Delta * 1 Echo * 2 Alpha * 3 Bravo * 4 Charlie * 5 Foxtrot * and the function will return 2, because that's where the rows really ended up. * @param topModelFrom the list of rows containing the tracks that are about to be moved. * @param topModelTo the target row where the tracks should be moved. * @return the first row where the tracks ended up in the new list. */ int moveRows( QList& topModelFrom, int topModelTo ); /** * Reorders tracks in the playlist. For each i, track at position * topModelFrom[i] is moved to the position topModelTo[i]. Note that when track * on position A is moved to the position B, the track from position B needs to * be moved as well. As a consequence, every track position appearing * in topModelFrom needs to appear in topModelTo. * @param topModelFrom the list containing positions of tracks to be moved * @param topModelTo the list containing positions the tracks should be moved to */ void reorderRows( const QList &topModelFrom, const QList &topModelTo ); void undo(); void redo(); void clear(); Q_SIGNALS: void canRedoChanged( bool ); void canUndoChanged( bool ); void changed(); void replacingPlaylist(); private Q_SLOTS: void slotLoaderWithOptionsFinished( const Meta::TrackList &tracks ); void slotLoaderWithRowFinished( const Meta::TrackList &tracks ); private: Controller(); - ~Controller(); + ~Controller() override; static Controller *s_instance; //!< Instance member. /** * Converts a row number in 'm_topModel' to a row in 'm_bottomModel', for purposes of * insert. This is not useful for remove/move. */ int insertionTopRowToBottom( int topModelRow ); /** * Handles the insertion of a list of tracks into the playlist on a specific row. * The row number is always in the *bottom* playlist model, in contrast to most other * functions in this class. * @param bottomModelRow the insertion row in the bottom model. * @param tl the Meta::TrackList to be inserted. */ void insertionHelper( int bottomModelRow, Meta::TrackList& tl ); AbstractModel* m_topModel; AbstractModel* m_bottomModel; QUndoStack* m_undoStack; }; } Q_DECLARE_OPERATORS_FOR_FLAGS( Playlist::AddOptions ) Q_DECLARE_METATYPE( Playlist::AddOptions ) namespace The { AMAROK_EXPORT Playlist::Controller* playlistController(); } #endif diff --git a/src/playlist/PlaylistInfoWidget.h b/src/playlist/PlaylistInfoWidget.h index 4c8853ce32..4062a2027a 100644 --- a/src/playlist/PlaylistInfoWidget.h +++ b/src/playlist/PlaylistInfoWidget.h @@ -1,40 +1,40 @@ /**************************************************************************************** * Copyright (c) 2011 Kevin Funk * * Copyright (c) 2013 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 AMAROK_PLAYLISTINFOWIDGET_H #define AMAROK_PLAYLISTINFOWIDGET_H #include /** A small widget that displays the current length and size of the playlist. It is used in the bottom bar of the playlist view */ class PlaylistInfoWidget : public QLabel { Q_OBJECT public: explicit PlaylistInfoWidget( QWidget* parent = nullptr ); - virtual ~PlaylistInfoWidget(); + ~PlaylistInfoWidget() override; protected: bool event( QEvent *event ) override; private Q_SLOTS: void updateTotalPlaylistLength(); }; #endif diff --git a/src/playlist/PlaylistModel.h b/src/playlist/PlaylistModel.h index f111c073c8..68e5887d3b 100644 --- a/src/playlist/PlaylistModel.h +++ b/src/playlist/PlaylistModel.h @@ -1,171 +1,171 @@ /**************************************************************************************** * Copyright (c) 2007 Ian Monroe * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2008 Soren Harward * * Copyright (c) 2008 Nikolaj Hald Nielsen * * Copyright (c) 2010 Nanno Langstraat * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_PLAYLISTMODEL_H #define AMAROK_PLAYLISTMODEL_H #include "UndoCommands.h" #include "amarok_export.h" #include "core/meta/Observer.h" #include "core/support/Amarok.h" #include "playlist/proxymodels/AbstractModel.h" #include #include #include #include class QMimeData; class QModelIndex; class TestPlaylistModels; namespace Playlist { class AMAROK_EXPORT Model : public QAbstractListModel, public Meta::Observer, public Playlist::AbstractModel { friend class InsertTracksCmd; friend class RemoveTracksCmd; friend class MoveTracksCmd; friend class ::TestPlaylistModels; //this test really needs access to the private functions. Q_OBJECT public: explicit Model( QObject *parent = nullptr ); - ~Model(); + ~Model() override; // Inherited from QAbstractItemModel (via QAbstractListModel) int columnCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); return NUM_COLUMNS; } QVariant data( const QModelIndex& index, int role ) const override; bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) override; Qt::ItemFlags flags( const QModelIndex &index ) const override; QVariant headerData( int section, Qt::Orientation orientation, int role ) const override; QMimeData* mimeData( const QModelIndexList &indexes ) const override; QStringList mimeTypes() const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); return m_items.size(); } Qt::DropActions supportedDropActions() const override; // Inherited from Playlist::AbstractModel QAbstractItemModel* qaim() const override { return const_cast( this ); } quint64 activeId() const override; Meta::TrackPtr activeTrack() const override; int activeRow() const override { return m_activeRow; } // returns -1 if there is no active row bool containsTrack( const Meta::TrackPtr& track ) const override; int firstRowForTrack( const Meta::TrackPtr& track ) const override; QSet allRowsForTrack( const Meta::TrackPtr& track ) const override; quint64 idAt( const int row ) const override; bool rowExists( int row ) const override { return (( row >= 0 ) && ( row < m_items.size() ) ); } int rowForId( const quint64 id ) const override; // returns -1 if the id is invalid int rowFromBottomModel( const int row ) override { return row; } int rowToBottomModel( const int row ) override { return row; } void setActiveId( const quint64 id ) override { setActiveRow( rowForId( id ) ); } void setActiveRow( int row ) override; void setAllNewlyAddedToUnplayed(); void setAllUnplayed() override; void emitQueueChanged() override; int queuePositionOfRow( int row ) override; Item::State stateOfId( quint64 id ) const override; Item::State stateOfRow( int row ) const override; qint64 totalLength() const override { return m_totalLength; } quint64 totalSize() const override { return m_totalSize; } Meta::TrackPtr trackAt( int row ) const override; Meta::TrackPtr trackForId( const quint64 id ) const override; bool exportPlaylist( const QString &path, bool relative = false ) override; Meta::TrackList tracks() override; // Inherited from Meta::Observer using Observer::metadataChanged; void metadataChanged( const Meta::TrackPtr &track ) override; void metadataChanged( const Meta::AlbumPtr &album ) override; // static member functions static QString prettyColumnName( Column index ); //!< takes a Column enum and returns its string name /** Set the columns that are displayed in the tooltip */ static void setTooltipColumns( bool columns[] ); static void enableToolTip( bool enable ); Q_SIGNALS: void activeTrackChanged( quint64 ); void queueChanged(); protected: int rowForItem( Item *item ) const { return m_items.indexOf( item ); } private Q_SLOTS: void saveState(); void queueSaveState(); void insertTracksFromTrackLoader( const Meta::TrackList &tracks ); private: QString tooltipFor( Meta::TrackPtr track ) const; // Inherited from QAbstractItemModel. Make them private so that nobody is tempted to use them. bool insertRow( int, const QModelIndex& parent = QModelIndex() ) { Q_UNUSED( parent ); return false; } bool insertRows( int, int, const QModelIndex& parent = QModelIndex() ) override { Q_UNUSED( parent ); return false; } bool removeRow( int, const QModelIndex& parent = QModelIndex() ) { Q_UNUSED( parent ); return false; } bool removeRows( int, int, const QModelIndex& parent = QModelIndex() ) override { Q_UNUSED( parent ); return false; } // These functions do the real work of modifying the playlist, and should be called ONLY by UndoCommands void insertTracksCommand( const InsertCmdList& ); void removeTracksCommand( const RemoveCmdList& ); void moveTracksCommand( const MoveCmdList&, bool reverse = false ); void clearCommand(); // Always alter the state of a row via one of the following functions. void setStateOfItem_batchStart(); void setStateOfItem_batchEnd(); void setStateOfItem( Item *item, int row, Item::State state ); // 'item' must equal 'm_items.at( row )' void setStateOfItem( Item *item, Item::State state ) { setStateOfItem( item, rowForItem( item ), state ); } void setStateOfRow( int row, Item::State state ) { setStateOfItem( m_items.at( row ), row, state ); } // Variables QList m_items; //!< list of playlist items, in their "natural" (unsorted) order. QHash m_itemIds; //!< maps playlist item ID to Item pointer. int m_activeRow; //!< the row being played qint64 m_totalLength; quint64 m_totalSize; QString m_playlistName; bool m_proposeOverwriting; int m_setStateOfItem_batchMinRow; //!< For 'setStateOfItem_batch*()' int m_setStateOfItem_batchMaxRow; static bool s_tooltipColumns[NUM_COLUMNS]; static bool s_showToolTip; QTimer *m_saveStateTimer; }; } // namespace Playlist #endif diff --git a/src/playlist/PlaylistModelStack.h b/src/playlist/PlaylistModelStack.h index 3f41f31b8b..c1d2a98a16 100644 --- a/src/playlist/PlaylistModelStack.h +++ b/src/playlist/PlaylistModelStack.h @@ -1,104 +1,104 @@ /**************************************************************************************** * Copyright (c) 2009 Téo Mrnjavac * * * * 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_PLAYLISTMODELSTACK_H #define AMAROK_PLAYLISTMODELSTACK_H #include "proxymodels/AbstractModel.h" #include "PlaylistModel.h" #include "proxymodels/SortFilterProxy.h" #include "proxymodels/SearchProxy.h" #include "proxymodels/GroupingProxy.h" // THE PLAYLIST MODELS ARCHITECTURE // Amarok's playlist uses Qt's Model-View design pattern, so we have // * 1 source model which feeds the tracks data: Playlist::Model // * 3 proxies which modify the rows: SortFilterProxy==>SearchProxy==>GroupingProxy // * 1 or more views, such as Playlist::PrettyListView. // At any time a view should ONLY talk to the topmost proxy model, exposed by Playlist:: // ModelStack::instance()->groupingProxy() or The::playlist() for short. // External classes that talk to the playlist should only talk to The::playlist(), // exceptionally to Playlist::ModelStack::instance()->bottom() if they really really need // the source model. // // Each playlist model implements the interface defined in Playlist::AbstractModel. // Each playlist proxy is a subclass od QSortFilterProxyModel through Playlist::ProxyBase, // and uses the default implementations of AbstractModel methods defined in ProxyBase. // To add a new proxy the recommended procedure is to subclass ProxyBase (which drags in // QSortFilterProxyModel, this is no problem because QSortFilterProxyModel is transparent // and fast by default), reimplement the relevant methods from ProxyBase and insert it in // the right place in the ModelStack constructor. // --Téo 13/8/2009 namespace Playlist { /** * Singleton class that handles and wraps around the Playlist models architecture. * To talk to the playlist, use The::playlist(). Playlist::ModelStack::instance()->bottom() * should only be used internally or in very specific situations. * @author Téo Mrnjavac */ class AMAROK_EXPORT ModelStack : public QObject { Q_OBJECT public: /** * Accessor for the singleton pattern. * @return a pointer to the only instance of Playlist::ModelStack. */ static ModelStack *instance(); /** * Singleton destructor. */ static void destroy(); /** * Use the 'The::playlist()' model unless you have a specific need for a lower model. */ GroupingProxy *groupingProxy(); SortFilterProxy *sortProxy(); SortFilterProxy *filterProxy(); Playlist::Model *bottom(); private: /** * Constructor. */ ModelStack(); /** * Destructor. */ - ~ModelStack(); + ~ModelStack() override; static ModelStack *s_instance; //!< Instance member. GroupingProxy *m_grouping; SearchProxy *m_search; SortFilterProxy *m_sortfilter; Model *m_model; }; } //namespace Playlist namespace The { AMAROK_EXPORT Playlist::AbstractModel* playlist(); } #endif //AMAROK_PLAYLISTMODELSTACK_H diff --git a/src/playlist/PlaylistSortWidget.h b/src/playlist/PlaylistSortWidget.h index a97b444d6f..56823fb624 100644 --- a/src/playlist/PlaylistSortWidget.h +++ b/src/playlist/PlaylistSortWidget.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2009 Téo Mrnjavac * * * * 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 PLAYLISTSORTWIDGET_H #define PLAYLISTSORTWIDGET_H #include "PlaylistBreadcrumbItem.h" #include #include namespace Playlist { /** * A breadcrumb-based widget that allows the user to build a multilevel sorting scheme for * the playlist. * @author Téo Mrnjavac */ class SortWidget : public QWidget { Q_OBJECT public: /** * Constructor. */ explicit SortWidget( QWidget *parent ); /** * Destructor. */ - ~SortWidget(); + ~SortWidget() override; /** * Returns the list of levels that are currently defined in the breadcrumb path. * @return the list of names of levels. */ QStringList levels() const; /** * Generates a QString usable by a URL runner that represents the current sort scheme. */ QString sortPath() const; /** * Generate current sort scheme from a sort path stored in a QString. */ void readSortPath( const QString &sortPath ); /** * Generates a user-visible QString usable by a URL runner for the title of a bookmark. */ QString prettySortPath() const; public Q_SLOTS: /** * Generates a new sort scheme and forwards it to Playlist::SortProxy to apply it to * the playlist. */ void updateSortScheme(); /** * Removes items from the breadcrumb path up to a certain level. * @param level the cutoff level of the breadcrumb path. */ void trimToLevel( const int level = -1 ); private: QHBoxLayout * m_ribbon; QList< BreadcrumbItem * > m_items; BreadcrumbAddMenuButton * m_addButton; QHBoxLayout * m_layout; BreadcrumbUrlMenuButton *m_urlButton; private Q_SLOTS: /** * Adds a level to the breadcrumb path. * @param internalColumnName the name of the level. * @param sortOrder the Qt::SortOrder of the level. */ void addLevel( const QString &internalColumnName, Qt::SortOrder sortOrder = Qt::AscendingOrder ); /** * Adds a level to the breadcrumb path. * Orders the level in ascending order. * @param internalColumnName the name of the level. */ void addLevelAscending( const QString &internalColumnName ); /** * Handles the (possible) deletion of further levels when an item is clicked. */ void onItemClicked(); /** * Handles the rearrangement of the breadcrumb path when a sibling of an item is clicked. * @param action the action in the menu. */ void onItemSiblingClicked( const QString &internalColumnName ); /** * Handles the rearrangement of the breadcrumb path when a Shuffle action is clicked. */ void onShuffleSiblingClicked(); }; } //namespace Playlist #endif //PLAYLISTSORTWIDGET_H diff --git a/src/playlist/PlaylistViewUrlGenerator.h b/src/playlist/PlaylistViewUrlGenerator.h index aba40077bc..4c2cc633b4 100644 --- a/src/playlist/PlaylistViewUrlGenerator.h +++ b/src/playlist/PlaylistViewUrlGenerator.h @@ -1,47 +1,47 @@ /**************************************************************************************** * Copyright (c) 2009 Téo Mrnjavac * * * * 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 PLAYLISTVIEWURLGENERATOR_H #define PLAYLISTVIEWURLGENERATOR_H #include "amarok_export.h" #include "amarokurls/AmarokUrl.h" #include "amarokurls/AmarokUrlGenerator.h" namespace Playlist { class AMAROK_EXPORT ViewUrlGenerator : public AmarokUrlGenerator { public: static ViewUrlGenerator * instance(); QString description() override; QIcon icon() override; AmarokUrl createUrl() override; private: ViewUrlGenerator(); - virtual ~ViewUrlGenerator(); + ~ViewUrlGenerator() override; static ViewUrlGenerator * s_instance; }; } #endif //PLAYLISTVIEWURLGENERATOR_H diff --git a/src/playlist/PlaylistViewUrlRunner.h b/src/playlist/PlaylistViewUrlRunner.h index 72a17e28d5..5449c36eaa 100644 --- a/src/playlist/PlaylistViewUrlRunner.h +++ b/src/playlist/PlaylistViewUrlRunner.h @@ -1,43 +1,43 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * Copyright (c) 2009 Téo Mrnjavac * * * * 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 PLAYLISTVIEWURLRUNNER_H #define PLAYLISTVIEWURLRUNNER_H #include "amarokurls/AmarokUrl.h" #include "amarokurls/AmarokUrlRunnerBase.h" #include namespace Playlist { class ViewUrlRunner : public AmarokUrlRunnerBase { public: ViewUrlRunner(); - virtual ~ViewUrlRunner(); + ~ViewUrlRunner() override; QString command() const override; QString prettyCommand() const override; QIcon icon() const override; bool run( const AmarokUrl &url ) override; }; } #endif //PLAYLISTVIEWURLRUNNER_H diff --git a/src/playlist/layouts/LayoutConfigAction.h b/src/playlist/layouts/LayoutConfigAction.h index 80a25575d9..019dd2cfed 100644 --- a/src/playlist/layouts/LayoutConfigAction.h +++ b/src/playlist/layouts/LayoutConfigAction.h @@ -1,84 +1,84 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * Copyright (c) 2009 Téo Mrnjavac * * * * 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 LAYOUTCONFIGACTION_H #define LAYOUTCONFIGACTION_H #include #include #include namespace Playlist { class PlaylistLayoutEditDialog; /** * Action used to show a menu for selecting active playlist layout. Also contains an entry for showing the * playlist layout editor. * @author Nikolaj Hald Nielsen */ class LayoutConfigAction : public QAction { Q_OBJECT public: /** * Constructor. * @param parent Parent widget. */ explicit LayoutConfigAction( QWidget * parent ); /** * Destructor. */ - ~LayoutConfigAction(); + ~LayoutConfigAction() override; protected Q_SLOTS: /** * Set the currently active layout based on the selected action. * @param layoutAction The layoutAction triggered. */ void setActiveLayout( QAction *layoutAction ); /** * Notify the action that the list of selectable layouts have changed. Clears the list of layouts * and refetches it from the LayoutManager. */ void layoutListChanged(); /** * Launch the playlist layout editor. */ void configureLayouts(); /** * The active layout has changed. Update the selected item to represent this. */ void onActiveLayoutChanged(); private: QAction *m_configAction; QActionGroup *m_layoutActions; QMenu *m_layoutMenu; PlaylistLayoutEditDialog * m_layoutDialog; }; } #endif diff --git a/src/playlist/layouts/LayoutEditWidget.h b/src/playlist/layouts/LayoutEditWidget.h index b72ed987ac..3c28138257 100644 --- a/src/playlist/layouts/LayoutEditWidget.h +++ b/src/playlist/layouts/LayoutEditWidget.h @@ -1,84 +1,84 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 LAYOUTEDITWIDGET_H #define LAYOUTEDITWIDGET_H #include "LayoutItemConfig.h" #include "widgets/TokenWithLayout.h" #include class QCheckBox; class TokenDropTarget; namespace Playlist { /** * A widget to define the layout of a single type of playlist item ( head, body or single ) * @author Nikolaj Hald Nielsen */ class LayoutEditWidget : public QWidget { Q_OBJECT public: /** * Constructor. * @param parent The parent widget. */ explicit LayoutEditWidget( QWidget *parent ); /** * Destructor. */ - ~LayoutEditWidget(); + ~LayoutEditWidget() override; /** * Setup the edit widget to represent an existing LayoutItemConfig. * @param config The config to read. */ void readLayout( const Playlist::LayoutItemConfig &config ); /** * Create and return a LayoutItemConfig corresponding to the current state of the editor * @return LayoutItemConfig matching the contents of the editor. */ Playlist::LayoutItemConfig config(); /** * Clear the editor. */ void clear(); Q_SIGNALS: /** * Signal emitted when the token drop target receives input focus. * The parameter is a widget that received the focus. */ void focuseReceived( QWidget* ); void changed(); private: QCheckBox *m_showCoverCheckBox; TokenDropTarget *m_dragstack; }; } #endif diff --git a/src/playlist/layouts/PlaylistLayoutEditDialog.h b/src/playlist/layouts/PlaylistLayoutEditDialog.h index 66d3e5da4c..3bb34e34ec 100644 --- a/src/playlist/layouts/PlaylistLayoutEditDialog.h +++ b/src/playlist/layouts/PlaylistLayoutEditDialog.h @@ -1,153 +1,153 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * Copyright (c) 2009 Téo Mrnjavac * * * * 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 PLAYLISTLAYOUTEDITDIALOG_H #define PLAYLISTLAYOUTEDITDIALOG_H #include "playlist/layouts/LayoutEditWidget.h" #include "playlist/layouts/LayoutItemConfig.h" #include #include "ui_PlaylistLayoutEditDialog.h" namespace Playlist { /** * Dialog for adding, deleting, copying and editing playlist layouts. The order in which the layouts are * shown can also be changed. * @author Nikolaj Hald Nielsen */ class PlaylistLayoutEditDialog : public QDialog, private Ui::PlaylistLayoutEditDialog { Q_OBJECT public: /** * Constructor for PlaylistLayoutEditDialog. * Populates the token pool, loads the available layouts from the LayoutManager in the right area and loads the configuration of the currently active layout. * @param parent The parent widget. */ explicit PlaylistLayoutEditDialog( QWidget *parent = nullptr ); /** * Destructor. */ - ~PlaylistLayoutEditDialog(); + ~PlaylistLayoutEditDialog() override; public Q_SLOTS: /** * Set the currently selected layout. * Loads the configuration of the layout layoutName from the m_layoutsMap to the LayoutItemConfig area. * @param layoutName The name of the layout to select. */ void setLayout( const QString &layoutName ); protected Q_SLOTS: /** * Previews the current layout in the playlist without saving it. */ void preview(); /** * Accepts the currently changed layouts and stores them. Closes the dialog. */ void accept() override; /** * Reject the changed layouts and close the dialog. */ void reject() override; /** * Accepts the currently changed layouts and stores them. */ void apply(); /** * Creates a new PlaylistLayout with a given name and loads it in the right area to configure it. * The new layout is not saved in the LayoutManager but in m_layoutsMap. */ void newLayout(); /** * Creates a new PlaylistLayout with a given name as a copy of an existing layout and loads it in the right area to configure it. * The new layout is not saved in the LayoutManager but in m_layoutsMap. */ void copyLayout(); /** * Deletes the current layout selected in the layoutListWidget. */ void deleteLayout(); /** * Renames the current layout selected in the layoutListWidget. */ void renameLayout(); /** * Moves the currently selected layout up one place (if not already at the top). This is applied immediately. */ void moveUp(); /** * Moves the currently selected layout down one place (if not already at the bottom). This is applied immediately. */ void moveDown(); /** * Disables the delete and rename buttons if the selected layout is one of the default layouts and enables them otherwise. */ void toggleEditButtons(); /** * Activates/Deactivates the up and down buttons depending on whether the currently selected item can be moved up and or down. */ void toggleUpDownButtons(); /** Writes back the current UI values to the m_layoutsMap. */ void setLayoutChanged(); private: /** * Changes which layout tabs are enabled based on the grouping mode selected */ void setEnabledTabs(); /** * Populates the grouping mode combo box with options */ void setupGroupByCombo(); Playlist::LayoutEditWidget *m_partsEdit[Playlist::PlaylistLayout::NumParts]; QMap *m_layoutsMap; /** The name of the currently active layout */ QString m_layoutName; QString m_firstActiveLayout; }; } #endif diff --git a/src/playlist/navigators/DynamicTrackNavigator.h b/src/playlist/navigators/DynamicTrackNavigator.h index b7c76e6ac1..f75f54e1ed 100644 --- a/src/playlist/navigators/DynamicTrackNavigator.h +++ b/src/playlist/navigators/DynamicTrackNavigator.h @@ -1,64 +1,64 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Jones * * Copyright (c) 2010 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 DYNAMICTRACKNAVIGATOR_H #define DYNAMICTRACKNAVIGATOR_H #include "StandardTrackNavigator.h" namespace Dynamic { class DynamicPlaylist; } #include namespace Playlist { /** A navigator that implements 'dynamic mode', which is a never-ending queue of tracks. The navigator will use the current dynamic playlist and try to get new tracks before advancing */ class DynamicTrackNavigator : public StandardTrackNavigator { Q_OBJECT public: DynamicTrackNavigator() ; - ~DynamicTrackNavigator(); + ~DynamicTrackNavigator() override; void appendUpcoming(); public Q_SLOTS: void repopulate(); private Q_SLOTS: void activePlaylistChanged(); void receiveTracks( const Meta::TrackList &); void trackChanged(); private: void removePlayed(); QPointer m_playlist; }; } #endif diff --git a/src/playlist/navigators/NavigatorConfigAction.h b/src/playlist/navigators/NavigatorConfigAction.h index 9cf0dfce53..e89abd0b1b 100644 --- a/src/playlist/navigators/NavigatorConfigAction.h +++ b/src/playlist/navigators/NavigatorConfigAction.h @@ -1,67 +1,67 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 Pulic License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see . * ****************************************************************************************/ #ifndef NAVIGATORCONFIGACTION_H #define NAVIGATORCONFIGACTION_H #include class NavigatorConfigAction : public QAction { Q_OBJECT public: /** * Constructor. * @param parent Parent widget. */ explicit NavigatorConfigAction( QWidget * parent ); /** * Destructor. */ - ~NavigatorConfigAction(); + ~NavigatorConfigAction() override; protected Q_SLOTS: /** * Set the currently active navigator based on the selected action. * @param navigatorAction The action triggered. */ void setActiveNavigator( QAction *navigatorAction ); void setFavored( QAction *favorAction ); void navigatorChanged(); private: QAction * m_standardNavigatorAction; QAction * m_onlyQueueNavigatorAction; QAction * m_repeatTrackNavigatorAction; QAction * m_repeatAlbumNavigatorAction; QAction * m_repeatPlaylistNavigatorAction; QAction * m_randomTrackNavigatorAction; QAction * m_randomAlbumNavigatorAction; QAction * m_favorNoneAction; QAction * m_favorScoresAction; QAction * m_favorRatingsAction; QAction * m_favorLastPlayedAction; }; #endif // NAVIGATORCONFIGACTION_H diff --git a/src/playlist/navigators/TrackNavigator.h b/src/playlist/navigators/TrackNavigator.h index db7469e6a0..fde21d30b8 100644 --- a/src/playlist/navigators/TrackNavigator.h +++ b/src/playlist/navigators/TrackNavigator.h @@ -1,136 +1,136 @@ /**************************************************************************************** * Copyright (c) 2007 Ian Monroe * * Copyright (c) 2008 Soren Harward * * Copyright (c) 2009 Téo Mrnjavac * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 TRACKNAVIGATOR_H #define TRACKNAVIGATOR_H #include "playlist/proxymodels/AbstractModel.h" #include #include namespace Playlist { typedef QList ItemList; // A convenient typedef! /** * An abstract class which defines what should be done after a track * finishes playing. The Playlist::Model will have an object of the * currently active strategy. It is the "strategy" pattern from the Design * Patterns book. In Amarok 1.x, the Playlist became very confusing due to * random mode and dynamic playlists requiring complicated nested if * statements. This should prevent that. */ class TrackNavigator : public QObject { Q_OBJECT public: TrackNavigator(); - virtual ~TrackNavigator() { } + ~TrackNavigator() override { } /** * what is the next track at this moment. It could change before the * track really plays (you need to catch playlist changes); does NOT * affect the navigators queue. */ virtual quint64 likelyNextTrack() = 0; /** * what is the last track at this moment. It could change before the * track really plays (you need to catch playlist changes); does NOT * affect the navigators queue. */ virtual quint64 likelyLastTrack() = 0; /** * The engine will finish the current track in a couple of seconds, * and would like to know what the next track should be. */ virtual quint64 requestNextTrack() = 0; /** * The user triggers the next-track action. */ virtual quint64 requestUserNextTrack() = 0; /** * The user triggers the previous-track action. */ virtual quint64 requestLastTrack() = 0; /** * Find the position of the id in the queue * @return the position, or -1 if non in queue */ int queuePosition( const quint64 id ) const; /** * Getter for the internal queue. * @return the tracks queued. */ QQueue queue(); public Q_SLOTS: /** * Queues the specified id and schedules it to be played. */ virtual void queueIds( const QList &ids ); /** * Dequeue the specified id from the queue list */ virtual void dequeueId( const quint64 id ); /** * Play the track one position earlier. */ bool queueMoveUp( const quint64 id ); /** * Play the track one position later. */ bool queueMoveDown( const quint64 id ); private Q_SLOTS: void slotModelReset(); void slotRowsAboutToBeRemoved( const QModelIndex &parent, int start, int end ); protected: /** * Choose the most reasonable fallback item in case a navigator wants to play * something, but doesn't have a good choice itself. */ quint64 bestFallbackItem(); // Holds the list of tracks to be played next. General // workflow should dictate that the TrackAdvancer should // respect the queue list as an override to what the Advancer // implementation would normally return as the next track. // TODO: a history queue to allow requestLastTrack() to work // properly? // Static queue so that all navigators share the same queue QQueue m_queue; AbstractModel *m_model; }; } #endif diff --git a/src/playlist/proxymodels/GroupingProxy.h b/src/playlist/proxymodels/GroupingProxy.h index abed5cfb45..d4369876b6 100644 --- a/src/playlist/proxymodels/GroupingProxy.h +++ b/src/playlist/proxymodels/GroupingProxy.h @@ -1,157 +1,157 @@ /**************************************************************************************** * Copyright (c) 2007-2008 Ian Monroe * * Copyright (c) 2007 Nikolaj Hald Nielsen * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2008 Soren Harward * * Copyright (c) 2009 Téo Mrnjavac * * Copyright (c) 2010 Nanno Langstraat * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_PLAYLISTGROUPINGPROXY_H #define AMAROK_PLAYLISTGROUPINGPROXY_H #include "ProxyBase.h" #include "core/meta/forward_declarations.h" #include #include #include namespace Playlist { // Extension of Playlist::DataRoles enum GroupDataRoles { GroupRole = 0x1000, GroupedTracksRole // deprecated }; namespace Grouping { enum GroupMode { None = 1, Head, Head_Collapsed, // deprecated Body, Tail, Collapsed, // deprecated Invalid }; } class GroupingProxy : public ProxyBase { Q_OBJECT public: explicit GroupingProxy( AbstractModel *belowModel, QObject *parent = nullptr ); - ~GroupingProxy(); + ~GroupingProxy() override; static GroupingProxy* instance(); static void destroy(); //! Configuration QString groupingCategory() const; /** * The criterion by which adjacent items are divided into groups. * @param groupingCategory A string from 'groupableCategories', or "None", or empty string. */ void setGroupingCategory( const QString &groupingCategory ); //! Grouping info functions /** * @return true if 'index' is the first item of a Group. */ bool isFirstInGroup( const QModelIndex & index ); /** * @return true if 'index' is the last item of a Group. */ bool isLastInGroup( const QModelIndex & index ); /** * @return The first item of the Group that 'index' belongs to. */ QModelIndex firstIndexInSameGroup( const QModelIndex & index ); /** * @return The last item of the Group that 'index' belongs to. */ QModelIndex lastIndexInSameGroup( const QModelIndex & index ); /** * @return The number of items in the Group that 'index' belongs to. */ int groupRowCount( const QModelIndex & index ); /** * @return The play length (in seconds) of the Group that 'index' belongs to. */ int groupPlayLength( const QModelIndex & index ); //! Custom version of functions inherited from QSortFilterProxyModel QVariant data( const QModelIndex &index, int role ) const override; //Q_SIGNALS: // Emits signals inherited from QSortFilterProxy // Emits signals inherited from Playlist::AbstractModel / ProxyBase private Q_SLOTS: /** * Handlers for the standard QAbstractItemModel signals. */ void proxyDataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight ); void proxyLayoutChanged(); void proxyModelReset(); void proxyRowsInserted( const QModelIndex& parent, int start, int end ); void proxyRowsRemoved( const QModelIndex& parent, int start, int end ); private: /** * This function determines the "Status within the group" of a model row. */ Grouping::GroupMode groupModeForIndex( const QModelIndex & index ); /** * This function is used to determine if 2 tracks belong in the same group. * The track pointers are allowed to be invalid. * @return true if track should be grouped together, false otherwise */ bool shouldBeGrouped( Meta::TrackPtr track1, Meta::TrackPtr track2 ); /** * Invalidate any cached assumptions about model rows. */ void invalidateGrouping(); // Variables QString m_groupingCategory; int m_groupingCategoryIndex; QHash m_cachedGroupModeForRow; }; } // namespace Playlist #endif diff --git a/src/playlist/proxymodels/ProxyBase.h b/src/playlist/proxymodels/ProxyBase.h index f78c694b35..fddd8b7887 100644 --- a/src/playlist/proxymodels/ProxyBase.h +++ b/src/playlist/proxymodels/ProxyBase.h @@ -1,124 +1,124 @@ /**************************************************************************************** * Copyright (c) 2009 Téo Mrnjavac * * Copyright (c) 2010 Nanno Langstraat * * * * 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_PROXYBASE_H #define AMAROK_PROXYBASE_H #include "AbstractModel.h" #include "playlist/PlaylistItem.h" #include namespace Playlist { /** * A ProxyModel that implements all the common forwarders for the interface of any * playlist proxy. * @author Téo Mrnjavac */ class ProxyBase : public QSortFilterProxyModel, public Playlist::AbstractModel { Q_OBJECT public: /** * Constructor. */ explicit ProxyBase( AbstractModel *belowModel, QObject *parent = nullptr ); /** * Destructor. */ - virtual ~ProxyBase(); + ~ProxyBase() override; //! Inherited from Playlist::AbstractModel QAbstractItemModel* qaim() const override { return const_cast( this ); } quint64 activeId() const override; int activeRow() const override; Meta::TrackPtr activeTrack() const override; QSet allRowsForTrack( const Meta::TrackPtr& track ) const override; void clearSearchTerm() override; bool containsTrack( const Meta::TrackPtr& track ) const override; int currentSearchFields() override; QString currentSearchTerm() override; bool exportPlaylist( const QString &path, bool relative = false ) override; void filterUpdated() override; int find( const QString &searchTerm, int searchFields ) override; int findNext( const QString &searchTerm, int selectedRow, int searchFields ) override; int findPrevious( const QString &searchTerm, int selectedRow, int searchFields ) override; int firstRowForTrack( const Meta::TrackPtr& track ) const override; quint64 idAt( const int row ) const override; bool rowExists( int row ) const override; int rowForId( const quint64 id ) const override; int rowFromBottomModel( const int rowInBase ) override; int rowToBottomModel( const int rowInProxy ) override; void setActiveId( const quint64 id ) override; void setActiveRow( int row ) override; void setAllUnplayed() override; void emitQueueChanged() override; int queuePositionOfRow( int row ) override; void showOnlyMatches( bool onlyMatches ) override; Item::State stateOfId( quint64 id ) const override; Item::State stateOfRow( int row ) const override; qint64 totalLength() const override; quint64 totalSize() const override; Meta::TrackPtr trackAt( int row ) const override; Meta::TrackPtr trackForId( const quint64 id ) const override; Meta::TrackList tracks() override; Q_SIGNALS: //! Proxied from Playlist::Model. void activeTrackChanged( const quint64 ); void queueChanged(); protected: /** * Check if a certain row in the source model matches a search term when looking at * the fields specified by the searchFields bitmask. * @param sourceModelRow The row number in the source model to match against. * @param searchTerm The search term. * @param searchFields A bitmask containing the fields that should be matched against. * @return True if a match is found in any field, false otherwise. */ bool rowMatch( int sourceModelRow, const QString &searchTerm, int searchFields ) const; /** * Converts a row number in the underlying model to a row number in this proxy. * @param sourceModelRow the row number that's valid in 'sourceModel()'. * @return the row number that's valid in this proxy. */ virtual int rowFromSource( int sourceModelRow ) const; /** * Converts a row number in this proxy to a row number in the underlying model. * * As a special case, 'proxyModelRow == rowCount()' returns the bottom model's * 'rowCount()'. See comment at 'rowToBottomModel()'. * * @param proxyModelRow the row number that's valid in this proxy. * @return the row number that's valid in 'sourceModel()'. */ virtual int rowToSource( int proxyModelRow ) const; AbstractModel *m_belowModel; }; } //namespace Playlist #endif //AMAROK_PROXYBASE_H diff --git a/src/playlist/proxymodels/SearchProxy.h b/src/playlist/proxymodels/SearchProxy.h index 0ec722ce63..d58a45a872 100644 --- a/src/playlist/proxymodels/SearchProxy.h +++ b/src/playlist/proxymodels/SearchProxy.h @@ -1,62 +1,62 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * Copyright (c) 2009 Téo Mrnjavac * * * * 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_PLAYLISTSEARCHPROXY_H #define AMAROK_PLAYLISTSEARCHPROXY_H #include "ProxyBase.h" namespace Playlist { /** * A ProxyModel that implements Playlist searching. * It should sit anywhere above the FilterProxy and SortProxy. * @author Téo Mrnjavac */ class SearchProxy : public ProxyBase { Q_OBJECT public: /** * Constructor. */ explicit SearchProxy( AbstractModel *belowModel, QObject *parent = nullptr ); /** * Destructor. */ - ~SearchProxy(); + ~SearchProxy() override; /** * Implementation of Playlist::AbstractModel: search/filter-related functions. */ void clearSearchTerm() override; int currentSearchFields() override { return m_currentSearchFields; } QString currentSearchTerm() override { return m_currentSearchTerm; } int find( const QString & searchTerm, int searchFields = MatchTrack ) override; int findNext( const QString & searchTerm, int selectedRow, int searchFields = MatchTrack ) override; int findPrevious( const QString & searchTerm, int selectedRow, int searchFields = MatchTrack ) override; private: QString m_currentSearchTerm; int m_currentSearchFields; }; } //namespace Playlist #endif //AMAROK_PLAYLISTSEARCHPROXY_H diff --git a/src/playlist/proxymodels/SortFilterProxy.h b/src/playlist/proxymodels/SortFilterProxy.h index a8f538286b..d338fe1f17 100644 --- a/src/playlist/proxymodels/SortFilterProxy.h +++ b/src/playlist/proxymodels/SortFilterProxy.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * Copyright (c) 2009 Téo Mrnjavac * * Copyright (c) 2010 Nanno Langstraat * * * * 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_PLAYLIST_SORTFILTERPROXY_H #define AMAROK_PLAYLIST_SORTFILTERPROXY_H #include "ProxyBase.h" #include "SortAlgorithms.h" #include "SortScheme.h" namespace Playlist { /** * Sorting interface; rest of Amarok shouldn't care whether sort is in 1 QSFPM with filter or not, */ class SortProxy { public: /** * Destructor. */ virtual ~SortProxy() { } /** * Checks if the SortProxy is currently applying a SortScheme. * @return true if the SortProxy is sorting, otherwise false. */ virtual bool isSorted() = 0; /** * Applies a sorting scheme to the playlist. * @param scheme the sorting scheme that will be applied. */ virtual void updateSortMap( const SortScheme &scheme ) = 0; }; /** * A proxy model that: * - Does multilevel sorting on the Playlist. * - Filters the Playlist based on a search term. */ class SortFilterProxy : public ProxyBase, public SortProxy { Q_OBJECT public: //! Basics. explicit SortFilterProxy( AbstractModel *belowModel, QObject *parent = nullptr ); - ~SortFilterProxy(); + ~SortFilterProxy() override; //! Sort-related functions. //! SortProxy public functions bool isSorted() override; void updateSortMap( const SortScheme &scheme ) override; //! Filter-related functions. //! Playlist::AbstractModel search-related functions. void clearSearchTerm() override; void filterUpdated() override; /** This will set the search term for the filter. filterUpdated() must be called to update the results. This allows client 'PrettyListView' to give the user the time to type a few characters before we do a filter run that might block for a few seconds. */ int find( const QString & searchTerm, int searchFields = MatchTrack ) override; void showOnlyMatches( bool onlyMatches ) override; //!Q_SIGNALS: //! Emits signals inherited from QSortFilterProxy //! Emits signals inherited from Playlist::AbstractModel / ProxyBase private: /** * Reimplemented from QSortFilterProxyModel. The sort comparison function. * @param left the first index to compare. * @param right the second index to compare. * @return true if left is to be placed before right, false otherwise. */ bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override; /** * Reimplemented from QSortFilterProxyModel. The filter decision function. * When not in 'showOnlyMatches' mode, this always returns true. * @param sourceModelRow The row in 'sourceModel()' to check. * @param sourceModelParent Ignored. * @return True if the row should be included, false otherwise. */ bool filterAcceptsRow( int sourceModelRow, const QModelIndex &sourceModelParent ) const override; SortScheme m_scheme; //!< The current sorting scheme. multilevelLessThan m_mlt; //!< Decision object for current sorting scheme. QString m_currentSearchTerm; int m_currentSearchFields; bool m_showOnlyMatches; }; } // namespace Playlist #endif diff --git a/src/playlist/view/listview/InlineEditorWidget.h b/src/playlist/view/listview/InlineEditorWidget.h index a878830776..41aa5fb0d3 100644 --- a/src/playlist/view/listview/InlineEditorWidget.h +++ b/src/playlist/view/listview/InlineEditorWidget.h @@ -1,75 +1,75 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 INLINEEDITORWIDGET_H #define INLINEEDITORWIDGET_H #include "playlist/layouts/LayoutItemConfig.h" #include "widgets/BoxWidget.h" #include #include /** An inline editor for a playlist item. Relies on the same item layout configuration as is used by the delegate, and strives to have a similar look. */ class InlineEditorWidget : public BoxWidget { Q_OBJECT public: InlineEditorWidget(QWidget * parent, const QModelIndex &index, const Playlist::PlaylistLayout &layout, int height, int width ); - ~InlineEditorWidget(); + ~InlineEditorWidget() override; QMap changedValues(); Q_SIGNALS: void editingDone( InlineEditorWidget * editor ); protected Q_SLOTS: void editValueChanged(); void ratingValueChanged(); void splitterMoved( int pos, int index ); private: void createChildWidgets(); bool eventFilter( QObject *obj, QEvent *event ) override; QPersistentModelIndex m_index; Playlist::PlaylistLayout m_layout; int m_widgetHeight; int m_widgetWidth; QMap m_editorRoleMap; QMap m_changedValues; QMap m_orgValues; QMap m_splitterRowMap; bool m_layoutChanged; }; namespace Playlist { extern const qreal ALBUM_WIDTH; extern const qreal SINGLE_TRACK_ALBUM_WIDTH; extern const qreal MARGIN; extern const qreal MARGINH; extern const qreal MARGINBODY; extern const qreal PADDING; } #endif diff --git a/src/playlist/view/listview/PrettyItemDelegate.h b/src/playlist/view/listview/PrettyItemDelegate.h index d8cc426d53..ef5e00dc2a 100644 --- a/src/playlist/view/listview/PrettyItemDelegate.h +++ b/src/playlist/view/listview/PrettyItemDelegate.h @@ -1,119 +1,119 @@ /**************************************************************************************** * Copyright (c) 2007 Ian Monroe * * Copyright (c) 2008 Soren Harward * * Copyright (c) 2013 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 PRETTYITEMDELEGATE_H #define PRETTYITEMDELEGATE_H #include "core/meta/forward_declarations.h" #include "playlist/layouts/LayoutItemConfig.h" #include #include class InlineEditorWidget; class QPainter; class QTimeLine; namespace Playlist { class PrettyItemDelegate : public QStyledItemDelegate { Q_OBJECT public: static int rowsForItem( const QModelIndex &index ); explicit PrettyItemDelegate( QObject* parent = nullptr ); - ~PrettyItemDelegate(); + ~PrettyItemDelegate() override; QSize sizeHint( const QStyleOptionViewItem&, const QModelIndex& ) const override; void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const override; // helper function for view which lets us determine if a click is within an album group's header bool insideItemHeader( const QPoint&, const QRect& ); /** Returns the height an item header would have */ int headerHeight() const; /** * Handle clicks within a delegate. * @param pos The position of the click, in delegate coordinates. * @param itemRect QRect for the item. * @param index The index of the clicked item. * @return True if delegate acts on this click, false otherwise. */ bool clicked( const QPoint &pos, const QRect &itemRect, const QModelIndex& index ); QWidget * createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const override; void setModelData ( QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const override; void updateEditorGeometry ( QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index ) const override; /** * Paint a playlist item based on a LayoutItemConfig * * @param config The LayoutItemConfig that defines how the item should look and which info it should include. * @param painter The QPainter used to paint the item. * @param option Additional state options used to paint the item.. * @param index The model index of the track in the playlist that we are painting. * @param headerRow A boolean value specifying whether we should ignore any "markers" when painting this item. * Markers can be such things as the "now playing" background, queue markers, multi track markers and the likes. * The main reason for wanting to ignore these is that when painting the head part of the first track in the group, these * things should not be shown as they will be hown in the track part of the item. */ void paintItem( const LayoutItemConfig &config, QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, bool headerRow = false ) const; protected Q_SLOTS: void editorDone( InlineEditorWidget * editor ); Q_SIGNALS: void redrawRequested(); private Q_SLOTS: void currentDesktopChanged(); private: void paintActiveTrackExtras( const QRect &rect, QPainter* painter, const QModelIndex& index ) const; QTimeLine * m_animationTimeLine; QPointF centerImage( const QPixmap&, const QRectF& ) const; static int getGroupMode( const QModelIndex &index); QMap buildTrackArgsMap( const Meta::TrackPtr &track ) const; static QFontMetricsF* s_nfm; //normal static QFontMetricsF* s_ufm; //underline static QFontMetricsF* s_ifm; //italic static QFontMetricsF* s_bfm; //bold static int s_fontHeight; }; } #endif diff --git a/src/playlist/view/listview/PrettyListView.h b/src/playlist/view/listview/PrettyListView.h index b5869f63a3..667008d12d 100644 --- a/src/playlist/view/listview/PrettyListView.h +++ b/src/playlist/view/listview/PrettyListView.h @@ -1,159 +1,159 @@ /**************************************************************************************** * Copyright (c) 2008 Soren Harward * * Copyright (c) 2009 Téo Mrnjavac * * Copyright (c) 2009 Oleksandr Khayrullin * * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 PRETTYLISTVIEW_H #define PRETTYLISTVIEW_H #include "PrettyItemDelegate.h" #include "playlist/proxymodels/GroupingProxy.h" #include "playlist/view/PlaylistViewCommon.h" #include #include #include #include #include #include #include class PopupDropper; class QContextMenuEvent; class QDragLeaveEvent; class QDragMoveEvent; class QDropEvent; class QKeyEvent; class QMouseEvent; class QPaintEvent; class QTimer; namespace Playlist { class PrettyListView : public QListView, public ViewCommon { Q_OBJECT public: explicit PrettyListView( QWidget* parent = nullptr ); - ~PrettyListView(); + ~PrettyListView() override; protected: int verticalOffset() const override; Q_SIGNALS: void found(); void notFound(); // these slots are used by the ContextMenu public Q_SLOTS: void editTrackInformation(); void playFirstSelected(); void dequeueSelection(); void queueSelection(); /* Switch queue state for selected rows in playlist */ void switchQueueState(); void removeSelection(); void stopAfterTrack(); void scrollToActiveTrack(); void selectSource(); void downOneTrack(); void upOneTrack(); // Workaround for BUG 222961 and BUG 229240: see implementation for more comments. void setCurrentIndex( const QModelIndex &index ); void selectionModel_setCurrentIndex( const QModelIndex &index, QItemSelectionModel::SelectionFlags command ); // Never call selectionModel()->setCurrentIndex() directly! void find( const QString & searchTerm, int fields, bool filter ); void findNext( const QString & searchTerm, int fields ); void findPrevious( const QString & searchTerm, int fields ); void clearSearchTerm(); void showOnlyMatches( bool onlyMatches ); void findInSource(); protected: void showEvent( QShowEvent* ) override; void contextMenuEvent( QContextMenuEvent* ) override; void dragEnterEvent( QDragEnterEvent *event ) override; void dragLeaveEvent( QDragLeaveEvent* ) override; void dragMoveEvent( QDragMoveEvent* ) override; void dropEvent( QDropEvent* ) override; void keyPressEvent( QKeyEvent* ) override; void mousePressEvent( QMouseEvent* ) override; void mouseReleaseEvent( QMouseEvent* ) override; /** Draws a "drop here" text if empty */ void paintEvent( QPaintEvent* ) override; void startDrag( Qt::DropActions supportedActions ) override; bool edit( const QModelIndex &index, EditTrigger trigger, QEvent *event ) override; protected Q_SLOTS: void newPalette( const QPalette & palette ); private Q_SLOTS: void slotPlaylistActiveTrackChanged(); void bottomModelRowsInserted( const QModelIndex& parent, int start, int end ); void bottomModelRowsInsertedScroll(); void moveTrackSelection( int offset ); void slotSelectionChanged(); void trackActivated( const QModelIndex& ); void updateProxyTimeout(); void fixInvisible(); // Workaround for BUG 184714; see implementation for more comments. void redrawActive(); void playlistLayoutChanged(); private: bool mouseEventInHeader( const QMouseEvent* ) const; QItemSelectionModel::SelectionFlags headerPressSelectionCommand( const QModelIndex&, const QMouseEvent* ) const; QItemSelectionModel::SelectionFlags headerReleaseSelectionCommand( const QModelIndex&, const QMouseEvent* ) const; void startProxyUpdateTimeout(); QRect m_dropIndicator; QPersistentModelIndex m_headerPressIndex; bool m_mousePressInHeader; bool m_skipAutoScroll; bool m_firstScrollToActiveTrack; quint64 m_rowsInsertedScrollItem; QString m_searchTerm; int m_fields; bool m_filter; bool m_showOnlyMatches; QTimer *m_proxyUpdateTimer; PopupDropper *m_pd; PrettyItemDelegate * m_prettyDelegate; QTimer *m_animationTimer; QDateTime m_lastTimeSelectionChanged; // we want to prevent a click to change the selection and open the editor (BR 220818) public: QList selectedRows() const; }; } #endif diff --git a/src/playlist/view/listview/SourceSelectionPopup.h b/src/playlist/view/listview/SourceSelectionPopup.h index 0343975506..687d0abad0 100644 --- a/src/playlist/view/listview/SourceSelectionPopup.h +++ b/src/playlist/view/listview/SourceSelectionPopup.h @@ -1,57 +1,57 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 PLAYLISTSOURCESELECTIONPOPUP_H #define PLAYLISTSOURCESELECTIONPOPUP_H #include #include "core/capabilities/MultiSourceCapability.h" #include class QListWidget; class QListWidgetItem; namespace Playlist { /** A small popup to let the user choose between the sources for tracks or streams that might have several. @author */ class SourceSelectionPopup : public QDialog { Q_OBJECT public: SourceSelectionPopup( QWidget * parent, Capabilities::MultiSourceCapability * msc ); - ~SourceSelectionPopup(); + ~SourceSelectionPopup() override; Q_SIGNALS: void sourceChanged( int source ); protected Q_SLOTS: void sourceSelected( QListWidgetItem * item ); private: QListWidget *m_listWidget; Capabilities::MultiSourceCapability * m_msc; }; } #endif diff --git a/src/playlistgenerator/ConstraintNode.h b/src/playlistgenerator/ConstraintNode.h index cc39ca76bd..918423b8c2 100644 --- a/src/playlistgenerator/ConstraintNode.h +++ b/src/playlistgenerator/ConstraintNode.h @@ -1,95 +1,95 @@ /**************************************************************************************** * Copyright (c) 2008-2012 Soren Harward * * * * 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 APG_CONSTRAINTNODE #define APG_CONSTRAINTNODE #include "core/meta/forward_declarations.h" #include #include #include #include namespace Collections { class QueryMaker; } class QWidget; /* Abstract base class for all constraints, including ConstraintGroup * * Inheritance Tree: * * ConstraintNode * | * +----------------+-----------+ * | | * ConstraintGroup Constraint * | * +-----------------+-------------+-----+-------- ... etc * | | | * Matching PreventDuplicates PlaylistDuration * | * TagMatch * * * If you want to write a new Constraint, don't subclass this directly. * Subclass Constraint or one of its children instead. -- sth */ class ConstraintNode : public QObject { Q_OBJECT public: enum NodeType { ConstraintGroupType, ConstraintType }; - virtual ~ConstraintNode(); + ~ConstraintNode() override; // Functions used in ConstraintModel int row() const; int getRowCount() const; ConstraintNode* parent() const; bool addChild( ConstraintNode*, int ); ConstraintNode* getChild( int ); ConstraintNode* pruneChild( int ); bool removeChild( int ); virtual QString getName() const = 0; virtual int getNodeType() const = 0; virtual QWidget* editWidget() const = 0; virtual void toXml( QDomDocument&, QDomElement& ) const = 0; // Set up the initial query for the ConstraintSolver virtual Collections::QueryMaker* initQueryMaker( Collections::QueryMaker* qm ) const { return qm; } // Mathematical function called by the ConstraintSolver virtual double satisfaction( const Meta::TrackList& ) const = 0; // heuristic functions for the ConstraintSolver virtual quint32 suggestPlaylistSize() const; Q_SIGNALS: void dataChanged(); protected: ConstraintNode(ConstraintNode* parent); int where_is(const ConstraintNode*) const; QList m_children; }; #endif diff --git a/src/playlistgenerator/ConstraintSolver.h b/src/playlistgenerator/ConstraintSolver.h index fc7385b63e..c530842fbd 100644 --- a/src/playlistgenerator/ConstraintSolver.h +++ b/src/playlistgenerator/ConstraintSolver.h @@ -1,124 +1,124 @@ /**************************************************************************************** * Copyright (c) 2008-2012 Soren Harward * * * * 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 APG_CONSTRAINTSOLVER #define APG_CONSTRAINTSOLVER #include "core/meta/forward_declarations.h" #include #include #include #include class ConstraintNode; namespace Collections { class QueryMaker; } namespace APG { class ConstraintSolver : public QObject, public ThreadWeaver::Job { Q_OBJECT public: typedef QHash Population; static const int QUALITY_RANGE; // allows used to adjust speed/quality tradeoff ConstraintSolver( ConstraintNode*, int ); - ~ConstraintSolver(); + ~ConstraintSolver() override; Meta::TrackList getSolution() const; bool satisfied() const; int serial() const { return m_serialNumber; } int iterationCount() const { return m_maxGenerations; } // overloaded ThreadWeaver::Job functions bool canBeExecuted(); bool success() const override; void requestAbort() override; Q_SIGNALS: void readyToRun(); void incrementProgress(); void totalSteps( int ); void endProgressOperation( QObject* ); /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); protected: void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; // from ThreadWeaver::Job private Q_SLOTS: void receiveQueryMakerData( const Meta::TrackList &); void receiveQueryMakerDone(); private: int m_serialNumber; // a randomly-generated serial number to help with debugging double m_satisfactionThreshold; double m_finalSatisfaction; ConstraintNode* const m_constraintTreeRoot; Collections::QueryMaker* m_qm; mutable Meta::TrackList m_domain; // tracks available to solver QMutex m_domainMutex; bool m_domainReductionFailed; Meta::TrackList m_solvedPlaylist; // playlist generated by solver bool m_readyToRun; // job execution depends on QueryMaker finishing bool m_abortRequested; // internal mathematical functions void fill_population( Population& ); Meta::TrackList* find_best( const Population& ) const; void select_population( Population&, Meta::TrackList* ); void mutate_population( Population& ); Meta::TrackList* crossover( Meta::TrackList*, Meta::TrackList* ) const; static bool pop_comp( double, double ); Meta::TrackPtr random_track_from_domain() const; Meta::TrackList sample( Meta::TrackList, const int ) const; double rng_gaussian( const double, const double ) const; quint32 rng_poisson( const double ) const; double rng_uniform() const; quint32 playlist_size() const; bool select( const double ) const; // convenience function void dump_population( const Population& ) const; // internal mathematical parameters quint32 m_maxGenerations; quint32 m_populationSize; quint32 m_suggestedPlaylistSize; }; } // namespace APG #endif diff --git a/src/playlistgenerator/Preset.h b/src/playlistgenerator/Preset.h index 3e0c74d476..a6c80f7852 100644 --- a/src/playlistgenerator/Preset.h +++ b/src/playlistgenerator/Preset.h @@ -1,72 +1,72 @@ /**************************************************************************************** * Copyright (c) 2008-2010 Soren Harward * * * * 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 APG_PRESET #define APG_PRESET #include "core/meta/forward_declarations.h" #include "AmarokSharedPointer.h" #include #include #include #include namespace ThreadWeaver { class Job; } class ConstraintNode; namespace APG { class Preset : public QObject, public QSharedData { Q_OBJECT public: static AmarokSharedPointer createFromXml( QDomElement& ); static AmarokSharedPointer createNew(); - ~Preset(); + ~Preset() override; QString title() const { return m_title; } void setTitle( const QString& t ) { m_title = t; } ConstraintNode* constraintTreeRoot() const { return m_constraintTreeRoot; } void setConstraintTreeRoot( ConstraintNode* c ) { m_constraintTreeRoot = c; } QDomElement* toXml( QDomDocument& ) const; public Q_SLOTS: void generate( int ); Q_SIGNALS: void lock( bool ); private Q_SLOTS: void queueSolver(); void solverFinished( ThreadWeaver::JobPointer ); private: Preset( const QString&, QDomElement& ); Preset( const QString& ); QString m_title; ConstraintNode* m_constraintTreeRoot; }; typedef AmarokSharedPointer PresetPtr; } #endif diff --git a/src/playlistgenerator/PresetModel.h b/src/playlistgenerator/PresetModel.h index 51ceb091ef..74509b8688 100644 --- a/src/playlistgenerator/PresetModel.h +++ b/src/playlistgenerator/PresetModel.h @@ -1,99 +1,99 @@ /**************************************************************************************** * Copyright (c) 2008-2012 Soren Harward * * * * 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 APG_PRESET_MODEL #define APG_PRESET_MODEL #include "Preset.h" #include #include #include #include class QPersistentModelIndex; namespace APG { class PresetModel : public QAbstractListModel { Q_OBJECT public: static PresetModel* instance(); static void destroy(); static const QString presetExamples; // holds a hard-coded set of example presets // that are loaded the first time the // user opens the APG // Overloaded QAbstractListModel methods QVariant data( const QModelIndex&, int role = Qt::DisplayRole ) const override; QModelIndex index( int, int, const QModelIndex& parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex& ) const override { return QModelIndex(); } int rowCount( const QModelIndex& parent = QModelIndex() ) const override; int columnCount( const QModelIndex& ) const override { return 1; } APG::PresetPtr activePreset() const; Q_SIGNALS: void lock( bool ); // disable the edit widgets if the solver is running public Q_SLOTS: void addNew(); void edit(); void editPreset( const QModelIndex& ); void exportActive(); void import(); void removeActive(); void runGenerator( int ); void setActivePreset( const QModelIndex& ); void savePresetsToXmlDefault() const; // force saving to default location private Q_SLOTS: void savePresetsToXml( const QString&, const QList & ) const; void loadPresetsFromXml( const QString&, bool createDefaults = false ); private: PresetModel(); - ~PresetModel(); + ~PresetModel() override; static PresetModel* s_instance; class ExportDialog; void insertPreset(const APG::PresetPtr&); void parseXmlToPresets( QDomDocument& ); QPersistentModelIndex* m_activePresetIndex; QList m_presetList; }; // class PresetModel class PresetModel::ExportDialog : public QFileDialog { Q_OBJECT public: ExportDialog( APG::PresetPtr ); - ~ExportDialog(); + ~ExportDialog() override; Q_SIGNALS: void pleaseExport( const QString&, const QList ) const; private Q_SLOTS: void recvAccept() const; private: QList m_presetsToExportList; }; } //namespace APG #endif // APG_PRESET_MODEL diff --git a/src/playlistgenerator/TreeController.h b/src/playlistgenerator/TreeController.h index df95f6936a..fd12b53257 100644 --- a/src/playlistgenerator/TreeController.h +++ b/src/playlistgenerator/TreeController.h @@ -1,45 +1,45 @@ /**************************************************************************************** * Copyright (c) 2008-2010 Soren Harward * * * * 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 APG_TREECONTROLLER #define APG_TREECONTROLLER #include class QTreeView; class QWidget; namespace APG { class TreeModel; class TreeController : public QObject { Q_OBJECT public: TreeController( TreeModel*, QTreeView*, QWidget* parent = nullptr); - ~TreeController(); + ~TreeController() override; public Q_SLOTS: void addGroup() const; void addConstraint( const QString& ) const; void removeNode() const; private: TreeModel* m_model; QTreeView* m_view; }; } #endif diff --git a/src/playlistgenerator/TreeModel.h b/src/playlistgenerator/TreeModel.h index ef9f76a0d9..46f0a41650 100644 --- a/src/playlistgenerator/TreeModel.h +++ b/src/playlistgenerator/TreeModel.h @@ -1,57 +1,57 @@ /**************************************************************************************** * Copyright (c) 2008-2010 Soren Harward * * * * 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 APG_TREEMODEL #define APG_TREEMODEL #include "core/meta/forward_declarations.h" #include #include #include class ConstraintNode; namespace APG { class TreeModel : public QAbstractItemModel { Q_OBJECT public: explicit TreeModel( ConstraintNode*, QObject* parent = nullptr ); - ~TreeModel(); + ~TreeModel() override; QVariant data( const QModelIndex& index, int role ) const override; Qt::ItemFlags flags( const QModelIndex& index ) const override; QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex& child ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; int columnCount( const QModelIndex& parent = QModelIndex() ) const override { Q_UNUSED( parent ); return 1; } bool removeNode( const QModelIndex& ); QModelIndex insertGroup( const QModelIndex& ); QModelIndex insertConstraint( const QModelIndex&, const QString& ); private Q_SLOTS: void slotConstraintDataChanged(); private: ConstraintNode* m_rootNode; void connectDCSlotToNode( ConstraintNode* ); }; } #endif diff --git a/src/playlistgenerator/constraints/Checkpoint.h b/src/playlistgenerator/constraints/Checkpoint.h index 31e84cfe64..9a6212df84 100644 --- a/src/playlistgenerator/constraints/Checkpoint.h +++ b/src/playlistgenerator/constraints/Checkpoint.h @@ -1,158 +1,158 @@ /**************************************************************************************** * Copyright (c) 2008-2012 Soren Harward * * * * 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 APG_CHECKPOINT_CONSTRAINT #define APG_CHECKPOINT_CONSTRAINT #include "ui_CheckpointEditWidget.h" #include "playlistgenerator/Constraint.h" #include "core/meta/forward_declarations.h" #include #include class ConstraintFactoryEntry; class QWidget; namespace ConstraintTypes { /* This constraint sets a "checkpoint": a specific track that will be * played at a specific time in the playlist */ enum CheckpointType { CheckpointTrack, CheckpointAlbum, CheckpointArtist }; class Checkpoint : public Constraint { Q_OBJECT public: static Constraint* createFromXml(QDomElement&, ConstraintNode*); static Constraint* createNew(ConstraintNode*); static ConstraintFactoryEntry* registerMe(); QWidget* editWidget() const override; void toXml(QDomDocument&, QDomElement&) const override; QString getName() const override; double satisfaction( const Meta::TrackList& ) const override; quint32 suggestPlaylistSize() const override; private Q_SLOTS: void setPosition( const int ); void setStrictness( const int ); void setCheckpoint( const Meta::DataPtr& ); private: /* support classes */ class AbstractMatcher; class TrackMatcher; class ArtistMatcher; class AlbumMatcher; Checkpoint( QDomElement&, ConstraintNode* ); explicit Checkpoint( ConstraintNode* ); - ~Checkpoint(); + ~Checkpoint() override; // constraint parameters qint64 m_position; double m_strictness; Meta::DataPtr m_checkpointObject; CheckpointType m_checkpointType; // objects from the support classes QPointer m_matcher; // support functions double penalty( const qint64 ) const; }; // ABC for Checkpoint handlers class Checkpoint::AbstractMatcher : public QObject { Q_OBJECT public: AbstractMatcher() {} - virtual ~AbstractMatcher() {} + ~AbstractMatcher() override {} virtual QList find( const Meta::TrackList& ) const = 0; virtual bool match( const Meta::TrackPtr& ) const = 0; }; // Handles Checkpoints for a specific track class Checkpoint::TrackMatcher : public AbstractMatcher { public: TrackMatcher( const Meta::TrackPtr& ); - virtual ~TrackMatcher(); + ~TrackMatcher() override; QList find( const Meta::TrackList& ) const override; bool match( const Meta::TrackPtr& ) const override; private: Meta::TrackPtr m_trackToMatch; }; // Handles Checkpoints for an album (any track on this album satisfies the checkpoint) class Checkpoint::AlbumMatcher : public AbstractMatcher { public: AlbumMatcher( const Meta::AlbumPtr& ); - virtual ~AlbumMatcher(); + ~AlbumMatcher() override; QList find( const Meta::TrackList& ) const override; bool match( const Meta::TrackPtr& ) const override; private: Meta::AlbumPtr m_albumToMatch; }; // Handles Checkpoints for an artist (any track by this artist satisfies the checkpoint) class Checkpoint::ArtistMatcher : public AbstractMatcher { public: ArtistMatcher( const Meta::ArtistPtr& ); - virtual ~ArtistMatcher(); + ~ArtistMatcher() override; QList find( const Meta::TrackList& ) const override; bool match( const Meta::TrackPtr& ) const override; private: Meta::ArtistPtr m_artistToMatch; }; class CheckpointEditWidget : public QWidget { Q_OBJECT public: CheckpointEditWidget( const qint64, const int, const Meta::DataPtr& ); Q_SIGNALS: void updated(); void nameChanged( const QString& ); void positionChanged( const int ); void strictnessChanged( const int ); void checkpointChanged( const Meta::DataPtr& ); private Q_SLOTS: void on_timeEdit_Position_timeChanged( const QTime& ); void on_slider_Strictness_valueChanged( const int ); void on_trackSelector_selectionChanged( const Meta::DataPtr& ); private: Ui::CheckpointEditWidget ui; }; } // namespace ConstraintTypes #endif diff --git a/src/playlistgenerator/constraints/TagMatch.h b/src/playlistgenerator/constraints/TagMatch.h index d57897b202..ac0969a183 100644 --- a/src/playlistgenerator/constraints/TagMatch.h +++ b/src/playlistgenerator/constraints/TagMatch.h @@ -1,213 +1,213 @@ /**************************************************************************************** * Copyright (c) 2008-2012 Soren Harward * * * * 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 APG_TAGMATCH_CONSTRAINT #define APG_TAGMATCH_CONSTRAINT #include "ui_TagMatchEditWidget.h" #include "Matching.h" #include "core/meta/forward_declarations.h" #include #include #include #include #include class Constraint; class ConstraintFactoryEntry; namespace Collections { class QueryMaker; } namespace ConstraintTypes { class TagMatchFieldsModel; /* Puts tracks with the specified tag into the playlist. "Tag" is used a * bit loosely here; a more accurate term would probably be "metadata", * since the matchable properties include parameters like "rating" and * "last played" that aren't in the actual file that corresponds to the * track being played. -- sth */ class TagMatch : public MatchingConstraint { Q_OBJECT /* support classes declared below */ class Comparer; public: enum FieldTypes { FieldTypeInt, FieldTypeDate, FieldTypeString }; enum NumComparison { CompareNumLessThan, CompareNumEquals, CompareNumGreaterThan }; enum StrComparison { CompareStrEquals, CompareStrStartsWith, CompareStrEndsWith, CompareStrContains, CompareStrRegExp }; enum DateComparison { CompareDateBefore, CompareDateOn, CompareDateAfter, CompareDateWithin }; static Constraint* createFromXml(QDomElement&, ConstraintNode*); static Constraint* createNew(ConstraintNode*); static ConstraintFactoryEntry* registerMe(); QWidget* editWidget() const override; void toXml(QDomDocument&, QDomElement&) const override; QString getName() const override; Collections::QueryMaker* initQueryMaker(Collections::QueryMaker*) const override; double satisfaction(const Meta::TrackList&) const override; // Implementation of MatchingConstraint virtuals const QBitArray whatTracksMatch( const Meta::TrackList& ) override; int constraintMatchType() const override; private Q_SLOTS: void setComparison( int ); void setField( const QString& ); void setInvert( bool ); void setStrictness( int ); void setValue( const QVariant& ); private: TagMatch( QDomElement&, ConstraintNode* ); explicit TagMatch( ConstraintNode* ); - ~TagMatch(); + ~TagMatch() override; // constraint parameters int m_comparison; QString m_field; bool m_invert; double m_strictness; QVariant m_value; // convenience classes const Comparer* const m_comparer; const TagMatchFieldsModel* const m_fieldsModel; // convenience functions QString comparisonToString() const; QString valueToString() const; bool matches( const Meta::TrackPtr ) const; // match values are fuzzily calculated mutable QHash m_matchCache; // internal cache for per-track true/false data /* support class that does fuzzy comparisons */ class Comparer { public: Comparer(); ~Comparer(); double compareNum( const double, const int, const double, const double, const qint64 ) const; double compareStr( const QString&, const int, const QString& ) const; double compareDate( const uint, const int, const QVariant&, const double ) const; double compareLabels( const Meta::TrackPtr&, const int, const QString& ) const; // rough inverses of the comparison uint rangeDate( const double ) const; int rangeNum( const double, const qint64 ) const; private: QHash m_numFieldWeight; const double m_dateWeight; double fuzzyProb( const double, const double, const double, const double ) const; }; }; /* support class that manages data relationships for the various fields */ class TagMatchFieldsModel : public QAbstractListModel { Q_OBJECT public: TagMatchFieldsModel(); - ~TagMatchFieldsModel(); + ~TagMatchFieldsModel() override; // required by QAbstractListModel QVariant data( const QModelIndex&, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; bool contains( const QString& ) const; int index_of( const QString& ) const; QString field_at( int ) const; qint64 meta_value_of( const QString& ) const; QString pretty_name_of( const QString& ) const; TagMatch::FieldTypes type_of( const QString& ) const; private: QList m_fieldNames; QHash m_fieldTypes; QHash m_fieldMetaValues; QHash m_fieldPrettyNames; }; class TagMatchEditWidget : public QWidget { Q_OBJECT public: TagMatchEditWidget( const int, const QString&, const bool, const int, const QVariant& ); ~TagMatchEditWidget(); Q_SIGNALS: void comparisonChanged( int ); void fieldChanged( const QString& ); void invertChanged( bool ); void strictnessChanged( int ); void valueChanged( const QVariant& ); void updated(); private Q_SLOTS: // comparison void on_comboBox_ComparisonDate_currentIndexChanged( int ); void on_comboBox_ComparisonInt_currentIndexChanged( int ); void on_comboBox_ComparisonRating_currentIndexChanged( int ); void on_comboBox_ComparisonString_currentIndexChanged( int ); void on_comboBox_ComparisonTime_currentIndexChanged( int ); // field void on_comboBox_Field_currentIndexChanged( int ); // invert void on_checkBox_Invert_clicked( bool ); // strictness void on_slider_StrictnessDate_valueChanged( int ); void on_slider_StrictnessInt_valueChanged( int ); void on_slider_StrictnessRating_valueChanged( int ); void on_slider_StrictnessTime_valueChanged( int ); // value void on_kdatewidget_DateSpecific_changed( const QDate& ); void on_spinBox_ValueDateValue_valueChanged( int ); void on_comboBox_ValueDateUnit_currentIndexChanged( int ); void on_spinBox_ValueInt_valueChanged( int ); void on_lineEdit_StringValue_textChanged( const QString& ); void on_rating_RatingValue_ratingChanged( int ); void on_timeEdit_TimeValue_timeChanged( const QTime& ); void slotUpdateComboBoxLabels( int ); private: Ui::TagMatchEditWidget ui; TagMatchFieldsModel* const m_fieldsModel; }; } // namespace ConstraintTypes typedef QPair DateRange; Q_DECLARE_METATYPE( DateRange ) #endif diff --git a/src/playlistmanager/PlaylistManager.h b/src/playlistmanager/PlaylistManager.h index c31fe7d575..d991963380 100644 --- a/src/playlistmanager/PlaylistManager.h +++ b/src/playlistmanager/PlaylistManager.h @@ -1,218 +1,218 @@ /**************************************************************************************** * Copyright (c) 2007 Bart Cerneels * * Copyright (c) 2011 Lucas Lira Gomes * * * * 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_PLAYLISTMANAGER_H #define AMAROK_PLAYLISTMANAGER_H #include "core/support/Amarok.h" #include "amarok_export.h" #include "core/playlists/Playlist.h" #include "core/playlists/PlaylistProvider.h" #include "SyncedPlaylist.h" #include "SyncRelationStorage.h" #include #include class KJob; class PlaylistManager; namespace Playlists { class PlaylistFile; class PlaylistFileProvider; class UserPlaylistProvider; typedef AmarokSharedPointer PlaylistFilePtr; } namespace Podcasts { class PodcastProvider; } namespace The { AMAROK_EXPORT PlaylistManager* playlistManager(); } typedef QList PlaylistProviderList; /** * Facility for managing PlaylistProviders registered by other * parts of the application, plugins and scripts. */ class AMAROK_EXPORT PlaylistManager : public QObject { Q_OBJECT public: enum PlaylistCategory { UserPlaylist = 1, PodcastChannel }; Q_ENUM( PlaylistCategory ) static PlaylistManager *instance(); static void destroy(); /** * @returns all available categories registered at that moment */ QList availableCategories() { return m_providerMap.uniqueKeys(); } /** * returns playlists of a certain category from all registered PlaylistProviders */ Playlists::PlaylistList playlistsOfCategory( int playlistCategory ); /** * returns all PlaylistProviders that provider a certain playlist category. **/ PlaylistProviderList providersForCategory( int playlistCategory ); /** * Add a PlaylistProvider that contains Playlists of a category defined * in the PlaylistCategory enum. * @arg provider a PlaylistProvider * @arg category a default Category from the PlaylistManager::PlaylistCategory enum or a * custom one registered before with registerCustomCategory. */ void addProvider( Playlists::PlaylistProvider *provider, int category ); /** * Do all the work necessary to sync playlists, including the * SyncedPlaylist creation and more. This sync is persistent. * @arg playlist of the master playlist * @arg playlist of the slave playlist */ void setupSync( const Playlists::PlaylistPtr master, const Playlists::PlaylistPtr slave ); /** * Remove a PlaylistProvider. * @arg provider a PlaylistProvider */ void removeProvider( Playlists::PlaylistProvider *provider ); Playlists::PlaylistProvider *playlistProvider( int category, QString name ); /** * Saves a list of tracks to a new playlist. Used in the Playlist save button. * @arg tracks list of tracks to save * @arg name name of playlist to save * @arg toProvider If 0 (default) will save to the default UserPlaylistProvider * @arg editName whether to edit new playlist name as soon as it is created * @see defaultUserPlaylists */ bool save( Meta::TrackList tracks, const QString &name = QString(), Playlists::PlaylistProvider *toProvider = 0, bool editName = true ); /** * Saves a playlist from a file to the database. * @param fromLocation Saved playlist file to load */ bool import( const QUrl &fromLocation ); /** * Initiates renaming of playlists. Can Focus Saved Playlists and * initiate inline rename. * * @param playlist the playlists. */ void rename( Playlists::PlaylistPtr playlist ); /** * Rename @p playlist to @p newName, return true if renaming was successful, * false otherwise. * * @param playlist the playlist. * @param newName the new name. */ bool rename( Playlists::PlaylistPtr playlist, const QString &newName ); bool deletePlaylists( Playlists::PlaylistList playlistlist ); Podcasts::PodcastProvider *defaultPodcasts() { return m_defaultPodcastProvider; } Playlists::UserPlaylistProvider *defaultUserPlaylists() { return m_defaultUserPlaylistProvider; } /** * Retrieves the provider owning the given playlist. * Will only return multiple providers if this is a synced playlist * @arg playlist the playlist whose provider we want */ QList getProvidersForPlaylist( const Playlists::PlaylistPtr playlist ); /** * Checks if the provider to whom this playlist belongs supports writing * @arg playlist the playlist we are testing for writability * @return whether or not the playlist is writable */ bool isWritable( const Playlists::PlaylistPtr &playlist ); void completePodcastDownloads(); Q_SIGNALS: void updated( int category ); void categoryAdded( int category ); void providerAdded( Playlists::PlaylistProvider *provider, int category ); void providerRemoved( Playlists::PlaylistProvider *provider, int category ); void playlistAdded( Playlists::PlaylistPtr playlist, int category ); void playlistRemoved( Playlists::PlaylistPtr playlist, int category ); void playlistUpdated( Playlists::PlaylistPtr playlist, int category ); void renamePlaylist( Playlists::PlaylistPtr playlist ); private Q_SLOTS: void slotUpdated(); void slotPlaylistAdded( Playlists::PlaylistPtr playlist ); void slotPlaylistRemoved( Playlists::PlaylistPtr playlist ); void slotSyncNeeded(); private: void loadPlaylists( Playlists::PlaylistProvider *provider, int category ); void removePlaylists( Playlists::PlaylistProvider *provider ); void addPlaylist( Playlists::PlaylistPtr playlist, int category ); void removePlaylist( Playlists::PlaylistPtr playlist, int category ); static PlaylistManager *s_instance; PlaylistManager(); - ~PlaylistManager(); + ~PlaylistManager() override; SyncRelationStorage *m_syncRelStore; QList m_syncNeeded; bool hasToSync( Playlists::PlaylistPtr master, Playlists::PlaylistPtr slave ); Podcasts::PodcastProvider *m_defaultPodcastProvider; Playlists::UserPlaylistProvider *m_defaultUserPlaylistProvider; Playlists::PlaylistFileProvider *m_playlistFileProvider; QMultiMap m_providerMap; //Map PlaylistCategories to providers QMultiMap m_playlistMap; QMultiMap m_syncedPlaylistMap; QMap m_customCategories; QMap m_downloadJobMap; }; Q_DECLARE_METATYPE( PlaylistProviderList ) #endif diff --git a/src/playlistmanager/SyncedPodcast.h b/src/playlistmanager/SyncedPodcast.h index b64c8e87b9..9b21f1eee9 100644 --- a/src/playlistmanager/SyncedPodcast.h +++ b/src/playlistmanager/SyncedPodcast.h @@ -1,92 +1,92 @@ /**************************************************************************************** * Copyright (c) 2011 Lucas Lira Gomes * * * * 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 SYNCEDPODCAST_H #define SYNCEDPODCAST_H #include "core/podcasts/PodcastMeta.h" #include "playlistmanager/SyncedPlaylist.h" class SyncedPodcast : public SyncedPlaylist, public Podcasts::PodcastChannel { public: explicit SyncedPodcast( Podcasts::PodcastChannelPtr podcast ); - virtual ~SyncedPodcast() {} + ~SyncedPodcast() override {} //Playlist virtual methods QString name() const override { return title(); } //PodcastMetaCommon methods QString title() const override { return m_master->title(); } QString description() const override { return m_master->description(); } QStringList keywords() const override { return m_master->keywords(); } QString subtitle() const override { return m_master->subtitle(); } QString summary() const override { return m_master->summary(); } QString author() const override { return m_master->author(); } //Podcasts::PodcastChannel methods QUrl url() const override { return m_master->url(); } QUrl webLink() const override { return m_master->webLink(); } bool hasImage() const override { return m_master->hasImage(); } QUrl imageUrl() const override { return m_master->imageUrl(); } QImage image() const override { return m_master->image(); } QString copyright() const override { return m_master->copyright(); } QStringList labels() const override { return m_master->labels(); } QDate subscribeDate() const override { return m_master->subscribeDate(); } void setUrl( const QUrl &url ) override { m_master->setUrl( url ); } void setWebLink( const QUrl &link ) override { m_master->setWebLink( link ); } void setImage( const QImage &image ) override { m_master->setImage( image ); } void setImageUrl( const QUrl &imageUrl ) override { m_master->setImageUrl( imageUrl ); } void setCopyright( const QString ©right ) override { m_master->setCopyright( copyright ); } void setLabels( const QStringList &labels ) override { m_master->setLabels( labels ); } void addLabel( const QString &label ) override { m_master->addLabel( label ); } void setSubscribeDate( const QDate &date ) override { m_master->setSubscribeDate( date ); } Podcasts::PodcastEpisodePtr addEpisode( const Podcasts::PodcastEpisodePtr &episode ) override { return m_master->addEpisode( episode ); } Podcasts::PodcastEpisodeList episodes() const override { return m_master->episodes(); } bool load( QTextStream &stream ) { return m_master->load( stream ); } //Settings virtual QUrl saveLocation() const { return m_master->saveLocation(); } virtual bool autoScan() const { return m_master->autoScan(); } virtual bool hasPurge() const { return m_master->hasPurge(); } virtual int purgeCount() const { return m_master->purgeCount(); } void setSaveLocation( const QUrl &url ) { m_master->setSaveLocation( url ); } void setAutoScan( bool autoScan ) { m_master->setAutoScan( autoScan ); } void setFetchType( Podcasts::PodcastChannel::FetchType fetchType ) { m_master->setFetchType( fetchType ); } void setPurge( bool purge ) { m_master->setPurge( purge ); } void setPurgeCount( int purgeCount ) { m_master->setPurgeCount( purgeCount ); } private: Podcasts::PodcastChannelPtr m_master; }; typedef AmarokSharedPointer SyncedPodcastPtr; typedef QList SyncedPodcastList; Q_DECLARE_METATYPE( SyncedPodcastPtr ) Q_DECLARE_METATYPE( SyncedPodcastList ) #endif // SYNCEDPODCAST_H diff --git a/src/playlistmanager/file/PlaylistFileProvider.h b/src/playlistmanager/file/PlaylistFileProvider.h index c0dd294a75..204f7dabe1 100644 --- a/src/playlistmanager/file/PlaylistFileProvider.h +++ b/src/playlistmanager/file/PlaylistFileProvider.h @@ -1,89 +1,89 @@ /**************************************************************************************** * Copyright (c) 2007 Bart Cerneels * * * * 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 PLAYLISTFILEPROVIDER_H #define PLAYLISTFILEPROVIDER_H #include "core/playlists/PlaylistFormat.h" #include "core/playlists/PlaylistProvider.h" #include "core-impl/playlists/providers/user/UserPlaylistProvider.h" #include "core-impl/playlists/types/file/PlaylistFileSupport.h" #include class QTimer; namespace Playlists { /** @author Bart Cerneels */ class PlaylistFileProvider : public Playlists::UserPlaylistProvider { Q_OBJECT public: PlaylistFileProvider(); - virtual ~PlaylistFileProvider(); + ~PlaylistFileProvider() override; QString prettyName() const override; QIcon icon() const override; int category() const override { return Playlists::UserPlaylist; } int playlistCount() const override; Playlists::PlaylistList playlists() override; /** * Returns a Playlists::PlaylistPtr to the new playlist, NULL if something failed. * @param tracks Tracks being added to that new playlist. * @param name File name of the new playlist. If no extension is being given we * default to xspf. '/' and '\' are being replaced by '-'. */ Playlists::PlaylistPtr save( const Meta::TrackList &tracks, const QString &name = QString() ) override; virtual bool import( const QUrl &path ); bool isWritable() override { return true; } void renamePlaylist(Playlists::PlaylistPtr playlist, const QString &newName ) override; bool deletePlaylists( const Playlists::PlaylistList &playlists ) override; /* PlaylistFileProvider methods */ /** Schedules a PlaylistFile to be saved on the next iteration of the mainloop. * Each playlist will be scheduled and saved only once. */ void saveLater( Playlists::PlaylistFilePtr playlist ); private Q_SLOTS: void loadPlaylists(); void slotSaveLater(); private: bool deletePlaylistFiles( Playlists::PlaylistFileList playlistFiles ); KConfigGroup loadedPlaylistsConfig() const; bool m_playlistsLoaded; QList m_urlsToLoad; Playlists::PlaylistFileList m_playlists; QMultiMap m_groupMap; QTimer *m_saveLaterTimer; QList m_saveLaterPlaylists; }; } //namespace Playlists #endif diff --git a/src/playlistmanager/sql/SqlPlaylist.h b/src/playlistmanager/sql/SqlPlaylist.h index 69ed2316bd..caa31cd97b 100644 --- a/src/playlistmanager/sql/SqlPlaylist.h +++ b/src/playlistmanager/sql/SqlPlaylist.h @@ -1,91 +1,91 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 PLAYLISTSSQLPLAYLIST_H #define PLAYLISTSSQLPLAYLIST_H #include "core/playlists/Playlist.h" namespace Playlists { class PlaylistProvider; class SqlPlaylist; typedef AmarokSharedPointer SqlPlaylistPtr; typedef QList SqlPlaylistList; class SqlPlaylistGroup; typedef AmarokSharedPointer SqlPlaylistGroupPtr; typedef QList SqlPlaylistGroupList; /** A playlist that saves and loads itself from the Amarok database @author Nikolaj Hald Nielsen */ class SqlPlaylist : public Playlist { public: SqlPlaylist( const QString &name, const Meta::TrackList &tracks, SqlPlaylistGroupPtr parent, PlaylistProvider *provider, const QString &urlId = QString() ); SqlPlaylist( const QStringList & resultRow, SqlPlaylistGroupPtr parent, PlaylistProvider *provider ); - ~SqlPlaylist(); + ~SqlPlaylist() override; /* Playlist virtual functions */ QUrl uidUrl() const override; QString name() const override { return m_name; } PlaylistProvider *provider() const override { return m_provider; } void setName( const QString &name ) override; QStringList groups() override; void setGroups( const QStringList &groups ) override; int trackCount() const override; Meta::TrackList tracks() override; void triggerTrackLoad() override; void addTrack( const Meta::TrackPtr &track, int position = -1 ) override; void removeTrack( int position ) override; // SqlPlaylist-specific methods bool saveToDb( bool tracks = true ); void removeFromDb(); private: void loadTracks(); void saveTracks(); int m_dbId; SqlPlaylistGroupPtr m_parent; Meta::TrackList m_tracks; PlaylistProvider *m_provider; QString m_name; QString m_urlId; bool m_tracksLoaded; }; } Q_DECLARE_METATYPE( Playlists::SqlPlaylistPtr ) Q_DECLARE_METATYPE( Playlists::SqlPlaylistList ) #endif diff --git a/src/playlistmanager/sql/SqlUserPlaylistProvider.h b/src/playlistmanager/sql/SqlUserPlaylistProvider.h index a3e8e3267b..48ba6ea88b 100644 --- a/src/playlistmanager/sql/SqlUserPlaylistProvider.h +++ b/src/playlistmanager/sql/SqlUserPlaylistProvider.h @@ -1,87 +1,87 @@ /**************************************************************************************** * Copyright (c) 2008 Bart Cerneels * * * * 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_COLLECTION_SQLUSERPLAYLISTPROVIDER_H #define AMAROK_COLLECTION_SQLUSERPLAYLISTPROVIDER_H #include "core-impl/playlists/providers/user/UserPlaylistProvider.h" #include "SqlPlaylist.h" #include "SqlPlaylistGroup.h" #include #include namespace Playlists { class AMAROK_EXPORT SqlUserPlaylistProvider : public UserPlaylistProvider { Q_OBJECT public: /** * SqlUserPlaylistProvider constructor * @param debug used for unit testing; enabling means skipping * confirmation dialogs when deleting or renaming playlists. */ explicit SqlUserPlaylistProvider( bool debug = false ); - ~SqlUserPlaylistProvider(); + ~SqlUserPlaylistProvider() override; /* PlaylistProvider functions */ QString prettyName() const override { return i18n( "Amarok Database" ); } virtual QString description() const { return i18n( "Local playlists stored in the database" ); } QIcon icon() const override { return QIcon::fromTheme( QStringLiteral("server-database") ); } int playlistCount() const override; Playlists::PlaylistList playlists() override; virtual Playlists::PlaylistPtr save( const Meta::TrackList &tracks ); Playlists::PlaylistPtr save( const Meta::TrackList &tracks, const QString& name ) override; /* UserPlaylistProvider functions */ bool isWritable() override; bool deletePlaylists( const Playlists::PlaylistList &playlistlist ) override; void renamePlaylist(Playlists::PlaylistPtr playlist, const QString &newName ) override; Playlists::SqlPlaylistGroupPtr group( const QString &name ); static Playlists::SqlPlaylistList toSqlPlaylists( Playlists::PlaylistList playlists ); private: void reloadFromDb(); Playlists::SqlPlaylistGroupPtr m_root; void createTables(); void deleteTables(); void checkTables(); /** * removes COLUMN "description" from "playlists" */ void upgradeVersion2to3(); void loadFromDb(); bool deleteSqlPlaylists( Playlists::SqlPlaylistList playlistlist ); Playlists::SqlPlaylistList selectedPlaylists() const { return m_selectedPlaylists; } Playlists::SqlPlaylistList m_selectedPlaylists; const bool m_debug; }; } //namespace Playlists #endif diff --git a/src/scanner/AbstractScanResultProcessor.h b/src/scanner/AbstractScanResultProcessor.h index 99217ebab4..02c84b2dee 100644 --- a/src/scanner/AbstractScanResultProcessor.h +++ b/src/scanner/AbstractScanResultProcessor.h @@ -1,135 +1,135 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2008 Seb Ruiz * * Copyright (c) 2009-2010 Jeff Mitchell * * Copyright (c) 2013 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 ABSTRACT_SCAN_RESULTPROCESSOR_H #define ABSTRACT_SCAN_RESULTPROCESSOR_H #include "amarok_export.h" #include "GenericScanManager.h" #include #include #include #include #include #include #include namespace CollectionScanner { class Track; class Directory; class Album; class Playlist; } class GenericScanManager; template class QSharedPointer; /** The ScanResulProcessor class connects to a GenericScanManager and * adds further processing to the directoryScanned signal. * * The AbstractScanResultProcessor can determine if tracks need to be removed * and better sort Tracks into albums. */ class AMAROK_EXPORT AbstractScanResultProcessor : public QObject { Q_OBJECT public: explicit AbstractScanResultProcessor( GenericScanManager* manager, QObject* parent = nullptr ); - virtual ~AbstractScanResultProcessor(); + ~AbstractScanResultProcessor() override; Q_SIGNALS: /** Those signals can be connected to a progress bar to get progress information * from the scanner. */ void endProgressOperation( QObject * ); void incrementProgress(); void totalSteps( int totalSteps ); protected Q_SLOTS: // Signals received from the ScanManager. // They must be send in the correct order: // first scanStarted // then scandirectoryCount, scanDirectoryScanned in no particular order number // then scanSucceeded or scanFailed. virtual void scanStarted( GenericScanManager::ScanType type ); virtual void scanDirectoryCount( int count ); /** Submits a new directory for processing. */ virtual void scanDirectoryScanned( QSharedPointer dir ); virtual void scanSucceeded(); virtual void scanFailed( const QString& message ); virtual void abort(); protected: /** This are status messages that the scanner emits frequently. * You can collect them and display later. */ virtual void message( const QString& message ) = 0; virtual void commitDirectory( QSharedPointer dir ); virtual void commitPlaylist( const CollectionScanner::Playlist &playlist ); virtual void commitAlbum( CollectionScanner::Album *album ) = 0; virtual void commitTrack( CollectionScanner::Track *track, CollectionScanner::Album *srcAlbum ) = 0; /** * Delete directories (and their tracks) that have been deleted. * * In FullScan nad UpdateScan mode, it should delete all database directories on * mounted filesystems not encountered in the scan. * * In PartialUpdateScan mode, things are more complicated. It should only delete * not-encountered (direct) subdirectories of directories passed to * deleteDeletedTracksAndSubdirs(). However, if such directory is deleted, all its * subdirectories should be removed too. */ virtual void deleteDeletedDirectories() = 0; virtual void deleteDeletedTracksAndSubdirs( QSharedPointer directory ) = 0; CollectionScanner::Album* sortTrack( CollectionScanner::Track *track, const QString &dirName = QString() ); /** Cleans up all the stuff that the processor picked up through * the commit methods. * This function is called by scanSucceeded and scanFailed. */ virtual void cleanupMembers(); GenericScanManager* m_manager; QList > m_directories; // The keys for this hashtable are album name, artist (artist is empty for compilations) typedef QPair AlbumKey; QHash m_albums; // all the albums sorted by album name QMultiHash m_albumNames; GenericScanManager::ScanType m_type; }; #endif diff --git a/src/scanner/GenericScanManager.h b/src/scanner/GenericScanManager.h index 3fee5b5470..ab076a47b4 100644 --- a/src/scanner/GenericScanManager.h +++ b/src/scanner/GenericScanManager.h @@ -1,160 +1,160 @@ /**************************************************************************************** * Copyright (c) 2003-2008 Mark Kretschmann * * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Casey Link * * Copyright (c) 2008-2009 Jeff Mitchell * * Copyright (c) 2010-2011 Ralf Engels * * Copyright (c) 2011 Bart Cerneels * * Copyright (c) 2013 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 GENERICSCANMANAGER_H #define GENERICSCANMANAGER_H #include "amarok_export.h" #include "collectionscanner/Directory.h" #include #include #include #include #include class GenericScannerJob; /** * The ScanManager manages the scanning and directory watching. * * The scan manager will check the version of the amarokcollectionscanner application, * watch directories using the KDirWatch and initiate the scanning. * * For the scanning an external process with the scanner is started and the result * is handled in a separate thread. */ class AMAROK_EXPORT GenericScanManager : public QObject { Q_OBJECT public: explicit GenericScanManager( QObject* parent = nullptr ); - virtual ~GenericScanManager(); + ~GenericScanManager() override; /** The scan mode. In general a full scan will consider the information read from the disk as being superior to the one in the database. The full scan will overwrite existing album covers and statistics. An update scan is a scan done automatically by Amarok. I will check for new and changed tracks and will add to information already existing in the database. A partial update scan is an update scan that does not cover all directories, so the processor cannot rely on getting all directories from the scanner TODO: the ScanResultProcessor should be smart enough to figure out if directories should be removed. */ enum ScanType { /** This type of scan is done from the configuration dialog. * It should react as if it's the first time that the collection is scanned. * So it might e.g. throw away album covers added by the user. * * The ScanResultProcessor may assume that directories not found * during the scan are really gone (and not just excluded). */ FullScan = 0, /** This scan type scans the whole set of directories from a collection. * The ScanResultProcessor may assume that directories not found * during the scan are really gone (and not just excluded). */ UpdateScan = 1, /** This is an UpdateScan that does not include the whole set from a collection. * That means that directories not reported by the ScannerJob might not * have been excluded. */ PartialUpdateScan = 2 }; /** Returns true if the scanner job is currently scanning */ virtual bool isRunning(); /** Write the batch file * The batch file contains the known modification dates so that the scanner only * needs to report changed directories * @returns the path to the batch file or an empty string if nothing was written. */ virtual QString getBatchFile( const QStringList& scanDirsRequested ); public Q_SLOTS: /** Requests the scanner to do a full scan at the next possibility. */ virtual void requestScan( QList directories, GenericScanManager::ScanType type = UpdateScan ); /** Requests the scanner to do a full scan using the given import file. */ virtual void requestImport( QIODevice *input, GenericScanManager::ScanType type = UpdateScan ); /** Abort the request and all currently running scans. * Note: this function does not block further scans, so better * stop your directory watcher to stop scanning for a while. */ virtual void abort(); Q_SIGNALS: // the following signals are created by the scanner job and just // routed through // They are directly connected to the GenericScannerJob, so // beware of multi-threading void started( GenericScanManager::ScanType type ); /** Gives the estimated count of directories that this scan will have. This signal might not be emitted or emitted multiple times if the count is updated. */ void directoryCount( int count ); /** Emitted once we get the complete data for a directory. * @param dir The directory structure with all containing tracks. * * The dir pointer will stay valid until after the done signal. * Be careful, you need to have direct connections to * ensure that you don't access the pointer before it's being freed. * That also means that your slots are called within the job context. */ void directoryScanned( QSharedPointer dir ); void succeeded(); void failed( const QString& message ); protected: /** Connects all the signals to m_scannerJob */ void connectSignalsToJob(); QWeakPointer m_scannerJob; /** * This mutex is protecting the variables: * m_scannerJob */ QMutex m_mutex; }; Q_DECLARE_METATYPE(GenericScanManager::ScanType); #endif // GENERICSCANMANAGER_H diff --git a/src/scripting/scriptconsole/CompletionModel.h b/src/scripting/scriptconsole/CompletionModel.h index c6c3fabc6c..5c176704fb 100644 --- a/src/scripting/scriptconsole/CompletionModel.h +++ b/src/scripting/scriptconsole/CompletionModel.h @@ -1,48 +1,48 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 SCRIPTCONSOLE_COMPLETIONMODEL_H #define SCRIPTCONSOLE_COMPLETIONMODEL_H #include #include namespace KTextEditor { class View; } namespace ScriptConsoleNS { class AmarokScriptCodeCompletionModel : public KTextEditor::CodeCompletionModelControllerInterface , public KTextEditor::CodeCompletionModel { public: explicit AmarokScriptCodeCompletionModel( QObject *parent ); - virtual ~AmarokScriptCodeCompletionModel(); + ~AmarokScriptCodeCompletionModel() override; private: QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; void completionInvoked( KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType ) override; void executeCompletionItem( KTextEditor::View *view, const KTextEditor::Range &range, const QModelIndex &index ) const override; KTextEditor::Range completionRange( KTextEditor::View *view, const KTextEditor::Cursor &position ) override; bool shouldAbortCompletion( KTextEditor::View *view, const KTextEditor::Range &range, const QString ¤tCompletion ) override; QStringList m_completionList; QStringList m_autoCompleteStrings; }; } #endif // SCRIPTCONSOLE_COMPLETIONMODEL_H diff --git a/src/scripting/scriptconsole/ScriptConsole.h b/src/scripting/scriptconsole/ScriptConsole.h index 25b886f621..7afba0026d 100644 --- a/src/scripting/scriptconsole/ScriptConsole.h +++ b/src/scripting/scriptconsole/ScriptConsole.h @@ -1,106 +1,106 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 SCRIPTCONSOLE_H #define SCRIPTCONSOLE_H #include #include #include #include #include namespace KTextEditor{ class Editor; } class QEvent; class QListWidget; class QListWidgetItem; class QModelIndex; class QScriptEngine; namespace ScriptConsoleNS { class ScriptConsoleItem; class ScriptListDockWidget; class ScriptConsole : public QMainWindow { Q_OBJECT public: static ScriptConsole *instance(); private Q_SLOTS: void slotAbortEvaluation(); void slotExecuteNewScript(); void slotNewScript(); void setCurrentScriptItem( ScriptConsoleItem *item ); void slotEvaluationSuspended(); void slotEvaluationResumed(); void slotEditScript( ScriptConsoleItem *item ); private: explicit ScriptConsole( QWidget *parent ); - virtual ~ScriptConsole(); + ~ScriptConsole() override; bool eventFilter( QObject *watched, QEvent *event ) override; QDockWidget *getWidget( const QString &title, QScriptEngineDebugger::DebuggerWidget widget ); void closeEvent( QCloseEvent *event ) override; ScriptConsoleItem* createScriptItem( const QString &script ); QScriptEngineDebugger *m_debugger; QPointer m_scriptItem; QDockWidget *m_codeWidget; QString m_savePath; KTextEditor::Editor *m_editor; ScriptListDockWidget *m_scriptListDock; static QPointer s_instance; }; class ScriptListDockWidget : public QDockWidget { Q_OBJECT public: explicit ScriptListDockWidget( QWidget *parent ); - ~ScriptListDockWidget(); + ~ScriptListDockWidget() override; void addScript( ScriptConsoleItem *script ); void addItem( QListWidgetItem *item ); public Q_SLOTS: void clear(); void removeCurrentScript(); void prev(); void next(); Q_SIGNALS: void edit( ScriptConsoleItem *item ); void executeScript( ScriptConsoleItem *item ); void currentItemChanged( ScriptConsoleItem *newItem ); void newScript(); private Q_SLOTS: void slotDoubleClicked( const QModelIndex &index ); void slotCurrentItemChanged( QListWidgetItem *newItem, QListWidgetItem *oldItem ); private: QListWidget *m_scriptListWidget; const int ScriptRole = 1002; }; } #endif // SCRIPTCONSOLE_H diff --git a/src/scripting/scriptconsole/ScriptConsoleItem.h b/src/scripting/scriptconsole/ScriptConsoleItem.h index bc2484c3ff..54b4e4ce14 100644 --- a/src/scripting/scriptconsole/ScriptConsoleItem.h +++ b/src/scripting/scriptconsole/ScriptConsoleItem.h @@ -1,64 +1,64 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 SCRIPT_CONSOLE_ITEM_H #define SCRIPT_CONSOLE_ITEM_H #include "scripting/scriptmanager/ScriptItem.h" namespace KTextEditor{ class View; } class QScriptEngine; class QWidget; namespace ScriptConsoleNS { class ScriptEditorDocument; class ScriptConsoleItem : public ScriptItem { Q_OBJECT public: ScriptConsoleItem( QObject *parent, const QString &name, const QString &path , const QString &category, ScriptEditorDocument *document ); - virtual ~ScriptConsoleItem(); + ~ScriptConsoleItem() override; ScriptEditorDocument* document() { return m_viewFactory; } bool start( bool silent = false ) override; KTextEditor::View *createEditorView( QWidget *parent ); /** * Clear script files on disk upon object deletion */ void setClearOnDeletion( bool clearOnDelete ); void pause() override; private: bool m_clearOnDelete; ScriptEditorDocument *m_viewFactory; QPointer m_view; void timerEvent(QTimerEvent* event) override; void initializeScriptEngine() override; static KPluginInfo createSpecFile( const QString &name, const QString &category, const QString &path ); QString handleError( QScriptEngine *engine ) override; }; } Q_DECLARE_METATYPE( ScriptConsoleNS::ScriptConsoleItem* ) #endif // SCRIPT_CONSOLE_ITEM_H diff --git a/src/scripting/scriptconsole/ScriptEditorDocument.h b/src/scripting/scriptconsole/ScriptEditorDocument.h index ac07fc697a..6e20dea882 100644 --- a/src/scripting/scriptconsole/ScriptEditorDocument.h +++ b/src/scripting/scriptconsole/ScriptEditorDocument.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 SCRIPT_EDITOR_DOCUMENT_H #define SCRIPT_EDITOR_DOCUMENT_H #include "AmarokSharedPointer.h" #include #include namespace KTextEditor { class Document; class View; } class QUrl; class QColor; class QWidget; namespace ScriptConsoleNS { class AmarokScriptCodeCompletionModel; class ScriptEditorDocument : public QObject { Q_OBJECT public: ScriptEditorDocument( QObject *parent, KTextEditor::Document* document ); - virtual ~ScriptEditorDocument(); + ~ScriptEditorDocument() override; QString text() const; KTextEditor::View *createView( QWidget *editor = 0 ); void setText( const QString &text ); void save( const QUrl &url ); void save(); void setReadWrite( bool readWrite ); static void highlight( KTextEditor::View *view, int line, const QColor &color ); private: KTextEditor::Document *m_document; static QPointer s_completionModel; }; } #endif // SCRIPT_EDITOR_DOCUMENT_H diff --git a/src/scripting/scriptengine/AmarokCollectionViewScript.h b/src/scripting/scriptengine/AmarokCollectionViewScript.h index f6c1abff62..58872fc4d4 100644 --- a/src/scripting/scriptengine/AmarokCollectionViewScript.h +++ b/src/scripting/scriptengine/AmarokCollectionViewScript.h @@ -1,248 +1,248 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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_COLLECTIONVIEW_SCRIPT_H #define AMAROK_COLLECTIONVIEW_SCRIPT_H #include "browsers/BrowserDefines.h" // #include "core/meta/forward_declarations.h" #include "core/meta/Meta.h" #include #include #include #include #include #include #include class CollectionTreeItemModelBase; class CollectionWidget; class CollectionTreeItem; namespace Collections { class Collection; class QueryMaker; } class QMenu; class QScriptEngine; typedef QList QActionList; namespace AmarokScript { class AmarokScriptEngine; class Selection; class CollectionViewItem; // SCRIPTDOX Amarok.Window.CollectionView /** * Must call Importer.loadAmarokBinding( "collectionview" ); first; */ class AmarokCollectionViewScript : public QObject { Q_OBJECT Q_PROPERTY( QString filter READ filter WRITE setFilter ) Q_PROPERTY( QScriptValue selection READ selectionScriptValue ) Q_PROPERTY( bool showYears READ showYears WRITE setShowYears ) Q_PROPERTY( bool showTrackNumbers READ showTrackNumbers WRITE setShowTrackNumbers ) Q_PROPERTY( bool showCovers READ showCovers WRITE setShowCovers ) /** * Set levels like: * * Importer.loadAmarokBinding("collectionview"); * var cat = Amarok.Window.CollectionView.Category; * Amarok.Window.CollectionView.levels = [cat.Album,cat.Artist,cat.Year]; */ Q_PROPERTY( QList levels READ levels WRITE setLevels ) Q_PROPERTY( bool mergedView READ mergedView WRITE setMergedView ) public: AmarokCollectionViewScript( AmarokScriptEngine *scriptEngine, const QString &scriptName ); - ~AmarokCollectionViewScript(); + ~AmarokCollectionViewScript() override; static void createScriptedActions( QMenu &menu, const QModelIndexList &indices ); QActionList actions(); static Selection *selection(); // SCRIPTDOX ENUM Amarok.CollectionView.Category enum Category { None = CategoryId::None, Album = CategoryId::Album, Artist = CategoryId::Artist, AlbumArtist = CategoryId::AlbumArtist, Composer = CategoryId::Composer, Genre = CategoryId::Genre, Year = CategoryId::Year, Label = CategoryId::Label }; Q_ENUM( Category ) public Q_SLOTS: void setLevel( int level, int type ); /** * Set a function returning a QActionList here. */ void setAction( const QScriptValue &value ); Q_SIGNALS: void filterChanged( QString ); private: QString filter() const; void setFilter( const QString &filter ); QList levels() const; void setLevels( const QList &levels ); QScriptValue selectionScriptValue(); void setShowYears( bool shown ); void setShowTrackNumbers( bool shown ); void setShowCovers( bool shown ); bool showYears(); bool showTrackNumbers(); bool showCovers(); bool mergedView() const; void setMergedView( bool merged ); static QMap s_instances; static QPointer s_selection; QScriptValue m_actionFunction; CollectionWidget *m_collectionWidget; AmarokScriptEngine *m_engine; QString m_scriptName; const QMetaEnum m_categoryEnum; friend class AmarokWindowScript; }; /** * Represents an item from the CollectionTreeView */ class CollectionViewItem : public QObject { Q_OBJECT Q_PROPERTY( CollectionTreeItem* parent READ parent ) Q_PROPERTY( int childCount READ childCount ) Q_PROPERTY( QList children READ children ) Q_PROPERTY( int row READ row ) Q_PROPERTY( int level READ level ) Q_PROPERTY( Collections::Collection* parentCollection READ parentCollection ) Q_PROPERTY( bool isCollection READ isCollection ) Q_PROPERTY( bool isDataItem READ isDataItem ) Q_PROPERTY( bool isAlbumItem READ isAlbumItem ) Q_PROPERTY( bool isTrackItem READ isTrackItem ) Q_PROPERTY( bool isVariousArtistItem READ isVariousArtistItem ) Q_PROPERTY( bool isNoLabelItem READ isNoLabelItem ) /** * Returns true if all of this item's children have been loaded. */ Q_PROPERTY( bool childrenLoaded READ childrenLoaded ) public: explicit CollectionViewItem( CollectionTreeItem *item, QObject *parent = nullptr ); CollectionTreeItem* data() const; static QScriptValue toScriptValue( QScriptEngine *engine, CollectionTreeItem* const &item ); /** * @return QueryMaker representing this item's descendant tracks ( or just the item if a track ) */ Q_INVOKABLE Collections::QueryMaker* queryMaker(); /** * Add a filter representing this item to @p queryMaker. * For example, for obtaining a specific collection's items in the merged view. * * @param queryMaker the Query maker. */ Q_INVOKABLE void addFilter( Collections::QueryMaker *queryMaker ); /** * Return the child item at @p row. * * @param row the number of the row. */ Q_INVOKABLE CollectionTreeItem* child( int row ); /** * Load children if they haven't already been loaded. * Emit loaded( CollectionTreeItem* ) on completion. */ Q_INVOKABLE void loadChildren(); /** * Return the track item represented by this collection item, * invalid track if !isTrack */ Q_INVOKABLE Meta::TrackPtr track(); private Q_SLOTS: void slotDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight ); Q_SIGNALS: void loaded( CollectionTreeItem* ); private: CollectionTreeItem* parent() const; QList children() const; int row() const; int level() const; bool isAlbumItem() const; bool isTrackItem() const; bool isVariousArtistItem() const; bool isNoLabelItem() const; bool isDataItem() const; int childCount() const; bool isCollection() const; Collections::Collection* parentCollection() const; bool childrenLoaded() const; CollectionTreeItemModelBase *getModel(); CollectionTreeItem *m_item; }; class Selection : public QObject { Q_OBJECT /** * Whether the selected items belongs to a single collection. */ Q_PROPERTY( bool singleCollection READ singleCollection ) /** * Get the selected lis tof items. */ Q_PROPERTY( QList selectedItems READ selectedItems ) public Q_SLOTS: /** * Get a QueryMaker for the selected items. */ Collections::QueryMaker* queryMaker(); private: Selection( const QModelIndexList &indices ); bool singleCollection() const; QList selectedItems(); QModelIndexList m_indices; friend AmarokCollectionViewScript; }; } #endif diff --git a/src/scripting/scriptengine/AmarokScriptXml.h b/src/scripting/scriptengine/AmarokScriptXml.h index de933cd56c..4b1e2a90a5 100644 --- a/src/scripting/scriptengine/AmarokScriptXml.h +++ b/src/scripting/scriptengine/AmarokScriptXml.h @@ -1,52 +1,52 @@ /* * Copyright (C) 2017 Malte Veerman * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef AMAROKSCRIPTXML_H #define AMAROKSCRIPTXML_H #include class QDomDocument; class QScriptEngine; class QXmlStreamReader; namespace AmarokScript { class AmarokScriptXml : public QObject { Q_OBJECT public: explicit AmarokScriptXml( QScriptEngine *engine ); - ~AmarokScriptXml(); + ~AmarokScriptXml() override; Q_INVOKABLE void setReaderData( const QString &data ); Q_INVOKABLE bool setDomObjectData( const QString &data ); Q_INVOKABLE QString readFirstStreamElementWithName( const QString &name ); Q_INVOKABLE QString textOfFirstDomElementWithName( const QString &name ); private: QXmlStreamReader *m_reader; QDomDocument *m_domDocument; }; } #endif // AMAROKSCRIPTXML_H diff --git a/src/scripting/scriptengine/ScriptingDefines.h b/src/scripting/scriptengine/ScriptingDefines.h index 1dad4576cf..f97b84bab8 100644 --- a/src/scripting/scriptengine/ScriptingDefines.h +++ b/src/scripting/scriptengine/ScriptingDefines.h @@ -1,142 +1,142 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 AMAROKSCRIPT_SCRIPTING_DEFINES_H #define AMAROKSCRIPT_SCRIPTING_DEFINES_H #include #include #include #include #include class QMetaEnum; namespace AmarokScript { template void fromScriptValue( const QScriptValue &obj, type &object ) { const WrapperType *wrapper = dynamic_cast( obj.toQObject() ); if( wrapper ) object = wrapper->data(); else object = 0; } template QScriptValue toScriptValue( QScriptEngine *engine, type const &object ) { WrapperType *wrapper = new WrapperType( object ); return engine->newQObject( wrapper, QScriptEngine::ScriptOwnership, QScriptEngine::ExcludeSuperClassContents ); } template QScriptValue toScriptArray( QScriptEngine *engine, const Container &container ) { QScriptValue scriptArray = engine->newArray(); typename Container::const_iterator begin = container.begin(); typename Container::const_iterator end = container.end(); typename Container::const_iterator it; for( it = begin; it != end; ++it ) scriptArray.setProperty( quint32(it - begin), engine->toScriptValue(*it) ); return scriptArray; } template void fromScriptArray( const QScriptValue &value, Container &container ) { quint32 len = value.property( QStringLiteral("length") ).toUInt32(); for( quint32 i = 0; i < len; ++i ) { QScriptValue item = value.property( i ); typedef typename Container::value_type ContainerValue; container.push_back( qscriptvalue_cast(item) ); } } template QScriptValue toScriptMap( QScriptEngine *engine, const Map &map ) { QScriptValue scriptMap = engine->newObject(); for( typename Map::const_iterator it( map.begin() ); it != map.end(); ++it ) scriptMap.setProperty( it.key(), engine->toScriptValue( it.value() ) ); return scriptMap; } template void fromScriptMap( const QScriptValue &value, Map &map ) { QScriptValueIterator it( value ); while( it.hasNext() ) { it.next(); map[it.name()] = qscriptvalue_cast( it.value() ); } } /** * SCRIPTDOX _ */ class AmarokScriptEngine : public QScriptEngine { Q_OBJECT public: explicit AmarokScriptEngine( QObject *parent ); - virtual ~AmarokScriptEngine(); + ~AmarokScriptEngine() override; void setDeprecatedProperty( const QString &parent, const QString &name, const QScriptValue &property ); // exposing the metaobject directly also exposes >900 other values QScriptValue enumObject( const QMetaEnum &metaEnum ); template void registerArrayType() { qScriptRegisterMetaType( this, toScriptArray, fromScriptArray ); } template void registerMapType() { qScriptRegisterMetaType( this, toScriptMap, fromScriptMap ); } // SCRIPTDOX exclude Q_INVOKABLE void invokableDeprecatedCall( const QString &call ); /** * @param function The function to invoke after time @param time in milliseconds. * @param thisObject [Optional] The this object this function is invoked with. * @param args [Optional] An array containing arguments this function is to be invoked with. */ Q_INVOKABLE void setTimeout( const QScriptValue &function, int time, const QScriptValue &thisObject = QScriptValue(), const QScriptValue &args = QScriptValue() ); private Q_SLOTS: void slotTimeout(); Q_SIGNALS: void deprecatedCall(const QString &); private: const QString internalObject; QHash m_callbacks; }; } #endif // AMAROKSCRIPT_SCRIPTING_DEFINES_H diff --git a/src/scripting/scriptengine/exporters/QueryMakerExporter.h b/src/scripting/scriptengine/exporters/QueryMakerExporter.h index f25aa0e1a6..ccabb08007 100644 --- a/src/scripting/scriptengine/exporters/QueryMakerExporter.h +++ b/src/scripting/scriptengine/exporters/QueryMakerExporter.h @@ -1,111 +1,111 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 QUERYMAKER_EXPORTER_H #define QUERYMAKER_EXPORTER_H #include "amarok_export.h" #include "core/collections/QueryMaker.h" #include "core/meta/Meta.h" #include #include #include namespace Collections { class QueryMaker; } class QScriptEngine; namespace AmarokScript { // SCRIPTDOX PROTOTYPE Collections::QueryMaker QueryMaker #ifdef DEBUG class AMAROK_EXPORT #else class #endif QueryMakerPrototype : public QObject { Q_OBJECT /** * Indicates whether this query maker object is valid. */ Q_PROPERTY( bool isValid READ isValid ) /** * The current filter string. */ Q_PROPERTY( QString filter READ filter ) public: static void init( QScriptEngine *engine ); QueryMakerPrototype( Collections::QueryMaker *collection ); - ~QueryMakerPrototype(); + ~QueryMakerPrototype() override; Collections::QueryMaker *data() const { return m_querymaker; } /** * Starts the query. This method returns immediately. All processing is done in one or more * separate worker thread(s). One of the newResultReady signals will be emitted at least once, * followed by the queryDone() signal exactly once. */ Q_INVOKABLE void run(); /** * Block until the query completes, returns the tracklist. */ Q_INVOKABLE Meta::TrackList blockingRun(); /** * Aborts a running query. */ Q_INVOKABLE void abort(); /** * Add a filter query to this query maker. */ Q_INVOKABLE void addFilter( const QString &filter ); private: QPointer m_querymaker; QString m_filter; Meta::TrackList m_result; bool isValid() const; QString filter() const; private Q_SLOTS: void slotResult( const Meta::TrackList &tracks ); Q_SIGNALS: /** * newResultReady will be emitted every time new results from the query maker are received. * This signal can be emitted zero times (in case of no results) one (the usual case) or multiple times * (e.g. in case when the result is received in several batches). * The results will be terminated by a queryDone signal. */ void newResultReady( Meta::TrackList ); /** * This signal is emitted after all the results have been submitted via zero or more newResultReady signals. */ void queryDone(); }; } #endif diff --git a/src/scripting/scriptengine/exporters/ScriptableBiasExporter.h b/src/scripting/scriptengine/exporters/ScriptableBiasExporter.h index fa76e409cf..44c22c197f 100644 --- a/src/scripting/scriptengine/exporters/ScriptableBiasExporter.h +++ b/src/scripting/scriptengine/exporters/ScriptableBiasExporter.h @@ -1,293 +1,293 @@ /**************************************************************************************** * Copyright (c) 2013 Anmol Ahuja * * * * 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 BIAS_EXPORTER_H #define BIAS_EXPORTER_H #include "dynamic/Bias.h" #include "dynamic/BiasFactory.h" #include #include #include #include #include class QScriptContext; class QScriptEngine; namespace AmarokScript { // SCRIPTDOX BiasFactory class ScriptableBiasFactory : public QObject, public Dynamic::AbstractBiasFactory { Q_OBJECT /** * Set whether this bias is enabled and visible in the dynamic playlist bias menu. */ Q_PROPERTY( bool enabled READ enabled WRITE setEnabled ) /** * A user visible name for this bias */ Q_PROPERTY( QString name READ i18nName WRITE setI18nName ) // corresponds to i18name /** * A unique identifier for this bias. */ Q_PROPERTY( QString identifier READ name WRITE setName ) /** * A user visible description for this bias. */ Q_PROPERTY( QString description READ i18nDescription WRITE setI18nDescription ) /** * Set a function returning widget appropriate for editing the bias, if needed. * var obj = new ScriptableBias(); obj.widget = function( a ) { return new QLabel(\"dfdsf\"); }" */ Q_PROPERTY( QScriptValue widget READ widgetFunction WRITE setWidgetFunction ) Q_PROPERTY( QScriptValue fromXml READ fromXmlFunction WRITE setFromXmlFunction ) Q_PROPERTY( QScriptValue toXml READ toXmlFunction WRITE setToXmlFunction ) /** * Set this to a function of signature: * TrackSet ( const Meta::TrackList &playlist, int contextCount, int finalCount, QStringList universeUids ) */ Q_PROPERTY( QScriptValue matchingTracks READ matchingTracksFunction WRITE setMatchingTracksFunction ) /** * bool trackMatches( int position, TrackList playlist, int contextCount ) */ Q_PROPERTY( QScriptValue trackMatches READ trackMatchesFunction WRITE setTrackMatchesFunction ) Q_PROPERTY( QScriptValue toStringFunction READ toStringFunction WRITE setToStringFunction ) Q_PROPERTY( QScriptValue init READ initFunction WRITE setInitFunction ) public: static void init( QScriptEngine *engine ); QString i18nName() const override; QString name() const override; QString i18nDescription() const override; QScriptValue initFunction() const; QScriptValue fromXmlFunction() const; QScriptValue matchingTracksFunction() const; QScriptValue toXmlFunction() const; QScriptValue toStringFunction() const; QScriptValue trackMatchesFunction() const; QScriptValue widgetFunction() const; QScriptEngine *engine() const; public Q_SLOTS: Dynamic::BiasPtr createBias() override; private: static QScriptValue groupBiasCtor( QScriptContext *context, QScriptEngine *engine ); static QScriptValue biasCtor( QScriptContext *context, QScriptEngine *engine ); ScriptableBiasFactory( QScriptEngine *engine = 0, bool groupBias = false ); - ~ScriptableBiasFactory(); + ~ScriptableBiasFactory() override; bool enabled() const; void setEnabled( bool enabled ); void setName( const QString &name ); void setI18nName( const QString &i18nName ); void setI18nDescription( const QString &description ); void setInitFunction( const QScriptValue &value ); void setWidgetFunction( const QScriptValue &value ); void setFromXmlFunction( const QScriptValue &value ); void setToXmlFunction( const QScriptValue &value ); void setTrackMatchesFunction( const QScriptValue &value ); void setMatchingTracksFunction( const QScriptValue &value ); void setToStringFunction( const QScriptValue &value ); QScriptValue m_initFunction; QString m_name; QString m_i18nName; QString m_description; QScriptValue m_widgetFunction; QScriptValue m_fromXmlFunction; QScriptValue m_toXmlFunction; QScriptValue m_matchingTracksFunction; QScriptValue m_trackMatchesFunction; QScriptValue m_toStringFunction; bool m_groupBias; QScriptEngine *m_engine; bool m_enabled; }; class ScriptableBias : public Dynamic::AbstractBias { Q_OBJECT public: explicit ScriptableBias( ScriptableBiasFactory *biasProto ); ~ScriptableBias() override; QScriptValue scriptObject() { return m_biasObject; } public: void fromXml( QXmlStreamReader *reader ) override; void toXml(QXmlStreamWriter *writer) const override; Dynamic::TrackSet matchingTracks( const Meta::TrackList &playlist, int contextCount, int finalCount, const Dynamic::TrackCollectionPtr &universe ) const override; bool trackMatches( int position, const Meta::TrackList &playlist, int contextCount ) const override; QString toString() const override; QString name() const override; void paintOperator( QPainter *painter, const QRect &rect, AbstractBias *bias ) override; QWidget* widget( QWidget *parent = nullptr ) override; private Q_SLOTS: Dynamic::TrackSet slotMatchingTracks( const Meta::TrackList &playlist, int contextCount, int finalCount, const Dynamic::TrackCollectionPtr &universe ) const; void removeBias(); public Q_SLOTS: /** This slot is called when the bias should discard cached results. * This will be done in case a new playlist is requested for an updated * collection. */ void invalidate() override; /** Call this function when this bias should be replaced by a new one. * @param newBias The bias that replaces this bias. If you give * an empty BiasPrt as argument the bias will be removed. */ void replace( const Dynamic::BiasPtr &newBias ) override; /** * Call after an outstanding result is completed */ void ready( const Dynamic::TrackSet &trackSet ); private: QPointer m_scriptBias; QScriptEngine *m_engine; QScriptValue m_biasObject; }; /** * A representation of a set of tracks, relative to a given universe set. * Intersecting TrackSets from different universes is not a good idea. */ class TrackSetExporter : public QObject, public Dynamic::TrackSet { Q_OBJECT /** * The number of songs contained in this trackSet. */ Q_PROPERTY( int count READ trackCount ) /** * True if all of the tracks are included in the set. */ Q_PROPERTY( bool isFull READ isFull ) /** * Returns true if the results of this track set are not yet available */ Q_PROPERTY( bool isOutstanding READ isOutstanding ) /** * True if none of the tracks are included in the set. */ Q_PROPERTY( bool isEmpty READ isEmpty ) public: static QScriptValue toScriptValue( QScriptEngine *engine, Dynamic::TrackSet const &trackSet ); static void fromScriptValue( const QScriptValue &obj, Dynamic::TrackSet &trackSet ); static QScriptValue trackSetConstructor( QScriptContext* context, QScriptEngine* engine ); /** * Includes or excludes all tracks in the set. * @param value If true set is set to "full". Else to "empty". */ Q_INVOKABLE void reset( bool value ); /** * Returns true if the @param uid is included in the set */ Q_INVOKABLE bool containsUid( const QString& uid ) const; Q_INVOKABLE bool containsTrack( const Meta::TrackPtr &track ) const; /** * Returns the uids of a random track contains in this set */ Q_INVOKABLE Meta::TrackPtr getRandomTrack() const; /** * Add the track @param track to the trackset. */ Q_INVOKABLE void uniteTrack( const Meta::TrackPtr &track ); /** * Add the track set @p trackSet to the trackset. * * @param trackSet the track set to be added. */ Q_INVOKABLE void uniteTrackSet( const Dynamic::TrackSet &trackSet ); /** * Add the uids @p uids to the trackset. * * @param uids string list of the uids. */ Q_INVOKABLE void uniteUids( const QStringList &uids ); /** * Perform an intersection of the trackset with the set @param trackSet */ Q_INVOKABLE void intersectTrackSet( const Dynamic::TrackSet &trackSet ); /** * Perform an intersection on this trackset with the trackset represented by @param uids */ Q_INVOKABLE void intersectUids( const QStringList &uids ); /** * Subtract the track @param track from this trackset. */ Q_INVOKABLE void subtractTrack( const Meta::TrackPtr &track ); /** * Subtract the trackset @param trackSet from this trackset */ Q_INVOKABLE void subtractTrackSet( const Dynamic::TrackSet &trackSet ); /** * Subtract the set represented by @param uids from this trackset */ Q_INVOKABLE void subtractUids( const QStringList &uids ); private: static void init( QScriptEngine *engine ); explicit TrackSetExporter( const Dynamic::TrackSet &trackSet ); friend class ScriptableBiasFactory; }; } Q_DECLARE_METATYPE( QXmlStreamReader* ) Q_DECLARE_METATYPE( QXmlStreamWriter* ) Q_DECLARE_METATYPE( AmarokScript::ScriptableBias* ) #endif diff --git a/src/scripting/scriptmanager/ScriptManager.h b/src/scripting/scriptmanager/ScriptManager.h index f8ab5dd0c5..06e53c05b9 100644 --- a/src/scripting/scriptmanager/ScriptManager.h +++ b/src/scripting/scriptmanager/ScriptManager.h @@ -1,135 +1,135 @@ /**************************************************************************************** * Copyright (c) 2004-2010 Mark Kretschmann * * Copyright (c) 2005 Seb Ruiz * * Copyright (c) 2008 Peter ZHOU * * * * 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_SCRIPTMANAGER_H #define AMAROK_SCRIPTMANAGER_H #include "amarok_export.h" #include "core/meta/forward_declarations.h" #include "ScriptItem.h" #include #include #include namespace AmarokScript { class AmarokScript; } class QScriptEngine; class QScriptValue; class AMAROK_EXPORT ScriptManager : public QObject { Q_OBJECT public: static ScriptManager* instance(); static void destroy(); /** * Runs the script with the given name. * @param name The pluginName of the script. * @param silent Whether to suppress the script output. * @return True if successful. */ bool runScript( const QString& name, bool silent = false ); /** * Stops the script with the given name. * @param name The name of the script. * @return True if successful. */ bool stopScript( const QString& name ); void configChanged( bool changed ); KPluginInfo::List scripts( const QString &category ) const; /** Returns a list of all currently running scripts. Used by the DCOP handler. */ QStringList listRunningScripts() const; /** Returns the path of the spec file of the given script */ QString specForScript( const QString& name ) const; /** Returns whether or not there is a lyrics script running */ bool lyricsScriptRunning() const; QString scriptNameForEngine( const QScriptEngine *engine ) const; /** Notifies any running lyric scripts to fetch desired lyric from given URL */ void notifyFetchLyrics( const QString& artist, const QString& title, const QString& url, const Meta::TrackPtr &track ); void ServiceScriptPopulate( const QString &name, int level, int parent_id, const QString &callbackString, const QString &filter ); void ServiceScriptRequestInfo( const QString &name, int level, const QString &callbackString ); void ServiceScriptCustomize( const QString &name ); typedef QHash ScriptMap; ScriptMap m_scripts; QString m_lyricsScript; public Q_SLOTS: /** Finds installed scripts, updates them, and loads them */ void updateAllScripts(); Q_SIGNALS: // needed so the lyrics script can connect to this void fetchLyrics( const QString&, const QString&, const QString& url, Meta::TrackPtr ); void lyricsScriptStarted(); /** * Emitted when a script is added, removed or updated */ void scriptsChanged(); private Q_SLOTS: bool slotRunScript( const QString &name, bool silent = false ); void handleException( const QScriptValue &value ); void updaterFinished( const QString &scriptPath ); void slotConfigChanged(); private: explicit ScriptManager( QObject* parent ); - virtual ~ScriptManager(); + ~ScriptManager() override; /// \return false if loadScript failed. bool loadScript( const QString& path ); ///////////////////////////////////////////////////////////////////////////////////// // DATA MEMBERS ///////////////////////////////////////////////////////////////////////////////////// static ScriptManager* s_instance; bool m_configChanged; QStringList m_changedScripts; // count returning ScriptUpdaters in a thread-safe way QSemaphore m_updateSemaphore; // memorize how many scripts were found and tried to be updated int m_nScripts; }; #endif /* AMAROK_SCRIPTMANAGER_H */ diff --git a/src/scripting/scriptmanager/ScriptUpdater.h b/src/scripting/scriptmanager/ScriptUpdater.h index baa6168e11..3b3d7c79a8 100644 --- a/src/scripting/scriptmanager/ScriptUpdater.h +++ b/src/scripting/scriptmanager/ScriptUpdater.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2009 Jakob Kummerow * * * * 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_SCRIPTUPDATER_H #define AMAROK_SCRIPTUPDATER_H #include "ScriptUpdaterStatic.h" #include class KJob; class ScriptUpdater : public QObject { Q_OBJECT public: explicit ScriptUpdater( QObject *parent ); - virtual ~ScriptUpdater(); + ~ScriptUpdater() override; void setScriptPath( const QString& scriptPath ); public Q_SLOTS: void updateScript(); Q_SIGNALS: void finished( const QString &scriptPath ); private Q_SLOTS: void phase2( KJob * job ); void phase3( KJob * job ); void phase4( KJob * job ); private: bool isNewer(const QString & update, const QString & installed); QString m_scriptPath; // dynamically collected information about the script QString m_scriptname, m_scriptversion, m_fileName; QTemporaryFile m_archiveFile, m_sigFile, m_versionFile; }; #endif // AMAROK_SCRIPTUPDATER_H diff --git a/src/services/DynamicServiceQueryMaker.h b/src/services/DynamicServiceQueryMaker.h index bfa3c0431d..1b1880a6ee 100644 --- a/src/services/DynamicServiceQueryMaker.h +++ b/src/services/DynamicServiceQueryMaker.h @@ -1,84 +1,84 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 DYNAMICSERVICEQUERYMAKER_H #define DYNAMICSERVICEQUERYMAKER_H #include "core/meta/forward_declarations.h" #include "core/collections/QueryMaker.h" #include "ServiceCollection.h" #include "amarok_export.h" #include namespace ThreadWeaver { } namespace Collections { /** A base class for implementing custom querymakers that fetch data from an external source. Basically just stubs out the stuff that not every dynamic querymaker will need @author */ class AMAROK_EXPORT DynamicServiceQueryMaker : public QueryMaker { Q_OBJECT public: DynamicServiceQueryMaker( ); - virtual ~DynamicServiceQueryMaker() {} + ~DynamicServiceQueryMaker() override {} //this is the stuff that must be implemented void run() override = 0; void abortQuery() override = 0; //below here is the stuf that each dynamic querymaker will most likely only need //Some of, hence they are all stubbed out: QueryMaker* setQueryType( QueryType type ) override { Q_UNUSED( type); return this; } QueryMaker* addReturnValue ( qint64 value ) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy ( qint64 value, bool descending = false ) override; QueryMaker* addMatch ( const Meta::TrackPtr &track ) override; QueryMaker* addMatch ( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch ( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch ( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch ( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch ( const Meta::YearPtr &year ) override; QueryMaker* addMatch ( const Meta::LabelPtr &label ) override; QueryMaker* addFilter ( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* excludeFilter ( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* limitMaxResultSize ( int size ) override; QueryMaker* beginAnd() override { return this; } QueryMaker* beginOr() override { return this; } QueryMaker* endAndOr() override { return this; } static Meta::AlbumList matchAlbums( ServiceCollection *coll, const Meta::ArtistPtr &artist ); }; } //namespace Collections #endif diff --git a/src/services/ServiceAlbumCoverDownloader.h b/src/services/ServiceAlbumCoverDownloader.h index dc958decd5..2447c0f019 100644 --- a/src/services/ServiceAlbumCoverDownloader.h +++ b/src/services/ServiceAlbumCoverDownloader.h @@ -1,168 +1,168 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 SERVICEALBUMCOVERDOWNLOADER_H #define SERVICEALBUMCOVERDOWNLOADER_H #include "ServiceMetaBase.h" #include "amarok_export.h" #include #include #include #include namespace Meta { //forward declaration class ServiceAlbumWithCover; typedef AmarokSharedPointer ServiceAlbumWithCoverPtr; /** A specialized ServiceAlbum that supports fetching its cover from a known url. Takes care of caching covers. @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT ServiceAlbumWithCover : public ServiceAlbum { public: /** * Constructor, reimplemented from ServiceAlbum. * @param name The name of the album. */ explicit ServiceAlbumWithCover( const QString &name ); /** * Constructor, reimplemented from ServiceAlbum. * @param resultRow The result raw used to initialize the album. */ explicit ServiceAlbumWithCover( const QStringList &resultRow ); /** * Destructor. */ - virtual ~ServiceAlbumWithCover(); + ~ServiceAlbumWithCover() override; /** * Get the download prefix used for caching the cover. * @return The prefix, most often the name of the parent service. */ virtual QString downloadPrefix() const = 0; /** * Set the url from where to fetch the cover. * @param coverUrl The cover url. */ virtual void setCoverUrl( const QString &coverUrl ) = 0; /** * Ger the cover url * @return The url of the cover. */ virtual QString coverUrl() const = 0; /** * Set the cover image of the album. * @param image The cover image. */ void setImage( const QImage &image ) override; /** * Notify album that the download of the cover has been cancelled. */ void imageDownloadCanceled() const; /** * Reimplemented from Meta::Album. Get whether an album has a cover. This function always returns true to avoid the standard cover fetcher kicking in. * @param size Unused. * @return True. */ bool hasImage( int size = 1 ) const override { Q_UNUSED( size ); return true; } /** * Get the image of this album. If the image has not yet been fetched, this call will return a standard * "no-cover" cover and then start the download of the real cover. When the download is complete, any oberserves will be notified that the metadata of this album has been changed. * @param size The required size of the album. * @return The cover image or a default cover. */ QImage image( int size = 0 ) const override; //overridden from Meta::Album protected: mutable QImage m_cover; mutable bool m_hasFetchedCover; mutable bool m_isFetchingCover; QString m_coverDownloadPath; }; /** A helper class for fetching covers from online services, used by ServiceAlbumWithCover @author Nikolaj Hald Nielsen */ class ServiceAlbumCoverDownloader : public QObject { Q_OBJECT public: /** * Constructor. */ ServiceAlbumCoverDownloader(); /** * Destructor. */ - ~ServiceAlbumCoverDownloader(); + ~ServiceAlbumCoverDownloader() override; /** * Start the download of the cover of a ServiceAlbumWithCover. * @param album The albumwhose cover should be downloaded. */ void downloadCover( Meta::ServiceAlbumWithCoverPtr album ); private Q_SLOTS: /** * Slot called when the download job is complete. * @param downloadJob The job responsible for the cover download. */ void coverDownloadComplete( KJob * downloadJob ); /** * Slot called if the download job is cancelled. * @param downloadJob The job responsible for the cover download. */ void coverDownloadCanceled( KJob * downloadJob ); private: Meta::ServiceAlbumWithCoverPtr m_album; QString m_coverDownloadPath; KIO::FileCopyJob * m_albumDownloadJob; QTemporaryDir * m_tempDir; }; } #endif diff --git a/src/services/ServiceBase.h b/src/services/ServiceBase.h index 2739d5c572..dfdcc6d95a 100644 --- a/src/services/ServiceBase.h +++ b/src/services/ServiceBase.h @@ -1,352 +1,352 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMAROKSERVICEBASE_H #define AMAROKSERVICEBASE_H #include "browsers/BrowserCategory.h" #include "core/support/Amarok.h" #include "core/support/PluginFactory.h" #include "InfoParserBase.h" #include "ServiceCollectionTreeView.h" #include "ServiceMetaBase.h" #include "amarok_export.h" #include "core-impl/meta/proxy/MetaProxy.h" #include "widgets/PrettyTreeView.h" #include #include #include #include #include #include class BoxWidget; class ServiceBase; class SearchWidget; class QMenuBar; /** A virtual base class for factories for creating and handling the different types of service plugins @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT ServiceFactory : public Plugins::PluginFactory, public Collections::TrackProvider { Q_OBJECT public: /** * Constructor. */ ServiceFactory(); /** * Destructor. */ - virtual ~ServiceFactory(); + ~ServiceFactory() override; /** * Get the name of this service type. Reimplemented by subclasses. * @return The name. */ virtual QString name() = 0; /** * Get a KConfigGroup object containing the config for this type of service. Reimplemented by subclasses. * @return */ virtual KConfigGroup config() = 0; /** * Get a best guess if a service of the type generated by this factory will be likely to be able to provide tracks * for a given url. This is needed in order to allow on.demand loading of service plugins to handle a url. Reimplemented by subclasses. * @param url The url to test. * @return A bool representing whether the ServiceFactory believes that a service of this kind can process the given url. */ bool possiblyContainsTrack( const QUrl &url ) const override { Q_UNUSED( url ); return false; } /** * Attempt to create a Meta::Track object from a given url. This method is meant as a proxy that will forward this call to one or more * services managed by this factory. If init has not been called ( no services of this kind has been loaded ) they can now be loaded on * demand. * @param url The url to test. * @return A Meta::TrackPtr based one the url, or empty if nothing was known about the url. */ Meta::TrackPtr trackForUrl( const QUrl &url ) override; /** * Clear the list of active services created by this factory. Used when unloading services. */ void clearActiveServices(); QList activeServices() { return m_activeServices.toList(); } public Q_SLOTS: /** * The service is ready! */ void slotServiceReady(); Q_SIGNALS: /** * This signal is emitted whenever a new service has been loaded. * @param newService The service that has been loaded. */ void newService( ServiceBase *newService ); /** * This signal is emitted whenever a service is removed. ServiceFactory deletes * the service in next event loop iteration. * * @param removedService The service that has been removed */ void removeService( ServiceBase *removedService ); private Q_SLOTS: void slotNewService( ServiceBase *newService ); void slotRemoveService( ServiceBase *service ); private: QSet m_activeServices; QQueue m_tracksToLocate; }; /** A composite widget used as a base for building service browsers. It contains a home button ( to return to the list of services ), a name label, a tree view, grouping and filtering widgets and other conveniences that handle much of the layout of a new service. Some of these items can be shown or hidden as needed. @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT ServiceBase : public BrowserCategory { Q_OBJECT public: /** * Constructor. */ ServiceBase( const QString &name, ServiceFactory* parent, bool useCollectionTreeView = true, const QString &m_prettyName = QString() ); /** * Destructor. */ - ~ServiceBase(); + ~ServiceBase() override; /** * Set the SingleCollectionTreeItemModel that will be used to populate the tree view. * @param model The model. */ void setModel( QAbstractItemModel * model ); /** * Get the model that is used for displaying items in the tree view. * @return The model. */ QAbstractItemModel * model(); /** * Set the SingleCollectionTreeItemModel that will be used to populate the tree view. * @param model The model. */ void setView( QTreeView * model ); /** * Get the model that is used for displaying items in the tree view. * @return The model. */ QTreeView * view(); /** * Set if it should be possible to add the tracks shown in the tree view to the playlist. This method is a bit of a hack and might be removed! * @param playable Are tracks playable. */ void setPlayableTracks( bool playable ); /** * Set the info parser that will be used to show information about selected items in the service info context applet. * @param infoParser The info parser to use. */ void setInfoParser( InfoParserBase * infoParser ); /** * Get the info parser used to show information about selected items in the service info context applet. * @return The info parser. */ InfoParserBase * infoParser(); /** * Return the Collection used by this service. * @return The collection. */ virtual Collections::Collection * collection() = 0; /** * Do expensive initialization. This method is called when the service is first shown. */ void polish() override = 0; /** * ?????? * @return */ virtual bool updateContextView() { return false; } /** * Apply a filter to the tree view. * @param filter The filter to apply. */ void setFilter( const QString &filter ) override; /** * Returns a list of the messages that the current service accepts. Default implementation does not * accept any. * @return A string containing a description of accepted messages. */ virtual QString messages(); /** * Send a message to this service. Default implementation returns an error as no messages are * accepted * @param message The message to send to the service * @return The reply to the message */ virtual QString sendMessage( const QString &message ); /** * Returns whether the service is ready or not. * @return true if the status is ready, false if it is not ready */ bool serviceReady() const; //virtual void reset() = 0; /** * Returns the service's parent factory. * @return the service's Factory */ ServiceFactory* parent() const; QString filter() const override; QList levels() const override; public Q_SLOTS: //void treeViewSelectionChanged( const QItemSelection & selected ); /** * New info should be shown in the service info applet ( if present ). * @param infoHtml The html formatted info to show. */ void infoChanged ( const QString &infoHtml ); /** * Set sorting in the tree view to be "Artist-Album". */ void sortByArtistAlbum(); /** * Set sorting in the tree view to be "Artist". */ void sortByArtist(); /** * Set sorting in the tree view to be "Album". */ void sortByAlbum(); /** * Set sorting in the tree view to be "Genre-Artist". */ void sortByGenreArtist(); /** * Set sorting in the tree view to be "Genre-Artist-Album". */ void sortByGenreArtistAlbum(); void setLevels( const QList &levels ) override; Q_SIGNALS: /** * Signal emitted when the service wants to be hidden and the service browser list shown instead, for instance when the "Home" button is clicked. */ void home(); /** * Signal emitted when the selection in the tree view has changed ( and is only a single item ). * @param item The selected item */ void selectionChanged( CollectionTreeItem *item ); /** * Signal emitted when the service is ready to be used. You don't need to Q_EMIT this * manually, just call setServiceReady() as appropriate. */ void ready(); protected Q_SLOTS: /** * Slot called when an item in the tree view has been activated * @param index The index of the activated item */ void itemActivated ( const QModelIndex & index ); /** * Slot called when the selection in the tree view has changed ( and is only a single item ). * @param item The selected item */ void itemSelected( CollectionTreeItem * item ); protected: /** * Generate info to show in the service info applet. useful for showing initial info before any items are selected and hence * trigger the info parser. * @param html */ virtual void generateWidgetInfo( const QString &html = QString() ) const; /** * sets serviceReady() and emits a signal ready() as appropriate. */ void setServiceReady( bool ready ); static ServiceBase *s_instance; QTreeView *m_contentView; ServiceFactory *m_parentFactory; BoxWidget *m_topPanel; BoxWidget *m_bottomPanel; bool m_polished; bool m_useCollectionTreeView; QList m_urlsToInsert; InfoParserBase * m_infoParser; QMenuBar *m_menubar; QMenu *m_filterMenu; SearchWidget * m_searchWidget; //void addToPlaylist( CollectionTreeItem * item ); private: // need to move stuff here bool m_serviceready; QAbstractItemModel *m_model; QSortFilterProxyModel *m_filterModel; }; #endif diff --git a/src/services/ServiceCapabilities.h b/src/services/ServiceCapabilities.h index cd11a7b0aa..db0c3e8576 100644 --- a/src/services/ServiceCapabilities.h +++ b/src/services/ServiceCapabilities.h @@ -1,111 +1,111 @@ /**************************************************************************************** * Copyright (c) 2010 Nikolaj Hald Nielsen * * * * 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 SERVICECAPABILITIES_H #define SERVICECAPABILITIES_H #include "amarok_export.h" #include "amarokurls/AmarokUrl.h" #include "core/capabilities/BookmarkThisCapability.h" #include "core/capabilities/ActionsCapability.h" #include "core/capabilities/FindInSourceCapability.h" #include "core/capabilities/SourceInfoCapability.h" class BookmarkThisProvider; class ActionsProvider; class SourceInfoProvider; namespace Meta { class ServiceTrack; } /** A service specific implementation of the BookmarkThisCapability @author Nikolaj Hald Nielsen */ class AMAROK_EXPORT ServiceBookmarkThisCapability : public Capabilities::BookmarkThisCapability { public: explicit ServiceBookmarkThisCapability( BookmarkThisProvider * provider ); - ~ServiceBookmarkThisCapability(); + ~ServiceBookmarkThisCapability() override; bool isBookmarkable() override; QString browserName() override; QString collectionName() override; bool simpleFiltering() override; QAction * bookmarkAction() const override; private: BookmarkThisProvider * m_provider; }; class AMAROK_EXPORT ServiceActionsCapability : public Capabilities::ActionsCapability { Q_OBJECT public: explicit ServiceActionsCapability( ActionsProvider * actionsProvider ); - virtual ~ServiceActionsCapability(); + ~ServiceActionsCapability() override; QList< QAction * > actions() const override; private: ActionsProvider * m_actionsProvider; }; class AMAROK_EXPORT ServiceSourceInfoCapability : public Capabilities::SourceInfoCapability { public: explicit ServiceSourceInfoCapability( SourceInfoProvider * sourceInfoProvider ); - ~ServiceSourceInfoCapability(); + ~ServiceSourceInfoCapability() override; QString sourceName() override; QString sourceDescription() override; QPixmap emblem() override; QString scalableEmblem() override; private: SourceInfoProvider * m_sourceInfoProvider; }; class AMAROK_EXPORT ServiceFindInSourceCapability : public Capabilities::FindInSourceCapability { Q_OBJECT public: explicit ServiceFindInSourceCapability( Meta::ServiceTrack *track ); void findInSource( QFlags tag ) override; private: Meta::ServiceTrack * m_track; }; #endif // SERVICECAPABILITIES_H diff --git a/src/services/ServiceCollection.h b/src/services/ServiceCollection.h index d39cace897..38aff772b3 100644 --- a/src/services/ServiceCollection.h +++ b/src/services/ServiceCollection.h @@ -1,116 +1,116 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Nikolaj Hald Nielsen * * Copyright (c) 2008 Casey Link * * * * 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 SERVICECOLLECTION_H #define SERVICECOLLECTION_H #include "amarok_export.h" #include "core/collections/Collection.h" #include "core-impl/collections/support/MemoryCollection.h" #include "ServiceBase.h" #include #include #include typedef QMap TrackIdMap; typedef QMap ArtistIdMap; typedef QMap AlbumIdMap; typedef QMap GenreIdMap; namespace Collections { /** * This is a specialized collection that can be used by services who dynamically * fetch their data from somewhere ( a web service, an external program, etc....) */ class AMAROK_EXPORT ServiceCollection : public Collections::Collection { Q_OBJECT public: explicit ServiceCollection( ServiceBase * service = 0 ); ServiceCollection( ServiceBase * service, const QString &id, const QString &prettyName ); - virtual ~ServiceCollection(); + ~ServiceCollection() override; Collections::QueryMaker* queryMaker() override; QString collectionId() const override; QString prettyName() const override; QIcon icon() const override { return QIcon::fromTheme(QStringLiteral("action-view-services-scripted-amarok")); } CollectionLocation* location() override; void emitUpdated(); virtual QStringList query( const QString &query ) { Q_UNUSED( query ); return QStringList(); } virtual int insert( const QString &statement, const QString &table ) { Q_UNUSED( statement ); Q_UNUSED( table ); return 0; } virtual QString escape( const QString &text ) const { Q_UNUSED( text ); return QString(); } Meta::TrackPtr trackById( int id ); Meta::AlbumPtr albumById( int id ); Meta::ArtistPtr artistById( int id ); Meta::GenrePtr genreById( int id ); //Override some stuff to be able to handle id mappings void addTrack( const Meta::TrackPtr &trackPtr ); void addArtist( const Meta::ArtistPtr &artistPtr ); void addAlbum( const Meta::AlbumPtr &albumPtr ); void addGenre( const Meta::GenrePtr &genrePtr ); //TODO: //void setTrackMap( TrackMap map ) { m_trackMap = map; } //void setArtistMap( ArtistMap map ) { m_artistMap = map; } //void setAlbumMap( AlbumMap map ) { m_albumMap = map; } //void setGenreMap( GenreMap map ) { m_genreMap = map; } ServiceBase * service(); //convenience functions for subclasses void acquireWriteLock() { m_mc->acquireWriteLock(); } void acquireReadLock() { m_mc->acquireReadLock(); } void releaseLock() { m_mc->releaseLock(); } GenreMap genreMap() const { return m_mc->genreMap(); } void setGenreMap( const GenreMap &map ) { m_mc->setGenreMap( map ); } ArtistMap artistMap() const { return m_mc->artistMap(); } void setArtistMap( const ArtistMap &map ) { m_mc->setArtistMap( map ); } TrackMap trackMap() const { return m_mc->trackMap(); } void setTrackMap( const TrackMap &map ) { m_mc->setTrackMap( map ); } AlbumMap albumMap() const { return m_mc->albumMap(); } void setAlbumMap( const AlbumMap &map ) { m_mc->setAlbumMap( map ); } private: ServiceBase * m_service; QSharedPointer m_mc; QString m_collectionId; QString m_prettyName; TrackIdMap m_trackIdMap; ArtistIdMap m_artistIdMap; AlbumIdMap m_albumIdMap; GenreIdMap m_genreIdMap; }; } //namespace Collections #endif diff --git a/src/services/ServiceCollectionLocation.h b/src/services/ServiceCollectionLocation.h index 3f64cd84db..0e25587376 100644 --- a/src/services/ServiceCollectionLocation.h +++ b/src/services/ServiceCollectionLocation.h @@ -1,52 +1,52 @@ /**************************************************************************************** * Copyright (c) 2008 Casey Link * * * * 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_SERVICECOLLECTIONLOCATION_H #define AMAROK_SERVICECOLLECTIONLOCATION_H #include "core/collections/CollectionLocation.h" #include "amarok_export.h" #include "ServiceCollection.h" #include #include #include namespace Collections { class AMAROK_EXPORT ServiceCollectionLocation : public CollectionLocation { Q_OBJECT public: ServiceCollectionLocation(); explicit ServiceCollectionLocation( ServiceCollection *parentCollection ); - virtual ~ServiceCollectionLocation(); + ~ServiceCollectionLocation() override; void getKIOCopyableUrls( const Meta::TrackList &tracks ) override; //These are service dependent QString prettyLocation() const override; bool isWritable() const override; bool isOrganizable() const override; private: ServiceCollection *m_collection; //parent collection bool m_removeSources; //used by the destination to remember the value, needed in copyurlsToCollection bool m_overwriteFiles; }; } //namespace Collections #endif diff --git a/src/services/ServiceCollectionTreeView.h b/src/services/ServiceCollectionTreeView.h index 73b440d460..12bc4c9919 100644 --- a/src/services/ServiceCollectionTreeView.h +++ b/src/services/ServiceCollectionTreeView.h @@ -1,48 +1,48 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 SERVICECOLLECTIONTREEVIEW_H #define SERVICECOLLECTIONTREEVIEW_H #include "browsers/CollectionTreeView.h" /** A simple extension of the CollectionTreeView class that allows optional support for specifying that tracks are not playable and thus should not be added to the playlist on activation and does not have the add and load options in the context menu. @author Nikolaj Hald Nielsen */ class ServiceCollectionTreeView : public CollectionTreeView { public: explicit ServiceCollectionTreeView( QWidget *parent = nullptr ); - ~ServiceCollectionTreeView(); + ~ServiceCollectionTreeView() override; void setPlayableTracks( bool playable ); bool playableTracks() const; protected: void mouseDoubleClickEvent(QMouseEvent* event) override; void contextMenuEvent(QContextMenuEvent* event) override; private: bool m_playableTracks; }; #endif diff --git a/src/services/ServiceMetaBase.h b/src/services/ServiceMetaBase.h index 59f2d3e7c3..3803146180 100644 --- a/src/services/ServiceMetaBase.h +++ b/src/services/ServiceMetaBase.h @@ -1,562 +1,562 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 SERVICEMETABASE_H #define SERVICEMETABASE_H #include "amarok_export.h" #include "amarokurls/BookmarkMetaActions.h" #include "core/support/Debug.h" #include "InfoParserBase.h" #include "core-impl/meta/proxy/MetaProxy.h" #include "ServiceCapabilities.h" #include #include #include namespace Amarok { } class AMAROK_EXPORT ServiceMetaFactory { public: explicit ServiceMetaFactory( const QString &dbPrefix ); virtual ~ServiceMetaFactory() {} QString tablePrefix() const; virtual int getTrackSqlRowCount(); virtual QString getTrackSqlRows(); virtual Meta::TrackPtr createTrack( const QStringList &rows ); virtual int getAlbumSqlRowCount(); virtual QString getAlbumSqlRows(); virtual Meta::AlbumPtr createAlbum( const QStringList &rows ); virtual int getArtistSqlRowCount(); virtual QString getArtistSqlRows(); virtual Meta::ArtistPtr createArtist( const QStringList &rows ); virtual int getGenreSqlRowCount(); virtual QString getGenreSqlRows(); virtual Meta::GenrePtr createGenre( const QStringList &rows ); private: QString m_dbTablePrefix; }; class AMAROK_EXPORT ServiceDisplayInfoProvider { public: ServiceDisplayInfoProvider() {} virtual ~ServiceDisplayInfoProvider() {} virtual void processInfoOf( InfoParserBase * infoParser ) = 0; }; class AMAROK_EXPORT ActionsProvider { public: ActionsProvider() {} virtual ~ActionsProvider() {} virtual QList< QAction *> actions() { DEBUG_BLOCK return QList< QAction *>(); } }; class AMAROK_EXPORT SourceInfoProvider { public: SourceInfoProvider() {} virtual ~SourceInfoProvider() {} virtual QString sourceName() { return QString(); } virtual QString sourceDescription() { return QString(); } virtual QPixmap emblem() { return QPixmap(); } virtual QString scalableEmblem() { return QString(); } virtual bool hasSourceInfo() const { return true; } }; class AMAROK_EXPORT BookmarkThisProvider : public QObject { Q_OBJECT public: BookmarkThisProvider() : QObject() {} - virtual ~BookmarkThisProvider() {} + ~BookmarkThisProvider() override {} virtual bool isBookmarkable() const { return false; } virtual QString browserName() const { return QStringLiteral("internet"); } virtual QString collectionName() const { return QString(); } virtual bool simpleFiltering() const { return true; } virtual QAction * bookmarkAction() { return 0; } protected: QPointer m_bookmarkAction; }; namespace Meta { class ServiceTrack; class ServiceAlbum; class ServiceArtist; class ServiceGenre; class ServiceComposer; class ServiceYear; typedef AmarokSharedPointer ServiceTrackPtr; typedef AmarokSharedPointer ServiceArtistPtr; typedef AmarokSharedPointer ServiceAlbumPtr; typedef AmarokSharedPointer ServiceGenrePtr; typedef AmarokSharedPointer ServiceComposerPtr; typedef AmarokSharedPointer ServiceYearPtr; typedef QList ServiceTrackList; typedef QList ServiceArtistList; typedef QList ServiceAlbumList; typedef QList ServiceComposerList; typedef QList ServiceGenreList; typedef QList ServiceYearList; class AMAROK_EXPORT ServiceTrack : public Meta::Track, public ServiceDisplayInfoProvider, public ActionsProvider, public SourceInfoProvider, public BookmarkThisProvider { public: //Give this a displayable name as some services has terrible names for their streams //ServiceTrack( const QString & name ); explicit ServiceTrack( const QString & name ); //create track based on an sql query result explicit ServiceTrack( const QStringList & resultRow ); - virtual ~ServiceTrack(); + ~ServiceTrack() override; QString name() const override; virtual QUrl downloadableUrl() const; QUrl playableUrl() const override; QString uidUrl() const override; QString prettyUrl() const override; QString notPlayableReason() const override; AlbumPtr album() const override; virtual void setAlbum( const QString &newAlbum ); ArtistPtr artist() const override; virtual void setArtist( const QString &newArtist ); GenrePtr genre() const override; virtual void setGenre( const QString &newGenre ); ComposerPtr composer() const override; virtual void setComposer( const QString &newComposer ); YearPtr year() const override; virtual void setYear( int newYear ); virtual void setTitle( const QString &newTitle ); qreal bpm() const override; QString comment() const override; virtual void setComment( const QString &newComment ); virtual QString description() const; virtual void setDescription( const QString &newDescription ); qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; int trackNumber() const override; virtual void setTrackNumber( int newTrackNumber ); int discNumber() const override; virtual void setDiscNumber( int newDiscNumber ); QString type() const override; void processInfoOf( InfoParserBase * infoParser ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::Actions ) || ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) || ( type == Capabilities::Capability::BookmarkThis ) || ( type == Capabilities::Capability::FindInSource && isBookmarkable() ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::Actions ) return new ServiceActionsCapability( this ); else if ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) return new ServiceSourceInfoCapability( this ); else if ( type == Capabilities::Capability::BookmarkThis ) return new ServiceBookmarkThisCapability( this ); else if ( type == Capabilities::Capability::FindInSource && isBookmarkable() ) return new ServiceFindInSourceCapability( this ); return 0; } StatisticsPtr statistics() override; //ServiceTrack specific methods virtual void setAlbumPtr( const Meta::AlbumPtr &album ); void setArtist( const Meta::ArtistPtr &artist ); void setComposer( const Meta::ComposerPtr &composer ); void setGenre( const Meta::GenrePtr &genre ); void setYear( const Meta::YearPtr &year ); void setStatisticsProvider( const Meta::StatisticsPtr &provider ); void setLength( qint64 length ); void setId( int id ); int id( ) const; void setAlbumId( int albumId ); int albumId() const; void setArtistId( int id ); int artistId() const; virtual void setUidUrl( const QString &url ); void setDownloadableUrl( const QString &url ); private: Meta::StatisticsPtr m_statsStore; ArtistPtr m_artist; AlbumPtr m_album; GenrePtr m_genre; ComposerPtr m_composer; YearPtr m_year; int m_id; int m_trackNumber; qint64 m_length; QString m_description; QString m_displayUrl; QString m_playableUrl; QString m_downloadableUrl; int m_albumId; QString m_albumName; int m_artistId; QString m_artistName; QString m_name; }; class AMAROK_EXPORT ServiceArtist : public Meta::Artist, public ServiceDisplayInfoProvider, public ActionsProvider, public SourceInfoProvider, public BookmarkThisProvider { public: explicit ServiceArtist( const QStringList & resultRow ); explicit ServiceArtist( const QString & name ); - virtual ~ServiceArtist(); + ~ServiceArtist() override; QString name() const override; TrackList tracks() override; void processInfoOf( InfoParserBase * infoParser ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::Actions ) || ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) || ( type == Capabilities::Capability::BookmarkThis ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::Actions ) return new ServiceActionsCapability( this ); else if ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) return new ServiceSourceInfoCapability( this ); else if ( type == Capabilities::Capability::BookmarkThis ) return new ServiceBookmarkThisCapability( this ); return 0; } QAction * bookmarkAction() override { if ( isBookmarkable() ) { if ( m_bookmarkAction.isNull()) m_bookmarkAction = QPointer( new BookmarkArtistAction( this, ArtistPtr( this ) ) ); return m_bookmarkAction.data(); } else return 0; } //ServiceArtist specific methods void addTrack( const TrackPtr &track ); void setDescription( const QString &description ); QString description( ) const; void setId( int id ); int id( ) const; void setTitle( const QString &title ); void setSourceName( const QString &source ) { m_sourceName = source; } QString sourceName() override { return m_sourceName; } private: int m_id; QString m_name; QString m_description; TrackList m_tracks; QString m_sourceName; }; class AMAROK_EXPORT ServiceAlbum : public Meta::Album, public ServiceDisplayInfoProvider, public ActionsProvider, public SourceInfoProvider, public BookmarkThisProvider { public: explicit ServiceAlbum( const QStringList & resultRow ); explicit ServiceAlbum( const QString & name ); - virtual ~ServiceAlbum(); + ~ServiceAlbum() override; QString name() const override; bool isCompilation() const override; bool canUpdateCompilation() const override; void setCompilation( bool compilation ) override; bool hasAlbumArtist() const override; ArtistPtr albumArtist() const override; TrackList tracks() override; void processInfoOf( InfoParserBase * infoParser ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::Actions ) || ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) || ( type == Capabilities::Capability::BookmarkThis ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::Actions ) return new ServiceActionsCapability( this ); else if ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) return new ServiceSourceInfoCapability( this ); else if ( type == Capabilities::Capability::BookmarkThis ) return new ServiceBookmarkThisCapability( this ); return 0; } QAction * bookmarkAction() override { if ( isBookmarkable() ) { if ( m_bookmarkAction.isNull()) m_bookmarkAction = QPointer( new BookmarkAlbumAction( this, AlbumPtr( this ) ) ); return m_bookmarkAction.data(); } else return 0; } //ServiceAlbum specific methods void addTrack( const TrackPtr &track ); void setAlbumArtist( const ArtistPtr &artist ); void setDescription( const QString &description ); QString description( ) const; void setId( int id ); int id() const; void setArtistId( int artistId ); int artistId( ) const; void setArtistName( const QString &name ); QString artistName() const; void setTitle( const QString &title ); void setSourceName( const QString &source ) { m_sourceName = source; } QString sourceName() override { return m_sourceName; } private: int m_id; QString m_name; TrackList m_tracks; bool m_isCompilation; ArtistPtr m_albumArtist; QString m_description; int m_artistId; QString m_artistName; QString m_sourceName; }; class AMAROK_EXPORT ServiceGenre : public Meta::Genre, public ServiceDisplayInfoProvider, public ActionsProvider, public SourceInfoProvider, public BookmarkThisProvider { public: explicit ServiceGenre( const QString &name ); explicit ServiceGenre( const QStringList &row ); - virtual ~ServiceGenre(); + ~ServiceGenre() override; QString name() const override; TrackList tracks() override; void processInfoOf( InfoParserBase * infoParser ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::Actions ) || ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) || ( type == Capabilities::Capability::BookmarkThis ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::Actions ) return new ServiceActionsCapability( this ); else if ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) return new ServiceSourceInfoCapability( this ); else if ( type == Capabilities::Capability::BookmarkThis ) return new ServiceBookmarkThisCapability( this ); return 0; } //ServiceGenre specific methods void setId( int id ); int id() const; void addTrack( const TrackPtr &track ); int albumId(); void setAlbumId( int albumId ); void setSourceName( const QString &source ) { m_sourceName = source; } QString sourceName() override { return m_sourceName; } private: int m_id; int m_albumId; QString m_name; TrackList m_tracks; QString m_sourceName; }; class AMAROK_EXPORT ServiceComposer : public Meta::Composer, public ServiceDisplayInfoProvider, public ActionsProvider, public SourceInfoProvider, public BookmarkThisProvider { public: explicit ServiceComposer( const QString &name ); ~ServiceComposer() override; QString name() const override; TrackList tracks() override; void processInfoOf( InfoParserBase * infoParser ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::Actions ) || ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) || ( type == Capabilities::Capability::BookmarkThis ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::Actions ) return new ServiceActionsCapability( this ); else if ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) return new ServiceSourceInfoCapability( this ); else if ( type == Capabilities::Capability::BookmarkThis ) return new ServiceBookmarkThisCapability( this ); return 0; } //ServiceComposer specific methods void addTrack( const ServiceTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; class AMAROK_EXPORT ServiceYear : public Meta::Year, public ServiceDisplayInfoProvider, public ActionsProvider, public SourceInfoProvider, public BookmarkThisProvider { public: explicit ServiceYear( const QString &name ); - virtual ~ServiceYear(); + ~ServiceYear() override; QString name() const override; TrackList tracks() override; void processInfoOf( InfoParserBase * infoParser ) override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::Actions ) || ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) || ( type == Capabilities::Capability::BookmarkThis ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::Actions ) return new ServiceActionsCapability( this ); else if ( type == Capabilities::Capability::SourceInfo && hasSourceInfo() ) return new ServiceSourceInfoCapability( this ); else if ( type == Capabilities::Capability::BookmarkThis ) return new ServiceBookmarkThisCapability( this ); return 0; } //ServiceYear specific methods void addTrack( const ServiceTrackPtr &track ); private: QString m_name; TrackList m_tracks; }; } #endif diff --git a/src/services/ServicePluginManager.h b/src/services/ServicePluginManager.h index 537057f460..f1dbd2dd5e 100644 --- a/src/services/ServicePluginManager.h +++ b/src/services/ServicePluginManager.h @@ -1,74 +1,74 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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_SERVICEPLUGINMANAGER_H #define AMAROK_SERVICEPLUGINMANAGER_H #include #include #include class ServiceBase; namespace Plugins { class PluginFactory; } /** A class to keep track of available service plugins and load them as needed * * @author */ class ServicePluginManager : public QObject { Q_OBJECT public: static ServicePluginManager *instance(); static void destroy(); /** * Load any services that are configured to be loaded. * Unload any services that have been switched off. */ void setFactories( const QList > &factories ); public Q_SLOTS: QStringList loadedServices() const; QStringList loadedServiceNames() const; QString serviceDescription( const QString &service ); QString serviceMessages( const QString &service ); QString sendMessage( const QString &service, const QString &message ); private: static ServicePluginManager* s_instance; ServicePluginManager(); - ~ServicePluginManager(); + ~ServicePluginManager() override; Q_DISABLE_COPY( ServicePluginManager ) /** The list of currently set factories. * Note: the PluginManager owns the pointers. */ QList > m_factories; private Q_SLOTS: void slotNewService( ServiceBase *newService); void slotRemoveService( ServiceBase *removedService ); }; #endif //AMAROK_SERVICEPLUGINMANAGER_H diff --git a/src/services/ServiceSqlCollection.h b/src/services/ServiceSqlCollection.h index 7ac1f802e4..9b5985ed94 100644 --- a/src/services/ServiceSqlCollection.h +++ b/src/services/ServiceSqlCollection.h @@ -1,63 +1,63 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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_SERVICESQLCOLLECTION_H #define AMAROK_SERVICESQLCOLLECTION_H #include "amarok_export.h" #include "ServiceCollection.h" #include "ServiceMetaBase.h" #include "ServiceSqlRegistry.h" namespace Collections { class AMAROK_EXPORT ServiceSqlCollection : public ServiceCollection { Q_OBJECT public: ServiceSqlCollection( const QString &id, const QString &prettyName, ServiceMetaFactory * metaFactory, ServiceSqlRegistry * registry ); - virtual ~ServiceSqlCollection(); + ~ServiceSqlCollection() override; virtual void startFullScan() {} //TODO QueryMaker* queryMaker() override; QString collectionId() const override; QString prettyName() const override; QStringList query( const QString &query ) override; int insert( const QString &statement, const QString &table ) override; QString escape( const QString &text ) const override; void emitUpdated() { Q_EMIT( updated() ); } Meta::TrackPtr trackForUrl( const QUrl &url ) override; bool possiblyContainsTrack( const QUrl &url ) const override; private: ServiceMetaFactory * m_metaFactory; ServiceSqlRegistry * m_registry; QString m_collectionId; QString m_prettyName; }; } //namespace Collections #endif /* AMAROK_COLLECTION_SQLCOLLECTION_H */ diff --git a/src/services/ServiceSqlQueryMaker.h b/src/services/ServiceSqlQueryMaker.h index ad9f1b8f23..9b3fe84c3c 100644 --- a/src/services/ServiceSqlQueryMaker.h +++ b/src/services/ServiceSqlQueryMaker.h @@ -1,112 +1,112 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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_SERVICESQLQUERYMAKER_H #define AMAROK_SERVICESQLQUERYMAKER_H #include "ServiceMetaBase.h" #include "ServiceSqlRegistry.h" #include "core/collections/QueryMaker.h" #include #include #include #include namespace Collections { class ServiceSqlCollection; class ServiceSqlQueryMaker : public QueryMaker { Q_OBJECT public: ServiceSqlQueryMaker( ServiceSqlCollection* collection, ServiceMetaFactory * metaFactory, ServiceSqlRegistry * registry ); - virtual ~ServiceSqlQueryMaker(); + ~ServiceSqlQueryMaker() override; void abortQuery() override; void run() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::YearPtr &year ) override; QueryMaker* addMatch( const Meta::LabelPtr &label ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; QueryMaker* addReturnValue( qint64 value ) override; QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; QueryMaker* orderBy( qint64 value, bool descending = false ) override; QueryMaker* limitMaxResultSize( int size ) override; QueryMaker* beginAnd() override; QueryMaker* beginOr() override; QueryMaker* endAndOr() override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; QString query(); QStringList runQuery( const QString &query ); void handleResult( const QStringList &result ); protected: virtual QString escape( const QString &text ) const; virtual QString likeCondition( const QString &text, bool anyBegin, bool anyEnd ) const; public Q_SLOTS: void done( ThreadWeaver::JobPointer job ); private: template void emitProperResult( const ListType& list ); void linkTables(); void buildQuery(); bool isValidValue( qint64 value ); QString nameForValue( qint64 value ); QString andOr() const; void handleTracks( const QStringList &result ); void handleArtists( const QStringList &result ); void handleAlbums( const QStringList &result ); void handleGenres( const QStringList &result ); //void handleComposers( const QStringList &result ); //void handleYears( const QStringList &result ); ServiceSqlCollection *m_collection; ServiceSqlRegistry * m_registry; ServiceMetaFactory * m_metaFactory; struct Private; Private * const d; }; } //namespace Collections #endif /* AMAROK_COLLECTION_SQLQUERYBUILDER_H */ diff --git a/src/services/ServiceSqlRegistry.h b/src/services/ServiceSqlRegistry.h index 208341b711..9384671c88 100644 --- a/src/services/ServiceSqlRegistry.h +++ b/src/services/ServiceSqlRegistry.h @@ -1,77 +1,77 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * * * 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 SERVICESQLREGISTRY_H #define SERVICESQLREGISTRY_H //#include "ServiceSqlCollection.h" #include "amarok_export.h" #include "ServiceMetaBase.h" #include #include #include #include #include #include class SqlCollection; typedef QPair TrackId; class AMAROK_EXPORT ServiceSqlRegistry : public QObject { Q_OBJECT public: explicit ServiceSqlRegistry( ServiceMetaFactory * metaFactory ); - virtual ~ServiceSqlRegistry(); + ~ServiceSqlRegistry() override; void setMetaFactory( ServiceMetaFactory * metaFactory ); ServiceMetaFactory * factory(); //TrackPtr getTrack( const QString &url ); Meta::TrackPtr getTrack( const QStringList &rowData ); Meta::ArtistPtr getArtist( const QStringList &rowData ); Meta::GenrePtr getGenre( const QStringList &rowData ); // ComposerPtr getComposer( const QString &name, int id = -1 ); // YearPtr getYear( const QString &year, int id = -1 ); Meta::AlbumPtr getAlbum( const QStringList &rowData ); //TODO fix this private: //we don't care about the ordering so use the faster QHash QHash m_trackMap; QHash m_artistMap; QHash m_composerMap; QHash m_genreMap; QHash m_yearMap; QHash m_albumMap; //TODO: needs improvement QMutex m_trackMutex; QMutex m_artistMutex; QMutex m_composerMutex; QMutex m_genreMutex; QMutex m_yearMutex; QMutex m_albumMutex; QTimer *m_timer; //ServiceSqlCollection *m_collection; ServiceMetaFactory * m_metaFactory; }; #endif /* SERVICESQLREGISTRY_H */ diff --git a/src/services/ampache/AddServerDialog.h b/src/services/ampache/AddServerDialog.h index 3dde04f506..be1c87142e 100644 --- a/src/services/ampache/AddServerDialog.h +++ b/src/services/ampache/AddServerDialog.h @@ -1,51 +1,51 @@ /**************************************************************************************** * Copyright (c) 2010 Ian Monroe * * * 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 ADDSERVERDIALOG_H #define ADDSERVERDIALOG_H #include #include namespace Ui { class NewServerWidget; } class AmpacheAccountLogin; class AddServerDialog : public QDialog { Q_OBJECT public: AddServerDialog(); - ~AddServerDialog(); + ~AddServerDialog() override; QString name(); QString password(); QString username(); QUrl url(); private Q_SLOTS: void anyTextEdited(); void verifyData(); void loginResult(); private: Ui::NewServerWidget* m_widgets; QPointer m_login; }; #endif // ADDSERVERDIALOG_H diff --git a/src/services/ampache/AmpacheAccountLogin.h b/src/services/ampache/AmpacheAccountLogin.h index b5b1dfa95d..b5c8f562aa 100644 --- a/src/services/ampache/AmpacheAccountLogin.h +++ b/src/services/ampache/AmpacheAccountLogin.h @@ -1,81 +1,81 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * (c) 2010 Ian Monroe * * (c) 2013 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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 AMPACHEACCOUNTLOGIN_H #define AMPACHEACCOUNTLOGIN_H #include "NetworkAccessManagerProxy.h" #include #include #include class QNetworkReply; #ifdef MAKE_AMPACHE_ACCOUNT_LOGIN_LIB #define AMPACHE_ACCOUNT_EXPORT Q_DECL_EXPORT #else #define AMPACHE_ACCOUNT_EXPORT Q_DECL_IMPORT #endif class AMPACHE_ACCOUNT_EXPORT AmpacheAccountLogin : public QObject { Q_OBJECT public: AmpacheAccountLogin ( const QUrl& url, const QString& username, const QString& password, QWidget* parent = nullptr ); - ~AmpacheAccountLogin(); + ~AmpacheAccountLogin() override; QUrl server() const { return m_server; } QString sessionId() const { return m_sessionId; } bool authenticated() const { return m_authenticated; } void reauthenticate(); Q_SIGNALS: void loginSuccessful(); //!authentication was successful void finished(); //!authentication was or was not successful private Q_SLOTS: void authenticate( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void authenticationComplete( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); private: int getVersion( const QDomDocument& doc ) const; /** Does general response verification. Emits finished if something is fishy. @returns true if the check was successful. */ bool generalVerify( QNetworkReply *reply, const QDomDocument& doc, const NetworkAccessManagerProxy::Error &e ); /** Returns the base url. You would need to add query items to use it. */ QUrl getRequestUrl( const QString &action = QString() ) const; bool m_authenticated; QUrl m_server; QString m_username; QString m_password; QString m_sessionId; QNetworkReply *m_authRequest; QNetworkReply *m_pingRequest; }; #endif // AMPACHEACCOUNTLOGIN_H diff --git a/src/services/ampache/AmpacheMeta.h b/src/services/ampache/AmpacheMeta.h index f9f2bab4ff..5e648a05cf 100644 --- a/src/services/ampache/AmpacheMeta.h +++ b/src/services/ampache/AmpacheMeta.h @@ -1,137 +1,137 @@ /**************************************************************************************** * Copyright (c) 2007 Casey Link * * Copyright (c) 2007 Nikolaj Hald Nielsen * * (c) 2013 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 AMPACHEMETA_H #define AMPACHEMETA_H #include "ServiceBase.h" #include "ServiceMetaBase.h" #include "ServiceAlbumCoverDownloader.h" #include #include #include #include #include #include namespace Meta { class AmpacheTrack : public ServiceTrack { public: explicit AmpacheTrack( const QString& title, ServiceBase * service = 0 ) : ServiceTrack( title ) , m_service( service ) , m_discNumber( 0 ) { Q_UNUSED(m_service); // might be used again later } QString sourceName() override { return "Ampache"; } QString sourceDescription() override { return "The Ampache music server project: http://Ampache.org"; } QPixmap emblem() override { return QPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/emblem-ampache.png" ) ); } QString scalableEmblem() override { return QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/emblem-ampache-scalable.svgz" ); } QString notPlayableReason() const override; int discNumber() const override { return m_discNumber; } void setDiscNumber( int newDiscNumber ) override { m_discNumber = newDiscNumber; } private: ServiceBase * m_service; int m_discNumber; }; class AmpacheAlbum : public ServiceAlbumWithCover { private: QString m_coverURL; public: explicit AmpacheAlbum( const QString &name ); explicit AmpacheAlbum( const QStringList &resultRow ); - ~AmpacheAlbum(); + ~AmpacheAlbum() override; QString downloadPrefix() const override { return "ampache"; } void setCoverUrl( const QString &coverURL ) override; QString coverUrl() const override; bool operator==( const Meta::Album &other ) const override { return name() == other.name(); } QList ids() const { return m_ampacheAlbums.keys(); } struct AmpacheAlbumInfo { int id; int discNumber; int year; }; /** Add an ampache album to this Amarok album. Warning: The album will not be automatically registered with the new id, same as with setId */ void addInfo( const AmpacheAlbumInfo &info ); /** Get's an album info for a specific ID */ AmpacheAlbumInfo getInfo( int id ) const; private: // the unique album key of ampache contains discNumber and year // the Amarok key only name and artist // so this AmpacheAlbum object represents a number of ampache albums. QHash m_ampacheAlbums; }; class AmpacheArtist : public ServiceArtist { private: QString m_coverURL; public: AmpacheArtist( const QString &name, ServiceBase * service ) : ServiceArtist( name ) , m_service( service ) {} bool isBookmarkable() const override { return true; } QString collectionName() const override { return m_service->name(); } bool simpleFiltering() const override { return true; } bool operator==( const Meta::Artist &other ) const override { return name() == other.name(); } private: ServiceBase * m_service; }; } #endif // End include guard diff --git a/src/services/ampache/AmpacheService.h b/src/services/ampache/AmpacheService.h index b166c2d7a0..b80491fa42 100644 --- a/src/services/ampache/AmpacheService.h +++ b/src/services/ampache/AmpacheService.h @@ -1,80 +1,80 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMPACHESERVICE_H #define AMPACHESERVICE_H #include "AmpacheServiceCollection.h" #include "ServiceBase.h" #include class AmpacheAccountLogin; class AmpacheServiceFactory: public ServiceFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_ampache.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: AmpacheServiceFactory(); - virtual ~AmpacheServiceFactory() {} + ~AmpacheServiceFactory() override {} bool possiblyContainsTrack( const QUrl &url ) const override; void init() override; QString name() override; KConfigGroup config() override; }; /** A service for displaying, previewing and downloading music from Ampache music servers @author */ class AmpacheService : public ServiceBase { Q_OBJECT public: explicit AmpacheService( AmpacheServiceFactory* parent, const QString &name, const QUrl &url = QUrl(), const QString &username = QString(), const QString &password = QString() ); - ~AmpacheService(); + ~AmpacheService() override; void polish() override; void reauthenticate(); Collections::Collection * collection() override { return m_collection; } private Q_SLOTS: void onLoginSuccessful(); private: InfoParserBase *m_infoParser; Collections::AmpacheServiceCollection * m_collection; QPointer m_ampacheLogin; // Disable copy constructor and assignment AmpacheService( const AmpacheService& ); AmpacheService& operator=( const AmpacheService& ); }; #endif diff --git a/src/services/ampache/AmpacheServiceCollection.h b/src/services/ampache/AmpacheServiceCollection.h index 6f9daa4efe..095f966da6 100644 --- a/src/services/ampache/AmpacheServiceCollection.h +++ b/src/services/ampache/AmpacheServiceCollection.h @@ -1,93 +1,93 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMPACHESERVICECOLLECTION_H #define AMPACHESERVICECOLLECTION_H #include #include "AmpacheMeta.h" #include "core/collections/support/TrackForUrlWorker.h" class AmpacheTrackForUrlWorker : public Amarok::TrackForUrlWorker { Q_OBJECT public: AmpacheTrackForUrlWorker( const QUrl &url, const MetaProxy::TrackPtr &track, const QUrl &server, const QString &sessionId, ServiceBase *service); - ~AmpacheTrackForUrlWorker(); + ~AmpacheTrackForUrlWorker() override; void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; void parseTrack( const QString &xml ); Q_SIGNALS: void authenticationNeeded(); private: MetaProxy::TrackPtr m_proxy; int m_urlTrackId; int m_urlAlbumId; int m_urlArtistId; Meta::AmpacheTrack *m_urlTrack; Meta::AmpacheAlbum *m_urlAlbum; Meta::ServiceArtist *m_urlArtist; QUrl m_server; QString m_sessionId; ServiceBase *m_service; }; namespace Collections { /** A collection that dynamically fetches data from a remote location as needed @author */ class AmpacheServiceCollection : public ServiceCollection { Q_OBJECT public: AmpacheServiceCollection( ServiceBase *service, const QUrl &server, const QString &sessionId ); - virtual ~AmpacheServiceCollection(); + ~AmpacheServiceCollection() override; QueryMaker *queryMaker() override; QString collectionId() const override; QString prettyName() const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; bool possiblyContainsTrack( const QUrl &url ) const override; Q_SIGNALS: void authenticationNeeded(); public Q_SLOTS: void slotAuthenticationNeeded(); void slotLookupComplete( const Meta::TrackPtr & ); private: QUrl m_server; QString m_sessionId; AmpacheTrackForUrlWorker *m_trackForUrlWorker; }; } //namespace Collections #endif diff --git a/src/services/ampache/AmpacheServiceQueryMaker.h b/src/services/ampache/AmpacheServiceQueryMaker.h index 10ec4f8c94..b46252a92a 100644 --- a/src/services/ampache/AmpacheServiceQueryMaker.h +++ b/src/services/ampache/AmpacheServiceQueryMaker.h @@ -1,92 +1,92 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMPACHESERVICEQUERYMAKER_H #define AMPACHESERVICEQUERYMAKER_H #include "DynamicServiceQueryMaker.h" #include "AmpacheServiceCollection.h" #include "AmpacheService.h" #include "NetworkAccessManagerProxy.h" #include namespace Collections { /** QueryMaker for Ampache Since Ampache only supports a very limited set of searches this query maker is very restricted. E.g. it does not support searches with AND and OR. TODO: support tags TODO: think about only using the MemoryQueryMaker */ class AmpacheServiceQueryMaker : public DynamicServiceQueryMaker { Q_OBJECT public: AmpacheServiceQueryMaker( AmpacheServiceCollection * collection, const QUrl &server, const QString &sessionId ); - ~AmpacheServiceQueryMaker(); + ~AmpacheServiceQueryMaker() override; void run() override; void abortQuery() override; QueryMaker* setQueryType( QueryType type ) override; using DynamicServiceQueryMaker::addMatch; QueryMaker* addMatch( const Meta::TrackPtr &track ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) override; QueryMaker* addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare ) override; int validFilterMask() override; QueryMaker* limitMaxResultSize( int size ) override; void fetchArtists(); void fetchAlbums(); void fetchTracks(); protected: struct Private; Private * const d; public Q_SLOTS: void artistDownloadComplete( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void albumDownloadComplete( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); void trackDownloadComplete( const QUrl &url, const QByteArray &data, const NetworkAccessManagerProxy::Error &e ); private: // Disable copy constructor and assignment AmpacheServiceQueryMaker( const AmpacheServiceQueryMaker& ); AmpacheServiceQueryMaker& operator= ( const AmpacheServiceQueryMaker& ); /** Gets the url for the ampache requests. Already adds query items for the dateFilter and the limit. */ QUrl getRequestUrl( const QString &action = QString() ) const; /* template void emitProperResult(const ListType& list); */ }; } //namespace Collections #endif diff --git a/src/services/ampache/AmpacheSettings.h b/src/services/ampache/AmpacheSettings.h index 89c14526eb..a0cbe9ff18 100644 --- a/src/services/ampache/AmpacheSettings.h +++ b/src/services/ampache/AmpacheSettings.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMPACHESETTINGS_H #define AMPACHESETTINGS_H #include "AmpacheConfig.h" #include namespace Ui { class AmpacheConfigWidget; } /** Class for handling settings for Ampache services @author */ class AmpacheSettings : public KCModule { Q_OBJECT public: explicit AmpacheSettings( QWidget *parent, const QVariantList &args ); - virtual ~AmpacheSettings(); + ~AmpacheSettings() override; void save() override; void load() override; void defaults() override; private: AmpacheConfig m_config; Ui::AmpacheConfigWidget * m_configDialog; void loadList(); int m_lastRowEdited; int m_lastColumnEdited; private Q_SLOTS: void add(); void remove(); void serverNameChanged(const QString & text); void onCellDoubleClicked(int row, int column); void saveCellEdit(int row, int column); }; #endif diff --git a/src/services/ampache/LastfmInfoParser.h b/src/services/ampache/LastfmInfoParser.h index 6b865f85c1..35ce0b28af 100644 --- a/src/services/ampache/LastfmInfoParser.h +++ b/src/services/ampache/LastfmInfoParser.h @@ -1,47 +1,47 @@ /*************************************************************************************** * Copyright (c) 2009 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 LASTFMINFOPARSER_H #define LASTFMINFOPARSER_H #include "services/InfoParserBase.h" #include class QNetworkReply; class LastfmInfoParser : public InfoParserBase { Q_OBJECT public: LastfmInfoParser() : InfoParserBase() {} - ~LastfmInfoParser() {} + ~LastfmInfoParser() override {} void getInfo(const Meta::TrackPtr &track) override; void getInfo(const Meta::AlbumPtr &album) override; void getInfo(const Meta::ArtistPtr &artist) override; private Q_SLOTS: void onGetTrackInfo(); void onGetAlbumInfo(); void onGetArtistInfo(); private: QMap m_jobs; }; #endif // LASTFMINFOPARSER_H diff --git a/src/services/gpodder/GpodderPodcastRequestHandler.h b/src/services/gpodder/GpodderPodcastRequestHandler.h index 449bec6124..c56ec1942f 100644 --- a/src/services/gpodder/GpodderPodcastRequestHandler.h +++ b/src/services/gpodder/GpodderPodcastRequestHandler.h @@ -1,45 +1,45 @@ /**************************************************************************************** * Copyright (c) 2011 Stefan Derkits * * Copyright (c) 2011 Christian Wagner * * Copyright (c) 2011 Felix Winter * * * * 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 GPODDERPODCASTREQUESTHANDLER_H_ #define GPODDERPODCASTREQUESTHANDLER_H_ #include "GpodderServiceModel.h" #include #include class GpodderPodcastRequestHandler : public QObject { Q_OBJECT public: GpodderPodcastRequestHandler( mygpo::PodcastListPtr podcasts, const QModelIndex &parentItem, GpodderServiceModel *model ); - virtual ~GpodderPodcastRequestHandler(); + ~GpodderPodcastRequestHandler() override; public Q_SLOTS: void finished(); void requestError( QNetworkReply::NetworkError ); void parseError(); private: mygpo::PodcastListPtr m_podcasts; QModelIndex m_parentItem; GpodderServiceModel *m_model; }; #endif /* GPODDERPODCASTREQUESTHANDLER_H_ */ diff --git a/src/services/gpodder/GpodderProvider.h b/src/services/gpodder/GpodderProvider.h index 94b800dc6d..e6deb51868 100644 --- a/src/services/gpodder/GpodderProvider.h +++ b/src/services/gpodder/GpodderProvider.h @@ -1,183 +1,183 @@ /**************************************************************************************** * Copyright (c) 2011 Stefan Derkits * * Copyright (c) 2011 Christian Wagner * * Copyright (c) 2011 Felix Winter * * Copyright (c) 2011 Lucas Lira Gomes * * * * 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 GPODDERPROVIDER_H #define GPODDERPROVIDER_H #include "core/podcasts/PodcastProvider.h" #include "core/podcasts/PodcastReader.h" #include "GpodderPodcastMeta.h" #include #include #include "playlistmanager/file/KConfigSyncRelStore.h" #include "playlistmanager/PlaylistManager.h" #include #include #include #include #include using namespace mygpo; class QAction; namespace Podcasts { class GpodderProvider : public PodcastProvider { Q_OBJECT public: GpodderProvider( const QString& username, const QString& devicename, ApiRequest *apiRequest ); - ~GpodderProvider(); + ~GpodderProvider() override; //TrackProvider methods bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; //PodcastProvider methods /** Special function to get an episode for a given guid. * * note: this functions is required because QUrl does not preserve every possible guids. * This means we can not use trackForUrl(). * Problematic guids contain non-latin characters, percent encoded parts, capitals, etc. */ PodcastEpisodePtr episodeForGuid( const QString &guid ) override; void addPodcast( const QUrl &url ) override; Podcasts::PodcastChannelPtr addChannel( const Podcasts::PodcastChannelPtr &channel ) override; Podcasts::PodcastEpisodePtr addEpisode( Podcasts::PodcastEpisodePtr episode ) override; Podcasts::PodcastChannelList channels() override; // PlaylistProvider methods QString prettyName() const override; QIcon icon() const override; Playlists::PlaylistList playlists() override; void completePodcastDownloads() override; /** Copy a playlist to the provider. */ Playlists::PlaylistPtr addPlaylist( Playlists::PlaylistPtr playlist ) override; QActionList playlistActions( const Playlists::PlaylistList &playlists ) override; private Q_SLOTS: void requestDeviceUpdates(); void deviceUpdatesFinished(); void continueDeviceUpdatesFinished(); void deviceUpdatesParseError(); void deviceUpdatesRequestError( QNetworkReply::NetworkError error ); void requestEpisodeActionsInCascade(); void episodeActionsInCascadeFinished(); void episodeActionsInCascadeParseError(); void episodeActionsInCascadeRequestError( QNetworkReply::NetworkError error ); void timerGenerateEpisodeAction(); void timerSynchronizeStatus(); void timerSynchronizeSubscriptions(); void timerPrepareToSyncPodcastStatus(); void slotRemoveChannels(); void synchronizeStatusParseError(); void synchronizeStatusRequestError( QNetworkReply::NetworkError error ); void slotSuccessfulStatusSynchronisation(); void slotSuccessfulSubscriptionSynchronisation(); void slotSyncPlaylistAdded( Playlists::PlaylistPtr playlist ); void slotSyncPlaylistRemoved( Playlists::PlaylistPtr playlist ); void slotPaused(); void slotTrackChanged( Meta::TrackPtr track ); void slotTrackPositionChanged( qint64 position, bool userSeek ); void requestUrlResolve( GpodderPodcastChannelPtr channel ); void urlResolvePermanentRedirection ( KIO::Job *job, const QUrl &fromUrl, const QUrl &toUrl ); void urlResolveFinished( KJob * ); void slotEpisodeDownloaded( Podcasts::PodcastEpisodePtr episode ); void slotEpisodeDeleted( Podcasts::PodcastEpisodePtr episode ); void slotEpisodeMarkedAsNew( Podcasts::PodcastEpisodePtr episode ); private: QActionList channelActions( PodcastChannelList episodes ); ApiRequest *m_apiRequest; const QString m_username; const QString m_deviceName; PodcastChannelList m_channels; KIO::TransferJob *m_resolveUrlJob; AddRemoveResultPtr m_addRemoveResult; DeviceUpdatesPtr m_deviceUpdatesResult; AddRemoveResultPtr m_episodeActionsResult; EpisodeActionListPtr m_episodeActionListResult; qulonglong m_timestampStatus; qulonglong m_timestampSubscription; qulonglong subscriptionTimestamp(); void setSubscriptionTimestamp( qulonglong newTimestamp ); void removeChannel( const QUrl &url ); void createPlayStatusBookmark(); void synchronizeStatus(); void synchronizeSubscriptions(); void updateLocalPodcasts( const QList< QPair > updatedUrls ); KConfigGroup gpodderActionsConfig() const; void loadCachedEpisodeActions(); void saveCachedEpisodeActions(); KConfigGroup gpodderPodcastsConfig() const; void loadCachedPodcastsChanges(); void saveCachedPodcastsChanges(); QAction *m_removeAction; //Lists of podcasts to be added or removed from gpodder.net QList m_addList; QList m_removeList; QUrl resolvedPodcastUrl( const PodcastEpisodePtr episode ); QMap m_redirectionUrlMap; QQueue m_channelsToRequestActions; QMap m_resolvedPodcasts; //Used as a temporary container for podcasts with already urls resolved //before adding them to m_channels QQueue m_resolvedChannelsToBeAdded; QMap m_episodeStatusMap; QMap m_uploadEpisodeStatusMap; QTimer *m_timerGeneratePlayAction; QTimer *m_timerSynchronizeStatus; QTimer *m_timerSynchronizeSubscriptions; Meta::TrackPtr m_trackToSyncStatus; }; } #endif diff --git a/src/services/gpodder/GpodderService.h b/src/services/gpodder/GpodderService.h index 270a95c8e4..cb275c4b47 100644 --- a/src/services/gpodder/GpodderService.h +++ b/src/services/gpodder/GpodderService.h @@ -1,87 +1,87 @@ /**************************************************************************************** * Copyright (c) 2010 - 2011 Stefan Derkits * * Copyright (c) 2010 - 2011 Christian Wagner * * Copyright (c) 2010 - 2011 Felix Winter * * * * 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 GPODDERSERVICE_H #define GPODDERSERVICE_H #include "core/support/Amarok.h" #include "GpodderProvider.h" #include "services/ServiceBase.h" #include #include class GpodderService; namespace The { GpodderService *gpodderService(); } class GpodderServiceFactory : public ServiceFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_gpodder.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: GpodderServiceFactory(); ~GpodderServiceFactory() override; void init() override; QString name() override; KConfigGroup config() override; private Q_SLOTS: void slotCreateGpodderService(); void slotRemoveGpodderService(); private: ServiceBase *createGpodderService(); }; class GpodderService : public ServiceBase { Q_OBJECT public: GpodderService( GpodderServiceFactory *parent, const QString &name ); - virtual ~GpodderService(); + ~GpodderService() override; private Q_SLOTS: void subscribe(); void itemSelected( CollectionTreeItem *selectedItem ); private: void init(); void polish() override; void enableGpodderProvider( const QString &username ); Collections::Collection *collection() override { return 0; } bool m_inited; mygpo::ApiRequest *m_apiRequest; Podcasts::GpodderProvider *m_podcastProvider; QSortFilterProxyModel *m_proxyModel; QPushButton *m_subscribeButton; QItemSelectionModel *m_selectionModel; }; #endif // GPODDERSERVICE_H diff --git a/src/services/gpodder/GpodderServiceConfig.h b/src/services/gpodder/GpodderServiceConfig.h index 7ac06dfff0..18e2f531f1 100644 --- a/src/services/gpodder/GpodderServiceConfig.h +++ b/src/services/gpodder/GpodderServiceConfig.h @@ -1,83 +1,83 @@ /**************************************************************************************** * Copyright (c) 2007 Shane King * * Copyright (c) 2009 Leo Franchi * * Copyright (c) 2010 Stefan Derkits * * Copyright (c) 2010 Christian Wagner * * Copyright (c) 2010 Felix Winter * * * * 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 GPODDERSERVICECONFIG_H #define GPODDERSERVICECONFIG_H #include #include namespace KWallet { class Wallet; } class QMessageBox; #ifdef MAKE_GPODDER_SERVICE_CONFIG_LIB #define GPODDER_CONFIG_EXPORT Q_DECL_EXPORT #else #define GPODDER_CONFIG_EXPORT Q_DECL_IMPORT #endif class GPODDER_CONFIG_EXPORT GpodderServiceConfig : public QObject { Q_OBJECT public: static const char *configSectionName() { return "Service_gpodder"; } GpodderServiceConfig(); - ~GpodderServiceConfig(); + ~GpodderServiceConfig() override; void load(); void save(); void reset(); const QString &username() { return m_username; } void setUsername( const QString &username ) { m_username = username; } const QString &password() { return m_password; } void setPassword( const QString &password ) { m_password = password; } bool enableProvider() { return m_enableProvider; } void setEnableProvider( bool enableProvider ) { m_enableProvider = enableProvider; } bool ignoreWallet() { return m_ignoreWallet; } void setIgnoreWallet( bool ignoreWallet ) { m_ignoreWallet = ignoreWallet; } bool isDataLoaded() { return m_isDataLoaded; } private Q_SLOTS: void textDialogYes(); void textDialogNo(); private: void askAboutMissingKWallet(); void tryToOpenWallet(); QString m_username; QString m_password; bool m_enableProvider; //Enables PodcastProvider if correct LoginData given bool m_ignoreWallet; bool m_isDataLoaded; QMessageBox *m_askDiag; KWallet::Wallet *m_wallet; }; #endif // GPODDERSERVICECONFIG_H diff --git a/src/services/gpodder/GpodderServiceModel.h b/src/services/gpodder/GpodderServiceModel.h index bae71a33cd..08b5a559e1 100644 --- a/src/services/gpodder/GpodderServiceModel.h +++ b/src/services/gpodder/GpodderServiceModel.h @@ -1,78 +1,78 @@ /**************************************************************************************** * Copyright (c) 2011 Stefan Derkits * * Copyright (c) 2011 Christian Wagner * * Copyright (c) 2011 Felix Winter * * * * 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 GPODDERSERVICEMODEL_H_ #define GPODDERSERVICEMODEL_H_ #include "GpodderTreeItem.h" #include #include #include "NetworkAccessManagerProxy.h" #include #include class GpodderTreeItem; class GpodderServiceModel: public QAbstractItemModel { Q_OBJECT public: explicit GpodderServiceModel( mygpo::ApiRequest *request, QObject *parent = nullptr ); - virtual ~GpodderServiceModel(); + ~GpodderServiceModel() override; // QAbstractItemModel methods QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex &index ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; bool hasChildren( const QModelIndex &parent = QModelIndex() ) const override; void insertPodcastList( mygpo::PodcastListPtr podcasts, const QModelIndex & parentItem ); private Q_SLOTS: void topTagsRequestError( QNetworkReply::NetworkError error ); void topTagsParseError(); void insertTagList(); void topPodcastsRequestError( QNetworkReply::NetworkError error ); void topPodcastsParseError(); void suggestedPodcastsRequestError( QNetworkReply::NetworkError error ); void suggestedPodcastsParseError(); void requestTopTags(); void requestTopPodcasts(); void requestSuggestedPodcasts(); protected: bool canFetchMore( const QModelIndex &parent ) const override; void fetchMore( const QModelIndex &parent ) override; private: GpodderTreeItem *m_rootItem; GpodderTreeItem *m_topTagsItem; GpodderTreeItem *m_topPodcastsItem; GpodderTreeItem *m_suggestedPodcastsItem; //The gpodder.net topTags mygpo::TagListPtr m_topTags; mygpo::ApiRequest *m_apiRequest; }; #endif /* GPODDERSERVICEMODEL_H_ */ diff --git a/src/services/gpodder/GpodderServiceSettings.h b/src/services/gpodder/GpodderServiceSettings.h index 65eac560a1..1c3707b7ee 100644 --- a/src/services/gpodder/GpodderServiceSettings.h +++ b/src/services/gpodder/GpodderServiceSettings.h @@ -1,66 +1,66 @@ /**************************************************************************************** * Copyright (c) 2007 Shane King * * Copyright (c) 2010 Stefan Derkits * * Copyright (c) 2010 Christian Wagner * * Copyright (c) 2010 Felix Winter * * * * 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 GPODDERSERVICESETTINGS_H #define GPODDERSERVICESETTINGS_H #include "GpodderServiceConfig.h" #include #include #include namespace Ui { class GpodderConfigWidget; } class GpodderServiceSettings : public KCModule { Q_OBJECT public: GpodderServiceSettings( QWidget *parent, const QVariantList &args ); - virtual ~GpodderServiceSettings(); + ~GpodderServiceSettings() override; void save() override; void load() override; void defaults() override; private Q_SLOTS: void testLogin(); void finished(); void onError( QNetworkReply::NetworkError code ); void onParseError( ); void deviceCreationFinished(); void deviceCreationError( QNetworkReply::NetworkError code ); void settingsChanged(); private: Ui::GpodderConfigWidget *m_configDialog; GpodderServiceConfig m_config; mygpo::DeviceListPtr m_devices; mygpo::AddRemoveResultPtr m_result; bool m_enableProvider; QNetworkReply *m_createDevice; }; #endif // GPODDERSERVICESETTINGS_H diff --git a/src/services/gpodder/GpodderTagTreeItem.h b/src/services/gpodder/GpodderTagTreeItem.h index d216331aca..63cc965d89 100644 --- a/src/services/gpodder/GpodderTagTreeItem.h +++ b/src/services/gpodder/GpodderTagTreeItem.h @@ -1,40 +1,40 @@ /**************************************************************************************** * Copyright (c) 2011 Stefan Derkits * * Copyright (c) 2011 Christian Wagner * * Copyright (c) 2011 Felix Winter * * * * 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 GPODDERTAGTREEITEM_H_ #define GPODDERTAGTREEITEM_H_ #include "GpodderTreeItem.h" #include #include class GpodderTagTreeItem: public GpodderTreeItem { Q_OBJECT public: explicit GpodderTagTreeItem( mygpo::TagPtr tag, GpodderTreeItem *parent = nullptr ); - virtual ~GpodderTagTreeItem(); + ~GpodderTagTreeItem() override; QVariant displayData() const override; mygpo::TagPtr tag() const; private: mygpo::TagPtr m_tag; }; #endif /* GPODDERTAGTREEITEM_H_ */ diff --git a/src/services/gpodder/GpodderTreeItem.h b/src/services/gpodder/GpodderTreeItem.h index 399624cf37..642e1cb371 100644 --- a/src/services/gpodder/GpodderTreeItem.h +++ b/src/services/gpodder/GpodderTreeItem.h @@ -1,59 +1,59 @@ /**************************************************************************************** * Copyright (c) 2011 Stefan Derkits * * Copyright (c) 2011 Christian Wagner * * Copyright (c) 2011 Felix Winter * * * * 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 GPODDERTREEITEM_H_ #define GPODDERTREEITEM_H_ #include #include #include #include #include class GpodderTreeItem : public QObject { Q_OBJECT public: explicit GpodderTreeItem( GpodderTreeItem *parent = nullptr, const QString &name = QString() ); - virtual ~GpodderTreeItem(); + ~GpodderTreeItem() override; void appendChild( GpodderTreeItem *child ); GpodderTreeItem *child( int row ); int childCount() const; void setHasChildren( bool hasChildren ); bool hasChildren() const; GpodderTreeItem *parent() const; bool isRoot() const; virtual QVariant displayData() const; virtual void appendTags( mygpo::TagListPtr tags ); virtual void appendPodcasts( mygpo::PodcastListPtr podcasts ); private: QList m_childItems; GpodderTreeItem *m_parentItem; QString m_name; bool m_hasChildren; }; #endif /* GPODDERTREEITEM_H_ */ diff --git a/src/services/lastfm/AvatarDownloader.h b/src/services/lastfm/AvatarDownloader.h index 74e8086921..f02a7f4e3d 100644 --- a/src/services/lastfm/AvatarDownloader.h +++ b/src/services/lastfm/AvatarDownloader.h @@ -1,62 +1,62 @@ /**************************************************************************************** * Copyright (c) 2008 Casey Link * * * * 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 AVATAR_DOWNLOADER_H #define AVATAR_DOWNLOADER_H #include "network/NetworkAccessManagerProxy.h" #include #include #include class AvatarDownloader : public QObject { Q_OBJECT public: /** * Constructor. */ AvatarDownloader(); /** * Destructor. */ - ~AvatarDownloader(); + ~AvatarDownloader() override; /** * Start the download * @param username The username for which avatar should be downloaded. * @param url The url that should be downloaded. */ void downloadAvatar( const QString& username, const QUrl &url ); Q_SIGNALS: void avatarDownloaded( const QString &username, QPixmap avatar ); private Q_SLOTS: /** * Slot called when the network access manager finished a request */ void downloaded( const QUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); private: QHash m_userAvatarUrls; }; #endif diff --git a/src/services/lastfm/LastFmService.h b/src/services/lastfm/LastFmService.h index 69964e2472..69ca52a5b7 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(); void init() override; QString name() override; KConfigGroup config() override; bool possiblyContainsTrack( const QUrl &url ) const override; }; class LastFmService : public ServiceBase { Q_OBJECT public: LastFmService( LastFmServiceFactory* parent, const QString &name ); - virtual ~LastFmService(); + ~LastFmService() override; void polish() override; 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 50a142328b..3ecedb803b 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(); + ~LastFmServiceCollection() override; bool possiblyContainsTrack( const QUrl &url ) const override; Meta::TrackPtr trackForUrl( const QUrl &url ) override; QString collectionId() const override; QString prettyName() const override; 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/LastFmServiceConfig.h b/src/services/lastfm/LastFmServiceConfig.h index e3985d9bb2..b7d6d2b9f8 100644 --- a/src/services/lastfm/LastFmServiceConfig.h +++ b/src/services/lastfm/LastFmServiceConfig.h @@ -1,143 +1,143 @@ /**************************************************************************************** * Copyright (c) 2007 Shane King * * Copyright (c) 2009 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 LASTFMSERVICECONFIG_H #define LASTFMSERVICECONFIG_H #include "services/lastfm/amarok_service_lastfm_config_export.h" #include #include #include namespace KWallet { class Wallet; } class QMessageBox; class LastFmServiceConfig; typedef QSharedPointer LastFmServiceConfigPtr; /** * Configuration of the Last.fm plugin. Because some operations are async, you should * connect to the updated() signal and listen to changes, especially ones to username, * password or sessionKey. */ class AMAROK_SERVICE_LASTFM_CONFIG_EXPORT LastFmServiceConfig : public QObject { Q_OBJECT public: static const char *configSectionName() { return "Service_LastFm"; } /** * Singleton pattern accessor. Not thread safe - must be called from the main * thread. */ static LastFmServiceConfigPtr instance(); - ~LastFmServiceConfig(); + ~LastFmServiceConfig() override; /** * Saves the configuration back to the storage and notifies other users about * the change. This method must be called after calling any of the set* methods. */ void save(); QString username() const { return m_username; } void setUsername( const QString &username ) { m_username = username; } QString password() const { return m_password; } void setPassword( const QString &password ) { m_password = password; } QString sessionKey() const { return m_sessionKey; } void setSessionKey( const QString &sessionKey ) { m_sessionKey = sessionKey; } bool scrobble() const { return m_scrobble; } static bool defaultScrobble() { return true; } void setScrobble( bool scrobble ) { m_scrobble = scrobble; } bool fetchSimilar() const { return m_fetchSimilar; } static bool defaultFetchSimilar() { return true; } void setFetchSimilar( bool fetchSimilar ) { m_fetchSimilar = fetchSimilar; } bool scrobbleComposer() const { return m_scrobbleComposer; } static bool defaultScrobbleComposer() { return false; } void setScrobbleComposer( bool scrobbleComposer ) { m_scrobbleComposer = scrobbleComposer; } bool useFancyRatingTags() const { return m_useFancyRatingTags; } static bool defaultUseFancyRatingTags() { return true; } void setUseFancyRatingTags( bool useFancyRatingTags ) { m_useFancyRatingTags = useFancyRatingTags; } bool announceCorrections() const { return m_announceCorrections; } static bool defaultAnnounceCorrections() { return true; } void setAnnounceCorrections( bool announceCorrections ) { m_announceCorrections = announceCorrections; } bool filterByLabel() const { return m_filterByLabel; } static bool defaultFilterByLabel() { return false; } void setFilterByLabel( bool filterByLabel ) { m_filterByLabel = filterByLabel; } QString filteredLabel() const { return m_filteredLabel; } static QString defaultFilteredLabel() { return QString(); } void setFilteredLabel( const QString &filteredLabel ) { m_filteredLabel = filteredLabel; } Q_SIGNALS: /** * Emitted when settings are changed. (after save() is called) */ void updated(); private Q_SLOTS: void slotWalletOpenedToRead( bool success ); void slotWalletOpenedToWrite( bool success ); void slotStoreCredentialsInAscii(); private: Q_DISABLE_COPY( LastFmServiceConfig ) LastFmServiceConfig(); void openWalletToRead(); void openWalletToWrite(); void openWalletAsync(); void prepareOpenedWallet(); void askAboutMissingKWallet(); // don't remove or reorder entries, would break saved config enum KWalletUsage { NoPasswordEnteredYet, PasswodInKWallet, PasswordInAscii }; QString m_username; QString m_password; QString m_sessionKey; bool m_scrobble; bool m_fetchSimilar; bool m_scrobbleComposer; bool m_useFancyRatingTags; bool m_announceCorrections; bool m_filterByLabel; QString m_filteredLabel; KWalletUsage m_kWalletUsage; QMessageBox* m_askDiag; KWallet::Wallet* m_wallet; static QWeakPointer s_instance; }; #endif // LASTFMSERVICECONFIG_H diff --git a/src/services/lastfm/LastFmServiceSettings.h b/src/services/lastfm/LastFmServiceSettings.h index e48c0eede0..0bd3c6db1b 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(); + ~LastFmServiceSettings() override; 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 42c2fe6865..5f691151fe 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(); + ~LastFmTreeModel() override; 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 override; QModelIndex parent( const QModelIndex &index ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; static int avatarSize(); void prepareAvatar( QPixmap& avatar, int size ); 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 34510d040a..7239d351d9 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(); + ~LastFmTreeView() override; Q_SIGNALS: void statusMessage ( const QString& message ); void plsShowRestState(); void plsShowNowPlaying(); private Q_SLOTS: void slotReplacePlaylistByChildTracks(); void slotAppendChildTracks(); protected: 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 a44397cc83..94f6d51579 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(); + ~ScrobblerAdapter() override; public: // ScrobblingService methods: QString prettyName() const override; ScrobbleError scrobble( const Meta::TrackPtr &track, double playedFraction = 1.0, 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 1d3224b773..cbcd740c7e 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(); + ~SynchronizationAdapter() override; QString id() const override; QString prettyName() const override; QString description() const override; QIcon icon() const override; qint64 reliableTrackMetaData() const override; qint64 writableTrackStatsData() const override; 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/biases/LastFmBias.h b/src/services/lastfm/biases/LastFmBias.h index f841b9ec45..2848b38d9a 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(); + ~LastFmBias() override; void fromXml( QXmlStreamReader *reader ) override; void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); QString name() const override; QString toString() const override; QWidget* widget( QWidget* parent = nullptr ) override; virtual Dynamic::TrackSet matchingTracks( const Meta::TrackList& playlist, int contextCount, int finalCount, Dynamic::TrackCollectionPtr universe ) const; bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const override; MatchType match() const; void setMatch( MatchType value ); public Q_SLOTS: void invalidate() override; private Q_SLOTS: 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: 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 6fbc1ae4ba..618dde791a 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(); + ~WeeklyTopBias() override; void fromXml( QXmlStreamReader *reader ) override; void toXml( QXmlStreamWriter *writer ) const override; static QString sName(); QString name() const override; QString toString() const override; QWidget* widget( QWidget* parent = nullptr ) override; bool trackMatches( int position, const Meta::TrackList& playlist, int contextCount ) const override; DateRange range() const; void setRange( const DateRange &range ); private Q_SLOTS: 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: 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 f68ef3aec6..9852c10515 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(); + ~Track() override; // methods inherited from Meta::Base QString name() const override; QString sortableName() const override; // methods inherited from Meta::Track QUrl playableUrl() const override; QString prettyUrl() const override; QString uidUrl() const override; QString notPlayableReason() const override; 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; qreal bpm() const override; QString comment() const override; int trackNumber() const override; int discNumber() const override; qint64 length() const override; int filesize() const override; int sampleRate() const override; int bitrate() const override; QString type() const override; bool inCollection() const override; Collections::Collection *collection() const override; bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; Meta::StatisticsPtr statistics() override; // own methods: void setTrackInfo( const lastfm::Track &trackInfo ); 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(); + ~LastFmProviderCapability() override; }; typedef AmarokSharedPointer TrackPtr; } #endif diff --git a/src/services/lastfm/meta/LastFmMeta_p.h b/src/services/lastfm/meta/LastFmMeta_p.h index f30da286e4..6008263c34 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() + ~Private() override { } 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::currentDateTimeUtc().toSecsSinceEpoch(); } 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() override { return Meta::TrackList(); } 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 override { return false; } bool hasAlbumArtist() const override { return false; } Meta::ArtistPtr albumArtist() const override { return Meta::ArtistPtr(); } Meta::TrackList tracks() override { return Meta::TrackList(); } QString name() const override { if( d ) return d->album; return QString(); } 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 ) 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 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 override { return QString(); } 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 override { return QString(); } 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 override { return QString(); } 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 98bf9073c6..828f58006a 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(); + ~LastFmMultiPlayableCapability() override; // Capabilities::MultiPlayableCapability methods 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 7358740c7a..2c34003ac3 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(); + ~LastFmStreamInfoCapability() override; QString streamName() const override; QString streamSource() const override; private: LastFm::Track *m_sourceTrack; }; #endif diff --git a/src/services/magnatune/MagnatuneActions.h b/src/services/magnatune/MagnatuneActions.h index be4062ac7c..7ee7c2f0f4 100644 --- a/src/services/magnatune/MagnatuneActions.h +++ b/src/services/magnatune/MagnatuneActions.h @@ -1,66 +1,66 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEACTIONS_H #define MAGNATUNEACTIONS_H #include "MagnatuneMeta.h" #include /** A simple QAction subclass for purchasing or downloading content from Magnatune @author Nikolaj Hald Nielsen */ class MagnatuneDownloadAction : public QAction { Q_OBJECT public: MagnatuneDownloadAction( const QString &text, Meta::MagnatuneAlbum * album ); - ~MagnatuneDownloadAction(); + ~MagnatuneDownloadAction() override; private Q_SLOTS: void slotTriggered(); private: Meta::MagnatuneAlbum * m_album; }; /** A simple QAction subclass for purchasing or downloading content from Magnatune @author Nikolaj Hald Nielsen */ class MagnatuneAddToFavoritesAction : public QAction { Q_OBJECT public: MagnatuneAddToFavoritesAction( const QString &text, Meta::MagnatuneAlbum * album ); - ~MagnatuneAddToFavoritesAction(); + ~MagnatuneAddToFavoritesAction() override; private Q_SLOTS: void slotTriggered(); private: Meta::MagnatuneAlbum * m_album; }; #endif diff --git a/src/services/magnatune/MagnatuneAlbumDownloader.h b/src/services/magnatune/MagnatuneAlbumDownloader.h index 04c6a60449..8b81c4c293 100644 --- a/src/services/magnatune/MagnatuneAlbumDownloader.h +++ b/src/services/magnatune/MagnatuneAlbumDownloader.h @@ -1,78 +1,78 @@ /**************************************************************************************** * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEALBUMDOWNLOADER_H #define MAGNATUNEALBUMDOWNLOADER_H #include "MagnatuneDownloadInfo.h" #include "MagnatuneMeta.h" #include #include #include #include /** This class encapsulates the downloading of an album once all required information has been retrieved @author Nikolaj Hald Nielsen */ class MagnatuneAlbumDownloader : public QObject { Q_OBJECT public: MagnatuneAlbumDownloader(); - ~MagnatuneAlbumDownloader(); + ~MagnatuneAlbumDownloader() override; Q_SIGNALS: /** * This signal is emitted when a download is finished or cancelled * @param success true is download completed, false if download was cancelled. */ void downloadComplete( bool success ); public Q_SLOTS: /** * Initiates the download of an album * @param info A MagnatuneDownloadInfo object containing all needed information */ void downloadAlbum( MagnatuneDownloadInfo info ); protected: KIO::FileCopyJob *m_albumDownloadJob; KIO::FileCopyJob *m_coverDownloadJob; QString m_currentAlbumUnpackLocation; QString m_currentAlbumFileName; MagnatuneDownloadInfo m_currentAlbumInfo; QTemporaryDir * m_tempDir; protected Q_SLOTS: /** * Unzip the downloaded album * @param downloadJob */ void albumDownloadComplete( KJob* downloadJob ); void albumDownloadAborted(); void coverDownloadComplete( KJob* downloadJob ); void coverAddAborted(); }; #endif diff --git a/src/services/magnatune/MagnatuneCollectionLocation.h b/src/services/magnatune/MagnatuneCollectionLocation.h index 87fda7dec3..0c7ebcb6a0 100644 --- a/src/services/magnatune/MagnatuneCollectionLocation.h +++ b/src/services/magnatune/MagnatuneCollectionLocation.h @@ -1,43 +1,43 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 MAGNATUNECOLLECTIONLOCATION_H #define MAGNATUNECOLLECTIONLOCATION_H #include "MagnatuneSqlCollection.h" #include "ServiceCollectionLocation.h" namespace Collections { /** A ServiceCollectionLocation subclass responsible for showing a small Magnatune specific dialog when copying tracks from Magnatune @author Nikolaj Hald Nielsen */ class MagnatuneCollectionLocation : public ServiceCollectionLocation { public: explicit MagnatuneCollectionLocation( MagnatuneSqlCollection *parentCollection ); - virtual ~MagnatuneCollectionLocation(); + ~MagnatuneCollectionLocation() override; void showSourceDialog( const Meta::TrackList &tracks, bool removeSources ) override; }; } //namespace Collections #endif diff --git a/src/services/magnatune/MagnatuneDatabaseWorker.h b/src/services/magnatune/MagnatuneDatabaseWorker.h index 656ba4c318..4b7e123ebb 100644 --- a/src/services/magnatune/MagnatuneDatabaseWorker.h +++ b/src/services/magnatune/MagnatuneDatabaseWorker.h @@ -1,87 +1,87 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEDATABASEWORKER_H #define MAGNATUNEDATABASEWORKER_H #include "MagnatuneMeta.h" #include "../ServiceSqlRegistry.h" #include /** A small helper class to do some simple asynchronous database queries @author Nikolaj Hald Nielsen */ class MagnatuneDatabaseWorker : public QObject, public ThreadWeaver::Job { Q_OBJECT public: MagnatuneDatabaseWorker(); - ~MagnatuneDatabaseWorker(); + ~MagnatuneDatabaseWorker() override; void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; void fetchMoodMap(); void fetchTrackswithMood( const QString &mood, int noOfTracks, ServiceSqlRegistry * registry ); void fetchAlbumBySku( const QString &sku, ServiceSqlRegistry * registry ); Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); void gotMoodMap( const QMap &map ); void gotMoodyTracks( const Meta::TrackList &tracks ); void gotAlbumBySku( Meta::MagnatuneAlbum * album ); private Q_SLOTS: void completeJob(); private: void doFetchMoodMap(); void doFetchTrackswithMood(); void doFetchAlbumBySku(); enum taskType { FETCH_MODS, FETCH_MOODY_TRACKS, ALBUM_BY_SKU }; int m_task; QMap m_moodMap; Meta::TrackList m_moodyTracks; QString m_mood; QString m_sku; int m_noOfTracks; Meta::MagnatuneAlbum * m_album; ServiceSqlRegistry * m_registry; protected: void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; }; #endif diff --git a/src/services/magnatune/MagnatuneDownloadHandler.h b/src/services/magnatune/MagnatuneDownloadHandler.h index f1ec9c550f..2ac81e5de4 100644 --- a/src/services/magnatune/MagnatuneDownloadHandler.h +++ b/src/services/magnatune/MagnatuneDownloadHandler.h @@ -1,85 +1,85 @@ /**************************************************************************************** * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEDOWNLOADHANDLER_H #define MAGNATUNEDOWNLOADHANDLER_H #include #include #include #include "MagnatuneAlbumDownloader.h" #include "MagnatuneDownloadDialog.h" #include "MagnatuneMeta.h" /** The main class responsible for handling of downloads from Magnatune.com @author Nikolaj Hald Nielsen */ class MagnatuneDownloadHandler : public QObject { Q_OBJECT public: MagnatuneDownloadHandler(); - ~MagnatuneDownloadHandler(); + ~MagnatuneDownloadHandler() override; void setParent( QWidget * parent ); /** * Starts a download operation * @param album The album to download */ void downloadAlbum( Meta::MagnatuneAlbum * album ); Q_SIGNALS: void downloadCompleted( bool success ); private: KIO::TransferJob * m_resultDownloadJob; //need a parent to pass to any dialogs we spawn QWidget * m_parent; MagnatuneDownloadDialog * m_downloadDialog; MagnatuneAlbumDownloader * m_albumDownloader; Meta::MagnatuneAlbum * m_currentAlbum; QString m_currentAlbumCoverName; bool m_membershipDownload; bool parseDownloadXml( const QString &xml ); void membershipDownload( int membershipType, const QString &username, const QString &password ); /** * This function saves the xml download info received from Magnatune.com after a * successful download. This information can be used to later redownload a lost album, * or acquire an album in a different file format. Note that no personal information * or credit card number is stored. The information is saved to the amarok config * directory in the sub folder magnatune.com/purchases. The name of each info file * is generated from the artist and album names. * @param infoXml The info to store. */ void saveDownloadInfo(const QString &infoXml); protected Q_SLOTS: void xmlDownloadComplete( KJob* downLoadJob ); void albumDownloadComplete( bool success ); }; #endif diff --git a/src/services/magnatune/MagnatuneMeta.h b/src/services/magnatune/MagnatuneMeta.h index 082bdeff18..d986ebab43 100644 --- a/src/services/magnatune/MagnatuneMeta.h +++ b/src/services/magnatune/MagnatuneMeta.h @@ -1,193 +1,193 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEMETA_H #define MAGNATUNEMETA_H #include "../ServiceMetaBase.h" #include "../ServiceAlbumCoverDownloader.h" #include #include #include #include class MagnatuneStore; namespace Meta { class MagnatuneTrack : public ServiceTrack { Q_OBJECT public: explicit MagnatuneTrack( const QString &name ); explicit MagnatuneTrack( const QStringList &resultRow ); QString lofiUrl(); void setLofiUrl( const QString &url ); QList moods() const; void setMoods( const QList &moods ); void setDownloadMembership(); QString sourceName() override; QString sourceDescription() override; QPixmap emblem() override; bool isBookmarkable() const override { return true; } QString collectionName() const override { return QStringLiteral("Magnatune.com"); } bool simpleFiltering() const override { return false; } void setOggUrl( const QString& url ); QString oggUrl() const; void setAlbumPtr( const Meta::AlbumPtr &album ) override; public Q_SLOTS: void download(); private: QString m_lofiUrl; QString m_oggUrl; bool m_downloadMembership; QList m_moods; }; class MagnatuneArtist : public ServiceArtist { private: QUrl m_photoUrl; QUrl m_magnatuneUrl; public: explicit MagnatuneArtist( const QString &name ); explicit MagnatuneArtist( const QStringList &resultRow ); void setPhotoUrl( const QUrl &photoUrl ); QUrl photoUrl() const; void setMagnatuneUrl( const QUrl &url ); QUrl magnatuneUrl() const; bool isBookmarkable() const override { return true; } QString collectionName() const override { return QStringLiteral("Magnatune.com"); } bool simpleFiltering() const override { return false; } }; class MagnatuneAlbum : public ServiceAlbumWithCover { Q_OBJECT private: QString m_coverUrl; int m_launchYear; QString m_albumCode; MagnatuneStore * m_store; bool m_downloadMembership; public: explicit MagnatuneAlbum( const QString &name ); explicit MagnatuneAlbum( const QStringList &resultRow ); - ~MagnatuneAlbum(); + ~MagnatuneAlbum() override; QString downloadPrefix() const override { return QStringLiteral("magnatune"); } void setLaunchYear( int launchYear ); int launchYear() const; void setCoverUrl( const QString &coverUrl ) override; QString coverUrl() const override; QUrl imageLocation( int size = 1 ) override { Q_UNUSED( size ); return QUrl( coverUrl() ); } void setAlbumCode( const QString &albumCode ); QString albumCode(); void setStore( MagnatuneStore * store ); MagnatuneStore * store(); void setDownloadMembership(); bool isBookmarkable() const override { return true; } QString collectionName() const override { return QStringLiteral("Magnatune.com"); } bool simpleFiltering() const override { return false; } public Q_SLOTS: void download(); void addToFavorites(); }; class MagnatuneGenre : public ServiceGenre { public: explicit MagnatuneGenre( const QString &name ); explicit MagnatuneGenre( const QStringList &resultRow ); bool isBookmarkable() const override { return true; } QString collectionName() const override { return QStringLiteral("Magnatune.com"); } bool simpleFiltering() const override { return false; } }; } class MagnatuneMetaFactory : public ServiceMetaFactory { public: enum { OGG = 0, MP3 = 1, LOFI = 2 }; MagnatuneMetaFactory( const QString &dbPrefix, MagnatuneStore * store ); - virtual ~MagnatuneMetaFactory() {} + ~MagnatuneMetaFactory() override {} int getTrackSqlRowCount() override; QString getTrackSqlRows() override; Meta::TrackPtr createTrack( const QStringList &rows ) override; int getAlbumSqlRowCount() override; QString getAlbumSqlRows() override; Meta::AlbumPtr createAlbum( const QStringList &rows ) override; int getArtistSqlRowCount() override; QString getArtistSqlRows() override; Meta::ArtistPtr createArtist( const QStringList &rows ) override; //virtual int getGenreSqlRowCount(); //virtual QString getGenreSqlRows(); Meta::GenrePtr createGenre( const QStringList &rows ) override; //stuff for supporting the new membership services at Magnatune.com void setMembershipInfo ( const QString &prefix, const QString &userName, const QString &password ); void setStreamType( int type ); private: QString m_membershipPrefix; int m_streamType; QString m_userName; QString m_password; MagnatuneStore * m_store; }; #endif diff --git a/src/services/magnatune/MagnatuneNeedUpdateWidget.h b/src/services/magnatune/MagnatuneNeedUpdateWidget.h index 90764c1251..bb80d35c73 100644 --- a/src/services/magnatune/MagnatuneNeedUpdateWidget.h +++ b/src/services/magnatune/MagnatuneNeedUpdateWidget.h @@ -1,46 +1,46 @@ /**************************************************************************************** * Copyright (c) 2012 Edward "hades" Toroshchin * * * * 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 MAGNATUNENEEDUPDATEWIDGET_H #define MAGNATUNENEEDUPDATEWIDGET_H #include namespace Ui { class MagnatuneNeedUpdateWidget; } class MagnatuneNeedUpdateWidget : public QWidget { Q_OBJECT public: explicit MagnatuneNeedUpdateWidget(QWidget *parent = nullptr); - ~MagnatuneNeedUpdateWidget(); + ~MagnatuneNeedUpdateWidget() override; protected: Ui::MagnatuneNeedUpdateWidget* ui; Q_SIGNALS: void wantUpdate(); public Q_SLOTS: void enable(); void disable(); protected Q_SLOTS: void startUpdate(); void saveSettings(); }; #endif // MAGNATUNENEEDUPDATEWIDGET_H diff --git a/src/services/magnatune/MagnatuneRedownloadHandler.h b/src/services/magnatune/MagnatuneRedownloadHandler.h index 12e65e8b2a..e6c19c2e4f 100644 --- a/src/services/magnatune/MagnatuneRedownloadHandler.h +++ b/src/services/magnatune/MagnatuneRedownloadHandler.h @@ -1,76 +1,76 @@ /**************************************************************************************** * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * * * * 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 MAGNATUNE_REDOWNLOAD_HANDLER_H #define MAGNATUNE_REDOWNLOAD_HANDLER_H #include "MagnatuneAlbumDownloader.h" #include "MagnatuneDownloadDialog.h" #include "MagnatuneDownloadInfo.h" #include "MagnatuneRedownloadDialog.h" #include /** This class handles the redownloading of previously downloaded albums @author Nikolaj Hald Nielsen */ class MagnatuneRedownloadHandler : public QObject { Q_OBJECT public: explicit MagnatuneRedownloadHandler(QWidget * parent); - ~MagnatuneRedownloadHandler(); + ~MagnatuneRedownloadHandler() override; /** * Calls forth the redownload dialog. */ void showRedownloadDialog(); Q_SIGNALS: void reDownloadCompleted( bool success ); protected: QStringList GetPurchaseList( ); /** * Attempt to get a list of previous purchases for an email. * If set, use the email from the magnatune settings, otherwise, QueryMaker * the user (and then save it to settings) */ void fetchServerSideRedownloadList(); QWidget * m_parent; MagnatuneRedownloadDialog * m_redownloadDialog; MagnatuneDownloadDialog * m_downloadDialog; MagnatuneAlbumDownloader * m_albumDownloader; KIO::TransferJob * m_redownloadApiJob; protected Q_SLOTS: void redownload(const MagnatuneDownloadInfo &info ); void selectionDialogCancelled(); void albumDownloadComplete( bool success ); void redownloadApiResult( KJob* job ); }; #endif diff --git a/src/services/magnatune/MagnatuneSettingsModule.h b/src/services/magnatune/MagnatuneSettingsModule.h index 768cd0a623..e875e263a2 100644 --- a/src/services/magnatune/MagnatuneSettingsModule.h +++ b/src/services/magnatune/MagnatuneSettingsModule.h @@ -1,54 +1,54 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 MAGNATUNESETTINGSMODULE_H #define MAGNATUNESETTINGSMODULE_H #include "MagnatuneConfig.h" #include namespace Ui { class MagnatuneConfigWidget; } /** A KCM module to configure the Magnatune service @author */ class MagnatuneSettingsModule : public KCModule { Q_OBJECT public: explicit MagnatuneSettingsModule( QWidget *parent = nullptr, const QVariantList &args = QVariantList() ); - ~MagnatuneSettingsModule(); + ~MagnatuneSettingsModule() override; void save() override; void load() override; void defaults() override; private Q_SLOTS: void settingsChanged(); private: MagnatuneConfig m_config; Ui::MagnatuneConfigWidget * m_configDialog; }; #endif diff --git a/src/services/magnatune/MagnatuneUrlRunner.h b/src/services/magnatune/MagnatuneUrlRunner.h index dc494a2560..f6afb6dde3 100644 --- a/src/services/magnatune/MagnatuneUrlRunner.h +++ b/src/services/magnatune/MagnatuneUrlRunner.h @@ -1,50 +1,50 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEURLRUNNER_H #define MAGNATUNEURLRUNNER_H #include "amarokurls/AmarokUrlRunnerBase.h" #include #include /** @author Nikolaj Hald Nielsen */ class MagnatuneUrlRunner : public QObject, public AmarokUrlRunnerBase { Q_OBJECT public: MagnatuneUrlRunner(); - virtual ~MagnatuneUrlRunner(); + ~MagnatuneUrlRunner() override; QString command() const override; QString prettyCommand() const override; QIcon icon() const override; bool run( const AmarokUrl &url ) override; Q_SIGNALS: void showFavorites(); void showHome(); void showRecommendations(); void buyOrDownload( const QString &sku ); void removeFromFavorites( const QString &sku ); }; #endif diff --git a/src/services/magnatune/MagnatuneXmlParser.h b/src/services/magnatune/MagnatuneXmlParser.h index 93260317c2..ac11463d39 100644 --- a/src/services/magnatune/MagnatuneXmlParser.h +++ b/src/services/magnatune/MagnatuneXmlParser.h @@ -1,146 +1,146 @@ /**************************************************************************************** * Copyright (c) 2006,2007 Nikolaj Hald Nielsen * * * * 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 MAGNATUNEXMLPARSER_H #define MAGNATUNEXMLPARSER_H #include "MagnatuneDatabaseHandler.h" #include "MagnatuneMeta.h" #include #include #include #include #include #include /** * Parser for the XML file from http://magnatune.com/info/album_info.xml * * @author Nikolaj Hald Nielsen */ class MagnatuneXmlParser : public QObject, public ThreadWeaver::Job { Q_OBJECT public: /** * Constructor * @param fileName The file to parse * @return Pointer to new object */ explicit MagnatuneXmlParser( const QString &fileName ); /** * The function that starts the actual work. Inherited from ThreadWeaver::Job * Note the work is performed in a separate thread */ void run(ThreadWeaver::JobPointer self = QSharedPointer(), ThreadWeaver::Thread *thread = 0) override; /** * Destructor * @return none */ - ~MagnatuneXmlParser(); + ~MagnatuneXmlParser() override; /** * Reads, and starts parsing, file. Should not be used directly. * @param filename The file to read */ void readConfigFile( const QString &filename ); void setDbHandler( MagnatuneDatabaseHandler * dbHandler ); Q_SIGNALS: /** This signal is emitted when this job is being processed by a thread. */ void started(ThreadWeaver::JobPointer); /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ void done(ThreadWeaver::JobPointer); /** This job has failed. * This signal is emitted when success() returns false after the job is executed. */ void failed(ThreadWeaver::JobPointer); /** * Signal emitted when parsing is complete. */ void doneParsing(); private Q_SLOTS: /** * Called when the job has completed. Is executed in the GUI thread */ void completeJob(); private: QMap artistNameIdMap; QString m_currentArtist; QString m_currentArtistGenre; /** * Parses a DOM element * @param e The element to parse */ void parseElement( const QDomElement &e ); /** * Parses all children of a DOM element * @param e The element whose children is to be parsed */ void parseChildren( const QDomElement &e ); /** * Parse a DOM element representing an album * @param e The album element to parse */ void parseAlbum( const QDomElement &e ); /** * Parse a DOM element representing a track * @param e The track element to parse */ void parseTrack( const QDomElement &e ); /** * Parse the moods of a track * @param e The moods element to parse */ void parseMoods( const QDomElement &e ); QScopedPointer m_pCurrentAlbum; QScopedPointer m_pCurrentArtist; QList m_currentAlbumTracksList; QStringList m_currentTrackMoodList; QString m_sFileName; int m_nNumberOfTracks; int m_nNumberOfAlbums; int m_nNumberOfArtists; MagnatuneDatabaseHandler * m_dbHandler; protected: void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; }; #endif diff --git a/src/services/opmldirectory/OpmlDirectoryMeta.h b/src/services/opmldirectory/OpmlDirectoryMeta.h index c56bd78ab4..ef0d2fb49b 100644 --- a/src/services/opmldirectory/OpmlDirectoryMeta.h +++ b/src/services/opmldirectory/OpmlDirectoryMeta.h @@ -1,67 +1,67 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 OPMLDIRECTORYMETA_H #define OPMLDIRECTORYMETA_H #include "../ServiceMetaBase.h" #include #include #include #include class OpmlDirectoryService; class OpmlDirectoryMetaFactory : public ServiceMetaFactory { public: OpmlDirectoryMetaFactory( const QString &dbPrefix, OpmlDirectoryService *service ); - virtual ~OpmlDirectoryMetaFactory() {} + ~OpmlDirectoryMetaFactory() override {} Meta::TrackPtr createTrack( const QStringList &rows ) override; Meta::AlbumPtr createAlbum( const QStringList &rows ) override; }; namespace Meta { class OpmlDirectoryFeed; class OpmlDirectoryCategory; typedef AmarokSharedPointer OpmlDirectoryFeedPtr; typedef AmarokSharedPointer OpmlDirectoryCategoryPtr; class OpmlDirectoryFeed : public ServiceTrack { public: explicit OpmlDirectoryFeed( const QString &name ); explicit OpmlDirectoryFeed( const QStringList &resultRow ); }; class OpmlDirectoryCategory : public ServiceAlbum { public: explicit OpmlDirectoryCategory( const QString &name ); explicit OpmlDirectoryCategory( const QStringList &resultRow ); }; } #endif diff --git a/src/services/opmldirectory/OpmlDirectoryModel.h b/src/services/opmldirectory/OpmlDirectoryModel.h index 36ec3b6409..fb7b9d02e6 100644 --- a/src/services/opmldirectory/OpmlDirectoryModel.h +++ b/src/services/opmldirectory/OpmlDirectoryModel.h @@ -1,94 +1,94 @@ /**************************************************************************************** * Copyright (c) 2010 Bart Cerneels . * ****************************************************************************************/ #ifndef OPMLDIRECTORYMODEL_H #define OPMLDIRECTORYMODEL_H #include "OpmlOutline.h" #include #include class OpmlParser; class QAction; typedef QList QActionList; class OpmlDirectoryModel : public QAbstractItemModel { Q_OBJECT public: //TODO: make these rols part of a common class in Amarok::. enum { ActionRole = Qt::UserRole, //list of QActions for the index DecorationUriRole, //a URI for the decoration to be fetched by the view. CustomRoleOffset //first role that can be used by subclasses for their own data }; explicit OpmlDirectoryModel( QUrl outlineUrl, QObject *parent = nullptr ); - ~OpmlDirectoryModel(); + ~OpmlDirectoryModel() override; // QAbstractItemModel methods QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; Qt::ItemFlags flags( const QModelIndex &index ) const override; QModelIndex parent( const QModelIndex &index ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; bool hasChildren( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override; bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override; // OpmlDirectoryModel methods virtual void saveOpml( const QUrl &saveLocation ); virtual OpmlNodeType opmlNodeType( const QModelIndex &idx ) const; //TODO: extract these into OpmlPodcastDirectoryModel subclass void subscribe( const QModelIndexList &indexes ) const; Q_SIGNALS: public Q_SLOTS: void slotAddOpmlAction(); void slotAddFolderAction(); protected: bool canFetchMore( const QModelIndex &parent ) const override; void fetchMore( const QModelIndex &parent ) override; private Q_SLOTS: void slotOpmlHeaderDone(); void slotOpmlOutlineParsed( OpmlOutline * ); void slotOpmlParsingDone(); void slotOpmlWriterDone( int result ); private: QModelIndex addOutlineToModel( const QModelIndex &parentIdx, OpmlOutline *oultine ); QUrl m_rootOpmlUrl; QList m_rootOutlines; QMap m_currentFetchingMap; QMap m_imageMap; QAction *m_addOpmlAction; QAction *m_addFolderAction; }; #endif // OPMLDIRECTORYMODEL_H diff --git a/src/services/opmldirectory/OpmlDirectoryService.h b/src/services/opmldirectory/OpmlDirectoryService.h index 145c4c377d..e1106c2731 100644 --- a/src/services/opmldirectory/OpmlDirectoryService.h +++ b/src/services/opmldirectory/OpmlDirectoryService.h @@ -1,84 +1,84 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 OPMLDIRECTORYSERVICE_H #define OPMLDIRECTORYSERVICE_H #include "amarokurls/AmarokUrlRunnerBase.h" #include "../ServiceBase.h" #include "OpmlDirectoryDatabaseHandler.h" #include "ServiceSqlCollection.h" #include "core/support/Amarok.h" #include class OpmlDirectoryServiceFactory: public ServiceFactory { Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_opmldirectory.json") Q_INTERFACES(Plugins::PluginFactory) Q_OBJECT public: OpmlDirectoryServiceFactory(); - virtual ~OpmlDirectoryServiceFactory(); + ~OpmlDirectoryServiceFactory() override; void init() override; QString name() override; KConfigGroup config() override; }; /** A service for displaying, previewing and downloading music from OpmlDirectory.com @author */ class OpmlDirectoryService : public ServiceBase, public AmarokUrlRunnerBase { Q_OBJECT public: OpmlDirectoryService( OpmlDirectoryServiceFactory* parent, const QString &name, const QString &prettyName ); ~OpmlDirectoryService() override; void polish() override; Collections::Collection * collection() override { return nullptr; } /* UrlRunnerBase methods */ QString command() const override; QString prettyCommand() const override; bool run( const AmarokUrl &url ) override; QIcon icon() const override { return QIcon::fromTheme( QStringLiteral("view-services-opml-amarok") ); } private Q_SLOTS: void subscribe(); void slotSelectionChanged( const QItemSelection &, const QItemSelection & ); private: QPushButton *m_addOpmlButton; QPushButton *m_subscribeButton; int m_currentCategoryId; int m_numberOfFeeds; int m_numberOfCategories; }; #endif diff --git a/src/services/scriptable/ScriptableServiceManager.h b/src/services/scriptable/ScriptableServiceManager.h index 26f2279a0f..db6046096c 100644 --- a/src/services/scriptable/ScriptableServiceManager.h +++ b/src/services/scriptable/ScriptableServiceManager.h @@ -1,124 +1,124 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 AMAROKSCRIPTABLESERVICEMANAGER_H #define AMAROKSCRIPTABLESERVICEMANAGER_H #include "AmarokProcess.h" #include "../ServiceBase.h" #include "ScriptableService.h" #include #include #include class ScriptableServiceManager; namespace The { AMAROK_EXPORT ScriptableServiceManager* scriptableServiceManager(); } class ScriptableServiceManager : public QObject { Q_OBJECT friend ScriptableServiceManager* The::scriptableServiceManager(); public: void removeRunningScript( const QString &name ); ScriptableService * service( const QString &name ); Q_SIGNALS: /** * Signal emitted whenever a new service is ready to be added * @param service The service to add */ void addService( ServiceBase * service ); void serviceUpdated( ServiceBase * service ); public Q_SLOTS: /** * Initialzises a new service. This method is exported to DBUS * @param name the name of the service to create. Must be the same as the name of the script * @param levels How many levels of items should be added ( 1 - 4 ) * @param shortDescription Some short description * @param rootHtml The html to display when the service is selected * @param showSearchBar Determines whether to show search bar * @return returns true if successful and false otherwise */ bool initService( const QString &name, int levels, const QString &shortDescription, const QString &rootHtml, bool showSearchBar ); /** * Add a new item to a service * @param serviceName The name of the service to add an item to * @param level The level of this item * @param parentId The id of the parent item that this item should be a child of ( -1 if no parent ) * @param name The name of this item * @param infoHtml The html info to display when this item is selected * @param callbackData The callback data needed to let the script know how to populate this items children ( Empty string if leaf item ) * @param playableUrl The url to play if added to the playlist ( Empty string if not leaf node ) * @param albumOverride The album override * @param artistOverride The artist override * @param genreOverride The genre override * @param composerOverride The composer override * @param yearOverride The year override * @param coverUrl The cover URL * @return the id of the created item ( or -1 on failure ) */ int insertItem( const QString &serviceName, int level, int parentId, const QString &name, const QString &infoHtml, const QString &callbackData, const QString &playableUrl, const QString & albumOverride, const QString & artistOverride, const QString & genreOverride, const QString & composerOverride, int yearOverride, const QString &coverUrl ); /** * Let the service know that the script has added all child nodes * @param serviceName The service we have been adding items to * @param parentId The id of the parent node */ void donePopulating( const QString &serviceName, int parentId ); void setIcon( const QString &serviceName, const QPixmap &icon ); void setEmblem( const QString &serviceName, const QPixmap &emblem ); void setScalableEmblem( const QString &serviceName, const QString &emblemPath ); void setCurrentInfo( const QString &serviceName, const QString &info ); private: /** * Constructor */ ScriptableServiceManager(); /** * Destructor */ - ~ScriptableServiceManager(); + ~ScriptableServiceManager() override; static ScriptableServiceManager * s_instance; QMap m_serviceMap; QString m_rootHtml; }; #endif diff --git a/src/services/scriptable/ScriptableServiceMeta_p.h b/src/services/scriptable/ScriptableServiceMeta_p.h index a1d3049db8..84ea0ac32a 100644 --- a/src/services/scriptable/ScriptableServiceMeta_p.h +++ b/src/services/scriptable/ScriptableServiceMeta_p.h @@ -1,320 +1,320 @@ /**************************************************************************************** * Copyright (c) 2007 Maximilian Kossick * * Copyright (c) 2008 Peter ZHOU * * Copyright (c) 2008-2009 Nikolaj Hald Nielsen * * * * 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_SCRIPTABLE_SERVICE_META_P_H #define AMAROK_SCRIPTABLE_SERVICE_META_P_H #include "core/support/Debug.h" #include "core/meta/Meta.h" #include "core/capabilities/SourceInfoCapability.h" #include #include #include #include #include // internal helper classes /** * Base class for the private meta types. This is used to give these private items source info capability which is needed in some cases,for instance when bookmarking. */ class ScriptableServiceInternalMetaItem { public: QString serviceName() { return m_serviceName; } QString serviceDescription() { return m_serviceDescription; } QPixmap serviceEmblem() { return m_serviceEmblem; } QString serviceScalableEmblem() { return m_serviceScalableEmblem; } void setServiceName( const QString &name ) { m_serviceName = name; } void setServiceDescription( const QString &description ) { m_serviceDescription = description; } void setServiceEmblem( const QPixmap &emblem ) { m_serviceEmblem = emblem; } void setServiceScalableEmblem( const QString &emblemPath ) { m_serviceScalableEmblem = emblemPath; } protected: QString m_serviceName; QString m_serviceDescription; QPixmap m_serviceEmblem; QString m_serviceScalableEmblem; }; class AMAROK_EXPORT ScriptableServiceInternalSourceInfoCapability : public Capabilities::SourceInfoCapability { public: explicit ScriptableServiceInternalSourceInfoCapability( ScriptableServiceInternalMetaItem * sourceInfoProvider ) { m_sourceInfoProvider = sourceInfoProvider; } - ~ScriptableServiceInternalSourceInfoCapability() {} + ~ScriptableServiceInternalSourceInfoCapability() override {} QString sourceName() override { return m_sourceInfoProvider->serviceName(); } QString sourceDescription() override { return m_sourceInfoProvider->serviceDescription(); } QPixmap emblem() override { return m_sourceInfoProvider->serviceEmblem(); } QString scalableEmblem() override { return m_sourceInfoProvider->serviceScalableEmblem(); } private: ScriptableServiceInternalMetaItem * m_sourceInfoProvider; }; class ScriptableServiceInternalArtist : public Meta::Artist, public ScriptableServiceInternalMetaItem { public: explicit ScriptableServiceInternalArtist( const QString &name = QString() ) : Meta::Artist() , m_name( name ) {} Meta::TrackList tracks() override { return Meta::TrackList(); } QString name() const override { if( !m_name.isEmpty() ) return m_name; else return i18nc( "The value is not known", "Unknown" ); } QString prettyName() const override { return name(); } bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::SourceInfo ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::SourceInfo ) return new ScriptableServiceInternalSourceInfoCapability( this ); return 0; } private: QString m_name; }; class ScriptableServiceInternalAlbum : public Meta::ServiceAlbumWithCover, public ScriptableServiceInternalMetaItem { public: explicit ScriptableServiceInternalAlbum( const QString &name = QString() ) : Meta::ServiceAlbumWithCover( QString() ) , m_name( name ) {} bool isCompilation() const override { return false; } bool hasAlbumArtist() const override { return false; } Meta::ArtistPtr albumArtist() const override { return Meta::ArtistPtr(); } Meta::TrackList tracks() override { return Meta::TrackList(); } QString name() const override { if( !m_name.isEmpty() ) return m_name; else return i18nc( "The value is not known", "Unknown" ); } QString prettyName() const override { return name(); } QString downloadPrefix() const override { return QStringLiteral("script"); } void setCoverUrl( const QString &coverUrl ) override { m_coverUrl = coverUrl; } QString coverUrl() const override { return m_coverUrl; } QUrl imageLocation( int size = 1 ) override { Q_UNUSED( size ); return QUrl( coverUrl() ); } bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::SourceInfo ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::SourceInfo ) return new ScriptableServiceInternalSourceInfoCapability( this ); return 0; } private: QString m_name; QString m_coverUrl; }; class ScriptableServiceInternalGenre : public Meta::Genre, public ScriptableServiceInternalMetaItem { public: explicit ScriptableServiceInternalGenre( const QString &name = QString() ) : Meta::Genre() , m_name( name ) {} Meta::TrackList tracks() override { return Meta::TrackList(); } QString name() const override { if( !m_name.isEmpty() ) return m_name; else return i18nc( "The value is not known", "Unknown" ); } QString prettyName() const override { return name(); } bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::SourceInfo ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::SourceInfo ) return new ScriptableServiceInternalSourceInfoCapability( this ); return 0; } private: QString m_name; }; class ScriptableServiceInternalComposer : public Meta::Composer, public ScriptableServiceInternalMetaItem { public: explicit ScriptableServiceInternalComposer( const QString &name = QString() ) : Meta::Composer() , m_name( name ) {} Meta::TrackList tracks() override { return Meta::TrackList(); } QString name() const override { if( !m_name.isEmpty() ) return m_name; else return i18nc( "The value is not known", "Unknown" ); } QString prettyName() const override { return name(); } bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::SourceInfo ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::SourceInfo ) return new ScriptableServiceInternalSourceInfoCapability( this ); return 0; } private: QString m_name; }; class ScriptableServiceInternalYear : public Meta::Year, public ScriptableServiceInternalMetaItem { public: explicit ScriptableServiceInternalYear( const QString &name = QString() ) : Meta::Year() , m_name( name ) {} Meta::TrackList tracks() override { return Meta::TrackList(); } QString name() const override { if( !m_name.isEmpty() ) return m_name; else return i18nc( "The value is not known", "Unknown" ); } QString prettyName() const override { return name(); } bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override { return ( type == Capabilities::Capability::SourceInfo ); } Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override { if ( type == Capabilities::Capability::SourceInfo ) return new ScriptableServiceInternalSourceInfoCapability( this ); return 0; } private: QString m_name; }; #endif diff --git a/src/services/scriptable/ScriptableServiceQueryMaker.h b/src/services/scriptable/ScriptableServiceQueryMaker.h index 32115d0421..675057ae44 100644 --- a/src/services/scriptable/ScriptableServiceQueryMaker.h +++ b/src/services/scriptable/ScriptableServiceQueryMaker.h @@ -1,93 +1,93 @@ /**************************************************************************************** * Copyright (c) 2007 Nikolaj Hald Nielsen * * * * 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 SCRIPTABLESERVICEQUERYMAKER_H #define SCRIPTABLESERVICEQUERYMAKER_H #include "../DynamicServiceQueryMaker.h" #include "core/meta/forward_declarations.h" #include "ScriptableServiceCollection.h" namespace Collections { /** * A query maker for fetching external data from scripted services. */ class ScriptableServiceQueryMaker : public DynamicServiceQueryMaker { Q_OBJECT public: ScriptableServiceQueryMaker( ScriptableServiceCollection * collection, const QString &name ); - ~ScriptableServiceQueryMaker(); + ~ScriptableServiceQueryMaker() override; void run() override; void abortQuery() override; QueryMaker* setQueryType( QueryType type ) override; QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) override; using QueryMaker::addMatch; QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; // ScriptableServiceQueryMaker-specific methods /** * Set to true if ScriptableServiceQueryMaker should convert tracks which are in * fact playlists to Meta::MultiTrack instances to be playable. Defaults to false. */ void setConvertToMultiTracks( bool convert ); protected Q_SLOTS: void slotScriptComplete( ); private Q_SLOTS: void fetchGenre(); void fetchArtists(); void fetchAlbums(); void fetchTracks(); protected: void handleResult( const Meta::GenreList &genres ); void handleResult( const Meta::ArtistList &artists ); void handleResult( const Meta::AlbumList &albums ); void handleResult( const Meta::TrackList &tracks ); ScriptableServiceCollection * m_collection; AmarokProcIO * m_script; struct Private; Private * const d; QString m_sessionId; int m_parentAlbumId; int m_parentArtistId; private: QString m_name; bool m_convertToMultiTracks; }; } //namespace Collections #endif diff --git a/src/statemanagement/ApplicationController.h b/src/statemanagement/ApplicationController.h index fb3d0f001c..4d9065f133 100644 --- a/src/statemanagement/ApplicationController.h +++ b/src/statemanagement/ApplicationController.h @@ -1,39 +1,39 @@ /**************************************************************************************** * Copyright (c) 2010 Maximilian Kossick * * * * 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_APPLICATIONCONTROLLER_H #define AMAROK_APPLICATIONCONTROLLER_H #include namespace Amarok { class ApplicationController : public QObject { Q_OBJECT public: explicit ApplicationController( QObject *parent ) : QObject( parent ) {} - virtual ~ ApplicationController() {} + ~ ApplicationController() override {} public Q_SLOTS: virtual void start() = 0; virtual void shutdown() = 0; }; } #endif diff --git a/src/statsyncing/Controller.h b/src/statsyncing/Controller.h index 41f740a5eb..f69f02a684 100644 --- a/src/statsyncing/Controller.h +++ b/src/statsyncing/Controller.h @@ -1,246 +1,246 @@ /**************************************************************************************** * 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 STATSYNCING_CONTROLLER_H #define STATSYNCING_CONTROLLER_H #include "amarok_export.h" // for CollectionManager::CollectionStatus that cannot be fwd-declared #include "core-impl/collections/support/CollectionManager.h" #include #include #include #include class QTimer; namespace StatSyncing { class Config; class CreateProviderDialog; class Process; class Provider; typedef QSharedPointer ProviderPtr; typedef QList ProviderPtrList; class ProviderFactory; class ScrobblingService; typedef QSharedPointer ScrobblingServicePtr; /** * A singleton class that controls statistics synchronization and related tasks. */ class AMAROK_EXPORT Controller : public QObject { Q_OBJECT public: explicit Controller( QObject *parent = nullptr ); - ~Controller(); + ~Controller() override; /** * Return a list of Meta::val* fields that statistics synchronization can * actually synchronize. */ static QList availableFields(); /** * Register a StatSyncing::Provider with StatSyncing controller. This makes * it possible to synchronize provider with other providers. You don't need * to call this for Collections that are registered through CollectionManager * (and marked as enabled there) as it is done automatically. */ virtual void registerProvider( const ProviderPtr &provider ); /** * Forget about StatSyncing::Provider @p provider. * @param provider the provider */ virtual void unregisterProvider( const ProviderPtr &provider ); /** * Handle plugin factories derived from ProviderFactory, used for creating * multiple provider instances. This method is called by Amarok's plugin * infrastructure. */ void setFactories( const QList > &factories ); /** * Returns true if any instantiatable provider types are registered with the * controller. */ bool hasProviderFactories() const; /** * Returns true if the provider identified by @param id is configurable */ bool providerIsConfigurable( const QString &id ) const; /** * Returns a configuration dialog for a provider identified by @param id . * @returns 0 if there's no provider identified by id or the provider is not * configurable, otherwise a pointer to the dialog constructed as a child of * The::mainWindow */ QWidget *providerConfigDialog( const QString &id ) const; /** * Returns a provider creation dialog, prepopulated with registered provider * types. * @returns a pointer to the dialog constructed as a child of The::mainWindow, * and is a subclass of KAssistantDialog. * * @see StatSyncing::CreateProviderDialog */ QWidget *providerCreationDialog() const; /** * Register ScrobblingService with StatSyncing controller. Controller then * listens to EngineController and calls scrobble() etc. when user plays * tracks. Also allows scrobbling for tracks played on just connected iPods. * * @param service */ void registerScrobblingService( const ScrobblingServicePtr &service ); /** * Forget about ScrobblingService @param service */ void unregisterScrobblingService( const ScrobblingServicePtr &service ); /** * Return a list of currently registered scrobbling services (in arbitrary * order). */ QList scrobblingServices() const; /** * Return StatSyncing configuration object that describes enabled and * disabled statsyncing providers. You may not cache the pointer. */ Config *config(); public Q_SLOTS: /** * Start the whole synchronization machinery. This call returns quickly, * way before the synchronization is finished. */ void synchronize(); /** * Scrobble a track using all registered scrobbling services. They may check * certain criteria such as track length and refuse to scrobble the track. * * @param track track to scrobble * @param playedFraction fraction which has been actually played, or a number * greater than 1 if the track was played multiple times * (for example on a media device) * @param time time when it was played, invalid QDateTime signifies that the * track has been played just now. This is the default when the * parameter is omitted. */ void scrobble( const Meta::TrackPtr &track, double playedFraction = 1.0, const QDateTime &time = QDateTime() ); Q_SIGNALS: /** * Emitted when a track passed to scrobble() is successfully queued for * scrobbling submission. This signal is emitted for every scrobbling service. * For each service, you either get this or scrobbleFailed(). */ void trackScrobbled( const ScrobblingServicePtr &service, const Meta::TrackPtr &track ); /** * Emitted when a scrobbling service @p service was unable to scrobble() a track. * * @param service the service * @param track the track * @param error is a ScrobblingService::ScrobbleError enum value. */ void scrobbleFailed( const ScrobblingServicePtr &service, const Meta::TrackPtr &track, int error ); private Q_SLOTS: /** * Creates new instance of provider type identified by @param type * with configuration stored in @param config. */ void createProvider( const QString &type, const QVariantMap &config ); /** * Reconfigures provider identified by @param id with configuration * stored in @param config. */ void reconfigureProvider( const QString &id, const QVariantMap &config ); /** * Can only be connected to provider changed() signal */ void slotProviderUpdated(); /** * Wait a few seconds and if no collectionUpdate() signal arrives until then, * start synchronization. Otherwise postpone the synchronization for a few * seconds. */ void delayedStartSynchronization(); void slotCollectionAdded( Collections::Collection* collection, CollectionManager::CollectionStatus status ); void slotCollectionRemoved( const QString &id ); void startNonInteractiveSynchronization(); void synchronizeWithMode( int mode ); void slotTrackFinishedPlaying( const Meta::TrackPtr &track, double playedFraction ); void slotResetLastSubmittedNowPlayingTrack(); void slotUpdateNowPlayingWithCurrentTrack(); private: Q_DISABLE_COPY( Controller ) ProviderPtr findRegisteredProvider( const QString &id ) const; /** * Return true if important metadata of both tracks is equal. */ bool tracksVirtuallyEqual( const Meta::TrackPtr &first, const Meta::TrackPtr &second ); QMap > m_providerFactories; // synchronization-related ProviderPtrList m_providers; QPointer m_currentProcess; QTimer *m_startSyncingTimer; Config *m_config; /** * When a new collection appears, StatSyncing::Controller will automatically * trigger synchronization. It however waits s_syncingTriggerTimeout * milliseconds to let the collection settle down. Moreover, if the newly * added collection emits updated(), the timeout will run from start again. * * (reason: e.g. iPod Collection appears quickly, but with no tracks, which * are added gradually as they are parsed. This "ensures" we only start * syncing as soon as all tracks are parsed.) */ static const int s_syncingTriggerTimeout; // scrobbling-related QList m_scrobblingServices; QTimer *m_updateNowPlayingTimer; Meta::TrackPtr m_lastSubmittedNowPlayingTrack; }; } // namespace StatSyncing #endif // STATSYNCING_CONTROLLER_H diff --git a/src/statsyncing/Process.h b/src/statsyncing/Process.h index 6afc72eec9..b0b1f4a3b7 100644 --- a/src/statsyncing/Process.h +++ b/src/statsyncing/Process.h @@ -1,115 +1,115 @@ /**************************************************************************************** * 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 STATSYNCING_PROCESS_H #define STATSYNCING_PROCESS_H #include "statsyncing/Options.h" #include "statsyncing/Provider.h" #include #include #include #include #include #include class QDialog; namespace ThreadWeaver { class Job; } namespace StatSyncing { class ChooseProvidersPage; class MatchedTracksModel; class MatchedTracksPage; class ProvidersModel; /** * Class that is responsible for one synchronization process from track matching * to committing synchronized values back to storage. This class should live in a main * thread and is event-based. * * Process auto-deletes itself when it is done with its work. */ class Process : public QObject { Q_OBJECT public: enum Mode { Interactive, NonInteractive, }; /** * Creates the synchronization process that will offer user to synchronize * @p checkedFields of @p providers. If @p mode is Interactive, * introductory dialog will be shown that allows subset of fields and * providers to be chosen. Otherwise performs the syncing in the background * and shows a window only if conflict occurs. * @param providers the providers * @param preSelectedProviders the preselected providers * @param checkedFields the fields * @param mode the mode * @param parent the parent QObject */ Process( const ProviderPtrList &providers, const ProviderPtrSet &preSelectedProviders, qint64 checkedFields, Mode mode, QObject *parent = nullptr ); - virtual ~Process(); + ~Process() override; public Q_SLOTS: /** * Starts the process. */ void start(); /** * Raises and activates possible UI window related to this synchronization * process. */ void raise(); private Q_SLOTS: void slotMatchTracks(); void slotTracksMatched( ThreadWeaver::JobPointer job ); void slotBack(); void slotSynchronize(); void slotLogSynchronization( ThreadWeaver::JobPointer job ); void slotSaveSizeAndDelete(); void slotDeleteDialog(); private: Q_DISABLE_COPY( Process ) Mode m_mode; Options m_options; ProvidersModel *m_providersModel; qint64 m_checkedFields; MatchedTracksModel *m_matchedTracksModel; TrackList m_tracksToScrobble; // gets deleted when MainWindow is deleted QPointer m_dialog; QPointer m_providersPage; QPointer m_tracksPage; }; } // namespace StatSyncing #endif // STATSYNCING_PROCESS_H diff --git a/src/statsyncing/Provider.h b/src/statsyncing/Provider.h index 91e9167528..13c4350219 100644 --- a/src/statsyncing/Provider.h +++ b/src/statsyncing/Provider.h @@ -1,190 +1,190 @@ /**************************************************************************************** * 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 STATSYNCING_PROVIDER_H #define STATSYNCING_PROVIDER_H #include "amarok_export.h" #include "statsyncing/Track.h" #include #include #include #include #include #include namespace StatSyncing { /** * A widget class used for configuring providers. */ class AMAROK_EXPORT ProviderConfigWidget : public QWidget { Q_OBJECT public: explicit ProviderConfigWidget( QWidget *parent, Qt::WindowFlags f = {} ); - virtual ~ProviderConfigWidget(); + ~ProviderConfigWidget() override; /** * Return a QVariantMap holding configuration for the provider. Types stored * in QVariantMap must be supported by @see KConfigGroup . */ virtual QVariantMap config() const = 0; }; /** * A class that can provide tracks for statistics synchronization. It can be backed * by local Amarok collections or by online services such as Last.fm. * * Instances of subclasses are guaranteed to be created in the main thread. * Providers are memory-managed as explicitly shared data, always use ProviderPtr * to store a reference to Provider. */ class AMAROK_EXPORT Provider : public QObject { Q_OBJECT public: Provider(); - virtual ~Provider(); + ~Provider() override; /** * Unique identifier for this collection; may be used as a key to store * configuration; must be thread-safe */ virtual QString id() const = 0; /** * User-visible name of the provider; must be thread-safe */ virtual QString prettyName() const = 0; /** * User-visible short localized description. Default implementation returns * an empty string. */ virtual QString description() const; /** * Icon of this provider; must be thread-safe */ virtual QIcon icon() const = 0; /** * Return true if this provider can be reconfigured after creation. Returns * false by default. */ virtual bool isConfigurable() const; /** * Return a ProviderConfigWidget of configuration widget for this provider. * Returns a null pointer by default. Please note that Provider does *not* * retain ownership of this pointer, therefore should always return a new * instance. */ virtual ProviderConfigWidget *configWidget(); /** * Reconfigure the provider using configuration stored in @p config. * Does nothing by default. * * @param config the configuration */ virtual void reconfigure( const QVariantMap &config ); /** * Return binary OR of Meta::val* fields that this provider knows about its * tracks. Must include at least: Meta::valTitle, Meta::valArtist and * Meta::valAlbum. Optional fields: Meta::valComposer, Meta::valYear * Meta::valTrackNr and Meta::valDiscNr */ virtual qint64 reliableTrackMetaData() const = 0; /** * Return binary OR of Meta::val* fields that this provider can write back * to tracks. Choose a combination of: Meta::valRating, valFirstPlayed, * valLastPlayed, valPlaycount, valLabel. */ virtual qint64 writableTrackStatsData() const = 0; enum Preference { Never, /// never synchronize automatically NoByDefault, /// don't synchronize automatically by default Ask, /// ask on first appearance whether to synchronize by default YesByDefault /// enable auto syncing on first appearance without asking /// intended only for Local Collection }; /** * Return if this provider should participate in synchronization by * default even when the user does not actively add it. User can always * disable providers even if they are checked by default. */ virtual Preference defaultPreference() = 0; /** * Return a set of track artist names that appear in this provider. Multiple * artists differing just in letter case are allowed, or rather mandated, * because @see artistTracks() method is case-sensitive. * * This method must be called in non-main thread and is allowed to block for * a longer time; it must be implemented in a reentrant manner. */ virtual QSet artists() = 0; /** * Return a list of track delegates from (track) artist @param artistName that * appear in this provider; the matching should be performed CASE-SENSITIVELY * and should match the whole string, not just substring. If you have multiple * variants of the artist name differing just in letter case, you should * return all of the variants in @see artists(). * * This method must be called in non-main thread and is allowed to block for * a longer time; it must be implemented in a reentrant manner. */ virtual TrackList artistTracks( const QString &artistName ) = 0; /** * Write back statistics to the underlying storage for all updated tracks * managed by this provider that weren't yet saved. Default implementation * does nothing. * * Guaranteed to be (and must be) called from non-main thread. Can block for * a longer time. */ virtual void commitTracks(); Q_SIGNALS: /** * Emitted when some data such as prettyName() were updated. */ void updated(); }; typedef QSharedPointer ProviderPtr; typedef QList ProviderPtrList; typedef QSet ProviderPtrSet; /** * Container for a set of track frovider lists, one for each provider */ typedef QMap PerProviderTrackList; } // namespace StatSyncing #endif // STATSYNCING_PROVIDER_H diff --git a/src/statsyncing/ProviderFactory.h b/src/statsyncing/ProviderFactory.h index 80746fea3a..f57d18a9b6 100644 --- a/src/statsyncing/ProviderFactory.h +++ b/src/statsyncing/ProviderFactory.h @@ -1,85 +1,85 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_PROVIDER_FACTORY_H #define STATSYNCING_PROVIDER_FACTORY_H #include "amarok_export.h" #include "core/support/PluginFactory.h" #include #include #include namespace StatSyncing { class Provider; typedef QSharedPointer ProviderPtr; class ProviderConfigWidget; /** * A class allowing the creation of multiple providers of the same type. */ class AMAROK_EXPORT ProviderFactory : public Plugins::PluginFactory { Q_OBJECT public: ProviderFactory(); - virtual ~ProviderFactory(); + ~ProviderFactory() override; /** * A string that is unique to this provider factory. It may be used as a key * in associative structures. */ virtual QString type() const = 0; /** * The name of the type of created provider. This name will be displayed * in the provider creation dialog. */ virtual QString prettyName() const = 0; /** * User-visible short localized description. This is the default description * of created providers. Default implementation returns an empty string. */ virtual QString description() const; /** * The icon representing the type of created provider. This icon will be * displayed in the provider creation dialog, and is the default icon * of created providers. */ virtual QIcon icon() const = 0; /** * New instance of configuration widget for the provider. Please note that * ProviderFactory does *not* retain ownership of this pointer, therefore * should always return a new instance. */ virtual ProviderConfigWidget *createConfigWidget() = 0; /** * Create a new provider instance using configuration stored in @param config */ virtual ProviderPtr createProvider( const QVariantMap &config ) = 0; }; } // namespace StatSyncing #endif // STATSYNCING_PROVIDER_H diff --git a/src/statsyncing/ui/ChooseProvidersPage.h b/src/statsyncing/ui/ChooseProvidersPage.h index 6cdcb3eb3d..3edc175174 100644 --- a/src/statsyncing/ui/ChooseProvidersPage.h +++ b/src/statsyncing/ui/ChooseProvidersPage.h @@ -1,72 +1,72 @@ /**************************************************************************************** * 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 STATSYNCING_CHOOSEPROVIDERSPAGE_H #define STATSYNCING_CHOOSEPROVIDERSPAGE_H #include "ui_ChooseProvidersPage.h" namespace StatSyncing { class ProvidersModel; class ChooseProvidersPage : public QWidget, private Ui::ChooseProvidersPage { Q_OBJECT public: explicit ChooseProvidersPage( QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - virtual ~ChooseProvidersPage(); + ~ChooseProvidersPage() override; void setFields( const QList &fields, qint64 checkedFields ); qint64 checkedFields() const; /** * Sets the model of providers to choose from. ChooseProvidersPage does _not_ * take ownership of the model or the selection model. */ void setProvidersModel( ProvidersModel *model, QItemSelectionModel *selectionModel ); public Q_SLOTS: void disableControls(); void setProgressBarText( const QString &text ); void setProgressBarMaximum( int maximum ); void progressBarIncrementProgress(); Q_SIGNALS: void checkedFieldsChanged(); /** * Emitted when user clicks the Next button. */ void accepted(); /** * Emitted when user pushes the Cancel button. */ void rejected(); private Q_SLOTS: void updateMatchedLabel(); void updateEnabledFields(); void openConfiguration(); private: ProvidersModel *m_providersModel; }; } // namespace StatSyncing #endif // STATSYNCING_CHOOSEPROVIDERSPAGE_H diff --git a/src/statsyncing/ui/ConfigureProviderDialog.h b/src/statsyncing/ui/ConfigureProviderDialog.h index 915c86c11d..ca75ae33c5 100644 --- a/src/statsyncing/ui/ConfigureProviderDialog.h +++ b/src/statsyncing/ui/ConfigureProviderDialog.h @@ -1,55 +1,55 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_CONFIGURE_PROVIDER_DIALOG_H #define STATSYNCING_CONFIGURE_PROVIDER_DIALOG_H #include #include #include #include #include #include namespace StatSyncing { class ConfigureProviderDialog : public KPageDialog { Q_OBJECT public: explicit ConfigureProviderDialog( const QString &providerId, QWidget *configWidget, QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - virtual ~ConfigureProviderDialog(); + ~ConfigureProviderDialog() override; Q_SIGNALS: void providerConfigured( const QString &id, const QVariantMap &config ); private: QString m_providerId; QWidget *mainWidget; private Q_SLOTS: void slotAccepted(); }; } // namespace StatSyncing #endif // STATSYNCING_CONFIGURE_PROVIDER_DIALOG_H diff --git a/src/statsyncing/ui/CreateProviderDialog.h b/src/statsyncing/ui/CreateProviderDialog.h index b29ffe3450..08e82a52f1 100644 --- a/src/statsyncing/ui/CreateProviderDialog.h +++ b/src/statsyncing/ui/CreateProviderDialog.h @@ -1,67 +1,67 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 STATSYNCING_CREATE_PROVIDER_DIALOG_H #define STATSYNCING_CREATE_PROVIDER_DIALOG_H #include #include #include #include #include #include class QVBoxLayout; namespace StatSyncing { class ProviderConfigWidget; class CreateProviderDialog : public KAssistantDialog { Q_OBJECT public: explicit CreateProviderDialog( QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - virtual ~CreateProviderDialog(); + ~CreateProviderDialog() override; public Q_SLOTS: void addProviderType( const QString &id, const QString &prettyName, const QIcon &icon, ProviderConfigWidget *configWidget ); Q_SIGNALS: void providerConfigured( const QString &id, const QVariantMap &config ); private: int buttonInsertPosition( const QString &prettyName ); QButtonGroup m_providerButtons; QMap m_idForButton; QMap m_configForButton; KPageWidgetItem *m_providerTypePage; QVBoxLayout *m_layout; private Q_SLOTS: void providerButtonToggled( bool checked ); void slotAccepted(); }; } // namespace StatSyncing #endif // STATSYNCING_CREATE_PROVIDER_DIALOG_H diff --git a/src/statsyncing/ui/MatchedTracksPage.h b/src/statsyncing/ui/MatchedTracksPage.h index 7740fae46d..e5969d679a 100644 --- a/src/statsyncing/ui/MatchedTracksPage.h +++ b/src/statsyncing/ui/MatchedTracksPage.h @@ -1,121 +1,121 @@ /**************************************************************************************** * 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 STATSYNCING_MATCHEDTRACKSPAGE_H #define STATSYNCING_MATCHEDTRACKSPAGE_H #include "ui_MatchedTracksPage.h" #include "statsyncing/Provider.h" #include "statsyncing/ScrobblingService.h" class QSortFilterProxyModel; namespace StatSyncing { class MatchedTracksModel; class SortFilterProxyModel; class MatchedTracksPage : public QWidget, private Ui::MatchedTracksPage { Q_OBJECT public: explicit MatchedTracksPage( QWidget *parent = nullptr, Qt::WindowFlags f = {} ); - virtual ~MatchedTracksPage(); + ~MatchedTracksPage() override; /** * Set provider, you must call this before showing the widget. */ void setProviders( const ProviderPtrList &providers ); /** * Set matched tracks model. MatchedTracksPage does _not_ take ownership of * the pointer. */ void setMatchedTracksModel( MatchedTracksModel *model ); /** * Add unique tracks model. MatchedTracksPage does _not_ take ownership of the * model pointer. */ void addUniqueTracksModel( ProviderPtr provider, QAbstractItemModel *model ); /** * Add excluded tracks model. MatchedTracksPage does _not_ take ownership of * the model pointer. */ void addExcludedTracksModel( ProviderPtr provider, QAbstractItemModel *model ); /** * Set a list of tracks that are going to be scrobbled */ void setTracksToScrobble( const TrackList &tracksToScrobble, const QList &services ); Q_SIGNALS: /** * Emitted when user pushes the Back button. */ void back(); /** * Emitted when user clicks the Synchronize button. */ void accepted(); /** * Emitted when user pushes the Cancel button. */ void rejected(); private Q_SLOTS: void changeMatchedTracksFilter( int index ); void changeUniqueTracksProvider( int index ); void changeExcludedTracksProvider( int index ); void refreshMatchedStatusText(); void refreshUniqueStatusText(); void refreshExcludedStatusText(); void rememberExpandedState( const QModelIndex &parent, int start, int end ); void restoreExpandedState( const QModelIndex &parent, int start, int end ); void takeRatingsFrom(); void includeLabelsFrom(); void excludeLabelsFrom(); void expand( int onlyWithTupleFlags = -1 ); void collapse(); void openConfiguration(); private: void refreshStatusTextHelper( QSortFilterProxyModel *topModel, QLabel *label ); static void setHeaderSizePoliciesFromModel( QHeaderView *header, QAbstractItemModel *model ); Q_DISABLE_COPY( MatchedTracksPage ) QSet m_expandedTuples; SortFilterProxyModel *m_matchedProxyModel; QSortFilterProxyModel *m_uniqueProxyModel; QSortFilterProxyModel *m_excludedProxyModel; MatchedTracksModel *m_matchedTracksModel; QMap m_uniqueTracksModels; QMap m_excludedTracksModels; }; } // namespace StatSyncing #endif // STATSYNCING_MATCHEDTRACKSPAGE_H diff --git a/src/statusbar/KJobProgressBar.h b/src/statusbar/KJobProgressBar.h index b955bd3f9c..ef7d128e24 100644 --- a/src/statusbar/KJobProgressBar.h +++ b/src/statusbar/KJobProgressBar.h @@ -1,40 +1,40 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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_KJOB_PROGRESS_BAR_H #define AMAROK_KJOB_PROGRESS_BAR_H #include "statusbar/ProgressBar.h" #include /** * A specialized progress bar that takes a KJob in the constructor and keeps itself updated */ class KJobProgressBar : public ProgressBar { Q_OBJECT public: explicit KJobProgressBar( QWidget *parent, KJob * job ); - ~KJobProgressBar(); + ~KJobProgressBar() override; private Q_SLOTS: void updateJobStatus( KJob*, unsigned long ); void infoMessage( KJob*, const QString &plain, const QString &rich ); }; #endif diff --git a/src/statusbar/NetworkProgressBar.h b/src/statusbar/NetworkProgressBar.h index 5e133d94b5..147ae50fbb 100644 --- a/src/statusbar/NetworkProgressBar.h +++ b/src/statusbar/NetworkProgressBar.h @@ -1,40 +1,40 @@ /**************************************************************************************** * Copyright (c) 2010 Rick W. Chen * * * * 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_NETWORK_PROGRESS_BAR_H #define AMAROK_NETWORK_PROGRESS_BAR_H #include "statusbar/ProgressBar.h" #include /** * A specialized progress bar that takes a QNetworkReply in the constructor and keeps itself updated */ class NetworkProgressBar : public ProgressBar { Q_OBJECT public: explicit NetworkProgressBar( QWidget *parent, QNetworkReply *reply ); - ~NetworkProgressBar(); + ~NetworkProgressBar() override; private Q_SLOTS: void progressChanged( qint64 bytesChanged, qint64 bytesTotal ); void infoMessage( QNetworkReply::NetworkError code ); }; #endif diff --git a/src/statusbar/PopupWidget.h b/src/statusbar/PopupWidget.h index f85ffc86e7..f21df2f62a 100644 --- a/src/statusbar/PopupWidget.h +++ b/src/statusbar/PopupWidget.h @@ -1,31 +1,31 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 POPUPWIDGET_H #define POPUPWIDGET_H #include "widgets/BoxWidget.h" class PopupWidget : public BoxWidget { public: explicit PopupWidget( const QString &name = QString() ); - ~PopupWidget(); + ~PopupWidget() override; void reposition(); }; #endif diff --git a/src/statusbar/ProgressBar.h b/src/statusbar/ProgressBar.h index f626ad15c1..f81d933c92 100644 --- a/src/statusbar/ProgressBar.h +++ b/src/statusbar/ProgressBar.h @@ -1,83 +1,83 @@ /**************************************************************************************** * Copyright (c) 2008 Nikolaj Hald Nielsen * * * * 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 PROGRESSBAR_H #define PROGRESSBAR_H #include "amarok_export.h" #include #include #include #include #include #include #define POST_COMPLETION_DELAY 2000 /** * A widget that encapsulates a progress bar, a description string and a cancel button. */ class AMAROK_EXPORT ProgressBar : public QFrame { Q_OBJECT public: explicit ProgressBar( QWidget *parent ); - ~ProgressBar(); + ~ProgressBar() override; void setDescription( const QString &description ); template ProgressBar *setAbortSlot( Receiver receiver, Func slot, Qt::ConnectionType type = Qt::AutoConnection ) { cancelButton()->setHidden( false ); if( receiver ) connect( this, &ProgressBar::cancelled, receiver, slot, type ); connect( cancelButton(), &QAbstractButton::clicked, this, &ProgressBar::cancel ); return this; } QToolButton *cancelButton() { return m_cancelButton; } QProgressBar *progressBar() { return m_progressBar; } QLabel *descriptionLabel() { return m_descriptionLabel; } int maximum() { return m_progressBar->maximum(); } void setMaximum( int max ) { m_progressBar->setMaximum( max ); } int value() { return m_progressBar->value(); } void setValue( int value ); int percentage(); public Q_SLOTS: void cancel(); void delayedDone(); void slotTotalSteps( int steps ) { m_progressBar->setMaximum( steps ); } Q_SIGNALS: void cancelled( ProgressBar * ); void complete( ProgressBar * ); void percentageChanged( int ); private: QToolButton *m_cancelButton; QProgressBar *m_progressBar; QLabel *m_descriptionLabel; }; #endif diff --git a/src/synchronization/SynchronizationBaseJob.h b/src/synchronization/SynchronizationBaseJob.h index c7d406568f..06d281a509 100644 --- a/src/synchronization/SynchronizationBaseJob.h +++ b/src/synchronization/SynchronizationBaseJob.h @@ -1,122 +1,122 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 SYNCHRONIZATIONBASEJOB_H #define SYNCHRONIZATIONBASEJOB_H #include "core/meta/forward_declarations.h" #include "core/meta/support/MetaKeys.h" #include #include #include #include #include #include namespace Collections { class Collection; class QueryMaker; } class SynchronizationBaseJob : public QObject { Q_OBJECT public: enum State { NotStarted, ComparingArtists, ComparingAlbums, ComparingTracks, Syncing }; Q_ENUM( State ) enum InSet { OnlyInA, OnlyInB, InBoth }; Q_ENUM( InSet ) SynchronizationBaseJob(); - ~SynchronizationBaseJob(); + ~SynchronizationBaseJob() override; void setFilter( const QString &filter ); public Q_SLOTS: virtual void synchronize(); private Q_SLOTS: void slotTracksReady( const Meta::TrackList &artists ); void slotAlbumsReady( const Meta::AlbumList &albums ); void slotArtistsReady( const Meta::ArtistList &tracks ); void slotQueryDone(); void slotSyncTracks( const Meta::TrackList &tracks ); void slotSyncQueryDone(); void timeout(); protected: void setCollectionA( Collections::Collection *collection ); void setCollectionB( Collections::Collection *collection ); /** * perform the actual synchronization in this method. * SynchronizationBaseJob will delete itself afterwards. */ virtual void doSynchronization( const Meta::TrackList &tracks, InSet syncDirection, Collections::Collection *collA, Collections::Collection *collB ) = 0; private: Collections::QueryMaker* createQueryMaker( Collections::Collection *collection ); void handleAlbumResult(); void handleArtistResult(); void handleTrackResult(); private: Collections::QueryMaker* setupArtistQuery( Collections::Collection *coll ); Collections::QueryMaker* setupAlbumQuery( Collections::Collection *coll ); Collections::QueryMaker* setupTrackQuery( Collections::Collection *coll ); State m_state; int m_currentResultCount; Collections::Collection *m_collectionA; Collections::Collection *m_collectionB; /** All the query makers we created and the collection they belong to. */ QHash m_queryMakers; QSet m_artistsA; QSet m_artistsB; QSet m_albumsA; QSet m_albumsB; QSet m_tracksA; QSet m_tracksB; QHash m_keyToTrackA; QHash m_keyToTrackB; QHash m_artistResult; QHash m_albumResult; Meta::TrackList m_trackResultOnlyInA; Meta::TrackList m_trackResultOnlyInB; QTimer m_timer; }; #endif diff --git a/src/toolbar/CurrentTrackToolbar.h b/src/toolbar/CurrentTrackToolbar.h index 1e1d906d46..9c8188787d 100644 --- a/src/toolbar/CurrentTrackToolbar.h +++ b/src/toolbar/CurrentTrackToolbar.h @@ -1,37 +1,37 @@ /**************************************************************************************** * Copyright (c) 2009 Nikolaj Hald Nielsen * * * * 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 CURRENTTRACKTOOLBAR_H #define CURRENTTRACKTOOLBAR_H #include /** A toolbar that contains the CurrentTrackActions of the currently playing track. */ class CurrentTrackToolbar : public QToolBar { Q_OBJECT public: explicit CurrentTrackToolbar( QWidget * parent ); - ~CurrentTrackToolbar(); + ~CurrentTrackToolbar() override; protected Q_SLOTS: void handleAddActions(); }; #endif diff --git a/src/widgets/AlbumBreadcrumbWidget.h b/src/widgets/AlbumBreadcrumbWidget.h index 59ccf0d364..be39289f9b 100644 --- a/src/widgets/AlbumBreadcrumbWidget.h +++ b/src/widgets/AlbumBreadcrumbWidget.h @@ -1,66 +1,66 @@ /**************************************************************************************** * Copyright (c) 2010 Rick W. Chen * * * * 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_ALBUMBREADCRUMBWIDGET_H #define AMAROK_ALBUMBREADCRUMBWIDGET_H #include "core/meta/forward_declarations.h" #include "widgets/BoxWidget.h" class BreadcrumbItemButton; /** * This simple widget shows a breadcrumb-like display of one artist and one * album. Clicking on the artist or album emits signals containing their meta * objects and names. * * It looks like this: * \code * +-------------------------------+ * | > X artist > Y album | * +-------------------------------+ * where X and Y are generic artist and album icons respectively. * \endcode * * TODO: list artists/albums when clicking on the '>' to be more useful */ class AlbumBreadcrumbWidget : public BoxWidget { Q_OBJECT public: explicit AlbumBreadcrumbWidget( const Meta::AlbumPtr &album, QWidget *parent = nullptr ); - ~AlbumBreadcrumbWidget(); + ~AlbumBreadcrumbWidget() override; void setAlbum( const Meta::AlbumPtr &album ); Q_SIGNALS: void artistClicked( const QString& ); void albumClicked( const QString& ); private Q_SLOTS: void slotArtistClicked(); void slotAlbumClicked(); private: Meta::AlbumPtr m_album; BreadcrumbItemButton *m_artistButton; BreadcrumbItemButton *m_albumButton; void updateBreadcrumbs(); }; #endif /* AMAROK_ALBUMBREADCRUMBWIDGET_H */ diff --git a/src/widgets/BreadcrumbItemButton.h b/src/widgets/BreadcrumbItemButton.h index bfc4134e91..f3d809c0aa 100644 --- a/src/widgets/BreadcrumbItemButton.h +++ b/src/widgets/BreadcrumbItemButton.h @@ -1,105 +1,105 @@ /**************************************************************************************** * Copyright (c) 2006 Peter Penz * * Copyright (c) 2006 Aaron Seigo * * Copyright (c) 2009 Seb Ruiz * * * * 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 BREADCRUMBITEMBUTTON_P_H #define BREADCRUMBITEMBUTTON_P_H #include #include "widgets/ElidingButton.h" class QEvent; /** * @brief Base class for buttons of the URL navigator. * * Each button of the URL navigator contains an URL, which * is set as soon as the button has been clicked. */ class BreadcrumbItemButton : public Amarok::ElidingButton { Q_OBJECT public: explicit BreadcrumbItemButton( QWidget* parent ); BreadcrumbItemButton( const QString &text, QWidget *parent ); BreadcrumbItemButton( const QIcon &icon, const QString &text, QWidget *parent ); ~BreadcrumbItemButton() override; void setActive( const bool active ); QSize sizeHint() const override; protected: enum DisplayHint { ActiveHint = 1, HoverHint = 2 }; void setDisplayHintEnabled(DisplayHint hint, bool enable); bool isDisplayHintEnabled(DisplayHint hint) const; void enterEvent(QEvent* event) override; void leaveEvent(QEvent* event) override; void paintEvent(QPaintEvent* event) override; virtual void drawHoverBackground(QPainter* painter); /** Returns the foreground color by respecting the current display hint. */ QColor foregroundColor() const; private: void init(); int m_displayHint; }; class BreadcrumbItemMenuButton : public BreadcrumbItemButton { Q_OBJECT public: explicit BreadcrumbItemMenuButton( QWidget* parent ); ~BreadcrumbItemMenuButton() override { } protected: void paintEvent(QPaintEvent* event) override; }; class BreadcrumbUrlMenuButton : public BreadcrumbItemButton { Q_OBJECT public: BreadcrumbUrlMenuButton( const QString &urlsCommand, QWidget *parent ); - virtual ~BreadcrumbUrlMenuButton(); + ~BreadcrumbUrlMenuButton() override; public Q_SLOTS: void generateMenu( const QPoint &pos ); protected Q_SLOTS: void showMenu(); void copyCurrentToClipboard(); private: QString m_urlsCommand; QAction * m_copyToClipboardAction; }; #endif diff --git a/src/widgets/FilenameLayoutWidget.h b/src/widgets/FilenameLayoutWidget.h index f6b911edaf..943397f15a 100644 --- a/src/widgets/FilenameLayoutWidget.h +++ b/src/widgets/FilenameLayoutWidget.h @@ -1,152 +1,152 @@ /**************************************************************************************** * Copyright (c) 2008 Téo Mrnjavac * * Copyright (c) 2009 Daniel Dewald * * Copyright (c) 2012 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 FILENAMELAYOUTWIDGET_H #define FILENAMELAYOUTWIDGET_H #include "amarok_export.h" #include class Token; class TokenPool; class TokenDropTarget; class QStackedWidget; class QLabel; class QFrame; class QComboBox; class QPushButton; class QVBoxLayout; class QHBoxLayout; class QLineEdit; //Holds the TokenLayoutWidget and TokenPool and handles their interaction. Also holds a number of case and substitution options for the filename scheme. class AMAROK_EXPORT FilenameLayoutWidget : public QWidget { Q_OBJECT public: enum Type { Unknown = 0 , Ignore , TrackNumber , Title , Artist , Composer , Year , Album , AlbumArtist , Comment , Genre , FileType , Folder , Initial , DiscNumber , Space , Slash , Dot , Dash , Underscore , CollectionRoot }; explicit FilenameLayoutWidget( QWidget *parent = nullptr ); - virtual ~FilenameLayoutWidget() {} + ~FilenameLayoutWidget() override {} QString getParsableScheme() const; void setScheme( const QString &scheme ); public Q_SLOTS: virtual void onAccept(); Q_SIGNALS: /** emitted when either the scheme, option checkboxes or the replace edits change */ void schemeChanged(); private Q_SLOTS: void toggleAdvancedMode(); /* Updates the update preset button */ void slotUpdatePresetButton(); void slotFormatPresetSelected( int ); void slotAddFormat(); void slotRemoveFormat(); void slotUpdateFormat(); private: /** Set the advanced mode, blending out several "advanced" widgets */ void setAdvancedMode( bool isAdvanced ); /* Iterates over the elements of the TokenLayoutWidget bar (really over the elements of a QList that stores the indexes of the tokens) and generates a string that TagGuesser can digest. */ QString dropTargetScheme() const; /** Fills the m_dropTarget according to the given string scheme. */ void inferScheme( const QString &scheme ); bool m_advancedMode; protected: /** Set's several configuration options. Don't move this function to the constructor. It calls virtuals. */ void populateConfiguration(); /** Populates the preset combo box */ void populateFormatList( const QString &custom ); /** Saves the preset combo box */ void saveFormatList() const; virtual Token* createToken(qint64 value) const; /** Returns a styled token to be used in as pre and postfix on the schema editing line. */ virtual Token* createStaticToken(qint64 value) const; QVBoxLayout *m_mainLayout; QComboBox *m_presetCombo; QPushButton *m_addPresetButton; QPushButton *m_updatePresetButton; QPushButton *m_removePresetButton; QPushButton *m_advancedButton; TokenPool *m_tokenPool; QStackedWidget *m_schemeStack; QHBoxLayout *m_schemaLineLayout; TokenDropTarget *m_dropTarget; QLabel *m_syntaxLabel; QFrame *m_filenameLayout; QLineEdit *m_filenameLayoutEdit; /** The name of the category used for storing the configuration */ QString m_configCategory; }; #endif //FILENAMELAYOUTWIDGET_H diff --git a/src/widgets/HintLineEdit.h b/src/widgets/HintLineEdit.h index cacbede179..ad9bfc8961 100644 --- a/src/widgets/HintLineEdit.h +++ b/src/widgets/HintLineEdit.h @@ -1,46 +1,46 @@ /**************************************************************************************** * Copyright (c) 2006 Martin Aumueller * * * * 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 HINTLINEEDIT_H #define HINTLINEEDIT_H #include //baseclass class BoxWidget; class QLabel; class QWidget; class HintLineEdit : public QLineEdit { Q_OBJECT public: explicit HintLineEdit( const QString &hint, const QString &text, QWidget *parent = nullptr ); explicit HintLineEdit( const QString &text, QWidget *parent = nullptr ); explicit HintLineEdit( QWidget *parent = nullptr ); - virtual ~HintLineEdit(); + ~HintLineEdit() override; virtual QObject *parent(); virtual void setHint( const QString &hint ); private: void init(); BoxWidget *m_vbox; QLabel *m_hint; }; #endif diff --git a/src/widgets/MetaQueryWidget.h b/src/widgets/MetaQueryWidget.h index a83b10af1f..eb7a08aeb0 100644 --- a/src/widgets/MetaQueryWidget.h +++ b/src/widgets/MetaQueryWidget.h @@ -1,229 +1,229 @@ /**************************************************************************************** * Copyright (c) 2008 Daniel Caleb Jones * * Copyright (c) 2009 Mark Kretschmann * * Copyright (c) 2010 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) version 3 or * * any later version accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * * version 3 of the license. * * * * 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_METAQUERYWIDGET_H #define AMAROK_METAQUERYWIDGET_H #include #include #include "core/meta/forward_declarations.h" #include "core/meta/support/MetaConstants.h" #include #include class QHBoxLayout; class QLabel; class QVBoxLayout; namespace Collections { class QueryMaker; } /** * A class that allows to select a time distance. */ class TimeDistanceWidget : public QWidget { Q_OBJECT public: explicit TimeDistanceWidget( QWidget *parent = nullptr ); qint64 timeDistance() const; void setTimeDistance( qint64 value ); template void connectChanged( Receiver receiver, Func slot ) { connect( m_timeEdit, QOverload::of(&QSpinBox::valueChanged), receiver, slot ); connect( m_unitSelection, QOverload::of(&QComboBox::currentIndexChanged), receiver, slot ); } protected: QSpinBox *m_timeEdit; QComboBox *m_unitSelection; private Q_SLOTS: void slotUpdateComboBoxLabels( int value ); }; class MetaQueryWidget : public QWidget { Q_PROPERTY( bool hideFieldSelector READ isFieldSelectorHidden WRITE setFieldSelectorHidden ) Q_OBJECT public: /** Creates a MetaQueryWidget which can be used to select one meta query filter. * @param parent The parent widget * @param onlyNumeric If set to true the widget will only display numeric fields. * @param noCondition If set to true no condition can be selected. */ explicit MetaQueryWidget( QWidget* parent = nullptr, bool onlyNumeric = false, bool noCondition = false ); - ~MetaQueryWidget(); + ~MetaQueryWidget() override; enum FilterCondition { Equals = 0, GreaterThan = 1, LessThan = 2, Between = 3, OlderThan = 4, NewerThan = 5, Contains = 6 }; struct Filter { Filter() : m_field( 0 ) , numValue( 0 ) , numValue2( 0 ) , condition( Contains ) {} qint64 field() const { return m_field; } void setField( qint64 newField ); /** Returns a textual representation of the field. */ QString fieldToString() const; /** Returns a textual representation of the filter. * Used for the edit filter dialog (or for debugging) */ QString toString( bool invert = false ) const; bool isNumeric() const { return MetaQueryWidget::isNumeric( m_field ); } bool isDate() const { return MetaQueryWidget::isDate( m_field ); } /** Returns the minimum allowed value for the field type */ static qint64 minimumValue( quint64 field ); static qint64 maximumValue( quint64 field ); static qint64 defaultValue( quint64 field ); private: qint64 m_field; public: QString value; qint64 numValue; qint64 numValue2; FilterCondition condition; }; /** Returns the current filter value. */ Filter filter() const; /** Returns true if the given field is a numeric field */ static bool isNumeric( qint64 field ); /** Returns true if the given field is a date field */ static bool isDate( qint64 field ); /** Returns a localized text of the condition. * @param condition The condition * @param field Needed in order to test whether the field is a date, numeric or a string since the texts differ slightly */ static QString conditionToString( FilterCondition condition, qint64 field ); public Q_SLOTS: void setFilter(const MetaQueryWidget::Filter &value); void setField( const qint64 field ); /** Field Selector combo box visibility state */ bool isFieldSelectorHidden() const; void setFieldSelectorHidden( const bool hidden ); Q_SIGNALS: void changed(const MetaQueryWidget::Filter &value); private Q_SLOTS: void fieldChanged( int ); void compareChanged( int ); void valueChanged( const QString& ); void numValueChanged( int ); void numValue2Changed( int ); void numValueChanged( qint64 ); void numValue2Changed( qint64 ); void numValueChanged( const QTime& ); void numValue2Changed( const QTime& ); void numValueDateChanged(); void numValue2DateChanged(); void numValueTimeDistanceChanged(); void numValueFormatChanged( int ); void populateComboBox(const QStringList & ); void comboBoxPopulated(); private: void makeFieldSelection(); /** Adds the value selection widgets to the layout. * Adds m_compareSelection, m_valueSelection1, m_valueSelection2 to the layout. */ void setValueSelection(); void makeCompareSelection(); void makeValueSelection(); void makeGenericComboSelection( bool editable, Collections::QueryMaker* populateQuery ); void makeMetaComboSelection( qint64 field ); void makeFormatComboSelection(); void makeGenericNumberSelection( qint64 field, const QString& unit = QLatin1String("") ); void makePlaycountSelection(); void makeRatingSelection(); void makeLengthSelection(); void makeDateTimeSelection(); void makeFilenameSelection(); bool m_onlyNumeric; bool m_noCondition; bool m_settingFilter; // if set to true we are just setting the filter QVBoxLayout* m_layoutMain; QHBoxLayout* m_layoutValue; QVBoxLayout* m_layoutValueLabels; QVBoxLayout* m_layoutValueValues; QComboBox* m_fieldSelection; QLabel* m_andLabel; QComboBox* m_compareSelection; QWidget* m_valueSelection1; QWidget* m_valueSelection2; Filter m_filter; QMap< QObject*, QPointer > m_runningQueries; }; #endif diff --git a/src/widgets/StarManager.h b/src/widgets/StarManager.h index 443bf0e02c..aa5022ea0a 100644 --- a/src/widgets/StarManager.h +++ b/src/widgets/StarManager.h @@ -1,75 +1,75 @@ /**************************************************************************************** * Copyright (c) 2007 Jeff Mitchell * * * * 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_STAR_MANAGER_H #define AMAROK_STAR_MANAGER_H #include #include /** * TODO: only used in Osd.cpp, remove! We can paint stars using KRatingWidget */ class StarManager : public QObject { Q_OBJECT public: static StarManager *instance(); QPixmap* getStar( int num ); QPixmap* getGreyStar() { return &m_greyedStarPix; } QPixmap* getHalfStar( int num = -1 ); QImage& getStarImage( int num ); QImage& getGreyStarImage() { return m_greyedStar; } QImage& getHalfStarImage( int num = -1 ); bool setColor( int starNum, const QColor &color ); bool setHalfColor( const QColor &color ); void reinitStars( int height = -1, int margin = -1 ); Q_SIGNALS: void ratingsColorsChanged(); private: explicit StarManager( QObject* parent ); - ~StarManager(); + ~StarManager() override; static StarManager* s_instance; int m_height; int m_margin; //cached stars...why both? For faster conversion when drawing context browser QPixmap m_starPix; QImage m_star; QPixmap m_greyedStarPix; QImage m_greyedStar; QPixmap m_halfStarPix; QImage m_halfStar; QImage m_images[5]; QImage m_halfimages[5]; QPixmap m_pixmaps[5]; QPixmap m_halfpixmaps[5]; QColor m_colors[5]; QColor m_halfStarColor; }; #endif diff --git a/src/widgets/TrackSelectWidget.h b/src/widgets/TrackSelectWidget.h index 8898d326b2..4d98e49c5b 100644 --- a/src/widgets/TrackSelectWidget.h +++ b/src/widgets/TrackSelectWidget.h @@ -1,55 +1,55 @@ /**************************************************************************************** * Copyright (c) 2008-2010 Soren Harward * * * * 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_TRACK_SELECT_WIDGET_H #define AMAROK_TRACK_SELECT_WIDGET_H #include "core/meta/forward_declarations.h" #include "widgets/BoxWidget.h" #include class CollectionTreeItem; class CollectionTreeItemModel; class CollectionTreeView; class KSqueezedTextLabel; class TrackSelectWidget: public BoxWidget { Q_OBJECT public: explicit TrackSelectWidget( QWidget* parent ); - ~TrackSelectWidget(); + ~TrackSelectWidget() override; void setData( const Meta::DataPtr& ); Q_SIGNALS: void selectionChanged( const Meta::DataPtr& ); private Q_SLOTS: void recvNewSelection( CollectionTreeItem* ); private: CollectionTreeView* m_view; CollectionTreeItemModel* m_model; KSqueezedTextLabel* m_label; const QString dataToLabel( const Meta::DataPtr& ) const; }; #endif // AMAROK_TRACK_SELECT_WIDGET_H diff --git a/tests/MetaNotificationSpy.cpp b/tests/MetaNotificationSpy.cpp index 49a8b7bfdf..39d7719eb0 100644 --- a/tests/MetaNotificationSpy.cpp +++ b/tests/MetaNotificationSpy.cpp @@ -1,162 +1,162 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 . * ****************************************************************************************/ #include "MetaNotificationSpy.h" #include "core/meta/Meta.h" #include "core/meta/Observer.h" class MetaNotificationSpyPrivate : public Meta::Observer { public: MetaNotificationSpyPrivate() : Meta::Observer() {} - virtual ~MetaNotificationSpyPrivate() {} + ~MetaNotificationSpyPrivate() override {} virtual void metadataChanged( Meta::TrackPtr track ) { trackNotifications << track; } virtual void metadataChanged( Meta::ArtistPtr artist ) { artistNotifications << artist; } virtual void metadataChanged( Meta::AlbumPtr album ) { albumNotifications << album; } virtual void metadataChanged( Meta::GenrePtr genre ) { genreNotifications << genre; } virtual void metadataChanged( Meta::ComposerPtr composer ) { composerNotifications << composer; } virtual void metadataChanged( Meta::YearPtr year ) { yearNotifications << year; } Meta::TrackList trackNotifications; Meta::AlbumList albumNotifications; Meta::ArtistList artistNotifications; Meta::GenreList genreNotifications; Meta::ComposerList composerNotifications; Meta::YearList yearNotifications; }; MetaNotificationSpy::MetaNotificationSpy() : d( new MetaNotificationSpyPrivate() ) { //nothing to do } MetaNotificationSpy::MetaNotificationSpy( const Meta::TrackPtr &track ) : d( new MetaNotificationSpyPrivate() ) { d->subscribeTo( track ); } MetaNotificationSpy::MetaNotificationSpy( const Meta::AlbumPtr &album ) : d( new MetaNotificationSpyPrivate() ) { d->subscribeTo( album ); } MetaNotificationSpy::MetaNotificationSpy( const Meta::ArtistPtr &artist ) : d( new MetaNotificationSpyPrivate() ) { d->subscribeTo( artist ); } MetaNotificationSpy::MetaNotificationSpy( const Meta::ComposerPtr &composer ) : d( new MetaNotificationSpyPrivate() ) { d->subscribeTo( composer ); } MetaNotificationSpy::MetaNotificationSpy( const Meta::GenrePtr &genre ) : d( new MetaNotificationSpyPrivate() ) { d->subscribeTo( genre ); } MetaNotificationSpy::MetaNotificationSpy( const Meta::YearPtr &year ) : d( new MetaNotificationSpyPrivate() ) { d->subscribeTo( year ); } MetaNotificationSpy::~MetaNotificationSpy() { delete d; } void MetaNotificationSpy::subscribeTo(const Meta::AlbumPtr &album) { d->subscribeTo( album ); } void MetaNotificationSpy::subscribeTo(const Meta::ArtistPtr &artist) { d->subscribeTo( artist ); } void MetaNotificationSpy::subscribeTo(const Meta::ComposerPtr &composer) { d->subscribeTo( composer ); } void MetaNotificationSpy::subscribeTo(const Meta::GenrePtr &genre) { d->subscribeTo( genre ); } void MetaNotificationSpy::subscribeTo(const Meta::TrackPtr &track) { d->subscribeTo( track ); } void MetaNotificationSpy::subscribeTo(const Meta::YearPtr &year) { d->subscribeTo( year ); } Meta::TrackList MetaNotificationSpy::notificationsFromTracks() const { return d->trackNotifications; } Meta::AlbumList MetaNotificationSpy::notificationsFromAlbums() const { return d->albumNotifications; } Meta::ArtistList MetaNotificationSpy::notificationsFromArtists() const { return d->artistNotifications; } Meta::ComposerList MetaNotificationSpy::notificationsFromComposers() const { return d->composerNotifications; } Meta::GenreList MetaNotificationSpy::notificationsFromGenres() const { return d->genreNotifications; } Meta::YearList MetaNotificationSpy::notificationsFromYears() const { return d->yearNotifications; } diff --git a/tests/core-impl/collections/db/sql/TestSqlAlbum.h b/tests/core-impl/collections/db/sql/TestSqlAlbum.h index 4a964f2980..834b7dc8a6 100644 --- a/tests/core-impl/collections/db/sql/TestSqlAlbum.h +++ b/tests/core-impl/collections/db/sql/TestSqlAlbum.h @@ -1,68 +1,68 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 TESTSQLALBUM_H #define TESTSQLALBUM_H #include #include #include class MySqlEmbeddedStorage; class SqlRegistry; namespace Collections { class SqlCollection; } class TestSqlAlbum : public QObject { Q_OBJECT public: TestSqlAlbum(); - ~TestSqlAlbum(); + ~TestSqlAlbum() override; private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); void testTracks(); void testIsCompilation(); void testAlbumArtist(); void testImage(); void testCapabilities(); void testSetCompilationWithoutExistingCompilation(); void testSetCompilationWithExistingCompilation(); void testUnsetCompilationWithoutExistingAlbum(); void testUnsetCompilationWithExistingAlbum(); void testUnsetCompilationWithMultipleExistingAlbums(); void testUnsetCompilationWithArtistAFeaturingB(); void testUnsetCompilationWithMultipleArtists(); private: Collections::SqlCollection *m_collection; QSharedPointer m_storage; QTemporaryDir *m_tmpDir; }; #endif // TESTSQLALBUM_H diff --git a/tests/core/meta/TestMetaTrack.h b/tests/core/meta/TestMetaTrack.h index bcfb46bdbc..4becce84dd 100644 --- a/tests/core/meta/TestMetaTrack.h +++ b/tests/core/meta/TestMetaTrack.h @@ -1,82 +1,82 @@ /*************************************************************************** * Copyright (c) 2009 Sven Krohlas * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef TESTMETATRACK_H #define TESTMETATRACK_H #include "core/meta/forward_declarations.h" #include #include #include class TestMetaTrack : public QObject { Q_OBJECT public: TestMetaTrack(); - ~TestMetaTrack(); + ~TestMetaTrack() override; private Q_SLOTS: void initTestCase(); void testPrettyName(); void testPlayableUrl(); void testPrettyUrl(); void testUidUrl(); void testIsPlayable(); void testAlbum(); void testArtist(); void testComposer(); void testGenre(); void testYear(); void testComment(); void testSetAndGetScore(); void testSetAndGetRating(); void testLength(); void testFilesize(); void testSampleRate(); void testBitrate(); void testTrackNumber(); void testDiscNumber(); void testLastPlayed(); void testFirstPlayed(); void testPlayCount(); void testReplayGain(); void testType(); void testInCollection(); void testCollection(); void testSetAndGetCachedLyrics(); void testOperatorEquals(); void testLessThan(); private: Meta::TrackPtr m_testTrack1; Meta::TrackPtr m_testTrack2; QString m_trackPath; QTemporaryDir m_tempDir; QString dataPath( const QString &relPath ); }; #endif // TESTMETATRACK_H diff --git a/tests/core/meta/support/TestMetaAlbumKey.h b/tests/core/meta/support/TestMetaAlbumKey.h index 83576c8c2b..96a4c562eb 100644 --- a/tests/core/meta/support/TestMetaAlbumKey.h +++ b/tests/core/meta/support/TestMetaAlbumKey.h @@ -1,50 +1,50 @@ /**************************************************************************************** * Copyright (c) 2012 Jasneet Singh Bhatti * * 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 TESTMETAALBUMKEY_H #define TESTMETAALBUMKEY_H #include "core/meta/forward_declarations.h" #include class TestMetaAlbumKey : public QObject { Q_OBJECT public: - ~TestMetaAlbumKey(); + ~TestMetaAlbumKey() override; private Q_SLOTS: void initTestCase(); /** * Test constructor AlbumKey( const AlbumPtr &album ) */ void testAlbumKey(); void testOperatorAssignment(); void testOperatorLessThan(); private: /** * For portability in fetching tracks from disk */ QString dataPath( const QString &relPath ); Meta::TrackPtr m_track1, m_track2, m_track3; Meta::AlbumPtr m_album1, m_album2, m_album3; }; #endif // TESTMETAALBUMKEY_H diff --git a/tests/core/meta/support/TestPrivateMetaRegistry.h b/tests/core/meta/support/TestPrivateMetaRegistry.h index bb999ba87c..19a128440a 100644 --- a/tests/core/meta/support/TestPrivateMetaRegistry.h +++ b/tests/core/meta/support/TestPrivateMetaRegistry.h @@ -1,74 +1,74 @@ /**************************************************************************************** * Copyright (c) 2012 Jasneet Singh Bhatti * * 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 TESTPRIVATEMETAREGISTRY_H #define TESTPRIVATEMETAREGISTRY_H #include "core/meta/forward_declarations.h" #include using namespace Meta; class TestPrivateMetaRegistry : public QObject { Q_OBJECT public: - ~TestPrivateMetaRegistry(); + ~TestPrivateMetaRegistry() override; private Q_SLOTS: void initTestCase(); /** * Data driven testing */ void testInsertAlbum_data(); void testInsertAlbum(); void testInsertArtist_data(); void testInsertArtist(); void testInsertComposer_data(); void testInsertComposer(); void testInsertGenre_data(); void testInsertGenre(); void testInsertYear_data(); void testInsertYear(); /** * Test if the getters correctly return a pointer to null for a non-existing * combination of owner and key. * This is done in a separate method to avoid repetition of this verification * for each instance of the test data */ void testNull(); private: /** * For portability in fetching tracks from disk */ QString datapath( const QString &relPath ); /** * All _data() methods use this to create test data */ void createTestData(); /** * Test tracks required for generating test data */ TrackPtr m_track1, m_track2, m_track3, m_track4, m_track5; }; #endif // TESTPRIVATEMETAREGISTRY_H diff --git a/tests/importers/TestAmarokImporter.h b/tests/importers/TestAmarokImporter.h index 0591c9a343..a79a2d832b 100644 --- a/tests/importers/TestAmarokImporter.h +++ b/tests/importers/TestAmarokImporter.h @@ -1,53 +1,53 @@ /**************************************************************************************** * Copyright (c) 2013 Konrad Zemek * * * * 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 TEST_AMAROK_IMPORTER #define TEST_AMAROK_IMPORTER #include "TestImporterBase.h" #include class TestAmarokImporter : public TestImporterBase { Q_OBJECT private: QVariantMap m_cfg; protected: - virtual StatSyncing::ProviderPtr getProvider() override; - virtual StatSyncing::ProviderPtr getWritableProvider() override; - virtual qint64 reliableStatistics() const override; + StatSyncing::ProviderPtr getProvider() override; + StatSyncing::ProviderPtr getWritableProvider() override; + qint64 reliableStatistics() const override; private Q_SLOTS: void initTestCase(); void init(); void configWidgetShouldOnlyShowFieldsRelevantToConnection(); void configWidgetShouldNotSetDriver(); void configWidgetShouldShowExternalAsDefault(); void configWidgetShouldNotBreakOnNonsenseInitialValues(); void configWidgetShouldReadSavedConfig(); void providerShouldIgnoreConfigsDbDriver(); void providerShouldHandleNonexistentDbDir(); void providerShouldHandleInvalidDbDir(); void providerShouldHandleExternalConnectionError(); void providerShouldHandleErroneousConfigValues(); }; #endif // TEST_AMAROK_IMPORTER diff --git a/tests/mocks/MetaMock.h b/tests/mocks/MetaMock.h index 4c7c07ac51..4b46958b65 100644 --- a/tests/mocks/MetaMock.h +++ b/tests/mocks/MetaMock.h @@ -1,177 +1,177 @@ /**************************************************************************************** * Copyright (c) 2009 Maximilian Kossick * * * * 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 METAMOCK_H #define METAMOCK_H #include "core/meta/Meta.h" #include "core/meta/Statistics.h" #include "core/meta/support/MetaConstants.h" #include #include /** * This class provides simple mocks for meta classes. * it will look for the keys defined in meta/MetaConstants.h * in the given QVariantMap and return those values in the respective methods. */ class MetaMock : public Meta::Track, Meta::Statistics { public: MetaMock( const QVariantMap &data ) : Meta::Track(), m_data( data ), m_labels( Meta::LabelList() ) {} - virtual ~MetaMock() {} + ~MetaMock() override {} Meta::AlbumPtr album() const override { return m_album; } Meta::YearPtr year() const override { return m_year; } Meta::GenrePtr genre() const override { return m_genre; } Meta::ArtistPtr artist() const override { return m_artist; } Meta::ComposerPtr composer() const override { return m_composer; } QString name() const override { return m_data.value( Meta::Field::TITLE ).toString(); } QString prettyName() const override { return name(); } QUrl playableUrl() const override { return m_data.value( Meta::Field::URL ).value(); } QString prettyUrl() const override { return playableUrl().url(); } QString uidUrl() const override { return m_data.value( Meta::Field::UNIQUEID ).toString(); } QString notPlayableReason() const override { return QStringLiteral( "dummy reason" ); } QString comment() const override { return m_data.value( Meta::Field::COMMENT ).toString(); } qreal bpm() const override { return m_data.value( Meta::Field::BPM ).toDouble(); } qint64 length() const override { return m_data.value( Meta::Field::LENGTH ).toInt(); } int filesize() const override { return m_data.value( Meta::Field::FILESIZE ).toInt(); } int sampleRate() const override { return m_data.value( Meta::Field::SAMPLERATE ).toInt(); } int bitrate() const override { return m_data.value( Meta::Field::BITRATE ).toInt(); } QDateTime createDate() const override { return QDateTime(); } //field missing int trackNumber() const override { return m_data.value( Meta::Field::TRACKNUMBER ).toInt(); } int discNumber() const override { return m_data.value( Meta::Field::DISCNUMBER ).toInt(); } QString type() const override { return "Mock"; } Meta::LabelList labels() const override { return m_labels; } - virtual Meta::StatisticsPtr statistics() override { return Meta::StatisticsPtr( this ); } + Meta::StatisticsPtr statistics() override { return Meta::StatisticsPtr( this ); } // Meta::Statistics getters double score() const override { return m_data.value( Meta::Field::SCORE ).toDouble(); } int rating() const override { return m_data.value( Meta::Field::RATING ).toInt(); } QDateTime firstPlayed() const override { return m_data.value( Meta::Field::FIRST_PLAYED ).toDateTime(); } QDateTime lastPlayed() const override { return m_data.value( Meta::Field::LAST_PLAYED ).toDateTime(); } int playCount() const override { return m_data.value( Meta::Field::PLAYCOUNT ).toInt(); } // Meta::Statistics setters void setScore( double newScore ) override { m_data[Meta::Field::SCORE].setValue( newScore ); } void setRating( int newRating ) override { m_data[Meta::Field::RATING].setValue( newRating ); } void setFirstPlayed( const QDateTime &date ) override { m_data[Meta::Field::FIRST_PLAYED].setValue( date ); } void setLastPlayed( const QDateTime &date ) override { m_data[Meta::Field::LAST_PLAYED].setValue( date ); } void setPlayCount( int newPlayCount ) override { m_data[Meta::Field::PLAYCOUNT].setValue( newPlayCount ); } public: QVariantMap m_data; Meta::ArtistPtr m_artist; Meta::AlbumPtr m_album; Meta::GenrePtr m_genre; Meta::YearPtr m_year; Meta::ComposerPtr m_composer; Meta::LabelList m_labels; }; class MockYear : public Meta::Year { public: MockYear( const QString &name ) : Meta::Year() , m_name( name ) {} QString name() const override { return m_name; } QString prettyName() const override { return m_name; } Meta::TrackList tracks() override { return Meta::TrackList(); } QString m_name; }; class MockGenre : public Meta::Genre { public: MockGenre( const QString &name ) : Meta::Genre() , m_name( name ) {} QString name() const override { return m_name; } QString prettyName() const override { return m_name; } Meta::TrackList tracks() override { return Meta::TrackList(); } QString m_name; }; class MockComposer : public Meta::Composer { public: MockComposer( const QString &name ) : Meta::Composer() , m_name( name ) {} QString name() const override { return m_name; } QString prettyName() const override { return m_name; } Meta::TrackList tracks() override { return Meta::TrackList(); } QString m_name; }; class MockArtist : public Meta::Artist { public: MockArtist( const QString &name ) : Meta::Artist() , m_name( name ) {} QString name() const override { return m_name; } QString prettyName() const override { return m_name; } Meta::TrackList tracks() override { return Meta::TrackList(); } Meta::AlbumList albums() { return Meta::AlbumList(); } QString m_name; }; class MockAlbum : public Meta::Album { public: MockAlbum( const QString &name, const Meta::ArtistPtr &albumArtist = Meta::ArtistPtr() ) : Meta::Album() , m_name( name ) , m_albumArtist( albumArtist ) {} QString name() const override { return m_name; } QString prettyName() const override { return m_name; } Meta::TrackList tracks() override { return Meta::TrackList(); } bool hasAlbumArtist() const override { return ( m_albumArtist ) ? true : false; } Meta::ArtistPtr albumArtist() const override { return m_albumArtist; } bool isCompilation() const override { return !hasAlbumArtist(); } QString m_name; Meta::ArtistPtr m_albumArtist; }; class MockLabel : public Meta::Label { public: MockLabel( const QString &name ) : Meta::Label() , m_name( name ) {} QString name() const override { return m_name; } QString m_name; }; #endif // METAMOCK_H diff --git a/utilities/afttagger/AFTTagger.h b/utilities/afttagger/AFTTagger.h index 3c84f3fd0f..d4d3949204 100644 --- a/utilities/afttagger/AFTTagger.h +++ b/utilities/afttagger/AFTTagger.h @@ -1,75 +1,75 @@ /*************************************************************************** * Copyright (C) 2008-2009 Jeff Mitchell * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef AFTTAGGER_H #define AFTTAGGER_H #include #include #include #include #include #include #include #include #include #include #include /** * @class AFTTagger * @short Inserts AFT tags into directories and files */ class AFTTagger : public QCoreApplication { public: AFTTagger( int &argc, char **argv ); - ~AFTTagger() {} + ~AFTTagger() override {} void processPath( const QString &path ); bool handleMPEG( TagLib::MPEG::File *file ); bool handleMPC( TagLib::MPC::File *file ); bool handleMP4( TagLib::MP4::File *file ); bool handleOgg( TagLib::Ogg::File *file ); bool handleFLAC( TagLib::FLAC::File *file ); bool handleXiphComment( TagLib::Ogg::XiphComment *comment, TagLib::File *file ); QString createCurrentUID( TagLib::File *file ); QString createV1UID( TagLib::File *file ); QString upgradeUID( int version, const QString &currValue ); void readArgs(); void displayHelp(); bool m_delete; bool m_newid; bool m_quiet; bool m_recurse; bool m_verbose; QStringList m_fileFolderList; QTime m_time; QTextStream m_textStream; }; #endif // AFTTAGGER_H diff --git a/utilities/collectionscanner/CollectionScanner.h b/utilities/collectionscanner/CollectionScanner.h index 65cf99636d..472fe45f5c 100644 --- a/utilities/collectionscanner/CollectionScanner.h +++ b/utilities/collectionscanner/CollectionScanner.h @@ -1,99 +1,99 @@ /*************************************************************************** * Copyright (C) 2003-2010 Mark Kretschmann * * (C) 2008 Dan Meltzer * * (C) 2008-2009 Jeff Mitchell * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef COLLECTIONSCANNER_H #define COLLECTIONSCANNER_H #include "collectionscanner/ScanningState.h" #include #include #include #include #include namespace CollectionScanner { /** * @class Scanner * @short Scans directories and builds the Collection */ class Scanner : public QCoreApplication { Q_OBJECT public: Scanner( int &argc, char **argv ); - ~Scanner(); + ~Scanner() override; /** Reads the batch file and adds the content to m_folders and m_Times */ void readBatchFile( const QString &path ); /** Get's the modified time from the given file and set's m_newerTime according */ void readNewerTime( const QString &path ); private Q_SLOTS: void doJob(); private: void addDir( const QString& dir, QSet *entries ); /** Returns true if the track is modified. * Modification is determined first by m_mTimes and (if not found) * then by m_newerTime */ bool isModified( const QString& dir ); void readArgs(); /** Displays the error message and exits */ void error( const QString &str ); /** Displays the version and exits */ void displayVersion(); /** Displays the help and an optional error message and exits */ void displayHelp( const QString &error = QString() ); bool m_charset; QStringList m_folders; uint m_newerTime; QHash m_mTimes; bool m_incremental; bool m_recursively; bool m_restart; bool m_idlePriority; QString m_mtimeFile; ScanningState m_scanningState; // Disable copy constructor and assignment Scanner( const Scanner& ); Scanner& operator= ( const Scanner& ); }; } #endif // COLLECTIONSCANNER_H