Remove ModelFutureWatcher
This commit is contained in:
parent
33494dcddc
commit
3cc9c1e446
|
@ -197,8 +197,17 @@ _detail::ClosureBase* NewClosure(QFuture<T> future, QObject* receiver,
|
||||||
QFutureWatcher<T>* watcher = new QFutureWatcher<T>;
|
QFutureWatcher<T>* watcher = new QFutureWatcher<T>;
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater()));
|
QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater()));
|
||||||
return NewClosure(watcher, SIGNAL(finished()),
|
return NewClosure(watcher, SIGNAL(finished()), receiver, slot, future,
|
||||||
receiver, slot, future, args...);
|
args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
_detail::ClosureBase* NewClosure(QFuture<void> future, QObject* receiver,
|
||||||
|
const char* slot, const Args&... args) {
|
||||||
|
QFutureWatcher<void>* watcher = new QFutureWatcher<void>;
|
||||||
|
watcher->setFuture(future);
|
||||||
|
QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater()));
|
||||||
|
return NewClosure(watcher, SIGNAL(finished()), receiver, slot, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoAfter(QObject* receiver, const char* slot, int msec);
|
void DoAfter(QObject* receiver, const char* slot, int msec);
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/* This file is part of Clementine.
|
|
||||||
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
|
|
||||||
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Clementine is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CORE_MODELFUTUREWATCHER_H_
|
|
||||||
#define CORE_MODELFUTUREWATCHER_H_
|
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
|
||||||
#include <QPersistentModelIndex>
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class ModelFutureWatcher : public QFutureWatcher<T> {
|
|
||||||
public:
|
|
||||||
explicit ModelFutureWatcher(const QModelIndex& index, QObject* parent = nullptr)
|
|
||||||
: QFutureWatcher<T>(parent), index_(index) {}
|
|
||||||
|
|
||||||
~ModelFutureWatcher() {}
|
|
||||||
|
|
||||||
const QPersistentModelIndex& index() const { return index_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPersistentModelIndex index_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CORE_MODELFUTUREWATCHER_H_
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/closure.h"
|
#include "core/closure.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "core/modelfuturewatcher.h"
|
|
||||||
#include "core/qhash_qurl.h"
|
#include "core/qhash_qurl.h"
|
||||||
#include "core/tagreaderclient.h"
|
#include "core/tagreaderclient.h"
|
||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
|
@ -417,20 +416,13 @@ void Playlist::SongSaveComplete(TagReaderReply* reply,
|
||||||
const QPersistentModelIndex& index) {
|
const QPersistentModelIndex& index) {
|
||||||
if (reply->is_successful() && index.isValid()) {
|
if (reply->is_successful() && index.isValid()) {
|
||||||
QFuture<void> future = item_at(index.row())->BackgroundReload();
|
QFuture<void> future = item_at(index.row())->BackgroundReload();
|
||||||
ModelFutureWatcher<void>* watcher =
|
NewClosure(future, this, SLOT(ItemReloadComplete(QPersistentModelIndex)),
|
||||||
new ModelFutureWatcher<void>(index, this);
|
index);
|
||||||
watcher->setFuture(future);
|
|
||||||
connect(watcher, SIGNAL(finished()), SLOT(ItemReloadComplete()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::ItemReloadComplete() {
|
void Playlist::ItemReloadComplete(const QPersistentModelIndex& index) {
|
||||||
ModelFutureWatcher<void>* watcher =
|
|
||||||
static_cast<ModelFutureWatcher<void>*>(sender());
|
|
||||||
watcher->deleteLater();
|
|
||||||
const QPersistentModelIndex& index = watcher->index();
|
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
emit EditingFinished(index);
|
emit EditingFinished(index);
|
||||||
|
|
|
@ -393,7 +393,7 @@ signals:
|
||||||
void QueueLayoutChanged();
|
void QueueLayoutChanged();
|
||||||
void SongSaveComplete(TagReaderReply* reply,
|
void SongSaveComplete(TagReaderReply* reply,
|
||||||
const QPersistentModelIndex& index);
|
const QPersistentModelIndex& index);
|
||||||
void ItemReloadComplete();
|
void ItemReloadComplete(const QPersistentModelIndex& index);
|
||||||
void ItemsLoaded();
|
void ItemsLoaded();
|
||||||
void SongInsertVetoListenerDestroyed();
|
void SongInsertVetoListenerDestroyed();
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#include "core/mac_startup.h"
|
#include "core/mac_startup.h"
|
||||||
#include "core/mergedproxymodel.h"
|
#include "core/mergedproxymodel.h"
|
||||||
#include "core/mimedata.h"
|
#include "core/mimedata.h"
|
||||||
#include "core/modelfuturewatcher.h"
|
|
||||||
#include "core/mpris_common.h"
|
#include "core/mpris_common.h"
|
||||||
#include "core/network.h"
|
#include "core/network.h"
|
||||||
#include "core/player.h"
|
#include "core/player.h"
|
||||||
|
|
Loading…
Reference in New Issue