Fix code style and errors

This commit is contained in:
Jonas Kvinge
2019-04-08 18:46:11 +02:00
parent 0ce5b50950
commit 9be161d165
58 changed files with 146 additions and 146 deletions

View File

@@ -56,7 +56,9 @@ BlockAnalyzer::BlockAnalyzer(QWidget *parent)
store_(1 << 8, 0),
fade_bars_(kFadeSize),
fade_pos_(1 << 8, 50),
fade_intensity_(1 << 8, 32) {
fade_intensity_(1 << 8, 32),
step_(0)
{
setMinimumSize(kMinColumns * (kWidth + 1) - 1, kMinRows * (kHeight + 1) - 1); //-1 is padding, no drawing takes place there
setMaximumWidth(kMaxColumns * (kWidth + 1) - 1);

View File

@@ -116,7 +116,7 @@ void SCollection::Stopped() {
CurrentSongChanged(Song());
}
void SCollection::CurrentSongChanged(const Song &song) {
void SCollection::CurrentSongChanged(const Song &song) { // FIXME
TagReaderReply *reply = nullptr;

View File

@@ -49,9 +49,9 @@
const char *CollectionBackend::kSettingsGroup = "Collection";
CollectionBackend::CollectionBackend(QObject *parent)
: CollectionBackendInterface(parent)
{}
CollectionBackend::CollectionBackend(QObject *parent) :
CollectionBackendInterface(parent),
db_(nullptr) {}
void CollectionBackend::Init(Database *db, const QString &songs_table, const QString &dirs_table, const QString &subdirs_table, const QString &fts_table) {
db_ = db;
@@ -1095,7 +1095,6 @@ void CollectionBackend::IncrementPlayCount(int id) {
void CollectionBackend::IncrementSkipCount(int id, float progress) {
if (id == -1) return;
progress = qBound(0.0f, progress, 1.0f);
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());

View File

@@ -161,13 +161,10 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
switch (event->type()) {
case QEvent::ToolTip: {
QRect displayed_text;
QSize real_text;
bool is_elided = false;
real_text = sizeHint(option, index);
displayed_text = view->visualRect(index);
is_elided = displayed_text.width() < real_text.width();
QSize real_text = sizeHint(option, index);
QRect displayed_text = view->visualRect(index);
bool is_elided = displayed_text.width() < real_text.width();
if (is_elided) {
QToolTip::showText(he->globalPos(), text, view);
@@ -361,7 +358,7 @@ void CollectionView::SetFilter(CollectionFilterWidget *filter) { filter_ = filte
void CollectionView::TotalSongCountUpdated(int count) {
bool old = total_song_count_;
int old = total_song_count_;
total_song_count_ = count;
if (old != total_song_count_) update();
@@ -376,7 +373,7 @@ void CollectionView::TotalSongCountUpdated(int count) {
void CollectionView::TotalArtistCountUpdated(int count) {
bool old = total_artist_count_;
int old = total_artist_count_;
total_artist_count_ = count;
if (old != total_artist_count_) update();
@@ -391,7 +388,7 @@ void CollectionView::TotalArtistCountUpdated(int count) {
void CollectionView::TotalAlbumCountUpdated(int count) {
bool old = total_album_count_;
int old = total_album_count_;
total_album_count_ = count;
if (old != total_album_count_) update();

View File

@@ -167,13 +167,10 @@ bool ContextItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view,
switch (event->type()) {
case QEvent::ToolTip: {
QRect displayed_text;
QSize real_text;
bool is_elided = false;
real_text = sizeHint(option, index);
displayed_text = view->visualRect(index);
is_elided = displayed_text.width() < real_text.width();
QSize real_text = sizeHint(option, index);
QRect displayed_text = view->visualRect(index);
bool is_elided = displayed_text.width() < real_text.width();
if (is_elided) {
QToolTip::showText(he->globalPos(), text, view);

View File

@@ -72,7 +72,7 @@ bool Application::kIsPortable = false;
class ApplicationImpl {
public:
ApplicationImpl(Application *app) :
explicit ApplicationImpl(Application *app) :
tag_reader_client_([=]() {
TagReaderClient *client = new TagReaderClient(app);
app->MoveToNewThread(client);

View File

@@ -312,8 +312,8 @@ bool CommandlineOptions::is_empty() const {
seek_to_ == -1 &&
seek_by_ == 0 &&
play_track_at_ == -1 &&
show_osd_ == false &&
toggle_pretty_osd_ == false &&
!show_osd_ &&
!toggle_pretty_osd_ &&
urls_.isEmpty();
}

View File

@@ -1321,7 +1321,7 @@ void MainWindow::AddToPlaylist(QAction *action) {
}
SongList songs;
for (PlaylistItemPtr item : items) {
for (const PlaylistItemPtr &item : items) {
songs << item->Metadata();
}
@@ -1587,7 +1587,7 @@ void MainWindow::EditTracks() {
void MainWindow::EditTagDialogAccepted() {
for (PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) {
for (const PlaylistItemPtr &item : edit_tag_dialog_->playlist_items()) {
item->Reload();
}
@@ -2256,7 +2256,7 @@ void MainWindow::AutoCompleteTags() {
void MainWindow::AutoCompleteTagsAccepted() {
for (PlaylistItemPtr item : autocomplete_tag_items_) {
for (const PlaylistItemPtr &item : autocomplete_tag_items_) {
item->Reload();
}

View File

@@ -81,6 +81,8 @@ const char *Player::kSettingsGroup = "Player";
Player::Player(Application *app, QObject *parent)
: PlayerInterface(parent),
app_(app),
analyzer_(nullptr),
equalizer_(nullptr),
stream_change_type_(Engine::First),
last_state_(Engine::Empty),
nb_errors_received_(0),

View File

@@ -257,7 +257,7 @@ void SongLoader::LoadLocalAsync(const QString &filename) {
cue.open(QIODevice::ReadOnly);
SongList song_list = cue_parser_->Load(&cue, matching_cue, QDir(filename.section('/', 0, -2)));
for (Song song: song_list){
for (const Song &song : song_list) {
if (song.is_valid()) songs_ << song;
}
return;

View File

@@ -263,7 +263,7 @@ bool RemoveRecursive(const QString &path) {
return false;
}
if (!dir.rmdir(path)) return false;
return dir.rmdir(path);
return true;

View File

@@ -422,10 +422,7 @@ bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent *e) {
const QString suffix = QFileInfo(url.toLocalFile()).suffix().toLower();
if (IsKnownImageExtension(suffix)) return true;
}
if (e->mimeData()->hasImage()) {
return true;
}
return false;
return e->mimeData()->hasImage();
}

View File

@@ -31,8 +31,9 @@
#include "core/tagreaderclient.h"
#include "coverexportrunnable.h"
CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song)
: dialog_result_(dialog_result), song_(song) {}
CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song) :
dialog_result_(dialog_result),
song_(song) {}
void CoverExportRunnable::run() {

View File

@@ -55,7 +55,7 @@ signals:
AlbumCoverExport::DialogResult dialog_result_;
Song song_;
AlbumCoverExporter* album_cover_exporter_;
};
#endif // COVEREXPORTRUNNABLE_H

View File

@@ -197,7 +197,7 @@ void CddaSongLoader::AudioCDTagsLoaded(const QString &artist, const QString &alb
MusicBrainzClient *musicbrainz_client = qobject_cast<MusicBrainzClient*>(sender());
musicbrainz_client->deleteLater();
SongList songs;
if (results.size() == 0) return;
if (results.empty()) return;
int track_number = 1;
for (const MusicBrainzClient::Result &ret : results) {
Song song;

View File

@@ -36,8 +36,10 @@
const int DeviceDatabaseBackend::kDeviceSchemaVersion = 0;
DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent)
: QObject(parent) {}
DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent) :
QObject(parent),
db_(nullptr)
{}
void DeviceDatabaseBackend::Init(Database* db) { db_ = db; }

View File

@@ -37,7 +37,9 @@
#include "core/logging.h"
DeviceLister::DeviceLister() : thread_(nullptr) {}
DeviceLister::DeviceLister() :
thread_(nullptr),
next_mount_request_id_(0) {}
DeviceLister::~DeviceLister() {

View File

@@ -686,7 +686,7 @@ void DeviceManager::Forget(QModelIndex idx) {
backend_->RemoveDevice(info->database_id_);
info->database_id_ = -1;
if (!info->BestBackend() || (info->BestBackend() && !info->BestBackend()->lister_)) { // It's not attached any more so remove it from the list
if (!info->BestBackend() || !info->BestBackend()->lister_) { // It's not attached any more so remove it from the list
beginRemoveRows(ItemToIndex(root_), idx.row(), idx.row());
devices_.removeAll(info);
root_->Delete(info->row);

View File

@@ -36,7 +36,8 @@ MtpLoader::MtpLoader(const QUrl &url, TaskManager *task_manager, CollectionBacke
device_(device),
url_(url),
task_manager_(task_manager),
backend_(backend) {
backend_(backend),
connection_(nullptr) {
original_thread_ = thread();
}

View File

@@ -41,7 +41,6 @@ AlsaDeviceFinder::AlsaDeviceFinder()
QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
QList<Device> ret;
int result = -1;
snd_pcm_stream_name(SND_PCM_STREAM_PLAYBACK);
@@ -50,7 +49,7 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
snd_ctl_card_info_alloca(&cardinfo);
while (true) {
result = snd_card_next(&card);
int result = snd_card_next(&card);
if (result < 0) {
qLog(Error) << "Unable to get soundcard:" << snd_strerror(result);
break;

View File

@@ -52,6 +52,7 @@ Engine::Base::Base()
crossfade_enabled_(true),
autocrossfade_enabled_(false),
crossfade_same_album_(false),
fadeout_pause_enabled_(false),
fadeout_duration_(2),
fadeout_duration_nanosec_(2 * kNsecPerSec),
about_to_end_emitted_(false) {}

View File

@@ -367,10 +367,10 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
output.name = plugin.name;
output.description = plugin.description;
if (plugin.name == kAutoSink) output.iconname = "soundcard";
else if ((plugin.name == kALSASink) || (plugin.name == kOSS4Sink) || (plugin.name == kOSS4Sink)) output.iconname = "alsa";
else if (plugin.name== kJackAudioSink) output.iconname = "jack";
else if (plugin.name == kALSASink || plugin.name == kOSS4Sink) output.iconname = "alsa";
else if (plugin.name == kJackAudioSink) output.iconname = "jack";
else if (plugin.name == kPulseSink) output.iconname = "pulseaudio";
else if ((plugin.name == kA2DPSink) || (plugin.name == kAVDTPSink)) output.iconname = "bluetooth";
else if (plugin.name == kA2DPSink || plugin.name == kAVDTPSink) output.iconname = "bluetooth";
else output.iconname = "soundcard";
ret.append(output);
}

View File

@@ -89,6 +89,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine *engine)
next_uri_set_(false),
volume_percent_(100),
volume_modifier_(1.0),
use_fudge_timer_(false),
pipeline_(nullptr),
audiobin_(nullptr),
queue_(nullptr),

View File

@@ -183,7 +183,6 @@ EngineBase::OutputDetailsList PhononEngine::GetOutputsList() const {
bool PhononEngine::ValidOutput(const QString &output) {
return (output == "auto" || output == "" || output == DefaultOutput());
return(false);
}

View File

@@ -861,7 +861,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n
// exercise vetoes
SongList songs;
for (PlaylistItemPtr item : items) {
for (const PlaylistItemPtr &item : items) {
songs << item->Metadata();
}
@@ -1432,13 +1432,11 @@ PlaylistItemList Playlist::RemoveItemsWithoutUndo(int row, int count) {
endRemoveRows();
QList<int>::iterator it = virtual_items_.begin();
int i = 0;
while (it != virtual_items_.end()) {
if (*it >= items_.count())
it = virtual_items_.erase(it);
else
++it;
++i;
}
// Reset current_virtual_index_
@@ -1738,7 +1736,7 @@ QSortFilterProxyModel *Playlist::proxy() const { return proxy_; }
SongList Playlist::GetAllSongs() const {
SongList ret;
for (PlaylistItemPtr item : items_) {
for (const PlaylistItemPtr &item : items_) {
ret << item->Metadata();
}
return ret;
@@ -1748,7 +1746,7 @@ PlaylistItemList Playlist::GetAllItems() const { return items_; }
quint64 Playlist::GetTotalLength() const {
quint64 ret = 0;
for (PlaylistItemPtr item : items_) {
for (const PlaylistItemPtr &item : items_) {
quint64 length = item->Metadata().length_nanosec();
if (length > 0) ret += length;
}

View File

@@ -291,7 +291,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items,
if (db_->CheckErrors(clear)) return;
// Save the new ones
for (PlaylistItemPtr item : items) {
for (const PlaylistItemPtr &item : items) {
insert.bindValue(":playlist", playlist);
item->BindToQuery(&insert);

View File

@@ -262,13 +262,9 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
switch (event->type()) {
case QEvent::ToolTip: {
QRect displayed_text;
QSize real_text;
bool is_elided = false;
real_text = sizeHint(option, index);
displayed_text = view->visualRect(index);
is_elided = displayed_text.width() < real_text.width();
QSize real_text = sizeHint(option, index);
QRect displayed_text = view->visualRect(index);
bool is_elided = displayed_text.width() < real_text.width();
if (is_elided) {
QToolTip::showText(he->globalPos(), text, view);
}

View File

@@ -296,7 +296,8 @@ FilterTree *FilterParser::parseAndGroup() {
break;
}
checkAnd(); // if there's no 'AND', we'll add the term anyway...
} while (iter_ != end_);
}
while (iter_ != end_);
return group;
}
@@ -304,13 +305,13 @@ bool FilterParser::checkAnd() {
if (iter_ != end_) {
if (*iter_ == QChar('A')) {
buf_ += *iter_;
iter_++;
++iter_;
if (iter_ != end_ && *iter_ == QChar('N')) {
buf_ += *iter_;
iter_++;
++iter_;
if (iter_ != end_ && *iter_ == QChar('D')) {
buf_ += *iter_;
iter_++;
++iter_;
if (iter_ != end_ && (iter_->isSpace() || *iter_ == QChar('-') || *iter_ == '(')) {
advance();
buf_.clear();
@@ -337,10 +338,10 @@ bool FilterParser::checkOr(bool step_over) {
if (iter_ != end_) {
if (*iter_ == 'O') {
buf_ += *iter_;
iter_++;
++iter_;
if (iter_ != end_ && *iter_ == 'R') {
buf_ += *iter_;
iter_++;
++iter_;
if (iter_ != end_ && (iter_->isSpace() || *iter_ == '-' || *iter_ == '(')) {
if (step_over) {
buf_.clear();
@@ -359,7 +360,7 @@ FilterTree *FilterParser::parseSearchExpression() {
advance();
if (iter_ == end_) return new NopFilter;
if (*iter_ == '(') {
iter_++;
++iter_;
advance();
FilterTree *tree = parseOrGroup();
advance();
@@ -375,7 +376,8 @@ FilterTree *FilterParser::parseSearchExpression() {
FilterTree *tree = parseSearchExpression();
if (tree->type() != FilterTree::Nop) return new NotFilter(tree);
return tree;
} else {
}
else {
return parseSearchTerm();
}
}
@@ -401,10 +403,10 @@ FilterTree *FilterParser::parseSearchTerm() {
buf_.clear();
prefix.clear(); // prefix isn't allowed here - let's ignore it
}
else if (iter_->isSpace() || *iter_ == '(' || *iter_ == ')' ||
*iter_ == '-') {
else if (iter_->isSpace() || *iter_ == '(' || *iter_ == ')' || *iter_ == '-') {
break;
} else if (buf_.isEmpty()) {
}
else if (buf_.isEmpty()) {
// we don't know whether there is a column part in this search term thus we assume the latter and just try and read a prefix
if (prefix.isEmpty() && (*iter_ == '>' || *iter_ == '<' || *iter_ == '=' || *iter_ == '!')) {
prefix += *iter_;
@@ -428,8 +430,8 @@ FilterTree *FilterParser::parseSearchTerm() {
return createSearchTermTreeNode(col, prefix, search);
}
FilterTree *FilterParser::createSearchTermTreeNode(
const QString &col, const QString &prefix, const QString &search) const {
FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QString &prefix, const QString &search) const {
if (search.isEmpty() && prefix != "=") {
return new NopFilter;
}

View File

@@ -451,7 +451,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) {
for (const Song &song : songs) {
for (const Data &data : playlists_) {
PlaylistItemList items = data.p->collection_items_by_id(song.id());
for (PlaylistItemPtr item : items) {
for (PlaylistItemPtr &item : items) {
if (item->Metadata().directory_id() != song.directory_id()) continue;
static_cast<CollectionPlaylistItem*>(item.get())->SetMetadata(song);
data.p->ItemChanged(item);

View File

@@ -411,14 +411,10 @@ bool PlaylistTabBar::event(QEvent *e) {
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(e);
QRect displayed_tab;
QSize real_tab;
bool is_elided = false;
real_tab = tabSizeHint(tabAt(he->pos()));
displayed_tab = tabRect(tabAt(he->pos()));
QSize real_tab = tabSizeHint(tabAt(he->pos()));
QRect displayed_tab = tabRect(tabAt(he->pos()));
// Check whether the tab is elided or not
is_elided = displayed_tab.width() < real_tab.width();
bool is_elided = displayed_tab.width() < real_tab.width();
if (!is_elided) {
// If it's not elided, don't show the tooltip
QToolTip::hideText();

View File

@@ -38,6 +38,7 @@ SongLoaderInserter::SongLoaderInserter(TaskManager *task_manager, CollectionBack
row_(-1),
play_now_(true),
enqueue_(false),
enqueue_next_(false),
collection_(collection),
player_(player) {}

View File

@@ -225,7 +225,7 @@ void Queue::UpdateTotalLength() {
quint64 total = 0;
for (QPersistentModelIndex row : source_indexes_) {
for (const QPersistentModelIndex &row : source_indexes_) {
int id = row.row();
Q_ASSERT(playlist_->has_item_at(id));

View File

@@ -291,12 +291,11 @@ QByteArray ListenBrainzScrobbler::GetReplyData(QNetworkReply *reply) {
data = reply->readAll();
QJsonParseError error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &error);
int error_code = -1;
QString error_reason;
if (error.error == QJsonParseError::NoError && !json_doc.isNull() && !json_doc.isEmpty() && json_doc.isObject()) {
QJsonObject json_obj = json_doc.object();
if (json_obj.contains("code") && json_obj.contains("error")) {
error_code = json_obj["code"].toInt();
int error_code = json_obj["code"].toInt();
QString error_message = json_obj["error"].toString();
error_reason = QString("%1 (%2)").arg(error_message).arg(error_code);
}

View File

@@ -342,7 +342,7 @@ void NotificationsSettingsPage::NotificationTypeChanged() {
#ifdef Q_OS_MACOS
ui_->notifications_options->setEnabled(pretty);
#endif
ui_->notifications_duration->setEnabled(!pretty || (pretty && !ui_->notifications_disable_duration->isChecked()));
ui_->notifications_duration->setEnabled(!pretty || !ui_->notifications_disable_duration->isChecked());
ui_->notifications_disable_duration->setEnabled(pretty);
}

View File

@@ -641,7 +641,6 @@ void TidalService::AlbumsReceived(QNetworkReply *reply, int search_id, int artis
}
int limit = 0;
int offset = 0;
int total_albums = 0;
if (artist_search_) { // This was a list of albums by artist
if (!json_obj.contains("limit") ||
@@ -653,7 +652,7 @@ void TidalService::AlbumsReceived(QNetworkReply *reply, int search_id, int artis
return;
}
limit = json_obj["limit"].toInt();
offset = json_obj["offset"].toInt();
int offset = json_obj["offset"].toInt();
total_albums = json_obj["totalNumberOfItems"].toInt();
if (offset != offset_requested) {
AlbumsFinished(artist_id, offset_requested, total_albums, limit);

View File

@@ -420,7 +420,7 @@ void FancyTabWidget::paintEvent(QPaintEvent *pe) {
QColor baseColor = StyleHelper::baseColor();
QRect backgroundRect = rect();
backgroundRect.setWidth(((FancyTabBar*)tabBar())->width());
backgroundRect.setWidth(tabBar()->width());
p.fillRect(backgroundRect, baseColor);
// Horizontal gradient over the sidebar from transparent to dark

View File

@@ -54,6 +54,7 @@ ExtendedEditor::ExtendedEditor(QWidget *widget, int extra_right_padding, bool dr
draw_hint_(draw_hint),
font_point_size_(widget->font().pointSizeF() - 1),
is_rtl_(false) {
clear_button_->setIcon(IconLoader::Load("edit-clear-locationbar-ltr"));
clear_button_->setIconSize(QSize(16, 16));
clear_button_->setCursor(Qt::ArrowCursor);
@@ -76,6 +77,7 @@ ExtendedEditor::ExtendedEditor(QWidget *widget, int extra_right_padding, bool dr
widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(setFocus()));
UpdateButtonGeometry();
}
void ExtendedEditor::set_hint(const QString& hint) {

View File

@@ -45,6 +45,7 @@ const int MultiLoadingIndicator::kSpacing = 6;
MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
: QWidget(parent),
task_manager_(nullptr),
spinner_(new BusyIndicator(this))
{
spinner_->move(kHorizontalPadding, kVerticalPadding);

View File

@@ -160,7 +160,7 @@ void OSD::CallFinished(QDBusPendingCallWatcher *watcher) {
std::unique_ptr<QDBusPendingCallWatcher> w(watcher);
QDBusPendingReply<uint> reply = *watcher;
QDBusPendingReply<uint> reply = *w.get();
if (reply.isError()) {
qLog(Warning) << "Error sending notification" << reply.error().name();
return;

View File

@@ -217,12 +217,7 @@ void PlayingWidget::SetMode(int mode) {
mode_ = Mode(mode);
if (mode_ == SmallSongDetails) {
fit_cover_width_action_->setEnabled(false);
}
else {
fit_cover_width_action_->setEnabled(true);
}
fit_cover_width_action_->setEnabled(mode_ != SmallSongDetails);
UpdateHeight();
UpdateDetailsText();