Remove ModelFutureWatcher

This commit is contained in:
John Maguire 2015-11-26 18:59:44 +00:00
parent 33494dcddc
commit 3cc9c1e446
5 changed files with 15 additions and 54 deletions

View File

@ -197,8 +197,17 @@ _detail::ClosureBase* NewClosure(QFuture<T> future, QObject* receiver,
QFutureWatcher<T>* watcher = new QFutureWatcher<T>;
watcher->setFuture(future);
QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater()));
return NewClosure(watcher, SIGNAL(finished()),
receiver, slot, future, args...);
return NewClosure(watcher, SIGNAL(finished()), receiver, slot, future,
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);

View File

@ -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_

View File

@ -47,7 +47,6 @@
#include "core/application.h"
#include "core/closure.h"
#include "core/logging.h"
#include "core/modelfuturewatcher.h"
#include "core/qhash_qurl.h"
#include "core/tagreaderclient.h"
#include "core/timeconstants.h"
@ -417,20 +416,13 @@ void Playlist::SongSaveComplete(TagReaderReply* reply,
const QPersistentModelIndex& index) {
if (reply->is_successful() && index.isValid()) {
QFuture<void> future = item_at(index.row())->BackgroundReload();
ModelFutureWatcher<void>* watcher =
new ModelFutureWatcher<void>(index, this);
watcher->setFuture(future);
connect(watcher, SIGNAL(finished()), SLOT(ItemReloadComplete()));
NewClosure(future, this, SLOT(ItemReloadComplete(QPersistentModelIndex)),
index);
}
reply->deleteLater();
}
void Playlist::ItemReloadComplete() {
ModelFutureWatcher<void>* watcher =
static_cast<ModelFutureWatcher<void>*>(sender());
watcher->deleteLater();
const QPersistentModelIndex& index = watcher->index();
void Playlist::ItemReloadComplete(const QPersistentModelIndex& index) {
if (index.isValid()) {
emit dataChanged(index, index);
emit EditingFinished(index);

View File

@ -393,7 +393,7 @@ signals:
void QueueLayoutChanged();
void SongSaveComplete(TagReaderReply* reply,
const QPersistentModelIndex& index);
void ItemReloadComplete();
void ItemReloadComplete(const QPersistentModelIndex& index);
void ItemsLoaded();
void SongInsertVetoListenerDestroyed();

View File

@ -53,7 +53,6 @@
#include "core/mac_startup.h"
#include "core/mergedproxymodel.h"
#include "core/mimedata.h"
#include "core/modelfuturewatcher.h"
#include "core/mpris_common.h"
#include "core/network.h"
#include "core/player.h"