Replace use of C-style casts

This commit is contained in:
Jonas Kvinge
2022-06-13 00:23:42 +02:00
parent abdcadb5fa
commit d82fd421ed
39 changed files with 95 additions and 93 deletions

View File

@@ -136,7 +136,7 @@ PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists(const GetPlaylistsFl
p.special_type = q.value(3).toString();
p.ui_path = q.value(4).toString();
p.favorite = q.value(5).toBool();
p.dynamic_type = PlaylistGenerator::Type(q.value(6).toInt());
p.dynamic_type = static_cast<PlaylistGenerator::Type>(q.value(6).toInt());
p.dynamic_data = q.value(7).toByteArray();
p.dynamic_backend = q.value(8).toString();
ret << p;
@@ -169,7 +169,7 @@ PlaylistBackend::Playlist PlaylistBackend::GetPlaylist(const int id) {
p.special_type = q.value(3).toString();
p.ui_path = q.value(4).toString();
p.favorite = q.value(5).toBool();
p.dynamic_type = PlaylistGenerator::Type(q.value(6).toInt());
p.dynamic_type = static_cast<PlaylistGenerator::Type>(q.value(6).toInt());
p.dynamic_data = q.value(7).toByteArray();
p.dynamic_backend = q.value(8).toString();
@@ -253,7 +253,7 @@ PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std
// The song tables get joined first, plus one each for the song ROWIDs
const int playlist_row = static_cast<int>(Song::kColumns.count() + 1) * kSongTableJoins;
PlaylistItemPtr item(PlaylistItem::NewFromSource(Song::Source(row.value(playlist_row).toInt())));
PlaylistItemPtr item(PlaylistItem::NewFromSource(static_cast<Song::Source>(row.value(playlist_row).toInt())));
if (item) {
item->InitFromQuery(row);
return RestoreCueData(item, state);

View File

@@ -360,7 +360,7 @@ QString FileTypeItemDelegate::displayText(const QVariant &value, const QLocale &
Q_UNUSED(locale);
bool ok = false;
Song::FileType type = Song::FileType(value.toInt(&ok));
Song::FileType type = static_cast<Song::FileType>(value.toInt(&ok));
if (!ok) return tr("Unknown");
@@ -500,7 +500,7 @@ void SongSourceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
QStyleOptionViewItem option_copy(option);
initStyleOption(&option_copy, idx);
const Song::Source source = Song::Source(idx.data().toInt());
const Song::Source source = static_cast<Song::Source>(idx.data().toInt());
QPixmap pixmap = LookupPixmap(source, option_copy.decorationSize);
QWidget *parent_widget = qobject_cast<QWidget*>(parent());

View File

@@ -1056,7 +1056,7 @@ void PlaylistView::paintEvent(QPaintEvent *event) {
// Actually draw the background image
if (!cached_scaled_background_image_.isNull()) {
// Set opactiy only if needed, as this deactivate hardware acceleration
if (!qFuzzyCompare(previous_background_image_opacity_, qreal(0.0))) {
if (!qFuzzyCompare(previous_background_image_opacity_, static_cast<qreal>(0.0))) {
background_painter.setOpacity(1.0 - previous_background_image_opacity_);
}
switch (background_image_position_) {
@@ -1524,7 +1524,7 @@ void PlaylistView::set_background_image(const QImage &image) {
void PlaylistView::FadePreviousBackgroundImage(const qreal value) {
previous_background_image_opacity_ = value;
if (qFuzzyCompare(previous_background_image_opacity_, qreal(0.0))) {
if (qFuzzyCompare(previous_background_image_opacity_, static_cast<qreal>(0.0))) {
previous_background_image_ = QPixmap();
previous_background_image_opacity_ = 0.0;
}