Simplify some statements

This commit is contained in:
Filip Gawin 2019-02-22 18:44:39 +01:00
parent 248f1d8596
commit be827f4f7f
15 changed files with 20 additions and 39 deletions

View File

@ -310,9 +310,8 @@ bool CommandlineOptions::Parse() {
bool CommandlineOptions::is_empty() const {
return player_action_ == Player_None && set_volume_ == -1 &&
volume_modifier_ == 0 && seek_to_ == -1 && seek_by_ == 0 &&
play_track_at_ == -1 && show_osd_ == false &&
toggle_pretty_osd_ == false && urls_.isEmpty() &&
delete_current_track_ == false;
play_track_at_ == -1 && !show_osd_ && !toggle_pretty_osd_ &&
urls_.isEmpty() && !delete_current_track_;
}
bool CommandlineOptions::contains_play_options() const {

View File

@ -505,10 +505,8 @@ void MergedProxyModel::LayoutChanged() {
}
bool MergedProxyModel::IsKnownModel(const QAbstractItemModel* model) const {
if (model == this || model == sourceModel() ||
merge_points_.contains(const_cast<QAbstractItemModel*>(model)))
return true;
return false;
return model == this || model == sourceModel() ||
merge_points_.contains(const_cast<QAbstractItemModel*>(model));
}
QModelIndexList MergedProxyModel::mapFromSource(

View File

@ -270,9 +270,7 @@ bool RemoveRecursive(const QString& path) {
if (!QFile::remove(path + "/" + child)) return false;
}
if (!dir.rmdir(path)) return false;
return true;
return dir.rmdir(path);
}
bool CopyRecursive(const QString& source, const QString& destination) {

View File

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

View File

@ -351,11 +351,9 @@ void InternetModel::UpdateServices() {
bool setting_val = s.value(service_name).toBool();
// Only update if values are different
if (setting_val == true &&
shown_services_[internet_service].shown == false) {
if (setting_val && !shown_services_[internet_service].shown) {
ShowService(internet_service);
} else if (setting_val == false &&
shown_services_[internet_service].shown == true) {
} else if (!setting_val && shown_services_[internet_service].shown) {
HideService(internet_service);
}
}
@ -378,7 +376,7 @@ int InternetModel::FindItemPosition(const QString& text) {
}
void InternetModel::ShowService(InternetService* service) {
if (shown_services_[service].shown != true) {
if (!shown_services_[service].shown) {
QStandardItem* item = shown_services_[service].item;
int pos = FindItemPosition(item->text());
invisibleRootItem()->insertRow(pos, item);

View File

@ -50,7 +50,7 @@ void InternetShowSettingsPage::Load() {
item->setIcon(0, service_it.value().item->icon());
Qt::CheckState check_state =
service_it.value().shown == true ? Qt::Checked : Qt::Unchecked;
service_it.value().shown ? Qt::Checked : Qt::Unchecked;
item->setData(0, Qt::CheckStateRole, check_state);
/* We have to store the constant name of the service */
item->setData(1, Qt::UserRole, service_it.key()->name());

View File

@ -40,7 +40,7 @@ bool GPodderTopTagsModel::hasChildren(const QModelIndex& parent) const {
bool GPodderTopTagsModel::canFetchMore(const QModelIndex& parent) const {
if (parent.isValid() && parent.data(Role_Type).toInt() == Type_Folder &&
parent.data(Role_HasLazyLoaded).toBool() == false) {
!parent.data(Role_HasLazyLoaded).toBool()) {
return true;
}

View File

@ -38,8 +38,7 @@ PodcastDiscoveryModel::PodcastDiscoveryModel(Application* app, QObject* parent)
QVariant PodcastDiscoveryModel::data(const QModelIndex& index, int role) const {
if (index.isValid() && role == Qt::DecorationRole &&
QStandardItemModel::data(index, Role_StartedLoadingImage).toBool() ==
false) {
!QStandardItemModel::data(index, Role_StartedLoadingImage).toBool()) {
const QUrl image_url =
QStandardItemModel::data(index, Role_ImageUrl).toUrl();
if (image_url.isValid()) {

View File

@ -481,7 +481,7 @@ void SubsonicLibraryScanner::OnGetAlbumListFinished(QNetworkReply* reply,
if (albums_added > 0) {
// Non-empty reply means potentially more albums to fetch
GetAlbumList(offset + kAlbumChunkSize);
} else if (album_queue_.size() == 0) {
} else if (album_queue_.empty()) {
// Empty reply and no albums means an empty Subsonic server
scanning_ = false;
emit ScanFinished();

View File

@ -268,7 +268,7 @@ void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) {
const pb::remote::RequestInsertUrls& request = msg.request_insert_urls();
// Insert plain urls without metadata
if (request.urls().size() > 0) {
if (!request.urls().empty()) {
QList<QUrl> urls;
for (auto it = request.urls().begin(); it != request.urls().end(); ++it) {
std::string s = *it;
@ -281,7 +281,7 @@ void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) {
}
// Add songs with metadata if present
if (request.songs().size() > 0) {
if (!request.songs().empty()) {
SongList songs;
for (int i = 0; i < request.songs().size(); i++) {
songs << CreateSongFromProtobuf(request.songs(i));

View File

@ -128,11 +128,7 @@ class PlaylistListFilterProxyModel : public QSortFilterProxyModel {
}
//accept if any of the children is accepted on it's own merits
if (hasAcceptedChildren(source_row, source_parent)) {
return true;
}
return false;
return hasAcceptedChildren(source_row, source_parent);
}
};

View File

@ -1133,7 +1133,7 @@ void PlaylistView::ReloadSettings() {
// set_background_image when it is not needed, as this will cause the fading
// animation to start again. This also avoid to do useless
// "force_background_redraw".
if (background_initialized_ == false ||
if (!background_initialized_ ||
background_image_filename != background_image_filename_ ||
background_type != background_image_type_ ||
blur_radius_ != blur_radius || opacity_level_ != opacity_level) {

View File

@ -104,10 +104,7 @@ bool Ripper::CheckCDIOIsValid() {
}
bool Ripper::MediaChanged() const {
if (cdio_ && cdio_get_media_changed(cdio_))
return true;
else
return false;
return cdio_ && cdio_get_media_changed(cdio_);
}
void Ripper::Start() {

View File

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

View File

@ -110,8 +110,7 @@ NowPlayingWidget::NowPlayingWidget(QWidget* parent)
fit_cover_width_action_ = menu_->addAction(tr("Fit cover to width"));
fit_cover_width_action_->setCheckable(true);
fit_cover_width_action_->setEnabled((mode_ != SmallSongDetails) ? true
: false);
fit_cover_width_action_->setEnabled(mode_ != SmallSongDetails);
connect(fit_cover_width_action_, SIGNAL(toggled(bool)),
SLOT(FitCoverWidth(bool)));
fit_cover_width_action_->setChecked(fit_width_);