Use persistent model index.
This commit is contained in:
parent
992e0fb95e
commit
8166a50b2a
|
@ -2,7 +2,7 @@
|
|||
#define MODELFUTUREWATCHER_H
|
||||
|
||||
#include <QFutureWatcher>
|
||||
#include <QModelIndex>
|
||||
#include <QPersistentModelIndex>
|
||||
|
||||
template <typename T>
|
||||
class ModelFutureWatcher : public QFutureWatcher<T> {
|
||||
|
@ -15,10 +15,10 @@ class ModelFutureWatcher : public QFutureWatcher<T> {
|
|||
~ModelFutureWatcher() {
|
||||
}
|
||||
|
||||
const QModelIndex& index() const { return index_; }
|
||||
const QPersistentModelIndex& index() const { return index_; }
|
||||
|
||||
private:
|
||||
QModelIndex index_;
|
||||
QPersistentModelIndex index_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -251,10 +251,12 @@ bool Playlist::setData(const QModelIndex &index, const QVariant &value, int) {
|
|||
void Playlist::SongSaveComplete() {
|
||||
ModelFutureWatcher<bool>* watcher = static_cast<ModelFutureWatcher<bool>*>(sender());
|
||||
watcher->deleteLater();
|
||||
const QModelIndex& index = watcher->index();
|
||||
item_at(index.row())->Reload();
|
||||
emit dataChanged(index, index);
|
||||
emit EditingFinished(index);
|
||||
const QPersistentModelIndex& index = watcher->index();
|
||||
if (index.isValid()) {
|
||||
item_at(index.row())->Reload();
|
||||
emit dataChanged(index, index);
|
||||
emit EditingFinished(index);
|
||||
}
|
||||
}
|
||||
|
||||
int Playlist::current_index() const {
|
||||
|
|
Loading…
Reference in New Issue