Dont update temporary metadata while editing song with inline editor
This commit is contained in:
parent
2bf8187bff
commit
624a920aec
|
@ -1880,6 +1880,7 @@ void MainWindow::EditValue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_->playlist->view()->edit(current.sibling(current.row(), column));
|
ui_->playlist->view()->edit(current.sibling(current.row(), column));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddFile() {
|
void MainWindow::AddFile() {
|
||||||
|
|
|
@ -139,7 +139,8 @@ Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, Collecti
|
||||||
cancel_restore_(false),
|
cancel_restore_(false),
|
||||||
scrobbled_(false),
|
scrobbled_(false),
|
||||||
nowplaying_(false),
|
nowplaying_(false),
|
||||||
scrobble_point_(-1) {
|
scrobble_point_(-1),
|
||||||
|
editing_(-1) {
|
||||||
|
|
||||||
undo_stack_->setUndoLimit(kUndoStackSize);
|
undo_stack_->setUndoLimit(kUndoStackSize);
|
||||||
|
|
||||||
|
@ -1504,7 +1505,9 @@ void Playlist::SetStreamMetadata(const QUrl &url, const Song &song, const bool m
|
||||||
current_item()->SetTemporaryMetadata(song);
|
current_item()->SetTemporaryMetadata(song);
|
||||||
|
|
||||||
if (minor) {
|
if (minor) {
|
||||||
emit dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1));
|
if (editing_ != current_item_index_.row()) {
|
||||||
|
emit dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1));
|
||||||
|
}
|
||||||
// if the song is invalid, we won't play it - there's no point in informing anybody about the change
|
// if the song is invalid, we won't play it - there's no point in informing anybody about the change
|
||||||
const Song metadata(current_item_metadata());
|
const Song metadata(current_item_metadata());
|
||||||
if (metadata.is_valid()) {
|
if (metadata.is_valid()) {
|
||||||
|
|
|
@ -220,6 +220,7 @@ class Playlist : public QAbstractListModel {
|
||||||
bool nowplaying() const { return nowplaying_; }
|
bool nowplaying() const { return nowplaying_; }
|
||||||
void set_scrobbled(bool state) { scrobbled_ = state; }
|
void set_scrobbled(bool state) { scrobbled_ = state; }
|
||||||
void set_nowplaying(bool state) { nowplaying_ = state; }
|
void set_nowplaying(bool state) { nowplaying_ = state; }
|
||||||
|
void set_editing(const int row) { editing_ = row; }
|
||||||
qint64 scrobble_point_nanosec() const { return scrobble_point_; }
|
qint64 scrobble_point_nanosec() const { return scrobble_point_; }
|
||||||
void UpdateScrobblePoint(const qint64 seek_point_nanosec = 0);
|
void UpdateScrobblePoint(const qint64 seek_point_nanosec = 0);
|
||||||
|
|
||||||
|
@ -395,6 +396,8 @@ class Playlist : public QAbstractListModel {
|
||||||
bool nowplaying_;
|
bool nowplaying_;
|
||||||
qint64 scrobble_point_;
|
qint64 scrobble_point_;
|
||||||
|
|
||||||
|
int editing_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLAYLIST_H
|
#endif // PLAYLIST_H
|
||||||
|
|
|
@ -674,6 +674,16 @@ QModelIndex PlaylistView::PrevEditableIndex(const QModelIndex ¤t) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlaylistView::edit(const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event) {
|
||||||
|
|
||||||
|
bool result = QAbstractItemView::edit(index, trigger, event);
|
||||||
|
if (result && trigger == QAbstractItemView::AllEditTriggers && !event) {
|
||||||
|
playlist_->set_editing(index.row());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void PlaylistView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) {
|
void PlaylistView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) {
|
||||||
|
|
||||||
if (hint == QAbstractItemDelegate::NoHint) {
|
if (hint == QAbstractItemDelegate::NoHint) {
|
||||||
|
@ -693,13 +703,15 @@ void PlaylistView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHi
|
||||||
else {
|
else {
|
||||||
QTreeView::closeEditor(editor, QAbstractItemDelegate::NoHint);
|
QTreeView::closeEditor(editor, QAbstractItemDelegate::NoHint);
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
edit(index);
|
QAbstractItemView::edit(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QTreeView::closeEditor(editor, hint);
|
QTreeView::closeEditor(editor, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playlist_->set_editing(-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistView::mouseMoveEvent(QMouseEvent *event) {
|
void PlaylistView::mouseMoveEvent(QMouseEvent *event) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ class PlaylistHeader;
|
||||||
// This proxy style uses QCommonStyle to paint the affected elements.
|
// This proxy style uses QCommonStyle to paint the affected elements.
|
||||||
// This class is used by internet search view as well.
|
// This class is used by internet search view as well.
|
||||||
class PlaylistProxyStyle : public QProxyStyle {
|
class PlaylistProxyStyle : public QProxyStyle {
|
||||||
public:
|
public:
|
||||||
PlaylistProxyStyle(QStyle *base);
|
PlaylistProxyStyle(QStyle *base);
|
||||||
|
|
||||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
||||||
|
@ -121,6 +121,7 @@ class PlaylistView : public QTreeView {
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
void SetColumnAlignment(int section, Qt::Alignment alignment);
|
void SetColumnAlignment(int section, Qt::Alignment alignment);
|
||||||
void JumpToCurrentlyPlayingTrack();
|
void JumpToCurrentlyPlayingTrack();
|
||||||
|
void edit(const QModelIndex &index) { return QAbstractItemView::edit(index); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PlayItem(const QModelIndex &index);
|
void PlayItem(const QModelIndex &index);
|
||||||
|
@ -155,6 +156,7 @@ class PlaylistView : public QTreeView {
|
||||||
|
|
||||||
// QAbstractItemView
|
// QAbstractItemView
|
||||||
void rowsInserted(const QModelIndex &parent, int start, int end);
|
void rowsInserted(const QModelIndex &parent, int start, int end);
|
||||||
|
bool edit(const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event);
|
||||||
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
|
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in New Issue