Connection syntax migration (#637)
This commit is contained in:
@@ -97,21 +97,19 @@ void SCollection::Init() {
|
||||
watcher_->set_backend(backend_);
|
||||
watcher_->set_task_manager(app_->task_manager());
|
||||
|
||||
connect(backend_, SIGNAL(DirectoryDiscovered(Directory, SubdirectoryList)), watcher_, SLOT(AddDirectory(Directory, SubdirectoryList)));
|
||||
connect(backend_, SIGNAL(DirectoryDeleted(Directory)), watcher_, SLOT(RemoveDirectory(Directory)));
|
||||
connect(watcher_, SIGNAL(NewOrUpdatedSongs(SongList)), backend_, SLOT(AddOrUpdateSongs(SongList)));
|
||||
connect(watcher_, SIGNAL(SongsMTimeUpdated(SongList)), backend_, SLOT(UpdateMTimesOnly(SongList)));
|
||||
connect(watcher_, SIGNAL(SongsDeleted(SongList)), backend_, SLOT(DeleteSongs(SongList)));
|
||||
connect(watcher_, SIGNAL(SongsUnavailable(SongList)), backend_, SLOT(MarkSongsUnavailable(SongList)));
|
||||
connect(watcher_, SIGNAL(SongsReadded(SongList, bool)), backend_, SLOT(MarkSongsUnavailable(SongList, bool)));
|
||||
connect(watcher_, SIGNAL(SubdirsDiscovered(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList)));
|
||||
connect(watcher_, SIGNAL(SubdirsMTimeUpdated(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList)));
|
||||
connect(watcher_, SIGNAL(CompilationsNeedUpdating()), backend_, SLOT(UpdateCompilations()));
|
||||
connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song)));
|
||||
connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped()));
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsReadded, backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
|
||||
connect(app_->lastfm_import(), SIGNAL(UpdateLastPlayed(QString, QString, QString, qint64)), backend_, SLOT(UpdateLastPlayed(QString, QString, QString, qint64)));
|
||||
connect(app_->lastfm_import(), SIGNAL(UpdatePlayCount(QString, QString, int)), backend_, SLOT(UpdatePlayCount(QString, QString, int)));
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateLastPlayed, backend_, &CollectionBackend::UpdateLastPlayed);
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::UpdatePlayCount, backend_, &CollectionBackend::UpdatePlayCount);
|
||||
|
||||
// This will start the watcher checking for updates
|
||||
backend_->LoadDirectoriesAsync();
|
||||
@@ -122,11 +120,11 @@ void SCollection::Exit() {
|
||||
|
||||
wait_for_exit_ << backend_ << watcher_;
|
||||
|
||||
disconnect(backend_, nullptr, watcher_, nullptr);
|
||||
disconnect(watcher_, nullptr, backend_, nullptr);
|
||||
QObject::disconnect(backend_, nullptr, watcher_, nullptr);
|
||||
QObject::disconnect(watcher_, nullptr, backend_, nullptr);
|
||||
|
||||
connect(backend_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived()));
|
||||
connect(watcher_, SIGNAL(ExitFinished()), this, SLOT(ExitReceived()));
|
||||
QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &SCollection::ExitReceived);
|
||||
QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &SCollection::ExitReceived);
|
||||
backend_->ExitAsync();
|
||||
watcher_->ExitAsync();
|
||||
|
||||
@@ -135,7 +133,7 @@ void SCollection::Exit() {
|
||||
void SCollection::ExitReceived() {
|
||||
|
||||
QObject *obj = qobject_cast<QObject*>(sender());
|
||||
disconnect(obj, nullptr, this, nullptr);
|
||||
QObject::disconnect(obj, nullptr, this, nullptr);
|
||||
qLog(Debug) << obj << "successfully exited.";
|
||||
wait_for_exit_.removeAll(obj);
|
||||
if (wait_for_exit_.isEmpty()) emit ExitFinished();
|
||||
@@ -165,20 +163,3 @@ void SCollection::ReloadSettings() {
|
||||
model_->ReloadSettings();
|
||||
|
||||
}
|
||||
|
||||
void SCollection::Stopped() {
|
||||
|
||||
CurrentSongChanged(Song());
|
||||
}
|
||||
|
||||
void SCollection::CurrentSongChanged(const Song &song) { // FIXME
|
||||
|
||||
Q_UNUSED(song);
|
||||
|
||||
TagReaderReply *reply = nullptr;
|
||||
|
||||
if (reply) {
|
||||
connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,13 +73,10 @@ class SCollection : public QObject {
|
||||
void AbortScan();
|
||||
void Rescan(const SongList &songs);
|
||||
|
||||
private slots:
|
||||
void ExitReceived();
|
||||
|
||||
void IncrementalScan();
|
||||
|
||||
void CurrentSongChanged(const Song &song);
|
||||
void Stopped();
|
||||
private slots:
|
||||
void ExitReceived();
|
||||
|
||||
signals:
|
||||
void ExitFinished();
|
||||
|
||||
@@ -902,7 +902,7 @@ Song::Source CollectionBackend::Source() const {
|
||||
return source_;
|
||||
}
|
||||
|
||||
void CollectionBackend::UpdateCompilations() {
|
||||
void CollectionBackend::CompilationsNeedUpdating() {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
@@ -204,7 +204,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
void DeleteSongs(const SongList &songs);
|
||||
void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true);
|
||||
void AddOrUpdateSubdirs(const SubdirectoryList &subdirs);
|
||||
void UpdateCompilations();
|
||||
void CompilationsNeedUpdating();
|
||||
void UpdateManualAlbumArt(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url);
|
||||
void ForceCompilation(const QString &album, const QList<QString> &artists, const bool on);
|
||||
void IncrementPlayCount(const int id);
|
||||
|
||||
@@ -37,11 +37,10 @@
|
||||
CollectionDirectoryModel::CollectionDirectoryModel(CollectionBackend *backend, QObject *parent)
|
||||
: QStandardItemModel(parent),
|
||||
dir_icon_(IconLoader::Load("document-open-folder")),
|
||||
backend_(backend)
|
||||
{
|
||||
backend_(backend) {
|
||||
|
||||
connect(backend_, SIGNAL(DirectoryDiscovered(Directory, SubdirectoryList)), SLOT(DirectoryDiscovered(Directory)));
|
||||
connect(backend_, SIGNAL(DirectoryDeleted(Directory)), SLOT(DirectoryDeleted(Directory)));
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, this, &CollectionDirectoryModel::DirectoryDiscovered);
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, this, &CollectionDirectoryModel::DirectoryDeleted);
|
||||
|
||||
}
|
||||
|
||||
@@ -77,34 +76,33 @@ void CollectionDirectoryModel::AddDirectory(const QString &path) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionDirectoryModel::RemoveDirectory(const QModelIndex &index) {
|
||||
void CollectionDirectoryModel::RemoveDirectory(const QModelIndex &idx) {
|
||||
|
||||
if (!backend_ || !index.isValid()) return;
|
||||
if (!backend_ || !idx.isValid()) return;
|
||||
|
||||
Directory dir;
|
||||
dir.path = index.data().toString();
|
||||
dir.id = index.data(kIdRole).toInt();
|
||||
dir.path = idx.data().toString();
|
||||
dir.id = idx.data(kIdRole).toInt();
|
||||
|
||||
backend_->RemoveDirectory(dir);
|
||||
|
||||
}
|
||||
|
||||
QVariant CollectionDirectoryModel::data(const QModelIndex &index, int role) const {
|
||||
QVariant CollectionDirectoryModel::data(const QModelIndex &idx, int role) const {
|
||||
|
||||
switch (role) {
|
||||
case MusicStorage::Role_Storage:
|
||||
case MusicStorage::Role_StorageForceConnect:
|
||||
return QVariant::fromValue(storage_[index.row()]);
|
||||
return QVariant::fromValue(storage_[idx.row()]);
|
||||
|
||||
case MusicStorage::Role_FreeSpace:
|
||||
return Utilities::FileSystemFreeSpace(data(index, Qt::DisplayRole).toString());
|
||||
return Utilities::FileSystemFreeSpace(data(idx, Qt::DisplayRole).toString());
|
||||
|
||||
case MusicStorage::Role_Capacity:
|
||||
return Utilities::FileSystemCapacity(data(index, Qt::DisplayRole).toString());
|
||||
return Utilities::FileSystemCapacity(data(idx, Qt::DisplayRole).toString());
|
||||
|
||||
default:
|
||||
return QStandardItemModel::data(index, role);
|
||||
return QStandardItemModel::data(idx, role);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@ class CollectionDirectoryModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionDirectoryModel(CollectionBackend* backend, QObject *parent = nullptr);
|
||||
explicit CollectionDirectoryModel(CollectionBackend *backend, QObject *parent = nullptr);
|
||||
~CollectionDirectoryModel() override;
|
||||
|
||||
// To be called by GUIs
|
||||
void AddDirectory(const QString &path);
|
||||
void RemoveDirectory(const QModelIndex &index);
|
||||
void RemoveDirectory(const QModelIndex &idx);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant data(const QModelIndex &idx, int role) const override;
|
||||
|
||||
private slots:
|
||||
// To be called by the backend
|
||||
@@ -61,7 +61,7 @@ class CollectionDirectoryModel : public QStandardItemModel {
|
||||
|
||||
QIcon dir_icon_;
|
||||
CollectionBackend* backend_;
|
||||
QList<std::shared_ptr<MusicStorage> > storage_;
|
||||
QList<std::shared_ptr<MusicStorage>> storage_;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONDIRECTORYMODEL_H
|
||||
|
||||
@@ -85,8 +85,8 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
|
||||
QString("</p></body></html>")
|
||||
);
|
||||
|
||||
connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed()));
|
||||
connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout()));
|
||||
QObject::connect(ui_->filter, &QSearchField::returnPressed, this, &CollectionFilterWidget::ReturnPressed);
|
||||
QObject::connect(filter_delay_, &QTimer::timeout, this, &CollectionFilterWidget::FilterDelayTimeout);
|
||||
|
||||
filter_delay_->setInterval(kFilterDelay);
|
||||
filter_delay_->setSingleShot(true);
|
||||
@@ -119,9 +119,9 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
|
||||
group_by_menu_ = new QMenu(tr("Group by"), this);
|
||||
group_by_menu_->addActions(group_by_group_->actions());
|
||||
|
||||
connect(group_by_group_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*)));
|
||||
connect(ui_->save_grouping, SIGNAL(triggered()), this, SLOT(SaveGroupBy()));
|
||||
connect(ui_->manage_groupings, SIGNAL(triggered()), this, SLOT(ShowGroupingManager()));
|
||||
QObject::connect(group_by_group_, &QActionGroup::triggered, this, &CollectionFilterWidget::GroupByClicked);
|
||||
QObject::connect(ui_->save_grouping, &QAction::triggered, this, &CollectionFilterWidget::SaveGroupBy);
|
||||
QObject::connect(ui_->manage_groupings, &QAction::triggered, this, &CollectionFilterWidget::ShowGroupingManager);
|
||||
|
||||
// Collection config menu
|
||||
collection_menu_ = new QMenu(tr("Display options"), this);
|
||||
@@ -133,7 +133,7 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent)
|
||||
collection_menu_->addSeparator();
|
||||
ui_->options->setMenu(collection_menu_);
|
||||
|
||||
connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString)));
|
||||
QObject::connect(ui_->filter, &QSearchField::textChanged, this, &CollectionFilterWidget::FilterTextChanged);
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
@@ -179,14 +179,14 @@ QString CollectionFilterWidget::group_by(const int number) { return group_by() +
|
||||
void CollectionFilterWidget::UpdateGroupByActions() {
|
||||
|
||||
if (group_by_group_) {
|
||||
disconnect(group_by_group_, nullptr, nullptr, nullptr);
|
||||
QObject::disconnect(group_by_group_, nullptr, this, nullptr);
|
||||
delete group_by_group_;
|
||||
}
|
||||
|
||||
group_by_group_ = CreateGroupByActions(this);
|
||||
group_by_menu_->clear();
|
||||
group_by_menu_->addActions(group_by_group_->actions());
|
||||
connect(group_by_group_, SIGNAL(triggered(QAction*)), SLOT(GroupByClicked(QAction*)));
|
||||
QObject::connect(group_by_group_, &QActionGroup::triggered, this, &CollectionFilterWidget::GroupByClicked);
|
||||
if (model_) {
|
||||
CheckCurrentGrouping(model_->GetGroupBy());
|
||||
}
|
||||
@@ -300,24 +300,24 @@ void CollectionFilterWidget::FocusOnFilter(QKeyEvent *event) {
|
||||
void CollectionFilterWidget::SetCollectionModel(CollectionModel *model) {
|
||||
|
||||
if (model_) {
|
||||
disconnect(model_, nullptr, this, nullptr);
|
||||
disconnect(model_, nullptr, group_by_dialog_.get(), nullptr);
|
||||
disconnect(group_by_dialog_.get(), nullptr, model_, nullptr);
|
||||
QObject::disconnect(model_, nullptr, this, nullptr);
|
||||
QObject::disconnect(model_, nullptr, group_by_dialog_.get(), nullptr);
|
||||
QObject::disconnect(group_by_dialog_.get(), nullptr, model_, nullptr);
|
||||
for (QAction *action : filter_ages_.keys()) {
|
||||
disconnect(action, &QAction::triggered, model_, nullptr);
|
||||
QObject::disconnect(action, &QAction::triggered, model_, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
model_ = model;
|
||||
|
||||
// Connect signals
|
||||
connect(model_, SIGNAL(GroupingChanged(CollectionModel::Grouping)), group_by_dialog_.get(), SLOT(CollectionGroupingChanged(CollectionModel::Grouping)));
|
||||
connect(model_, SIGNAL(GroupingChanged(CollectionModel::Grouping)), SLOT(GroupingChanged(CollectionModel::Grouping)));
|
||||
connect(group_by_dialog_.get(), SIGNAL(Accepted(CollectionModel::Grouping)), model_, SLOT(SetGroupBy(CollectionModel::Grouping)));
|
||||
QObject::connect(model_, &CollectionModel::GroupingChanged, group_by_dialog_.get(), &GroupByDialog::CollectionGroupingChanged);
|
||||
QObject::connect(model_, &CollectionModel::GroupingChanged, this, &CollectionFilterWidget::GroupingChanged);
|
||||
QObject::connect(group_by_dialog_.get(), &GroupByDialog::Accepted, model_, &CollectionModel::SetGroupBy);
|
||||
|
||||
for (QAction *action : filter_ages_.keys()) {
|
||||
int age = filter_ages_[action];
|
||||
connect(action, &QAction::triggered, [this, age]() { model_->SetFilterAge(age); } );
|
||||
QObject::connect(action, &QAction::triggered, [this, age]() { model_->SetFilterAge(age); } );
|
||||
}
|
||||
|
||||
// Load settings
|
||||
|
||||
@@ -90,7 +90,7 @@ class CollectionFilterWidget : public QWidget {
|
||||
void UpPressed();
|
||||
void DownPressed();
|
||||
void ReturnPressed();
|
||||
void Filter(const QString &text);
|
||||
void Filter(QString text);
|
||||
|
||||
protected:
|
||||
void keyReleaseEvent(QKeyEvent *e) override;
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
|
||||
CollectionItemDelegate::CollectionItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {}
|
||||
|
||||
void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const {
|
||||
void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const {
|
||||
|
||||
const bool is_divider = index.data(CollectionModel::Role_IsDivider).toBool();
|
||||
const bool is_divider = idx.data(CollectionModel::Role_IsDivider).toBool();
|
||||
|
||||
if (is_divider) {
|
||||
QString text(index.data().toString());
|
||||
QString text(idx.data().toString());
|
||||
|
||||
painter->save();
|
||||
|
||||
@@ -61,7 +61,7 @@ void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||
|
||||
// Does this item have an icon?
|
||||
QPixmap pixmap;
|
||||
QVariant decoration = index.data(Qt::DecorationRole);
|
||||
QVariant decoration = idx.data(Qt::DecorationRole);
|
||||
if (!decoration.isNull()) {
|
||||
if (decoration.canConvert<QPixmap>()) {
|
||||
pixmap = decoration.value<QPixmap>();
|
||||
@@ -113,35 +113,35 @@ void CollectionItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||
painter->restore();
|
||||
}
|
||||
else {
|
||||
QStyledItemDelegate::paint(painter, opt, index);
|
||||
QStyledItemDelegate::paint(painter, opt, idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) {
|
||||
bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) {
|
||||
|
||||
Q_UNUSED(option);
|
||||
|
||||
if (!event || !view) return false;
|
||||
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
QString text = displayText(index.data(), QLocale::system());
|
||||
QString text = displayText(idx.data(), QLocale::system());
|
||||
|
||||
if (text.isEmpty() || !he) return false;
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip: {
|
||||
|
||||
QSize real_text = sizeHint(option, index);
|
||||
QRect displayed_text = view->visualRect(index);
|
||||
QSize real_text = sizeHint(option, idx);
|
||||
QRect displayed_text = view->visualRect(idx);
|
||||
bool is_elided = displayed_text.width() < real_text.width();
|
||||
|
||||
if (is_elided) {
|
||||
QToolTip::showText(he->globalPos(), text, view);
|
||||
}
|
||||
else if (index.data(Qt::ToolTipRole).isValid()) {
|
||||
else if (idx.data(Qt::ToolTipRole).isValid()) {
|
||||
// If the item has a tooltip text, display it
|
||||
QString tooltip_text = index.data(Qt::ToolTipRole).toString();
|
||||
QString tooltip_text = idx.data(Qt::ToolTipRole).toString();
|
||||
QToolTip::showText(he->globalPos(), tooltip_text, view);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -37,10 +37,10 @@ class CollectionItemDelegate : public QStyledItemDelegate {
|
||||
|
||||
public:
|
||||
explicit CollectionItemDelegate(QObject *parent);
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
|
||||
public slots:
|
||||
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) override;
|
||||
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &idx) override;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONITEMDELEGATE_H
|
||||
|
||||
@@ -107,7 +107,7 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
|
||||
cover_loader_options_.scale_output_image_ = true;
|
||||
|
||||
if (app_) {
|
||||
connect(app_->album_cover_loader(), SIGNAL(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)), SLOT(AlbumCoverLoaded(quint64, AlbumCoverLoaderResult)));
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CollectionModel::AlbumCoverLoaded);
|
||||
}
|
||||
|
||||
QIcon nocover = IconLoader::Load("cdcase");
|
||||
@@ -118,17 +118,17 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
|
||||
if (app_ && !sIconCache) {
|
||||
sIconCache = new QNetworkDiskCache(this);
|
||||
sIconCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + kPixmapDiskCacheDir);
|
||||
connect(app_, SIGNAL(ClearPixmapDiskCache()), SLOT(ClearDiskCache()));
|
||||
QObject::connect(app_, &Application::ClearPixmapDiskCache, this, &CollectionModel::ClearDiskCache);
|
||||
}
|
||||
|
||||
connect(backend_, SIGNAL(SongsDiscovered(SongList)), SLOT(SongsDiscovered(SongList)));
|
||||
connect(backend_, SIGNAL(SongsDeleted(SongList)), SLOT(SongsDeleted(SongList)));
|
||||
connect(backend_, SIGNAL(DatabaseReset()), SLOT(Reset()));
|
||||
connect(backend_, SIGNAL(TotalSongCountUpdated(int)), SLOT(TotalSongCountUpdatedSlot(int)));
|
||||
connect(backend_, SIGNAL(TotalArtistCountUpdated(int)), SLOT(TotalArtistCountUpdatedSlot(int)));
|
||||
connect(backend_, SIGNAL(TotalAlbumCountUpdated(int)), SLOT(TotalAlbumCountUpdatedSlot(int)));
|
||||
connect(backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsSlightlyChanged(SongList)));
|
||||
connect(backend_, SIGNAL(SongsRatingChanged(SongList)), SLOT(SongsSlightlyChanged(SongList)));
|
||||
QObject::connect(backend_, &CollectionBackend::SongsDiscovered, this, &CollectionModel::SongsDiscovered);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsDeleted, this, &CollectionModel::SongsDeleted);
|
||||
QObject::connect(backend_, &CollectionBackend::DatabaseReset, this, &CollectionModel::Reset);
|
||||
QObject::connect(backend_, &CollectionBackend::TotalSongCountUpdated, this, &CollectionModel::TotalSongCountUpdatedSlot);
|
||||
QObject::connect(backend_, &CollectionBackend::TotalArtistCountUpdated, this, &CollectionModel::TotalArtistCountUpdatedSlot);
|
||||
QObject::connect(backend_, &CollectionBackend::TotalAlbumCountUpdated, this, &CollectionModel::TotalAlbumCountUpdatedSlot);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsStatisticsChanged, this, &CollectionModel::SongsSlightlyChanged);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsRatingChanged, this, &CollectionModel::SongsSlightlyChanged);
|
||||
|
||||
backend_->UpdateTotalSongCountAsync();
|
||||
backend_->UpdateTotalArtistCountAsync();
|
||||
@@ -909,12 +909,14 @@ void CollectionModel::LazyPopulate(CollectionItem *parent, const bool signal) {
|
||||
}
|
||||
|
||||
void CollectionModel::ResetAsync() {
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QFuture<CollectionModel::QueryResult> future = QtConcurrent::run(&CollectionModel::RunQuery, this, root_);
|
||||
#else
|
||||
QFuture<CollectionModel::QueryResult> future = QtConcurrent::run(this, &CollectionModel::RunQuery, root_);
|
||||
#endif
|
||||
NewClosure(future, this, SLOT(ResetAsyncQueryFinished(QFuture<CollectionModel::QueryResult>)), future);
|
||||
|
||||
}
|
||||
|
||||
void CollectionModel::ResetAsyncQueryFinished(QFuture<CollectionModel::QueryResult> future) {
|
||||
|
||||
@@ -196,10 +196,10 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
void ExpandAll(CollectionItem *item = nullptr) const;
|
||||
|
||||
signals:
|
||||
void TotalSongCountUpdated(const int count);
|
||||
void TotalArtistCountUpdated(const int count);
|
||||
void TotalAlbumCountUpdated(const int count);
|
||||
void GroupingChanged(const CollectionModel::Grouping &g);
|
||||
void TotalSongCountUpdated(int count);
|
||||
void TotalArtistCountUpdated(int count);
|
||||
void TotalAlbumCountUpdated(int count);
|
||||
void GroupingChanged(CollectionModel::Grouping g);
|
||||
|
||||
public slots:
|
||||
void SetFilterAge(const int age);
|
||||
@@ -212,13 +212,14 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
void Reset();
|
||||
void ResetAsync();
|
||||
|
||||
void SongsDiscovered(const SongList &songs);
|
||||
|
||||
protected:
|
||||
void LazyPopulate(CollectionItem *item) override { LazyPopulate(item, true); }
|
||||
void LazyPopulate(CollectionItem *parent, const bool signal);
|
||||
|
||||
private slots:
|
||||
// From CollectionBackend
|
||||
void SongsDiscovered(const SongList &songs);
|
||||
void SongsDeleted(const SongList &songs);
|
||||
void SongsSlightlyChanged(const SongList &songs);
|
||||
void TotalSongCountUpdatedSlot(const int count);
|
||||
|
||||
@@ -338,33 +338,33 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
if (!context_menu_) {
|
||||
context_menu_ = new QMenu(this);
|
||||
action_add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
|
||||
action_load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(Load()));
|
||||
action_open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
|
||||
action_add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &CollectionView::AddToPlaylist);
|
||||
action_load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &CollectionView::Load);
|
||||
action_open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &CollectionView::OpenInNewPlaylist);
|
||||
|
||||
context_menu_->addSeparator();
|
||||
action_add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, SLOT(AddToPlaylistEnqueue()));
|
||||
action_add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, SLOT(AddToPlaylistEnqueueNext()));
|
||||
action_add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue track"), this, &CollectionView::AddToPlaylistEnqueue);
|
||||
action_add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load("go-next"), tr("Queue to play next"), this, &CollectionView::AddToPlaylistEnqueueNext);
|
||||
|
||||
context_menu_->addSeparator();
|
||||
action_organize_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, SLOT(Organize()));
|
||||
action_organize_ = context_menu_->addAction(IconLoader::Load("edit-copy"), tr("Organize files..."), this, &CollectionView::Organize);
|
||||
#ifndef Q_OS_WIN
|
||||
action_copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDevice()));
|
||||
action_copy_to_device_ = context_menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, &CollectionView::CopyToDevice);
|
||||
#endif
|
||||
action_delete_files_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, SLOT(Delete()));
|
||||
action_delete_files_ = context_menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, &CollectionView::Delete);
|
||||
|
||||
context_menu_->addSeparator();
|
||||
action_edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, SLOT(EditTracks()));
|
||||
action_edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit tracks information..."), this, SLOT(EditTracks()));
|
||||
action_show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(ShowInBrowser()));
|
||||
action_edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, &CollectionView::EditTracks);
|
||||
action_edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit tracks information..."), this, &CollectionView::EditTracks);
|
||||
action_show_in_browser_ = context_menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, &CollectionView::ShowInBrowser);
|
||||
|
||||
context_menu_->addSeparator();
|
||||
|
||||
action_rescan_songs_ = context_menu_->addAction(tr("Rescan song(s)"), this, SLOT(RescanSongs()));
|
||||
action_rescan_songs_ = context_menu_->addAction(tr("Rescan song(s)"), this, &CollectionView::RescanSongs);
|
||||
|
||||
context_menu_->addSeparator();
|
||||
action_show_in_various_ = context_menu_->addAction( tr("Show in various artists"), this, SLOT(ShowInVarious()));
|
||||
action_no_show_in_various_ = context_menu_->addAction( tr("Don't show in various artists"), this, SLOT(NoShowInVarious()));
|
||||
action_show_in_various_ = context_menu_->addAction(tr("Show in various artists"), this, &CollectionView::ShowInVarious);
|
||||
action_no_show_in_various_ = context_menu_->addAction(tr("Don't show in various artists"), this, &CollectionView::NoShowInVarious);
|
||||
|
||||
context_menu_->addSeparator();
|
||||
|
||||
@@ -372,7 +372,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
action_copy_to_device_->setDisabled(app_->device_manager()->connected_devices_model()->rowCount() == 0);
|
||||
connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), action_copy_to_device_, SLOT(setDisabled(bool)));
|
||||
QObject::connect(app_->device_manager()->connected_devices_model(), &DeviceStateFilterModel::IsEmptyChanged, action_copy_to_device_, &QAction::setDisabled);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -387,9 +387,9 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
int regular_elements = 0;
|
||||
int regular_editable = 0;
|
||||
|
||||
for (const QModelIndex &index : selected_indexes) {
|
||||
for (const QModelIndex &idx : selected_indexes) {
|
||||
++regular_elements;
|
||||
if(app_->collection_model()->data(index, CollectionModel::Role_Editable).toBool()) {
|
||||
if (app_->collection_model()->data(idx, CollectionModel::Role_Editable).toBool()) {
|
||||
++regular_editable;
|
||||
}
|
||||
}
|
||||
@@ -442,11 +442,11 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionView::ShowInVarious() { ShowInVarious(true); }
|
||||
void CollectionView::ShowInVarious() { SetShowInVarious(true); }
|
||||
|
||||
void CollectionView::NoShowInVarious() { ShowInVarious(false); }
|
||||
void CollectionView::NoShowInVarious() { SetShowInVarious(false); }
|
||||
|
||||
void CollectionView::ShowInVarious(const bool on) {
|
||||
void CollectionView::SetShowInVarious(const bool on) {
|
||||
|
||||
if (!context_menu_index_.isValid()) return;
|
||||
|
||||
@@ -547,12 +547,12 @@ void CollectionView::keyboardSearch(const QString &search) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionView::scrollTo(const QModelIndex &index, ScrollHint hint) {
|
||||
void CollectionView::scrollTo(const QModelIndex &idx, ScrollHint hint) {
|
||||
|
||||
if (is_in_keyboard_search_)
|
||||
QTreeView::scrollTo(index, QAbstractItemView::PositionAtTop);
|
||||
QTreeView::scrollTo(idx, QAbstractItemView::PositionAtTop);
|
||||
else
|
||||
QTreeView::scrollTo(index, hint);
|
||||
QTreeView::scrollTo(idx, hint);
|
||||
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ void CollectionView::EditTracks() {
|
||||
|
||||
if (!edit_tag_dialog_) {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(app_, this));
|
||||
connect(edit_tag_dialog_.get(), SIGNAL(Error(QString)), SLOT(EditTagError(QString)));
|
||||
QObject::connect(edit_tag_dialog_.get(), &EditTagDialog::Error, this, &CollectionView::EditTagError);
|
||||
}
|
||||
edit_tag_dialog_->SetSongs(GetSelectedSongs());
|
||||
edit_tag_dialog_->show();
|
||||
@@ -668,7 +668,7 @@ void CollectionView::Delete() {
|
||||
std::shared_ptr<MusicStorage> storage = app_->collection_model()->directory_model()->index(0, 0).data(MusicStorage::Role_Storage).value<std::shared_ptr<MusicStorage>>();
|
||||
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
||||
connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList)));
|
||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &CollectionView::DeleteFilesFinished);
|
||||
delete_files->Start(selected_songs);
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class CollectionView : public AutoExpandingTreeView {
|
||||
|
||||
// QTreeView
|
||||
void keyboardSearch(const QString &search) override;
|
||||
void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
|
||||
void scrollTo(const QModelIndex &idx, ScrollHint hint = EnsureVisible) override;
|
||||
|
||||
int TotalSongs();
|
||||
int TotalArtists();
|
||||
@@ -114,7 +114,7 @@ class CollectionView : public AutoExpandingTreeView {
|
||||
|
||||
private:
|
||||
void RecheckIsEmpty();
|
||||
void ShowInVarious(const bool on);
|
||||
void SetShowInVarious(const bool on);
|
||||
bool RestoreLevelFocus(const QModelIndex &parent = QModelIndex());
|
||||
void SaveContainerPath(const QModelIndex &child);
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ CollectionViewContainer::CollectionViewContainer(QWidget *parent) : QWidget(pare
|
||||
ui_->setupUi(this);
|
||||
view()->SetFilter(filter());
|
||||
|
||||
connect(filter(), SIGNAL(UpPressed()), view(), SLOT(UpAndFocus()));
|
||||
connect(filter(), SIGNAL(DownPressed()), view(), SLOT(DownAndFocus()));
|
||||
connect(filter(), SIGNAL(ReturnPressed()), view(), SLOT(FilterReturnPressed()));
|
||||
connect(view(), SIGNAL(FocusOnFilterSignal(QKeyEvent*)), filter(), SLOT(FocusOnFilter(QKeyEvent*)));
|
||||
QObject::connect(filter(), &CollectionFilterWidget::UpPressed, view(), &CollectionView::UpAndFocus);
|
||||
QObject::connect(filter(), &CollectionFilterWidget::DownPressed, view(), &CollectionView::DownAndFocus);
|
||||
QObject::connect(filter(), &CollectionFilterWidget::ReturnPressed, view(), &CollectionView::FilterReturnPressed);
|
||||
QObject::connect(view(), &CollectionView::FocusOnFilterSignal, filter(), &CollectionFilterWidget::FocusOnFilter);
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
|
||||
@@ -91,7 +91,8 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
connect(rescan_timer_, SIGNAL(timeout()), SLOT(RescanPathsNow()));
|
||||
QObject::connect(rescan_timer_, &QTimer::timeout, this, &CollectionWatcher::RescanPathsNow);
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::ExitAsync() {
|
||||
@@ -644,7 +645,7 @@ void CollectionWatcher::AddWatch(const Directory &dir, const QString &path) {
|
||||
|
||||
if (!QFile::exists(path)) return;
|
||||
|
||||
connect(fs_watcher_, SIGNAL(PathChanged(QString)), this, SLOT(DirectoryChanged(QString)), Qt::UniqueConnection);
|
||||
QObject::connect(fs_watcher_, &FileSystemWatcherInterface::PathChanged, this, &CollectionWatcher::DirectoryChanged, Qt::UniqueConnection);
|
||||
fs_watcher_->AddPath(path);
|
||||
subdir_mapping_[path] = dir;
|
||||
|
||||
|
||||
@@ -65,13 +65,13 @@ class CollectionWatcher : public QObject {
|
||||
void ExitAsync();
|
||||
|
||||
signals:
|
||||
void NewOrUpdatedSongs(const SongList &songs);
|
||||
void SongsMTimeUpdated(const SongList &songs);
|
||||
void SongsDeleted(const SongList &songs);
|
||||
void SongsUnavailable(const SongList &songs);
|
||||
void SongsReadded(const SongList &songs, bool unavailable = false);
|
||||
void SubdirsDiscovered(const SubdirectoryList &subdirs);
|
||||
void SubdirsMTimeUpdated(const SubdirectoryList &subdirs);
|
||||
void NewOrUpdatedSongs(SongList);
|
||||
void SongsMTimeUpdated(SongList);
|
||||
void SongsDeleted(SongList);
|
||||
void SongsUnavailable(SongList songs, bool unavailable = true);
|
||||
void SongsReadded(SongList songs, bool unavailable = false);
|
||||
void SubdirsDiscovered(SubdirectoryList subdirs);
|
||||
void SubdirsMTimeUpdated(SubdirectoryList subdirs);
|
||||
void CompilationsNeedUpdating();
|
||||
void ExitFinished();
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ GroupByDialog::GroupByDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_Grou
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Bitdepth, 18));
|
||||
p_->mapping_.insert(Mapping(CollectionModel::GroupBy_Bitrate, 19));
|
||||
|
||||
connect(ui_->buttonbox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(Reset()));
|
||||
QObject::connect(ui_->buttonbox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &GroupByDialog::Reset);
|
||||
|
||||
resize(sizeHint());
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class GroupByDialog : public QDialog {
|
||||
void accept() override;
|
||||
|
||||
signals:
|
||||
void Accepted(const CollectionModel::Grouping &g);
|
||||
void Accepted(CollectionModel::Grouping g);
|
||||
|
||||
private slots:
|
||||
void Reset();
|
||||
|
||||
@@ -61,9 +61,10 @@ SavedGroupingManager::SavedGroupingManager(QWidget *parent)
|
||||
ui_->remove->setEnabled(false);
|
||||
|
||||
ui_->remove->setShortcut(QKeySequence::Delete);
|
||||
connect(ui_->list->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(UpdateButtonState()));
|
||||
QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &SavedGroupingManager::UpdateButtonState);
|
||||
|
||||
QObject::connect(ui_->remove, &QPushButton::clicked, this, &SavedGroupingManager::Remove);
|
||||
|
||||
connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove()));
|
||||
}
|
||||
|
||||
SavedGroupingManager::~SavedGroupingManager() {
|
||||
@@ -184,10 +185,10 @@ void SavedGroupingManager::Remove() {
|
||||
if (ui_->list->selectionModel()->hasSelection()) {
|
||||
QSettings s;
|
||||
s.beginGroup(CollectionModel::kSavedGroupingsSettingsGroup);
|
||||
for (const QModelIndex &index : ui_->list->selectionModel()->selectedRows()) {
|
||||
if (index.isValid()) {
|
||||
qLog(Debug) << "Remove saved grouping: " << model_->item(index.row(), 0)->text();
|
||||
s.remove(model_->item(index.row(), 0)->text());
|
||||
for (const QModelIndex &idx : ui_->list->selectionModel()->selectedRows()) {
|
||||
if (idx.isValid()) {
|
||||
qLog(Debug) << "Remove saved grouping: " << model_->item(idx.row(), 0)->text();
|
||||
s.remove(model_->item(idx.row(), 0)->text());
|
||||
}
|
||||
}
|
||||
s.endGroup();
|
||||
|
||||
@@ -43,7 +43,7 @@ class SavedGroupingManager : public QDialog {
|
||||
~SavedGroupingManager() override;
|
||||
|
||||
void UpdateModel();
|
||||
void SetFilter(CollectionFilterWidget* filter) { filter_ = filter; }
|
||||
void SetFilter(CollectionFilterWidget *filter) { filter_ = filter; }
|
||||
|
||||
static QString GroupByToString(const CollectionModel::GroupBy &g);
|
||||
|
||||
@@ -52,7 +52,7 @@ class SavedGroupingManager : public QDialog {
|
||||
void Remove();
|
||||
|
||||
private:
|
||||
Ui_SavedGroupingManager* ui_;
|
||||
Ui_SavedGroupingManager *ui_;
|
||||
QStandardItemModel *model_;
|
||||
CollectionFilterWidget *filter_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user