Fix compile warnings

This commit is contained in:
Jonas Kvinge
2020-04-23 21:08:28 +02:00
parent a303850341
commit 8da4c88fd3
54 changed files with 509 additions and 461 deletions

View File

@@ -273,6 +273,8 @@ static T CreateLogger(Level level, const QString &class_name, int line, const ch
return ret.space(); return ret.space();
} }
QString CXXDemangle(const QString &mangled_function);
QString CXXDemangle(const QString &mangled_function) { QString CXXDemangle(const QString &mangled_function) {
int status; int status;
@@ -286,6 +288,8 @@ QString CXXDemangle(const QString &mangled_function) {
} }
QString DarwinDemangle(const QString &symbol);
QString DarwinDemangle(const QString &symbol) { QString DarwinDemangle(const QString &symbol) {
QStringList split = symbol.split(' ', QString::SkipEmptyParts); QStringList split = symbol.split(' ', QString::SkipEmptyParts);
@@ -294,6 +298,8 @@ QString DarwinDemangle(const QString &symbol) {
} }
QString LinuxDemangle(const QString &symbol);
QString LinuxDemangle(const QString &symbol) { QString LinuxDemangle(const QString &symbol) {
QRegExp regex("\\(([^+]+)"); QRegExp regex("\\(([^+]+)");
@@ -305,6 +311,8 @@ QString LinuxDemangle(const QString &symbol) {
} }
QString DemangleSymbol(const QString &symbol);
QString DemangleSymbol(const QString &symbol) { QString DemangleSymbol(const QString &symbol) {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
return DarwinDemangle(symbol); return DarwinDemangle(symbol);

View File

@@ -47,13 +47,13 @@ void _MessageHandlerBase::SetDevice(QIODevice *device) {
connect(device, SIGNAL(readyRead()), SLOT(DeviceReadyRead())); connect(device, SIGNAL(readyRead()), SLOT(DeviceReadyRead()));
// Yeah I know. // Yeah I know.
if (QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(device)) { if (QAbstractSocket *abstractsocket = qobject_cast<QAbstractSocket*>(device)) {
flush_abstract_socket_ = &QAbstractSocket::flush; flush_abstract_socket_ = &QAbstractSocket::flush;
connect(socket, SIGNAL(disconnected()), SLOT(DeviceClosed())); connect(abstractsocket, SIGNAL(disconnected()), SLOT(DeviceClosed()));
} }
else if (QLocalSocket* socket = qobject_cast<QLocalSocket*>(device)) { else if (QLocalSocket *localsocket = qobject_cast<QLocalSocket*>(device)) {
flush_local_socket_ = &QLocalSocket::flush; flush_local_socket_ = &QLocalSocket::flush;
connect(socket, SIGNAL(disconnected()), SLOT(DeviceClosed())); connect(localsocket, SIGNAL(disconnected()), SLOT(DeviceClosed()));
} }
else { else {
qFatal("Unsupported device type passed to _MessageHandlerBase"); qFatal("Unsupported device type passed to _MessageHandlerBase");

View File

@@ -26,13 +26,16 @@ _MessageReplyBase::_MessageReplyBase(QObject *parent)
: QObject(parent), finished_(false), success_(false) {} : QObject(parent), finished_(false), success_(false) {}
bool _MessageReplyBase::WaitForFinished() { bool _MessageReplyBase::WaitForFinished() {
qLog(Debug) << "Waiting on ID" << id(); qLog(Debug) << "Waiting on ID" << id();
semaphore_.acquire(); semaphore_.acquire();
qLog(Debug) << "Acquired ID" << id(); qLog(Debug) << "Acquired ID" << id();
return success_; return success_;
} }
void _MessageReplyBase::Abort() { void _MessageReplyBase::Abort() {
Q_ASSERT(!finished_); Q_ASSERT(!finished_);
finished_ = true; finished_ = true;
success_ = false; success_ = false;
@@ -40,4 +43,5 @@ void _MessageReplyBase::Abort() {
emit Finished(success_); emit Finished(success_);
qLog(Debug) << "Releasing ID" << id() << "(aborted)"; qLog(Debug) << "Releasing ID" << id() << "(aborted)";
semaphore_.release(); semaphore_.release();
} }

View File

@@ -212,46 +212,46 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
// Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same way; // Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same way;
// apart, so we keep specific behavior for some formats by adding another "else if" block below. // apart, so we keep specific behavior for some formats by adding another "else if" block below.
if (TagLib::Ogg::XiphComment *tag = dynamic_cast<TagLib::Ogg::XiphComment*>(fileref->file()->tag())) { if (TagLib::Ogg::XiphComment *tag_ogg = dynamic_cast<TagLib::Ogg::XiphComment*>(fileref->file()->tag())) {
ParseOggTag(tag->fieldListMap(), nullptr, &disc, &compilation, song); ParseOggTag(tag_ogg->fieldListMap(), nullptr, &disc, &compilation, song);
if (!tag->pictureList().isEmpty()) { if (!tag_ogg->pictureList().isEmpty()) {
song->set_art_automatic(kEmbeddedCover); song->set_art_automatic(kEmbeddedCover);
} }
} }
if (TagLib::FLAC::File *file = dynamic_cast<TagLib::FLAC::File *>(fileref->file())) { if (TagLib::FLAC::File *file_flac = dynamic_cast<TagLib::FLAC::File *>(fileref->file())) {
song->set_bitdepth(file->audioProperties()->bitsPerSample()); song->set_bitdepth(file_flac->audioProperties()->bitsPerSample());
if (file->xiphComment()) { if (file_flac->xiphComment()) {
ParseOggTag(file->xiphComment()->fieldListMap(), nullptr, &disc, &compilation, song); ParseOggTag(file_flac->xiphComment()->fieldListMap(), nullptr, &disc, &compilation, song);
if (!file->pictureList().isEmpty()) { if (!file_flac->pictureList().isEmpty()) {
song->set_art_automatic(kEmbeddedCover); song->set_art_automatic(kEmbeddedCover);
} }
} }
if (tag) Decode(tag->comment(), nullptr, song->mutable_comment()); if (tag) Decode(tag->comment(), nullptr, song->mutable_comment());
} }
else if (TagLib::WavPack::File *file = dynamic_cast<TagLib::WavPack::File *>(fileref->file())) { else if (TagLib::WavPack::File *file_wavpack = dynamic_cast<TagLib::WavPack::File *>(fileref->file())) {
song->set_bitdepth(file->audioProperties()->bitsPerSample()); song->set_bitdepth(file_wavpack->audioProperties()->bitsPerSample());
if (file->tag()) { if (file_wavpack->tag()) {
ParseAPETag(file->APETag()->itemListMap(), nullptr, &disc, &compilation, song); ParseAPETag(file_wavpack->APETag()->itemListMap(), nullptr, &disc, &compilation, song);
} }
if (tag) Decode(tag->comment(), nullptr, song->mutable_comment()); if (tag) Decode(tag->comment(), nullptr, song->mutable_comment());
} }
else if (TagLib::APE::File *file = dynamic_cast<TagLib::APE::File*>(fileref->file())) { else if (TagLib::APE::File *file_ape = dynamic_cast<TagLib::APE::File*>(fileref->file())) {
if (file->tag()) { if (file_ape->tag()) {
ParseAPETag(file->APETag()->itemListMap(), nullptr, &disc, &compilation, song); ParseAPETag(file_ape->APETag()->itemListMap(), nullptr, &disc, &compilation, song);
} }
song->set_bitdepth(file->audioProperties()->bitsPerSample()); song->set_bitdepth(file_ape->audioProperties()->bitsPerSample());
if (tag) Decode(tag->comment(), nullptr, song->mutable_comment()); if (tag) Decode(tag->comment(), nullptr, song->mutable_comment());
} }
else if (TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) { else if (TagLib::MPEG::File *file_mpeg = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
if (file->ID3v2Tag()) { if (file_mpeg->ID3v2Tag()) {
const TagLib::ID3v2::FrameListMap &map = file->ID3v2Tag()->frameListMap(); const TagLib::ID3v2::FrameListMap &map = file_mpeg->ID3v2Tag()->frameListMap();
if (!map["TPOS"].isEmpty()) disc = TStringToQString(map["TPOS"].front()->toString()).trimmed(); if (!map["TPOS"].isEmpty()) disc = TStringToQString(map["TPOS"].front()->toString()).trimmed();
if (!map["TCOM"].isEmpty()) Decode(map["TCOM"].front()->toString(), nullptr, song->mutable_composer()); if (!map["TCOM"].isEmpty()) Decode(map["TCOM"].front()->toString(), nullptr, song->mutable_composer());
@@ -309,12 +309,12 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
} }
} }
else if (TagLib::MP4::File *file = dynamic_cast<TagLib::MP4::File*>(fileref->file())) { else if (TagLib::MP4::File *file_mp4 = dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
song->set_bitdepth(file->audioProperties()->bitsPerSample()); song->set_bitdepth(file_mp4->audioProperties()->bitsPerSample());
if (file->tag()) { if (file_mp4->tag()) {
TagLib::MP4::Tag *mp4_tag = file->tag(); TagLib::MP4::Tag *mp4_tag = file_mp4->tag();
// Find album artists // Find album artists
if (mp4_tag->item("aART").isValid()) { if (mp4_tag->item("aART").isValid()) {
@@ -348,11 +348,11 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
} }
} }
else if (TagLib::ASF::File *file = dynamic_cast<TagLib::ASF::File*>(fileref->file())) { else if (TagLib::ASF::File *file_asf = dynamic_cast<TagLib::ASF::File*>(fileref->file())) {
song->set_bitdepth(file->audioProperties()->bitsPerSample()); song->set_bitdepth(file_asf->audioProperties()->bitsPerSample());
const TagLib::ASF::AttributeListMap &attributes_map = file->tag()->attributeListMap(); const TagLib::ASF::AttributeListMap &attributes_map = file_asf->tag()->attributeListMap();
if (attributes_map.contains(kASF_OriginalDate_ID)) { if (attributes_map.contains(kASF_OriginalDate_ID)) {
const TagLib::ASF::AttributeList &attributes = attributes_map[kASF_OriginalDate_ID]; const TagLib::ASF::AttributeList &attributes = attributes_map[kASF_OriginalDate_ID];
@@ -368,9 +368,9 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
} }
} }
else if (TagLib::MPC::File* file = dynamic_cast<TagLib::MPC::File*>(fileref->file())) { else if (TagLib::MPC::File* file_mpc = dynamic_cast<TagLib::MPC::File*>(fileref->file())) {
if (file->tag()) { if (file_mpc->tag()) {
ParseAPETag(file->APETag()->itemListMap(), nullptr, &disc, &compilation, song); ParseAPETag(file_mpc->APETag()->itemListMap(), nullptr, &disc, &compilation, song);
} }
if (tag) Decode(tag->comment(), nullptr, song->mutable_comment()); if (tag) Decode(tag->comment(), nullptr, song->mutable_comment());
} }
@@ -578,26 +578,26 @@ bool TagReader::SaveFile(const QString &filename, const pb::tagreader::SongMetad
SetVorbisComments(tag, song); SetVorbisComments(tag, song);
} }
else if (TagLib::WavPack::File *file = dynamic_cast<TagLib::WavPack::File*>(fileref->file())) { else if (TagLib::WavPack::File *file_wavpack = dynamic_cast<TagLib::WavPack::File*>(fileref->file())) {
TagLib::APE::Tag *tag = file->APETag(true); TagLib::APE::Tag *tag = file_wavpack->APETag(true);
if (!tag) return false; if (!tag) return false;
SaveAPETag(tag, song); SaveAPETag(tag, song);
} }
else if (TagLib::APE::File *file = dynamic_cast<TagLib::APE::File*>(fileref->file())) { else if (TagLib::APE::File *file_ape = dynamic_cast<TagLib::APE::File*>(fileref->file())) {
TagLib::APE::Tag *tag = file->APETag(true); TagLib::APE::Tag *tag = file_ape->APETag(true);
if (!tag) return false; if (!tag) return false;
SaveAPETag(tag, song); SaveAPETag(tag, song);
} }
else if (TagLib::MPC::File *file = dynamic_cast<TagLib::MPC::File*>(fileref->file())) { else if (TagLib::MPC::File *file_mpc = dynamic_cast<TagLib::MPC::File*>(fileref->file())) {
TagLib::APE::Tag *tag = file->APETag(true); TagLib::APE::Tag *tag = file_mpc->APETag(true);
if (!tag) return false; if (!tag) return false;
SaveAPETag(tag, song); SaveAPETag(tag, song);
} }
else if (TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) { else if (TagLib::MPEG::File *file_mpeg = dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
TagLib::ID3v2::Tag *tag = file->ID3v2Tag(true); TagLib::ID3v2::Tag *tag = file_mpeg->ID3v2Tag(true);
if (!tag) return false; if (!tag) return false;
SetTextFrame("TPOS", song.disc() <= 0 -1 ? QString() : QString::number(song.disc()), tag); SetTextFrame("TPOS", song.disc() <= 0 -1 ? QString() : QString::number(song.disc()), tag);
SetTextFrame("TCOM", song.composer(), tag); SetTextFrame("TCOM", song.composer(), tag);
@@ -609,8 +609,8 @@ bool TagReader::SaveFile(const QString &filename, const pb::tagreader::SongMetad
SetUnsyncLyricsFrame(song.lyrics(), tag); SetUnsyncLyricsFrame(song.lyrics(), tag);
} }
else if (TagLib::MP4::File *file = dynamic_cast<TagLib::MP4::File*>(fileref->file())) { else if (TagLib::MP4::File *file_mp4 = dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
TagLib::MP4::Tag *tag = file->tag(); TagLib::MP4::Tag *tag = file_mp4->tag();
tag->setItem("disk", TagLib::MP4::Item(song.disc() <= 0 -1 ? 0 : song.disc(), 0)); tag->setItem("disk", TagLib::MP4::Item(song.disc() <= 0 -1 ? 0 : song.disc(), 0));
tag->setItem("\251wrt", TagLib::StringList(song.composer().c_str())); tag->setItem("\251wrt", TagLib::StringList(song.composer().c_str()));
tag->setItem("\251grp", TagLib::StringList(song.grouping().c_str())); tag->setItem("\251grp", TagLib::StringList(song.grouping().c_str()));

View File

@@ -185,8 +185,8 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
if (fade_intensity_[x] > 0) { if (fade_intensity_[x] > 0) {
const uint offset = --fade_intensity_[x]; const uint offset = --fade_intensity_[x];
const uint y = y_ + (fade_pos_[x] * (kHeight + 1)); const uint y2 = y_ + (fade_pos_[x] * (kHeight + 1));
canvas_painter.drawPixmap(x * (kWidth + 1), y, fade_bars_[offset], 0, 0, kWidth, height() - y); canvas_painter.drawPixmap(x * (kWidth + 1), y2, fade_bars_[offset], 0, 0, kWidth, height() - y2);
} }
if (fade_intensity_[x] == 0) fade_pos_[x] = rows_; if (fade_intensity_[x] == 0) fade_pos_[x] = rows_;
@@ -237,7 +237,8 @@ static inline void adjustToLimits(int &b, int &f, uint &amount) {
* It won't modify the hue of fg unless absolutely necessary * It won't modify the hue of fg unless absolutely necessary
* @return the adjusted form of fg * @return the adjusted form of fg
*/ */
QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount = 150) { QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount = 150);
QColor ensureContrast(const QColor &bg, const QColor &fg, uint amount) {
class OutputOnExit { class OutputOnExit {
public: public:
@@ -344,18 +345,18 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
p.fillRect(0, y * (kHeight + 1), kWidth, kHeight, QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y), b + static_cast<int>(db * y))); p.fillRect(0, y * (kHeight + 1), kWidth, kHeight, QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y), b + static_cast<int>(db * y)));
{ {
const QColor bg = palette().color(QPalette::Background).darker(112); const QColor bg2 = palette().color(QPalette::Background).darker(112);
// make a complimentary fadebar colour // make a complimentary fadebar colour
// TODO dark is not always correct, dumbo! // TODO dark is not always correct, dumbo!
int h, s, v; int h, s, v;
palette().color(QPalette::Background).darker(150).getHsv(&h, &s, &v); palette().color(QPalette::Background).darker(150).getHsv(&h, &s, &v);
const QColor fg(QColor::fromHsv(h + 120, s, v)); const QColor fg2(QColor::fromHsv(h + 120, s, v));
const double dr = fg.red() - bg.red(); const double dr2 = fg2.red() - bg2.red();
const double dg = fg.green() - bg.green(); const double dg2 = fg2.green() - bg2.green();
const double db = fg.blue() - bg.blue(); const double db2 = fg2.blue() - bg2.blue();
const int r = bg.red(), g = bg.green(), b = bg.blue(); const int r2 = bg2.red(), g2 = bg2.green(), b2 = bg2.blue();
// Precalculate all fade-bar pixmaps // Precalculate all fade-bar pixmaps
for (uint y = 0; y < kFadeSize; ++y) { for (uint y = 0; y < kFadeSize; ++y) {
@@ -363,7 +364,7 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
QPainter f(&fade_bars_[y]); QPainter f(&fade_bars_[y]);
for (int z = 0; static_cast<uint>(z) < rows_; ++z) { for (int z = 0; static_cast<uint>(z) < rows_; ++z) {
const double Y = 1.0 - (log10(kFadeSize - y) / log10(kFadeSize)); const double Y = 1.0 - (log10(kFadeSize - y) / log10(kFadeSize));
f.fillRect(0, z * (kHeight + 1), kWidth, kHeight, QColor(r + static_cast<int>(dr * Y), g + static_cast<int>(dg * Y), b + static_cast<int>(db * Y))); f.fillRect(0, z * (kHeight + 1), kWidth, kHeight, QColor(r2 + static_cast<int>(dr2 * Y), g2 + static_cast<int>(dg2 * Y), b2 + static_cast<int>(db2 * Y)));
} }
} }
} }

View File

@@ -75,20 +75,20 @@ class RainbowAnalyzer : public Analyzer::Base {
static RainbowType rainbowtype; static RainbowType rainbowtype;
inline QRect SourceRect(RainbowType rainbowtype) const { inline QRect SourceRect(RainbowType _rainbowtype) const {
return QRect(0, kHeight[rainbowtype] * frame_, kWidth[rainbowtype], kHeight[rainbowtype]); return QRect(0, kHeight[_rainbowtype] * frame_, kWidth[_rainbowtype], kHeight[_rainbowtype]);
} }
inline QRect SleepingSourceRect(RainbowType rainbowtype) const { inline QRect SleepingSourceRect(RainbowType _rainbowtype) const {
return QRect(0, kHeight[rainbowtype] * kFrameCount[rainbowtype], kWidth[rainbowtype], kSleepingHeight[rainbowtype]); return QRect(0, kHeight[_rainbowtype] * kFrameCount[_rainbowtype], kWidth[_rainbowtype], kSleepingHeight[_rainbowtype]);
} }
inline QRect DestRect(RainbowType rainbowtype) const { inline QRect DestRect(RainbowType _rainbowtype) const {
return QRect(width() - kWidth[rainbowtype], (height() - kHeight[rainbowtype]) / 2, kWidth[rainbowtype], kHeight[rainbowtype]); return QRect(width() - kWidth[_rainbowtype], (height() - kHeight[_rainbowtype]) / 2, kWidth[_rainbowtype], kHeight[_rainbowtype]);
} }
inline QRect SleepingDestRect(RainbowType rainbowtype) const { inline QRect SleepingDestRect(RainbowType _rainbowtype) const {
return QRect(width() - kWidth[rainbowtype], (height() - kSleepingHeight[rainbowtype]) / 2, kWidth[rainbowtype], kSleepingHeight[rainbowtype]); return QRect(width() - kWidth[_rainbowtype], (height() - kSleepingHeight[_rainbowtype]) / 2, kWidth[_rainbowtype], kSleepingHeight[_rainbowtype]);
} }
private: private:

View File

@@ -995,7 +995,7 @@ void CollectionBackend::UpdateCompilations(QSqlQuery &find_song, QSqlQuery &upda
} }
CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, bool compilation, const QueryOptions &opt) { CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, const bool compilation_required, const QueryOptions &opt) {
AlbumList ret; AlbumList ret;
@@ -1003,7 +1003,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
query.SetColumnSpec("album, artist, albumartist, compilation, compilation_detected, art_automatic, art_manual, url"); query.SetColumnSpec("album, artist, albumartist, compilation, compilation_detected, art_automatic, art_manual, url");
query.SetOrderBy("album"); query.SetOrderBy("album");
if (compilation) { if (compilation_required) {
query.AddCompilationRequirement(true); query.AddCompilationRequirement(true);
} }
else if (!artist.isEmpty()) { else if (!artist.isEmpty()) {
@@ -1020,11 +1020,11 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
QString last_artist; QString last_artist;
QString last_album_artist; QString last_album_artist;
while (query.Next()) { while (query.Next()) {
bool compilation = query.Value(3).toBool() | query.Value(4).toBool(); bool is_compilation = query.Value(3).toBool() | query.Value(4).toBool();
Album info; Album info;
info.artist = compilation ? QString() : query.Value(1).toString(); info.artist = is_compilation ? QString() : query.Value(1).toString();
info.album_artist = compilation ? QString() : query.Value(2).toString(); info.album_artist = is_compilation ? QString() : query.Value(2).toString();
info.album_name = query.Value(0).toString(); info.album_name = query.Value(0).toString();
info.first_url = QUrl::fromEncoded(query.Value(7).toByteArray()); info.first_url = QUrl::fromEncoded(query.Value(7).toByteArray());

View File

@@ -141,10 +141,10 @@ class CollectionBackend : public CollectionBackendInterface {
void UpdateTotalArtistCountAsync(); void UpdateTotalArtistCountAsync();
void UpdateTotalAlbumCountAsync(); void UpdateTotalAlbumCountAsync();
SongList FindSongsInDirectory(int id); SongList FindSongsInDirectory(const int id);
SubdirectoryList SubdirsInDirectory(int id); SubdirectoryList SubdirsInDirectory(const int id);
DirectoryList GetAllDirectories(); DirectoryList GetAllDirectories();
void ChangeDirPath(int id, const QString &old_path, const QString &new_path); void ChangeDirPath(const int id, const QString &old_path, const QString &new_path);
QStringList GetAll(const QString &column, const QueryOptions &opt = QueryOptions()); QStringList GetAll(const QString &column, const QueryOptions &opt = QueryOptions());
QStringList GetAllArtists(const QueryOptions &opt = QueryOptions()); QStringList GetAllArtists(const QueryOptions &opt = QueryOptions());
@@ -161,7 +161,7 @@ class CollectionBackend : public CollectionBackendInterface {
void UpdateManualAlbumArtAsync(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url); void UpdateManualAlbumArtAsync(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url);
Album GetAlbumArt(const QString &artist, const QString &albumartist, const QString &album); Album GetAlbumArt(const QString &artist, const QString &albumartist, const QString &album);
Song GetSongById(int id); Song GetSongById(const int id);
SongList GetSongsById(const QList<int> &ids); SongList GetSongsById(const QList<int> &ids);
SongList GetSongsById(const QStringList &ids); SongList GetSongsById(const QStringList &ids);
SongList GetSongsByForeignId(const QStringList &ids, const QString &table, const QString &column); SongList GetSongsByForeignId(const QStringList &ids, const QString &table, const QString &column);
@@ -175,9 +175,9 @@ class CollectionBackend : public CollectionBackendInterface {
bool ExecQuery(CollectionQuery *q); bool ExecQuery(CollectionQuery *q);
SongList ExecCollectionQuery(CollectionQuery *query); SongList ExecCollectionQuery(CollectionQuery *query);
void IncrementPlayCountAsync(int id); void IncrementPlayCountAsync(const int id);
void IncrementSkipCountAsync(int id, float progress); void IncrementSkipCountAsync(const int id, const float progress);
void ResetStatisticsAsync(int id); void ResetStatisticsAsync(const int id);
void DeleteAll(); void DeleteAll();
@@ -199,10 +199,10 @@ class CollectionBackend : public CollectionBackendInterface {
void AddOrUpdateSubdirs(const SubdirectoryList &subdirs); void AddOrUpdateSubdirs(const SubdirectoryList &subdirs);
void UpdateCompilations(); void UpdateCompilations();
void UpdateManualAlbumArt(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url); void UpdateManualAlbumArt(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url);
void ForceCompilation(const QString &album, const QList<QString> &artists, bool on); void ForceCompilation(const QString &album, const QList<QString> &artists, const bool on);
void IncrementPlayCount(int id); void IncrementPlayCount(const int id);
void IncrementSkipCount(int id, float progress); void IncrementSkipCount(const int id, const float progress);
void ResetStatistics(int id); void ResetStatistics(const int id);
void SongPathChanged(const Song &song, const QFileInfo &new_file); void SongPathChanged(const Song &song, const QFileInfo &new_file);
signals: signals:
@@ -215,9 +215,9 @@ class CollectionBackend : public CollectionBackendInterface {
void DatabaseReset(); void DatabaseReset();
void TotalSongCountUpdated(int total); void TotalSongCountUpdated(const int total);
void TotalArtistCountUpdated(int total); void TotalArtistCountUpdated(const int total);
void TotalAlbumCountUpdated(int total); void TotalAlbumCountUpdated(const int total);
void ExitFinished(); void ExitFinished();
@@ -233,11 +233,11 @@ class CollectionBackend : public CollectionBackendInterface {
}; };
void UpdateCompilations(QSqlQuery &find_song, QSqlQuery &update_song, SongList &deleted_songs, SongList &added_songs, const QUrl &url, const bool compilation_detected); void UpdateCompilations(QSqlQuery &find_song, QSqlQuery &update_song, SongList &deleted_songs, SongList &added_songs, const QUrl &url, const bool compilation_detected);
AlbumList GetAlbums(const QString &artist, const QString &album_artist, bool compilation = false, const QueryOptions &opt = QueryOptions()); AlbumList GetAlbums(const QString &artist, const QString &album_artist, const bool compilation_required = false, const QueryOptions &opt = QueryOptions());
AlbumList GetAlbums(const QString &artist, bool compilation, const QueryOptions &opt = QueryOptions()); AlbumList GetAlbums(const QString &artist, const bool compilation_required, const QueryOptions &opt = QueryOptions());
SubdirectoryList SubdirsInDirectory(int id, QSqlDatabase &db); SubdirectoryList SubdirsInDirectory(const int id, QSqlDatabase &db);
Song GetSongById(int id, QSqlDatabase &db); Song GetSongById(const int id, QSqlDatabase &db);
SongList GetSongsById(const QStringList &ids, QSqlDatabase &db); SongList GetSongsById(const QStringList &ids, QSqlDatabase &db);
Song GetSongBySongId(const QString &song_id, QSqlDatabase &db); Song GetSongBySongId(const QString &song_id, QSqlDatabase &db);

View File

@@ -37,13 +37,13 @@ class CollectionItem : public SimpleTreeItem<CollectionItem> {
Type_LoadingIndicator, Type_LoadingIndicator,
}; };
explicit CollectionItem(SimpleTreeModel<CollectionItem> *model) explicit CollectionItem(SimpleTreeModel<CollectionItem> *_model)
: SimpleTreeItem<CollectionItem>(Type_Root, model), : SimpleTreeItem<CollectionItem>(Type_Root, _model),
container_level(-1), container_level(-1),
compilation_artist_node_(nullptr) {} compilation_artist_node_(nullptr) {}
explicit CollectionItem(Type type, CollectionItem *parent = nullptr) explicit CollectionItem(Type _type, CollectionItem *_parent = nullptr)
: SimpleTreeItem<CollectionItem>(type, parent), : SimpleTreeItem<CollectionItem>(_type, _parent),
container_level(-1), container_level(-1),
compilation_artist_node_(nullptr) {} compilation_artist_node_(nullptr) {}

View File

@@ -587,10 +587,10 @@ QVariant CollectionModel::AlbumIcon(const QModelIndex &idx) {
if (use_disk_cache_) { if (use_disk_cache_) {
std::unique_ptr<QIODevice> cache(sIconCache->data(QUrl(cache_key))); std::unique_ptr<QIODevice> cache(sIconCache->data(QUrl(cache_key)));
if (cache) { if (cache) {
QImage cached_pixmap; QImage cached_image;
if (cached_pixmap.load(cache.get(), "XPM")) { if (cached_image.load(cache.get(), "XPM")) {
QPixmapCache::insert(cache_key, QPixmap::fromImage(cached_pixmap)); QPixmapCache::insert(cache_key, QPixmap::fromImage(cached_image));
return QPixmap::fromImage(cached_pixmap); return QPixmap::fromImage(cached_image);
} }
} }
} }

View File

@@ -461,11 +461,11 @@ void CollectionView::ShowInVarious(bool on) {
void CollectionView::Load() { void CollectionView::Load() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->clear_first_ = true; mimedata->clear_first_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
@@ -477,31 +477,31 @@ void CollectionView::AddToPlaylist() {
void CollectionView::AddToPlaylistEnqueue() { void CollectionView::AddToPlaylistEnqueue() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData* mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void CollectionView::AddToPlaylistEnqueueNext() { void CollectionView::AddToPlaylistEnqueueNext() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->enqueue_next_now_ = true; mimedata->enqueue_next_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void CollectionView::OpenInNewPlaylist() { void CollectionView::OpenInNewPlaylist() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData* mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->open_in_new_playlist_ = true; mimedata->open_in_new_playlist_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }

View File

@@ -321,11 +321,11 @@ void ContextAlbumsView::contextMenuEvent(QContextMenuEvent *e) {
void ContextAlbumsView::Load() { void ContextAlbumsView::Load() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->clear_first_ = true; mimedata->clear_first_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
@@ -337,21 +337,21 @@ void ContextAlbumsView::AddToPlaylist() {
void ContextAlbumsView::AddToPlaylistEnqueue() { void ContextAlbumsView::AddToPlaylistEnqueue() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void ContextAlbumsView::OpenInNewPlaylist() { void ContextAlbumsView::OpenInNewPlaylist() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->open_in_new_playlist_ = true; mimedata->open_in_new_playlist_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }

View File

@@ -114,8 +114,8 @@ class ApplicationImpl {
CoverProviders *cover_providers = new CoverProviders(app); CoverProviders *cover_providers = new CoverProviders(app);
// Initialize the repository of cover providers. // Initialize the repository of cover providers.
cover_providers->AddProvider(new LastFmCoverProvider(app, app)); cover_providers->AddProvider(new LastFmCoverProvider(app, app));
cover_providers->AddProvider(new DiscogsCoverProvider(app, app));
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app)); cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app));
cover_providers->AddProvider(new DiscogsCoverProvider(app, app));
cover_providers->AddProvider(new DeezerCoverProvider(app, app)); cover_providers->AddProvider(new DeezerCoverProvider(app, app));
cover_providers->AddProvider(new QobuzCoverProvider(app, app)); cover_providers->AddProvider(new QobuzCoverProvider(app, app));
#ifdef HAVE_TIDAL #ifdef HAVE_TIDAL

View File

@@ -1400,71 +1400,71 @@ void MainWindow::UpdateTrackSliderPosition() {
} }
void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *data) const { void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const {
switch (b) { switch (b) {
case BehaviourSettingsPage::AddBehaviour_Append: case BehaviourSettingsPage::AddBehaviour_Append:
data->clear_first_ = false; mimedata->clear_first_ = false;
data->enqueue_now_ = false; mimedata->enqueue_now_ = false;
break; break;
case BehaviourSettingsPage::AddBehaviour_Enqueue: case BehaviourSettingsPage::AddBehaviour_Enqueue:
data->clear_first_ = false; mimedata->clear_first_ = false;
data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
break; break;
case BehaviourSettingsPage::AddBehaviour_Load: case BehaviourSettingsPage::AddBehaviour_Load:
data->clear_first_ = true; mimedata->clear_first_ = true;
data->enqueue_now_ = false; mimedata->enqueue_now_ = false;
break; break;
case BehaviourSettingsPage::AddBehaviour_OpenInNew: case BehaviourSettingsPage::AddBehaviour_OpenInNew:
data->open_in_new_playlist_ = true; mimedata->open_in_new_playlist_ = true;
break; break;
} }
} }
void MainWindow::ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *data) const { void MainWindow::ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const {
switch (b) { switch (b) {
case BehaviourSettingsPage::PlayBehaviour_Always: case BehaviourSettingsPage::PlayBehaviour_Always:
data->play_now_ = true; mimedata->play_now_ = true;
break; break;
case BehaviourSettingsPage::PlayBehaviour_Never: case BehaviourSettingsPage::PlayBehaviour_Never:
data->play_now_ = false; mimedata->play_now_ = false;
break; break;
case BehaviourSettingsPage::PlayBehaviour_IfStopped: case BehaviourSettingsPage::PlayBehaviour_IfStopped:
data->play_now_ = !(app_->player()->GetState() == Engine::Playing); mimedata->play_now_ = !(app_->player()->GetState() == Engine::Playing);
break; break;
} }
} }
void MainWindow::AddToPlaylist(QMimeData *data) { void MainWindow::AddToPlaylist(QMimeData *q_mimedata) {
if (!data) return; if (!q_mimedata) return;
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
// Should we replace the flags with the user's preference? // Should we replace the flags with the user's preference?
if (mime_data->override_user_settings_) { if (mimedata->override_user_settings_) {
// Do nothing // Do nothing
} }
else if (mime_data->from_doubleclick_) { else if (mimedata->from_doubleclick_) {
ApplyAddBehaviour(doubleclick_addmode_, mime_data); ApplyAddBehaviour(doubleclick_addmode_, mimedata);
ApplyPlayBehaviour(doubleclick_playmode_, mime_data); ApplyPlayBehaviour(doubleclick_playmode_, mimedata);
} }
else { else {
ApplyPlayBehaviour(menu_playmode_, mime_data); ApplyPlayBehaviour(menu_playmode_, mimedata);
} }
// Should we create a new playlist for the songs? // Should we create a new playlist for the songs?
if (mime_data->open_in_new_playlist_) { if (mimedata->open_in_new_playlist_) {
app_->playlist_manager()->New(mime_data->get_name_for_new_playlist()); app_->playlist_manager()->New(mimedata->get_name_for_new_playlist());
} }
} }
app_->playlist_manager()->current()->dropMimeData(data, Qt::CopyAction, -1, 0, QModelIndex()); app_->playlist_manager()->current()->dropMimeData(q_mimedata, Qt::CopyAction, -1, 0, QModelIndex());
delete data; delete q_mimedata;
} }
@@ -1892,9 +1892,9 @@ void MainWindow::AddFile() {
urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath()); urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath());
} }
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(urls); mimedata->setUrls(urls);
AddToPlaylist(data); AddToPlaylist(mimedata);
} }
@@ -1911,19 +1911,19 @@ void MainWindow::AddFolder() {
settings_.setValue("add_folder_path", directory); settings_.setValue("add_folder_path", directory);
// Add media // Add media
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath())); mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath()));
AddToPlaylist(data); AddToPlaylist(mimedata);
} }
void MainWindow::AddCDTracks() { void MainWindow::AddCDTracks() {
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
// We are putting empty data, but we specify cdda mimetype to indicate that we want to load audio cd tracks // We are putting empty data, but we specify cdda mimetype to indicate that we want to load audio cd tracks
data->open_in_new_playlist_ = true; mimedata->open_in_new_playlist_ = true;
data->setData(Playlist::kCddaMimeType, QByteArray()); mimedata->setData(Playlist::kCddaMimeType, QByteArray());
AddToPlaylist(data); AddToPlaylist(mimedata);
} }
@@ -1931,9 +1931,9 @@ void MainWindow::AddStream() { add_stream_dialog_->show(); }
void MainWindow::AddStreamAccepted() { void MainWindow::AddStreamAccepted() {
MimeData* data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(QList<QUrl>() << add_stream_dialog_->url()); mimedata->setUrls(QList<QUrl>() << add_stream_dialog_->url());
AddToPlaylist(data); AddToPlaylist(mimedata);
} }
@@ -2046,31 +2046,31 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
} }
} }
#endif #endif
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(options.urls()); mimedata->setUrls(options.urls());
// Behaviour depends on command line options, so set it here // Behaviour depends on command line options, so set it here
data->override_user_settings_ = true; mimedata->override_user_settings_ = true;
if (options.player_action() == CommandlineOptions::Player_Play) data->play_now_ = true; if (options.player_action() == CommandlineOptions::Player_Play) mimedata->play_now_ = true;
else ApplyPlayBehaviour(doubleclick_playmode_, data); else ApplyPlayBehaviour(doubleclick_playmode_, mimedata);
switch (options.url_list_action()) { switch (options.url_list_action()) {
case CommandlineOptions::UrlList_Load: case CommandlineOptions::UrlList_Load:
data->clear_first_ = true; mimedata->clear_first_ = true;
break; break;
case CommandlineOptions::UrlList_Append: case CommandlineOptions::UrlList_Append:
// Nothing to do // Nothing to do
break; break;
case CommandlineOptions::UrlList_None: case CommandlineOptions::UrlList_None:
ApplyAddBehaviour(doubleclick_addmode_, data); ApplyAddBehaviour(doubleclick_addmode_, mimedata);
break; break;
case CommandlineOptions::UrlList_CreateNew: case CommandlineOptions::UrlList_CreateNew:
data->name_for_new_playlist_ = options.playlist_name(); mimedata->name_for_new_playlist_ = options.playlist_name();
ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour_OpenInNew, data); ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour_OpenInNew, mimedata);
break; break;
} }
AddToPlaylist(data); AddToPlaylist(mimedata);
} }
if (options.set_volume() != -1) app_->player()->SetVolume(options.set_volume()); if (options.set_volume() != -1) app_->player()->SetVolume(options.set_volume());
@@ -2113,9 +2113,9 @@ bool MainWindow::LoadUrl(const QString &url) {
if (!QFile::exists(url)) return false; if (!QFile::exists(url)) return false;
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(url)); mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
AddToPlaylist(data); AddToPlaylist(mimedata);
return true; return true;

View File

@@ -189,7 +189,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void CopyFilesToDevice(const QList<QUrl>& urls); void CopyFilesToDevice(const QList<QUrl>& urls);
void EditFileTags(const QList<QUrl>& urls); void EditFileTags(const QList<QUrl>& urls);
void AddToPlaylist(QMimeData *data); void AddToPlaylist(QMimeData *q_mimedata);
void AddToPlaylist(QAction *action); void AddToPlaylist(QAction *action);
void VolumeWheelEvent(const int delta); void VolumeWheelEvent(const int delta);
@@ -266,8 +266,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void SaveSettings(); void SaveSettings();
void ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *data) const; void ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const;
void ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *data) const; void ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const;
void CheckFullRescanRevisions(); void CheckFullRescanRevisions();

View File

@@ -109,7 +109,7 @@ void RegisterMetaTypes() {
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
qDBusRegisterMetaType<QList<QByteArray>>(); qDBusRegisterMetaType<QList<QByteArray>>();
qDBusRegisterMetaType<TrackMetadata>(); qDBusRegisterMetaType<TrackMetadata>();
qDBusRegisterMetaType<TrackIds>(); qDBusRegisterMetaType<Track_Ids>();
qDBusRegisterMetaType<MprisPlaylist>(); qDBusRegisterMetaType<MprisPlaylist>();
qDBusRegisterMetaType<MprisPlaylistList>(); qDBusRegisterMetaType<MprisPlaylistList>();
qDBusRegisterMetaType<MaybePlaylist>(); qDBusRegisterMetaType<MaybePlaylist>();

View File

@@ -500,14 +500,14 @@ void Mpris2::OpenUri(const QString &uri) {
app_->playlist_manager()->active()->InsertUrls(QList<QUrl>() << QUrl(uri), -1, true); app_->playlist_manager()->active()->InsertUrls(QList<QUrl>() << QUrl(uri), -1, true);
} }
TrackIds Mpris2::Tracks() const { Track_Ids Mpris2::Tracks() const {
// TODO // TODO
return TrackIds(); return Track_Ids();
} }
bool Mpris2::CanEditTracks() const { return false; } bool Mpris2::CanEditTracks() const { return false; }
TrackMetadata Mpris2::GetTracksMetadata(const TrackIds &tracks) const { TrackMetadata Mpris2::GetTracksMetadata(const Track_Ids &tracks) const {
Q_UNUSED(tracks); Q_UNUSED(tracks);

View File

@@ -46,7 +46,7 @@ class Song;
class Playlist; class Playlist;
typedef QList<QVariantMap> TrackMetadata; typedef QList<QVariantMap> TrackMetadata;
typedef QList<QDBusObjectPath> TrackIds; typedef QList<QDBusObjectPath> Track_Ids;
Q_DECLARE_METATYPE(TrackMetadata) Q_DECLARE_METATYPE(TrackMetadata)
struct MprisPlaylist { struct MprisPlaylist {
@@ -112,7 +112,7 @@ class Mpris2 : public QObject {
Q_PROPERTY(bool CanControl READ CanControl) Q_PROPERTY(bool CanControl READ CanControl)
// org.mpris.MediaPlayer2.TrackList MPRIS 2.0 Player interface // org.mpris.MediaPlayer2.TrackList MPRIS 2.0 Player interface
Q_PROPERTY(TrackIds Tracks READ Tracks) Q_PROPERTY(Track_Ids Tracks READ Tracks)
Q_PROPERTY(bool CanEditTracks READ CanEditTracks) Q_PROPERTY(bool CanEditTracks READ CanEditTracks)
// org.mpris.MediaPlayer2.Playlists MPRIS 2.1 Playlists interface // org.mpris.MediaPlayer2.Playlists MPRIS 2.1 Playlists interface
@@ -171,11 +171,11 @@ class Mpris2 : public QObject {
void OpenUri(const QString &uri); void OpenUri(const QString &uri);
// TrackList Properties // TrackList Properties
TrackIds Tracks() const; Track_Ids Tracks() const;
bool CanEditTracks() const; bool CanEditTracks() const;
// Methods // Methods
TrackMetadata GetTracksMetadata(const TrackIds &tracks) const; TrackMetadata GetTracksMetadata(const Track_Ids &tracks) const;
void AddTrack(const QString &uri, const QDBusObjectPath &afterTrack, bool setAsCurrent); void AddTrack(const QString &uri, const QDBusObjectPath &afterTrack, bool setAsCurrent);
void RemoveTrack(const QDBusObjectPath &trackId); void RemoveTrack(const QDBusObjectPath &trackId);
void GoTo(const QDBusObjectPath &trackId); void GoTo(const QDBusObjectPath &trackId);
@@ -194,7 +194,7 @@ signals:
void Seeked(qlonglong position); void Seeked(qlonglong position);
// TrackList // TrackList
void TrackListReplaced(const TrackIds &Tracks, QDBusObjectPath CurrentTrack); void TrackListReplaced(const Track_Ids &Tracks, QDBusObjectPath CurrentTrack);
void TrackAdded(const TrackMetadata &Metadata, QDBusObjectPath AfterTrack); void TrackAdded(const TrackMetadata &Metadata, QDBusObjectPath AfterTrack);
void TrackRemoved(const QDBusObjectPath &trackId); void TrackRemoved(const QDBusObjectPath &trackId);
void TrackMetadataChanged(const QDBusObjectPath &trackId, const TrackMetadata &metadata); void TrackMetadataChanged(const QDBusObjectPath &trackId, const TrackMetadata &metadata);

View File

@@ -29,6 +29,7 @@
#include <QtDebug> #include <QtDebug>
#include "core/logging.h" #include "core/logging.h"
#include "scangiomodulepath.h"
void ScanGIOModulePath() { void ScanGIOModulePath() {

View File

@@ -151,9 +151,9 @@ void SimpleTreeItem<T>::Delete(int child_row) {
} }
template <typename T> template <typename T>
T* SimpleTreeItem<T>::ChildByKey(const QString& key) const { T* SimpleTreeItem<T>::ChildByKey(const QString &_key) const {
for (T* child : children) { for (T* child : children) {
if (child->key == key) return child; if (child->key == _key) return child;
} }
return nullptr; return nullptr;
} }

View File

@@ -681,7 +681,7 @@ QString Song::ImageCacheDir(const Song::Source source) {
} }
int CompareSongsName(const Song &song1, const Song &song2) { int Song::CompareSongsName(const Song &song1, const Song &song2) {
return song1.PrettyTitleWithArtist().localeAwareCompare(song2.PrettyTitleWithArtist()) < 0; return song1.PrettyTitleWithArtist().localeAwareCompare(song2.PrettyTitleWithArtist()) < 0;
} }

View File

@@ -150,6 +150,7 @@ class Song {
static QString ImageCacheDir(const Song::Source source); static QString ImageCacheDir(const Song::Source source);
// Sort songs alphabetically using their pretty title // Sort songs alphabetically using their pretty title
static int CompareSongsName(const Song &song1, const Song &song2);
static void SortSongsListAlphabetically(QList<Song> *songs); static void SortSongsListAlphabetically(QList<Song> *songs);
// Constructors // Constructors

View File

@@ -296,20 +296,20 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
if (!QPixmapCache::find(pixmapName, &pixmap)) { if (!QPixmapCache::find(pixmapName, &pixmap)) {
QImage image(size * devicePixelRatio, size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); QImage image(size * devicePixelRatio, size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent); image.fill(Qt::transparent);
QPainter painter(&image); QPainter p(&image);
QStyleOption tweakedOption(*option); QStyleOption tweakedOption(*option);
tweakedOption.state = QStyle::State_Enabled; tweakedOption.state = QStyle::State_Enabled;
auto drawCommonStyleArrow = [&tweakedOption, element, &painter](const QRect &rect, const QColor &color) -> void auto drawCommonStyleArrow = [&tweakedOption, element, &p](const QRect &rect, const QColor &color) -> void
{ {
static const QCommonStyle* const style = qobject_cast<QCommonStyle*>(QApplication::style()); static const QCommonStyle* const style = qobject_cast<QCommonStyle*>(QApplication::style());
if (!style) if (!style)
return; return;
tweakedOption.palette.setColor(QPalette::ButtonText, color.rgb()); tweakedOption.palette.setColor(QPalette::ButtonText, color.rgb());
tweakedOption.rect = rect; tweakedOption.rect = rect;
painter.setOpacity(color.alphaF()); p.setOpacity(color.alphaF());
style->QCommonStyle::drawPrimitive(element, &tweakedOption, &painter); style->QCommonStyle::drawPrimitive(element, &tweakedOption, &p);
}; };
if (!enabled) { if (!enabled) {
@@ -319,7 +319,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
drawCommonStyleArrow(image.rect().translated(0, devicePixelRatio), toolBarDropShadowColor()); drawCommonStyleArrow(image.rect().translated(0, devicePixelRatio), toolBarDropShadowColor());
drawCommonStyleArrow(image.rect(), m_IconsBaseColor); drawCommonStyleArrow(image.rect(), m_IconsBaseColor);
} }
painter.end(); p.end();
pixmap = QPixmap::fromImage(image); pixmap = QPixmap::fromImage(image);
pixmap.setDevicePixelRatio(devicePixelRatio); pixmap.setDevicePixelRatio(devicePixelRatio);
QPixmapCache::insert(pixmapName, pixmap); QPixmapCache::insert(pixmapName, pixmap);

View File

@@ -332,6 +332,7 @@ QString ColorToRgba(const QColor &c) {
} }
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
void OpenInFileManager(const QString &path);
void OpenInFileManager(const QString &path) { void OpenInFileManager(const QString &path) {
QProcess proc; QProcess proc;

View File

@@ -799,19 +799,19 @@ SongMimeData *AlbumCoverManager::GetMimeDataForAlbums(const QModelIndexList &ind
SongList songs = GetSongsInAlbums(indexes); SongList songs = GetSongsInAlbums(indexes);
if (songs.isEmpty()) return nullptr; if (songs.isEmpty()) return nullptr;
SongMimeData *data = new SongMimeData; SongMimeData *mimedata = new SongMimeData;
data->backend = collection_backend_; mimedata->backend = collection_backend_;
data->songs = songs; mimedata->songs = songs;
return data; return mimedata;
} }
void AlbumCoverManager::AlbumDoubleClicked(const QModelIndex &index) { void AlbumCoverManager::AlbumDoubleClicked(const QModelIndex &index) {
SongMimeData *data = GetMimeDataForAlbums(QModelIndexList() << index); SongMimeData *mimedata = GetMimeDataForAlbums(QModelIndexList() << index);
if (data) { if (mimedata) {
data->from_doubleclick_ = true; mimedata->from_doubleclick_ = true;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
} }
} }
@@ -822,10 +822,10 @@ void AlbumCoverManager::AddSelectedToPlaylist() {
void AlbumCoverManager::LoadSelectedToPlaylist() { void AlbumCoverManager::LoadSelectedToPlaylist() {
SongMimeData *data = GetMimeDataForAlbums(ui_->albums->selectionModel()->selectedIndexes()); SongMimeData *mimedata = GetMimeDataForAlbums(ui_->albums->selectionModel()->selectedIndexes());
if (data) { if (mimedata) {
data->clear_first_ = true; mimedata->clear_first_ = true;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
} }
} }

View File

@@ -220,20 +220,20 @@ void AlbumCoverSearcher::SearchFinished(const quint64 id, const CoverSearchResul
for (const CoverSearchResult &result : results) { for (const CoverSearchResult &result : results) {
if (result.image_url.isEmpty()) continue; if (result.image_url.isEmpty()) continue;
quint64 id = app_->album_cover_loader()->LoadImageAsync(options_, result.image_url, QUrl()); quint64 new_id = app_->album_cover_loader()->LoadImageAsync(options_, result.image_url, QUrl());
QStandardItem *item = new QStandardItem; QStandardItem *item = new QStandardItem;
item->setIcon(no_cover_icon_); item->setIcon(no_cover_icon_);
item->setText(result.artist + " - " + result.album); item->setText(result.artist + " - " + result.album);
item->setData(result.image_url, Role_ImageURL); item->setData(result.image_url, Role_ImageURL);
item->setData(id, Role_ImageRequestId); item->setData(new_id, Role_ImageRequestId);
item->setData(false, Role_ImageFetchFinished); item->setData(false, Role_ImageFetchFinished);
item->setData(QVariant(Qt::AlignTop | Qt::AlignHCenter), Qt::TextAlignmentRole); item->setData(QVariant(Qt::AlignTop | Qt::AlignHCenter), Qt::TextAlignmentRole);
item->setData(result.provider, GroupedIconView::Role_Group); item->setData(result.provider, GroupedIconView::Role_Group);
model_->appendRow(item); model_->appendRow(item);
cover_loading_tasks_[id] = item; cover_loading_tasks_[new_id] = item;
} }
if (cover_loading_tasks_.isEmpty()) ui_->busy->hide(); if (cover_loading_tasks_.isEmpty()) ui_->busy->hide();

View File

@@ -60,8 +60,8 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
Type_Device, Type_Device,
}; };
explicit DeviceInfo(SimpleTreeModel<DeviceInfo> *model) explicit DeviceInfo(SimpleTreeModel<DeviceInfo> *_model)
: SimpleTreeItem<DeviceInfo>(Type_Root, model), : SimpleTreeItem<DeviceInfo>(Type_Root, _model),
database_id_(-1), database_id_(-1),
size_(0), size_(0),
transcode_mode_(MusicStorage::Transcode_Unsupported), transcode_mode_(MusicStorage::Transcode_Unsupported),
@@ -70,8 +70,8 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
unmount_(false), unmount_(false),
forget_(false) {} forget_(false) {}
explicit DeviceInfo(Type type, DeviceInfo *parent = nullptr) explicit DeviceInfo(const Type _type, DeviceInfo *_parent = nullptr)
: SimpleTreeItem<DeviceInfo>(type, parent), : SimpleTreeItem<DeviceInfo>(_type, _parent),
database_id_(-1), database_id_(-1),
size_(0), size_(0),
transcode_mode_(MusicStorage::Transcode_Unsupported), transcode_mode_(MusicStorage::Transcode_Unsupported),

View File

@@ -482,7 +482,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
} }
else { else {
// It's a completely new device // It's a completely new device
DeviceInfo *info = new DeviceInfo(DeviceInfo::Type_Device, root_); info = new DeviceInfo(DeviceInfo::Type_Device, root_);
info->backends_ << DeviceInfo::Backend(lister, id); info->backends_ << DeviceInfo::Backend(lister, id);
info->friendly_name_ = lister->MakeFriendlyName(id); info->friendly_name_ = lister->MakeFriendlyName(id);
info->size_ = lister->DeviceCapacity(id); info->size_ = lister->DeviceCapacity(id);

View File

@@ -376,11 +376,12 @@ SongList DeviceView::GetSelectedSongs() const {
void DeviceView::Load() { void DeviceView::Load() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->clear_first_ = true; mimedata->clear_first_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void DeviceView::AddToPlaylist() { void DeviceView::AddToPlaylist() {
@@ -388,11 +389,13 @@ void DeviceView::AddToPlaylist() {
} }
void DeviceView::OpenInNewPlaylist() { void DeviceView::OpenInNewPlaylist() {
QMimeData *data = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
mime_data->open_in_new_playlist_ = true; if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mimedata->open_in_new_playlist_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void DeviceView::Delete() { void DeviceView::Delete() {

View File

@@ -49,18 +49,18 @@ QString GioLister::DeviceInfo::unique_id() const {
if (!volume_root_uri.isEmpty()) return volume_root_uri; if (!volume_root_uri.isEmpty()) return volume_root_uri;
if (mount) if (mount_ptr)
return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size); return QString("Gio/%1/%2/%3").arg(mount_uuid, filesystem_type).arg(filesystem_size);
else else
return QString("Gio/unmounted/%1").arg((qulonglong)volume.get()); return QString("Gio/unmounted/%1").arg((qulonglong)volume_ptr.get());
} }
bool GioLister::DeviceInfo::is_suitable() const { bool GioLister::DeviceInfo::is_suitable() const {
if (!volume) return false; // This excludes smb or ssh mounts if (!volume_ptr) return false; // This excludes smb or ssh mounts
if (drive && !drive_removable) return false; // This excludes internal drives if (drive_ptr && !drive_removable) return false; // This excludes internal drives
if (filesystem_type.isEmpty()) return true; if (filesystem_type.isEmpty()) return true;
@@ -141,7 +141,7 @@ QVariantList GioLister::DeviceIcons(const QString &id) {
const DeviceInfo &info = devices_[id]; const DeviceInfo &info = devices_[id];
if (info.mount) { if (info.mount_ptr) {
ret << DeviceLister::GuessIconForPath(info.mount_path); ret << DeviceLister::GuessIconForPath(info.mount_path);
ret << info.mount_icon_names; ret << info.mount_icon_names;
} }
@@ -337,7 +337,7 @@ void GioLister::MountAdded(GMount *mount) {
// The volume might already exist - either mounted or unmounted. // The volume might already exist - either mounted or unmounted.
for (const QString &id : devices_.keys()) { for (const QString &id : devices_.keys()) {
if (devices_[id].volume == info.volume) { if (devices_[id].volume_ptr == info.volume_ptr) {
old_id = id; old_id = id;
break; break;
} }
@@ -411,7 +411,7 @@ QString GioLister::DeviceInfo::ConvertAndFree(char *str) {
void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) { void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {
// Get basic information // Get basic information
this->mount.reset_without_add(mount); mount_ptr.reset_without_add(mount);
if (!mount) return; if (!mount) return;
mount_name = ConvertAndFree(g_mount_get_name(mount)); mount_name = ConvertAndFree(g_mount_get_name(mount));
@@ -481,7 +481,7 @@ void GioLister::DeviceInfo::ReadMountInfo(GMount *mount) {
void GioLister::DeviceInfo::ReadVolumeInfo(GVolume *volume) { void GioLister::DeviceInfo::ReadVolumeInfo(GVolume *volume) {
this->volume.reset_without_add(volume); volume_ptr.reset_without_add(volume);
if (!volume) return; if (!volume) return;
volume_name = ConvertAndFree(g_volume_get_name(volume)); volume_name = ConvertAndFree(g_volume_get_name(volume));
@@ -498,7 +498,7 @@ void GioLister::DeviceInfo::ReadVolumeInfo(GVolume *volume) {
void GioLister::DeviceInfo::ReadDriveInfo(GDrive *drive) { void GioLister::DeviceInfo::ReadDriveInfo(GDrive *drive) {
this->drive.reset_without_add(drive); drive_ptr.reset_without_add(drive);
if (!drive) return; if (!drive) return;
drive_name = ConvertAndFree(g_drive_get_name(drive)); drive_name = ConvertAndFree(g_drive_get_name(drive));
@@ -506,18 +506,21 @@ void GioLister::DeviceInfo::ReadDriveInfo(GDrive *drive) {
} }
QString GioLister::FindUniqueIdByMount(GMount *mount) const { QString GioLister::FindUniqueIdByMount(GMount *mount) const {
for (const DeviceInfo &info : devices_) { for (const DeviceInfo &info : devices_) {
if (info.mount == mount) return info.unique_id(); if (info.mount_ptr == mount) return info.unique_id();
} }
return QString(); return QString();
} }
QString GioLister::FindUniqueIdByVolume(GVolume *volume) const { QString GioLister::FindUniqueIdByVolume(GVolume *volume) const {
for (const DeviceInfo &info : devices_) { for (const DeviceInfo &info : devices_) {
if (info.volume == volume) return info.unique_id(); if (info.volume_ptr == volume) return info.unique_id();
} }
return QString(); return QString();
} }
void GioLister::VolumeEjectFinished(GObject *object, GAsyncResult *result, gpointer) { void GioLister::VolumeEjectFinished(GObject *object, GAsyncResult *result, gpointer) {
@@ -536,11 +539,11 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
{ {
QMutexLocker l(&mutex_); QMutexLocker l(&mutex_);
if (!devices_.contains(id) || !devices_[id].mount || devices_[id].volume_root_uri.startsWith("mtp://")) return; if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith("mtp://")) return;
DeviceInfo &device_info = devices_[id]; DeviceInfo &device_info = devices_[id];
GFile *root = g_mount_get_root(device_info.mount); GFile *root = g_mount_get_root(device_info.mount_ptr);
GError *error = nullptr; GError *error = nullptr;
GFileInfo *info = g_file_query_filesystem_info(root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, nullptr, &error); GFileInfo *info = g_file_query_filesystem_info(root, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, nullptr, &error);
@@ -561,8 +564,10 @@ void GioLister::UpdateDeviceFreeSpace(const QString &id) {
} }
bool GioLister::DeviceNeedsMount(const QString &id) { bool GioLister::DeviceNeedsMount(const QString &id) {
QMutexLocker l(&mutex_); QMutexLocker l(&mutex_);
return devices_.contains(id) && !devices_[id].mount && !devices_[id].volume_root_uri.startsWith("mtp://"); return devices_.contains(id) && !devices_[id].mount_ptr && !devices_[id].volume_root_uri.startsWith("mtp://");
} }
void GioLister::MountDevice(const QString &id, const int request_id) { void GioLister::MountDevice(const QString &id, const int request_id) {
@@ -574,13 +579,13 @@ void GioLister::MountDevice(const QString &id, const int request_id) {
} }
const DeviceInfo &info = devices_[id]; const DeviceInfo &info = devices_[id];
if (info.mount) { if (info.mount_ptr) {
// Already mounted // Already mounted
emit DeviceMounted(id, request_id, true); emit DeviceMounted(id, request_id, true);
return; return;
} }
g_volume_mount(info.volume, G_MOUNT_MOUNT_NONE, nullptr, nullptr, VolumeMountFinished, nullptr); g_volume_mount(info.volume_ptr, G_MOUNT_MOUNT_NONE, nullptr, nullptr, VolumeMountFinished, nullptr);
emit DeviceMounted(id, request_id, true); emit DeviceMounted(id, request_id, true);
} }
@@ -588,26 +593,26 @@ void GioLister::MountDevice(const QString &id, const int request_id) {
void GioLister::UnmountDevice(const QString &id) { void GioLister::UnmountDevice(const QString &id) {
QMutexLocker l(&mutex_); QMutexLocker l(&mutex_);
if (!devices_.contains(id) || !devices_[id].mount || devices_[id].volume_root_uri.startsWith("mtp://")) return; if (!devices_.contains(id) || !devices_[id].mount_ptr || devices_[id].volume_root_uri.startsWith("mtp://")) return;
const DeviceInfo &info = devices_[id]; const DeviceInfo &info = devices_[id];
if (!info.mount) return; if (!info.mount_ptr) return;
if (info.volume) { if (info.volume_ptr) {
if (g_volume_can_eject(info.volume)) { if (g_volume_can_eject(info.volume_ptr)) {
g_volume_eject_with_operation(info.volume, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)VolumeEjectFinished, nullptr); g_volume_eject_with_operation(info.volume_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)VolumeEjectFinished, nullptr);
g_object_unref(info.volume); g_object_unref(info.volume_ptr);
return; return;
} }
} }
else return; else return;
if (g_mount_can_eject(info.mount)) { if (g_mount_can_eject(info.mount_ptr)) {
g_mount_eject_with_operation(info.mount, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)MountEjectFinished, nullptr); g_mount_eject_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)MountEjectFinished, nullptr);
} }
else if (g_mount_can_unmount(info.mount)) { else if (g_mount_can_unmount(info.mount_ptr)) {
g_mount_unmount_with_operation(info.mount, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)MountUnmountFinished, nullptr); g_mount_unmount_with_operation(info.mount_ptr, G_MOUNT_UNMOUNT_NONE, nullptr, nullptr, (GAsyncReadyCallback)MountUnmountFinished, nullptr);
} }
} }

View File

@@ -87,19 +87,19 @@ class GioLister : public DeviceLister {
void ReadMountInfo(GMount *mount); void ReadMountInfo(GMount *mount);
// Only available if it's a physical drive // Only available if it's a physical drive
ScopedGObject<GVolume> volume; ScopedGObject<GVolume> volume_ptr;
QString volume_name; QString volume_name;
QString volume_unix_device; QString volume_unix_device;
QString volume_root_uri; QString volume_root_uri;
QString volume_uuid; QString volume_uuid;
// Only available if it's a physical drive // Only available if it's a physical drive
ScopedGObject<GDrive> drive; ScopedGObject<GDrive> drive_ptr;
QString drive_name; QString drive_name;
bool drive_removable; bool drive_removable;
// Only available if it's mounted // Only available if it's mounted
ScopedGObject<GMount> mount; ScopedGObject<GMount> mount_ptr;
QString mount_path; QString mount_path;
QString mount_uri; QString mount_uri;
QString mount_name; QString mount_name;

View File

@@ -372,8 +372,8 @@ Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectP
else else
result.friendly_name = result.model + " " + result.uuid; result.friendly_name = result.model + " " + result.uuid;
for (const auto &path : filesystem.mountPoints()) for (const auto &p : filesystem.mountPoints())
result.mount_paths.push_back(path); result.mount_paths.push_back(p);
result.free_space = Utilities::FileSystemFreeSpace(result.mount_paths.at(0)); result.free_space = Utilities::FileSystemFreeSpace(result.mount_paths.at(0));
} }

View File

@@ -310,8 +310,8 @@ void EditTagDialog::SetSongsFinished(QFuture<QList<Data>> future) {
} }
// Add the filenames to the list // Add the filenames to the list
for (const Data &data : data_) { for (const Data &tag_data : data_) {
ui_->song_list->addItem(data.current_.basefilename()); ui_->song_list->addItem(tag_data.current_.basefilename());
} }
// Select all // Select all
@@ -443,8 +443,8 @@ void EditTagDialog::ResetFieldValue(const FieldData &field, const QModelIndexLis
// Reset each selected song // Reset each selected song
for (const QModelIndex &i : sel) { for (const QModelIndex &i : sel) {
Data &data = data_[i.row()]; Data &tag_data = data_[i.row()];
data.set_value(field.id_, data.original_value(field.id_)); tag_data.set_value(field.id_, tag_data.original_value(field.id_));
} }
// Reset the field // Reset the field
@@ -733,10 +733,10 @@ void EditTagDialog::ButtonClicked(QAbstractButton *button) {
} }
} }
void EditTagDialog::SaveData(const QList<Data> &data) { void EditTagDialog::SaveData(const QList<Data> &tag_data) {
for (int i = 0; i < data.count(); ++i) { for (int i = 0; i < tag_data.count(); ++i) {
const Data &ref = data[i]; const Data &ref = tag_data[i];
if (ref.current_.IsMetadataEqual(ref.original_)) continue; if (ref.current_.IsMetadataEqual(ref.original_)) continue;
pending_++; pending_++;

View File

@@ -156,7 +156,7 @@ class EditTagDialog : public QDialog {
// Called by QtConcurrentRun // Called by QtConcurrentRun
QList<Data> LoadData(const SongList &songs) const; QList<Data> LoadData(const SongList &songs) const;
void SaveData(const QList<Data> &data); void SaveData(const QList<Data> &tag_data);
private: private:
Ui_EditTagDialog *ui_; Ui_EditTagDialog *ui_;

View File

@@ -103,9 +103,9 @@ void TrackSelectionDialog::Init(const SongList &songs) {
data_.clear(); data_.clear();
for (const Song &song : songs) { for (const Song &song : songs) {
Data data; Data tag_data;
data.original_song_ = song; tag_data.original_song_ = song;
data_ << data; data_ << tag_data;
QListWidgetItem *item = new QListWidgetItem(ui_->song_list); QListWidgetItem *item = new QListWidgetItem(ui_->song_list);
item->setText(QFileInfo(song.url().toLocalFile()).fileName()); item->setText(QFileInfo(song.url().toLocalFile()).fileName());
@@ -175,14 +175,14 @@ void TrackSelectionDialog::UpdateStack() {
const int row = ui_->song_list->currentRow(); const int row = ui_->song_list->currentRow();
if (row < 0 || row >= data_.count()) return; if (row < 0 || row >= data_.count()) return;
const Data &data = data_[row]; const Data &tag_data = data_[row];
if (data.pending_) { if (tag_data.pending_) {
ui_->stack->setCurrentWidget(ui_->loading_page); ui_->stack->setCurrentWidget(ui_->loading_page);
ui_->progress->set_text(data.progress_string_ + "..."); ui_->progress->set_text(tag_data.progress_string_ + "...");
return; return;
} }
else if (data.results_.isEmpty()) { else if (tag_data.results_.isEmpty()) {
ui_->stack->setCurrentWidget(ui_->error_page); ui_->stack->setCurrentWidget(ui_->error_page);
return; return;
} }
@@ -193,13 +193,13 @@ void TrackSelectionDialog::UpdateStack() {
// Put the original tags at the top // Put the original tags at the top
AddDivider(tr("Original tags"), ui_->results); AddDivider(tr("Original tags"), ui_->results);
AddSong(data.original_song_, -1, ui_->results); AddSong(tag_data.original_song_, -1, ui_->results);
// Fill tree view with songs // Fill tree view with songs
AddDivider(tr("Suggested tags"), ui_->results); AddDivider(tr("Suggested tags"), ui_->results);
int song_index = 0; int song_index = 0;
for (const Song &song : data.results_) { for (const Song &song : tag_data.results_) {
AddSong(song, song_index++, ui_->results); AddSong(song, song_index++, ui_->results);
} }
@@ -207,7 +207,7 @@ void TrackSelectionDialog::UpdateStack() {
for (int i = 0; i < ui_->results->model()->rowCount(); ++i) { for (int i = 0; i < ui_->results->model()->rowCount(); ++i) {
const QModelIndex index = ui_->results->model()->index(i, 0); const QModelIndex index = ui_->results->model()->index(i, 0);
const QVariant id = index.data(Qt::UserRole); const QVariant id = index.data(Qt::UserRole);
if (!id.isNull() && id.toInt() == data.selected_result_) { if (!id.isNull() && id.toInt() == tag_data.selected_result_) {
ui_->results->setCurrentIndex(index); ui_->results->setCurrentIndex(index);
break; break;
} }
@@ -301,13 +301,13 @@ void TrackSelectionDialog::accept() {
QDialog::accept(); QDialog::accept();
for (const Data &data : data_) { for (const Data &tag_data : data_) {
if (data.pending_ || data.results_.isEmpty() || data.selected_result_ == -1) if (tag_data.pending_ || tag_data.results_.isEmpty() || tag_data.selected_result_ == -1)
continue; continue;
const Song &new_metadata = data.results_[data.selected_result_]; const Song &new_metadata = tag_data.results_[tag_data.selected_result_];
emit SongChosen(data.original_song_, new_metadata); emit SongChosen(tag_data.original_song_, new_metadata);
} }
} }

View File

@@ -673,10 +673,10 @@ void XineEngine::XineEventListener(void *p, const xine_event_t *event) {
{ {
// Series of \0 separated strings, terminated with a \0\0 // Series of \0 separated strings, terminated with a \0\0
char str[2000]; char str[2000];
char *p = str; char *str_p = str;
for (char *msg = data->messages; !(*msg == '\0' && *(msg+1) == '\0'); ++msg, ++p) for (char *msg = data->messages; !(*msg == '\0' && *(msg+1) == '\0'); ++msg, ++str_p)
*p = *msg == '\0' ? '\n' : *msg; *str_p = *msg == '\0' ? '\n' : *msg;
*p = '\0'; *str_p = '\0';
qLog(Debug) << "Xine:" << str; qLog(Debug) << "Xine:" << str;
break; break;
} }

View File

@@ -347,11 +347,11 @@ void InternetCollectionView::contextMenuEvent(QContextMenuEvent *e) {
void InternetCollectionView::Load() { void InternetCollectionView::Load() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->clear_first_ = true; mimedata->clear_first_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
@@ -363,31 +363,31 @@ void InternetCollectionView::AddToPlaylist() {
void InternetCollectionView::AddToPlaylistEnqueue() { void InternetCollectionView::AddToPlaylistEnqueue() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void InternetCollectionView::AddToPlaylistEnqueueNext() { void InternetCollectionView::AddToPlaylistEnqueueNext() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->enqueue_next_now_ = true; mimedata->enqueue_next_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
void InternetCollectionView::OpenInNewPlaylist() { void InternetCollectionView::OpenInNewPlaylist() {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) { if (MimeData* mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->open_in_new_playlist_ = true; mimedata->open_in_new_playlist_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }

View File

@@ -607,31 +607,31 @@ void InternetSearchView::AddSelectedToPlaylist() {
void InternetSearchView::LoadSelected() { void InternetSearchView::LoadSelected() {
MimeData *data = SelectedMimeData(); MimeData *mimedata = SelectedMimeData();
if (!data) return; if (!mimedata) return;
data->clear_first_ = true; mimedata->clear_first_ = true;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
} }
void InternetSearchView::AddSelectedToPlaylistEnqueue() { void InternetSearchView::AddSelectedToPlaylistEnqueue() {
MimeData *data = SelectedMimeData(); MimeData *mimedata = SelectedMimeData();
if (!data) return; if (!mimedata) return;
data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
} }
void InternetSearchView::OpenSelectedInNewPlaylist() { void InternetSearchView::OpenSelectedInNewPlaylist() {
MimeData *data = SelectedMimeData(); MimeData *mimedata = SelectedMimeData();
if (!data) return; if (!mimedata) return;
data->open_in_new_playlist_ = true; mimedata->open_in_new_playlist_ = true;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
} }
@@ -734,9 +734,9 @@ void InternetSearchView::SetSearchType(const InternetSearchView::SearchType type
void InternetSearchView::AddArtists() { void InternetSearchView::AddArtists() {
MimeData *data = SelectedMimeData(); MimeData *mimedata = SelectedMimeData();
if (!data) return; if (!mimedata) return;
if (const InternetSongMimeData *internet_song_data = qobject_cast<const InternetSongMimeData*>(data)) { if (const InternetSongMimeData *internet_song_data = qobject_cast<const InternetSongMimeData*>(mimedata)) {
emit AddArtistsSignal(internet_song_data->songs); emit AddArtistsSignal(internet_song_data->songs);
} }
@@ -744,9 +744,9 @@ void InternetSearchView::AddArtists() {
void InternetSearchView::AddAlbums() { void InternetSearchView::AddAlbums() {
MimeData *data = SelectedMimeData(); MimeData *mimedata = SelectedMimeData();
if (!data) return; if (!mimedata) return;
if (const InternetSongMimeData *internet_song_data = qobject_cast<const InternetSongMimeData*>(data)) { if (const InternetSongMimeData *internet_song_data = qobject_cast<const InternetSongMimeData*>(mimedata)) {
emit AddAlbumsSignal(internet_song_data->songs); emit AddAlbumsSignal(internet_song_data->songs);
} }
@@ -754,9 +754,9 @@ void InternetSearchView::AddAlbums() {
void InternetSearchView::AddSongs() { void InternetSearchView::AddSongs() {
MimeData *data = SelectedMimeData(); MimeData *mimedata = SelectedMimeData();
if (!data) return; if (!mimedata) return;
if (const InternetSongMimeData *internet_song_data = qobject_cast<const InternetSongMimeData*>(data)) { if (const InternetSongMimeData *internet_song_data = qobject_cast<const InternetSongMimeData*>(mimedata)) {
emit AddSongsSignal(internet_song_data->songs); emit AddSongsSignal(internet_song_data->songs);
} }
@@ -844,6 +844,7 @@ void InternetSearchView::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoad
if (!cover_loader_tasks_.contains(id)) { if (!cover_loader_tasks_.contains(id)) {
return; return;
} }
QPair<QModelIndex, QString> cover_loader_task = cover_loader_tasks_.take(id); QPair<QModelIndex, QString> cover_loader_task = cover_loader_tasks_.take(id);
QModelIndex idx = cover_loader_task.first; QModelIndex idx = cover_loader_task.first;
QString key = cover_loader_task.second; QString key = cover_loader_task.second;

View File

@@ -735,7 +735,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
else if (pid == own_pid) { else if (pid == own_pid) {
// Drag from a different playlist // Drag from a different playlist
PlaylistItemList items; PlaylistItemList items;
for (int row : source_rows) items << source_playlist->item_at(row); for (const int i : source_rows) items << source_playlist->item_at(i);
if (items.count() > kUndoItemLimit) { if (items.count() > kUndoItemLimit) {
// Too big to keep in the undo stack. Also clear the stack because it might have been invalidated. // Too big to keep in the undo stack. Also clear the stack because it might have been invalidated.
@@ -748,8 +748,8 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
// Remove the items from the source playlist if it was a move event // Remove the items from the source playlist if it was a move event
if (action == Qt::MoveAction) { if (action == Qt::MoveAction) {
for (int row : source_rows) { for (const int i : source_rows) {
source_playlist->undo_stack()->push(new PlaylistUndoCommands::RemoveItems(source_playlist, row, 1)); source_playlist->undo_stack()->push(new PlaylistUndoCommands::RemoveItems(source_playlist, i, 1));
} }
} }
} }
@@ -1035,7 +1035,7 @@ void Playlist::UpdateItems(const SongList &songs) {
QLinkedList<Song> songs_list; QLinkedList<Song> songs_list;
for (const Song &song : songs) songs_list.append(song); for (const Song &song : songs) songs_list.append(song);
for (int i = 0; i < items_.size(); i++) { for (int i = 0; i < items_.size() ; i++) {
// Update current items list // Update current items list
QMutableLinkedListIterator<Song> it(songs_list); QMutableLinkedListIterator<Song> it(songs_list);
while (it.hasNext()) { while (it.hasNext()) {
@@ -1054,7 +1054,7 @@ void Playlist::UpdateItems(const SongList &songs) {
items_[i] = new_item; items_[i] = new_item;
emit dataChanged(index(i, 0), index(i, ColumnCount - 1)); emit dataChanged(index(i, 0), index(i, ColumnCount - 1));
// Also update undo actions // Also update undo actions
for (int i = 0; i < undo_stack_->count(); i++) { for (int y = 0 ; y < undo_stack_->count() ; y++) {
QUndoCommand *undo_action = const_cast<QUndoCommand*>(undo_stack_->command(i)); QUndoCommand *undo_action = const_cast<QUndoCommand*>(undo_stack_->command(i));
PlaylistUndoCommands::InsertItems *undo_action_insert = dynamic_cast<PlaylistUndoCommands::InsertItems*>(undo_action); PlaylistUndoCommands::InsertItems *undo_action_insert = dynamic_cast<PlaylistUndoCommands::InsertItems*>(undo_action);
if (undo_action_insert) { if (undo_action_insert) {
@@ -1078,7 +1078,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
// We only want one index per row, but we can't just take column 0 because the user might have hidden it. // We only want one index per row, but we can't just take column 0 because the user might have hidden it.
const int first_column = indexes.first().column(); const int first_column = indexes.first().column();
QMimeData *data = new QMimeData; QMimeData *mimedata = new QMimeData;
QList<QUrl> urls; QList<QUrl> urls;
QList<int> rows; QList<int> rows;
@@ -1101,10 +1101,10 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
stream.writeRawData((char*)&pid, sizeof(pid)); stream.writeRawData((char*)&pid, sizeof(pid));
buf.close(); buf.close();
data->setUrls(urls); mimedata->setUrls(urls);
data->setData(kRowsMimetype, buf.data()); mimedata->setData(kRowsMimetype, buf.data());
return data; return mimedata;
} }

View File

@@ -531,9 +531,11 @@ void PlaylistView::showEvent(QShowEvent *) {
} }
namespace {
bool CompareSelectionRanges(const QItemSelectionRange &a, const QItemSelectionRange &b) { bool CompareSelectionRanges(const QItemSelectionRange &a, const QItemSelectionRange &b) {
return b.bottom() < a.bottom(); return b.bottom() < a.bottom();
} }
} // namespace
void PlaylistView::keyPressEvent(QKeyEvent *event) { void PlaylistView::keyPressEvent(QKeyEvent *event) {
@@ -1224,9 +1226,9 @@ void PlaylistView::CopyCurrentSongToClipboard() const {
continue; continue;
} }
const QVariant data = model()->data(currentIndex().sibling(currentIndex().row(), i)); const QVariant var_data = model()->data(currentIndex().sibling(currentIndex().row(), i));
if (data.type() == QVariant::String) { if (var_data.type() == QVariant::String) {
columns << data.toString(); columns << var_data.toString();
} }
} }

View File

@@ -237,12 +237,10 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
if (output.isEmpty()) output = engine()->DefaultOutput(); if (output.isEmpty()) output = engine()->DefaultOutput();
ui_->combobox_output->clear(); ui_->combobox_output->clear();
int i = 0;
for (const EngineBase::OutputDetails &o : engine()->GetOutputsList()) { for (const EngineBase::OutputDetails &o : engine()->GetOutputsList()) {
i++;
ui_->combobox_output->addItem(IconLoader::Load(o.iconname), o.description, QVariant::fromValue(o)); ui_->combobox_output->addItem(IconLoader::Load(o.iconname), o.description, QVariant::fromValue(o));
} }
if (i > 1) ui_->combobox_output->setEnabled(true); if (ui_->combobox_output->count() > 1) ui_->combobox_output->setEnabled(true);
bool found(false); bool found(false);
for (int i = 0; i < ui_->combobox_output->count(); ++i) { for (int i = 0; i < ui_->combobox_output->count(); ++i) {

View File

@@ -104,13 +104,13 @@ void MoodbarSettingsPage::InitMoodbarPreviews() {
qLog(Warning) << "Unable to open moodbar sample file"; qLog(Warning) << "Unable to open moodbar sample file";
return; return;
} }
QByteArray data(file.readAll()); QByteArray file_data = file.readAll();
// Render and set each preview // Render and set each preview
for (int i = 0; i < MoodbarRenderer::StyleCount; ++i) { for (int i = 0; i < MoodbarRenderer::StyleCount; ++i) {
const MoodbarRenderer::MoodbarStyle style = MoodbarRenderer::MoodbarStyle(i); const MoodbarRenderer::MoodbarStyle style = MoodbarRenderer::MoodbarStyle(i);
const ColorVector colors = MoodbarRenderer::Colors(data, style, palette()); const ColorVector colors = MoodbarRenderer::Colors(file_data, style, palette());
QPixmap pixmap(preview_size); QPixmap pixmap(preview_size);
QPainter p(&pixmap); QPainter p(&pixmap);

View File

@@ -180,8 +180,8 @@ void SettingsDialog::showEvent(QShowEvent *e) {
// Load settings // Load settings
loading_settings_ = true; loading_settings_ = true;
for (const PageData &data : pages_.values()) { for (const PageData &page : pages_.values()) {
data.page_->Load(); page.page_->Load();
} }
loading_settings_ = false; loading_settings_ = false;
@@ -207,8 +207,8 @@ void SettingsDialog::accept() {
void SettingsDialog::reject() { void SettingsDialog::reject() {
// Notify each page that user clicks on Cancel // Notify each page that user clicks on Cancel
for (const PageData &data : pages_.values()) { for (const PageData &page : pages_.values()) {
data.page_->Cancel(); page.page_->Cancel();
} }
SaveGeometry(); SaveGeometry();
@@ -294,18 +294,18 @@ void SettingsDialog::AddPage(Page id, SettingsPage *page, QTreeWidgetItem *paren
ui_->stacked_widget->addWidget(area); ui_->stacked_widget->addWidget(area);
// Remember where the page is // Remember where the page is
PageData data; PageData page_data;
data.item_ = item; page_data.item_ = item;
data.scroll_area_ = area; page_data.scroll_area_ = area;
data.page_ = page; page_data.page_ = page;
pages_[id] = data; pages_[id] = page_data;
} }
void SettingsDialog::Save() { void SettingsDialog::Save() {
for (const PageData &data : pages_.values()) { for (const PageData &page : pages_.values()) {
data.page_->Save(); page.page_->Save();
} }
emit ReloadSettings(); emit ReloadSettings();
@@ -340,9 +340,9 @@ void SettingsDialog::CurrentItemChanged(QTreeWidgetItem *item) {
ui_->title->setText("<b>" + item->text(0) + "</b>"); ui_->title->setText("<b>" + item->text(0) + "</b>");
// Display the right page // Display the right page
for (const PageData &data : pages_.values()) { for (const PageData &page : pages_.values()) {
if (data.item_ == item) { if (page.item_ == item) {
ui_->stacked_widget->setCurrentWidget(data.scroll_area_); ui_->stacked_widget->setCurrentWidget(page.scroll_area_);
break; break;
} }
} }

View File

@@ -419,11 +419,11 @@ void TranscodeDialog::AddDestination() {
} }
QIcon icon = IconLoader::Load("folder"); QIcon icon = IconLoader::Load("folder");
QVariant data = QVariant::fromValue(dir); QVariant data_var = QVariant::fromValue(dir);
// Do not insert duplicates. // Do not insert duplicates.
int duplicate_index = ui_->destination->findData(data); int duplicate_index = ui_->destination->findData(data_var);
if (duplicate_index == -1) { if (duplicate_index == -1) {
ui_->destination->addItem(icon, dir, data); ui_->destination->addItem(icon, dir, data_var);
ui_->destination->setCurrentIndex(ui_->destination->count() - 1); ui_->destination->setCurrentIndex(ui_->destination->count() - 1);
} }
else { else {

View File

@@ -105,15 +105,15 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
GstRegistry *registry = gst_registry_get(); GstRegistry *registry = gst_registry_get();
GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY); GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY);
for (GList *p = features; p; p = g_list_next(p)) { for (GList *f = features ; f ; f = g_list_next(f)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY(p->data); GstElementFactory *factory = GST_ELEMENT_FACTORY(f->data);
// Is this the right type of plugin? // Is this the right type of plugin?
if (QString(gst_element_factory_get_klass(factory)).contains(element_type)) { if (QString(gst_element_factory_get_klass(factory)).contains(element_type)) {
const GList *const templates = gst_element_factory_get_static_pad_templates(factory); const GList *const templates = gst_element_factory_get_static_pad_templates(factory);
for (const GList *p = templates; p; p = g_list_next(p)) { for (const GList *t = templates ; t ; t = g_list_next(t)) {
// Only interested in source pads // Only interested in source pads
GstStaticPadTemplate *pad_template = reinterpret_cast<GstStaticPadTemplate*>(p->data); GstStaticPadTemplate *pad_template = reinterpret_cast<GstStaticPadTemplate*>(t->data);
if (pad_template->direction != GST_PAD_SRC) continue; if (pad_template->direction != GST_PAD_SRC) continue;
// Does this pad support the mime type we want? // Does this pad support the mime type we want?

View File

@@ -108,11 +108,11 @@ void AutoExpandingTreeView::ItemDoubleClicked(const QModelIndex &idx) {
ignore_next_click_ = true; ignore_next_click_ = true;
if (add_on_double_click_) { if (add_on_double_click_) {
QMimeData *data = model()->mimeData(QModelIndexList() << idx); QMimeData *q_mimedata = model()->mimeData(QModelIndexList() << idx);
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->from_doubleclick_ = true; mimedata->from_doubleclick_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
} }
@@ -127,11 +127,11 @@ void AutoExpandingTreeView::mousePressEvent(QMouseEvent *event) {
//enqueue to playlist with middleClick //enqueue to playlist with middleClick
if (event->button() == Qt::MidButton) { if (event->button() == Qt::MidButton) {
QMimeData *data = model()->mimeData(selectedIndexes()); QMimeData *q_mimedata = model()->mimeData(selectedIndexes());
if (MimeData *mime_data = qobject_cast<MimeData*>(data)) { if (MimeData *mimedata = qobject_cast<MimeData*>(q_mimedata)) {
mime_data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
} }
emit AddToPlaylistSignal(data); emit AddToPlaylistSignal(q_mimedata);
} }
} }

View File

@@ -158,24 +158,24 @@ void FileView::ChangeFilePathWithoutUndo(const QString &new_path) {
} }
void FileView::ItemActivated(const QModelIndex &index) { void FileView::ItemActivated(const QModelIndex &idx) {
if (model_->isDir(index)) if (model_->isDir(idx))
ChangeFilePath(model_->filePath(index)); ChangeFilePath(model_->filePath(idx));
} }
void FileView::ItemDoubleClick(const QModelIndex &index) { void FileView::ItemDoubleClick(const QModelIndex &idx) {
if (model_->isDir(index)) if (model_->isDir(idx))
return; return;
QString file_path = model_->filePath(index); QString file_path = model_->filePath(idx);
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->from_doubleclick_ = true; mimedata->from_doubleclick_ = true;
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(file_path)); mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(file_path));
data->name_for_new_playlist_ = file_path; mimedata->name_for_new_playlist_ = file_path;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
} }

View File

@@ -74,8 +74,8 @@ class FileView : public QWidget {
void FileUp(); void FileUp();
void FileHome(); void FileHome();
void ChangeFilePath(const QString &new_path); void ChangeFilePath(const QString &new_path);
void ItemActivated(const QModelIndex &index); void ItemActivated(const QModelIndex &idx);
void ItemDoubleClick(const QModelIndex &index); void ItemDoubleClick(const QModelIndex &idx);
void Delete(const QStringList &filenames); void Delete(const QStringList &filenames);
void DeleteFinished(const SongList &songs_with_errors); void DeleteFinished(const SongList &songs_with_errors);

View File

@@ -78,17 +78,17 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
MimeData *FileViewList::MimeDataFromSelection() const { MimeData *FileViewList::MimeDataFromSelection() const {
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(UrlListFromSelection()); mimedata->setUrls(UrlListFromSelection());
QList<QString> filenames = FilenamesFromSelection(); QList<QString> filenames = FilenamesFromSelection();
// if just one folder selected - use it's path as the new playlist's name // if just one folder selected - use it's path as the new playlist's name
if (filenames.size() == 1 && QFileInfo(filenames.first()).isDir()) { if (filenames.size() == 1 && QFileInfo(filenames.first()).isDir()) {
if (filenames.first().length() > 20) { if (filenames.first().length() > 20) {
data->name_for_new_playlist_ = QDir(filenames.first()).dirName(); mimedata->name_for_new_playlist_ = QDir(filenames.first()).dirName();
} }
else { else {
data->name_for_new_playlist_ = filenames.first(); mimedata->name_for_new_playlist_ = filenames.first();
} }
} }
// otherwise, use the current root path // otherwise, use the current root path
@@ -97,18 +97,18 @@ MimeData *FileViewList::MimeDataFromSelection() const {
if (path.length() > 20) { if (path.length() > 20) {
QFileInfo info(path); QFileInfo info(path);
if (info.isDir()) { if (info.isDir()) {
data->name_for_new_playlist_ = QDir(info.filePath()).dirName(); mimedata->name_for_new_playlist_ = QDir(info.filePath()).dirName();
} }
else { else {
data->name_for_new_playlist_ = info.baseName(); mimedata->name_for_new_playlist_ = info.baseName();
} }
} }
else { else {
data->name_for_new_playlist_ = path; mimedata->name_for_new_playlist_ = path;
} }
} }
return data; return mimedata;
} }
@@ -124,9 +124,11 @@ QStringList FileViewList::FilenamesFromSelection() const {
} }
void FileViewList::LoadSlot() { void FileViewList::LoadSlot() {
MimeData *data = MimeDataFromSelection();
data->clear_first_ = true; MimeData *mimedata = MimeDataFromSelection();
emit AddToPlaylist(data); mimedata->clear_first_ = true;
emit AddToPlaylist(mimedata);
} }
void FileViewList::AddToPlaylistSlot() { void FileViewList::AddToPlaylistSlot() {
@@ -134,9 +136,11 @@ void FileViewList::AddToPlaylistSlot() {
} }
void FileViewList::OpenInNewPlaylistSlot() { void FileViewList::OpenInNewPlaylistSlot() {
MimeData *data = MimeDataFromSelection();
data->open_in_new_playlist_ = true; MimeData *mimedata = MimeDataFromSelection();
emit AddToPlaylist(data); mimedata->open_in_new_playlist_ = true;
emit AddToPlaylist(mimedata);
} }
void FileViewList::CopyToCollectionSlot() { void FileViewList::CopyToCollectionSlot() {
@@ -175,10 +179,10 @@ void FileViewList::mousePressEvent(QMouseEvent *e) {
// we need to update the menu selection // we need to update the menu selection
menu_selection_ = selectionModel()->selection(); menu_selection_ = selectionModel()->selection();
MimeData *data = new MimeData; MimeData *mimedata = new MimeData;
data->setUrls(UrlListFromSelection()); mimedata->setUrls(UrlListFromSelection());
data->enqueue_now_ = true; mimedata->enqueue_now_ = true;
emit AddToPlaylist(data); emit AddToPlaylist(mimedata);
break; break;
} }
default: default:

View File

@@ -46,11 +46,6 @@ class SystemTrayIcon;
class QDBusPendingCallWatcher; class QDBusPendingCallWatcher;
#ifdef HAVE_DBUS
QDBusArgument& operator<< (QDBusArgument &arg, const QImage &image);
const QDBusArgument &operator>> (const QDBusArgument &arg, QImage &image);
#endif
class OSD : public QObject { class OSD : public QObject {
Q_OBJECT Q_OBJECT

View File

@@ -51,6 +51,9 @@
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
QDBusArgument &operator<< (QDBusArgument &arg, const QImage &image);
const QDBusArgument &operator>> (const QDBusArgument &arg, QImage &image);
QDBusArgument &operator<<(QDBusArgument &arg, const QImage &image) { QDBusArgument &operator<<(QDBusArgument &arg, const QImage &image) {
if (image.isNull()) { if (image.isNull()) {

View File

@@ -40,24 +40,25 @@ THE SOFTWARE.
#include "core/iconloader.h" #include "core/iconloader.h"
class QSearchFieldPrivate : public QObject { class QSearchFieldPrivate : public QObject {
public: public:
QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineEdit, QToolButton *clearButton) QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineedit, QToolButton *clearbutton)
: QObject(searchField), lineEdit(lineEdit), clearButton(clearButton) {} : QObject(searchField), lineedit_(lineedit), clearbutton_(clearbutton) {}
int lineEditFrameWidth() const { int lineEditFrameWidth() const {
return lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); return lineedit_->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
} }
int clearButtonPaddedWidth() const { int clearButtonPaddedWidth() const {
return clearButton->width() + lineEditFrameWidth() * 2; return clearbutton_->width() + lineEditFrameWidth() * 2;
} }
int clearButtonPaddedHeight() const { int clearButtonPaddedHeight() const {
return clearButton->height() + lineEditFrameWidth() * 2; return clearbutton_->height() + lineEditFrameWidth() * 2;
} }
QPointer<QLineEdit> lineEdit; QPointer<QLineEdit> lineedit_;
QPointer<QToolButton> clearButton; QPointer<QToolButton> clearbutton_;
}; };
QSearchField::QSearchField(QWidget *parent) : QWidget(parent) { QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
@@ -68,21 +69,21 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed())); connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(setText(QString))); connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(setText(QString)));
QToolButton *clearButton = new QToolButton(this); QToolButton *clearbutton = new QToolButton(this);
QIcon clearIcon(IconLoader::Load("edit-clear-locationbar-ltr")); QIcon clearIcon(IconLoader::Load("edit-clear-locationbar-ltr"));
clearButton->setIcon(clearIcon); clearbutton->setIcon(clearIcon);
clearButton->setIconSize(QSize(16, 16)); clearbutton->setIconSize(QSize(16, 16));
clearButton->setStyleSheet("border: none; padding: 0px;"); clearbutton->setStyleSheet("border: none; padding: 0px;");
clearButton->resize(clearButton->sizeHint()); clearbutton->resize(clearbutton->sizeHint());
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(clearbutton, SIGNAL(clicked()), this, SLOT(clear()));
pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton); pimpl = new QSearchFieldPrivate(this, lineEdit, clearbutton);
const int frame_width = lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); const int frame_width = lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; } ").arg(clearButton->width())); lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; } ").arg(clearbutton->width()));
const int width = frame_width + qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth()); const int width = frame_width + qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth());
const int height = frame_width + qMax(lineEdit->minimumSizeHint().height(), pimpl->clearButtonPaddedHeight()); const int height = frame_width + qMax(lineEdit->minimumSizeHint().height(), pimpl->clearButtonPaddedHeight());
lineEdit->setMinimumSize(width, height); lineEdit->setMinimumSize(width, height);
@@ -97,25 +98,27 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
void QSearchField::setText(const QString &text) { void QSearchField::setText(const QString &text) {
Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); Q_ASSERT(pimpl && pimpl->clearbutton_ && pimpl->lineedit_);
if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) return; if (!(pimpl && pimpl->clearbutton_ && pimpl->lineedit_)) return;
if (text != this->text()) pimpl->lineEdit->setText(text); if (text != this->text()) pimpl->lineedit_->setText(text);
} }
void QSearchField::setPlaceholderText(const QString &text) { void QSearchField::setPlaceholderText(const QString &text) {
Q_ASSERT(pimpl && pimpl->lineEdit);
if (!(pimpl && pimpl->lineEdit)) return; Q_ASSERT(pimpl && pimpl->lineedit_);
pimpl->lineEdit->setPlaceholderText(text); if (!(pimpl && pimpl->lineedit_)) return;
pimpl->lineedit_->setPlaceholderText(text);
} }
QString QSearchField::placeholderText() const { QString QSearchField::placeholderText() const {
return pimpl->lineEdit->placeholderText(); return pimpl->lineedit_->placeholderText();
} }
void QSearchField::setFocus(Qt::FocusReason reason) { void QSearchField::setFocus(Qt::FocusReason reason) {
Q_ASSERT(pimpl && pimpl->lineEdit); Q_ASSERT(pimpl && pimpl->lineedit_);
if (pimpl && pimpl->lineEdit) pimpl->lineEdit->setFocus(reason); if (pimpl && pimpl->lineedit_) pimpl->lineedit_->setFocus(reason);
} }
void QSearchField::setFocus() { void QSearchField::setFocus() {
@@ -123,35 +126,47 @@ void QSearchField::setFocus() {
} }
void QSearchField::clear() { void QSearchField::clear() {
Q_ASSERT(pimpl && pimpl->lineEdit);
if (!(pimpl && pimpl->lineEdit)) return; Q_ASSERT(pimpl && pimpl->lineedit_);
pimpl->lineEdit->clear();
if (!(pimpl && pimpl->lineedit_)) return;
pimpl->lineedit_->clear();
} }
void QSearchField::selectAll() { void QSearchField::selectAll() {
Q_ASSERT(pimpl && pimpl->lineEdit);
if (!(pimpl && pimpl->lineEdit)) return; Q_ASSERT(pimpl && pimpl->lineedit_);
pimpl->lineEdit->selectAll();
if (!(pimpl && pimpl->lineedit_)) return;
pimpl->lineedit_->selectAll();
} }
QString QSearchField::text() const { QString QSearchField::text() const {
Q_ASSERT(pimpl && pimpl->lineEdit);
if (!(pimpl && pimpl->lineEdit)) return QString(); Q_ASSERT(pimpl && pimpl->lineedit_);
return pimpl->lineEdit->text();
if (!(pimpl && pimpl->lineedit_)) return QString();
return pimpl->lineedit_->text();
} }
void QSearchField::resizeEvent(QResizeEvent *resizeEvent) { void QSearchField::resizeEvent(QResizeEvent *resizeEvent) {
Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit);
if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) return; Q_ASSERT(pimpl && pimpl->clearbutton_ && pimpl->lineedit_);
if (!(pimpl && pimpl->clearbutton_ && pimpl->lineedit_)) return;
QWidget::resizeEvent(resizeEvent); QWidget::resizeEvent(resizeEvent);
const int x = pimpl->lineEditFrameWidth(); const int x = pimpl->lineEditFrameWidth();
const int y = (height() - pimpl->clearButton->height())/2; const int y = (height() - pimpl->clearbutton_->height())/2;
pimpl->clearButton->move(x, y); pimpl->clearbutton_->move(x, y);
} }
bool QSearchField::eventFilter(QObject *o, QEvent *e) { bool QSearchField::eventFilter(QObject *o, QEvent *e) {
if (pimpl && pimpl->lineEdit && o == pimpl->lineEdit) {
if (pimpl && pimpl->lineedit_ && o == pimpl->lineedit_) {
// Forward some lineEdit events to QSearchField (only those we need for // Forward some lineEdit events to QSearchField (only those we need for
// now, but some might be added later if needed) // now, but some might be added later if needed)
switch (e->type()) { switch (e->type()) {
@@ -164,4 +179,5 @@ bool QSearchField::eventFilter(QObject *o, QEvent *e) {
} }
} }
return QWidget::eventFilter(o, e); return QWidget::eventFilter(o, e);
} }

View File

@@ -40,15 +40,14 @@
const int StretchHeaderView::kMinimumColumnWidth = 10; const int StretchHeaderView::kMinimumColumnWidth = 10;
const int StretchHeaderView::kMagicNumber = 0x502c950f; const int StretchHeaderView::kMagicNumber = 0x502c950f;
StretchHeaderView::StretchHeaderView(Qt::Orientation orientation, QWidget* parent) StretchHeaderView::StretchHeaderView(const Qt::Orientation orientation, QWidget *parent)
: QHeaderView(orientation, parent), : QHeaderView(orientation, parent),
stretch_enabled_(false), stretch_enabled_(false),
in_mouse_move_event_(false) in_mouse_move_event_(false) {
{
connect(this, SIGNAL(sectionResized(int,int,int)), SLOT(SectionResized(int,int,int))); connect(this, SIGNAL(sectionResized(int,int,int)), SLOT(SectionResized(int,int,int)));
} }
void StretchHeaderView::setModel(QAbstractItemModel* model) { void StretchHeaderView::setModel(QAbstractItemModel *model) {
QHeaderView::setModel(model); QHeaderView::setModel(model);
@@ -113,7 +112,7 @@ void StretchHeaderView::UpdateWidths(const QList<int>& sections) {
} }
void StretchHeaderView::HideSection(int logical) { void StretchHeaderView::HideSection(const int logical) {
// Would this hide the last section? // Would this hide the last section?
bool all_hidden = true; bool all_hidden = true;
@@ -151,36 +150,41 @@ void StretchHeaderView::ShowSection(int logical) {
visible_count ++; visible_count ++;
} }
column_widths_[logical] = column_widths_[logical] = visible_count == 0 ? 1.0 : 1.0 / visible_count;
visible_count == 0 ? 1.0 : 1.0 / visible_count;
NormaliseWidths(); NormaliseWidths();
UpdateWidths(); UpdateWidths();
} }
void StretchHeaderView::SetSectionHidden(int logical, bool hidden) { void StretchHeaderView::SetSectionHidden(const int logical, const bool hidden) {
if (hidden) { if (hidden) {
HideSection(logical); HideSection(logical);
} }
else { else {
ShowSection(logical); ShowSection(logical);
} }
} }
void StretchHeaderView::resizeEvent(QResizeEvent* event) { void StretchHeaderView::resizeEvent(QResizeEvent *event) {
QHeaderView::resizeEvent(event); QHeaderView::resizeEvent(event);
if (!stretch_enabled_) return; if (!stretch_enabled_) return;
UpdateWidths(); UpdateWidths();
} }
void StretchHeaderView::mouseMoveEvent(QMouseEvent* e) { void StretchHeaderView::mouseMoveEvent(QMouseEvent *e) {
in_mouse_move_event_ = true; in_mouse_move_event_ = true;
QHeaderView::mouseMoveEvent(e); QHeaderView::mouseMoveEvent(e);
in_mouse_move_event_ = false; in_mouse_move_event_ = false;
} }
void StretchHeaderView::SectionResized(int logical, int, int new_size) { void StretchHeaderView::SectionResized(const int logical, const int, const int new_size) {
if (!stretch_enabled_) return; if (!stretch_enabled_) return;
@@ -210,7 +214,7 @@ void StretchHeaderView::ToggleStretchEnabled() {
SetStretchEnabled(!is_stretch_enabled()); SetStretchEnabled(!is_stretch_enabled());
} }
void StretchHeaderView::SetStretchEnabled(bool enabled) { void StretchHeaderView::SetStretchEnabled(const bool enabled) {
stretch_enabled_ = enabled; stretch_enabled_ = enabled;
@@ -230,7 +234,7 @@ void StretchHeaderView::SetStretchEnabled(bool enabled) {
} }
void StretchHeaderView::SetColumnWidth(int logical, ColumnWidthType width) { void StretchHeaderView::SetColumnWidth(const int logical, const ColumnWidthType width) {
if (!stretch_enabled_) return; if (!stretch_enabled_) return;
@@ -240,13 +244,14 @@ void StretchHeaderView::SetColumnWidth(int logical, ColumnWidthType width) {
for (int i=0 ; i<count() ; ++i) for (int i=0 ; i<count() ; ++i)
if (!isSectionHidden(i) && i != logical) if (!isSectionHidden(i) && i != logical)
other_columns << i; other_columns << i;
NormaliseWidths(other_columns); NormaliseWidths(other_columns);
} }
bool StretchHeaderView::RestoreState(const QByteArray& data) { bool StretchHeaderView::RestoreState(const QByteArray &sdata) {
QDataStream s(data); QDataStream s(sdata);
s.setVersion(QDataStream::Qt_5_6); s.setVersion(QDataStream::Qt_5_6);
int magic_number = 0; int magic_number = 0;

View File

@@ -39,32 +39,32 @@ class StretchHeaderView : public QHeaderView {
Q_OBJECT Q_OBJECT
public: public:
explicit StretchHeaderView(Qt::Orientation orientation, QWidget* parent = nullptr); explicit StretchHeaderView(const Qt::Orientation orientation, QWidget* parent = nullptr);
typedef double ColumnWidthType; typedef double ColumnWidthType;
static const int kMinimumColumnWidth; static const int kMinimumColumnWidth;
static const int kMagicNumber; static const int kMagicNumber;
void setModel(QAbstractItemModel* model); void setModel(QAbstractItemModel *model);
// Serialises the proportional and actual column widths. // Serialises the proportional and actual column widths.
// Use these instead of QHeaderView::restoreState and QHeaderView::saveState to persist the proportional values directly and avoid floating point errors over time. // Use these instead of QHeaderView::restoreState and QHeaderView::saveState to persist the proportional values directly and avoid floating point errors over time.
bool RestoreState(const QByteArray& data); bool RestoreState(const QByteArray &sdata);
QByteArray SaveState() const; QByteArray SaveState() const;
// Hides a section and resizes all other sections to fill the gap. Does nothing if you try to hide the last section. // Hides a section and resizes all other sections to fill the gap. Does nothing if you try to hide the last section.
void HideSection(int logical); void HideSection(const int logical);
// Shows a section and resizes all other sections to make room. // Shows a section and resizes all other sections to make room.
void ShowSection(int logical); void ShowSection(const int logical);
// Calls either HideSection or ShowSection. // Calls either HideSection or ShowSection.
void SetSectionHidden(int logical, bool hidden); void SetSectionHidden(const int logical, const bool hidden);
// Sets the width of the given column and resizes other columns appropriately. // Sets the width of the given column and resizes other columns appropriately.
// width is the proportion of the entire width from 0.0 to 1.0. // width is the proportion of the entire width from 0.0 to 1.0.
void SetColumnWidth(int logical, ColumnWidthType width); void SetColumnWidth(const int logical, const ColumnWidthType width);
bool is_stretch_enabled() const { return stretch_enabled_; } bool is_stretch_enabled() const { return stretch_enabled_; }
@@ -72,16 +72,16 @@ class StretchHeaderView : public QHeaderView {
// Changes the stretch mode. Enabling stretch mode will initialise the // Changes the stretch mode. Enabling stretch mode will initialise the
// proportional column widths from the current state of the header. // proportional column widths from the current state of the header.
void ToggleStretchEnabled(); void ToggleStretchEnabled();
void SetStretchEnabled(bool enabled); void SetStretchEnabled(const bool enabled);
signals: signals:
// Emitted when the stretch mode is changed. // Emitted when the stretch mode is changed.
void StretchEnabledChanged(bool enabled); void StretchEnabledChanged(const bool enabled);
protected: protected:
// QWidget // QWidget
void mouseMoveEvent(QMouseEvent* e); void mouseMoveEvent(QMouseEvent *e);
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent *event);
private: private:
// Scales column_widths_ values so the total is 1.0. // Scales column_widths_ values so the total is 1.0.
@@ -91,7 +91,7 @@ class StretchHeaderView : public QHeaderView {
void UpdateWidths(const QList<int>& sections = QList<int>()); void UpdateWidths(const QList<int>& sections = QList<int>());
private slots: private slots:
void SectionResized(int logical, int old_size, int new_size); void SectionResized(const int logical, const int old_size, const int new_size);
private: private:
bool stretch_enabled_; bool stretch_enabled_;