diff --git a/3rdparty/singleapplication/singleapplication.cpp b/3rdparty/singleapplication/singleapplication.cpp index dfa5cd04..82a681f9 100644 --- a/3rdparty/singleapplication/singleapplication.cpp +++ b/3rdparty/singleapplication/singleapplication.cpp @@ -244,8 +244,9 @@ bool SingleApplication::sendMessage(const QByteArray &message, const int timeout if (isPrimary()) return false; // Make sure the socket is connected - if (!d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect)) + if (!d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect)) { return false; + } d->socket_->write(message); const bool dataWritten = d->socket_->waitForBytesWritten(timeout); diff --git a/3rdparty/singleapplication/singleapplication_p.cpp b/3rdparty/singleapplication/singleapplication_p.cpp index 2aeac871..c2e67aaa 100644 --- a/3rdparty/singleapplication/singleapplication_p.cpp +++ b/3rdparty/singleapplication/singleapplication_p.cpp @@ -237,8 +237,9 @@ bool SingleApplicationPrivate::connectToPrimary(const int timeout, const Connect forever { randomSleep(); - if (socket_->state() != QLocalSocket::ConnectingState) + if (socket_->state() != QLocalSocket::ConnectingState) { socket_->connectToServer(blockServerName_); + } if (socket_->state() == QLocalSocket::ConnectingState) { socket_->waitForConnected(static_cast(timeout - time.elapsed())); diff --git a/3rdparty/singleapplication/singlecoreapplication.cpp b/3rdparty/singleapplication/singlecoreapplication.cpp index bcaeec41..db3a6d05 100644 --- a/3rdparty/singleapplication/singlecoreapplication.cpp +++ b/3rdparty/singleapplication/singlecoreapplication.cpp @@ -244,8 +244,9 @@ bool SingleCoreApplication::sendMessage(const QByteArray &message, const int tim if (isPrimary()) return false; // Make sure the socket is connected - if (!d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect)) + if (!d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect)) { return false; + } d->socket_->write(message); const bool dataWritten = d->socket_->waitForBytesWritten(timeout); diff --git a/3rdparty/singleapplication/singlecoreapplication_p.cpp b/3rdparty/singleapplication/singlecoreapplication_p.cpp index f2c0c7a6..7d8c89c0 100644 --- a/3rdparty/singleapplication/singlecoreapplication_p.cpp +++ b/3rdparty/singleapplication/singlecoreapplication_p.cpp @@ -237,8 +237,9 @@ bool SingleCoreApplicationPrivate::connectToPrimary(const int timeout, const Con forever { randomSleep(); - if (socket_->state() != QLocalSocket::ConnectingState) + if (socket_->state() != QLocalSocket::ConnectingState) { socket_->connectToServer(blockServerName_); + } if (socket_->state() == QLocalSocket::ConnectingState) { socket_->waitForConnected(static_cast(timeout - time.elapsed())); diff --git a/ext/gstmoodbar/gstfastspectrum.cpp b/ext/gstmoodbar/gstfastspectrum.cpp index 0cc12105..d87b85f3 100644 --- a/ext/gstmoodbar/gstfastspectrum.cpp +++ b/ext/gstmoodbar/gstfastspectrum.cpp @@ -311,8 +311,9 @@ static void input_data_mixed_int24_max (const guint8 * _in, double* out, guint l #else gint32 value = GST_READ_UINT24_LE (_in); #endif - if (value & 0x00800000) + if (value & 0x00800000) { value |= 0xff000000; + } out[op] = value / max_value; op = (op + 1) % nfft; @@ -374,8 +375,9 @@ static void gst_fastspectrum_run_fft (GstFastSpectrum * spectrum, guint input_po guint bands = spectrum->bands; guint nfft = 2 * bands - 2; - for (i = 0; i < nfft; i++) + for (i = 0; i < nfft; i++) { spectrum->fft_input[i] = spectrum->input_ring_buffer[(input_pos + i) % nfft]; + } // Should be safe to execute the same plan multiple times in parallel. fftw_execute(spectrum->plan); @@ -435,8 +437,9 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst /* rounding error for frames_per_interval in ns, * aggregated it in accumulated_error */ spectrum->error_per_interval = (spectrum->interval * rate) % GST_SECOND; - if (spectrum->frames_per_interval == 0) + if (spectrum->frames_per_interval == 0) { spectrum->frames_per_interval = 1; + } GST_INFO_OBJECT (spectrum, "interval %" GST_TIME_FORMAT ", fpi %" G_GUINT64_FORMAT ", error %" GST_TIME_FORMAT, @@ -448,8 +451,9 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst gst_fastspectrum_flush (spectrum); } - if (spectrum->num_frames == 0) + if (spectrum->num_frames == 0) { spectrum->message_ts = GST_BUFFER_TIMESTAMP (buffer); + } input_pos = spectrum->input_pos; input_data = spectrum->input_data; @@ -462,10 +466,12 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst "message frames todo: %u, fft frames todo: %u, input frames %" G_GSIZE_FORMAT, msg_todo, fft_todo, (size / bpf)); block_size = msg_todo; - if (block_size > (size / bpf)) + if (block_size > (size / bpf)) { block_size = (size / bpf); - if (block_size > fft_todo) + } + if (block_size > fft_todo) { block_size = fft_todo; + } /* Move the current frames into our ringbuffers */ input_data(data, spectrum->input_ring_buffer, block_size, max_value, input_pos, nfft); @@ -514,8 +520,9 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst memset(spectrum->spect_magnitude, 0, spectrum->bands * sizeof(double)); } - if (GST_CLOCK_TIME_IS_VALID (spectrum->message_ts)) + if (GST_CLOCK_TIME_IS_VALID (spectrum->message_ts)) { spectrum->message_ts += gst_util_uint64_scale (spectrum->num_frames, GST_SECOND, rate); + } spectrum->num_frames = 0; spectrum->num_fft = 0; diff --git a/src/analyzer/analyzerbase.cpp b/src/analyzer/analyzerbase.cpp index 8d3c1778..3959628d 100644 --- a/src/analyzer/analyzerbase.cpp +++ b/src/analyzer/analyzerbase.cpp @@ -126,10 +126,12 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) { int Analyzer::Base::resizeExponent(int exp) { - if (exp < 3) + if (exp < 3) { exp = 3; - else if (exp > 9) + } + else if (exp > 9) { exp = 9; + } if (exp != fht_->sizeExp()) { delete fht_; @@ -142,18 +144,24 @@ int Analyzer::Base::resizeExponent(int exp) { int Analyzer::Base::resizeForBands(const int bands) { int exp = 0; - if (bands <= 8) + if (bands <= 8) { exp = 4; - else if (bands <= 16) + } + else if (bands <= 16) { exp = 5; - else if (bands <= 32) + } + else if (bands <= 32) { exp = 6; - else if (bands <= 64) + } + else if (bands <= 64) { exp = 7; - else if (bands <= 128) + } + else if (bands <= 128) { exp = 8; - else + } + else { exp = 9; +} resizeExponent(exp); return fht_->size() / 2; @@ -164,18 +172,22 @@ void Analyzer::Base::demo(QPainter &p) { static int t = 201; // FIXME make static to namespace perhaps - if (t > 999) t = 1; // 0 = wasted calculations + if (t > 999) { + t = 1; // 0 = wasted calculations + } if (t < 201) { Scope s(32); const double dt = double(t) / 200; - for (uint i = 0; i < s.size(); ++i) + for (uint i = 0; i < s.size(); ++i) { s[i] = dt * (sin(M_PI + (i * M_PI) / s.size()) + 1.0); + } analyze(p, s, new_frame_); } - else + else { analyze(p, Scope(32, 0), new_frame_); + } ++t; @@ -196,11 +208,15 @@ void Analyzer::interpolate(const Scope &inVec, Scope &outVec) { uint64_t indexLeft = offset + 0; - if (indexLeft >= inVec.size()) indexLeft = inVec.size() - 1; + if (indexLeft >= inVec.size()) { + indexLeft = inVec.size() - 1; + } uint64_t indexRight = offset + 1; - if (indexRight >= inVec.size()) indexRight = inVec.size() - 1; + if (indexRight >= inVec.size()) { + indexRight = inVec.size() - 1; + } outVec[i] = inVec[indexLeft] * (1.0 - error) + inVec[indexRight] * error; } @@ -222,7 +238,9 @@ void Analyzer::initSin(Scope &v, const uint size) { void Analyzer::Base::timerEvent(QTimerEvent *e) { QWidget::timerEvent(e); - if (e->timerId() != timer_.timerId()) return; + if (e->timerId() != timer_.timerId()) { + return; + } new_frame_ = true; update(); diff --git a/src/analyzer/analyzercontainer.cpp b/src/analyzer/analyzercontainer.cpp index 4ee908a0..76a3de88 100644 --- a/src/analyzer/analyzercontainer.cpp +++ b/src/analyzer/analyzercontainer.cpp @@ -103,7 +103,9 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent) void AnalyzerContainer::mouseReleaseEvent(QMouseEvent *e) { - if (engine_->type() != Engine::EngineType::GStreamer) return; + if (engine_->type() != Engine::EngineType::GStreamer) { + return; + } if (e->button() == Qt::RightButton) { #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) @@ -124,8 +126,10 @@ void AnalyzerContainer::wheelEvent(QWheelEvent *e) { } void AnalyzerContainer::SetEngine(EngineBase *engine) { + if (current_analyzer_) current_analyzer_->set_engine(engine); engine_ = engine; + } void AnalyzerContainer::DisableAnalyzer() { diff --git a/src/analyzer/blockanalyzer.cpp b/src/analyzer/blockanalyzer.cpp index b31a2dff..e2ce83fd 100644 --- a/src/analyzer/blockanalyzer.cpp +++ b/src/analyzer/blockanalyzer.cpp @@ -88,15 +88,17 @@ void BlockAnalyzer::resizeEvent(QResizeEvent *e) { if (rows_ != oldRows) { barpixmap_ = QPixmap(kWidth, rows_ * (kHeight + 1)); - for (uint i = 0; i < kFadeSize; ++i) + for (uint i = 0; i < kFadeSize; ++i) { fade_bars_[i] = QPixmap(kWidth, rows_ * (kHeight + 1)); + } yscale_.resize(rows_ + 1); const int PRE = 1, PRO = 1; // PRE and PRO allow us to restrict the range somewhat - for (int z = 0; z < rows_; ++z) + for (int z = 0; z < rows_; ++z) { yscale_[z] = 1 - (log10(PRE + z) / log10(PRE + rows_ + PRO)); + } yscale_[rows_] = 0; @@ -168,10 +170,12 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram for (y = 0; scope_[x] < yscale_[y]; ++y) continue; // This is opposite to what you'd think, higher than y means the bar is lower than y (physically) - if (static_cast(y) > store_[x]) + if (static_cast(y) > store_[x]) { y = static_cast(store_[x] += step_); - else + } + else { store_[x] = y; + } // If y is lower than fade_pos_, then the bar has exceeded the height of the fadeout // if the fadeout is quite faded now, then display the new one @@ -192,8 +196,9 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram canvas_painter.drawPixmap(x * (kWidth + 1), y * (kHeight + 1) + y_, *bar(), 0, y * (kHeight + 1), bar()->width(), bar()->height()); } - for (int x = 0; x < store_.size(); ++x) + for (int x = 0; x < store_.size(); ++x) { canvas_painter.drawPixmap(x * (kWidth + 1), static_cast(store_[x]) * (kHeight + 1) + y_, topbarpixmap_); + } p.drawPixmap(0, 0, canvas_); @@ -279,20 +284,24 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) { // check the saturation for the two colours is sufficient that hue alone can // provide sufficient contrast - if (ds > amount / 2 && (bs > 125 && fs > 125)) + if (ds > amount / 2 && (bs > 125 && fs > 125)) { return fg; - else if (dv > amount / 2 && (bv > 125 && fv > 125)) + } + else if (dv > amount / 2 && (bv > 125 && fv > 125)) { return fg; + } } if (fs < 50 && ds < 40) { // low saturation on a low saturation is sad const int tmp = 50 - fs; fs = 50; - if (static_cast(amount) > tmp) + if (static_cast(amount) > tmp) { amount -= tmp; - else + } + else { amount = 0; + } } // test that there is available value to honor our contrast requirement @@ -309,19 +318,24 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) { return QColor::fromHsv(fh, fs, fv); } - if (fv > bv && bv > static_cast(amount)) + if (fv > bv && bv > static_cast(amount)) { return QColor::fromHsv(fh, fs, bv - static_cast(amount)); + } - if (fv < bv && fv > static_cast(amount)) + if (fv < bv && fv > static_cast(amount)) { return QColor::fromHsv(fh, fs, fv - amount); + } - if (fv > bv && (255 - fv > static_cast(amount))) + if (fv > bv && (255 - fv > static_cast(amount))) { return QColor::fromHsv(fh, fs, fv + amount); + } - if (fv < bv && (255 - bv > static_cast(amount))) + if (fv < bv && (255 - bv > static_cast(amount))) { return QColor::fromHsv(fh, fs, bv + amount); + } return Qt::blue; + } void BlockAnalyzer::paletteChange(const QPalette&) { @@ -339,9 +353,10 @@ void BlockAnalyzer::paletteChange(const QPalette&) { bar()->fill(bg); QPainter p(bar()); - for (int y = 0; y < rows_; ++y) + for (int y = 0; y < rows_; ++y) { // graduate the fg color p.fillRect(0, y * (kHeight + 1), kWidth, kHeight, QColor(r + static_cast(dr * y), g + static_cast(dg * y), b + static_cast(db * y))); + } { const QColor bg2 = palette().color(QPalette::Window).darker(112); @@ -387,8 +402,10 @@ void BlockAnalyzer::drawBackground() { if (!p.paintEngine()) return; - for (int x = 0; x < columns_; ++x) - for (int y = 0; y < rows_; ++y) + for (int x = 0; x < columns_; ++x) { + for (int y = 0; y < rows_; ++y) { p.fillRect(x * (kWidth + 1), y * (kHeight + 1) + y_, kWidth, kHeight, bgdark); + } + } } diff --git a/src/analyzer/boomanalyzer.cpp b/src/analyzer/boomanalyzer.cpp index 892e7204..6941ff90 100644 --- a/src/analyzer/boomanalyzer.cpp +++ b/src/analyzer/boomanalyzer.cpp @@ -158,8 +158,9 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame y = height() - static_cast(bar_height_[i]); canvas_painter.drawPixmap(x + 1, y, barPixmap_, 0, y, -1, -1); canvas_painter.setPen(fg_); - if (bar_height_[i] > 0) + if (bar_height_[i] > 0) { canvas_painter.drawRect(x, y, kColumnWidth - 1, height() - y - 1); + } y = height() - static_cast(peak_height_[i]); canvas_painter.setPen(palette().color(QPalette::Midlight)); diff --git a/src/analyzer/fht.cpp b/src/analyzer/fht.cpp index 885c442b..ab321a7b 100644 --- a/src/analyzer/fht.cpp +++ b/src/analyzer/fht.cpp @@ -28,11 +28,13 @@ #include FHT::FHT(int n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? -1 : n) { + if (n > 3) { buf_vector_.resize(num_); tab_vector_.resize(num_ * 2); makeCasTable(); } + } FHT::~FHT() = default; @@ -45,6 +47,7 @@ float *FHT::tab_() { return tab_vector_.data(); } int *FHT::log_() { return log_vector_.data(); } void FHT::makeCasTable(void) { + float *costab = tab_(); float *sintab = tab_() + num_ / 2 + 1; @@ -56,6 +59,7 @@ void FHT::makeCasTable(void) { sintab += 2; if (sintab > tab_() + num_ * 2) sintab = tab_() + 1; } + } void FHT::scale(float *p, float d) const { @@ -94,25 +98,33 @@ void FHT::logSpectrum(float *out, float *p) { } void FHT::semiLogSpectrum(float *p) { + power2(p); for (int i = 0; i < (num_ / 2); i++, p++) { float e = 10.0 * log10(sqrt(*p / 2)); *p = e < 0 ? 0 : e; } + } void FHT::spectrum(float *p) { + power2(p); - for (int i = 0; i < (num_ / 2); i++, p++) + for (int i = 0; i < (num_ / 2); i++, p++) { *p = static_cast(sqrt(*p / 2)); + } + } void FHT::power(float *p) { + power2(p); for (int i = 0; i < (num_ / 2); i++) *p++ /= 2; + } void FHT::power2(float *p) { + _transform(p, num_, 0); *p = static_cast(2 * pow(*p, 2)); @@ -124,13 +136,18 @@ void FHT::power2(float *p) { p++; q--; } + } void FHT::transform(float *p) { - if (num_ == 8) + + if (num_ == 8) { transform8(p); - else + } + else { _transform(p, num_, 0); + } + } void FHT::transform8(float *p) { diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index f05c86df..0c3aaed3 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -209,8 +209,9 @@ void CollectionModel::Init(const bool async) { endResetModel(); // Show a loading indicator in the status bar too. - if (app_) + if (app_) { init_task_id_ = app_->task_manager()->StartTask(tr("Loading songs")); + } ResetAsync(); } @@ -256,11 +257,14 @@ void CollectionModel::SongsDiscovered(const SongList &songs) { key.append(ContainerKey(type, song)); // Does it exist already? - if (!container_nodes_[i].contains(key)) { - // Create the container - container_nodes_[i][key] = ItemFromSong(type, true, i == 0, container, song, i); + if (container_nodes_[i].contains(key)) { + container = container_nodes_[i][key]; + } + else { + // Create the container + container = ItemFromSong(type, true, i == 0, container, song, i); + container_nodes_[i].insert(key, container); } - container = container_nodes_[i][key]; } @@ -270,7 +274,7 @@ void CollectionModel::SongsDiscovered(const SongList &songs) { if (!container->lazy_loaded && use_lazy_loading_) continue; // We've gone all the way down to the deepest level and everything was already lazy loaded, so now we have to create the song in the container. - song_nodes_[song.id()] = ItemFromSong(GroupBy_None, true, false, container, song, -1); + song_nodes_.insert(song.id(), ItemFromSong(GroupBy_None, true, false, container, song, -1)); } } @@ -570,7 +574,7 @@ void CollectionModel::SongsDeleted(const SongList &songs) { } // Remove from pending art loading - for (QMap::iterator it = pending_art_.begin() ; it != pending_art_.end();) { + for (QMap::iterator it = pending_art_.begin(); it != pending_art_.end();) { if (it.value().first == node) { it = pending_art_.erase(it); // clazy:exclude=strict-iterators } @@ -897,10 +901,10 @@ void CollectionModel::PostQuery(CollectionItem *parent, const CollectionModel::Q // Save a pointer to it for later if (child_type == GroupBy_None) { - song_nodes_[item->metadata.id()] = item; + song_nodes_.insert(item->metadata.id(), item); } else { - container_nodes_[child_level][item->key] = item; + container_nodes_[child_level].insert(item->key, item); } } diff --git a/src/collection/collectionview.cpp b/src/collection/collectionview.cpp index a511bdf5..c06ae066 100644 --- a/src/collection/collectionview.cpp +++ b/src/collection/collectionview.cpp @@ -254,10 +254,12 @@ void CollectionView::TotalSongCountUpdated(const int count) { total_song_count_ = count; if (old != total_song_count_) update(); - if (total_song_count_ == 0) + if (total_song_count_ == 0) { setCursor(Qt::PointingHandCursor); - else + } + else { unsetCursor(); + } emit TotalSongCountUpdated_(); @@ -269,10 +271,12 @@ void CollectionView::TotalArtistCountUpdated(const int count) { total_artist_count_ = count; if (old != total_artist_count_) update(); - if (total_artist_count_ == 0) + if (total_artist_count_ == 0) { setCursor(Qt::PointingHandCursor); - else + } + else { unsetCursor(); + } emit TotalArtistCountUpdated_(); @@ -284,10 +288,12 @@ void CollectionView::TotalAlbumCountUpdated(const int count) { total_album_count_ = count; if (old != total_album_count_) update(); - if (total_album_count_ == 0) + if (total_album_count_ == 0) { setCursor(Qt::PointingHandCursor); - else + } + else { unsetCursor(); + } emit TotalAlbumCountUpdated_(); @@ -548,10 +554,12 @@ void CollectionView::keyboardSearch(const QString &search) { void CollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) { - if (is_in_keyboard_search_) + if (is_in_keyboard_search_) { QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop); - else + } + else { QTreeView::scrollTo(idx, hint); + } } diff --git a/src/context/contextalbumsmodel.cpp b/src/context/contextalbumsmodel.cpp index 37d843c8..8bb0b8f3 100644 --- a/src/context/contextalbumsmodel.cpp +++ b/src/context/contextalbumsmodel.cpp @@ -84,12 +84,15 @@ void ContextAlbumsModel::AddSongs(const SongList &songs) { for (const Song &song : songs) { if (song_nodes_.contains(song.id())) continue; - CollectionItem *container = root_; QString key = CollectionModel::ContainerKey(CollectionModel::GroupBy_Album, song); - if (!container_nodes_.contains(key)) { - container_nodes_.insert(key, ItemFromSong(CollectionItem::Type_Container, true, container, song, 0)); + CollectionItem *container = nullptr; + if (container_nodes_.contains(key)) { + container = container_nodes_[key]; + } + else { + container = ItemFromSong(CollectionItem::Type_Container, true, container, song, 0); + container_nodes_.insert(key, container); } - container = container_nodes_[key]; song_nodes_[song.id()] = ItemFromSong(CollectionItem::Type_Song, true, container, song, -1); } @@ -240,7 +243,7 @@ QVariant ContextAlbumsModel::data(const CollectionItem *item, int role) const { void ContextAlbumsModel::Reset() { - for (QMap::iterator it = container_nodes_.begin() ; it != container_nodes_.end(); ++it) { + for (QMap::iterator it = container_nodes_.begin(); it != container_nodes_.end(); ++it) { const QString cache_key = AlbumIconPixmapCacheKey(ItemToIndex(it.value())); QPixmapCache::remove(cache_key); } diff --git a/src/context/contextalbumsview.cpp b/src/context/contextalbumsview.cpp index 2daee6e1..33dee66c 100644 --- a/src/context/contextalbumsview.cpp +++ b/src/context/contextalbumsview.cpp @@ -366,10 +366,12 @@ void ContextAlbumsView::OpenInNewPlaylist() { void ContextAlbumsView::scrollTo(const QModelIndex &idx, ScrollHint hint) { - if (is_in_keyboard_search_) + if (is_in_keyboard_search_) { QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop); - else + } + else { QTreeView::scrollTo(idx, hint); + } } @@ -386,8 +388,9 @@ void ContextAlbumsView::Organize() { organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model()); organize_dialog_->SetCopy(false); - if (organize_dialog_->SetSongs(GetSelectedSongs())) + if (organize_dialog_->SetSongs(GetSelectedSongs())) { organize_dialog_->show(); + } else { QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device")); } diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index 39be4067..1039a2ef 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -311,10 +311,12 @@ bool CommandlineOptions::Parse() { for (int i = optind; i < argc_; ++i) { QString value = QFile::decodeName(argv_[i]); QFileInfo file_info(value); - if (file_info.exists()) + if (file_info.exists()) { urls_ << QUrl::fromLocalFile(file_info.canonicalFilePath()); - else + } + else { urls_ << QUrl::fromUserInput(value); + } } return true; diff --git a/src/core/database.cpp b/src/core/database.cpp index ae668a86..0d6f5b78 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -135,10 +135,12 @@ QSqlDatabase Database::Connect() { db.setConnectOptions("QSQLITE_BUSY_TIMEOUT=30000"); //qLog(Debug) << "Opened database with connection id" << connection_id; - if (!injected_database_name_.isNull()) - db.setDatabaseName(injected_database_name_); - else + if (injected_database_name_.isNull()) { db.setDatabaseName(directory_ + "/" + kDatabaseFilename); + } + else { + db.setDatabaseName(injected_database_name_); + } if (!db.open()) { app_->AddError("Database: " + db.lastError().text()); @@ -206,8 +208,9 @@ QSqlDatabase Database::Connect() { // We might have to initialize the schema in some attached databases now, if they were deleted and don't match up with the main schema version. keys = attached_databases_.keys(); for (const QString &key : keys) { - if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) + if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) { continue; + } // Find out if there are any tables in this database QSqlQuery q(db); q.prepare(QString("SELECT ROWID FROM %1.sqlite_master WHERE type='table'").arg(key)); @@ -346,7 +349,9 @@ void Database::DetachDatabase(const QString &database_name) { void Database::UpdateDatabaseSchema(int version, QSqlDatabase &db) { QString filename; - if (version == 0) filename = ":/schema/schema.sql"; + if (version == 0) { + filename = ":/schema/schema.sql"; + } else { filename = QString(":/schema/schema-%1.sql").arg(version); qLog(Debug) << "Applying database schema update" << version << "from" << filename; diff --git a/src/core/filesystemmusicstorage.cpp b/src/core/filesystemmusicstorage.cpp index 9e0f963b..a2f33855 100644 --- a/src/core/filesystemmusicstorage.cpp +++ b/src/core/filesystemmusicstorage.cpp @@ -109,18 +109,22 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) { if (job.use_trash_) { #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - if (fileInfo.isDir()) + if (fileInfo.isDir()) { return Utilities::MoveToTrashRecursive(path); - else + } + else { return QFile::moveToTrash(path); + } #else return false; #endif } - if (fileInfo.isDir()) + if (fileInfo.isDir()) { return Utilities::RemoveRecursive(path); - else + } + else { return QFile::remove(path); + } } diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 57daedc7..516a2f68 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -670,8 +670,9 @@ MainWindow::MainWindow(Application *app, std::shared_ptr tray_ic QObject::connect(tidal_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); QObject::connect(tidal_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist); QObject::connect(tidal_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist); - if (TidalService *tidalservice = qobject_cast (app_->internet_services()->ServiceBySource(Song::Source_Tidal))) + if (TidalService *tidalservice = qobject_cast (app_->internet_services()->ServiceBySource(Song::Source_Tidal))) { QObject::connect(this, &MainWindow::AuthorizationUrlReceived, tidalservice, &TidalService::AuthorizationUrlReceived); + } #endif #ifdef HAVE_QOBUZ @@ -1087,10 +1088,12 @@ void MainWindow::ReloadSettings() { s.beginGroup(SubsonicSettingsPage::kSettingsGroup); bool enable_subsonic = s.value("enabled", false).toBool(); s.endGroup(); - if (enable_subsonic) + if (enable_subsonic) { ui_->tabs->EnableTab(subsonic_view_); - else + } + else { ui_->tabs->DisableTab(subsonic_view_); + } app_->scrobbler()->Service()->ReloadSettings(); #endif @@ -1098,20 +1101,24 @@ void MainWindow::ReloadSettings() { s.beginGroup(TidalSettingsPage::kSettingsGroup); bool enable_tidal = s.value("enabled", false).toBool(); s.endGroup(); - if (enable_tidal) + if (enable_tidal) { ui_->tabs->EnableTab(tidal_view_); - else + } + else { ui_->tabs->DisableTab(tidal_view_); + } #endif #ifdef HAVE_QOBUZ s.beginGroup(QobuzSettingsPage::kSettingsGroup); bool enable_qobuz = s.value("enabled", false).toBool(); s.endGroup(); - if (enable_qobuz) + if (enable_qobuz) { ui_->tabs->EnableTab(qobuz_view_); - else + } + else { ui_->tabs->DisableTab(qobuz_view_); + } #endif ui_->tabs->ReloadSettings(); @@ -1884,10 +1891,12 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex & else if (in_queue == 0 && not_in_queue > 1) playlist_queue_->setText(tr("Queue selected tracks")); else playlist_queue_->setText(tr("Toggle queue status")); - if (selected > 1) + if (selected > 1) { playlist_queue_play_next_->setText(tr("Queue selected tracks to play next")); - else + } + else { playlist_queue_play_next_->setText(tr("Queue to play next")); + } if (in_skipped == 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip track")); else if (in_skipped > 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip selected tracks")); @@ -2816,7 +2825,7 @@ void MainWindow::CheckFullRescanRevisions() { // Collect all reasons QSet reasons; - for (int i = from ; i <= to ; ++i) { + for (int i = from; i <= to; ++i) { QString reason = app_->collection()->full_rescan_reason(i); if (!reason.isEmpty()) { reasons.insert(reason); diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index 2e134981..ca091d94 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -237,8 +237,9 @@ void MergedProxyModel::SubModelResetSlot() { QModelIndex MergedProxyModel::GetActualSourceParent(const QModelIndex &source_parent, QAbstractItemModel *model) const { - if (!source_parent.isValid() && model != sourceModel()) + if (!source_parent.isValid() && model != sourceModel()) { return merge_points_.value(model); + } return source_parent; } @@ -303,10 +304,12 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare QModelIndex source_parent = mapToSource(parent); const QAbstractItemModel *child_model = merge_points_.key(source_parent); - if (child_model) + if (child_model) { source_index = child_model->index(row, column, QModelIndex()); - else + } + else { source_index = source_parent.model()->index(row, column, source_parent); + } } return mapFromSource(source_index); @@ -316,13 +319,16 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare QModelIndex MergedProxyModel::parent(const QModelIndex &child) const { QModelIndex source_child = mapToSource(child); - if (source_child.model() == sourceModel()) + if (source_child.model() == sourceModel()) { return mapFromSource(source_child.parent()); + } if (!IsKnownModel(source_child.model())) return QModelIndex(); - if (!source_child.parent().isValid()) + if (!source_child.parent().isValid()) { return mapFromSource(merge_points_.value(GetModel(source_child))); + } + return mapFromSource(source_child.parent()); } @@ -404,8 +410,10 @@ bool MergedProxyModel::setData(const QModelIndex &idx, const QVariant &value, in QModelIndex source_index = mapToSource(idx); - if (!source_index.isValid()) + if (!source_index.isValid()) { return sourceModel()->setData(idx, value, role); + } + return GetModel(idx)->setData(idx, value, role); } @@ -471,8 +479,10 @@ bool MergedProxyModel::canFetchMore(const QModelIndex &parent) const { QModelIndex source_index = mapToSource(parent); - if (!source_index.isValid()) + if (!source_index.isValid()) { return sourceModel()->canFetchMore(QModelIndex()); + } + return source_index.model()->canFetchMore(source_index); } @@ -481,10 +491,12 @@ void MergedProxyModel::fetchMore(const QModelIndex &parent) { QModelIndex source_index = mapToSource(parent); - if (!source_index.isValid()) + if (!source_index.isValid()) { sourceModel()->fetchMore(QModelIndex()); - else + } + else { GetModel(source_index)->fetchMore(source_index); + } } @@ -497,6 +509,7 @@ QAbstractItemModel *MergedProxyModel::GetModel(const QModelIndex &source_index) for (QAbstractItemModel *submodel : submodels) { if (submodel == const_model) return submodel; } + return nullptr; } diff --git a/src/core/mpris2.cpp b/src/core/mpris2.cpp index beffef22..dbb54c63 100644 --- a/src/core/mpris2.cpp +++ b/src/core/mpris2.cpp @@ -133,8 +133,9 @@ Mpris2::Mpris2(Application *app, QObject *parent) app_name_[0] = app_name_[0].toUpper(); - if (!QGuiApplication::desktopFileName().isEmpty()) + if (!QGuiApplication::desktopFileName().isEmpty()) { desktop_files_ << QGuiApplication::desktopFileName(); + } QStringList domain_split = QCoreApplication::organizationDomain().split("."); std::reverse(domain_split.begin(), domain_split.end()); diff --git a/src/core/multisortfilterproxy.cpp b/src/core/multisortfilterproxy.cpp index 732dceef..f0a1a633 100644 --- a/src/core/multisortfilterproxy.cpp +++ b/src/core/multisortfilterproxy.cpp @@ -97,10 +97,12 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c case QVariant::String: #endif default: - if (isSortLocaleAware()) + if (isSortLocaleAware()) { return left.toString().localeAwareCompare(right.toString()); - else + } + else { return left.toString().compare(right.toString(), sortCaseSensitivity()); + } } return 0; diff --git a/src/core/networkproxyfactory.cpp b/src/core/networkproxyfactory.cpp index 69e032a5..97465af1 100644 --- a/src/core/networkproxyfactory.cpp +++ b/src/core/networkproxyfactory.cpp @@ -114,10 +114,12 @@ QList NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q ret.setPort(env_url_.port()); ret.setUser(env_url_.userName()); ret.setPassword(env_url_.password()); - if (env_url_.scheme().startsWith("http")) + if (env_url_.scheme().startsWith("http")) { ret.setType(QNetworkProxy::HttpProxy); - else + } + else { ret.setType(QNetworkProxy::Socks5Proxy); + } qLog(Debug) << "Using proxy URL:" << env_url_; } break; diff --git a/src/core/player.cpp b/src/core/player.cpp index 7b91ffbc..3ca45a6d 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -111,7 +111,7 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) { Engine::EngineType use_enginetype(Engine::None); - for (int i = 0 ; use_enginetype == Engine::None ; i++) { + for (int i = 0; use_enginetype == Engine::None; i++) { switch(enginetype) { case Engine::None: #ifdef HAVE_GSTREAMER diff --git a/src/core/song.cpp b/src/core/song.cpp index 84ddd859..352e2f56 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -899,7 +899,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) { int x = col; d->id_ = toint(col); - for (int i = 0 ; i < Song::kColumns.size(); i++) { + for (int i = 0; i < Song::kColumns.size(); i++) { x++; if (x >= q.columns_.size()) { @@ -1609,8 +1609,9 @@ bool Song::IsOnSameAlbum(const Song &other) const { if (is_compilation() != other.is_compilation()) return false; - if (has_cue() && other.has_cue() && cue_path() == other.cue_path()) + if (has_cue() && other.has_cue() && cue_path() == other.cue_path()) { return true; + } if (is_compilation() && album() == other.album()) return true; diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 857ad0e7..7512e8f6 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -543,8 +543,9 @@ GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo *info, gpointer SongLoader *instance = reinterpret_cast(self); - if (instance->state_ == Finished) + if (instance->state_ == Finished) { return GST_PAD_PROBE_OK; + } GstBuffer *buffer = gst_pad_probe_info_get_buffer(info); GstMapInfo map; diff --git a/src/core/standarditemiconloader.cpp b/src/core/standarditemiconloader.cpp index a58cc08e..aa406831 100644 --- a/src/core/standarditemiconloader.cpp +++ b/src/core/standarditemiconloader.cpp @@ -71,7 +71,7 @@ void StandardItemIconLoader::LoadIcon(const Song &song, QStandardItem *for_item) void StandardItemIconLoader::RowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end) { - for (QMap::iterator it = pending_covers_.begin() ; it != pending_covers_.end() ; ) { + for (QMap::iterator it = pending_covers_.begin(); it != pending_covers_.end();) { const QStandardItem *item = it.value(); const QStandardItem *item_parent = item->parent(); diff --git a/src/core/stylehelper.cpp b/src/core/stylehelper.cpp index 5e0b67a3..9533c48d 100644 --- a/src/core/stylehelper.cpp +++ b/src/core/stylehelper.cpp @@ -90,8 +90,9 @@ qreal StyleHelper::sidebarFontSize() { QColor StyleHelper::notTooBrightHighlightColor() { QColor highlightColor = QApplication::palette().highlight().color(); - if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0) + if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0) { highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF()); + } return highlightColor; } @@ -108,29 +109,36 @@ QPalette StyleHelper::sidebarFontPalette(const QPalette &original) { QColor StyleHelper::panelTextColor(bool lightColored) { - if (!lightColored) - return Qt::white; - else + if (lightColored) { return Qt::black; + } + else { + return Qt::white; + } } QColor StyleHelper::baseColor(bool lightColored) { - if (!lightColored) - return m_baseColor; - else + if (lightColored) { return m_baseColor.lighter(230); + } + else { + return m_baseColor; + } } QColor StyleHelper::highlightColor(bool lightColored) { QColor result = baseColor(lightColored); - if (!lightColored) - result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16)); - else + if (lightColored) { result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.06)); + } + else { + result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16)); + } + return result; } @@ -284,8 +292,9 @@ static void menuGradientHelper(QPainter *p, const QRect spanRect, const QRect re void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option) { - if (option->rect.width() <= 1 || option->rect.height() <= 1) + if (option->rect.width() <= 1 || option->rect.height() <= 1) { return; + } const qreal devicePixelRatio = painter->device()->devicePixelRatio(); const bool enabled = option->state & QStyle::State_Enabled; @@ -383,24 +392,30 @@ void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QR const QSize size = img.size(); if (top > 0) { //top painter->drawImage(QRectF(rect.left() + left, rect.top(), rect.width() -right - left, top), img, QRectF(leftDIP, 0, size.width() - rightDIP - leftDIP, topDIP)); - if (left > 0) //top-left + if (left > 0) { //top-left painter->drawImage(QRectF(rect.left(), rect.top(), left, top), img, QRectF(0, 0, leftDIP, topDIP)); - if (right > 0) //top-right + } + if (right > 0) { //top-right painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top(), right, top), img, QRectF(size.width() - rightDIP, 0, rightDIP, topDIP)); + } } //left - if (left > 0) + if (left > 0) { painter->drawImage(QRectF(rect.left(), rect.top()+top, left, rect.height() - top - bottom), img, QRectF(0, topDIP, leftDIP, size.height() - bottomDIP - topDIP)); + } //center painter->drawImage(QRectF(rect.left() + left, rect.top()+top, rect.width() -right - left, rect.height() - bottom - top), img, QRectF(leftDIP, topDIP, size.width() - rightDIP - leftDIP, size.height() - bottomDIP - topDIP)); - if (right > 0) //right + if (right > 0) { //right painter->drawImage(QRectF(rect.left() +rect.width() - right, rect.top()+top, right, rect.height() - top - bottom), img, QRectF(size.width() - rightDIP, topDIP, rightDIP, size.height() - bottomDIP - topDIP)); + } if (bottom > 0) { //bottom painter->drawImage(QRectF(rect.left() +left, rect.top() + rect.height() - bottom, rect.width() - right - left, bottom), img, QRectF(leftDIP, size.height() - bottomDIP, size.width() - rightDIP - leftDIP, bottomDIP)); - if (left > 0) //bottom-left - painter->drawImage(QRectF(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img, QRectF(0, size.height() - bottomDIP, leftDIP, bottomDIP)); - if (right > 0) //bottom-right - painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), img, QRectF(size.width() - rightDIP, size.height() - bottomDIP, rightDIP, bottomDIP)); + if (left > 0) { //bottom-left + painter->drawImage(QRectF(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img, QRectF(0, size.height() - bottomDIP, leftDIP, bottomDIP)); + } + if (right > 0) { //bottom-right + painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), img, QRectF(size.width() - rightDIP, size.height() - bottomDIP, rightDIP, bottomDIP)); + } } } @@ -445,8 +460,9 @@ QString StyleHelper::dpiSpecificImageFile(const QString &fileName) { // See QIcon::addFile() if (qApp->devicePixelRatio() > 1.0) { const QString atDprfileName = imageFileWithResolution(fileName, qRound(qApp->devicePixelRatio())); - if (QFile::exists(atDprfileName)) + if (QFile::exists(atDprfileName)) { return atDprfileName; + } } return fileName; @@ -463,9 +479,11 @@ QList StyleHelper::availableImageResolutions(const QString &fileName) { QList result; const int maxResolutions = qApp->devicePixelRatio(); - for (int i = 1; i <= maxResolutions; ++i) - if (QFile::exists(imageFileWithResolution(fileName, i))) + for (int i = 1; i <= maxResolutions; ++i) { + if (QFile::exists(imageFileWithResolution(fileName, i))) { result.append(i); + } + } return result; } diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 68b1e796..d2f2a0a9 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -187,14 +187,18 @@ QString PrettySize(const quint64 bytes) { QString ret; if (bytes > 0) { - if (bytes <= 1000) + if (bytes <= 1000) { ret = QString::number(bytes) + " bytes"; - else if (bytes <= 1000 * 1000) + } + else if (bytes <= 1000 * 1000) { ret = QString::asprintf("%.1f KB", float(bytes) / 1000); - else if (bytes <= 1000 * 1000 * 1000) + } + else if (bytes <= 1000 * 1000 * 1000) { ret = QString::asprintf("%.1f MB", float(bytes) / (1000 * 1000)); - else + } + else { ret = QString::asprintf("%.1f GB", float(bytes) / (1000 * 1000 * 1000)); + } } return ret; @@ -239,13 +243,15 @@ bool MoveToTrashRecursive(const QString &path) { #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QDir dir(path); for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) { - if (!MoveToTrashRecursive(path + "/" + child)) + if (!MoveToTrashRecursive(path + "/" + child)) { return false; + } } for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) { - if (!QFile::moveToTrash(path + "/" + child)) + if (!QFile::moveToTrash(path + "/" + child)) { return false; + } } return dir.rmdir(path); @@ -262,13 +268,15 @@ bool RemoveRecursive(const QString &path) { QDir dir(path); for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) { - if (!RemoveRecursive(path + "/" + child)) + if (!RemoveRecursive(path + "/" + child)) { return false; + } } for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) { - if (!QFile::remove(path + "/" + child)) + if (!QFile::remove(path + "/" + child)) { return false; + } } return dir.rmdir(path); @@ -736,7 +744,7 @@ QString CryptographicRandomString(const int len) { QString GetRandomString(const int len, const QString &UseCharacters) { QString randstr; - for (int i = 0 ; i < len ; ++i) { + for (int i = 0; i < len; ++i) { #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) const int index = QRandomGenerator::global()->bounded(0, UseCharacters.length()); #else @@ -844,7 +852,7 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString & // Replace the first line int pos = 0; QRegularExpressionMatch match; - for (match = variable_replacer.match(message, pos) ; match.hasMatch() ; match = variable_replacer.match(message, pos)) { + for (match = variable_replacer.match(message, pos); match.hasMatch(); match = variable_replacer.match(message, pos)) { pos = match.capturedStart(); QStringList captured = match.capturedTexts(); copy.replace(captured[0], ReplaceVariable(captured[0], song, newline, html_escaped)); @@ -976,7 +984,7 @@ HRGN toHRGN(const QRegion ®ion) { HRGN resultRgn = nullptr; QRegion::const_iterator rects = region.begin(); resultRgn = qt_RectToHRGN(rects[0]); - for (int i = 1 ; i < rect_count ; ++i) { + for (int i = 1; i < rect_count; ++i) { HRGN tmpRgn = qt_RectToHRGN(rects[i]); const int res = CombineRgn(resultRgn, resultRgn, tmpRgn, RGN_OR); if (res == ERROR) qWarning("Error combining HRGNs."); diff --git a/src/core/windows7thumbbar.cpp b/src/core/windows7thumbbar.cpp index 7c8b2dd0..3b796d62 100644 --- a/src/core/windows7thumbbar.cpp +++ b/src/core/windows7thumbbar.cpp @@ -135,7 +135,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) { // Add the buttons THUMBBUTTON buttons[kMaxButtonCount]; - for (int i = 0 ; i < actions_.count() ; ++i) { + for (int i = 0; i < actions_.count(); ++i) { const QAction *action = actions_[i]; THUMBBUTTON *button = &buttons[i]; button->iId = i; @@ -148,7 +148,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) { qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD (hr); } - for (int i = 0 ; i < actions_.count() ; ++i) { + for (int i = 0; i < actions_.count(); ++i) { if (buttons[i].hIcon) { DestroyIcon(buttons[i].hIcon); } @@ -182,7 +182,7 @@ void Windows7ThumbBar::ActionChanged() { qLog(Debug) << "Updating" << actions_.count() << "buttons"; THUMBBUTTON buttons[kMaxButtonCount]; - for (int i = 0 ; i < actions_.count() ; ++i) { + for (int i = 0; i < actions_.count(); ++i) { QAction *action = actions_[i]; THUMBBUTTON *button = &buttons[i]; @@ -196,7 +196,7 @@ void Windows7ThumbBar::ActionChanged() { qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD (hr); } - for (int i = 0 ; i < actions_.count() ; ++i) { + for (int i = 0; i < actions_.count(); ++i) { if (buttons[i].hIcon) { DestroyIcon(buttons[i].hIcon); } diff --git a/src/covermanager/albumcoverfetchersearch.cpp b/src/covermanager/albumcoverfetchersearch.cpp index 27a186e9..013e5d95 100644 --- a/src/covermanager/albumcoverfetchersearch.cpp +++ b/src/covermanager/albumcoverfetchersearch.cpp @@ -142,7 +142,7 @@ void AlbumCoverFetcherSearch::ProviderSearchResults(const int id, const CoverPro void AlbumCoverFetcherSearch::ProviderSearchResults(CoverProvider *provider, const CoverProviderSearchResults &results) { CoverProviderSearchResults results_copy(results); - for (int i = 0 ; i < results_copy.count() ; ++i) { + for (int i = 0; i < results_copy.count(); ++i) { results_copy[i].provider = provider->name(); results_copy[i].score_provider = provider->quality(); diff --git a/src/covermanager/coverexportrunnable.cpp b/src/covermanager/coverexportrunnable.cpp index 808ae189..4243d20d 100644 --- a/src/covermanager/coverexportrunnable.cpp +++ b/src/covermanager/coverexportrunnable.cpp @@ -47,10 +47,12 @@ void CoverExportRunnable::run() { EmitCoverSkipped(); } else { - if (dialog_result_.RequiresCoverProcessing()) + if (dialog_result_.RequiresCoverProcessing()) { ProcessAndExportCover(); - else + } + else { ExportCover(); + } } } @@ -148,10 +150,12 @@ void CoverExportRunnable::ProcessAndExportCover() { } } - if (cover.save(new_file)) + if (cover.save(new_file)) { EmitCoverExported(); - else + } + else { EmitCoverSkipped(); + } } diff --git a/src/device/devicemanager.cpp b/src/device/devicemanager.cpp index 80bdf295..decdc8ad 100644 --- a/src/device/devicemanager.cpp +++ b/src/device/devicemanager.cpp @@ -339,8 +339,9 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const { return info->task_percentage_; case MusicStorage::Role_Storage: - if (!info->device_ && info->database_id_ != -1) + if (!info->device_ && info->database_id_ != -1) { const_cast(this)->Connect(info); + } if (!info->device_) return QVariant(); return QVariant::fromValue>(info->device_); @@ -452,7 +453,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) { // Do we have this device already? DeviceInfo *info = FindDeviceById(id); if (info) { - for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) { + for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) { if (info->backends_[backend_index].unique_id_ == id) { info->backends_[backend_index].lister_ = lister; break; @@ -506,7 +507,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString &id) { if (info->database_id_ != -1) { // Keep the structure around, but just "disconnect" it - for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) { + for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) { if (info->backends_[backend_index].unique_id_ == id) { info->backends_[backend_index].lister_ = nullptr; break; @@ -523,7 +524,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString &id) { } else { // If this was the last lister for the device then remove it from the model - for (int backend_index = 0 ; backend_index < info->backends_.count() ; ++backend_index) { + for (int backend_index = 0; backend_index < info->backends_.count(); ++backend_index) { if (info->backends_[backend_index].unique_id_ == id) { info->backends_.removeAt(backend_index); break; @@ -817,8 +818,9 @@ void DeviceManager::SetDeviceOptions(const QModelIndex &idx, const QString &frie emit dataChanged(idx, idx); - if (info->database_id_ != -1) + if (info->database_id_ != -1) { backend_->SetDeviceOptions(info->database_id_, friendly_name, icon_name, mode, format); + } } @@ -853,10 +855,12 @@ void DeviceManager::TasksChanged() { if (!idx.isValid()) continue; DeviceInfo *info = IndexToItem(idx); - if (task.progress_max) + if (task.progress_max) { info->task_percentage_ = static_cast(float(task.progress) / task.progress_max * 100); - else + } + else { info->task_percentage_ = 0; + } emit dataChanged(idx, idx); finished_tasks.removeAll(idx); diff --git a/src/device/deviceproperties.cpp b/src/device/deviceproperties.cpp index 0540bb39..377ef77f 100644 --- a/src/device/deviceproperties.cpp +++ b/src/device/deviceproperties.cpp @@ -144,8 +144,9 @@ void DeviceProperties::ModelChanged() { if (!isVisible()) return; - if (!index_.isValid()) + if (!index_.isValid()) { reject(); // Device went away + } else { UpdateHardwareInfo(); UpdateFormats(); diff --git a/src/device/giolister.cpp b/src/device/giolister.cpp index 67e747d5..77520d17 100644 --- a/src/device/giolister.cpp +++ b/src/device/giolister.cpp @@ -47,10 +47,12 @@ QString GioLister::DeviceInfo::unique_id() const { if (!volume_root_uri.isEmpty()) return volume_root_uri; - if (mount_ptr) + if (mount_ptr) { return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size); - else + } + else { return QString("Gio/unmounted/%1").arg(reinterpret_cast(volume_ptr.get())); + } } @@ -205,11 +207,13 @@ QList GioLister::MakeDeviceUrls(const QString &id) { } QStringList uris; - if (!volume_root_uri.isEmpty()) + if (!volume_root_uri.isEmpty()) { uris << volume_root_uri; + } - if (!mount_uri.isEmpty()) + if (!mount_uri.isEmpty()) { uris << mount_uri; + } QList ret; @@ -288,9 +292,10 @@ void GioLister::VolumeAdded(GVolume *volume) { return; } #ifdef HAVE_AUDIOCD - if (info.volume_root_uri.startsWith("cdda")) + if (info.volume_root_uri.startsWith("cdda")) { // Audio CD devices are already handled by CDDA lister return; + } #endif info.ReadDriveInfo(g_volume_get_drive(volume)); info.ReadMountInfo(g_volume_get_mount(volume)); @@ -331,9 +336,10 @@ void GioLister::MountAdded(GMount *mount) { return; } #ifdef HAVE_AUDIOCD - if (info.volume_root_uri.startsWith("cdda")) + if (info.volume_root_uri.startsWith("cdda")) { // Audio CD devices are already handled by CDDA lister return; + } #endif info.ReadMountInfo(mount); info.ReadDriveInfo(g_mount_get_drive(mount)); @@ -363,10 +369,12 @@ void GioLister::MountAdded(GMount *mount) { devices_[info.unique_id()] = info; } - if (!old_id.isEmpty()) - emit DeviceChanged(old_id); - else + if (old_id.isEmpty()) { emit DeviceAdded(info.unique_id()); + } + else { + emit DeviceChanged(old_id); + } } @@ -386,8 +394,9 @@ void GioLister::MountChanged(GMount *mount) { new_info.ReadDriveInfo(g_mount_get_drive(mount)); // Ignore the change if the new info is useless - if (new_info.invalid_enclosing_mount || (devices_[id].filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty())) + if (new_info.invalid_enclosing_mount || (devices_[id].filesystem_size != 0 && new_info.filesystem_size == 0) || (!devices_[id].filesystem_type.isEmpty() && new_info.filesystem_type.isEmpty())) { return; + } devices_[id] = new_info; } @@ -412,9 +421,11 @@ void GioLister::MountRemoved(GMount *mount) { } QString GioLister::DeviceInfo::ConvertAndFree(char *str) { + QString ret = QString::fromUtf8(str); g_free(str); return ret; + } void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) { diff --git a/src/device/gpoddevice.cpp b/src/device/gpoddevice.cpp index 5d603e0b..863743f7 100644 --- a/src/device/gpoddevice.cpp +++ b/src/device/gpoddevice.cpp @@ -315,8 +315,9 @@ void GPodDevice::StartDelete() { Start(); } bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &relative_to) { QString ipod_filename = path; - if (!relative_to.isEmpty() && path.startsWith(relative_to)) + if (!relative_to.isEmpty() && path.startsWith(relative_to)) { ipod_filename.remove(0, relative_to.length() + (relative_to.endsWith('/') ? -1 : 0)); + } ipod_filename.replace('/', ':'); @@ -337,7 +338,7 @@ bool GPodDevice::RemoveTrackFromITunesDb(const QString &path, const QString &rel } // Remove the track from all playlists - for (GList *playlists = db_->playlists ; playlists != nullptr ; playlists = playlists->next) { + for (GList *playlists = db_->playlists; playlists != nullptr; playlists = playlists->next) { Itdb_Playlist *playlist = static_cast(playlists->data); if (itdb_playlist_contains_track(playlist, track)) { @@ -356,11 +357,14 @@ bool GPodDevice::DeleteFromStorage(const DeleteJob &job) { Q_ASSERT(db_); - if (!RemoveTrackFromITunesDb(job.metadata_.url().toLocalFile(), url_.path())) + if (!RemoveTrackFromITunesDb(job.metadata_.url().toLocalFile(), url_.path())) { return false; + } // Remove the file - if (!QFile::remove(job.metadata_.url().toLocalFile())) return false; + if (!QFile::remove(job.metadata_.url().toLocalFile())) { + return false; + } // Remove it from our collection model songs_to_remove_ << job.metadata_; @@ -382,4 +386,3 @@ bool GPodDevice::GetSupportedFiletypes(QList *ret) { *ret << Song::FileType_MPEG; return true; } - diff --git a/src/device/mtpdevice.cpp b/src/device/mtpdevice.cpp index a299776a..25ca1177 100644 --- a/src/device/mtpdevice.cpp +++ b/src/device/mtpdevice.cpp @@ -255,8 +255,9 @@ bool MtpDevice::GetSupportedFiletypes(QList *ret, LIBMTP_mtpdevi uint16_t *list = nullptr; uint16_t length = 0; - if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length) + if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length) { return false; + } for (int i = 0; i < length; ++i) { switch (LIBMTP_filetype_t(list[i])) { diff --git a/src/device/udisks2lister.cpp b/src/device/udisks2lister.cpp index 82a3d2fd..f61a8f30 100644 --- a/src/device/udisks2lister.cpp +++ b/src/device/udisks2lister.cpp @@ -164,8 +164,9 @@ void Udisks2Lister::UnmountDevice(const QString &id) { auto eject_result = drive.Eject(QVariantMap()); eject_result.waitForFinished(); - if (eject_result.isError()) + if (eject_result.isError()) { qLog(Warning) << "Failed to eject " << id << ": " << eject_result.error(); + } } device_data_.remove(id); @@ -313,7 +314,9 @@ void Udisks2Lister::JobCompleted(const bool success, const QString &message) { OrgFreedesktopUDisks2JobInterface *job = qobject_cast(sender()); QDBusObjectPath jobPath(job->path()); - if (!job->isValid() || !success || !mounting_jobs_.contains(jobPath)) return; + if (!job->isValid() || !success || !mounting_jobs_.contains(jobPath)) { + return; + } qLog(Debug) << "Pending Job Completed | Path = " << job->path() << " | Mount? = " << mounting_jobs_[jobPath].is_mount << " | Success = " << success; diff --git a/src/dialogs/about.cpp b/src/dialogs/about.cpp index 6762838b..0869e601 100644 --- a/src/dialogs/about.cpp +++ b/src/dialogs/about.cpp @@ -192,8 +192,10 @@ QString About::ContributorsHtml() const { QString About::PersonToHtml(const Person &person) { - if (person.email.isNull()) + if (person.email.isEmpty()) { return person.name; - else + } + else { return QString("%1 <%3>").arg(person.name, person.email, person.email); + } } diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index 5c6a1173..7bc5f603 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -878,8 +878,9 @@ void EditTagDialog::FieldValueEdited() { if (ignore_edits_) return; const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes(); - if (sel.isEmpty()) + if (sel.isEmpty()) { return; + } QWidget *w = qobject_cast(sender()); @@ -896,8 +897,9 @@ void EditTagDialog::FieldValueEdited() { void EditTagDialog::ResetField() { const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes(); - if (sel.isEmpty()) + if (sel.isEmpty()) { return; + } QWidget *w = qobject_cast(sender()); diff --git a/src/dialogs/errordialog.cpp b/src/dialogs/errordialog.cpp index 64e83124..ce92da2f 100644 --- a/src/dialogs/errordialog.cpp +++ b/src/dialogs/errordialog.cpp @@ -77,8 +77,9 @@ void ErrorDialog::UpdateContent() { QString html; for (const QString &message : current_messages_) { - if (!html.isEmpty()) + if (!html.isEmpty()) { html += "
"; + } html += message.toHtmlEscaped(); } ui_->messages->setHtml(html); diff --git a/src/dialogs/trackselectiondialog.cpp b/src/dialogs/trackselectiondialog.cpp index 574fad8e..abdd3aef 100644 --- a/src/dialogs/trackselectiondialog.cpp +++ b/src/dialogs/trackselectiondialog.cpp @@ -266,8 +266,9 @@ void TrackSelectionDialog::SaveData(const QList &data) { for (int i = 0; i < data.count(); ++i) { const Data &ref = data[i]; - if (ref.pending_ || ref.results_.isEmpty() || ref.selected_result_ == -1) + if (ref.pending_ || ref.results_.isEmpty() || ref.selected_result_ == -1) { continue; + } const Song &new_metadata = ref.results_[ref.selected_result_]; @@ -302,8 +303,9 @@ void TrackSelectionDialog::accept() { QDialog::accept(); for (const Data &tag_data : data_) { - if (tag_data.pending_ || tag_data.results_.isEmpty() || tag_data.selected_result_ == -1) + if (tag_data.pending_ || tag_data.results_.isEmpty() || tag_data.selected_result_ == -1) { continue; + } const Song &new_metadata = tag_data.results_[tag_data.selected_result_]; diff --git a/src/engine/alsapcmdevicefinder.cpp b/src/engine/alsapcmdevicefinder.cpp index f056f457..0341db5a 100644 --- a/src/engine/alsapcmdevicefinder.cpp +++ b/src/engine/alsapcmdevicefinder.cpp @@ -44,7 +44,7 @@ QList AlsaPCMDeviceFinder::ListDevices() { return ret; } - for (void **n = hints ; *n ; ++n) { + for (void **n = hints; *n; ++n) { char *io = snd_device_name_get_hint(*n, "IOID"); char *name = snd_device_name_get_hint(*n, "NAME"); char *desc = snd_device_name_get_hint(*n, "DESC"); @@ -52,7 +52,7 @@ QList AlsaPCMDeviceFinder::ListDevices() { char *desc_last = desc; QString description; - for (char *desc_i = desc ; desc_i && *desc_i != '\0' ; ++desc_i) { + for (char *desc_i = desc; desc_i && *desc_i != '\0'; ++desc_i) { if (*desc_i == '\n') { *desc_i = '\0'; if (!description.isEmpty()) description.append(' '); diff --git a/src/engine/enginebase.cpp b/src/engine/enginebase.cpp index f530a53b..5fa24385 100644 --- a/src/engine/enginebase.cpp +++ b/src/engine/enginebase.cpp @@ -175,8 +175,9 @@ void Engine::Base::ReloadSettings() { void Engine::Base::EmitAboutToEnd() { - if (about_to_end_emitted_) + if (about_to_end_emitted_) { return; + } about_to_end_emitted_ = true; emit TrackAboutToEnd(); diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index 01d819c5..c1822c13 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -122,10 +122,12 @@ GstEngine::~GstEngine() { if (discoverer_) { - if (discovery_discovered_cb_id_ != -1) + if (discovery_discovered_cb_id_ != -1) { g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_discovered_cb_id_); - if (discovery_finished_cb_id_ != -1) + } + if (discovery_finished_cb_id_ != -1) { g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_finished_cb_id_); + } gst_discoverer_stop(discoverer_); g_object_unref(discoverer_); @@ -210,8 +212,9 @@ bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::T SetEqualizerParameters(equalizer_preamp_, equalizer_gains_); // Maybe fade in this track - if (crossfade) + if (crossfade) { current_pipeline_->StartFader(fadeout_duration_nanosec_, QTimeLine::Forward); + } // Setting up stream discoverer if (!discoverer_) { @@ -640,6 +643,7 @@ void GstEngine::SeekNow() { if (!current_pipeline_->Seek(seek_pos_)) { qLog(Warning) << "Seek failed"; } + } void GstEngine::PlayDone(const GstStateChangeReturn ret, const quint64 offset_nanosec, const int pipeline_id) { diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 9605918f..e3128a2a 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -130,17 +130,21 @@ GstEnginePipeline::~GstEnginePipeline() { if (pipeline_) { - if (pad_added_cb_id_ != -1) + if (pad_added_cb_id_ != -1) { g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_); + } - if (notify_source_cb_id_ != -1) + if (notify_source_cb_id_ != -1) { g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_); + } - if (about_to_finish_cb_id_ != -1) + if (about_to_finish_cb_id_ != -1) { g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_); + } - if (bus_cb_id_ != -1) + if (bus_cb_id_ != -1) { g_source_remove(bus_cb_id_); + } GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_)); if (bus) { @@ -170,9 +174,11 @@ void GstEnginePipeline::set_volume_enabled(const bool enabled) { } void GstEnginePipeline::set_stereo_balancer_enabled(const bool enabled) { + stereo_balancer_enabled_ = enabled; if (!enabled) stereo_balance_ = 0.0F; if (pipeline_) UpdateStereoBalance(); + } void GstEnginePipeline::set_equalizer_enabled(const bool enabled) { @@ -647,7 +653,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; int16_t *d = static_cast(g_malloc(buf16_size)); memset(d, 0, buf16_size); - for (int i = 0 ; i < (samples * channels) ; ++i) { + for (int i = 0; i < (samples * channels); ++i) { d[i] = static_cast((s[i] >> 16)); } gst_buffer_unmap(buf, &map_info); @@ -668,7 +674,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; int16_t *d = static_cast(g_malloc(buf16_size)); memset(d, 0, buf16_size); - for (int i = 0 ; i < (samples * channels) ; ++i) { + for (int i = 0; i < (samples * channels); ++i) { float sample_float = (s[i] * float(32768.0)); d[i] = static_cast(sample_float); } @@ -690,7 +696,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf int buf16_size = samples * static_cast(sizeof(int16_t)) * channels; int16_t *s16 = static_cast(g_malloc(buf16_size)); memset(s16, 0, buf16_size); - for (int i = 0 ; i < (samples * channels) ; ++i) { + for (int i = 0; i < (samples * channels); ++i) { s16[i] = *(reinterpret_cast(s24+1)); s24 += 3; if (s24 >= s24e) break; @@ -1071,8 +1077,9 @@ void GstEnginePipeline::BufferingMessageReceived(GstMessage *msg) { qint64 GstEnginePipeline::position() const { - if (pipeline_is_initialized_) + if (pipeline_is_initialized_) { gst_element_query_position(pipeline_, GST_FORMAT_TIME, &last_known_position_ns_); + } return last_known_position_ns_; @@ -1090,8 +1097,9 @@ qint64 GstEnginePipeline::length() const { GstState GstEnginePipeline::state() const { GstState s = GST_STATE_NULL, sp = GST_STATE_NULL; - if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE) + if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE) { return GST_STATE_NULL; + } return s; @@ -1179,10 +1187,12 @@ void GstEnginePipeline::UpdateEqualizer() { // Update band gains for (int i = 0; i < kEqBandCount; ++i) { float gain = eq_enabled_ ? eq_band_gains_[i] : float(0.0); - if (gain < 0) + if (gain < 0) { gain *= 0.24; - else + } + else { gain *= 0.12; + } const int index_in_eq = i + 1; // Offset because of the first dummy band we created. diff --git a/src/engine/mmdevicefinder.cpp b/src/engine/mmdevicefinder.cpp index 29765554..ba2e517b 100644 --- a/src/engine/mmdevicefinder.cpp +++ b/src/engine/mmdevicefinder.cpp @@ -53,7 +53,7 @@ QList MMDeviceFinder::ListDevices() { UINT count; hr = collection->GetCount(&count); if (hr == S_OK) { - for (ULONG i = 0 ; i < count ; i++) { + for (ULONG i = 0; i < count; i++) { IMMDevice *endpoint = nullptr; hr = collection->Item(i, &endpoint); if (hr == S_OK) { diff --git a/src/engine/vlcengine.cpp b/src/engine/vlcengine.cpp index 4bd4f6ae..0db83e4b 100644 --- a/src/engine/vlcengine.cpp +++ b/src/engine/vlcengine.cpp @@ -189,19 +189,24 @@ void VLCEngine::Seek(const quint64 offset_nanosec) { } void VLCEngine::SetVolumeSW(const uint percent) { + if (!Initialized()) return; if (!volume_control_ && percent != 100) return; libvlc_audio_set_volume(player_, percent); + } qint64 VLCEngine::position_nanosec() const { + if (state_ == Engine::Empty) return 0; const qint64 result = (position() * kNsecPerMsec); return qint64(qMax(0LL, result)); + } qint64 VLCEngine::length_nanosec() const { + if (state_ == Engine::Empty) return 0; const qint64 result = (end_nanosec_ - beginning_nanosec_); if (result > 0) { @@ -211,6 +216,7 @@ qint64 VLCEngine::length_nanosec() const { // Get the length from the pipeline if we don't know. return (length() * kNsecPerMsec); } + } EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const { @@ -330,7 +336,7 @@ EngineBase::PluginDetailsList VLCEngine::GetPluginList() const { ret << details; } - for (libvlc_audio_output_t *audio_output = audio_output_list ; audio_output ; audio_output = audio_output->p_next) { + for (libvlc_audio_output_t *audio_output = audio_output_list; audio_output; audio_output = audio_output->p_next) { PluginDetails details; details.name = QString::fromUtf8(audio_output->psz_name); details.description = QString::fromUtf8(audio_output->psz_description); @@ -349,7 +355,7 @@ void VLCEngine::GetDevicesList(const QString &output) const { Q_UNUSED(output); libvlc_audio_output_device_t *audio_output_device_list = libvlc_audio_output_device_list_get(instance_, output_.toUtf8().constData()); - for (libvlc_audio_output_device_t *audio_device = audio_output_device_list ; audio_device ; audio_device = audio_device->p_next) { + for (libvlc_audio_output_device_t *audio_device = audio_output_device_list; audio_device; audio_device = audio_device->p_next) { qLog(Debug) << audio_device->psz_device << audio_device->psz_description; } libvlc_audio_output_device_list_release(audio_output_device_list); diff --git a/src/equalizer/equalizer.cpp b/src/equalizer/equalizer.cpp index 2b77bc02..05709eb6 100644 --- a/src/equalizer/equalizer.cpp +++ b/src/equalizer/equalizer.cpp @@ -209,8 +209,9 @@ void Equalizer::SavePreset() { QString Equalizer::SaveCurrentPreset() { QString name = QInputDialog::getText(this, tr("Save preset"), tr("Name"), QLineEdit::Normal, tr(qPrintable(last_preset_))); - if (name.isEmpty()) + if (name.isEmpty()) { return QString(); + } AddPreset(name, current_params()); Save(); @@ -362,6 +363,7 @@ Equalizer::Params::Params() : preamp(0) { } Equalizer::Params::Params(int g0, int g1, int g2, int g3, int g4, int g5, int g6, int g7, int g8, int g9, int pre) : preamp(pre) { + gain[0] = g0; gain[1] = g1; gain[2] = g2; @@ -372,14 +374,17 @@ Equalizer::Params::Params(int g0, int g1, int g2, int g3, int g4, int g5, int g6 gain[7] = g7; gain[8] = g8; gain[9] = g9; + } bool Equalizer::Params::operator==(const Equalizer::Params &other) const { + if (preamp != other.preamp) return false; for (int i = 0; i < Equalizer::kBands; ++i) { if (gain[i] != other.gain[i]) return false; } return true; + } bool Equalizer::Params::operator!=(const Equalizer::Params &other) const { @@ -387,13 +392,17 @@ bool Equalizer::Params::operator!=(const Equalizer::Params &other) const { } QDataStream &operator<<(QDataStream &s, const Equalizer::Params &p) { + s << p.preamp; for (int i = 0; i < Equalizer::kBands; ++i) s << p.gain[i]; return s; + } QDataStream &operator>>(QDataStream &s, Equalizer::Params &p) { + s >> p.preamp; for (int i = 0; i < Equalizer::kBands; ++i) s >> p.gain[i]; return s; + } diff --git a/src/globalshortcuts/globalshortcutgrabber.cpp b/src/globalshortcuts/globalshortcutgrabber.cpp index 5f3ef5ab..da503cdc 100644 --- a/src/globalshortcuts/globalshortcutgrabber.cpp +++ b/src/globalshortcuts/globalshortcutgrabber.cpp @@ -93,10 +93,12 @@ bool GlobalShortcutGrabber::event(QEvent *e) { if (e->type() == QEvent::ShortcutOverride) { QKeyEvent *ke = static_cast(e); - if (modifier_keys_.contains(ke->key())) + if (modifier_keys_.contains(ke->key())) { ret_ = QKeySequence(ke->modifiers()); - else + } + else { ret_ = QKeySequence(ke->modifiers() | ke->key()); + } UpdateText(); diff --git a/src/globalshortcuts/globalshortcutsmanager.cpp b/src/globalshortcuts/globalshortcutsmanager.cpp index 37e406e6..1e38228f 100644 --- a/src/globalshortcuts/globalshortcutsmanager.cpp +++ b/src/globalshortcuts/globalshortcutsmanager.cpp @@ -93,16 +93,19 @@ GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) #endif #ifdef Q_OS_MACOS - if (!system_backend_) + if (!system_backend_) { system_backend_ = new GlobalShortcutsBackendMacOS(this); + } #endif #ifdef Q_OS_WIN - if (!system_backend_) + if (!system_backend_) { system_backend_ = new GlobalShortcutsBackendSystem(this); + } #endif #ifdef HAVE_X11_GLOBALSHORTCUTS - if (!system_backend_ && IsX11Available()) + if (!system_backend_ && IsX11Available()) { system_backend_ = new GlobalShortcutsBackendSystem(this); + } #endif ReloadSettings(); diff --git a/src/internet/internetcollectionview.cpp b/src/internet/internetcollectionview.cpp index 202dc027..3f2e275d 100644 --- a/src/internet/internetcollectionview.cpp +++ b/src/internet/internetcollectionview.cpp @@ -222,10 +222,12 @@ void InternetCollectionView::TotalSongCountUpdated(int count) { total_song_count_ = count; if (old != total_song_count_) update(); - if (total_song_count_ == 0) + if (total_song_count_ == 0) { setCursor(Qt::PointingHandCursor); - else + } + else { unsetCursor(); + } emit TotalSongCountUpdated_(); @@ -237,10 +239,12 @@ void InternetCollectionView::TotalArtistCountUpdated(int count) { total_artist_count_ = count; if (old != total_artist_count_) update(); - if (total_artist_count_ == 0) + if (total_artist_count_ == 0) { setCursor(Qt::PointingHandCursor); - else + } + else { unsetCursor(); + } emit TotalArtistCountUpdated_(); @@ -252,10 +256,12 @@ void InternetCollectionView::TotalAlbumCountUpdated(int count) { total_album_count_ = count; if (old != total_album_count_) update(); - if (total_album_count_ == 0) + if (total_album_count_ == 0) { setCursor(Qt::PointingHandCursor); - else + } + else { unsetCursor(); + } emit TotalAlbumCountUpdated_(); @@ -406,10 +412,12 @@ void InternetCollectionView::keyboardSearch(const QString &search) { void InternetCollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) { - if (is_in_keyboard_search_) + if (is_in_keyboard_search_) { QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop); - else + } + else { QTreeView::scrollTo(idx, hint); + } } diff --git a/src/internet/internetsearchmodel.cpp b/src/internet/internetsearchmodel.cpp index 65cb16be..2179c689 100644 --- a/src/internet/internetsearchmodel.cpp +++ b/src/internet/internetsearchmodel.cpp @@ -329,7 +329,7 @@ void InternetSearchModel::GetChildResults(const QStandardItem *item, InternetSea const QModelIndex parent_proxy_index = proxy_->mapFromSource(item->index()); // Yes - visit all the children, but do so through the proxy so we get them in the right order. - for (int i = 0 ; i < item->rowCount() ; ++i) { + for (int i = 0; i < item->rowCount(); ++i) { const QModelIndex proxy_index = parent_proxy_index.model()->index(i, 0, parent_proxy_index); const QModelIndex idx = proxy_->mapToSource(proxy_index); GetChildResults(itemFromIndex(idx), results, visited); @@ -361,7 +361,7 @@ void GatherResults(const QStandardItem *parent, InternetSearchView::ResultList * (*results).append(result); } - for (int i = 0 ; i < parent->rowCount() ; ++i) { + for (int i = 0; i < parent->rowCount(); ++i) { GatherResults(parent->child(i), results); } diff --git a/src/internet/internetsearchview.cpp b/src/internet/internetsearchview.cpp index 6f9a1e42..815b1274 100644 --- a/src/internet/internetsearchview.cpp +++ b/src/internet/internetsearchview.cpp @@ -509,7 +509,7 @@ void InternetSearchView::SearchDone(const int service_id, const SongList &songs, } // Load cached pixmaps into the results - for (InternetSearchView::ResultList::iterator it = results.begin() ; it != results.end() ; ++it) { + for (InternetSearchView::ResultList::iterator it = results.begin(); it != results.end(); ++it) { it->pixmap_cache_key_ = PixmapCacheKey(*it); } @@ -594,7 +594,7 @@ MimeData *InternetSearchView::SelectedMimeData() { QModelIndexList indexes = ui_->results->selectionModel()->selectedRows(); if (indexes.isEmpty()) { // There's nothing selected - take the first thing in the model that isn't a divider. - for (int i = 0 ; i < front_proxy_->rowCount() ; ++i) { + for (int i = 0; i < front_proxy_->rowCount(); ++i) { QModelIndex idx = front_proxy_->index(i, 0); if (!idx.data(CollectionModel::Role_IsDivider).toBool()) { indexes << idx; // clazy:exclude=reserve-candidates diff --git a/src/lyrics/lyricsfetchersearch.cpp b/src/lyrics/lyricsfetchersearch.cpp index 350af44c..f1397f04 100644 --- a/src/lyrics/lyricsfetchersearch.cpp +++ b/src/lyrics/lyricsfetchersearch.cpp @@ -85,7 +85,7 @@ void LyricsFetcherSearch::ProviderSearchFinished(const quint64 id, const LyricsS LyricsSearchResults results_copy(results); float higest_score = 0.0; - for (int i = 0 ; i < results_copy.count() ; ++i) { + for (int i = 0; i < results_copy.count(); ++i) { results_copy[i].provider = provider->name(); results_copy[i].score = 0.0; if (results_copy[i].artist.compare(request_.artist, Qt::CaseInsensitive) == 0) { diff --git a/src/moodbar/moodbarpipeline.cpp b/src/moodbar/moodbarpipeline.cpp index aba24079..43624cc3 100644 --- a/src/moodbar/moodbarpipeline.cpp +++ b/src/moodbar/moodbarpipeline.cpp @@ -173,10 +173,12 @@ void MoodbarPipeline::NewPadCallback(GstElement*, GstPad *pad, gpointer data) { gst_structure_get_int(structure, "rate", &rate); gst_caps_unref(caps); - if (self->builder_) + if (self->builder_) { self->builder_->Init(kBands, rate); - else + } + else { qLog(Error) << "Builder does not exist"; + } } diff --git a/src/musicbrainz/tagfetcher.cpp b/src/musicbrainz/tagfetcher.cpp index 1469a334..a4780905 100644 --- a/src/musicbrainz/tagfetcher.cpp +++ b/src/musicbrainz/tagfetcher.cpp @@ -63,7 +63,7 @@ void TagFetcher::StartFetch(const SongList &songs) { } if (have_fingerprints) { - for (int i = 0 ; i < songs_.count() ; ++i) { + for (int i = 0; i < songs_.count(); ++i) { const Song &song = songs_[i]; emit Progress(song, tr("Identifying song")); acoustid_client_->Start(i, song.fingerprint(), static_cast(song.length_nanosec() / kNsecPerMsec)); diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index 1e06f201..c33c0646 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -268,8 +268,9 @@ void Organize::ProcessSomeFiles() { } // Clean up the temporary transcoded file - if (!task.transcoded_filename_.isEmpty()) + if (!task.transcoded_filename_.isEmpty()) { QFile::remove(task.transcoded_filename_); + } tasks_complete_++; } diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp index 3a5064a7..88448c1f 100644 --- a/src/organize/organizedialog.cpp +++ b/src/organize/organizedialog.cpp @@ -543,8 +543,9 @@ void OrganizeDialog::UpdatePreviews() { } } - if (devices_) + if (devices_) { AdjustSize(); + } } diff --git a/src/organize/organizeformat.cpp b/src/organize/organizeformat.cpp index 408d18f9..cdb615ab 100644 --- a/src/organize/organizeformat.cpp +++ b/src/organize/organizeformat.cpp @@ -135,15 +135,16 @@ QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension) int ascii = 128; if (allow_ascii_ext_) ascii = 255; QString stripped; - for (int i = 0 ; i < filename.length() ; ++i) { + for (int i = 0; i < filename.length(); ++i) { const QChar c = filename[i]; if (c.unicode() < ascii) { stripped.append(c); } else { const QString decomposition = c.decomposition(); - if (!decomposition.isEmpty() && decomposition[0].unicode() < ascii) + if (!decomposition.isEmpty() && decomposition[0].unicode() < ascii) { stripped.append(decomposition[0]); + } } } filename = stripped; @@ -164,9 +165,9 @@ QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension) // Fix any parts of the path that start with dots. QStringList parts_old = filepath.split("/"); QStringList parts_new; - for (int i = 0 ; i < parts_old.count() ; ++i) { + for (int i = 0; i < parts_old.count(); ++i) { QString part = parts_old[i]; - for (int j = 0 ; j < kInvalidPrefixCharactersCount ; ++j) { + for (int j = 0; j < kInvalidPrefixCharactersCount; ++j) { if (part.startsWith(kInvalidPrefixCharacters[j])) { part = part.remove(0, 1); break; @@ -195,7 +196,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *any_em // Find any blocks first int pos = 0; QRegularExpressionMatch re_match; - for (re_match = block_regexp.match(block, pos) ; re_match.hasMatch() ; re_match = block_regexp.match(block, pos)) { + for (re_match = block_regexp.match(block, pos); re_match.hasMatch(); re_match = block_regexp.match(block, pos)) { pos = re_match.capturedStart(); // Recursively parse the block bool empty = false; @@ -210,7 +211,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *any_em // Now look for tags bool empty = false; pos = 0; - for (re_match = tag_regexp.match(block, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(block, pos)) { + for (re_match = tag_regexp.match(block, pos); re_match.hasMatch(); re_match = tag_regexp.match(block, pos)) { pos = re_match.capturedStart(); QString value = TagValue(re_match.captured(1), song); if (value.isEmpty()) empty = true; @@ -228,42 +229,60 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const { QString value; - if (tag == "title") + if (tag == "title") { value = song.title(); - else if (tag == "album") + } + else if (tag == "album") { value = song.album(); - else if (tag == "artist") + } + else if (tag == "artist") { value = song.artist(); - else if (tag == "composer") + } + else if (tag == "composer") { value = song.composer(); - else if (tag == "performer") + } + else if (tag == "performer") { value = song.performer(); - else if (tag == "grouping") + } + else if (tag == "grouping") { value = song.grouping(); - else if (tag == "lyrics") + } + else if (tag == "lyrics") { value = song.lyrics(); - else if (tag == "genre") + } + else if (tag == "genre") { value = song.genre(); - else if (tag == "comment") + } + else if (tag == "comment") { value = song.comment(); - else if (tag == "year") + } + else if (tag == "year") { value = QString::number(song.year()); - else if (tag == "originalyear") + } + else if (tag == "originalyear") { value = QString::number(song.effective_originalyear()); - else if (tag == "track") + } + else if (tag == "track") { value = QString::number(song.track()); - else if (tag == "disc") + } + else if (tag == "disc") { value = QString::number(song.disc()); - else if (tag == "length") + } + else if (tag == "length") { value = QString::number(song.length_nanosec() / kNsecPerSec); - else if (tag == "bitrate") + } + else if (tag == "bitrate") { value = QString::number(song.bitrate()); - else if (tag == "samplerate") + } + else if (tag == "samplerate") { value = QString::number(song.samplerate()); - else if (tag == "bitdepth") + } + else if (tag == "bitdepth") { value = QString::number(song.bitdepth()); - else if (tag == "extension") + } + else if (tag == "extension") { value = QFileInfo(song.url().toLocalFile()).suffix(); + } else if (tag == "artistinitial") { value = song.effective_albumartist().trimmed(); if (!value.isEmpty()) { @@ -298,10 +317,12 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons // Make sure all the blocks match up int block_level = 0; for (int i = 0; i < input.length(); ++i) { - if (input[i] == '{') - block_level++; - else if (input[i] == '}') - block_level--; + if (input[i] == '{') { + ++block_level; + } + else if (input[i] == '}') { + --block_level; + } if (block_level < 0 || block_level > 1) return QValidator::Invalid; } @@ -311,10 +332,11 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons // Make sure the tags are valid QRegularExpressionMatch re_match; int pos = 0; - for (re_match = tag_regexp.match(input, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(input, pos)) { + for (re_match = tag_regexp.match(input, pos); re_match.hasMatch(); re_match = tag_regexp.match(input, pos)) { pos = re_match.capturedStart(); - if (!OrganizeFormat::kKnownTags.contains(re_match.captured(1))) + if (!OrganizeFormat::kKnownTags.contains(re_match.captured(1))) { return QValidator::Invalid; + } pos += re_match.capturedLength(); } @@ -323,14 +345,11 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons } -OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QObject *parent) - : QSyntaxHighlighter(parent) {} +OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QObject *parent) : QSyntaxHighlighter(parent) {} -OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent) - : QSyntaxHighlighter(parent) {} +OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent) : QSyntaxHighlighter(parent) {} -OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent) - : QSyntaxHighlighter(parent) {} +OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) {} void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) { @@ -351,7 +370,7 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) { // Blocks QRegularExpressionMatch re_match; int pos = 0; - for (re_match = block_regexp.match(text, pos) ; re_match.hasMatch() ; re_match = block_regexp.match(text, pos)) { + for (re_match = block_regexp.match(text, pos); re_match.hasMatch(); re_match = block_regexp.match(text, pos)) { pos = re_match.capturedStart(); setFormat(pos, re_match.capturedLength(), block_format); pos += re_match.capturedLength(); @@ -359,7 +378,7 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) { // Tags pos = 0; - for (re_match = tag_regexp.match(text, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(text, pos)) { + for (re_match = tag_regexp.match(text, pos); re_match.hasMatch(); re_match = tag_regexp.match(text, pos)) { pos = re_match.capturedStart(); QTextCharFormat f = format(pos); f.setForeground(QColor(OrganizeFormat::kKnownTags.contains(re_match.captured(1)) ? valid_tag_color : invalid_tag_color)); @@ -369,4 +388,3 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) { } } - diff --git a/src/osd/osdpretty.cpp b/src/osd/osdpretty.cpp index a0948512..5c004968 100644 --- a/src/osd/osdpretty.cpp +++ b/src/osd/osdpretty.cpp @@ -193,8 +193,9 @@ void OSDPretty::showEvent(QShowEvent *e) { fader_->start(); // Timeout will be started in FaderFinished } else if (mode_ == Mode_Popup) { - if (!disable_duration()) + if (!disable_duration()) { timeout_->start(); + } // Ensures it is above when showing the preview raise(); } @@ -370,18 +371,21 @@ void OSDPretty::ShowMessage(const QString &summary, const QString &message, cons if (toggle_mode()) { set_toggle_mode(false); // If timeout is disabled, timer hadn't been started - if (!disable_duration()) + if (!disable_duration()) { timeout_->stop(); + } hide(); } else { - if (!disable_duration()) + if (!disable_duration()) { timeout_->start(); // Restart the timer + } } } else { - if (toggle_mode()) + if (toggle_mode()) { set_toggle_mode(false); + } // The OSD is not visible, show it show(); } @@ -402,10 +406,12 @@ void OSDPretty::setVisible(bool visible) { void OSDPretty::FaderFinished() { - if (fader_->direction() == QTimeLine::Backward) + if (fader_->direction() == QTimeLine::Backward) { hide(); - else if (mode_ == Mode_Popup && !disable_duration()) + } + else if (mode_ == Mode_Popup && !disable_duration()) { timeout_->start(); + } } @@ -462,8 +468,10 @@ void OSDPretty::enterEvent(QEnterEvent*) { #else void OSDPretty::enterEvent(QEvent*) { #endif - if (mode_ == Mode_Popup) + if (mode_ == Mode_Popup) { setWindowOpacity(0.25); + } + } void OSDPretty::leaveEvent(QEvent*) { @@ -472,8 +480,9 @@ void OSDPretty::leaveEvent(QEvent*) { void OSDPretty::mousePressEvent(QMouseEvent *e) { - if (mode_ == Mode_Popup) + if (mode_ == Mode_Popup) { hide(); + } else { original_window_pos_ = pos(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index d99d515d..f45a6f47 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -503,8 +503,9 @@ int Playlist::NextVirtualIndex(int i, const bool ignore_repeat_track) const { // This one's easy - if we have to repeat the current track then just return i if (repeat_mode == PlaylistSequence::Repeat_Track && !ignore_repeat_track) { - if (!FilterContainsVirtualIndex(i)) + if (!FilterContainsVirtualIndex(i)) { return virtual_items_.count(); // It's not in the filter any more + } return i; } @@ -782,10 +783,12 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro if (const SongMimeData *song_data = qobject_cast(data)) { // Dragged from a collection // We want to check if these songs are from the actual local file backend, if they are we treat them differently. - if (song_data->backend && song_data->backend->songs_table() == SCollection::kSongsTable) + if (song_data->backend && song_data->backend->songs_table() == SCollection::kSongsTable) { InsertSongItems(song_data->songs, row, play_now, enqueue_now, enqueue_next_now); - else + } + else { InsertSongItems(song_data->songs, row, play_now, enqueue_now, enqueue_next_now); + } } else if (const PlaylistItemMimeData *item_data = qobject_cast(data)) { InsertItems(item_data->items_, row, play_now, enqueue_now, enqueue_next_now); @@ -1184,7 +1187,7 @@ void Playlist::UpdateItems(SongList songs) { // then we remove song from our list because we will not need to check it again. // And we also update undo actions. - for (int i = 0; i < items_.size() ; i++) { + for (int i = 0; i < items_.size(); i++) { // Update current items list QMutableListIterator it(songs); while (it.hasNext()) { @@ -1203,7 +1206,7 @@ void Playlist::UpdateItems(SongList songs) { items_[i] = new_item; emit dataChanged(index(i, 0), index(i, ColumnCount - 1)); // Also update undo actions - for (int y = 0 ; y < undo_stack_->count() ; y++) { + for (int y = 0; y < undo_stack_->count(); y++) { QUndoCommand *undo_action = const_cast(undo_stack_->command(i)); PlaylistUndoCommands::InsertItems *undo_action_insert = dynamic_cast(undo_action); if (undo_action_insert) { @@ -1883,13 +1886,15 @@ void Playlist::Shuffle() { int begin = 0; if (current_item_index_.isValid()) { - if (new_items[0] != new_items[current_item_index_.row()]) + if (new_items[0] != new_items[current_item_index_.row()]) { std::swap(new_items[0], new_items[current_item_index_.row()]); + } begin = 1; } - if (dynamic_playlist_ && current_item_index_.isValid()) + if (dynamic_playlist_ && current_item_index_.isValid()) { begin += current_item_index_.row() + 1; + } const int count = items_.count(); for (int i = begin; i < count; ++i) { @@ -1925,16 +1930,18 @@ void Playlist::ReshuffleIndices() { if (playlist_sequence_->shuffle_mode() == PlaylistSequence::Shuffle_Off) { // No shuffling - sort the virtual item list normally. std::sort(virtual_items_.begin(), virtual_items_.end()); - if (current_row() != -1) + if (current_row() != -1) { current_virtual_index_ = virtual_items_.indexOf(current_row()); + } return; } // If the user is already playing a song, advance the begin iterator to only shuffle items that haven't been played yet. QList::iterator begin = virtual_items_.begin(); QList::iterator end = virtual_items_.end(); - if (current_virtual_index_ != -1) + if (current_virtual_index_ != -1) { std::advance(begin, current_virtual_index_ + 1); + } std::random_device rd; std::mt19937 g(rd()); diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp index 79b24ea2..47e57740 100644 --- a/src/playlist/playlistcontainer.cpp +++ b/src/playlist/playlistcontainer.cpp @@ -217,8 +217,9 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi UpdateNoMatchesLabel(); // Ensure that tab is current - if (ui_->tab_bar->current_id() != manager_->current_id()) + if (ui_->tab_bar->current_id() != manager_->current_id()) { ui_->tab_bar->set_current_id(manager_->current_id()); + } // Sort out the undo/redo actions delete undo_; diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index 89f508ef..454ae327 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -235,8 +235,9 @@ QStyleOptionViewItem PlaylistDelegateBase::Adjusted(const QStyleOptionViewItem & QPoint top_left(-view_->horizontalScrollBar()->value(), -view_->verticalScrollBar()->value()); - if (view_->header()->logicalIndexAt(top_left) != idx.column()) + if (view_->header()->logicalIndexAt(top_left) != idx.column()) { return option; + } QStyleOptionViewItem ret(option); @@ -327,8 +328,9 @@ QString DateItemDelegate::displayText(const QVariant &value, const QLocale &loca bool ok = false; qint64 time = value.toLongLong(&ok); - if (!ok || time == -1) + if (!ok || time == -1) { return QString(); + } return QDateTime::fromSecsSinceEpoch(time).toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat)); @@ -339,8 +341,9 @@ QString LastPlayedItemDelegate::displayText(const QVariant &value, const QLocale bool ok = false; const qint64 time = value.toLongLong(&ok); - if (!ok || time == -1) + if (!ok || time == -1) { return tr("Never"); + } return Utilities::Ago(time, locale); diff --git a/src/playlist/playlistfilterparser.cpp b/src/playlist/playlistfilterparser.cpp index d2a3aed0..d41ccacd 100644 --- a/src/playlist/playlistfilterparser.cpp +++ b/src/playlist/playlistfilterparser.cpp @@ -165,10 +165,12 @@ class DropTailComparatorDecorator : public SearchTermComparator { explicit DropTailComparatorDecorator(SearchTermComparator *cmp) : cmp_(cmp) {} bool Matches(const QString &element) const override { - if (element.length() > 9) + if (element.length() > 9) { return cmp_->Matches(element.left(element.length() - 9)); - else + } + else { return cmp_->Matches(element); + } } private: QScopedPointer cmp_; @@ -406,10 +408,12 @@ FilterTree *FilterParser::parseSearchTerm() { bool inQuotes = false; for (; iter_ != end_; ++iter_) { if (inQuotes) { - if (*iter_ == '"') + if (*iter_ == '"') { inQuotes = false; - else + } + else { buf_ += *iter_; + } } else { if (*iter_ == '"') { diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp index c4ed4bb7..e2e820a6 100644 --- a/src/playlist/playlistheader.cpp +++ b/src/playlist/playlistheader.cpp @@ -92,8 +92,9 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent *e) { menu_section_ = logicalIndexAt(e->pos()); - if (menu_section_ == -1 || (menu_section_ == logicalIndex(0) && logicalIndex(1) == -1)) + if (menu_section_ == -1 || (menu_section_ == logicalIndex(0) && logicalIndex(1) == -1)) { action_hide_->setVisible(false); + } else { action_hide_->setVisible(true); @@ -112,7 +113,7 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent *e) { qDeleteAll(show_actions_); show_actions_.clear(); - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { AddColumnAction(i); } diff --git a/src/playlist/playlistitem.cpp b/src/playlist/playlistitem.cpp index e838c86e..14b35fef 100644 --- a/src/playlist/playlistitem.cpp +++ b/src/playlist/playlistitem.cpp @@ -141,7 +141,9 @@ void PlaylistItem::RemoveBackgroundColor(short priority) { } QColor PlaylistItem::GetCurrentBackgroundColor() const { - if (background_colors_.isEmpty()) return QColor(); + if (background_colors_.isEmpty()) { + return QColor(); + } else { QList background_colors_keys = background_colors_.keys(); return background_colors_[background_colors_keys.last()]; diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index e7cb9c09..b7868d9c 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -461,10 +461,11 @@ void PlaylistManager::UpdateSummaryText() { if (!range.isValid()) continue; selected += range.bottom() - range.top() + 1; - for (int i = range.top() ; i <= range.bottom() ; ++i) { + for (int i = range.top(); i <= range.bottom(); ++i) { qint64 length = range.model()->index(i, Playlist::Column_Length).data().toLongLong(); - if (length > 0) + if (length > 0) { nanoseconds += length; + } } } diff --git a/src/playlist/playlisttabbar.cpp b/src/playlist/playlisttabbar.cpp index 522f59a8..9b8ea4c3 100644 --- a/src/playlist/playlisttabbar.cpp +++ b/src/playlist/playlisttabbar.cpp @@ -377,12 +377,14 @@ void PlaylistTabBar::dragMoveEvent(QDragMoveEvent *e) { e->setDropAction(Qt::CopyAction); e->accept(tabRect(drag_hover_tab_)); - if (!drag_hover_timer_.isActive()) + if (!drag_hover_timer_.isActive()) { drag_hover_timer_.start(kDragHoverTimeout, this); + } } else { drag_hover_timer_.stop(); } + } void PlaylistTabBar::dragLeaveEvent(QDragLeaveEvent*) { diff --git a/src/playlist/playlistundocommands.cpp b/src/playlist/playlistundocommands.cpp index efe5bebf..1377ef40 100644 --- a/src/playlist/playlistundocommands.cpp +++ b/src/playlist/playlistundocommands.cpp @@ -75,16 +75,23 @@ RemoveItems::RemoveItems(Playlist *playlist, int pos, int count) : Base(playlist } void RemoveItems::redo() { - for (int i = 0; i < ranges_.count(); ++i) + + for (int i = 0; i < ranges_.count(); ++i) { ranges_[i].items_ = playlist_->RemoveItemsWithoutUndo(ranges_[i].pos_, ranges_[i].count_); + } + } void RemoveItems::undo() { - for (int i = static_cast(ranges_.count() - 1); i >= 0; --i) + + for (int i = static_cast(ranges_.count() - 1); i >= 0; --i) { playlist_->InsertItemsWithoutUndo(ranges_[i].items_, ranges_[i].pos_); + } + } bool RemoveItems::mergeWith(const QUndoCommand *other) { + const RemoveItems *remove_command = static_cast(other); ranges_.append(remove_command->ranges_); @@ -93,6 +100,7 @@ bool RemoveItems::mergeWith(const QUndoCommand *other) { setText(tr("remove %n songs", "", sum)); return true; + } diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 13518e37..2e5156f7 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -505,8 +505,9 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option const_cast(this)->last_glow_rect_ = opt.rect; int step = glow_intensity_step_; - if (step >= kGlowIntensitySteps) + if (step >= kGlowIntensitySteps) { step = 2 * (kGlowIntensitySteps - 1) - step + 1; + } int row_height = opt.rect.height(); if (row_height != row_height_) { @@ -607,8 +608,9 @@ void PlaylistView::StopGlowing() { void PlaylistView::StartGlowing() { currently_glowing_ = true; - if (isVisible() && glow_enabled_) + if (isVisible() && glow_enabled_) { glow_timer_.start(1500 / kGlowIntensitySteps, this); + } } @@ -619,8 +621,9 @@ void PlaylistView::hideEvent(QHideEvent *e) { void PlaylistView::showEvent(QShowEvent *e) { - if (currently_glowing_ && glow_enabled_) + if (currently_glowing_ && glow_enabled_) { glow_timer_.start(1500 / kGlowIntensitySteps, this); + } MaybeAutoscroll(Playlist::AutoScroll_Maybe); @@ -710,8 +713,9 @@ void PlaylistView::RemoveSelected() { // Select the new current item, we want always the item after the last selected if (new_idx.isValid()) { // Workaround to update keyboard selected row, if it's not the first row (this also triggers selection) - if (new_row != 0) + if (new_row != 0) { keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier)); + } // Update visual selection with the entire row selectionModel()->select(new_idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } @@ -742,8 +746,9 @@ QModelIndex PlaylistView::NextEditableIndex(const QModelIndex ¤t) { QHeaderView *h = header(); int idx = columns.indexOf(h->visualIndex(current.column())); - if (idx + 1 >= columns.size()) + if (idx + 1 >= columns.size()) { return model()->index(current.row() + 1, h->logicalIndex(columns.first())); + } return model()->index(current.row(), h->logicalIndex(columns[idx + 1])); @@ -755,8 +760,9 @@ QModelIndex PlaylistView::PrevEditableIndex(const QModelIndex ¤t) { QHeaderView *h = header(); int idx = columns.indexOf(h->visualIndex(current.column())); - if (idx - 1 < 0) + if (idx - 1 < 0) { return model()->index(current.row() - 1, h->logicalIndex(columns.last())); + } return model()->index(current.row(), h->logicalIndex(columns[idx - 1])); @@ -780,19 +786,21 @@ void PlaylistView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHi else if (hint == QAbstractItemDelegate::EditNextItem || hint == QAbstractItemDelegate::EditPreviousItem) { QModelIndex idx; - if (hint == QAbstractItemDelegate::EditNextItem) + if (hint == QAbstractItemDelegate::EditNextItem) { idx = NextEditableIndex(currentIndex()); - else - idx = PrevEditableIndex(currentIndex()); - - if (!idx.isValid()) { - QTreeView::closeEditor(editor, QAbstractItemDelegate::SubmitModelCache); } else { + idx = PrevEditableIndex(currentIndex()); + } + + if (idx.isValid()) { QTreeView::closeEditor(editor, QAbstractItemDelegate::NoHint); setCurrentIndex(idx); QAbstractItemView::edit(idx); } + else { + QTreeView::closeEditor(editor, QAbstractItemDelegate::SubmitModelCache); + } } else { QTreeView::closeEditor(editor, hint); @@ -905,7 +913,11 @@ void PlaylistView::InhibitAutoscrollTimeout() { } void PlaylistView::MaybeAutoscroll(const Playlist::AutoScroll autoscroll) { - if (autoscroll == Playlist::AutoScroll_Always || (autoscroll == Playlist::AutoScroll_Maybe && !inhibit_autoscroll_)) JumpToCurrentlyPlayingTrack(); + + if (autoscroll == Playlist::AutoScroll_Always || (autoscroll == Playlist::AutoScroll_Maybe && !inhibit_autoscroll_)) { + JumpToCurrentlyPlayingTrack(); + } + } void PlaylistView::JumpToCurrentlyPlayingTrack() { @@ -1077,10 +1089,12 @@ void PlaylistView::paintEvent(QPaintEvent *event) { break; case QAbstractItemView::OnViewport: - if (model()->rowCount() == 0) + if (model()->rowCount() == 0) { drop_pos = 1; - else + } + else { drop_pos = 1 + visualRect(model()->index(model()->rowCount() - 1, first_column)).bottom(); + } break; } @@ -1123,23 +1137,29 @@ void PlaylistView::dragMoveEvent(QDragMoveEvent *event) { } void PlaylistView::dragEnterEvent(QDragEnterEvent *event) { + QTreeView::dragEnterEvent(event); cached_tree_ = QPixmap(); drag_over_ = true; + } void PlaylistView::dragLeaveEvent(QDragLeaveEvent *event) { + QTreeView::dragLeaveEvent(event); cached_tree_ = QPixmap(); drag_over_ = false; drop_indicator_row_ = -1; + } void PlaylistView::dropEvent(QDropEvent *event) { + QTreeView::dropEvent(event); cached_tree_ = QPixmap(); drop_indicator_row_ = -1; drag_over_ = false; + } void PlaylistView::PlaylistDestroyed() { @@ -1438,7 +1458,7 @@ void PlaylistView::set_background_image(const QImage &image) { if (!background_image_.isNull()) { // Apply opacity filter uchar *bits = background_image_.bits(); - for (int i = 0 ; i < background_image_.height() * background_image_.bytesPerLine() ; i += 4) { + for (int i = 0; i < background_image_.height() * background_image_.bytesPerLine(); i += 4) { bits[i + 3] = (opacity_level_ / 100.0) * 255; } diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index 24a6fc23..f1b6791c 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -143,10 +143,12 @@ void SongLoaderInserter::AudioCDTagsLoaded(const bool success) { SongLoader *loader = qobject_cast(sender()); if (!loader || !destination_) return; - if (success) + if (success) { destination_->UpdateItems(loader->songs()); - else + } + else { qLog(Error) << "Error while getting audio CD metadata from MusicBrainz"; + } deleteLater(); diff --git a/src/playlistparsers/asxparser.cpp b/src/playlistparsers/asxparser.cpp index c37bba2f..38354083 100644 --- a/src/playlistparsers/asxparser.cpp +++ b/src/playlistparsers/asxparser.cpp @@ -51,7 +51,7 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const // Some playlists have unescaped & characters in URLs :( QRegularExpression ex("(href\\s*=\\s*\")([^\"]+)\"", QRegularExpression::CaseInsensitiveOption); int index = 0; - for (QRegularExpressionMatch re_match = ex.match(data, index) ; re_match.hasMatch() ; re_match = ex.match(data, index)) { + for (QRegularExpressionMatch re_match = ex.match(data, index); re_match.hasMatch(); re_match = ex.match(data, index)) { index = re_match.capturedStart(); QString url = re_match.captured(2); url.replace(QRegularExpression("&(?!amp;|quot;|apos;|lt;|gt;)"), "&"); diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp index d7379c0e..024fdf6d 100644 --- a/src/playlistparsers/parserbase.cpp +++ b/src/playlistparsers/parserbase.cpp @@ -110,8 +110,9 @@ QString ParserBase::URLOrFilename(const QUrl &url, const QDir &dir, Playlist::Pa if (path_type != Playlist::Path_Absolute && QDir::isAbsolutePath(filename)) { const QString relative = dir.relativeFilePath(filename); - if (!relative.startsWith("../") || path_type == Playlist::Path_Relative) + if (!relative.startsWith("../") || path_type == Playlist::Path_Relative) { return relative; + } } return filename; diff --git a/src/playlistparsers/plsparser.cpp b/src/playlistparsers/plsparser.cpp index f5ef4622..5a174221 100644 --- a/src/playlistparsers/plsparser.cpp +++ b/src/playlistparsers/plsparser.cpp @@ -65,8 +65,9 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const // Use the title and length we've already loaded if any if (!songs[n].title().isEmpty()) song.set_title(songs[n].title()); - if (songs[n].length_nanosec() != -1) + if (songs[n].length_nanosec() != -1) { song.set_length_nanosec(songs[n].length_nanosec()); + } songs[n] = song; } diff --git a/src/qobuz/qobuzrequest.cpp b/src/qobuz/qobuzrequest.cpp index 6d32887b..d84790c9 100644 --- a/src/qobuz/qobuzrequest.cpp +++ b/src/qobuz/qobuzrequest.cpp @@ -708,7 +708,7 @@ void QobuzRequest::AlbumsFinishCheck(const QString &artist_id, const int limit, // Get songs for all the albums. QHash ::iterator it; - for (it = album_songs_requests_pending_.begin() ; it != album_songs_requests_pending_.end() ; ++it) { + for (it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) { Request request = it.value(); AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist, request.album); } diff --git a/src/queue/queue.cpp b/src/queue/queue.cpp index d2ae0876..7d942945 100644 --- a/src/queue/queue.cpp +++ b/src/queue/queue.cpp @@ -60,8 +60,9 @@ QModelIndex Queue::mapFromSource(const QModelIndex &source_index) const { const int source_row = source_index.row(); for (int i = 0; i < source_indexes_.count(); ++i) { - if (source_indexes_[i].row() == source_row) + if (source_indexes_[i].row() == source_row) { return index(i, source_index.column()); + } } return QModelIndex(); @@ -394,7 +395,7 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, if (!source_indexes.isEmpty()) { const int insert_point = row == -1 ? static_cast(source_indexes_.count()) : row; beginInsertRows(QModelIndex(), insert_point, insert_point + static_cast(source_indexes.count() - 1)); - for (int i = 0 ; i < source_indexes.count() ; ++i) { + for (int i = 0; i < source_indexes.count(); ++i) { source_indexes_.insert(insert_point + i, source_indexes[i]); } endInsertRows(); @@ -409,10 +410,12 @@ Qt::ItemFlags Queue::flags(const QModelIndex &idx) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - if (idx.isValid()) + if (idx.isValid()) { flags |= Qt::ItemIsDragEnabled; - else + } + else { flags |= Qt::ItemIsDropEnabled; + } return flags; diff --git a/src/queue/queueview.cpp b/src/queue/queueview.cpp index 197aea60..adc9396d 100644 --- a/src/queue/queueview.cpp +++ b/src/queue/queueview.cpp @@ -143,8 +143,9 @@ void QueueView::MoveDown() { QModelIndexList indexes = ui_->list->selectionModel()->selectedRows(); std::stable_sort(indexes.begin(), indexes.end()); - if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount() - 1) + if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount() - 1) { return; + } for (int i = static_cast(indexes.count() - 1); i >= 0; --i) { current_playlist_->queue()->MoveDown(indexes[i].row()); diff --git a/src/scrobbler/lastfmimport.cpp b/src/scrobbler/lastfmimport.cpp index 42e2cf87..9da474d2 100644 --- a/src/scrobbler/lastfmimport.cpp +++ b/src/scrobbler/lastfmimport.cpp @@ -397,7 +397,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in } if (page == 1) { - for (int i = 2 ; i <= pages ; ++i) { + for (int i = 2; i <= pages; ++i) { AddGetRecentTracksRequest(i); } } @@ -518,7 +518,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p else { QJsonArray array_track = json_obj["track"].toArray(); - for (QJsonArray::iterator it = array_track.begin() ; it != array_track.end() ; ++it) { + for (QJsonArray::iterator it = array_track.begin(); it != array_track.end(); ++it) { const QJsonValue &value_track = *it; @@ -554,7 +554,7 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p } if (page == 1) { - for (int i = 2 ; i <= pages ; ++i) { + for (int i = 2; i <= pages; ++i) { AddGetTopTracksRequest(i); } } diff --git a/src/scrobbler/scrobblercache.cpp b/src/scrobbler/scrobblercache.cpp index a8849c14..282875c1 100644 --- a/src/scrobbler/scrobblercache.cpp +++ b/src/scrobbler/scrobblercache.cpp @@ -168,7 +168,7 @@ void ScrobblerCache::WriteCache() { QJsonArray array; QHash > ::iterator i; - for (i = scrobbler_cache_.begin() ; i != scrobbler_cache_.end() ; ++i) { + for (i = scrobbler_cache_.begin(); i != scrobbler_cache_.end(); ++i) { ScrobblerCacheItemPtr item = i.value(); QJsonObject object; object.insert("timestamp", QJsonValue::fromVariant(item->timestamp_)); diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp index 6b465900..593b61a0 100644 --- a/src/settings/appearancesettingspage.cpp +++ b/src/settings/appearancesettingspage.cpp @@ -288,10 +288,12 @@ void AppearanceSettingsPage::Save() { } s.setValue(kBackgroundImageType, background_image_type_); - if (background_image_type_ == BackgroundImageType_Custom) + if (background_image_type_ == BackgroundImageType_Custom) { s.setValue(kBackgroundImageFilename, background_image_filename_); - else + } + else { s.remove(kBackgroundImageFilename); + } BackgroundImagePosition backgroundimageposition = BackgroundImagePosition(ui_->combobox_backgroundimageposition->itemData(ui_->combobox_backgroundimageposition->currentIndex()).toInt()); s.setValue(kBackgroundImageMaxSize, ui_->spinbox_background_image_maxsize->value()); diff --git a/src/settings/backendsettingspage.cpp b/src/settings/backendsettingspage.cpp index 6281863e..fde43e7d 100644 --- a/src/settings/backendsettingspage.cpp +++ b/src/settings/backendsettingspage.cpp @@ -211,7 +211,9 @@ void BackendSettingsPage::Load() { enginetype = ui_->combobox_engine->itemData(ui_->combobox_engine->currentIndex()).value(); QString output_name; - if (ui_->combobox_output->currentText().isEmpty()) output_name = engine()->DefaultOutput(); + if (ui_->combobox_output->currentText().isEmpty()) { + output_name = engine()->DefaultOutput(); + } else { EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value(); output_name = output.name; @@ -439,7 +441,9 @@ void BackendSettingsPage::Save() { QString output_name; QVariant device_value; - if (ui_->combobox_output->currentText().isEmpty()) output_name = engine()->DefaultOutput(); + if (ui_->combobox_output->currentText().isEmpty()) { + output_name = engine()->DefaultOutput(); + } else { EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value(); output_name = output.name; diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index 7a66505a..a36d5f2f 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -205,10 +205,12 @@ void BehaviourSettingsPage::Load() { #endif QString name = language_map_.key(s.value("language").toString()); - if (name.isEmpty()) + if (name.isEmpty()) { ui_->combobox_language->setCurrentIndex(0); - else + } + else { ui_->combobox_language->setCurrentIndex(ui_->combobox_language->findText(name)); + } ui_->combobox_menuplaymode->setCurrentIndex(ui_->combobox_menuplaymode->findData(s.value("menu_playmode", PlayBehaviour_Never).toInt())); diff --git a/src/settings/contextsettingspage.cpp b/src/settings/contextsettingspage.cpp index 87563a46..f1f7e0f2 100644 --- a/src/settings/contextsettingspage.cpp +++ b/src/settings/contextsettingspage.cpp @@ -138,7 +138,7 @@ void ContextSettingsPage::Load() { ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, "%title% - %artist%").toString()); ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString()); - for (int i = 0 ; i < ContextSettingsOrder::NELEMS ; ++i) { + for (int i = 0; i < ContextSettingsOrder::NELEMS; ++i) { checkboxes_[i]->setChecked(s.value(kSettingsGroupEnable[i], checkboxes_[i]->isChecked()).toBool()); } diff --git a/src/settings/coverssettingspage.cpp b/src/settings/coverssettingspage.cpp index 1e3e96ca..0e58cc66 100644 --- a/src/settings/coverssettingspage.cpp +++ b/src/settings/coverssettingspage.cpp @@ -97,7 +97,7 @@ void CoversSettingsPage::Load() { void CoversSettingsPage::Save() { QStringList providers; - for (int i = 0 ; i < ui_->providers->count() ; ++i) { + for (int i = 0; i < ui_->providers->count(); ++i) { const QListWidgetItem *item = ui_->providers->item(i); if (item->checkState() == Qt::Checked) providers << item->text(); // clazy:exclude=reserve-candidates } diff --git a/src/settings/globalshortcutssettingspage.cpp b/src/settings/globalshortcutssettingspage.cpp index 7b9a8959..51dd09b9 100644 --- a/src/settings/globalshortcutssettingspage.cpp +++ b/src/settings/globalshortcutssettingspage.cpp @@ -297,12 +297,15 @@ void GlobalShortcutsSettingsPage::ItemClicked(QTreeWidgetItem *item) { ui_->shortcut_options->setEnabled(true); ui_->shortcut_options->setTitle(tr("Shortcut for %1").arg(shortcut.s.action->text())); - if (shortcut.key == shortcut.s.default_key) + if (shortcut.key == shortcut.s.default_key) { ui_->radio_default->setChecked(true); - else if (shortcut.key.isEmpty()) + } + else if (shortcut.key.isEmpty()) { ui_->radio_none->setChecked(true); - else + } + else { ui_->radio_custom->setChecked(true); + } } diff --git a/src/settings/lyricssettingspage.cpp b/src/settings/lyricssettingspage.cpp index b0a66d46..c31d2756 100644 --- a/src/settings/lyricssettingspage.cpp +++ b/src/settings/lyricssettingspage.cpp @@ -97,7 +97,7 @@ void LyricsSettingsPage::Load() { void LyricsSettingsPage::Save() { QStringList providers; - for (int i = 0 ; i < ui_->providers->count() ; ++i) { + for (int i = 0; i < ui_->providers->count(); ++i) { const QListWidgetItem *item = ui_->providers->item(i); if (item->checkState() == Qt::Checked) providers << item->text(); // clazy:exclude=reserve-candidates } diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp index e9619762..73acc268 100644 --- a/src/settings/notificationssettingspage.cpp +++ b/src/settings/notificationssettingspage.cpp @@ -111,8 +111,9 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, QWi QObject::connect(ui_->notifications_exp_chooser2, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableSecondLine); QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled); - if (!dialog->osd()->SupportsNativeNotifications()) + if (!dialog->osd()->SupportsNativeNotifications()) { ui_->notifications_native->setEnabled(false); + } if (!dialog->osd()->SupportsTrayPopups()) ui_->notifications_tray->setEnabled(false); QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::UpdatePopupVisible); @@ -191,12 +192,15 @@ void NotificationsSettingsPage::Load() { ui_->notifications_opacity->setValue(static_cast(pretty_popup_->background_opacity() * 100)); QRgb color = pretty_popup_->background_color(); - if (color == OSDPretty::kPresetBlue) + if (color == OSDPretty::kPresetBlue) { ui_->notifications_bg_preset->setCurrentIndex(0); - else if (color == OSDPretty::kPresetRed) + } + else if (color == OSDPretty::kPresetRed) { ui_->notifications_bg_preset->setCurrentIndex(1); - else + } + else { ui_->notifications_bg_preset->setCurrentIndex(2); + } ui_->notifications_bg_preset->setItemData(2, QColor(color), Qt::DecorationRole); ui_->notifications_disable_duration->setChecked(pretty_popup_->disable_duration()); @@ -285,8 +289,7 @@ void NotificationsSettingsPage::PrettyColorPresetChanged(int index) { void NotificationsSettingsPage::ChooseBgColor() { QColor color = QColorDialog::getColor(pretty_popup_->background_color(), this); - if (!color.isValid()) - return; + if (!color.isValid()) return; pretty_popup_->set_background_color(color.rgb()); ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole); @@ -298,8 +301,7 @@ void NotificationsSettingsPage::ChooseBgColor() { void NotificationsSettingsPage::ChooseFgColor() { QColor color = QColorDialog::getColor(pretty_popup_->foreground_color(), this); - if (!color.isValid()) - return; + if (!color.isValid()) return; pretty_popup_->set_foreground_color(color.rgb()); diff --git a/src/settings/qobuzsettingspage.cpp b/src/settings/qobuzsettingspage.cpp index 2f1da468..a6cb2222 100644 --- a/src/settings/qobuzsettingspage.cpp +++ b/src/settings/qobuzsettingspage.cpp @@ -154,18 +154,24 @@ bool QobuzSettingsPage::eventFilter(QObject *object, QEvent *event) { } void QobuzSettingsPage::LogoutClicked() { + service_->Logout(); ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut); ui_->button_login->setEnabled(true); + } void QobuzSettingsPage::LoginSuccess() { + if (!this->isVisible()) return; ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn); ui_->button_login->setEnabled(true); + } void QobuzSettingsPage::LoginFailure(const QString &failure_reason) { + if (!this->isVisible()) return; QMessageBox::warning(this, tr("Authentication failed"), failure_reason); + } diff --git a/src/settings/tidalsettingspage.cpp b/src/settings/tidalsettingspage.cpp index bd7701e5..1f93633a 100644 --- a/src/settings/tidalsettingspage.cpp +++ b/src/settings/tidalsettingspage.cpp @@ -198,19 +198,25 @@ void TidalSettingsPage::OAuthClicked(const bool enabled) { } void TidalSettingsPage::LogoutClicked() { + service_->Logout(); ui_->button_login->setEnabled(true); ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut); + } void TidalSettingsPage::LoginSuccess() { + if (!this->isVisible()) return; ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn); ui_->button_login->setEnabled(true); + } void TidalSettingsPage::LoginFailure(const QString &failure_reason) { + if (!this->isVisible()) return; QMessageBox::warning(this, tr("Authentication failed"), failure_reason); ui_->button_login->setEnabled(true); + } diff --git a/src/smartplaylists/playlistquerygenerator.cpp b/src/smartplaylists/playlistquerygenerator.cpp index 6e66f7bc..92d3720a 100644 --- a/src/smartplaylists/playlistquerygenerator.cpp +++ b/src/smartplaylists/playlistquerygenerator.cpp @@ -96,8 +96,9 @@ PlaylistItemList PlaylistQueryGenerator::GenerateMore(const int count) { items << PlaylistItemPtr(PlaylistItem::NewFromSong(song)); previous_ids_ << song.id(); - if (previous_ids_.count() > GetDynamicFuture() + GetDynamicHistory()) + if (previous_ids_.count() > GetDynamicFuture() + GetDynamicHistory()) { previous_ids_.removeFirst(); + } } return items; diff --git a/src/smartplaylists/smartplaylistquerywizardplugin.cpp b/src/smartplaylists/smartplaylistquerywizardplugin.cpp index e8388953..81acbc18 100644 --- a/src/smartplaylists/smartplaylistquerywizardplugin.cpp +++ b/src/smartplaylists/smartplaylistquerywizardplugin.cpp @@ -331,8 +331,9 @@ void SmartPlaylistQueryWizardPlugin::MoveTermListToBottom(int min, int max) { Q_UNUSED(min); // Only scroll to the bottom if a new term is added - if (previous_scrollarea_max_ < max) + if (previous_scrollarea_max_ < max) { search_page_->ui_->terms_scroll_area->verticalScrollBar()->setValue(max); + } previous_scrollarea_max_ = max; diff --git a/src/smartplaylists/smartplaylistsearchterm.cpp b/src/smartplaylists/smartplaylistsearchterm.cpp index fc221064..25d66033 100644 --- a/src/smartplaylists/smartplaylistsearchterm.cpp +++ b/src/smartplaylists/smartplaylistsearchterm.cpp @@ -101,22 +101,29 @@ QString SmartPlaylistSearchTerm::ToSql() const { case Op_EndsWith: return col + " LIKE '%" + value + "'"; case Op_Equals: - if (TypeOf(field_) == Type_Text) + if (TypeOf(field_) == Type_Text) { return col + " LIKE '" + value + "'"; - else if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) + } + else if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) { return col + " = " + value; - else + } + else { return col + " = '" + value + "'"; + } case Op_GreaterThan: - if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) + if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) { return col + " > " + value; - else + } + else { return col + " > '" + value + "'"; + } case Op_LessThan: - if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) + if (TypeOf(field_) == Type_Date || TypeOf(field_) == Type_Time || TypeOf(field_) == Type_Rating) { return col + " < " + value; - else + } + else { return col + " < '" + value + "'"; + } case Op_NumericDate: return col + " > " + "DATETIME('now', '-" + value + " " + date + "', 'localtime')"; case Op_NumericDateNot: diff --git a/src/subsonic/subsonicbaserequest.cpp b/src/subsonic/subsonicbaserequest.cpp index 031e38f4..4e5afcd5 100644 --- a/src/subsonic/subsonicbaserequest.cpp +++ b/src/subsonic/subsonicbaserequest.cpp @@ -87,8 +87,9 @@ QUrl SubsonicBaseRequest::CreateUrl(const QString &ressource_name, const QList

::iterator it = album_songs_requests_pending_.begin() ; it != album_songs_requests_pending_.end() ; ++it) { + for (QHash ::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) { Request request = it.value(); AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist); } diff --git a/src/tidal/tidalrequest.cpp b/src/tidal/tidalrequest.cpp index 291a037c..8cc6e82d 100644 --- a/src/tidal/tidalrequest.cpp +++ b/src/tidal/tidalrequest.cpp @@ -728,7 +728,7 @@ void TidalRequest::AlbumsFinishCheck(const QString &artist_id, const int limit, // Get songs for all the albums. - for (QHash ::iterator it = album_songs_requests_pending_.begin() ; it != album_songs_requests_pending_.end() ; ++it) { + for (QHash ::iterator it = album_songs_requests_pending_.begin(); it != album_songs_requests_pending_.end(); ++it) { Request request = it.value(); AddAlbumSongsRequest(request.artist_id, request.album_id, request.album_artist, request.album, request.album_explicit); } diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp index 72299f58..edf6d5d3 100644 --- a/src/transcoder/transcoder.cpp +++ b/src/transcoder/transcoder.cpp @@ -105,13 +105,13 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co GstRegistry *registry = gst_registry_get(); GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY); - for (GList *f = features ; f ; f = g_list_next(f)) { + for (GList *f = features; f; f = g_list_next(f)) { GstElementFactory *factory = GST_ELEMENT_FACTORY(f->data); // Is this the right type of plugin? if (QString(gst_element_factory_get_klass(factory)).contains(element_type)) { const GList *const templates = gst_element_factory_get_static_pad_templates(factory); - for (const GList *t = templates ; t ; t = g_list_next(t)) { + for (const GList *t = templates; t; t = g_list_next(t)) { // Only interested in source pads GstStaticPadTemplate *pad_template = reinterpret_cast(t->data); if (pad_template->direction != GST_PAD_SRC) continue; @@ -484,9 +484,8 @@ bool Transcoder::event(QEvent *e) { // Find this job in the list JobStateList::iterator it = current_jobs_.begin(); - while (it != current_jobs_.end()) { + for (; it != current_jobs_.end(); ++it) { if (it->get() == finished_event->state_) break; - ++it; } if (it == current_jobs_.end()) { // Couldn't find it, maybe GStreamer gave us an event after we'd destroyed the pipeline? diff --git a/src/widgets/autoexpandingtreeview.cpp b/src/widgets/autoexpandingtreeview.cpp index dab65cfa..7b1baae9 100644 --- a/src/widgets/autoexpandingtreeview.cpp +++ b/src/widgets/autoexpandingtreeview.cpp @@ -65,22 +65,26 @@ void AutoExpandingTreeView::RecursivelyExpandSlot(const QModelIndex &idx) { bool AutoExpandingTreeView::RecursivelyExpand(const QModelIndex &idx, int *count) { - if (!CanRecursivelyExpand(idx)) + if (!CanRecursivelyExpand(idx)) { return true; + } - if (model()->canFetchMore(idx)) + if (model()->canFetchMore(idx)) { model()->fetchMore(idx); + } int children = model()->rowCount(idx); - if (*count + children > kRowsToShow) + if (*count + children > kRowsToShow) { return false; + } expand(idx); *count += children; - for (int i = 0 ; i < children ; ++i) { - if (!RecursivelyExpand(model()->index(i, 0, idx), count)) + for (int i = 0; i < children; ++i) { + if (!RecursivelyExpand(model()->index(i, 0, idx), count)) { return false; + } } return true; diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index d7d46c7b..a5205dd9 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -87,11 +87,13 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro QSize sizeHint() const override { FancyTabWidget *tabWidget = qobject_cast(parentWidget()); - if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) return QTabBar::sizeHint(); + if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) { + return QTabBar::sizeHint(); + } QSize size; int h = 0; - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { if (tabSizeHint(i).width() > size.width()) size.setWidth(tabSizeHint(i).width()); h += tabSizeHint(i).height(); } @@ -105,7 +107,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro FancyTabWidget *tabWidget = qobject_cast(parentWidget()); if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar || tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) { int w = 0; - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { if (tabSizeHint(i).width() > w) w = tabSizeHint(i).width(); } return w; @@ -129,7 +131,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro // If the text of any tab is wider than the set width then use that instead. int w = std::max(FancyTabWidget::TabSize_LargeSidebarMinWidth, tabWidget->iconsize_largesidebar() + 22); - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { QRect rect = fm.boundingRect(QRect(0, 0, std::max(FancyTabWidget::TabSize_LargeSidebarMinWidth, tabWidget->iconsize_largesidebar() + 22), height()), Qt::TextWordWrap, QTabBar::tabText(i)); rect.setWidth(rect.width() + 10); if (rect.width() > w) w = rect.width(); @@ -168,8 +170,9 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro QPoint pos = event->pos(); mouseHoverTabIndex = tabAt(pos); - if (mouseHoverTabIndex > -1) + if (mouseHoverTabIndex > -1) { update(); + } QTabBar::mouseMoveEvent(event); } @@ -180,8 +183,9 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro bool verticalTextTabs = false; - if (tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) + if (tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) { verticalTextTabs = true; + } // if LargeSidebar, restore spacers if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar && spacers.count() > 0) { @@ -194,7 +198,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro } else if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar) { // traverse in the opposite order to save indices of spacers - for (int i = count() - 1 ; i >= 0 ; --i) { + for (int i = count() - 1; i >= 0; --i) { // spacers are disabled tabs if (!isTabEnabled(i) && !spacers.contains(i)) { spacers[i] = tabWidget->widget(i); @@ -206,7 +210,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro // Restore any label text that was hidden/cached for the IconOnlyTabs mode if (labelCache.count() > 0 && tabWidget->mode() != FancyTabWidget::Mode_IconOnlyTabs) { - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { setTabToolTip(i, ""); setTabText(i, labelCache[tabWidget->widget(i)]); } @@ -215,7 +219,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar && tabWidget->mode() != FancyTabWidget::Mode_SmallSidebar) { // Cache and hide label text for IconOnlyTabs mode if (tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs && labelCache.count() == 0) { - for(int i = 0 ; i < count() ; ++i) { + for(int i = 0; i < count(); ++i) { labelCache[tabWidget->widget(i)] = tabText(i); setTabToolTip(i, tabText(i)); setTabText(i, ""); @@ -486,7 +490,7 @@ void FancyTabWidget::Load(const QString &kSettingsGroup) { s.endGroup(); QMultiMap ::iterator i; - for (i = tabs.begin() ; i != tabs.end() ; ++i) { + for (i = tabs.begin(); i != tabs.end(); ++i) { TabData *tab = i.value(); const int idx = insertTab(i.key(), tab->page(), tab->icon(), tab->label()); tabBar()->setTabData(idx, QVariant(tab->name())); diff --git a/src/widgets/fileview.cpp b/src/widgets/fileview.cpp index 331f2ea1..ebfde4fa 100644 --- a/src/widgets/fileview.cpp +++ b/src/widgets/fileview.cpp @@ -113,10 +113,14 @@ void FileView::ReloadSettings() { } void FileView::SetPath(const QString &path) { - if (!model_) - lazy_set_path_ = path; - else + + if (model_) { ChangeFilePathWithoutUndo(path); + } + else { + lazy_set_path_ = path; + } + } void FileView::SetTaskManager(TaskManager *task_manager) { @@ -150,12 +154,14 @@ void FileView::ChangeFilePath(const QString &new_path_native) { QString new_path = QDir::fromNativeSeparators(new_path_native); QFileInfo info(new_path); - if (!info.exists() || !info.isDir()) + if (!info.exists() || !info.isDir()) { return; + } QString old_path(model_->rootPath()); - if (old_path == new_path) + if (old_path == new_path) { return; + } undo_stack_->push(new UndoCommand(this, new_path)); @@ -180,8 +186,9 @@ void FileView::ItemActivated(const QModelIndex &idx) { void FileView::ItemDoubleClick(const QModelIndex &idx) { - if (model_->isDir(idx)) + if (model_->isDir(idx)) { return; + } QString file_path = model_->filePath(idx); @@ -287,4 +294,3 @@ void FileView::keyPressEvent(QKeyEvent *e) { QWidget::keyPressEvent(e); } - diff --git a/src/widgets/fileviewlist.cpp b/src/widgets/fileviewlist.cpp index 67c2e86a..3e691f4d 100644 --- a/src/widgets/fileviewlist.cpp +++ b/src/widgets/fileviewlist.cpp @@ -71,8 +71,9 @@ QList FileViewList::UrlListFromSelection() const { QList urls; const QModelIndexList indexes = menu_selection_.indexes(); for (const QModelIndex &index : indexes) { - if (index.column() == 0) + if (index.column() == 0) { urls << QUrl::fromLocalFile(qobject_cast(model())->fileInfo(index).canonicalFilePath()); + } } std::sort(urls.begin(), urls.end()); @@ -122,8 +123,9 @@ QStringList FileViewList::FilenamesFromSelection() const { QStringList filenames; const QModelIndexList indexes = menu_selection_.indexes(); for (const QModelIndex &index : indexes) { - if (index.column() == 0) + if (index.column() == 0) { filenames << qobject_cast(model())->filePath(index); + } } return filenames; diff --git a/src/widgets/freespacebar.cpp b/src/widgets/freespacebar.cpp index 1de5237a..40ebd84d 100644 --- a/src/widgets/freespacebar.cpp +++ b/src/widgets/freespacebar.cpp @@ -172,7 +172,7 @@ void FreeSpaceBar::DrawBar(QPainter *p, const QRect r) { p->setOpacity(0.35); p->setRenderHint(QPainter::Antialiasing, false); p->setPen(QPen(palette().color(QPalette::Light), 1.0)); - for (int x = r.left() + kMarkerSpacing ; x < r.right() ; x += kMarkerSpacing) { + for (int x = r.left() + kMarkerSpacing; x < r.right(); x += kMarkerSpacing) { p->drawLine(x, r.top() + 2, x, r.bottom() - 2); } diff --git a/src/widgets/groupediconview.cpp b/src/widgets/groupediconview.cpp index 130c5de3..7b3832de 100644 --- a/src/widgets/groupediconview.cpp +++ b/src/widgets/groupediconview.cpp @@ -140,8 +140,10 @@ void GroupedIconView::dataChanged(const QModelIndex &topLeft, const QModelIndex } void GroupedIconView::LayoutItems() { - if (!model()) + + if (!model()) { return; + } const int count = model()->rowCount(); @@ -210,29 +212,34 @@ void GroupedIconView::LayoutItems() { verticalScrollBar()->setRange(0, next_position.y() + max_row_height - viewport()->height()); update(); + } QRect GroupedIconView::visualRect(const QModelIndex &idx) const { - if (idx.row() < 0 || idx.row() >= visual_rects_.count()) + if (idx.row() < 0 || idx.row() >= visual_rects_.count()) { return QRect(); + } return visual_rects_[idx.row()].translated(-horizontalOffset(), -verticalOffset()); } QModelIndex GroupedIconView::indexAt(const QPoint &p) const { + const QPoint viewport_p = p + QPoint(horizontalOffset(), verticalOffset()); const int count = visual_rects_.count(); - for (int i=0 ; iindex(i, 0); } } return QModelIndex(); + } void GroupedIconView::paintEvent(QPaintEvent *e) { + // This code was adapted from QListView::paintEvent(), changed to use the visualRect() of items, and to draw headers. QStyleOptionViewItem option; @@ -241,8 +248,9 @@ void GroupedIconView::paintEvent(QPaintEvent *e) { #else option = viewOptions(); #endif - if (isWrapping()) + if (isWrapping()) { option.features = QStyleOptionViewItem::WrapText; + } option.locale = locale(); option.locale.setNumberOptions(QLocale::OmitGroupSeparator); option.widget = this; @@ -270,10 +278,12 @@ void GroupedIconView::paintEvent(QPaintEvent *e) { option.rect = visualRect(*it); - if (flow() == TopToBottom) + if (flow() == TopToBottom) { option.rect.setWidth(qMin(maxSize, option.rect.width())); - else + } + else { option.rect.setHeight(qMin(maxSize, option.rect.height())); + } option.state = state; if (selections && selections->isSelected(*it)) @@ -291,8 +301,9 @@ void GroupedIconView::paintEvent(QPaintEvent *e) { } if (focus && current == *it) { option.state |= QStyle::State_HasFocus; - if (viewState == EditingState) + if (viewState == EditingState) { option.state |= QStyle::State_Editing; + } } itemDelegate()->paint(&painter, option, *it); @@ -314,6 +325,7 @@ void GroupedIconView::paintEvent(QPaintEvent *e) { palette(), model()->index(header.first_row, 0).data(Role_Group).toString()); } + } void GroupedIconView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) { diff --git a/src/widgets/lineedit.cpp b/src/widgets/lineedit.cpp index e3ee8ec3..1ee8f0bd 100644 --- a/src/widgets/lineedit.cpp +++ b/src/widgets/lineedit.cpp @@ -254,8 +254,9 @@ void CheckBox::resizeEvent(QResizeEvent *e) { QString SpinBox::textFromValue(int val) const { - if (val <= 0 && !hint_.isEmpty()) + if (val <= 0 && !hint_.isEmpty()) { return "-"; + } return QSpinBox::textFromValue(val); } diff --git a/src/widgets/loginstatewidget.cpp b/src/widgets/loginstatewidget.cpp index 5538217c..2564dbae 100644 --- a/src/widgets/loginstatewidget.cpp +++ b/src/widgets/loginstatewidget.cpp @@ -113,6 +113,7 @@ void LoginStateWidget::FocusLastCredentialField() { line_edit->selectAll(); } } + } void LoginStateWidget::HideLoggedInState() { @@ -130,6 +131,7 @@ void LoginStateWidget::AddCredentialGroup(QWidget *widget) { } bool LoginStateWidget::eventFilter(QObject *object, QEvent *event) { + if (!credential_fields_.contains(object)) return QWidget::eventFilter(object, event); @@ -142,6 +144,7 @@ bool LoginStateWidget::eventFilter(QObject *object, QEvent *event) { } return QWidget::eventFilter(object, event); + } void LoginStateWidget::SetExpires(const QDate expires) { @@ -152,4 +155,5 @@ void LoginStateWidget::SetExpires(const QDate expires) { const QString expires_text = QLocale().toString(expires, QLocale::LongFormat); ui_->expires_label->setText(tr("Expires on %1").arg("" + expires_text + "")); } + } diff --git a/src/widgets/playingwidget.cpp b/src/widgets/playingwidget.cpp index b6d7ddc0..4717187d 100644 --- a/src/widgets/playingwidget.cpp +++ b/src/widgets/playingwidget.cpp @@ -379,7 +379,9 @@ void PlayingWidget::UpdateHeight() { // Update the animation settings and resize the widget now if we're visible timeline_show_hide_->setFrameRange(0, total_height_); - if (visible_ && active_ && timeline_show_hide_->state() != QTimeLine::Running) setMaximumHeight(total_height_); + if (visible_ && active_ && timeline_show_hide_->state() != QTimeLine::Running) { + setMaximumHeight(total_height_); + } // Re-scale the current image if (song_.is_valid()) { diff --git a/src/widgets/qsearchfield_mac.mm b/src/widgets/qsearchfield_mac.mm index f2c4f1c7..d7828ea9 100644 --- a/src/widgets/qsearchfield_mac.mm +++ b/src/widgets/qsearchfield_mac.mm @@ -234,7 +234,7 @@ void QSearchField::setFocus() { void QSearchField::showEvent(QShowEvent *e) { if (!e->spontaneous()) { - for (int i = 0 ; i < layout()->count() ; ++i) { + for (int i = 0; i < layout()->count(); ++i) { QWidget *widget = layout()->itemAt(i)->widget(); layout()->removeWidget(widget); delete widget; diff --git a/src/widgets/ratingwidget.cpp b/src/widgets/ratingwidget.cpp index ce3a5ecc..c34e9db6 100644 --- a/src/widgets/ratingwidget.cpp +++ b/src/widgets/ratingwidget.cpp @@ -41,7 +41,7 @@ RatingPainter::RatingPainter() { QPixmap off(star_off.pixmap(star_off_sizes.last())); // Generate the 10 states, better to do it now than on the fly - for (int i = 0 ; i < kStarCount * 2 + 1 ; ++i) { + for (int i = 0; i < kStarCount * 2 + 1; ++i) { const double rating = double(i) / double(2.0); // Clear the pixmap @@ -51,7 +51,7 @@ RatingPainter::RatingPainter() { // Draw the stars int x = 0; - for (int y = 0 ; y < kStarCount ; ++y, x += kStarSize) { + for (int y = 0; y < kStarCount; ++y, x += kStarSize) { const QRect rect(x, 0, kStarSize, kStarSize); if (rating - 0.25 <= y) { // Totally empty diff --git a/src/widgets/stickyslider.cpp b/src/widgets/stickyslider.cpp index 0b365abb..12604d86 100644 --- a/src/widgets/stickyslider.cpp +++ b/src/widgets/stickyslider.cpp @@ -38,6 +38,8 @@ void StickySlider::mouseMoveEvent(QMouseEvent *e) { if (sticky_center_ == -1) return; const int v = sliderPosition(); - if (v <= sticky_center_ + sticky_threshold_ && v >= sticky_center_ - sticky_threshold_) setSliderPosition(sticky_center_); + if (v <= sticky_center_ + sticky_threshold_ && v >= sticky_center_ - sticky_threshold_) { + setSliderPosition(sticky_center_); + } } diff --git a/src/widgets/stretchheaderview.cpp b/src/widgets/stretchheaderview.cpp index b1f9c3fd..964427bd 100644 --- a/src/widgets/stretchheaderview.cpp +++ b/src/widgets/stretchheaderview.cpp @@ -71,24 +71,25 @@ void StretchHeaderView::NormaliseWidths(const QList §ions) { if (!sections.isEmpty()) { selected_sum = 0.0; - for (int i = 0 ; i < count() ; ++i) - if (sections.contains(i)) + for (int i = 0; i < count(); ++i) + if (sections.contains(i)) { selected_sum += column_widths_[i]; + } } if (total_sum != 0.0 && !qFuzzyCompare(total_sum, 1.0)) { const ColumnWidthType mult = (selected_sum + (1.0 - total_sum)) / selected_sum; - for (int i = 0 ; i < column_widths_.count() ; ++i) { - if (sections.isEmpty() || sections.contains(i)) + for (int i = 0; i < column_widths_.count(); ++i) { + if (sections.isEmpty() || sections.contains(i)) { column_widths_[i] *= mult; + } } } } void StretchHeaderView::UpdateWidths(const QList §ions) { - if (!stretch_enabled_) - return; + if (!stretch_enabled_) return; ColumnWidthType total_w = 0.0; @@ -98,17 +99,20 @@ void StretchHeaderView::UpdateWidths(const QList §ions) { total_w += w; - if (!sections.isEmpty() && !sections.contains(i)) + if (!sections.isEmpty() && !sections.contains(i)) { continue; + } - if (pixels == 0 && !isSectionHidden(i)) + if (pixels == 0 && !isSectionHidden(i)) { hideSection(i); + } else if (pixels != 0 && isSectionHidden(i)) { showSection(i); } - if (pixels != 0) + if (pixels != 0) { resizeSection(i, pixels); + } } } @@ -117,7 +121,7 @@ void StretchHeaderView::HideSection(const int logical) { // Would this hide the last section? bool all_hidden = true; - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { if (i != logical && !isSectionHidden(i) && sectionSize(i) > 0) { all_hidden = false; break; @@ -147,9 +151,10 @@ void StretchHeaderView::ShowSection(int logical) { // How many sections are visible already? int visible_count = 0; - for (int i = 0 ; i < count() ; ++i) { - if (!isSectionHidden(i)) + for (int i = 0; i < count(); ++i) { + if (!isSectionHidden(i)) { ++visible_count; + } } column_widths_[logical] = visible_count == 0 ? 1.0 : 1.0 / visible_count; @@ -199,8 +204,9 @@ void StretchHeaderView::SectionResized(const int logical, const int, const int n int visual = visualIndex(logical); QList logical_sections_to_resize; for (int i = 0; i < count(); ++i) { - if (!isSectionHidden(i) && visualIndex(i) > visual) + if (!isSectionHidden(i) && visualIndex(i) > visual) { logical_sections_to_resize << i; + } } // Resize just those columns @@ -244,9 +250,11 @@ void StretchHeaderView::SetColumnWidth(const int logical, const ColumnWidthType column_widths_[logical] = width; QList other_columns; - for (int i = 0 ; i < count() ; ++i) - if (!isSectionHidden(i) && i != logical) + for (int i = 0; i < count(); ++i) { + if (!isSectionHidden(i) && i != logical) { other_columns << i; + } + } NormaliseWidths(other_columns); @@ -357,7 +365,7 @@ QByteArray StretchHeaderView::ResetState() { visual_indices.reserve(count()); pixel_widths.reserve(count()); - for (int i = 0 ; i < count() ; ++i) { + for (int i = 0; i < count(); ++i) { pixel_widths << 10; visual_indices << count(); } diff --git a/src/widgets/trackslider.cpp b/src/widgets/trackslider.cpp index 6bcd89e8..bf6c0db6 100644 --- a/src/widgets/trackslider.cpp +++ b/src/widgets/trackslider.cpp @@ -74,24 +74,30 @@ TrackSlider::TrackSlider(QWidget *parent) } TrackSlider::~TrackSlider() { + delete ui_; #ifdef HAVE_MOODBAR if (moodbar_style_) moodbar_style_->deleteLater(); #endif + } void TrackSlider::SetApplication(Application *app) { + #ifdef HAVE_MOODBAR if (!moodbar_style_) moodbar_style_ = new MoodbarProxyStyle(app, ui_->slider); #else Q_UNUSED(app); #endif + } void TrackSlider::UpdateLabelWidth() { + // We set the label's minimum size so it won't resize itself when the user is dragging the slider. UpdateLabelWidth(ui_->elapsed, "0:00:00"); UpdateLabelWidth(ui_->remaining, "-0:00:00"); + } void TrackSlider::UpdateLabelWidth(QLabel *label, const QString &text) { @@ -168,15 +174,20 @@ void TrackSlider::SetCanSeek(const bool can_seek) { } void TrackSlider::Seek(const int gap) { - if (ui_->slider->isEnabled()) + + if (ui_->slider->isEnabled()) { ui_->slider->setValue(static_cast(ui_->slider->value() + gap * kMsecPerSec)); + } + } void TrackSlider::ValueMaybeChanged(const int value) { + if (setting_value_) return; UpdateTimes(static_cast(value / kMsecPerSec)); emit ValueChangedSeconds(static_cast(value / kMsecPerSec)); + } bool TrackSlider::event(QEvent *e) { diff --git a/src/widgets/volumeslider.cpp b/src/widgets/volumeslider.cpp index acbbf6fc..b522b163 100644 --- a/src/widgets/volumeslider.cpp +++ b/src/widgets/volumeslider.cpp @@ -136,8 +136,9 @@ void SliderSlider::mousePressEvent(QMouseEvent *e) { void SliderSlider::mouseReleaseEvent(QMouseEvent*) { - if (!outside_ && QSlider::value() != prev_value_) + if (!outside_ && QSlider::value() != prev_value_) { emit sliderReleased(value()); + } sliding_ = false; outside_ = false;