Use static_cast
This commit is contained in:
@@ -672,7 +672,7 @@ void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const b
|
||||
// Compute the number of new items that have to be inserted
|
||||
// This is not necessarily 1 because the user might have added or removed items manually.
|
||||
// Note that the future excludes the current item.
|
||||
const int count = dynamic_history_length() + 1 + dynamic_playlist_->GetDynamicFuture() - items_.count();
|
||||
const int count = static_cast<int>(dynamic_history_length() + 1 + dynamic_playlist_->GetDynamicFuture() - items_.count());
|
||||
if (count > 0) {
|
||||
InsertDynamicItems(count);
|
||||
}
|
||||
@@ -925,7 +925,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = items_.count() - dest_rows.count();
|
||||
start = static_cast<int>(items_.count() - dest_rows.count());
|
||||
}
|
||||
|
||||
// Take the items out of the list first
|
||||
@@ -1009,7 +1009,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const
|
||||
}
|
||||
}
|
||||
|
||||
const int start = pos == -1 ? items_.count() : pos;
|
||||
const int start = pos == -1 ? static_cast<int>(items_.count()) : pos;
|
||||
|
||||
if (items.count() > kUndoItemLimit) {
|
||||
// Too big to keep in the undo stack. Also clear the stack because it might have been invalidated.
|
||||
@@ -1028,8 +1028,8 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int p
|
||||
|
||||
if (items.isEmpty()) return;
|
||||
|
||||
const int start = pos == -1 ? items_.count() : pos;
|
||||
const int end = start + items.count() - 1;
|
||||
const int start = pos == -1 ? static_cast<int>(items_.count()) : pos;
|
||||
const int end = start + static_cast<int>(items.count()) - 1;
|
||||
|
||||
beginInsertRows(QModelIndex(), start, end);
|
||||
for (int i = start; i <= end; ++i) {
|
||||
|
||||
@@ -245,7 +245,7 @@ QList<Song> PlaylistBackend::GetPlaylistSongs(int playlist) {
|
||||
PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
||||
|
||||
// The song tables get joined first, plus one each for the song ROWIDs
|
||||
const int playlist_row = (Song::kColumns.count() + 1) * kSongTableJoins;
|
||||
const int playlist_row = static_cast<int>(Song::kColumns.count() + 1) * kSongTableJoins;
|
||||
|
||||
PlaylistItemPtr item(PlaylistItem::NewFromSource(Song::Source(row.value(playlist_row).toInt())));
|
||||
if (item) {
|
||||
|
||||
@@ -94,9 +94,9 @@ void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
bool ok = false;
|
||||
const int queue_pos = idx.data(Playlist::Role_QueuePosition).toInt(&ok);
|
||||
if (ok && queue_pos != -1) {
|
||||
float opacity = kQueueOpacitySteps - qMin(kQueueOpacitySteps, queue_pos);
|
||||
float opacity = static_cast<float>(kQueueOpacitySteps - qMin(kQueueOpacitySteps, queue_pos));
|
||||
opacity /= kQueueOpacitySteps;
|
||||
opacity *= 1.0 - kQueueOpacityLowerBound;
|
||||
opacity *= float(1.0) - float(kQueueOpacityLowerBound);
|
||||
opacity += kQueueOpacityLowerBound;
|
||||
painter->setOpacity(opacity);
|
||||
|
||||
@@ -533,7 +533,7 @@ QString RatingItemDelegate::displayText(const QVariant &value, const QLocale&) c
|
||||
if (value.isNull() || value.toDouble() <= 0) return QString();
|
||||
|
||||
// Round to the nearest 0.5
|
||||
const double rating = float(int(value.toDouble() * RatingPainter::kStarCount * 2 + 0.5)) / 2;
|
||||
const double rating = double(int(value.toDouble() * RatingPainter::kStarCount * 2 + 0.5)) / 2;
|
||||
|
||||
return QString::number(rating, 'f', 1);
|
||||
|
||||
|
||||
@@ -171,8 +171,7 @@ class RatingComparatorDecorator : public SearchTermComparator {
|
||||
public:
|
||||
explicit RatingComparatorDecorator(SearchTermComparator *cmp) : cmp_(cmp) {}
|
||||
bool Matches(const QString &element) const override {
|
||||
return cmp_->Matches(
|
||||
QString::number(static_cast<int>(element.toDouble() * 10.0 + 0.5)));
|
||||
return cmp_->Matches(QString::number(static_cast<int>(element.toDouble() * 10.0 + 0.5)));
|
||||
}
|
||||
private:
|
||||
QScopedPointer<SearchTermComparator> cmp_;
|
||||
|
||||
@@ -51,7 +51,7 @@ void InsertItems::redo() {
|
||||
}
|
||||
|
||||
void InsertItems::undo() {
|
||||
const int start = pos_ == -1 ? playlist_->rowCount() - items_.count() : pos_;
|
||||
const int start = pos_ == -1 ? static_cast<int>(playlist_->rowCount() - items_.count()) : pos_;
|
||||
playlist_->RemoveItemsWithoutUndo(start, items_.count());
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void RemoveItems::redo() {
|
||||
}
|
||||
|
||||
void RemoveItems::undo() {
|
||||
for (int i = ranges_.count() - 1; i >= 0; --i)
|
||||
for (int i = static_cast<int>(ranges_.count() - 1); i >= 0; --i)
|
||||
playlist_->InsertItemsWithoutUndo(ranges_[i].items_, ranges_[i].pos_);
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +560,7 @@ void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, con
|
||||
cached_current_row_row_ = idx.row();
|
||||
|
||||
option.rect.moveTo(0, 0);
|
||||
cached_current_row_ = QPixmap(option.rect.width() * device_pixel_ratio_, option.rect.height() * device_pixel_ratio_);
|
||||
cached_current_row_ = QPixmap(static_cast<int>(option.rect.width() * device_pixel_ratio_), static_cast<int>(option.rect.height() * device_pixel_ratio_));
|
||||
cached_current_row_.setDevicePixelRatio(device_pixel_ratio_);
|
||||
cached_current_row_.fill(Qt::transparent);
|
||||
|
||||
@@ -1032,7 +1032,7 @@ void PlaylistView::paintEvent(QPaintEvent *event) {
|
||||
|
||||
if (drop_indicator_row_ != -1) {
|
||||
if (cached_tree_.isNull()) {
|
||||
cached_tree_ = QPixmap(size().width() * device_pixel_ratio_, size().height() * device_pixel_ratio_);
|
||||
cached_tree_ = QPixmap(static_cast<int>(size().width() * device_pixel_ratio_), static_cast<int>(size().height() * device_pixel_ratio_));
|
||||
cached_tree_.setDevicePixelRatio(device_pixel_ratio_);
|
||||
cached_tree_.fill(Qt::transparent);
|
||||
|
||||
@@ -1279,7 +1279,7 @@ bool PlaylistView::eventFilter(QObject *object, QEvent *event) {
|
||||
if (event->type() == QEvent::Enter && (object == horizontalScrollBar() || object == verticalScrollBar())) {
|
||||
return false;
|
||||
}
|
||||
return QObject::eventFilter(object, event);
|
||||
return QAbstractItemView::eventFilter(object, event);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ SongPlaylistItem::SongPlaylistItem(const Song::Source source) : PlaylistItem(sou
|
||||
SongPlaylistItem::SongPlaylistItem(const Song &song) : PlaylistItem(song.source()), song_(song) {}
|
||||
|
||||
bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
|
||||
song_.InitFromQuery(query, false, (Song::kColumns.count()+1));
|
||||
song_.InitFromQuery(query, false, (static_cast<int>(Song::kColumns.count()) + 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user