diff --git a/3rdparty/singleapplication/singleapplication.cpp b/3rdparty/singleapplication/singleapplication.cpp index b0a0b9fa3..66a565c7b 100644 --- a/3rdparty/singleapplication/singleapplication.cpp +++ b/3rdparty/singleapplication/singleapplication.cpp @@ -134,7 +134,7 @@ SingleApplication::SingleApplication(int &argc, char *argv[], bool allowSecondar } } - if (inst->primary == false) { + if (!inst->primary) { d->startPrimary(); if (!d->memory_->unlock()) { qDebug() << "SingleApplication: Unable to unlock memory after primary start."; diff --git a/3rdparty/singleapplication/singlecoreapplication.cpp b/3rdparty/singleapplication/singlecoreapplication.cpp index 5ead4cbb2..bc7e3ce9d 100644 --- a/3rdparty/singleapplication/singlecoreapplication.cpp +++ b/3rdparty/singleapplication/singlecoreapplication.cpp @@ -134,7 +134,7 @@ SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], bool allow } } - if (inst->primary == false) { + if (!inst->primary) { d->startPrimary(); if (!d->memory_->unlock()) { qDebug() << "SingleCoreApplication: Unable to unlock memory after primary start."; diff --git a/ext/libstrawberry-common/core/messagehandler.cpp b/ext/libstrawberry-common/core/messagehandler.cpp index 9947c35e2..277ebbb60 100644 --- a/ext/libstrawberry-common/core/messagehandler.cpp +++ b/ext/libstrawberry-common/core/messagehandler.cpp @@ -64,7 +64,7 @@ void _MessageHandlerBase::SetDevice(QIODevice *device) { void _MessageHandlerBase::DeviceReadyRead() { - while (device_->bytesAvailable()) { + while (device_->bytesAvailable() > 0) { if (!reading_protobuf_) { // Read the length of the next message QDataStream s(device_); diff --git a/src/collection/collectionquery.cpp b/src/collection/collectionquery.cpp index 8d04c1810..cf7bc3a5e 100644 --- a/src/collection/collectionquery.cpp +++ b/src/collection/collectionquery.cpp @@ -133,7 +133,7 @@ QString CollectionQuery::GetInnerQuery() const { void CollectionQuery::AddWhere(const QString &column, const QVariant &value, const QString &op) { // Ignore 'literal' for IN - if (!op.compare("IN", Qt::CaseInsensitive)) { + if (op.compare("IN", Qt::CaseInsensitive) == 0) { QStringList values = value.toStringList(); QStringList final; final.reserve(values.count()); diff --git a/src/collection/collectionwatcher.cpp b/src/collection/collectionwatcher.cpp index 7bf85e03c..8c222f408 100644 --- a/src/collection/collectionwatcher.cpp +++ b/src/collection/collectionwatcher.cpp @@ -777,7 +777,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path SongList songs; quint64 matching_cue_mtime = GetMtimeForCue(matching_cue); - if (matching_cue_mtime) { // If it's a CUE - create virtual tracks + if (matching_cue_mtime != 0) { // If it's a CUE - create virtual tracks // Don't process the same CUE many times if (cues_processed->contains(matching_cue)) return songs; diff --git a/src/context/contextalbumsview.cpp b/src/context/contextalbumsview.cpp index cd60f8984..36fb20264 100644 --- a/src/context/contextalbumsview.cpp +++ b/src/context/contextalbumsview.cpp @@ -305,10 +305,10 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) { const bool regular_elements_only = songs_selected == regular_elements && regular_elements > 0; // in all modes - load_->setEnabled(songs_selected); - add_to_playlist_->setEnabled(songs_selected); - open_in_new_playlist_->setEnabled(songs_selected); - add_to_playlist_enqueue_->setEnabled(songs_selected); + load_->setEnabled(songs_selected > 0); + add_to_playlist_->setEnabled(songs_selected > 0); + open_in_new_playlist_->setEnabled(songs_selected > 0); + add_to_playlist_enqueue_->setEnabled(songs_selected > 0); // if neither edit_track not edit_tracks are available, we show disabled edit_track element edit_track_->setVisible(regular_editable <= 1); diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 33d4ac668..97d1a8202 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -1303,8 +1303,8 @@ void MainWindow::SendNowPlaying() { } void MainWindow::VolumeChanged(const int volume) { - ui_->action_mute->setChecked(!volume); - tray_icon_->MuteButtonStateChanged(!volume); + ui_->action_mute->setChecked(volume == 0); + tray_icon_->MuteButtonStateChanged(volume == 0); } void MainWindow::SongChanged(const Song &song) { @@ -1824,8 +1824,8 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex & playlist_rescan_songs_->setVisible(local_songs > 0 && editable > 0); #ifdef HAVE_GSTREAMER - ui_->action_add_files_to_transcoder->setEnabled(local_songs > 0 && editable); - ui_->action_add_files_to_transcoder->setVisible(local_songs > 0 && editable); + ui_->action_add_files_to_transcoder->setEnabled(local_songs > 0 && editable > 0); + ui_->action_add_files_to_transcoder->setVisible(local_songs > 0 && editable > 0); #endif playlist_open_in_browser_->setVisible(selected > 0 && local_songs == selected); diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index 3924be0e8..7369ab5e7 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -108,11 +108,11 @@ void MergedProxyModel::AddSubModel(const QModelIndex &source_parent, QAbstractIt QModelIndex proxy_parent = mapFromSource(source_parent); const int rows = submodel->rowCount(); - if (rows) beginInsertRows(proxy_parent, 0, rows - 1); + if (rows > 0) beginInsertRows(proxy_parent, 0, rows - 1); merge_points_.insert(submodel, source_parent); - if (rows) endInsertRows(); + if (rows > 0) endInsertRows(); } void MergedProxyModel::RemoveSubModel(const QModelIndex &source_parent) { @@ -225,7 +225,7 @@ void MergedProxyModel::SubModelResetSlot() { // "Insert" items from the newly reset submodel int count = submodel->rowCount(); - if (count) { + if (count > 0) { beginInsertRows(proxy_parent, 0, count - 1); endInsertRows(); } diff --git a/src/core/song.cpp b/src/core/song.cpp index a278275e4..df3fa9a24 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -1127,7 +1127,7 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) { d->disc_ = track->cd_nr; d->year_ = track->year; d->genre_ = QString::fromUtf8(track->genre); - d->compilation_ = track->compilation; + d->compilation_ = track->compilation == 1; d->composer_ = QString::fromUtf8(track->composer); d->grouping_ = QString::fromUtf8(track->grouping); d->comment_ = QString::fromUtf8(track->comment); diff --git a/src/core/stylehelper.cpp b/src/core/stylehelper.cpp index 75c09bb64..31f421751 100644 --- a/src/core/stylehelper.cpp +++ b/src/core/stylehelper.cpp @@ -292,7 +292,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter, QRect r = option->rect; int size = qMin(r.height(), r.width()); QPixmap pixmap; - QString pixmapName = QString::asprintf("StyleHelper::drawArrow-%d-%d-%d-%f", element, size, enabled, devicePixelRatio); + QString pixmapName = QString::asprintf("StyleHelper::drawArrow-%d-%d-%d-%f", element, size, (enabled ? 1 : 0), devicePixelRatio); if (!QPixmapCache::find(pixmapName, &pixmap)) { QImage image(size * devicePixelRatio, size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); diff --git a/src/core/taskmanager.cpp b/src/core/taskmanager.cpp index add8711ab..1cc91efb5 100644 --- a/src/core/taskmanager.cpp +++ b/src/core/taskmanager.cpp @@ -87,7 +87,7 @@ void TaskManager::SetTaskProgress(const int id, const qint64 progress, const qin Task &t = tasks_[id]; t.progress = progress; - if (max) t.progress_max = max; + if (max > 0) t.progress_max = max; } emit TasksChanged(); @@ -101,7 +101,7 @@ void TaskManager::IncreaseTaskProgress(const int id, const qint64 progress, cons Task &t = tasks_[id]; t.progress += progress; - if (max) t.progress_max = max; + if (max > 0) t.progress_max = max; } emit TasksChanged(); diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 92bce8b01..e9ee66a99 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -123,7 +123,7 @@ QString PrettyTime(int seconds) { seconds %= 60; QString ret; - if (hours) ret = QString::asprintf("%d:%02d:%02d", hours, minutes, seconds); + if (hours > 0) ret = QString::asprintf("%d:%02d:%02d", hours, minutes, seconds); else ret = QString::asprintf("%d:%02d", minutes, seconds); return ret; @@ -141,7 +141,7 @@ QString WordyTime(const quint64 seconds) { // TODO: Make the plural rules translatable QStringList parts; - if (days) parts << (days == 1 ? tr("1 day") : tr("%1 days").arg(days)); + if (days > 0) parts << (days == 1 ? tr("1 day") : tr("%1 days").arg(days)); parts << PrettyTime(static_cast(seconds - days * 60 * 60 * 24)); return parts.join(" "); diff --git a/src/covermanager/albumcoverchoicecontroller.cpp b/src/covermanager/albumcoverchoicecontroller.cpp index f11765ffa..d4875a2ef 100644 --- a/src/covermanager/albumcoverchoicecontroller.cpp +++ b/src/covermanager/albumcoverchoicecontroller.cpp @@ -595,7 +595,7 @@ QUrl AlbumCoverChoiceController::SaveCoverToFileAutomatic(const Song::Source sou QUrl cover_url; if (result.is_jpeg()) { if (file.open(QIODevice::WriteOnly)) { - if (file.write(result.image_data)) cover_url = QUrl::fromLocalFile(filepath); + if (file.write(result.image_data) > 0) cover_url = QUrl::fromLocalFile(filepath); file.close(); } } diff --git a/src/covermanager/albumcovermanager.cpp b/src/covermanager/albumcovermanager.cpp index fc393342d..2a09e2d4e 100644 --- a/src/covermanager/albumcovermanager.cpp +++ b/src/covermanager/albumcovermanager.cpp @@ -572,7 +572,7 @@ void AlbumCoverManager::UpdateStatusText() { .arg(jobs_) .arg(fetch_statistics_.missing_images_); - if (fetch_statistics_.bytes_transferred_) { + if (fetch_statistics_.bytes_transferred_ > 0) { message += ", " + tr("%1 transferred").arg(Utilities::PrettySize(fetch_statistics_.bytes_transferred_)); } diff --git a/src/covermanager/coversearchstatisticsdialog.cpp b/src/covermanager/coversearchstatisticsdialog.cpp index 7b87f192f..f01266b6c 100644 --- a/src/covermanager/coversearchstatisticsdialog.cpp +++ b/src/covermanager/coversearchstatisticsdialog.cpp @@ -81,7 +81,7 @@ void CoverSearchStatisticsDialog::Show(const CoverSearchStatistics &statistics) AddLine(tr("Total network requests made"), QString::number(statistics.network_requests_made_)); AddLine(tr("Average image size"), statistics.AverageDimensions()); - AddLine(tr("Total bytes transferred"), statistics.bytes_transferred_ ? Utilities::PrettySize(statistics.bytes_transferred_) : "0 bytes"); + AddLine(tr("Total bytes transferred"), statistics.bytes_transferred_ > 0 ? Utilities::PrettySize(statistics.bytes_transferred_) : "0 bytes"); details_layout_->addStretch(); diff --git a/src/device/devicemanager.cpp b/src/device/devicemanager.cpp index c6396089e..1ed25c84e 100644 --- a/src/device/devicemanager.cpp +++ b/src/device/devicemanager.cpp @@ -282,13 +282,16 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const { switch (role) { case Qt::DisplayRole: { QString text; - if (!info->friendly_name_.isEmpty()) + if (!info->friendly_name_.isEmpty()) { text = info->friendly_name_; - else if (info->BestBackend()) + } + else if (info->BestBackend()) { text = info->BestBackend()->unique_id_; + } - if (info->size_) + if (info->size_ > 0) { text = text + QString(" (%1)").arg(Utilities::PrettySize(info->size_)); + } if (info->device_.get()) info->device_->Refresh(); return text; } diff --git a/src/device/mtpconnection.cpp b/src/device/mtpconnection.cpp index 600ebfe1f..171f08841 100644 --- a/src/device/mtpconnection.cpp +++ b/src/device/mtpconnection.cpp @@ -117,8 +117,9 @@ bool MtpConnection::GetSupportedFiletypes(QList *ret) { uint16_t *list = nullptr; uint16_t length = 0; - if (LIBMTP_Get_Supported_Filetypes(device_, &list, &length) || !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/mtpdevice.cpp b/src/device/mtpdevice.cpp index 37dfad86f..8e45edb86 100644 --- a/src/device/mtpdevice.cpp +++ b/src/device/mtpdevice.cpp @@ -255,7 +255,7 @@ bool MtpDevice::GetSupportedFiletypes(QList *ret, LIBMTP_mtpdevi uint16_t *list = nullptr; uint16_t length = 0; - if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) || !list || !length) + if (LIBMTP_Get_Supported_Filetypes(device, &list, &length) != 0 || !list || !length) return false; for (int i = 0; i < length; ++i) { diff --git a/src/engine/pulsedevicefinder.cpp b/src/engine/pulsedevicefinder.cpp index fb18977c6..85aab38a1 100644 --- a/src/engine/pulsedevicefinder.cpp +++ b/src/engine/pulsedevicefinder.cpp @@ -131,7 +131,7 @@ void PulseDeviceFinder::GetSinkInfoCallback(pa_context *c, const pa_sink_info *i state->devices.append(dev); } - if (eol) { + if (eol > 0) { state->finished = true; } } diff --git a/src/engine/vlcengine.cpp b/src/engine/vlcengine.cpp index 24737d860..e4e0731cf 100644 --- a/src/engine/vlcengine.cpp +++ b/src/engine/vlcengine.cpp @@ -252,10 +252,7 @@ bool VLCEngine::ALSADeviceSupport(const QString &output) { uint VLCEngine::position() const { - if (!Initialized()) return (0); - - bool is_playing = libvlc_media_player_is_playing(player_); - if (!is_playing) return 0; + if (!Initialized() || !libvlc_media_player_is_playing(player_)) return 0; float pos = libvlc_media_player_get_position(player_); return (pos * length()); @@ -264,10 +261,7 @@ uint VLCEngine::position() const { uint VLCEngine::length() const { - if (!Initialized()) return(0); - - bool is_playing = libvlc_media_player_is_playing(player_); - if (!is_playing) return 0; + if (!Initialized() || !libvlc_media_player_is_playing(player_)) return 0; libvlc_time_t len = libvlc_media_player_get_length(player_); diff --git a/src/internet/internetcollectionview.cpp b/src/internet/internetcollectionview.cpp index a503a0af5..1af441d21 100644 --- a/src/internet/internetcollectionview.cpp +++ b/src/internet/internetcollectionview.cpp @@ -335,11 +335,11 @@ void InternetCollectionView::contextMenuEvent(QContextMenuEvent *e) { int songs_selected = selected_indexes.count();; // In all modes - load_->setEnabled(songs_selected); - add_to_playlist_->setEnabled(songs_selected); - open_in_new_playlist_->setEnabled(songs_selected); - add_to_playlist_enqueue_->setEnabled(songs_selected); - if (remove_songs_) remove_songs_->setEnabled(songs_selected); + load_->setEnabled(songs_selected > 0); + add_to_playlist_->setEnabled(songs_selected > 0); + open_in_new_playlist_->setEnabled(songs_selected > 0); + add_to_playlist_enqueue_->setEnabled(songs_selected > 0); + if (remove_songs_) remove_songs_->setEnabled(songs_selected > 0); context_menu_->popup(e->globalPos()); diff --git a/src/internet/internetsearchmodel.cpp b/src/internet/internetsearchmodel.cpp index 2c96ee328..e9864f1d7 100644 --- a/src/internet/internetsearchmodel.cpp +++ b/src/internet/internetsearchmodel.cpp @@ -323,7 +323,7 @@ void InternetSearchModel::GetChildResults(const QStandardItem *item, InternetSea visited->insert(item); // Does this item have children? - if (item->rowCount()) { + if (item->rowCount() > 0) { 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. diff --git a/src/internet/internetsearchview.cpp b/src/internet/internetsearchview.cpp index aab505b4c..caad0246c 100644 --- a/src/internet/internetsearchview.cpp +++ b/src/internet/internetsearchview.cpp @@ -832,7 +832,7 @@ void InternetSearchView::LazyLoadAlbumCover(const QModelIndex &proxy_index) { // Walk down the item's children until we find a track QStandardItem *item_song = item_album; - while (item_song->rowCount()) { + while (item_song->rowCount() > 0) { item_song = item_song->child(0); } diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp index f9e5f4a50..ddaeba2df 100644 --- a/src/organize/organizedialog.cpp +++ b/src/organize/organizedialog.cpp @@ -496,14 +496,14 @@ void OrganizeDialog::UpdatePreviews() { quint64 capacity = destination.data(MusicStorage::Role_Capacity).toLongLong(); quint64 free = destination.data(MusicStorage::Role_FreeSpace).toLongLong(); - if (!capacity) { - ui_->free_space->hide(); - } - else { + if (capacity > 0) { ui_->free_space->show(); ui_->free_space->set_free_bytes(free); ui_->free_space->set_total_bytes(capacity); } + else { + ui_->free_space->hide(); + } // Update the format object format_.set_format(ui_->naming->toPlainText()); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 8e13e4dfd..bda6c4aa4 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -478,8 +478,9 @@ void PlaylistManager::UpdateSummaryText() { // TODO: Make the plurals translatable summary += tracks == 1 ? tr("1 track") : tr("%1 tracks").arg(tracks); - if (nanoseconds) + if (nanoseconds > 0) { summary += " - [ " + Utilities::WordyTimeNanosec(nanoseconds) + " ]"; + } emit SummaryTextChanged(summary); diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 1238eab48..d073110d9 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -880,7 +880,7 @@ void PlaylistView::mousePressEvent(QMouseEvent *event) { void PlaylistView::scrollContentsBy(int dx, int dy) { - if (dx) { + if (dx > 0) { InvalidateCachedCurrentPixmap(); } cached_tree_ = QPixmap(); diff --git a/src/playlistparsers/cueparser.cpp b/src/playlistparsers/cueparser.cpp index 57e8946e1..23b3d6322 100644 --- a/src/playlistparsers/cueparser.cpp +++ b/src/playlistparsers/cueparser.cpp @@ -138,7 +138,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const } // if this is a data file, all of it's tracks will be ignored - bool valid_file = file_type.compare("BINARY", Qt::CaseInsensitive) && file_type.compare("MOTOROLA", Qt::CaseInsensitive); + bool valid_file = file_type.compare("BINARY", Qt::CaseInsensitive) != 0 && file_type.compare("MOTOROLA", Qt::CaseInsensitive) != 0; QString track_type; QString index; diff --git a/src/queue/queue.cpp b/src/queue/queue.cpp index 7e76ea717..fae79db46 100644 --- a/src/queue/queue.cpp +++ b/src/queue/queue.cpp @@ -254,7 +254,7 @@ void Queue::UpdateSummaryText() { summary += tracks == 1 ? tr("1 track") : tr("%1 tracks").arg(tracks); - if (nanoseconds) { + if (nanoseconds > 0) { summary += " - [ " + Utilities::WordyTimeNanosec(nanoseconds) + " ]"; } diff --git a/src/smartplaylists/playlistgeneratorinserter.cpp b/src/smartplaylists/playlistgeneratorinserter.cpp index 991841af3..098434d35 100644 --- a/src/smartplaylists/playlistgeneratorinserter.cpp +++ b/src/smartplaylists/playlistgeneratorinserter.cpp @@ -49,7 +49,7 @@ PlaylistGeneratorInserter::PlaylistGeneratorInserter(TaskManager *task_manager, PlaylistItemList PlaylistGeneratorInserter::Generate(PlaylistGeneratorPtr generator, int dynamic_count) { - if (dynamic_count) { + if (dynamic_count > 0) { return generator->GenerateMore(dynamic_count); } else { diff --git a/src/smartplaylists/playlistquerygenerator.cpp b/src/smartplaylists/playlistquerygenerator.cpp index 2ffb73325..a75b7e7d5 100644 --- a/src/smartplaylists/playlistquerygenerator.cpp +++ b/src/smartplaylists/playlistquerygenerator.cpp @@ -77,7 +77,7 @@ PlaylistItemList PlaylistQueryGenerator::GenerateMore(const int count) { SmartPlaylistSearch search_copy = search_; search_copy.id_not_in_ = previous_ids_; - if (count) { + if (count > 0) { search_copy.limit_ = count; } diff --git a/src/smartplaylists/smartplaylistsearch.cpp b/src/smartplaylists/smartplaylistsearch.cpp index b635716e5..484d85b85 100644 --- a/src/smartplaylists/smartplaylistsearch.cpp +++ b/src/smartplaylists/smartplaylistsearch.cpp @@ -94,7 +94,7 @@ QString SmartPlaylistSearch::ToSql(const QString &songs_table) const { } // Add limit - if (first_item_) { + if (first_item_ > 0) { sql += QString(" LIMIT %1 OFFSET %2").arg(limit_).arg(first_item_); } else if (limit_ != -1) { diff --git a/src/smartplaylists/smartplaylistsmodel.cpp b/src/smartplaylists/smartplaylistsmodel.cpp index 39734d791..471d62da3 100644 --- a/src/smartplaylists/smartplaylistsmodel.cpp +++ b/src/smartplaylists/smartplaylistsmodel.cpp @@ -130,7 +130,7 @@ void SmartPlaylistsModel::Init() { } // Save the defaults if there are any unwritten ones - if (unwritten_defaults) { + if (unwritten_defaults > 0) { // How many items are stored already? int playlist_index = s.beginReadArray(backend_->songs_table()); s.endArray(); diff --git a/src/widgets/freespacebar.cpp b/src/widgets/freespacebar.cpp index 1ea64973f..41ad1efeb 100644 --- a/src/widgets/freespacebar.cpp +++ b/src/widgets/freespacebar.cpp @@ -146,7 +146,7 @@ void FreeSpaceBar::DrawBar(QPainter *p, const QRect r) { p->setClipPath(clip_path); // Draw any additional space - if (additional_) { + if (additional_ > 0) { QRect additional_rect(bar_rect); additional_rect.setLeft(bar_rect.right()); additional_rect.setWidth(static_cast(float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1)); @@ -190,8 +190,9 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) { // Work out the geometry for the text QList