Use override

This commit is contained in:
Jonas Kvinge
2020-06-15 21:55:05 +02:00
parent 72ede666d4
commit 651020388d
271 changed files with 1199 additions and 1231 deletions

View File

@@ -67,7 +67,7 @@ class Application : public QObject {
public:
explicit Application(QObject *parent = nullptr);
~Application();
~Application() override;
TagReaderClient *tag_reader_client() const;
Database *database() const;

View File

@@ -43,7 +43,7 @@ class Database : public QObject {
public:
explicit Database(Application *app, QObject *parent = nullptr, const QString &database_name = QString());
~Database();
~Database() override;
struct AttachedDatabase {
AttachedDatabase() {}
@@ -131,7 +131,7 @@ class MemoryDatabase : public Database {
public:
MemoryDatabase(Application *app, QObject *parent = nullptr)
: Database(app, parent, ":memory:") {}
~MemoryDatabase() {
~MemoryDatabase() override {
// Make sure Qt doesn't reuse the same database
QSqlDatabase::removeDatabase(Connect().connectionName());
}

View File

@@ -32,8 +32,8 @@ class DBusScreensaver : public Screensaver {
public:
explicit DBusScreensaver(const QString &service, const QString &path, const QString &interface);
void Inhibit();
void Uninhibit();
void Inhibit() override;
void Uninhibit() override;
private:
QString service_;

View File

@@ -44,7 +44,7 @@ DeleteFiles::DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage
original_thread_ = thread();
}
DeleteFiles::~DeleteFiles() {}
DeleteFiles::~DeleteFiles() = default;
void DeleteFiles::Start(const SongList &songs) {

View File

@@ -39,7 +39,7 @@ class DeleteFiles : public QObject {
public:
explicit DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage);
~DeleteFiles();
~DeleteFiles() override;
static const int kBatchSize;

View File

@@ -31,12 +31,11 @@
class FilesystemMusicStorage : public virtual MusicStorage {
public:
explicit FilesystemMusicStorage(const QString &root);
~FilesystemMusicStorage() {}
QString LocalPath() const { return root_; }
QString LocalPath() const override { return root_; }
bool CopyToStorage(const CopyJob &job);
bool DeleteFromStorage(const DeleteJob &job);
bool CopyToStorage(const CopyJob &job) override;
bool DeleteFromStorage(const DeleteJob &job) override;
private:
QString root_;

View File

@@ -28,8 +28,10 @@
class FileSystemWatcherInterface : public QObject {
Q_OBJECT
public:
explicit FileSystemWatcherInterface(QObject *parent = nullptr);
virtual void Init() {}
virtual void AddPath(const QString &path) = 0;
virtual void RemovePath(const QString &path) = 0;
@@ -37,7 +39,7 @@ class FileSystemWatcherInterface : public QObject {
static FileSystemWatcherInterface *Create(QObject *parent = nullptr);
signals:
signals:
void PathChanged(const QString &path);
};

View File

@@ -101,7 +101,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
public:
explicit MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, const CommandlineOptions& options, QWidget *parent = nullptr);
~MainWindow();
~MainWindow() override;
static const char *kSettingsGroup;
static const char *kAllFilesFilterSpec;
@@ -117,13 +117,13 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void CommandlineOptionsReceived(const CommandlineOptions& options);
protected:
void keyPressEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event);
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
void keyPressEvent(QKeyEvent *event) override;
void closeEvent(QCloseEvent *event) override;
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
// PlatformInterface
void Activate();
bool LoadUrl(const QString& url);
void Activate() override;
bool LoadUrl(const QString& url) override;
signals:
void AlbumCoverReady(const Song &song, const QImage &image);

View File

@@ -45,7 +45,7 @@ class MergedProxyModel : public QAbstractProxyModel {
public:
explicit MergedProxyModel(QObject *parent = nullptr);
~MergedProxyModel();
~MergedProxyModel() override;
// Make another model appear as a child of the given item in the source model.
void AddSubModel(const QModelIndex &source_parent, QAbstractItemModel *submodel);
@@ -56,33 +56,33 @@ class MergedProxyModel : public QAbstractProxyModel {
QModelIndex FindSourceParent(const QModelIndex &proxy_index) const;
// QAbstractItemModel
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &proxy_index, int role = Qt::DisplayRole) const;
bool hasChildren(const QModelIndex &parent) const;
QMap<int, QVariant> itemData(const QModelIndex &proxy_index) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QStringList mimeTypes() const;
QMimeData *mimeData(const QModelIndexList &indexes) const;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
bool canFetchMore(const QModelIndex &parent) const;
void fetchMore(const QModelIndex &parent);
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &child) const override;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &proxy_index, int role = Qt::DisplayRole) const override;
bool hasChildren(const QModelIndex &parent) const override;
QMap<int, QVariant> itemData(const QModelIndex &proxy_index) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) 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;
bool canFetchMore(const QModelIndex &parent) const override;
void fetchMore(const QModelIndex &parent) override;
// QAbstractProxyModel
// Note that these implementations of map{To,From}Source will not always give you an index in sourceModel(),
// you might get an index in one of the child models instead.
QModelIndex mapFromSource(const QModelIndex &source_index) const;
QModelIndex mapToSource(const QModelIndex &proxy_index) const;
void setSourceModel(QAbstractItemModel *source_model);
QModelIndex mapFromSource(const QModelIndex &source_index) const override;
QModelIndex mapToSource(const QModelIndex &proxy_index) const override;
void setSourceModel(QAbstractItemModel *source_model) override;
// Convenience functions that call map{To,From}Source multiple times.
QModelIndexList mapFromSource(const QModelIndexList &source_indexes) const;
QModelIndexList mapToSource(const QModelIndexList &proxy_indexes) const;
signals:
signals:
void SubModelReset(const QModelIndex &root, QAbstractItemModel *model);
private slots:

View File

@@ -37,7 +37,7 @@ class MultiSortFilterProxy : public QSortFilterProxyModel {
void AddSortSpec(int role, Qt::SortOrder order = Qt::AscendingOrder);
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
private:
int Compare(const QVariant &left, const QVariant &right) const;

View File

@@ -20,4 +20,4 @@
#include "musicstorage.h"
MusicStorage::MusicStorage() {}
MusicStorage::MusicStorage() = default;

View File

@@ -37,7 +37,7 @@
class MusicStorage {
public:
explicit MusicStorage();
virtual ~MusicStorage() {}
virtual ~MusicStorage() = default;
enum Role {
Role_Storage = Qt::UserRole + 100,

View File

@@ -44,23 +44,23 @@ class NetworkAccessManager : public QNetworkAccessManager {
explicit NetworkAccessManager(QObject *parent = nullptr);
protected:
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData);
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) override;
};
class ThreadSafeNetworkDiskCache : public QAbstractNetworkCache {
public:
explicit ThreadSafeNetworkDiskCache(QObject *parent);
~ThreadSafeNetworkDiskCache();
~ThreadSafeNetworkDiskCache() override;
qint64 cacheSize() const;
QIODevice *data(const QUrl &url);
void insert(QIODevice *device);
QNetworkCacheMetaData metaData(const QUrl &url);
QIODevice *prepare(const QNetworkCacheMetaData &metaData);
bool remove(const QUrl &url);
void updateMetaData(const QNetworkCacheMetaData &metaData);
qint64 cacheSize() const override;
QIODevice *data(const QUrl &url) override;
void insert(QIODevice *device) override;
QNetworkCacheMetaData metaData(const QUrl &url) override;
QIODevice *prepare(const QNetworkCacheMetaData &metaData) override;
bool remove(const QUrl &url) override;
void updateMetaData(const QNetworkCacheMetaData &metaData) override;
void clear();
void clear() override;
private:
static QMutex sMutex;

View File

@@ -41,7 +41,7 @@ class NetworkProxyFactory : public QNetworkProxyFactory {
// These methods are thread-safe
void ReloadSettings();
QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query);
QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query) override;
private:
explicit NetworkProxyFactory();

View File

@@ -40,7 +40,7 @@ class NetworkTimeouts : public QObject {
void SetTimeout(int msec) { timeout_msec_ = msec; }
protected:
void timerEvent(QTimerEvent *e);
void timerEvent(QTimerEvent *e) override;
private slots:
void ReplyFinished();

View File

@@ -130,23 +130,23 @@ class Player : public PlayerInterface {
Q_OBJECT
public:
Player(Application *app, QObject *parent);
~Player();
explicit Player(Application *app, QObject *parent);
~Player() override;
static const char *kSettingsGroup;
Engine::EngineType CreateEngine(Engine::EngineType enginetype);
void Init();
EngineBase *engine() const { return engine_.get(); }
Engine::State GetState() const { return last_state_; }
int GetVolume() const;
EngineBase *engine() const override { return engine_.get(); }
Engine::State GetState() const override{ return last_state_; }
int GetVolume() const override;
PlaylistItemPtr GetCurrentItem() const { return current_item_; }
PlaylistItemPtr GetItemAt(int pos) const;
PlaylistItemPtr GetCurrentItem() const override { return current_item_; }
PlaylistItemPtr GetItemAt(int pos) const override;
void RegisterUrlHandler(UrlHandler *handler);
void UnregisterUrlHandler(UrlHandler *handler);
void RegisterUrlHandler(UrlHandler *handler) override;
void UnregisterUrlHandler(UrlHandler *handler) override;
const UrlHandler *HandlerForUrl(const QUrl &url) const;
@@ -156,29 +156,29 @@ class Player : public PlayerInterface {
void SetEqualizer(Equalizer *equalizer) { equalizer_ = equalizer; }
public slots:
void ReloadSettings();
void ReloadSettings() override;
void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle);
void PlayPause();
void RestartOrPrevious();
void Next();
void Previous();
void SetVolume(int value);
void VolumeUp() { SetVolume(GetVolume() + 5); }
void VolumeDown() { SetVolume(GetVolume() - 5); }
void SeekTo(int seconds);
void SeekForward();
void SeekBackward();
void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) override;
void PlayPause() override;
void RestartOrPrevious() override;
void Next() override;
void Previous() override;
void SetVolume(int value) override;
void VolumeUp() override { SetVolume(GetVolume() + 5); }
void VolumeDown() override { SetVolume(GetVolume() - 5); }
void SeekTo(int seconds) override;
void SeekForward() override;
void SeekBackward() override;
void CurrentMetadataChanged(const Song &metadata);
void CurrentMetadataChanged(const Song &metadata) override;
void Mute();
void Pause();
void Stop(bool stop_after = false);
void Mute() override;
void Pause() override;
void Stop(bool stop_after = false) override;
void StopAfterCurrent();
void IntroPointReached();
void Play();
void ShowOSD();
void Play() override;
void ShowOSD() override;
void TogglePrettyOSD();
void HandleAuthentication();

View File

@@ -28,7 +28,7 @@
class PoTranslator : public QTranslator {
public:
QString translate(const char *context, const char *source_text, const char *disambiguation = 0, int n = -1) const {
QString translate(const char *context, const char *source_text, const char *disambiguation = 0, int n = -1) const override {
Q_UNUSED(n);
QString ret = QTranslator::translate(context, source_text, disambiguation);
if (!ret.isEmpty()) return ret;

View File

@@ -31,11 +31,12 @@
class QtFSListener : public FileSystemWatcherInterface {
Q_OBJECT
public:
explicit QtFSListener(QObject *parent);
virtual void AddPath(const QString &path);
virtual void RemovePath(const QString &path);
virtual void Clear();
void AddPath(const QString &path) override;
void RemovePath(const QString &path) override;
void Clear() override;
private:
QFileSystemWatcher watcher_;

View File

@@ -44,32 +44,32 @@ class QtSystemTrayIcon : public SystemTrayIcon {
public:
QtSystemTrayIcon(QObject *parent = nullptr);
~QtSystemTrayIcon();
~QtSystemTrayIcon() override;
void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *love, QAction *quit);
bool IsVisible() const;
void SetVisible(bool visible);
void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *love, QAction *quit) override;
bool IsVisible() const override;
void SetVisible(bool visible) override;
void ShowPopup(const QString &summary, const QString &message, int timeout);
void ShowPopup(const QString &summary, const QString &message, int timeout) override;
void SetNowPlaying(const Song &song, const QUrl &cover_url);
void ClearNowPlaying();
void SetNowPlaying(const Song &song, const QUrl &cover_url) override;
void ClearNowPlaying() override;
bool MuteEnabled() { return action_mute_->isVisible(); }
void SetMuteEnabled(bool enabled) { action_mute_->setVisible(enabled); }
bool MuteEnabled() const override { return action_mute_->isVisible(); }
void SetMuteEnabled(bool enabled) override { action_mute_->setVisible(enabled); }
protected:
// SystemTrayIcon
void UpdateIcon();
void SetPaused();
void SetPlaying(bool enable_play_pause = false);
void SetStopped();
void MuteButtonStateChanged(bool value);
void LoveVisibilityChanged(bool value);
void LoveStateChanged(bool value);
void UpdateIcon() override;
void SetPaused() override;
void SetPlaying(bool enable_play_pause = false) override;
void SetStopped() override;
void MuteButtonStateChanged(bool value) override;
void LoveVisibilityChanged(bool value) override;
void LoveStateChanged(bool value) override;
// QObject
bool eventFilter(QObject *, QEvent *);
bool eventFilter(QObject*, QEvent*) override;
private slots:
void Clicked(QSystemTrayIcon::ActivationReason);

View File

@@ -46,17 +46,17 @@ class DefaultSettingsProvider : public SettingsProvider {
public:
DefaultSettingsProvider();
void set_group(const char* group);
void set_group(const char* group) override;
QVariant value(const QString &key, const QVariant &default_value = QVariant()) const;
void setValue(const QString &key, const QVariant &value);
int beginReadArray(const QString &prefix);
void beginWriteArray(const QString &prefix, int size = -1);
void setArrayIndex(int i);
void endArray();
QVariant value(const QString &key, const QVariant &default_value = QVariant()) const override;
void setValue(const QString &key, const QVariant &value) override;
int beginReadArray(const QString &prefix) override;
void beginWriteArray(const QString &prefix, int size = -1) override;
void setArrayIndex(int i) override;
void endArray() override;
private:
QSettings backend_;
};
#endif // SETTINGSPROVIDER_H
#endif // SETTINGSPROVIDER_H

View File

@@ -29,17 +29,17 @@
template <typename T>
class SimpleTreeModel : public QAbstractItemModel {
public:
explicit SimpleTreeModel(T *root = 0, QObject *parent = nullptr);
virtual ~SimpleTreeModel() {}
explicit SimpleTreeModel(T *root = nullptr, QObject *parent = nullptr);
~SimpleTreeModel() override {}
// QAbstractItemModel
int columnCount(const QModelIndex &parent) const;
QModelIndex index(int row, int, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent) const;
bool hasChildren(const QModelIndex &parent) const;
bool canFetchMore(const QModelIndex &parent) const;
void fetchMore(const QModelIndex &parent);
int columnCount(const QModelIndex &parent) const override;
QModelIndex index(int row, int, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent) const override;
bool hasChildren(const QModelIndex &parent) const override;
bool canFetchMore(const QModelIndex &parent) const override;
void fetchMore(const QModelIndex &parent) override;
T *IndexToItem(const QModelIndex &index) const;
QModelIndex ItemToIndex(T *item) const;

View File

@@ -58,7 +58,7 @@ class SongLoader : public QObject {
Q_OBJECT
public:
explicit SongLoader(CollectionBackendInterface *collection, const Player *player, QObject *parent = nullptr);
~SongLoader();
~SongLoader() override;
enum Result {
Success,

View File

@@ -46,7 +46,7 @@ class StyleSheetLoader : public QObject {
void SetStyleSheet(QWidget *widget, const QString& filename);
protected:
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
private:
struct StyleSheetData {

View File

@@ -50,7 +50,7 @@ class SystemTrayIcon : public QObject {
virtual void SetNowPlaying(const Song &song, const QUrl &cover_url) { Q_UNUSED(song); Q_UNUSED(cover_url); }
virtual void ClearNowPlaying() {}
virtual bool MuteEnabled() { return false; }
virtual bool MuteEnabled() const { return false; }
virtual void SetMuteEnabled(bool enabled) { Q_UNUSED(enabled); }
static SystemTrayIcon *CreateSystemTrayIcon(QObject *parent = nullptr);

View File

@@ -34,7 +34,7 @@ class Thread : public QThread {
void SetIoPriority(Utilities::IoPriority priority) {
io_priority_ = priority;
}
virtual void run() override;
void run() override;
private:
Utilities::IoPriority io_priority_;

View File

@@ -28,7 +28,7 @@ class QTranslator;
class Translations : public QObject {
public:
explicit Translations();
~Translations();
~Translations() override;
void LoadTranslation(const QString &prefix, const QString &path, const QString &language);
private: