Connection syntax migration (#637)
This commit is contained in:
@@ -46,8 +46,8 @@ const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows";
|
||||
|
||||
Queue::Queue(Playlist *parent) : QAbstractProxyModel(parent), playlist_(parent), total_length_ns_(0) {
|
||||
|
||||
signal_item_count_changed_ = connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength()));
|
||||
connect(this, SIGNAL(TotalLengthChanged(quint64)), SLOT(UpdateSummaryText()));
|
||||
signal_item_count_changed_ = QObject::connect(this, &Queue::ItemCountChanged, this, &Queue::UpdateTotalLength);
|
||||
QObject::connect(this, &Queue::TotalLengthChanged, this, &Queue::UpdateSummaryText);
|
||||
|
||||
UpdateSummaryText();
|
||||
|
||||
@@ -86,16 +86,16 @@ QModelIndex Queue::mapToSource(const QModelIndex &proxy_index) const {
|
||||
void Queue::setSourceModel(QAbstractItemModel *source_model) {
|
||||
|
||||
if (sourceModel()) {
|
||||
disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex, QModelIndex)));
|
||||
disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(SourceLayoutChanged()));
|
||||
disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(SourceLayoutChanged()));
|
||||
QObject::disconnect(sourceModel(), &QAbstractItemModel::dataChanged, this, &Queue::SourceDataChanged);
|
||||
QObject::disconnect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, &Queue::SourceLayoutChanged);
|
||||
QObject::disconnect(sourceModel(), &QAbstractItemModel::layoutChanged, this, &Queue::SourceLayoutChanged);
|
||||
}
|
||||
|
||||
QAbstractProxyModel::setSourceModel(source_model);
|
||||
|
||||
connect(sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(SourceDataChanged(QModelIndex, QModelIndex)));
|
||||
connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(SourceLayoutChanged()));
|
||||
connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(SourceLayoutChanged()));
|
||||
QObject::connect(sourceModel(), &QAbstractItemModel::dataChanged, this, &Queue::SourceDataChanged);
|
||||
QObject::connect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, &Queue::SourceLayoutChanged);
|
||||
QObject::connect(sourceModel(), &QAbstractItemModel::layoutChanged, this, &Queue::SourceLayoutChanged);
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void Queue::SourceDataChanged(const QModelIndex &top_left, const QModelIndex &bo
|
||||
|
||||
void Queue::SourceLayoutChanged() {
|
||||
|
||||
disconnect(signal_item_count_changed_);
|
||||
QObject::disconnect(signal_item_count_changed_);
|
||||
|
||||
for (int i = 0; i < source_indexes_.count(); ++i) {
|
||||
if (!source_indexes_[i].isValid()) {
|
||||
@@ -124,7 +124,7 @@ void Queue::SourceLayoutChanged() {
|
||||
}
|
||||
}
|
||||
|
||||
signal_item_count_changed_ = connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength()));
|
||||
signal_item_count_changed_ = QObject::connect(this, &Queue::ItemCountChanged, this, &Queue::UpdateTotalLength);
|
||||
|
||||
emit ItemCountChanged(this->ItemCount());
|
||||
|
||||
@@ -332,10 +332,10 @@ QMimeData *Queue::mimeData(const QModelIndexList &indexes) const {
|
||||
QMimeData *data = new QMimeData;
|
||||
|
||||
QList<int> rows;
|
||||
for (const QModelIndex &index : indexes) {
|
||||
if (index.column() != 0) continue;
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
if (idx.column() != 0) continue;
|
||||
|
||||
rows << index.row();
|
||||
rows << idx.row();
|
||||
}
|
||||
|
||||
QBuffer buf;
|
||||
@@ -402,11 +402,11 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
|
||||
|
||||
}
|
||||
|
||||
Qt::ItemFlags Queue::flags(const QModelIndex &index) const {
|
||||
Qt::ItemFlags Queue::flags(const QModelIndex &idx) const {
|
||||
|
||||
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
|
||||
if (index.isValid())
|
||||
if (idx.isValid())
|
||||
flags |= Qt::ItemIsDragEnabled;
|
||||
else
|
||||
flags |= Qt::ItemIsDropEnabled;
|
||||
|
||||
@@ -76,15 +76,15 @@ class Queue : public QAbstractProxyModel {
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &idx) const override;
|
||||
|
||||
public slots:
|
||||
void UpdateSummaryText();
|
||||
|
||||
signals:
|
||||
void TotalLengthChanged(const quint64 length);
|
||||
void ItemCountChanged(const int count);
|
||||
void SummaryTextChanged(const QString& message);
|
||||
void TotalLengthChanged(quint64 length);
|
||||
void ItemCountChanged(int count);
|
||||
void SummaryTextChanged(QString message);
|
||||
|
||||
private slots:
|
||||
void SourceDataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right);
|
||||
|
||||
@@ -61,10 +61,10 @@ QueueView::QueueView(QWidget *parent)
|
||||
ui_->remove->setShortcut(QKeySequence::Delete);
|
||||
|
||||
// Button connections
|
||||
connect(ui_->move_down, SIGNAL(clicked()), SLOT(MoveDown()));
|
||||
connect(ui_->move_up, SIGNAL(clicked()), SLOT(MoveUp()));
|
||||
connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove()));
|
||||
connect(ui_->clear, SIGNAL(clicked()), SLOT(Clear()));
|
||||
QObject::connect(ui_->move_down, &QToolButton::clicked, this, &QueueView::MoveDown);
|
||||
QObject::connect(ui_->move_up, &QToolButton::clicked, this, &QueueView::MoveUp);
|
||||
QObject::connect(ui_->remove, &QToolButton::clicked, this, &QueueView::Remove);
|
||||
QObject::connect(ui_->clear, &QToolButton::clicked, this, &QueueView::Clear);
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
@@ -78,7 +78,7 @@ void QueueView::SetPlaylistManager(PlaylistManager *manager) {
|
||||
|
||||
playlists_ = manager;
|
||||
|
||||
connect(playlists_, SIGNAL(CurrentChanged(Playlist*)), SLOT(CurrentPlaylistChanged(Playlist*)));
|
||||
QObject::connect(playlists_, &PlaylistManager::CurrentChanged, this, &QueueView::CurrentPlaylistChanged);
|
||||
CurrentPlaylistChanged(playlists_->current());
|
||||
|
||||
}
|
||||
@@ -100,27 +100,27 @@ void QueueView::ReloadSettings() {
|
||||
void QueueView::CurrentPlaylistChanged(Playlist *playlist) {
|
||||
|
||||
if (current_playlist_) {
|
||||
disconnect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(UpdateButtonState()));
|
||||
disconnect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(UpdateButtonState()));
|
||||
disconnect(current_playlist_->queue(), SIGNAL(layoutChanged()), this, SLOT(UpdateButtonState()));
|
||||
disconnect(current_playlist_->queue(), SIGNAL(SummaryTextChanged(QString)), ui_->summary, SLOT(setText(QString)));
|
||||
disconnect(current_playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));
|
||||
QObject::disconnect(current_playlist_->queue(), &Queue::rowsInserted, this, &QueueView::UpdateButtonState);
|
||||
QObject::disconnect(current_playlist_->queue(), &Queue::rowsRemoved, this, &QueueView::UpdateButtonState);
|
||||
QObject::disconnect(current_playlist_->queue(), &Queue::layoutChanged, this, &QueueView::UpdateButtonState);
|
||||
QObject::disconnect(current_playlist_->queue(), &Queue::SummaryTextChanged, ui_->summary, &QLabel::setText);
|
||||
QObject::disconnect(current_playlist_, &Playlist::destroyed, this, &QueueView::PlaylistDestroyed);
|
||||
}
|
||||
|
||||
current_playlist_ = playlist;
|
||||
|
||||
connect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(UpdateButtonState()));
|
||||
connect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(UpdateButtonState()));
|
||||
connect(current_playlist_->queue(), SIGNAL(layoutChanged()), this, SLOT(UpdateButtonState()));
|
||||
connect(current_playlist_->queue(), SIGNAL(SummaryTextChanged(QString)), ui_->summary, SLOT(setText(QString)));
|
||||
connect(current_playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));
|
||||
QObject::connect(current_playlist_->queue(), &Queue::rowsInserted, this, &QueueView::UpdateButtonState);
|
||||
QObject::connect(current_playlist_->queue(), &Queue::rowsRemoved, this, &QueueView::UpdateButtonState);
|
||||
QObject::connect(current_playlist_->queue(), &Queue::layoutChanged, this, &QueueView::UpdateButtonState);
|
||||
QObject::connect(current_playlist_->queue(), &Queue::SummaryTextChanged, ui_->summary, &QLabel::setText);
|
||||
QObject::connect(current_playlist_, &Playlist::destroyed, this, &QueueView::PlaylistDestroyed);
|
||||
|
||||
ui_->list->setModel(current_playlist_->queue());
|
||||
|
||||
connect(ui_->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(UpdateButtonState()));
|
||||
connect(ui_->list->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(UpdateButtonState()));
|
||||
QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::currentChanged, this, &QueueView::UpdateButtonState);
|
||||
QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QueueView::UpdateButtonState);
|
||||
|
||||
QTimer::singleShot(0, current_playlist_->queue(), SLOT(UpdateSummaryText()));
|
||||
QTimer::singleShot(0, current_playlist_->queue(), &Queue::UpdateSummaryText);
|
||||
|
||||
}
|
||||
|
||||
@@ -131,8 +131,8 @@ void QueueView::MoveUp() {
|
||||
|
||||
if (indexes.isEmpty() || indexes.first().row() == 0) return;
|
||||
|
||||
for (const QModelIndex &index : indexes) {
|
||||
current_playlist_->queue()->MoveUp(index.row());
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
current_playlist_->queue()->MoveUp(idx.row());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -159,8 +159,8 @@ void QueueView::Remove() {
|
||||
|
||||
// collect the rows to be removed
|
||||
QList<int> row_list;
|
||||
for (const QModelIndex &index : ui_->list->selectionModel()->selectedRows()) {
|
||||
if (index.isValid()) row_list << index.row();
|
||||
for (const QModelIndex &idx : ui_->list->selectionModel()->selectedRows()) {
|
||||
if (idx.isValid()) row_list << idx.row();
|
||||
}
|
||||
|
||||
current_playlist_->queue()->Remove(row_list);
|
||||
|
||||
Reference in New Issue
Block a user