Change bool/int condition

This commit is contained in:
Jonas Kvinge
2021-06-22 13:54:58 +02:00
parent 58a5367015
commit 584f5e5935
34 changed files with 61 additions and 61 deletions

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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<int>(seconds - days * 60 * 60 * 24));
return parts.join(" ");