Change bool/int condition
This commit is contained in:
parent
58a5367015
commit
584f5e5935
@ -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.";
|
||||
|
@ -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.";
|
||||
|
@ -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_);
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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(" ");
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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_));
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -117,8 +117,9 @@ bool MtpConnection::GetSupportedFiletypes(QList<Song::FileType> *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])) {
|
||||
|
@ -255,7 +255,7 @@ bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType> *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) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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_);
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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) + " ]";
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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<int>(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<Label> labels;
|
||||
labels << Label(TextForSize(used_text_, total_ - free_), kColorBar1);
|
||||
if (additional_)
|
||||
if (additional_ > 0) {
|
||||
labels << Label(TextForSize(additional_text_, additional_), kColorAdd1);
|
||||
}
|
||||
labels << Label(TextForSize(free_text_, free_ - additional_), kColorBg2);
|
||||
|
||||
int text_width = 0;
|
||||
|
@ -81,7 +81,7 @@ void MultiLoadingIndicator::UpdateText() {
|
||||
QString task_text(task.name);
|
||||
task_text[0] = task_text[0].toLower();
|
||||
|
||||
if (task.progress_max) {
|
||||
if (task.progress_max > 0) {
|
||||
int percentage = static_cast<int>(float(task.progress) / task.progress_max * 100);
|
||||
task_text += QString(" %1%").arg(percentage);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user