From 0af1470ccea5407f6cd848af4b20680e058335c7 Mon Sep 17 00:00:00 2001 From: Krzysztof Sobiecki Date: Sat, 1 Nov 2014 19:26:05 +0100 Subject: [PATCH] Clean up src/core --- src/core/appearance.h | 8 ++++---- src/core/application.h | 10 ++++----- src/core/backgroundstreams.cpp | 18 +++++++++++++++++ src/core/backgroundstreams.h | 29 ++++++++++++++++++++++----- src/core/boundfuturewatcher.h | 23 ++++++++++++++++++--- src/core/cachedlist.h | 6 +++--- src/core/commandlineoptions.h | 6 +++--- src/core/crashreporting.h | 8 ++++---- src/core/database.cpp | 14 ++++++------- src/core/database.h | 25 +++++++++++------------ src/core/deletefiles.h | 8 ++++---- src/core/fht.cpp | 14 ++++++------- src/core/fht.h | 8 ++++---- src/core/filesystemmusicstorage.cpp | 2 +- src/core/filesystemmusicstorage.h | 8 ++++---- src/core/filesystemwatcherinterface.h | 10 ++++----- src/core/globalshortcutbackend.h | 10 ++++----- src/core/globalshortcuts.h | 10 ++++----- src/core/gnomeglobalshortcutbackend.h | 8 ++++---- src/core/mac_delegate.h | 17 ++++++++++++++++ src/core/mac_startup.h | 20 +++++++++++++++++- src/core/macfslistener.h | 8 ++++---- src/core/macglobalshortcutbackend.h | 8 ++++---- src/core/mergedproxymodel.cpp | 4 ++-- src/core/mergedproxymodel.h | 10 ++++----- src/core/metatypes.cpp | 21 +++++++++++++++++++ src/core/metatypes.h | 23 ++++++++++++++++++--- src/core/mimedata.h | 6 +++--- src/core/modelfuturewatcher.h | 23 ++++++++++++++++++--- src/core/mpris.h | 8 ++++---- src/core/mpris1.h | 10 ++++----- src/core/mpris2.cpp | 14 ++++++------- src/core/mpris2.h | 8 ++++---- src/core/mpris_common.h | 6 +++--- src/core/multisortfilterproxy.cpp | 18 +++++++++++++++++ src/core/multisortfilterproxy.h | 26 ++++++++++++++++++++---- src/core/musicstorage.h | 6 +++--- src/core/network.h | 14 ++++++------- src/core/networkproxyfactory.cpp | 19 ++++++++++++++++++ src/core/networkproxyfactory.h | 24 +++++++++++++++++++--- src/core/organise.cpp | 5 ++--- src/core/organise.h | 8 ++++---- src/core/organiseformat.cpp | 2 +- src/core/organiseformat.h | 8 ++++---- src/core/player.h | 10 ++++----- src/core/potranslator.h | 6 +++--- src/core/qhash_qurl.h | 6 +++--- src/core/qtfslistener.h | 8 ++++---- src/core/qxtglobalshortcutbackend.h | 8 ++++---- src/core/settingsprovider.h | 6 +++--- src/core/signalchecker.h | 6 +++--- src/core/simpletreeitem.h | 6 +++--- src/core/simpletreemodel.h | 6 +++--- src/core/song.cpp | 8 ++++---- src/core/song.h | 6 +++--- src/core/songloader.cpp | 9 +++++---- src/core/songloader.h | 11 +++++----- src/core/stylesheetloader.h | 8 ++++---- src/core/tagreaderclient.h | 10 ++++----- src/core/taskmanager.h | 10 ++++----- src/core/timeconstants.h | 6 +++--- src/core/ubuntuunityhack.h | 8 ++++---- src/core/urlhandler.h | 14 ++++++------- src/core/utilities.cpp | 18 ++++++++--------- src/core/utilities.h | 12 +++++------ 65 files changed, 470 insertions(+), 253 deletions(-) diff --git a/src/core/appearance.h b/src/core/appearance.h index e7fb36d0d..500835ed8 100644 --- a/src/core/appearance.h +++ b/src/core/appearance.h @@ -15,15 +15,15 @@ along with Clementine. If not, see . */ -#ifndef APPEARANCE_H -#define APPEARANCE_H +#ifndef CORE_APPEARANCE_H_ +#define CORE_APPEARANCE_H_ #include #include class Appearance : public QObject { public: - Appearance(QObject* parent = nullptr); + explicit Appearance(QObject* parent = nullptr); // Load the user preferred theme, which could the default system theme or a // custom set of colors that user has chosen void LoadUserTheme(); @@ -42,4 +42,4 @@ class Appearance : public QObject { QColor background_color_; }; -#endif // APPEARANCE_H +#endif // CORE_APPEARANCE_H_ diff --git a/src/core/application.h b/src/core/application.h index 27fdc73ea..3a45d479b 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef APPLICATION_H -#define APPLICATION_H +#ifndef CORE_APPLICATION_H_ +#define CORE_APPLICATION_H_ #include "ui/settingsdialog.h" @@ -54,7 +54,7 @@ class Application : public QObject { public: static bool kIsPortable; - Application(QObject* parent = nullptr); + explicit Application(QObject* parent = nullptr); ~Application(); const QString& language_name() const { return language_name_; } @@ -100,7 +100,7 @@ class Application : public QObject { void ReloadSettings(); void OpenSettingsDialogAtPage(SettingsDialog::Page page); -signals: + signals: void ErrorAdded(const QString& message); void SettingsChanged(); void SettingsDialogRequested(SettingsDialog::Page page); @@ -136,4 +136,4 @@ signals: QList threads_; }; -#endif // APPLICATION_H +#endif // CORE_APPLICATION_H_ diff --git a/src/core/backgroundstreams.cpp b/src/core/backgroundstreams.cpp index 8fd961582..09005404a 100644 --- a/src/core/backgroundstreams.cpp +++ b/src/core/backgroundstreams.cpp @@ -1,3 +1,21 @@ +/* This file is part of Clementine. + Copyright 2010-2013, David Sansome + Copyright 2010-2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + #include "backgroundstreams.h" #include diff --git a/src/core/backgroundstreams.h b/src/core/backgroundstreams.h index 6bd03bba9..6dbfe8089 100644 --- a/src/core/backgroundstreams.h +++ b/src/core/backgroundstreams.h @@ -1,5 +1,23 @@ -#ifndef BACKGROUNDSTREAMS_H -#define BACKGROUNDSTREAMS_H +/* This file is part of Clementine. + Copyright 2010-2013, David Sansome + Copyright 2010-2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef CORE_BACKGROUNDSTREAMS_H_ +#define CORE_BACKGROUNDSTREAMS_H_ #include #include @@ -12,8 +30,9 @@ class QAction; class BackgroundStreams : public QObject { Q_OBJECT + public: - explicit BackgroundStreams(EngineBase* engine, QObject* parent = nullptr); + BackgroundStreams(EngineBase* engine, QObject* parent = nullptr); ~BackgroundStreams(); void LoadStreams(); @@ -29,7 +48,7 @@ class BackgroundStreams : public QObject { void AddAction(const QString& name, QAction* action); -signals: + signals: void StreamStarted(const QString& name); void StreamStopped(const QString& name); @@ -65,4 +84,4 @@ signals: static const char* kEnterpriseUrl; }; -#endif +#endif // CORE_BACKGROUNDSTREAMS_H_ diff --git a/src/core/boundfuturewatcher.h b/src/core/boundfuturewatcher.h index ba238ad84..7981cf57b 100644 --- a/src/core/boundfuturewatcher.h +++ b/src/core/boundfuturewatcher.h @@ -1,5 +1,22 @@ -#ifndef BOUNDFUTUREWATCHER_H -#define BOUNDFUTUREWATCHER_H +/* This file is part of Clementine. + Copyright 2010-2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef CORE_BOUNDFUTUREWATCHER_H_ +#define CORE_BOUNDFUTUREWATCHER_H_ #include @@ -19,4 +36,4 @@ class BoundFutureWatcher : public QFutureWatcher, boost::noncopyable { D data_; }; -#endif +#endif // CORE_BOUNDFUTUREWATCHER_H_ diff --git a/src/core/cachedlist.h b/src/core/cachedlist.h index ca81c184e..49332aed6 100644 --- a/src/core/cachedlist.h +++ b/src/core/cachedlist.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef CACHEDLIST_H -#define CACHEDLIST_H +#ifndef CORE_CACHEDLIST_H_ +#define CORE_CACHEDLIST_H_ #include #include @@ -98,4 +98,4 @@ class CachedList { ListType data_; }; -#endif // CACHEDLIST_H +#endif // CORE_CACHEDLIST_H_ diff --git a/src/core/commandlineoptions.h b/src/core/commandlineoptions.h index 60bef1042..c4eba7a10 100644 --- a/src/core/commandlineoptions.h +++ b/src/core/commandlineoptions.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef COMMANDLINEOPTIONS_H -#define COMMANDLINEOPTIONS_H +#ifndef CORE_COMMANDLINEOPTIONS_H_ +#define CORE_COMMANDLINEOPTIONS_H_ #include #include @@ -114,4 +114,4 @@ class CommandlineOptions { QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a); QDataStream& operator>>(QDataStream& s, CommandlineOptions& a); -#endif // COMMANDLINEOPTIONS_H +#endif // CORE_COMMANDLINEOPTIONS_H_ diff --git a/src/core/crashreporting.h b/src/core/crashreporting.h index ec36d9bc5..74dc06764 100644 --- a/src/core/crashreporting.h +++ b/src/core/crashreporting.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef CRASHREPORTING_H -#define CRASHREPORTING_H +#ifndef CORE_CRASHREPORTING_H_ +#define CORE_CRASHREPORTING_H_ #include @@ -70,7 +70,7 @@ class CrashSender : public QObject { Q_OBJECT public: - CrashSender(const QString& path); + explicit CrashSender(const QString& path); // Returns false if the user doesn't want to send the crash report (caller // should exit), or true if he does (caller should start the Qt event loop). @@ -90,4 +90,4 @@ class CrashSender : public QObject { QProgressDialog* progress_; }; -#endif // CRASHREPORTING_H +#endif // CORE_CRASHREPORTING_H_ diff --git a/src/core/database.cpp b/src/core/database.cpp index 06e77f126..0edbc72c0 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -379,7 +379,7 @@ void Database::AttachDatabase(const QString& database_name, void Database::AttachDatabaseOnDbConnection(const QString& database_name, const AttachedDatabase& database, - QSqlDatabase& db) { + const QSqlDatabase& db) { AttachDatabase(database_name, database); // Attach the db @@ -408,7 +408,7 @@ void Database::DetachDatabase(const QString& database_name) { attached_databases_.remove(database_name); } -void Database::UpdateDatabaseSchema(int version, QSqlDatabase& db) { +void Database::UpdateDatabaseSchema(int version, const QSqlDatabase& db) { QString filename; if (version == 0) filename = ":/schema/schema.sql"; @@ -439,7 +439,7 @@ void Database::UpdateDatabaseSchema(int version, QSqlDatabase& db) { } } -void Database::UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db) { +void Database::UrlEncodeFilenameColumn(const QString& table, const QSqlDatabase& db) { QSqlQuery select(QString("SELECT ROWID, filename FROM %1").arg(table), db); QSqlQuery update( QString("UPDATE %1 SET filename=:filename WHERE ROWID=:id").arg(table), @@ -463,7 +463,7 @@ void Database::UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db) { } } -void Database::ExecSchemaCommandsFromFile(QSqlDatabase& db, +void Database::ExecSchemaCommandsFromFile(const QSqlDatabase& db, const QString& filename, int schema_version, bool in_transaction) { @@ -475,7 +475,7 @@ void Database::ExecSchemaCommandsFromFile(QSqlDatabase& db, schema_version, in_transaction); } -void Database::ExecSchemaCommands(QSqlDatabase& db, const QString& schema, +void Database::ExecSchemaCommands(const QSqlDatabase& db, const QString& schema, int schema_version, bool in_transaction) { // Run each command const QStringList commands(schema.split(QRegExp("; *\n\n"))); @@ -497,7 +497,7 @@ void Database::ExecSchemaCommands(QSqlDatabase& db, const QString& schema, } } -void Database::ExecSongTablesCommands(QSqlDatabase& db, +void Database::ExecSongTablesCommands(const QSqlDatabase& db, const QStringList& song_tables, const QStringList& commands) { for (const QString& command : commands) { @@ -527,7 +527,7 @@ void Database::ExecSongTablesCommands(QSqlDatabase& db, } } -QStringList Database::SongsTables(QSqlDatabase& db, int schema_version) const { +QStringList Database::SongsTables(const QSqlDatabase& db, int schema_version) const { QStringList ret; // look for the tables in the main db diff --git a/src/core/database.h b/src/core/database.h index 6b1442f65..9cee7a95e 100644 --- a/src/core/database.h +++ b/src/core/database.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef DATABASE_H -#define DATABASE_H +#ifndef CORE_DATABASE_H_ +#define CORE_DATABASE_H_ #include #include @@ -30,7 +30,6 @@ #include "gtest/gtest_prod.h" extern "C" { - struct sqlite3_tokenizer; struct sqlite3_tokenizer_cursor; struct sqlite3_tokenizer_module; @@ -65,7 +64,7 @@ class Database : public QObject { QMutex* Mutex() { return &mutex_; } void RecreateAttachedDb(const QString& database_name); - void ExecSchemaCommands(QSqlDatabase& db, const QString& schema, + void ExecSchemaCommands(const QSqlDatabase& db, const QString& schema, int schema_version, bool in_transaction = false); int startup_schema_version() const { return startup_schema_version_; } @@ -75,10 +74,10 @@ class Database : public QObject { const AttachedDatabase& database); void AttachDatabaseOnDbConnection(const QString& database_name, const AttachedDatabase& database, - QSqlDatabase& db); + const QSqlDatabase& db); void DetachDatabase(const QString& database_name); -signals: + signals: void Error(const QString& message); public slots: @@ -87,16 +86,16 @@ signals: private: void UpdateMainSchema(QSqlDatabase* db); - void ExecSchemaCommandsFromFile(QSqlDatabase& db, const QString& filename, + void ExecSchemaCommandsFromFile(const QSqlDatabase& db, const QString& filename, int schema_version, bool in_transaction = false); - void ExecSongTablesCommands(QSqlDatabase& db, const QStringList& song_tables, + void ExecSongTablesCommands(const QSqlDatabase& db, const QStringList& song_tables, const QStringList& commands); - void UpdateDatabaseSchema(int version, QSqlDatabase& db); - void UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db); - QStringList SongsTables(QSqlDatabase& db, int schema_version) const; - bool IntegrityCheck(QSqlDatabase db); + void UpdateDatabaseSchema(int version, const QSqlDatabase& db); + void UrlEncodeFilenameColumn(const QString& table, const QSqlDatabase& db); + QStringList SongsTables(const QSqlDatabase& db, int schema_version) const; + bool IntegrityCheck(const QSqlDatabase db); void BackupFile(const QString& filename); bool OpenDatabase(const QString& filename, sqlite3** connection) const; @@ -183,4 +182,4 @@ class MemoryDatabase : public Database { } }; -#endif // DATABASE_H +#endif // CORE_DATABASE_H_ diff --git a/src/core/deletefiles.h b/src/core/deletefiles.h index ddef77797..7bb94f902 100644 --- a/src/core/deletefiles.h +++ b/src/core/deletefiles.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef DELETEFILES_H -#define DELETEFILES_H +#ifndef CORE_DELETEFILES_H_ +#define CORE_DELETEFILES_H_ #include @@ -39,7 +39,7 @@ class DeleteFiles : public QObject { void Start(const SongList& songs); void Start(const QStringList& filenames); -signals: + signals: void Finished(const SongList& songs_with_errors); private slots: @@ -61,4 +61,4 @@ signals: SongList songs_with_errors_; }; -#endif // DELETEFILES_H +#endif // CORE_DELETEFILES_H_ diff --git a/src/core/fht.cpp b/src/core/fht.cpp index 7f8d84759..ffd9432ac 100644 --- a/src/core/fht.cpp +++ b/src/core/fht.cpp @@ -58,11 +58,11 @@ void FHT::makeCasTable(void) { } float* FHT::copy(float* d, float* s) { - return (float*)memcpy(d, s, m_num * sizeof(float)); + return static_cast(memcpy(d, s, m_num * sizeof(float))); } float* FHT::clear(float* d) { - return (float*)memset(d, 0, m_num * sizeof(float)); + return static_cast(memset(d, 0, m_num * sizeof(float))); } void FHT::scale(float* p, float d) { @@ -77,9 +77,9 @@ void FHT::logSpectrum(float* out, float* p) { int n = m_num / 2, i, j, k, *r; if (!m_log) { m_log = new int[n]; - float f = n / log10((double)n); + float f = n / log10(static_cast(n)); for (i = 0, r = m_log; i < n; i++, r++) { - j = int(rint(log10(i + 1.0) * f)); + j = static_cast(rint(log10(i + 1.0) * f)); *r = j >= n ? n - 1 : j; } } @@ -87,9 +87,9 @@ void FHT::logSpectrum(float* out, float* p) { *out++ = *p = *p / 100; for (k = i = 1, r = m_log; i < n; i++) { j = *r++; - if (i == j) + if (i == j) { *out++ = p[i]; - else { + } else { float base = p[k - 1]; float step = (p[j] - base) / (j - (k - 1)); for (float corr = 0; k <= j; k++, corr += step) *out++ = base + corr; @@ -108,7 +108,7 @@ void FHT::semiLogSpectrum(float* p) { void FHT::spectrum(float* p) { power2(p); - for (int i = 0; i < (m_num / 2); i++, p++) *p = (float)sqrt(*p * .5); + for (int i = 0; i < (m_num / 2); i++, p++) *p = static_cast(sqrt(*p * .5)); } void FHT::power(float* p) { diff --git a/src/core/fht.h b/src/core/fht.h index 73c5daa6a..b82e51cca 100644 --- a/src/core/fht.h +++ b/src/core/fht.h @@ -18,8 +18,8 @@ // // $Id$ -#ifndef FHT_H -#define FHT_H +#ifndef CORE_FHT_H_ +#define CORE_FHT_H_ /** * Implementation of the Hartley Transform after Bracewell's discrete @@ -54,7 +54,7 @@ class FHT { * should be at least 3. Values of more than 3 need a trigonometry table. * @see makeCasTable() */ - FHT(int); + explicit FHT(int); ~FHT(); inline int sizeExp() const { return m_exp2; } @@ -115,4 +115,4 @@ class FHT { void transform(float*); }; -#endif +#endif // CORE_FHT_H_ diff --git a/src/core/filesystemmusicstorage.cpp b/src/core/filesystemmusicstorage.cpp index 4895540e6..0e829de41 100644 --- a/src/core/filesystemmusicstorage.cpp +++ b/src/core/filesystemmusicstorage.cpp @@ -57,4 +57,4 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob& job) { return Utilities::RemoveRecursive(path); else return QFile::remove(path); -} \ No newline at end of file +} diff --git a/src/core/filesystemmusicstorage.h b/src/core/filesystemmusicstorage.h index 71cae43dc..ebfc7bc54 100644 --- a/src/core/filesystemmusicstorage.h +++ b/src/core/filesystemmusicstorage.h @@ -15,14 +15,14 @@ along with Clementine. If not, see . */ -#ifndef FILESYSTEMMUSICSTORAGE_H -#define FILESYSTEMMUSICSTORAGE_H +#ifndef CORE_FILESYSTEMMUSICSTORAGE_H_ +#define CORE_FILESYSTEMMUSICSTORAGE_H_ #include "musicstorage.h" class FilesystemMusicStorage : public virtual MusicStorage { public: - FilesystemMusicStorage(const QString& root); + explicit FilesystemMusicStorage(const QString& root); ~FilesystemMusicStorage() {} QString LocalPath() const { return root_; } @@ -34,4 +34,4 @@ class FilesystemMusicStorage : public virtual MusicStorage { QString root_; }; -#endif // FILESYSTEMMUSICSTORAGE_H +#endif // CORE_FILESYSTEMMUSICSTORAGE_H_ diff --git a/src/core/filesystemwatcherinterface.h b/src/core/filesystemwatcherinterface.h index 22a91ec23..a73722422 100644 --- a/src/core/filesystemwatcherinterface.h +++ b/src/core/filesystemwatcherinterface.h @@ -15,15 +15,15 @@ along with Clementine. If not, see . */ -#ifndef FILESYSTEMWATCHERINTERFACE_H -#define FILESYSTEMWATCHERINTERFACE_H +#ifndef CORE_FILESYSTEMWATCHERINTERFACE_H_ +#define CORE_FILESYSTEMWATCHERINTERFACE_H_ #include class FileSystemWatcherInterface : public QObject { Q_OBJECT public: - FileSystemWatcherInterface(QObject* parent = nullptr); + explicit FileSystemWatcherInterface(QObject* parent = nullptr); virtual void Init() {} virtual void AddPath(const QString& path) = 0; virtual void RemovePath(const QString& path) = 0; @@ -31,8 +31,8 @@ class FileSystemWatcherInterface : public QObject { static FileSystemWatcherInterface* Create(QObject* parent = nullptr); -signals: + signals: void PathChanged(const QString& path); }; -#endif +#endif // CORE_FILESYSTEMWATCHERINTERFACE_H_ diff --git a/src/core/globalshortcutbackend.h b/src/core/globalshortcutbackend.h index 3393e9861..a62278941 100644 --- a/src/core/globalshortcutbackend.h +++ b/src/core/globalshortcutbackend.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef GLOBALSHORTCUTBACKEND_H -#define GLOBALSHORTCUTBACKEND_H +#ifndef CORE_GLOBALSHORTCUTBACKEND_H_ +#define CORE_GLOBALSHORTCUTBACKEND_H_ #include @@ -26,7 +26,7 @@ class GlobalShortcutBackend : public QObject { Q_OBJECT public: - GlobalShortcutBackend(GlobalShortcuts* parent = nullptr); + explicit GlobalShortcutBackend(GlobalShortcuts* parent = nullptr); virtual ~GlobalShortcutBackend() {} bool is_active() const { return active_; } @@ -34,7 +34,7 @@ class GlobalShortcutBackend : public QObject { bool Register(); void Unregister(); -signals: + signals: void RegisterFinished(bool success); protected: @@ -45,4 +45,4 @@ signals: bool active_; }; -#endif // GLOBALSHORTCUTBACKEND_H +#endif // CORE_GLOBALSHORTCUTBACKEND_H_ diff --git a/src/core/globalshortcuts.h b/src/core/globalshortcuts.h index 113ad35fb..978177906 100644 --- a/src/core/globalshortcuts.h +++ b/src/core/globalshortcuts.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef GLOBALSHORTCUTS_H -#define GLOBALSHORTCUTS_H +#ifndef CORE_GLOBALSHORTCUTS_H_ +#define CORE_GLOBALSHORTCUTS_H_ #include #include @@ -33,7 +33,7 @@ class GlobalShortcuts : public QWidget { Q_OBJECT public: - GlobalShortcuts(QWidget* parent = nullptr); + explicit GlobalShortcuts(QWidget* parent = nullptr); static const char* kSettingsGroup; @@ -55,7 +55,7 @@ class GlobalShortcuts : public QWidget { void Unregister(); void Register(); -signals: + signals: void Play(); void Pause(); void PlayPause(); @@ -96,4 +96,4 @@ signals: QSignalMapper* rating_signals_mapper_; }; -#endif +#endif // CORE_GLOBALSHORTCUTS_H_ diff --git a/src/core/gnomeglobalshortcutbackend.h b/src/core/gnomeglobalshortcutbackend.h index 6127648bb..37b827faa 100644 --- a/src/core/gnomeglobalshortcutbackend.h +++ b/src/core/gnomeglobalshortcutbackend.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef GNOMEGLOBALSHORTCUTBACKEND_H -#define GNOMEGLOBALSHORTCUTBACKEND_H +#ifndef CORE_GNOMEGLOBALSHORTCUTBACKEND_H_ +#define CORE_GNOMEGLOBALSHORTCUTBACKEND_H_ #include "globalshortcutbackend.h" @@ -28,7 +28,7 @@ class GnomeGlobalShortcutBackend : public GlobalShortcutBackend { Q_OBJECT public: - GnomeGlobalShortcutBackend(GlobalShortcuts* parent); + explicit GnomeGlobalShortcutBackend(GlobalShortcuts* parent); static const char* kGsdService; static const char* kGsdPath; @@ -49,4 +49,4 @@ class GnomeGlobalShortcutBackend : public GlobalShortcutBackend { bool is_connected_; }; -#endif // GNOMEGLOBALSHORTCUTBACKEND_H +#endif // CORE_GNOMEGLOBALSHORTCUTBACKEND_H_ diff --git a/src/core/mac_delegate.h b/src/core/mac_delegate.h index 8a5aaf5a5..c029e5943 100644 --- a/src/core/mac_delegate.h +++ b/src/core/mac_delegate.h @@ -1,3 +1,20 @@ +/* This file is part of Clementine. + Copyright 2011-2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + #import #include "config.h" diff --git a/src/core/mac_startup.h b/src/core/mac_startup.h index a65273d9d..26d2419c1 100644 --- a/src/core/mac_startup.h +++ b/src/core/mac_startup.h @@ -1,3 +1,21 @@ +/* This file is part of Clementine. + Copyright 2010, David Sansome + Copyright 2011-2012, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + #ifndef MAC_STARTUP_H #define MAC_STARTUP_H @@ -32,4 +50,4 @@ void EnableFullScreen(const QWidget& main_window); } // namespace mac -#endif +#endif // MAC_STARTUP_H diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h index de816dfbf..b482c2ce3 100644 --- a/src/core/macfslistener.h +++ b/src/core/macfslistener.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MACFSLISTENER_H -#define MACFSLISTENER_H +#ifndef CORE_MACFSLISTENER_H_ +#define CORE_MACFSLISTENER_H_ #include @@ -36,7 +36,7 @@ class MacFSListener : public FileSystemWatcherInterface { void RemovePath(const QString& path); void Clear(); -signals: + signals: void PathChanged(const QString& path); private slots: @@ -57,4 +57,4 @@ signals: QTimer update_timer_; }; -#endif +#endif // CORE_MACFSLISTENER_H_ diff --git a/src/core/macglobalshortcutbackend.h b/src/core/macglobalshortcutbackend.h index 49ef44aac..ab09d3a99 100644 --- a/src/core/macglobalshortcutbackend.h +++ b/src/core/macglobalshortcutbackend.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MACGLOBALSHORTCUTBACKEND_H -#define MACGLOBALSHORTCUTBACKEND_H +#ifndef CORE_MACGLOBALSHORTCUTBACKEND_H_ +#define CORE_MACGLOBALSHORTCUTBACKEND_H_ #include @@ -32,7 +32,7 @@ class MacGlobalShortcutBackend : public GlobalShortcutBackend { Q_OBJECT public: - MacGlobalShortcutBackend(GlobalShortcuts* parent); + explicit MacGlobalShortcutBackend(GlobalShortcuts* parent); virtual ~MacGlobalShortcutBackend(); bool IsAccessibilityEnabled() const; @@ -53,4 +53,4 @@ class MacGlobalShortcutBackend : public GlobalShortcutBackend { std::unique_ptr p_; }; -#endif // MACGLOBALSHORTCUTBACKEND_H +#endif // CORE_MACGLOBALSHORTCUTBACKEND_H_ diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index 4a090776f..9fb67a842 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -44,7 +44,7 @@ std::size_t hash_value(const QModelIndex& index) { return qHash(index); } namespace { struct Mapping { - Mapping(const QModelIndex& _source_index) : source_index(_source_index) {} + explicit Mapping(const QModelIndex& _source_index) : source_index(_source_index) {} QModelIndex source_index; }; @@ -190,7 +190,7 @@ void MergedProxyModel::SourceModelReset() { void MergedProxyModel::SubModelReset() { QAbstractItemModel* submodel = static_cast(sender()); - // TODO: When we require Qt 4.6, use beginResetModel() and endResetModel() + // TODO(David Sansome): When we require Qt 4.6, use beginResetModel() and endResetModel() // in LibraryModel and catch those here - that will let us do away with this // std::numeric_limits::max() hack. diff --git a/src/core/mergedproxymodel.h b/src/core/mergedproxymodel.h index 24dbe47c3..64c61c97f 100644 --- a/src/core/mergedproxymodel.h +++ b/src/core/mergedproxymodel.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MERGEDPROXYMODEL_H -#define MERGEDPROXYMODEL_H +#ifndef CORE_MERGEDPROXYMODEL_H_ +#define CORE_MERGEDPROXYMODEL_H_ #include @@ -30,7 +30,7 @@ class MergedProxyModel : public QAbstractProxyModel { Q_OBJECT public: - MergedProxyModel(QObject* parent = nullptr); + explicit MergedProxyModel(QObject* parent = nullptr); ~MergedProxyModel(); // Make another model appear as a child of the given item in the source model. @@ -73,7 +73,7 @@ class MergedProxyModel : public QAbstractProxyModel { 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: @@ -107,4 +107,4 @@ signals: std::unique_ptr p_; }; -#endif // MERGEDPROXYMODEL_H +#endif // CORE_MERGEDPROXYMODEL_H_ diff --git a/src/core/metatypes.cpp b/src/core/metatypes.cpp index 40ee5d9e1..03dc7a031 100644 --- a/src/core/metatypes.cpp +++ b/src/core/metatypes.cpp @@ -1,3 +1,24 @@ +/* This file is part of Clementine. + Copyright 2014, David Sansome + Copyright 2012-2014, John Maguire + Copyright 2013, Andreas + Copyright 2013, pie.or.paj + Copyright 2014, Maltsev Vlad + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + #include "metatypes.h" #include diff --git a/src/core/metatypes.h b/src/core/metatypes.h index d757794af..0150f182a 100644 --- a/src/core/metatypes.h +++ b/src/core/metatypes.h @@ -1,6 +1,23 @@ -#ifndef METATYPES_H -#define METATYPES_H +/* This file is part of Clementine. + Copyright 2012, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef CORE_METATYPES_H_ +#define CORE_METATYPES_H_ void RegisterMetaTypes(); -#endif +#endif // CORE_METATYPES_H_ diff --git a/src/core/mimedata.h b/src/core/mimedata.h index e8136aed4..30f67741d 100644 --- a/src/core/mimedata.h +++ b/src/core/mimedata.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MIMEDATA_H -#define MIMEDATA_H +#ifndef CORE_MIMEDATA_H_ +#define CORE_MIMEDATA_H_ #include @@ -72,4 +72,4 @@ class MimeData : public QMimeData { } }; -#endif // MIMEDATA_H +#endif // CORE_MIMEDATA_H_ diff --git a/src/core/modelfuturewatcher.h b/src/core/modelfuturewatcher.h index 171e74892..7fb0dd4ca 100644 --- a/src/core/modelfuturewatcher.h +++ b/src/core/modelfuturewatcher.h @@ -1,5 +1,22 @@ -#ifndef MODELFUTUREWATCHER_H -#define MODELFUTUREWATCHER_H +/* This file is part of Clementine. + Copyright 2010-2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef CORE_MODELFUTUREWATCHER_H_ +#define CORE_MODELFUTUREWATCHER_H_ #include #include @@ -18,4 +35,4 @@ class ModelFutureWatcher : public QFutureWatcher { QPersistentModelIndex index_; }; -#endif +#endif // CORE_MODELFUTUREWATCHER_H_ diff --git a/src/core/mpris.h b/src/core/mpris.h index bb260e6b8..83a3574ee 100644 --- a/src/core/mpris.h +++ b/src/core/mpris.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MPRIS_H -#define MPRIS_H +#ifndef CORE_MPRIS_H_ +#define CORE_MPRIS_H_ #include @@ -33,7 +33,7 @@ class Mpris : public QObject { public: Mpris(Application* app, QObject* parent = nullptr); -signals: + signals: void RaiseMainWindow(); private: @@ -43,4 +43,4 @@ signals: } // namespace mpris -#endif // MPRIS_H +#endif // CORE_MPRIS_H_ diff --git a/src/core/mpris1.h b/src/core/mpris1.h index e43e1d560..eef5705ed 100644 --- a/src/core/mpris1.h +++ b/src/core/mpris1.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MPRIS1_H -#define MPRIS1_H +#ifndef CORE_MPRIS1_H_ +#define CORE_MPRIS1_H_ #include "core/player.h" @@ -149,7 +149,7 @@ class Mpris1Player : public QObject { void CurrentSongChanged(const Song& song, const QString& art_uri, const QImage&); -signals: + signals: void CapsChange(int); void TrackChange(const QVariantMap&); void StatusChange(DBusStatus); @@ -184,7 +184,7 @@ class Mpris1TrackList : public QObject { // Amarok extension void PlayTrack(int index); -signals: + signals: void TrackListChange(int i); private slots: @@ -196,4 +196,4 @@ signals: } // namespace mpris -#endif // MPRIS1_H +#endif // CORE_MPRIS1_H_ diff --git a/src/core/mpris2.cpp b/src/core/mpris2.cpp index 4b2145969..73cde0539 100644 --- a/src/core/mpris2.cpp +++ b/src/core/mpris2.cpp @@ -345,7 +345,7 @@ void Mpris2::ArtLoaded(const Song& song, const QString& art_uri) { double Mpris2::Volume() const { if (mpris1_->player()) { - return double(mpris1_->player()->VolumeGet()) / 100; + return static_cast(mpris1_->player()->VolumeGet()) / 100; } else { return 0.0; } @@ -458,28 +458,28 @@ void Mpris2::OpenUri(const QString& uri) { } TrackIds Mpris2::Tracks() const { - // TODO + // TODO(John Maguire): ? return TrackIds(); } bool Mpris2::CanEditTracks() const { return false; } TrackMetadata Mpris2::GetTracksMetadata(const TrackIds& tracks) const { - // TODO + // TODO(John Maguire): ? return TrackMetadata(); } void Mpris2::AddTrack(const QString& uri, const QDBusObjectPath& afterTrack, bool setAsCurrent) { - // TODO + // TODO(John Maguire): ? } void Mpris2::RemoveTrack(const QDBusObjectPath& trackId) { - // TODO + // TODO(John Maguire): ? } void Mpris2::GoTo(const QDBusObjectPath& trackId) { - // TODO + // TODO(John Maguire): ? } quint32 Mpris2::PlaylistCount() const { @@ -529,7 +529,7 @@ void Mpris2::ActivatePlaylist(const QDBusObjectPath& playlist_id) { app_->player()->Next(); } -// TODO: Support sort orders. +// TODO(John Maguire): Support sort orders. MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const QString& order, bool reverse_order) { diff --git a/src/core/mpris2.h b/src/core/mpris2.h index 4732fe575..c0ce29f19 100644 --- a/src/core/mpris2.h +++ b/src/core/mpris2.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MPRIS2_H -#define MPRIS2_H +#ifndef CORE_MPRIS2_H_ +#define CORE_MPRIS2_H_ #include "playlist/playlistitem.h" @@ -175,7 +175,7 @@ class Mpris2 : public QObject { QList GetPlaylists(quint32 index, quint32 max_count, const QString& order, bool reverse_order); -signals: + signals: // Player void Seeked(qlonglong position); @@ -228,4 +228,4 @@ signals: } // namespace mpris -#endif +#endif // CORE_MPRIS2_H_ diff --git a/src/core/mpris_common.h b/src/core/mpris_common.h index 329010a0d..06256fe31 100644 --- a/src/core/mpris_common.h +++ b/src/core/mpris_common.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MPRIS_COMMON_H -#define MPRIS_COMMON_H +#ifndef CORE_MPRIS_COMMON_H_ +#define CORE_MPRIS_COMMON_H_ #include #include @@ -58,4 +58,4 @@ inline QString AsMPRISDateTimeType(uint time) { } // namespace mpris -#endif // MPRIS_COMMON_H +#endif // CORE_MPRIS_COMMON_H_ diff --git a/src/core/multisortfilterproxy.cpp b/src/core/multisortfilterproxy.cpp index b87ca12ab..d70d49e4e 100644 --- a/src/core/multisortfilterproxy.cpp +++ b/src/core/multisortfilterproxy.cpp @@ -1,3 +1,21 @@ +/* This file is part of Clementine. + Copyright 2011-2012, David Sansome + Copyright 2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + #include "multisortfilterproxy.h" #include "core/logging.h" diff --git a/src/core/multisortfilterproxy.h b/src/core/multisortfilterproxy.h index b8c4fd314..fee70c4ab 100644 --- a/src/core/multisortfilterproxy.h +++ b/src/core/multisortfilterproxy.h @@ -1,11 +1,29 @@ -#ifndef MULTISORTFILTERPROXY_H -#define MULTISORTFILTERPROXY_H +/* This file is part of Clementine. + Copyright 2011, David Sansome + Copyright 2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef CORE_MULTISORTFILTERPROXY_H_ +#define CORE_MULTISORTFILTERPROXY_H_ #include class MultiSortFilterProxy : public QSortFilterProxyModel { public: - MultiSortFilterProxy(QObject* parent = nullptr); + explicit MultiSortFilterProxy(QObject* parent = nullptr); void AddSortSpec(int role, Qt::SortOrder order = Qt::AscendingOrder); @@ -19,4 +37,4 @@ class MultiSortFilterProxy : public QSortFilterProxyModel { QList sorting_; }; -#endif // MULTISORTFILTERPROXY_H +#endif // CORE_MULTISORTFILTERPROXY_H_ diff --git a/src/core/musicstorage.h b/src/core/musicstorage.h index 58fc52e11..6da556b9e 100644 --- a/src/core/musicstorage.h +++ b/src/core/musicstorage.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef MUSICSTORAGE_H -#define MUSICSTORAGE_H +#ifndef CORE_MUSICSTORAGE_H_ +#define CORE_MUSICSTORAGE_H_ #include "song.h" @@ -86,4 +86,4 @@ class MusicStorage { Q_DECLARE_METATYPE(MusicStorage*); Q_DECLARE_METATYPE(std::shared_ptr); -#endif // MUSICSTORAGE_H +#endif // CORE_MUSICSTORAGE_H_ diff --git a/src/core/network.h b/src/core/network.h index 4e5ab20da..1c6ccb8e1 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef NETWORK_H -#define NETWORK_H +#ifndef CORE_NETWORK_H_ +#define CORE_NETWORK_H_ #include #include @@ -27,7 +27,7 @@ class QNetworkDiskCache; class ThreadSafeNetworkDiskCache : public QAbstractNetworkCache { public: - ThreadSafeNetworkDiskCache(QObject* parent); + explicit ThreadSafeNetworkDiskCache(QObject* parent); qint64 cacheSize() const; QIODevice* data(const QUrl& url); @@ -48,7 +48,7 @@ class NetworkAccessManager : public QNetworkAccessManager { Q_OBJECT public: - NetworkAccessManager(QObject* parent = nullptr); + explicit NetworkAccessManager(QObject* parent = nullptr); protected: QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, @@ -78,7 +78,7 @@ class RedirectFollower : public QObject { QByteArray readAll() { return current_reply_->readAll(); } void abort() { current_reply_->abort(); } -signals: + signals: // These are all forwarded from the current reply. void readyRead(); void error(QNetworkReply::NetworkError); @@ -106,7 +106,7 @@ class NetworkTimeouts : public QObject { public: NetworkTimeouts(int timeout_msec, QObject* parent = nullptr); - // TODO: Template this to avoid code duplication. + // TODO(John Maguire): Template this to avoid code duplication. void AddReply(QNetworkReply* reply); void AddReply(RedirectFollower* reply); void SetTimeout(int msec) { timeout_msec_ = msec; } @@ -124,4 +124,4 @@ class NetworkTimeouts : public QObject { QMap redirect_timers_; }; -#endif // NETWORK_H +#endif // CORE_NETWORK_H_ diff --git a/src/core/networkproxyfactory.cpp b/src/core/networkproxyfactory.cpp index 7ffde1c94..f4deb70c5 100644 --- a/src/core/networkproxyfactory.cpp +++ b/src/core/networkproxyfactory.cpp @@ -1,3 +1,22 @@ +/* This file is part of Clementine. + Copyright 2010-2011, David Sansome + Copyright 2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + + #include "networkproxyfactory.h" #include "core/logging.h" diff --git a/src/core/networkproxyfactory.h b/src/core/networkproxyfactory.h index 882f0554b..b2a8e2908 100644 --- a/src/core/networkproxyfactory.h +++ b/src/core/networkproxyfactory.h @@ -1,5 +1,23 @@ -#ifndef NETWORKPROXYFACTORY_H -#define NETWORKPROXYFACTORY_H +/* This file is part of Clementine. + Copyright 2010-2011, David Sansome + Copyright 2014, John Maguire + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#ifndef CORE_NETWORKPROXYFACTORY_H_ +#define CORE_NETWORKPROXYFACTORY_H_ #include #include @@ -37,4 +55,4 @@ class NetworkProxyFactory : public QNetworkProxyFactory { #endif }; -#endif // NETWORKPROXYFACTORY_H +#endif // CORE_NETWORKPROXYFACTORY_H_ diff --git a/src/core/organise.cpp b/src/core/organise.cpp index ed89d8ed0..b64eab174 100644 --- a/src/core/organise.cpp +++ b/src/core/organise.cpp @@ -189,9 +189,8 @@ void Organise::ProcessSomeFiles() { if (!destination_->CopyToStorage(job)) { files_with_errors_ << task.song_info_.song_.basefilename(); - } - else { - if(job.mark_as_listened_) { + } else { + if (job.mark_as_listened_) { emit FileCopied(job.metadata_.id()); } } diff --git a/src/core/organise.h b/src/core/organise.h index 48f18d991..2c49a3165 100644 --- a/src/core/organise.h +++ b/src/core/organise.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef ORGANISE_H -#define ORGANISE_H +#ifndef CORE_ORGANISE_H_ +#define CORE_ORGANISE_H_ #include @@ -52,7 +52,7 @@ class Organise : public QObject { void Start(); -signals: + signals: void Finished(const QStringList& files_with_errors); void FileCopied(int database_id); @@ -111,4 +111,4 @@ signals: QStringList files_with_errors_; }; -#endif // ORGANISE_H +#endif // CORE_ORGANISE_H_ diff --git a/src/core/organiseformat.cpp b/src/core/organiseformat.cpp index 06f9a4ecc..552e3af85 100644 --- a/src/core/organiseformat.cpp +++ b/src/core/organiseformat.cpp @@ -232,7 +232,7 @@ QString OrganiseFormat::TagValue(const QString& tag, const Song& song) const { OrganiseFormat::Validator::Validator(QObject* parent) : QValidator(parent) {} -QValidator::State OrganiseFormat::Validator::validate(QString& input, +QValidator::State OrganiseFormat::Validator::validate(const QString& input, int&) const { QRegExp tag_regexp(kTagPattern); diff --git a/src/core/organiseformat.h b/src/core/organiseformat.h index e11a24006..9dba29857 100644 --- a/src/core/organiseformat.h +++ b/src/core/organiseformat.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SRC_CORE_ORGANISEFORMAT_H_ -#define SRC_CORE_ORGANISEFORMAT_H_ +#ifndef CORE_ORGANISEFORMAT_H_ +#define CORE_ORGANISEFORMAT_H_ #include #include @@ -51,7 +51,7 @@ class OrganiseFormat { class Validator : public QValidator { public: explicit Validator(QObject* parent = nullptr); - QValidator::State validate(QString& format, int& pos) const; + QValidator::State validate(const QString& format, const int& pos) const; }; class SyntaxHighlighter : public QSyntaxHighlighter { @@ -80,4 +80,4 @@ class OrganiseFormat { bool replace_the_; }; -#endif // SRC_CORE_ORGANISEFORMAT_H_ +#endif // CORE_ORGANISEFORMAT_H_ diff --git a/src/core/player.h b/src/core/player.h index d300b5cb3..f65dc278e 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef PLAYER_H -#define PLAYER_H +#ifndef CORE_PLAYER_H_ +#define CORE_PLAYER_H_ #include @@ -37,7 +37,7 @@ class PlayerInterface : public QObject { Q_OBJECT public: - PlayerInterface(QObject* parent = nullptr) : QObject(parent) {} + explicit PlayerInterface(QObject* parent = nullptr) : QObject(parent) {} virtual EngineBase* engine() const = 0; virtual Engine::State GetState() const = 0; @@ -82,7 +82,7 @@ class PlayerInterface : public QObject { virtual void Play() = 0; virtual void ShowOSD() = 0; -signals: + signals: void Playing(); void Paused(); void Stopped(); @@ -190,4 +190,4 @@ class Player : public PlayerInterface { int volume_before_mute_; }; -#endif // PLAYER_H +#endif // CORE_PLAYER_H_ diff --git a/src/core/potranslator.h b/src/core/potranslator.h index de6dc9085..d1cdcd808 100644 --- a/src/core/potranslator.h +++ b/src/core/potranslator.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef POTRANSLATOR_H -#define POTRANSLATOR_H +#ifndef CORE_POTRANSLATOR_H_ +#define CORE_POTRANSLATOR_H_ #include @@ -34,4 +34,4 @@ class PoTranslator : public QTranslator { } }; -#endif // POTRANSLATOR_H +#endif // CORE_POTRANSLATOR_H_ diff --git a/src/core/qhash_qurl.h b/src/core/qhash_qurl.h index bc8a9c79d..2f3ca8a99 100644 --- a/src/core/qhash_qurl.h +++ b/src/core/qhash_qurl.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef QHASH_QURL_H -#define QHASH_QURL_H +#ifndef CORE_QHASH_QURL_H_ +#define CORE_QHASH_QURL_H_ #include @@ -24,4 +24,4 @@ inline uint qHash(const QUrl& url) { return qHash(url.toEncoded()); } #endif -#endif // QHASH_QURL_H +#endif // CORE_QHASH_QURL_H_ diff --git a/src/core/qtfslistener.h b/src/core/qtfslistener.h index 8800e9bf6..01a7bb87c 100644 --- a/src/core/qtfslistener.h +++ b/src/core/qtfslistener.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef QTFSLISTENER_H -#define QTFSLISTENER_H +#ifndef CORE_QTFSLISTENER_H_ +#define CORE_QTFSLISTENER_H_ #include "filesystemwatcherinterface.h" @@ -25,7 +25,7 @@ class QtFSListener : public FileSystemWatcherInterface { Q_OBJECT public: - QtFSListener(QObject* parent); + explicit QtFSListener(QObject* parent); virtual void AddPath(const QString& path); virtual void RemovePath(const QString& path); virtual void Clear(); @@ -34,4 +34,4 @@ class QtFSListener : public FileSystemWatcherInterface { QFileSystemWatcher watcher_; }; -#endif +#endif // CORE_QTFSLISTENER_H_ diff --git a/src/core/qxtglobalshortcutbackend.h b/src/core/qxtglobalshortcutbackend.h index bbe65c5cd..2e671afc1 100644 --- a/src/core/qxtglobalshortcutbackend.h +++ b/src/core/qxtglobalshortcutbackend.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef QXTGLOBALSHORTCUTBACKEND_H -#define QXTGLOBALSHORTCUTBACKEND_H +#ifndef CORE_QXTGLOBALSHORTCUTBACKEND_H_ +#define CORE_QXTGLOBALSHORTCUTBACKEND_H_ #include "globalshortcutbackend.h" @@ -24,7 +24,7 @@ class QxtGlobalShortcut; class QxtGlobalShortcutBackend : public GlobalShortcutBackend { public: - QxtGlobalShortcutBackend(GlobalShortcuts* parent = nullptr); + explicit QxtGlobalShortcutBackend(GlobalShortcuts* parent = nullptr); protected: bool DoRegister(); @@ -35,4 +35,4 @@ class QxtGlobalShortcutBackend : public GlobalShortcutBackend { QList shortcuts_; }; -#endif // QXTGLOBALSHORTCUTBACKEND_H +#endif // CORE_QXTGLOBALSHORTCUTBACKEND_H_ diff --git a/src/core/settingsprovider.h b/src/core/settingsprovider.h index ef6ef6585..f3e55df3c 100644 --- a/src/core/settingsprovider.h +++ b/src/core/settingsprovider.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SETTINGSPROVIDER_H -#define SETTINGSPROVIDER_H +#ifndef CORE_SETTINGSPROVIDER_H_ +#define CORE_SETTINGSPROVIDER_H_ #include #include @@ -55,4 +55,4 @@ class DefaultSettingsProvider : public SettingsProvider { QSettings backend_; }; -#endif // SETTINGSPROVIDER_H +#endif // CORE_SETTINGSPROVIDER_H_ diff --git a/src/core/signalchecker.h b/src/core/signalchecker.h index 224513e33..b8bf78f78 100644 --- a/src/core/signalchecker.h +++ b/src/core/signalchecker.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SIGNALCHECKER_H -#define SIGNALCHECKER_H +#ifndef CORE_SIGNALCHECKER_H_ +#define CORE_SIGNALCHECKER_H_ #include @@ -34,4 +34,4 @@ bool CheckedGConnect(gpointer source, const char* signal, GCallback callback, CheckedGConnect(source, signal, G_CALLBACK(callback), data, \ FUNCTION_ARITY(callback)); -#endif // SIGNALCHECKER_H +#endif // CORE_SIGNALCHECKER_H_ diff --git a/src/core/simpletreeitem.h b/src/core/simpletreeitem.h index 02eceb4ab..93dfee0ca 100644 --- a/src/core/simpletreeitem.h +++ b/src/core/simpletreeitem.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SIMPLETREEITEM_H -#define SIMPLETREEITEM_H +#ifndef CORE_SIMPLETREEITEM_H_ +#define CORE_SIMPLETREEITEM_H_ #include "simpletreemodel.h" @@ -154,4 +154,4 @@ T* SimpleTreeItem::ChildByKey(const QString& key) const { return nullptr; } -#endif // SIMPLETREEITEM_H +#endif // CORE_SIMPLETREEITEM_H_ diff --git a/src/core/simpletreemodel.h b/src/core/simpletreemodel.h index 247ee4916..2388b54d3 100644 --- a/src/core/simpletreemodel.h +++ b/src/core/simpletreemodel.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SIMPLETREEMODEL_H -#define SIMPLETREEMODEL_H +#ifndef CORE_SIMPLETREEMODEL_H_ +#define CORE_SIMPLETREEMODEL_H_ #include @@ -148,4 +148,4 @@ void SimpleTreeModel::EmitDataChanged(T* item) { emit dataChanged(index, index); } -#endif // SIMPLETREEMODEL_H +#endif // CORE_SIMPLETREEMODEL_H_ diff --git a/src/core/song.cpp b/src/core/song.cpp index f5ff92e8b..7693f1c0f 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -614,7 +614,7 @@ void Song::InitFromQuery(const SqlRow& q, bool reliable_metadata, int col) { void Song::InitFromFilePartial(const QString& filename) { set_url(QUrl::fromLocalFile(filename)); // We currently rely on filename suffix to know if it's a music file or not. - // TODO: I know this is not satisfying, but currently, we rely on TagLib + // TODO(Arnaud Bienner): I know this is not satisfying, but currently, we rely on TagLib // which seems to have the behavior (filename checks). Someday, it would be // nice to perform some magic tests everywhere. QFileInfo info(filename); @@ -680,7 +680,7 @@ void Song::InitFromItdb(const Itdb_Track* track, const QString& prefix) { d->ctime_ = track->time_added; d->filesize_ = track->size; d->filetype_ = track->type2 ? Type_Mpeg : Type_Mp4; - d->rating_ = float(track->rating) / 100; // 100 = 20 * 5 stars + d->rating_ = static_cast(track->rating) / 100; // 100 = 20 * 5 stars d->playcount_ = track->playcount; d->skipcount_ = track->skipcount; d->lastplayed_ = track->time_played; @@ -747,7 +747,7 @@ void Song::InitFromMTP(const LIBMTP_track_t* track, const QString& host) { d->mtime_ = track->modificationdate; d->ctime_ = track->modificationdate; - d->rating_ = float(track->rating) / 100; + d->rating_ = static_cast(track->rating) / 100; d->playcount_ = track->usecount; switch (track->filetype) { @@ -1043,7 +1043,7 @@ bool Song::IsEditable() const { } bool Song::operator==(const Song& other) const { - // TODO: this isn't working for radios + // TODO(Paweł Bara): this isn't working for radios return url() == other.url() && beginning_nanosec() == other.beginning_nanosec(); } diff --git a/src/core/song.h b/src/core/song.h index a31ff4a10..936329d17 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SONG_H -#define SONG_H +#ifndef CORE_SONG_H_ +#define CORE_SONG_H_ #include #include @@ -301,4 +301,4 @@ uint qHash(const Song& song); // Hash function using field checked in IsSimilar function uint HashSimilar(const Song& song); -#endif // SONG_H +#endif // CORE_SONG_H_ diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 440944f9a..11e6c400b 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -162,7 +162,7 @@ void SongLoader::AudioCDTracksTagsLoaded(const SongList& songs) { songs_ = songs; emit LoadAudioCDFinished(true); } -#endif // HAVE_AUDIOCD +#endif // HAVE_AUDIOCD SongLoader::Result SongLoader::LoadLocal(const QString& filename) { qLog(Debug) << "Loading local file" << filename; @@ -195,7 +195,6 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename) { } void SongLoader::LoadLocalAsync(const QString& filename) { - // First check to see if it's a directory - if so we will load all the songs // inside right away. if (QFileInfo(filename).isDir()) { @@ -233,7 +232,7 @@ void SongLoader::LoadLocalAsync(const QString& filename) { SongList song_list = cue_parser_->Load(&cue, matching_cue, QDir(filename.section('/', 0, -2))); - for (Song song: song_list){ + for (Song song : song_list) { if (song.is_valid()) songs_ << song; } return; @@ -242,7 +241,9 @@ void SongLoader::LoadLocalAsync(const QString& filename) { // Assume it's just a normal file Song song; song.InitFromFilePartial(filename); - if (song.is_valid()) songs_ << song; + if (song.is_valid()) { + songs_ << song; + } } void SongLoader::LoadMetadataBlocking() { diff --git a/src/core/songloader.h b/src/core/songloader.h index a794e2663..1943fa56b 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef SONGLOADER_H -#define SONGLOADER_H +#ifndef CORE_SONGLOADER_H_ +#define CORE_SONGLOADER_H_ #include #include @@ -41,6 +41,7 @@ class CddaSongLoader; class SongLoader : public QObject { Q_OBJECT + public: SongLoader(LibraryBackendInterface* library, const Player* player, QObject* parent = nullptr); @@ -73,7 +74,7 @@ class SongLoader : public QObject { void LoadMetadataBlocking(); Result LoadAudioCD(); -signals: + signals: void AudioCDTracksLoaded(); void LoadAudioCDFinished(bool success); void LoadRemoteFinished(); @@ -84,7 +85,7 @@ signals: #ifdef HAVE_AUDIOCD void AudioCDTracksLoadedSlot(const SongList& songs); void AudioCDTracksTagsLoaded(const SongList& songs); -#endif // HAVE_AUDIOCD +#endif // HAVE_AUDIOCD private: enum State { WaitingForType, WaitingForMagic, WaitingForData, Finished, }; @@ -142,4 +143,4 @@ signals: QThreadPool thread_pool_; }; -#endif // SONGLOADER_H +#endif // CORE_SONGLOADER_H_ diff --git a/src/core/stylesheetloader.h b/src/core/stylesheetloader.h index ff889fa12..72d6a6e04 100644 --- a/src/core/stylesheetloader.h +++ b/src/core/stylesheetloader.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef STYLESHEETLOADER_H -#define STYLESHEETLOADER_H +#ifndef CORE_STYLESHEETLOADER_H_ +#define CORE_STYLESHEETLOADER_H_ #include #include @@ -25,7 +25,7 @@ class StyleSheetLoader : public QObject { public: - StyleSheetLoader(QObject* parent = nullptr); + explicit StyleSheetLoader(QObject* parent = nullptr); // Sets the given stylesheet on the given widget. // If the stylesheet contains strings like %palette-[role], these get replaced @@ -45,4 +45,4 @@ class StyleSheetLoader : public QObject { QMap filenames_; }; -#endif // STYLESHEETLOADER_H +#endif // CORE_STYLESHEETLOADER_H_ diff --git a/src/core/tagreaderclient.h b/src/core/tagreaderclient.h index 3fa14d975..dd7b2cc4b 100644 --- a/src/core/tagreaderclient.h +++ b/src/core/tagreaderclient.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef TAGREADERCLIENT_H -#define TAGREADERCLIENT_H +#ifndef CORE_TAGREADERCLIENT_H_ +#define CORE_TAGREADERCLIENT_H_ #include "song.h" #include "tagreadermessages.pb.h" @@ -32,7 +32,7 @@ class TagReaderClient : public QObject { Q_OBJECT public: - TagReaderClient(QObject* parent = nullptr); + explicit TagReaderClient(QObject* parent = nullptr); typedef AbstractMessageHandler HandlerType; typedef HandlerType::ReplyType ReplyType; @@ -61,7 +61,7 @@ class TagReaderClient : public QObject { bool IsMediaFileBlocking(const QString& filename); QImage LoadEmbeddedArtBlocking(const QString& filename); - // TODO: Make this not a singleton + // TODO(David Sansome): Make this not a singleton static TagReaderClient* Instance() { return sInstance; } public slots: @@ -80,4 +80,4 @@ class TagReaderClient : public QObject { typedef TagReaderClient::ReplyType TagReaderReply; -#endif // TAGREADERCLIENT_H +#endif // CORE_TAGREADERCLIENT_H_ diff --git a/src/core/taskmanager.h b/src/core/taskmanager.h index 36c34d677..817256c0f 100644 --- a/src/core/taskmanager.h +++ b/src/core/taskmanager.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef TASKMANAGER_H -#define TASKMANAGER_H +#ifndef CORE_TASKMANAGER_H_ +#define CORE_TASKMANAGER_H_ #include #include @@ -26,7 +26,7 @@ class TaskManager : public QObject { Q_OBJECT public: - TaskManager(QObject* parent = nullptr); + explicit TaskManager(QObject* parent = nullptr); struct Task { int id; @@ -60,7 +60,7 @@ class TaskManager : public QObject { void SetTaskFinished(int id); int GetTaskProgress(int id); -signals: + signals: void TasksChanged(); void PauseLibraryWatchers(); @@ -74,4 +74,4 @@ signals: Q_DISABLE_COPY(TaskManager); }; -#endif // TASKMANAGER_H +#endif // CORE_TASKMANAGER_H_ diff --git a/src/core/timeconstants.h b/src/core/timeconstants.h index 8a79d5397..22e756d5b 100644 --- a/src/core/timeconstants.h +++ b/src/core/timeconstants.h @@ -18,8 +18,8 @@ // it is used by the Spotify blob which links against libspotify and is not GPL // compatible. -#ifndef TIMECONSTANTS_H -#define TIMECONSTANTS_H +#ifndef CORE_TIMECONSTANTS_H_ +#define CORE_TIMECONSTANTS_H_ #include @@ -33,4 +33,4 @@ const qint64 kNsecPerSec = 1000000000ll; const qint64 kSecsPerDay = 24 * 60 * 60; -#endif // TIMECONSTANTS_H +#endif // CORE_TIMECONSTANTS_H_ diff --git a/src/core/ubuntuunityhack.h b/src/core/ubuntuunityhack.h index c09e96304..26cebe9a4 100644 --- a/src/core/ubuntuunityhack.h +++ b/src/core/ubuntuunityhack.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef UBUNTUUNITYHACK_H -#define UBUNTUUNITYHACK_H +#ifndef CORE_UBUNTUUNITYHACK_H_ +#define CORE_UBUNTUUNITYHACK_H_ #include @@ -25,7 +25,7 @@ class QProcess; class UbuntuUnityHack : public QObject { Q_OBJECT public: - UbuntuUnityHack(QObject* parent = nullptr); + explicit UbuntuUnityHack(QObject* parent = nullptr); private slots: void GetFinished(int exit_code); @@ -37,4 +37,4 @@ class UbuntuUnityHack : public QObject { static const char* kUnitySystrayWhitelist; }; -#endif // UBUNTUUNITYHACK_H +#endif // CORE_UBUNTUUNITYHACK_H_ diff --git a/src/core/urlhandler.h b/src/core/urlhandler.h index 03e77fc04..0ecaec47d 100644 --- a/src/core/urlhandler.h +++ b/src/core/urlhandler.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef URLHANDLER_H -#define URLHANDLER_H +#ifndef CORE_URLHANDLER_H_ +#define CORE_URLHANDLER_H_ #include #include @@ -26,7 +26,7 @@ class UrlHandler : public QObject { Q_OBJECT public: - UrlHandler(QObject* parent = nullptr); + explicit UrlHandler(QObject* parent = nullptr); // The URL scheme that this handler handles. virtual QString scheme() const = 0; @@ -75,11 +75,11 @@ class UrlHandler : public QObject { // Functions to be warned when something happen to a track handled by // UrlHandler. - virtual void TrackAboutToEnd() {}; - virtual void TrackSkipped() {}; + virtual void TrackAboutToEnd() {} + virtual void TrackSkipped() {} -signals: + signals: void AsyncLoadComplete(const UrlHandler::LoadResult& result); }; -#endif // URLHANDLER_H +#endif // CORE_URLHANDLER_H_ diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 1ce8c63f8..f769c1d86 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -91,9 +91,9 @@ QString PrettyTime(int seconds) { QString ret; if (hours) - ret.sprintf("%d:%02d:%02d", hours, minutes, seconds); + ret.sprintf("%d:%02d:%02d", hours, minutes, seconds); // NOLINT(runtime/printf) else - ret.sprintf("%d:%02d", minutes, seconds); + ret.sprintf("%d:%02d", minutes, seconds); // NOLINT(runtime/printf) return ret; } @@ -105,7 +105,7 @@ QString PrettyTimeNanosec(qint64 nanoseconds) { QString WordyTime(quint64 seconds) { quint64 days = seconds / (60 * 60 * 24); - // TODO: Make the plural rules translatable + // TODO(David Sansome): Make the plural rules translatable QStringList parts; if (days) parts << (days == 1 ? tr("1 day") : tr("%1 days").arg(days)); @@ -152,11 +152,11 @@ QString PrettySize(quint64 bytes) { if (bytes <= 1000) ret = QString::number(bytes) + " bytes"; else if (bytes <= 1000 * 1000) - ret.sprintf("%.1f KB", float(bytes) / 1000); + ret.sprintf("%.1f KB", static_cast(bytes) / 1000); // NOLINT(runtime/printf) else if (bytes <= 1000 * 1000 * 1000) - ret.sprintf("%.1f MB", float(bytes) / (1000 * 1000)); + ret.sprintf("%.1f MB", static_cast(bytes) / (1000 * 1000)); // NOLINT(runtime/printf) else - ret.sprintf("%.1f GB", float(bytes) / (1000 * 1000 * 1000)); + ret.sprintf("%.1f GB", static_cast(bytes) / (1000 * 1000 * 1000)); // NOLINT(runtime/printf) } return ret; } @@ -419,8 +419,8 @@ QByteArray Hmac(const QByteArray& key, const QByteArray& data, const int kBlockSize = 64; // bytes Q_ASSERT(key.length() <= kBlockSize); - QByteArray inner_padding(kBlockSize, char(0x36)); - QByteArray outer_padding(kBlockSize, char(0x5c)); + QByteArray inner_padding(kBlockSize, static_cast(0x36)); + QByteArray outer_padding(kBlockSize, static_cast(0x5c)); for (int i = 0; i < key.length(); ++i) { inner_padding[i] = inner_padding[i] ^ key[i]; @@ -475,7 +475,7 @@ QByteArray Sha256(const QByteArray& data) { } // File must not be open and will be closed afterwards! -QByteArray Sha1File(QFile& file) { +QByteArray Sha1File(const QFile& file) { file.open(QIODevice::ReadOnly); QCryptographicHash hash(QCryptographicHash::Sha1); QByteArray data; diff --git a/src/core/utilities.h b/src/core/utilities.h index 9d32c8c1d..e2e091c21 100644 --- a/src/core/utilities.h +++ b/src/core/utilities.h @@ -15,8 +15,8 @@ along with Clementine. If not, see . */ -#ifndef UTILITIES_H -#define UTILITIES_H +#ifndef CORE_UTILITIES_H_ +#define CORE_UTILITIES_H_ #include @@ -64,7 +64,7 @@ QByteArray HmacMd5(const QByteArray& key, const QByteArray& data); QByteArray HmacSha256(const QByteArray& key, const QByteArray& data); QByteArray HmacSha1(const QByteArray& key, const QByteArray& data); QByteArray Sha256(const QByteArray& data); -QByteArray Sha1File(QFile& file); +QByteArray Sha1File(const QFile& file); QByteArray Sha1CoverHash(const QString& artist, const QString& album); // Picks an unused ephemeral port number. Doesn't hold the port open so @@ -145,11 +145,11 @@ int GetThreadId(); bool IsLaptop(); QString SystemLanguageName(); -} +} // namespace Utilities class ScopedWCharArray { public: - ScopedWCharArray(const QString& str); + explicit ScopedWCharArray(const QString& str); QString ToString() const { return QString::fromWCharArray(data_.get()); } @@ -166,4 +166,4 @@ class ScopedWCharArray { std::unique_ptr data_; }; -#endif // UTILITIES_H +#endif // CORE_UTILITIES_H_