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 { bool CommandlineOptions::is_empty() const {
return player_action_ == Player_None && set_volume_ == -1 && return player_action_ == Player_None && set_volume_ == -1 &&
volume_modifier_ == 0 && seek_to_ == -1 && seek_by_ == 0 && volume_modifier_ == 0 && seek_to_ == -1 && seek_by_ == 0 &&
play_track_at_ == -1 && show_osd_ == false && play_track_at_ == -1 && !show_osd_ && !toggle_pretty_osd_ &&
toggle_pretty_osd_ == false && urls_.isEmpty() && urls_.isEmpty() && !delete_current_track_;
delete_current_track_ == false;
} }
bool CommandlineOptions::contains_play_options() const { bool CommandlineOptions::contains_play_options() const {

View File

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

View File

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

View File

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

View File

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

View File

@ -50,7 +50,7 @@ void InternetShowSettingsPage::Load() {
item->setIcon(0, service_it.value().item->icon()); item->setIcon(0, service_it.value().item->icon());
Qt::CheckState check_state = 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); item->setData(0, Qt::CheckStateRole, check_state);
/* We have to store the constant name of the service */ /* We have to store the constant name of the service */
item->setData(1, Qt::UserRole, service_it.key()->name()); 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 { bool GPodderTopTagsModel::canFetchMore(const QModelIndex& parent) const {
if (parent.isValid() && parent.data(Role_Type).toInt() == Type_Folder && if (parent.isValid() && parent.data(Role_Type).toInt() == Type_Folder &&
parent.data(Role_HasLazyLoaded).toBool() == false) { !parent.data(Role_HasLazyLoaded).toBool()) {
return true; return true;
} }

View File

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

View File

@ -481,7 +481,7 @@ void SubsonicLibraryScanner::OnGetAlbumListFinished(QNetworkReply* reply,
if (albums_added > 0) { if (albums_added > 0) {
// Non-empty reply means potentially more albums to fetch // Non-empty reply means potentially more albums to fetch
GetAlbumList(offset + kAlbumChunkSize); GetAlbumList(offset + kAlbumChunkSize);
} else if (album_queue_.size() == 0) { } else if (album_queue_.empty()) {
// Empty reply and no albums means an empty Subsonic server // Empty reply and no albums means an empty Subsonic server
scanning_ = false; scanning_ = false;
emit ScanFinished(); 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(); const pb::remote::RequestInsertUrls& request = msg.request_insert_urls();
// Insert plain urls without metadata // Insert plain urls without metadata
if (request.urls().size() > 0) { if (!request.urls().empty()) {
QList<QUrl> urls; QList<QUrl> urls;
for (auto it = request.urls().begin(); it != request.urls().end(); ++it) { for (auto it = request.urls().begin(); it != request.urls().end(); ++it) {
std::string s = *it; std::string s = *it;
@ -281,7 +281,7 @@ void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) {
} }
// Add songs with metadata if present // Add songs with metadata if present
if (request.songs().size() > 0) { if (!request.songs().empty()) {
SongList songs; SongList songs;
for (int i = 0; i < request.songs().size(); i++) { for (int i = 0; i < request.songs().size(); i++) {
songs << CreateSongFromProtobuf(request.songs(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 //accept if any of the children is accepted on it's own merits
if (hasAcceptedChildren(source_row, source_parent)) { return hasAcceptedChildren(source_row, source_parent);
return true;
}
return false;
} }
}; };

View File

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

View File

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

View File

@ -347,10 +347,7 @@ bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent* e) {
const QString suffix = QFileInfo(url.toLocalFile()).suffix().toLower(); const QString suffix = QFileInfo(url.toLocalFile()).suffix().toLower();
if (IsKnownImageExtension(suffix)) return true; if (IsKnownImageExtension(suffix)) return true;
} }
if (e->mimeData()->hasImage()) { return e->mimeData()->hasImage();
return true;
}
return false;
} }
QString AlbumCoverChoiceController::SaveCover(Song* song, const QDropEvent* e) { 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_ = menu_->addAction(tr("Fit cover to width"));
fit_cover_width_action_->setCheckable(true); fit_cover_width_action_->setCheckable(true);
fit_cover_width_action_->setEnabled((mode_ != SmallSongDetails) ? true fit_cover_width_action_->setEnabled(mode_ != SmallSongDetails);
: false);
connect(fit_cover_width_action_, SIGNAL(toggled(bool)), connect(fit_cover_width_action_, SIGNAL(toggled(bool)),
SLOT(FitCoverWidth(bool))); SLOT(FitCoverWidth(bool)));
fit_cover_width_action_->setChecked(fit_width_); fit_cover_width_action_->setChecked(fit_width_);