Clang-Tidy and Clazy fixes
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <random>
|
||||
#include <chrono>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
@@ -43,6 +44,7 @@
|
||||
#include <QFile>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QMimeData>
|
||||
#include <QVariant>
|
||||
@@ -91,6 +93,8 @@
|
||||
#include "internet/internetplaylistitem.h"
|
||||
#include "internet/internetsongmimedata.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const char *Playlist::kCddaMimeType = "x-content/audio-cdda";
|
||||
const char *Playlist::kRowsMimetype = "application/x-strawberry-playlist-rows";
|
||||
const char *Playlist::kPlayNowMimetype = "application/x-strawberry-play-now";
|
||||
@@ -161,7 +165,7 @@ Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, Collecti
|
||||
column_alignments_ = PlaylistView::DefaultColumnAlignment();
|
||||
|
||||
timer_save_->setSingleShot(true);
|
||||
timer_save_->setInterval(900);
|
||||
timer_save_->setInterval(900ms);
|
||||
|
||||
}
|
||||
|
||||
@@ -174,7 +178,7 @@ template <typename T>
|
||||
void Playlist::InsertSongItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemList items;
|
||||
|
||||
items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
items << PlaylistItemPtr(new T(song));
|
||||
}
|
||||
@@ -800,7 +804,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
qint64 own_pid = QCoreApplication::applicationPid();
|
||||
|
||||
QDataStream stream(data->data(kRowsMimetype));
|
||||
stream.readRawData(reinterpret_cast<char*>(&source_playlist), sizeof(source_playlist));
|
||||
stream.readRawData(reinterpret_cast<char*>(&source_playlist), sizeof(source_playlist)); // NOLINT(bugprone-sizeof-expression)
|
||||
stream >> source_rows;
|
||||
if (!stream.atEnd()) {
|
||||
stream.readRawData(reinterpret_cast<char*>(&pid), sizeof(pid));
|
||||
@@ -818,6 +822,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
else if (pid == own_pid) {
|
||||
// Drag from a different playlist
|
||||
PlaylistItemList items;
|
||||
items.reserve(source_rows.count());
|
||||
for (const int i : source_rows) items << source_playlist->item_at(i);
|
||||
|
||||
if (items.count() > kUndoItemLimit) {
|
||||
@@ -896,6 +901,7 @@ void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
PlaylistItemList moved_items;
|
||||
moved_items.reserve(source_rows.count());
|
||||
|
||||
if (pos < 0) {
|
||||
pos = items_.count();
|
||||
@@ -904,12 +910,12 @@ void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
|
||||
// Take the items out of the list first, keeping track of whether the insertion point changes
|
||||
int offset = 0;
|
||||
int start = pos;
|
||||
for (int source_row : source_rows) {
|
||||
for (const int source_row : source_rows) {
|
||||
moved_items << items_.takeAt(source_row - offset);
|
||||
if (pos > source_row) {
|
||||
start--;
|
||||
--start;
|
||||
}
|
||||
offset++;
|
||||
++offset;
|
||||
}
|
||||
|
||||
// Put the items back in
|
||||
@@ -946,11 +952,13 @@ void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
|
||||
void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
PlaylistItemList moved_items;
|
||||
moved_items.reserve(dest_rows.count());
|
||||
|
||||
int pos = start;
|
||||
for (int dest_row : dest_rows) {
|
||||
if (dest_row < pos) start--;
|
||||
for (const int dest_row : dest_rows) {
|
||||
if (dest_row < pos) --start;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
@@ -958,8 +966,9 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
}
|
||||
|
||||
// Take the items out of the list first
|
||||
for (int i = 0; i < dest_rows.count(); i++)
|
||||
for (int i = 0; i < dest_rows.count(); ++i) {
|
||||
moved_items << items_.takeAt(start);
|
||||
}
|
||||
|
||||
// Put the items back in
|
||||
int offset = 0;
|
||||
@@ -974,10 +983,12 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
// This index was moved
|
||||
const int i = pidx.row() - start;
|
||||
changePersistentIndex(pidx, index(dest_rows[i], pidx.column(), QModelIndex()));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int d = 0;
|
||||
if (pidx.row() >= start + dest_rows.count())
|
||||
if (pidx.row() >= start + dest_rows.count()) {
|
||||
d -= dest_rows.count();
|
||||
}
|
||||
|
||||
for (int dest_row : dest_rows) {
|
||||
if (pidx.row() + d > dest_row) d++;
|
||||
@@ -996,15 +1007,16 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
|
||||
|
||||
void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
if (itemsIn.isEmpty())
|
||||
if (itemsIn.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlaylistItemList items = itemsIn;
|
||||
|
||||
// exercise vetoes
|
||||
// Exercise vetoes
|
||||
SongList songs;
|
||||
|
||||
for (PlaylistItemPtr item : items) {
|
||||
songs.reserve(items.count());
|
||||
for (PlaylistItemPtr item : items) { // clazy:exclude=range-loop
|
||||
songs << item->Metadata();
|
||||
}
|
||||
|
||||
@@ -1012,11 +1024,11 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const
|
||||
QSet<Song> vetoed;
|
||||
for (SongInsertVetoListener *listener : veto_listeners_) {
|
||||
for (const Song &song : listener->AboutToInsertSongs(GetAllSongs(), songs)) {
|
||||
// avoid veto-ing a song multiple times
|
||||
// Avoid veto-ing a song multiple times
|
||||
vetoed.insert(song);
|
||||
}
|
||||
if (vetoed.count() == song_count) {
|
||||
// all songs were vetoed and there's nothing more to do (there's no need for an undo step)
|
||||
// All songs were vetoed and there's nothing more to do (there's no need for an undo step)
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1033,7 +1045,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const
|
||||
}
|
||||
}
|
||||
|
||||
// check for empty items once again after veto
|
||||
// Check for empty items once again after veto
|
||||
if (items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -1085,7 +1097,7 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int p
|
||||
if (enqueue) {
|
||||
QModelIndexList indexes;
|
||||
for (int i = start; i <= end; ++i) {
|
||||
indexes << index(i, 0);
|
||||
indexes << index(i, 0); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
queue_->ToggleTracks(indexes);
|
||||
}
|
||||
@@ -1093,7 +1105,7 @@ void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int p
|
||||
if (enqueue_next) {
|
||||
QModelIndexList indexes;
|
||||
for (int i = start; i <= end; ++i) {
|
||||
indexes << index(i, 0);
|
||||
indexes << index(i, 0); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
queue_->InsertFirst(indexes);
|
||||
}
|
||||
@@ -1135,6 +1147,7 @@ void Playlist::InsertSongsOrCollectionItems(const SongList &songs, const int pos
|
||||
void Playlist::InsertInternetItems(InternetService *service, const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemList playlist_items;
|
||||
playlist_items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
playlist_items << std::make_shared<InternetPlaylistItem>(service, song);
|
||||
}
|
||||
@@ -1215,7 +1228,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
|
||||
const Playlist *self = this;
|
||||
const qint64 pid = QCoreApplication::applicationPid();
|
||||
|
||||
stream.writeRawData(reinterpret_cast<char*>(&self), sizeof(self));
|
||||
stream.writeRawData(reinterpret_cast<char*>(&self), sizeof(self)); // NOLINT(bugprone-sizeof-expression)
|
||||
stream << rows;
|
||||
stream.writeRawData(reinterpret_cast<const char*>(&pid), sizeof(pid));
|
||||
buf.close();
|
||||
@@ -1393,7 +1406,7 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemList &new_items) {
|
||||
PlaylistItemList old_items = items_;
|
||||
items_ = new_items;
|
||||
|
||||
QMap<const PlaylistItem*, int> new_rows;
|
||||
QHash<const PlaylistItem*, int> new_rows;
|
||||
for (int i = 0; i < new_items.length(); ++i) {
|
||||
new_rows[new_items[i].get()] = i;
|
||||
}
|
||||
@@ -1621,6 +1634,7 @@ PlaylistItemList Playlist::RemoveItemsWithoutUndo(const int row, const int count
|
||||
|
||||
// Remove items
|
||||
PlaylistItemList ret;
|
||||
ret.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
PlaylistItemPtr item(items_.takeAt(row));
|
||||
ret << item;
|
||||
@@ -1637,22 +1651,26 @@ PlaylistItemList Playlist::RemoveItemsWithoutUndo(const int row, const int count
|
||||
|
||||
QList<int>::iterator it = virtual_items_.begin();
|
||||
while (it != virtual_items_.end()) {
|
||||
if (*it >= items_.count())
|
||||
it = virtual_items_.erase(it);
|
||||
else
|
||||
if (*it >= items_.count()) {
|
||||
it = virtual_items_.erase(it); // clazy:exclude=strict-iterators
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset current_virtual_index_
|
||||
if (current_row() == -1)
|
||||
if (current_row() == -1) {
|
||||
if (row - 1 > 0 && row - 1 < items_.size()) {
|
||||
current_virtual_index_ = virtual_items_.indexOf(row - 1);
|
||||
}
|
||||
else {
|
||||
current_virtual_index_ = -1;
|
||||
}
|
||||
else
|
||||
}
|
||||
else {
|
||||
current_virtual_index_ = virtual_items_.indexOf(current_row());
|
||||
}
|
||||
|
||||
ScheduleSave();
|
||||
|
||||
@@ -1664,15 +1682,19 @@ void Playlist::StopAfter(const int row) {
|
||||
|
||||
QModelIndex old_stop_after = stop_after_;
|
||||
|
||||
if ((stop_after_.isValid() && stop_after_.row() == row) || row == -1)
|
||||
if ((stop_after_.isValid() && stop_after_.row() == row) || row == -1) {
|
||||
stop_after_ = QModelIndex();
|
||||
else
|
||||
}
|
||||
else {
|
||||
stop_after_ = index(row, 0);
|
||||
}
|
||||
|
||||
if (old_stop_after.isValid())
|
||||
if (old_stop_after.isValid()) {
|
||||
emit dataChanged(old_stop_after, old_stop_after.sibling(old_stop_after.row(), ColumnCount - 1));
|
||||
if (stop_after_.isValid())
|
||||
}
|
||||
if (stop_after_.isValid()) {
|
||||
emit dataChanged(stop_after_, stop_after_.sibling(stop_after_.row(), ColumnCount - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1712,8 +1734,10 @@ bool Playlist::stop_after_current() const {
|
||||
PlaylistItemPtr Playlist::current_item() const {
|
||||
|
||||
// QList[] runs in constant time, so no need to cache current_item
|
||||
if (current_item_index_.isValid() && current_item_index_.row() <= items_.length())
|
||||
if (current_item_index_.isValid() && current_item_index_.row() <= items_.length()) {
|
||||
return items_[current_item_index_.row()];
|
||||
}
|
||||
|
||||
return PlaylistItemPtr();
|
||||
|
||||
}
|
||||
@@ -1960,7 +1984,8 @@ QSortFilterProxyModel *Playlist::proxy() const { return proxy_; }
|
||||
SongList Playlist::GetAllSongs() const {
|
||||
|
||||
SongList ret;
|
||||
for (PlaylistItemPtr item : items_) {
|
||||
ret.reserve(items_.count());
|
||||
for (PlaylistItemPtr item : items_) { // clazy:exclude=range-loop
|
||||
ret << item->Metadata();
|
||||
}
|
||||
return ret;
|
||||
@@ -1972,7 +1997,7 @@ PlaylistItemList Playlist::GetAllItems() const { return items_; }
|
||||
quint64 Playlist::GetTotalLength() const {
|
||||
|
||||
quint64 ret = 0;
|
||||
for (PlaylistItemPtr item : items_) {
|
||||
for (PlaylistItemPtr item : items_) { // clazy:exclude=range-loop
|
||||
quint64 length = item->Metadata().length_nanosec();
|
||||
if (length > 0) ret += length;
|
||||
}
|
||||
@@ -2072,11 +2097,11 @@ void Playlist::InvalidateDeletedSongs() {
|
||||
if (!exists && !item->HasForegroundColor(kInvalidSongPriority)) {
|
||||
// gray out the song if it's not there
|
||||
item->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
|
||||
invalidated_rows.append(row);
|
||||
invalidated_rows.append(row); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
else if (exists && item->HasForegroundColor(kInvalidSongPriority)) {
|
||||
item->RemoveForegroundColor(kInvalidSongPriority);
|
||||
invalidated_rows.append(row);
|
||||
invalidated_rows.append(row); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2101,7 +2126,7 @@ void Playlist::RemoveDeletedSongs() {
|
||||
Song song = item->Metadata();
|
||||
|
||||
if (song.url().isLocalFile() && !QFile::exists(song.url().toLocalFile())) {
|
||||
rows_to_remove.append(row);
|
||||
rows_to_remove.append(row); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2141,12 +2166,12 @@ void Playlist::RemoveDuplicateSongs() {
|
||||
const Song &uniq_song = uniq_song_it->first;
|
||||
|
||||
if (song.bitrate() > uniq_song.bitrate()) {
|
||||
rows_to_remove.append(unique_songs[uniq_song]);
|
||||
rows_to_remove.append(unique_songs[uniq_song]); // clazy:exclude=reserve-candidates
|
||||
unique_songs.erase(uniq_song);
|
||||
unique_songs.insert(std::make_pair(song, row));
|
||||
}
|
||||
else {
|
||||
rows_to_remove.append(row);
|
||||
rows_to_remove.append(row); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
found_duplicate = true;
|
||||
}
|
||||
@@ -2169,7 +2194,7 @@ void Playlist::RemoveUnavailableSongs() {
|
||||
|
||||
// Check only local files
|
||||
if (song.url().isLocalFile() && !QFile::exists(song.url().toLocalFile())) {
|
||||
rows_to_remove.append(row);
|
||||
rows_to_remove.append(row); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2294,7 +2319,7 @@ void Playlist::RateSongs(const QModelIndexList &index_list, const double rating)
|
||||
if (has_item_at(row)) {
|
||||
PlaylistItemPtr item = item_at(row);
|
||||
if (item && item->IsLocalCollectionItem() && item->Metadata().id() != -1) {
|
||||
id_list << item->Metadata().id();
|
||||
id_list << item->Metadata().id(); // clazy:exclude=reserve-candidates
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList &items,
|
||||
if (db_->CheckErrors(clear)) return;
|
||||
|
||||
// Save the new ones
|
||||
for (PlaylistItemPtr item : items) {
|
||||
for (PlaylistItemPtr item : items) { // clazy:exclude=range-loop
|
||||
insert.bindValue(":playlist", playlist);
|
||||
item->BindToQuery(&insert);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
|
||||
}
|
||||
|
||||
void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &text, int width, const float opacity) const {
|
||||
void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect line_rect, const QFont &font, const QString &text, int width, const float opacity) const {
|
||||
|
||||
QFont smaller = font;
|
||||
smaller.setPointSize(smaller.pointSize() - 1);
|
||||
@@ -255,7 +255,6 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
|
||||
if (!event || !view) return false;
|
||||
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
QString text = displayText(idx.data(), QLocale::system());
|
||||
|
||||
// Special case: we want newlines in the comment tooltip
|
||||
@@ -267,7 +266,7 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
text.replace("\n", "<br />");
|
||||
}
|
||||
|
||||
if (text.isEmpty() || !he) return false;
|
||||
if (text.isEmpty() || !event) return false;
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip: {
|
||||
@@ -275,7 +274,7 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
QRect displayed_text = view->visualRect(idx);
|
||||
bool is_elided = displayed_text.width() < real_text.width();
|
||||
if (is_elided) {
|
||||
QToolTip::showText(he->globalPos(), text, view);
|
||||
QToolTip::showText(event->globalPos(), text, view);
|
||||
}
|
||||
else { // in case that another text was previously displayed
|
||||
QToolTip::hideText();
|
||||
@@ -287,7 +286,7 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
|
||||
return true;
|
||||
|
||||
case QEvent::WhatsThis:
|
||||
QWhatsThis::showText(he->globalPos(), text, view);
|
||||
QWhatsThis::showText(event->globalPos(), text, view);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -364,7 +363,7 @@ QWidget *TextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
||||
return new QLineEdit(parent);
|
||||
}
|
||||
|
||||
TagCompletionModel::TagCompletionModel(CollectionBackend *backend, Playlist::Column column) {
|
||||
TagCompletionModel::TagCompletionModel(CollectionBackend *backend, const Playlist::Column column, QObject *parent) : QStringListModel(parent) {
|
||||
|
||||
QString col = database_column(column);
|
||||
if (!col.isEmpty()) {
|
||||
@@ -466,7 +465,7 @@ QString SongSourceDelegate::displayText(const QVariant &value, const QLocale&) c
|
||||
return QString();
|
||||
}
|
||||
|
||||
QPixmap SongSourceDelegate::LookupPixmap(const Song::Source &source, const QSize &size) const {
|
||||
QPixmap SongSourceDelegate::LookupPixmap(const Song::Source source, const QSize size) const {
|
||||
|
||||
QPixmap pixmap;
|
||||
QString cache_key = QString("%1-%2x%3").arg(Song::TextForSource(source)).arg(size.width()).arg(size.height());
|
||||
|
||||
@@ -56,11 +56,13 @@ class CollectionBackend;
|
||||
class Player;
|
||||
|
||||
class QueuedItemDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QueuedItemDelegate(QObject *parent, int indicator_column = Playlist::Column_Title);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &idx, int width = -1, const float opacity = 1.0) const;
|
||||
void DrawBox(QPainter *painter, const QRect line_rect, const QFont &font, const QString &idx, int width = -1, const float opacity = 1.0) const;
|
||||
|
||||
int queue_indicator_size(const QModelIndex &idx) const;
|
||||
|
||||
@@ -99,44 +101,58 @@ class PlaylistDelegateBase : public QueuedItemDelegate {
|
||||
};
|
||||
|
||||
class LengthItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LengthItemDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
};
|
||||
|
||||
class SizeItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SizeItemDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
};
|
||||
|
||||
class DateItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DateItemDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
};
|
||||
|
||||
class LastPlayedItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LastPlayedItemDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
};
|
||||
|
||||
class FileTypeItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileTypeItemDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
};
|
||||
|
||||
class TextItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TextItemDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
};
|
||||
|
||||
class TagCompletionModel : public QStringListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagCompletionModel(CollectionBackend *backend, Playlist::Column column);
|
||||
explicit TagCompletionModel(CollectionBackend *backend, const Playlist::Column column, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
static QString database_column(Playlist::Column column);
|
||||
@@ -157,6 +173,8 @@ class TagCompleter : public QCompleter {
|
||||
};
|
||||
|
||||
class TagCompletionItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagCompletionItemDelegate(QObject *parent, CollectionBackend *backend, Playlist::Column column) : PlaylistDelegateBase(parent), backend_(backend), column_(column) {};
|
||||
|
||||
@@ -168,31 +186,37 @@ class TagCompletionItemDelegate : public PlaylistDelegateBase {
|
||||
};
|
||||
|
||||
class NativeSeparatorsDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NativeSeparatorsDelegate(QObject *parent) : PlaylistDelegateBase(parent) {}
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
};
|
||||
|
||||
class SongSourceDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SongSourceDelegate(QObject *parent);
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
|
||||
private:
|
||||
QPixmap LookupPixmap(const Song::Source &source, const QSize &size) const;
|
||||
QPixmap LookupPixmap(const Song::Source source, const QSize size) const;
|
||||
|
||||
mutable QPixmapCache pixmap_cache_;
|
||||
};
|
||||
|
||||
class RatingItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RatingItemDelegate(QObject *parent);
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
QString displayText(const QVariant &value, const QLocale &locale) const override;
|
||||
|
||||
void set_mouse_over(const QModelIndex &idx, const QModelIndexList &selected_indexes, const QPoint &pos) {
|
||||
void set_mouse_over(const QModelIndex &idx, const QModelIndexList &selected_indexes, const QPoint pos) {
|
||||
mouse_over_index_ = idx;
|
||||
selected_indexes_ = selected_indexes;
|
||||
mouse_over_pos_ = pos;
|
||||
|
||||
@@ -35,8 +35,11 @@
|
||||
|
||||
class SearchTermComparator {
|
||||
public:
|
||||
SearchTermComparator() = default;
|
||||
virtual ~SearchTermComparator() {}
|
||||
virtual bool Matches(const QString &element) const = 0;
|
||||
private:
|
||||
Q_DISABLE_COPY(SearchTermComparator)
|
||||
};
|
||||
|
||||
// "compares" by checking if the field contains the search term
|
||||
@@ -48,6 +51,8 @@ class DefaultComparator : public SearchTermComparator {
|
||||
}
|
||||
private:
|
||||
QString search_term_;
|
||||
|
||||
Q_DISABLE_COPY(DefaultComparator)
|
||||
};
|
||||
|
||||
class EqComparator : public SearchTermComparator {
|
||||
@@ -112,7 +117,7 @@ class LexicalLeComparator : public SearchTermComparator {
|
||||
|
||||
class GtComparator : public SearchTermComparator {
|
||||
public:
|
||||
explicit GtComparator(int value) : search_term_(value) {}
|
||||
explicit GtComparator(const int value) : search_term_(value) {}
|
||||
bool Matches(const QString &element) const override {
|
||||
return element.toInt() > search_term_;
|
||||
}
|
||||
@@ -122,7 +127,7 @@ class GtComparator : public SearchTermComparator {
|
||||
|
||||
class GeComparator : public SearchTermComparator {
|
||||
public:
|
||||
explicit GeComparator(int value) : search_term_(value) {}
|
||||
explicit GeComparator(const int value) : search_term_(value) {}
|
||||
bool Matches(const QString &element) const override {
|
||||
return element.toInt() >= search_term_;
|
||||
}
|
||||
@@ -132,7 +137,7 @@ class GeComparator : public SearchTermComparator {
|
||||
|
||||
class LtComparator : public SearchTermComparator {
|
||||
public:
|
||||
explicit LtComparator(int value) : search_term_(value) {}
|
||||
explicit LtComparator(const int value) : search_term_(value) {}
|
||||
bool Matches(const QString &element) const override {
|
||||
return element.toInt() < search_term_;
|
||||
}
|
||||
@@ -142,7 +147,7 @@ class LtComparator : public SearchTermComparator {
|
||||
|
||||
class LeComparator : public SearchTermComparator {
|
||||
public:
|
||||
explicit LeComparator(int value) : search_term_(value) {}
|
||||
explicit LeComparator(const int value) : search_term_(value) {}
|
||||
bool Matches(const QString &element) const override {
|
||||
return element.toInt() <= search_term_;
|
||||
}
|
||||
@@ -198,7 +203,7 @@ class FilterTerm : public FilterTree {
|
||||
// filter that applies a SearchTermComparator to one specific field of a playlist entry
|
||||
class FilterColumnTerm : public FilterTree {
|
||||
public:
|
||||
FilterColumnTerm(int column, SearchTermComparator *comparator) : col(column), cmp_(comparator) {}
|
||||
FilterColumnTerm(const int column, SearchTermComparator *comparator) : col(column), cmp_(comparator) {}
|
||||
|
||||
bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const override {
|
||||
QModelIndex idx(model->index(row, col, parent));
|
||||
@@ -261,12 +266,15 @@ FilterTree *FilterParser::parse() {
|
||||
}
|
||||
|
||||
void FilterParser::advance() {
|
||||
|
||||
while (iter_ != end_ && iter_->isSpace()) {
|
||||
++iter_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FilterTree *FilterParser::parseOrGroup() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
|
||||
@@ -278,9 +286,11 @@ FilterTree *FilterParser::parseOrGroup() {
|
||||
advance();
|
||||
}
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
FilterTree *FilterParser::parseAndGroup() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
|
||||
@@ -296,9 +306,11 @@ FilterTree *FilterParser::parseAndGroup() {
|
||||
}
|
||||
while (iter_ != end_);
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
bool FilterParser::checkAnd() {
|
||||
|
||||
if (iter_ != end_) {
|
||||
if (*iter_ == QChar('A')) {
|
||||
buf_ += *iter_;
|
||||
@@ -319,9 +331,11 @@ bool FilterParser::checkAnd() {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool FilterParser::checkOr(bool step_over) {
|
||||
bool FilterParser::checkOr(const bool step_over) {
|
||||
|
||||
if (!buf_.isEmpty()) {
|
||||
if (buf_ == "OR") {
|
||||
if (step_over) {
|
||||
@@ -351,9 +365,11 @@ bool FilterParser::checkOr(bool step_over) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
FilterTree *FilterParser::parseSearchExpression() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
if (*iter_ == '(') {
|
||||
@@ -377,9 +393,11 @@ FilterTree *FilterParser::parseSearchExpression() {
|
||||
else {
|
||||
return parseSearchTerm();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FilterTree *FilterParser::parseSearchTerm() {
|
||||
|
||||
QString col;
|
||||
QString search;
|
||||
QString prefix;
|
||||
@@ -425,6 +443,7 @@ FilterTree *FilterParser::parseSearchTerm() {
|
||||
buf_.clear();
|
||||
|
||||
return createSearchTermTreeNode(col, prefix, search);
|
||||
|
||||
}
|
||||
|
||||
FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QString &prefix, const QString &search) const {
|
||||
|
||||
@@ -30,9 +30,10 @@
|
||||
class QAbstractItemModel;
|
||||
class QModelIndex;
|
||||
|
||||
// structure for filter parse tree
|
||||
// Structure for filter parse tree
|
||||
class FilterTree {
|
||||
public:
|
||||
FilterTree() = default;
|
||||
virtual ~FilterTree() {}
|
||||
virtual bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const = 0;
|
||||
enum FilterType {
|
||||
@@ -44,9 +45,11 @@ class FilterTree {
|
||||
Term
|
||||
};
|
||||
virtual FilterType type() = 0;
|
||||
private:
|
||||
Q_DISABLE_COPY(FilterTree)
|
||||
};
|
||||
|
||||
// trivial filter that accepts *anything*
|
||||
// Trivial filter that accepts *anything*
|
||||
class NopFilter : public FilterTree {
|
||||
public:
|
||||
bool accept(int row, const QModelIndex &parent, const QAbstractItemModel *const model) const override { Q_UNUSED(row); Q_UNUSED(parent); Q_UNUSED(model); return true; }
|
||||
@@ -77,9 +80,9 @@ class FilterParser {
|
||||
void advance();
|
||||
FilterTree *parseOrGroup();
|
||||
FilterTree *parseAndGroup();
|
||||
// check if iter is at the start of 'AND' if so, step over it and return true if not, return false and leave iter where it was
|
||||
// Check if iter is at the start of 'AND' if so, step over it and return true if not, return false and leave iter where it was
|
||||
bool checkAnd();
|
||||
// check if iter is at the start of 'OR'
|
||||
// Check if iter is at the start of 'OR'
|
||||
bool checkOr(bool step_over = true);
|
||||
FilterTree *parseSearchExpression();
|
||||
FilterTree *parseSearchTerm();
|
||||
|
||||
@@ -143,13 +143,13 @@ bool PlaylistItem::HasCurrentBackgroundColor() const {
|
||||
return !background_colors_.isEmpty();
|
||||
}
|
||||
|
||||
void PlaylistItem::SetForegroundColor(short priority, const QColor &color) {
|
||||
void PlaylistItem::SetForegroundColor(const short priority, const QColor &color) {
|
||||
foreground_colors_[priority] = color;
|
||||
}
|
||||
bool PlaylistItem::HasForegroundColor(short priority) const {
|
||||
bool PlaylistItem::HasForegroundColor(const short priority) const {
|
||||
return foreground_colors_.contains(priority);
|
||||
}
|
||||
void PlaylistItem::RemoveForegroundColor(short priority) {
|
||||
void PlaylistItem::RemoveForegroundColor(const short priority) {
|
||||
foreground_colors_.remove(priority);
|
||||
}
|
||||
QColor PlaylistItem::GetCurrentForegroundColor() const {
|
||||
@@ -164,5 +164,5 @@ QColor PlaylistItem::GetCurrentForegroundColor() const {
|
||||
bool PlaylistItem::HasCurrentForegroundColor() const {
|
||||
return !foreground_colors_.isEmpty();
|
||||
}
|
||||
void PlaylistItem::SetShouldSkip(bool val) { should_skip_ = val; }
|
||||
void PlaylistItem::SetShouldSkip(const bool val) { should_skip_ = val; }
|
||||
bool PlaylistItem::GetShouldSkip() const { return should_skip_; }
|
||||
|
||||
@@ -45,7 +45,7 @@ class SqlRow;
|
||||
|
||||
class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
public:
|
||||
explicit PlaylistItem(const Song::Source &source) : should_skip_(false), source_(source) {}
|
||||
explicit PlaylistItem(const Song::Source source) : should_skip_(false), source_(source) {}
|
||||
virtual ~PlaylistItem();
|
||||
|
||||
static PlaylistItem *NewFromSource(const Song::Source source);
|
||||
@@ -93,23 +93,23 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
virtual void SetArtManual(const QUrl &cover_url) = 0;
|
||||
|
||||
// Background colors.
|
||||
void SetBackgroundColor(short priority, const QColor &color);
|
||||
bool HasBackgroundColor(short priority) const;
|
||||
void RemoveBackgroundColor(short priority);
|
||||
void SetBackgroundColor(const short priority, const QColor &color);
|
||||
bool HasBackgroundColor(const short priority) const;
|
||||
void RemoveBackgroundColor(const short priority);
|
||||
QColor GetCurrentBackgroundColor() const;
|
||||
bool HasCurrentBackgroundColor() const;
|
||||
|
||||
// Foreground colors.
|
||||
void SetForegroundColor(short priority, const QColor &color);
|
||||
bool HasForegroundColor(short priority) const;
|
||||
void RemoveForegroundColor(short priority);
|
||||
void SetForegroundColor(const short priority, const QColor &color);
|
||||
bool HasForegroundColor(const short priority) const;
|
||||
void RemoveForegroundColor(const short priority);
|
||||
QColor GetCurrentForegroundColor() const;
|
||||
bool HasCurrentForegroundColor() const;
|
||||
|
||||
// Convenience function to find out whether this item is from the local collection, as opposed to a device, a file on disk, or a stream.
|
||||
// Remember that even if this returns true, the collection item might be invalid so you might want to check that its id is not equal to -1 before actually using it.
|
||||
virtual bool IsLocalCollectionItem() const { return false; }
|
||||
void SetShouldSkip(bool val);
|
||||
void SetShouldSkip(const bool val);
|
||||
bool GetShouldSkip() const;
|
||||
|
||||
protected:
|
||||
@@ -128,6 +128,8 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
|
||||
QMap<short, QColor> background_colors_;
|
||||
QMap<short, QColor> foreground_colors_;
|
||||
|
||||
Q_DISABLE_COPY(PlaylistItem)
|
||||
};
|
||||
typedef std::shared_ptr<PlaylistItem> PlaylistItemPtr;
|
||||
typedef QList<PlaylistItemPtr> PlaylistItemList;
|
||||
|
||||
@@ -32,8 +32,8 @@ class PlaylistItemMimeData : public MimeData {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistItemMimeData(const PlaylistItemPtr &item) : items_(PlaylistItemList() << item) {}
|
||||
explicit PlaylistItemMimeData(const PlaylistItemList &items) : items_(items) {}
|
||||
explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject* = nullptr) : MimeData(), items_(PlaylistItemList() << item) {}
|
||||
explicit PlaylistItemMimeData(const PlaylistItemList &items, QObject* = nullptr) : MimeData(), items_(items) {}
|
||||
|
||||
PlaylistItemList items_;
|
||||
};
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <QStandardItemModel>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemSelectionModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
@@ -52,6 +51,7 @@
|
||||
#include "playlistlistview.h"
|
||||
#include "playlistlistcontainer.h"
|
||||
#include "playlistlistmodel.h"
|
||||
#include "playlistlistsortfiltermodel.h"
|
||||
#include "playlistmanager.h"
|
||||
#include "ui_playlistlistcontainer.h"
|
||||
#include "organize/organizedialog.h"
|
||||
@@ -61,23 +61,6 @@
|
||||
# include "device/devicestatefiltermodel.h"
|
||||
#endif
|
||||
|
||||
class PlaylistListSortFilterModel : public QSortFilterProxyModel {
|
||||
public:
|
||||
explicit PlaylistListSortFilterModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent) {}
|
||||
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override {
|
||||
// Compare the display text first.
|
||||
const int ret = left.data().toString().localeAwareCompare(right.data().toString());
|
||||
if (ret < 0) return true;
|
||||
if (ret > 0) return false;
|
||||
|
||||
// Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same.
|
||||
return left.row() < right.row();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
PlaylistListContainer::PlaylistListContainer(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
app_(nullptr),
|
||||
@@ -350,7 +333,7 @@ void PlaylistListContainer::ItemsSelectedChanged(const bool selected) {
|
||||
ui_->save_playlist->setEnabled(selected);
|
||||
}
|
||||
|
||||
void PlaylistListContainer::ItemDoubleClicked(const QModelIndex proxy_idx) {
|
||||
void PlaylistListContainer::ItemDoubleClicked(const QModelIndex &proxy_idx) {
|
||||
|
||||
const QModelIndex idx = proxy_->mapToSource(proxy_idx);
|
||||
if (!idx.isValid()) return;
|
||||
@@ -411,7 +394,7 @@ void PlaylistListContainer::Delete() {
|
||||
// Is it a playlist?
|
||||
switch (idx.data(PlaylistListModel::Role_Type).toInt()) {
|
||||
case PlaylistListModel::Type_Playlist:
|
||||
ids << idx.data(PlaylistListModel::Role_PlaylistId).toInt();
|
||||
ids << idx.data(PlaylistListModel::Role_PlaylistId).toInt(); // clazy:exclude=reserve-candidates
|
||||
break;
|
||||
|
||||
case PlaylistListModel::Type_Folder:
|
||||
|
||||
@@ -62,7 +62,7 @@ class PlaylistListContainer : public QWidget {
|
||||
private slots:
|
||||
// From the UI
|
||||
void NewFolderClicked();
|
||||
void ItemDoubleClicked(const QModelIndex proxy_idx);
|
||||
void ItemDoubleClicked(const QModelIndex &proxy_idx);
|
||||
|
||||
// From the model
|
||||
void PlaylistPathChanged(const int id, const QString &new_path);
|
||||
|
||||
@@ -132,7 +132,7 @@ void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, const in
|
||||
const int id = idx.data(Role_PlaylistId).toInt();
|
||||
QMap<int, QStandardItem*>::iterator it = playlists_by_id_.find(id);
|
||||
if (it != playlists_by_id_.end() && it.value() == item) {
|
||||
playlists_by_id_.erase(it);
|
||||
playlists_by_id_.erase(it); // clazy:exclude=strict-iterators
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
40
src/playlist/playlistlistsortfiltermodel.h
Normal file
40
src/playlist/playlistlistsortfiltermodel.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class PlaylistListSortFilterModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistListSortFilterModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent) {}
|
||||
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override {
|
||||
// Compare the display text first.
|
||||
const int ret = left.data().toString().localeAwareCompare(right.data().toString());
|
||||
if (ret < 0) return true;
|
||||
if (ret > 0) return false;
|
||||
|
||||
// Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same.
|
||||
return left.row() < right.row();
|
||||
}
|
||||
};
|
||||
@@ -132,6 +132,7 @@ QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
|
||||
QList<Playlist*> result;
|
||||
|
||||
QList<Data> datas = playlists_.values();
|
||||
result.reserve(datas.count());
|
||||
for (const Data &data : datas) {
|
||||
result.append(data.p);
|
||||
}
|
||||
@@ -568,7 +569,8 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList &songs) {
|
||||
|
||||
QSet<QString> artists;
|
||||
QSet<QString> albums;
|
||||
|
||||
artists.reserve(songs.count());
|
||||
albums.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
artists << (song.artist().isEmpty() ? tr("Unknown") : song.artist());
|
||||
albums << (song.album().isEmpty() ? tr("Unknown") : song.album());
|
||||
|
||||
@@ -346,6 +346,7 @@ void PlaylistTabBar::InsertTab(const int id, const int index, const QString &tex
|
||||
void PlaylistTabBar::TabMoved() {
|
||||
|
||||
QList<int> ids;
|
||||
ids.reserve(count());
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
ids << tabData(i).toInt();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds
|
||||
const int PlaylistView::kDropIndicatorWidth = 2;
|
||||
const int PlaylistView::kDropIndicatorGradientWidth = 5;
|
||||
|
||||
PlaylistProxyStyle::PlaylistProxyStyle() : QProxyStyle(nullptr), common_style_(new QCommonStyle) {}
|
||||
PlaylistProxyStyle::PlaylistProxyStyle(QObject*) : QProxyStyle(nullptr), common_style_(new QCommonStyle) {}
|
||||
|
||||
void PlaylistProxyStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
|
||||
|
||||
@@ -465,6 +465,7 @@ QList<QPixmap> PlaylistView::LoadBarPixmap(const QString &filename) {
|
||||
|
||||
// Animation steps
|
||||
QList<QPixmap> ret;
|
||||
ret.reserve(kGlowIntensitySteps);
|
||||
for (int i = 0; i < kGlowIntensitySteps; ++i) {
|
||||
QImage step(image.copy());
|
||||
p.begin(&step);
|
||||
@@ -560,7 +561,7 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option
|
||||
|
||||
}
|
||||
|
||||
void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &idx) {
|
||||
void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &idx) { // clazy:exclude=function-args-by-ref
|
||||
|
||||
cached_current_row_rect_ = option.rect;
|
||||
cached_current_row_row_ = idx.row();
|
||||
@@ -1289,7 +1290,7 @@ void PlaylistView::resizeEvent(QResizeEvent *e) {
|
||||
bool PlaylistView::eventFilter(QObject *object, QEvent *event) {
|
||||
|
||||
if (event->type() == QEvent::Enter && (object == horizontalScrollBar() || object == verticalScrollBar())) {
|
||||
return false;
|
||||
return false; // clazy:exclude=base-class-event
|
||||
}
|
||||
return QAbstractItemView::eventFilter(object, event);
|
||||
|
||||
@@ -1397,7 +1398,7 @@ void PlaylistView::Stopped() {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistView::AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResult result) {
|
||||
void PlaylistView::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result) {
|
||||
|
||||
if ((song != Song() && song_playing_ == Song()) || result.album_cover.image == current_song_cover_art_) return;
|
||||
|
||||
@@ -1510,7 +1511,7 @@ void PlaylistView::SetRatingLockStatus(const bool state) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistView::RatingHoverIn(const QModelIndex &idx, const QPoint &pos) {
|
||||
void PlaylistView::RatingHoverIn(const QModelIndex &idx, const QPoint pos) {
|
||||
|
||||
if (editTriggers() & QAbstractItemView::NoEditTriggers) {
|
||||
return;
|
||||
|
||||
@@ -82,8 +82,10 @@ class RatingItemDelegate;
|
||||
// This proxy style uses QCommonStyle to paint the affected elements.
|
||||
// This class is used by internet search view as well.
|
||||
class PlaylistProxyStyle : public QProxyStyle {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistProxyStyle();
|
||||
explicit PlaylistProxyStyle(QObject *parent = nullptr);
|
||||
|
||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;
|
||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;
|
||||
@@ -122,7 +124,7 @@ class PlaylistView : public QTreeView {
|
||||
void SaveSettings();
|
||||
void SetColumnAlignment(const int section, const Qt::Alignment alignment);
|
||||
void JumpToCurrentlyPlayingTrack();
|
||||
void edit(const QModelIndex &idx) { return QAbstractItemView::edit(idx); }
|
||||
void edit(const QModelIndex &idx) { QAbstractItemView::edit(idx); }
|
||||
|
||||
signals:
|
||||
void PlayItem(QModelIndex idx, Playlist::AutoScroll autoscroll);
|
||||
@@ -181,10 +183,10 @@ class PlaylistView : public QTreeView {
|
||||
void Playing();
|
||||
void Stopped();
|
||||
void SongChanged(const Song &song);
|
||||
void AlbumCoverLoaded(const Song &song, AlbumCoverLoaderResult result = AlbumCoverLoaderResult());
|
||||
void AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &result = AlbumCoverLoaderResult());
|
||||
void DynamicModeChanged(const bool dynamic);
|
||||
void SetRatingLockStatus(const bool state);
|
||||
void RatingHoverIn(const QModelIndex &idx, const QPoint &pos);
|
||||
void RatingHoverIn(const QModelIndex &idx, const QPoint pos);
|
||||
void RatingHoverOut();
|
||||
|
||||
private:
|
||||
@@ -197,7 +199,7 @@ class PlaylistView : public QTreeView {
|
||||
|
||||
void set_background_image_type(AppearanceSettingsPage::BackgroundImageType bg) {
|
||||
background_image_type_ = bg;
|
||||
emit BackgroundPropertyChanged();
|
||||
emit BackgroundPropertyChanged(); // clazy:exclude=incorrect-emit
|
||||
}
|
||||
// Save image as the background_image_ after applying some modifications (opacity, ...).
|
||||
// Should be used instead of modifying background_image_ directly
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
#include "playlist.h"
|
||||
#include "songloaderinserter.h"
|
||||
|
||||
SongLoaderInserter::SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player)
|
||||
: task_manager_(task_manager),
|
||||
SongLoaderInserter::SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player, QObject *parent)
|
||||
: QObject(parent),
|
||||
task_manager_(task_manager),
|
||||
destination_(nullptr),
|
||||
row_(-1),
|
||||
play_now_(true),
|
||||
|
||||
@@ -41,7 +41,7 @@ class SongLoaderInserter : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player);
|
||||
explicit SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player, QObject *parent = nullptr);
|
||||
~SongLoaderInserter() override;
|
||||
|
||||
void Load(Playlist *destination, int row, bool play_now, bool enqueue, bool enqueue_next, const QList<QUrl> &urls);
|
||||
|
||||
@@ -35,7 +35,7 @@ class SongMimeData : public MimeData {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SongMimeData() : backend(nullptr) {}
|
||||
explicit SongMimeData(QObject* = nullptr) : MimeData(), backend(nullptr) {}
|
||||
|
||||
CollectionBackendInterface *backend;
|
||||
SongList songs;
|
||||
|
||||
@@ -52,6 +52,8 @@ class SongPlaylistItem : public PlaylistItem {
|
||||
|
||||
private:
|
||||
Song song_;
|
||||
|
||||
Q_DISABLE_COPY(SongPlaylistItem)
|
||||
};
|
||||
|
||||
#endif // SONGPLAYLISTITEM_H
|
||||
|
||||
Reference in New Issue
Block a user