Only allow playlist editing if song is editable
Set proper flags in model instead of overriding edit in view. Proper fix for #524
This commit is contained in:
parent
495c6bc21c
commit
22afcbcbb6
|
@ -645,13 +645,14 @@ void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const b
|
|||
|
||||
Qt::ItemFlags Playlist::flags(const QModelIndex &idx) const {
|
||||
|
||||
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
|
||||
if (column_is_editable(static_cast<Column>(idx.column()))) flags |= Qt::ItemIsEditable;
|
||||
|
||||
if (idx.isValid()) return flags | Qt::ItemIsDragEnabled;
|
||||
|
||||
return Qt::ItemIsDropEnabled;
|
||||
if (idx.isValid()) {
|
||||
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
|
||||
if (item_at(idx.row())->Metadata().IsEditable() && column_is_editable(static_cast<Column>(idx.column()))) flags |= Qt::ItemIsEditable;
|
||||
return flags;
|
||||
}
|
||||
else {
|
||||
return Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -704,11 +704,6 @@ QModelIndex PlaylistView::PrevEditableIndex(const QModelIndex ¤t) {
|
|||
|
||||
bool PlaylistView::edit(const QModelIndex &idx, QAbstractItemView::EditTrigger trigger, QEvent *event) {
|
||||
|
||||
// Only allow playlist editing if song is editable.
|
||||
if (trigger == QAbstractItemView::AllEditTriggers && !event && playlist_ && !playlist_->item_at(idx.row())->Metadata().IsEditable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = QAbstractItemView::edit(idx, trigger, event);
|
||||
if (result && trigger == QAbstractItemView::AllEditTriggers && !event) {
|
||||
playlist_->set_editing(idx.row());
|
||||
|
|
Loading…
Reference in New Issue