Remove NewClosure
This commit is contained in:
@@ -23,8 +23,9 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtConcurrentRun>
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
|
||||
#include "core/closure.h"
|
||||
#include "core/taskmanager.h"
|
||||
|
||||
#include "playlist/playlist.h"
|
||||
@@ -67,13 +68,17 @@ void PlaylistGeneratorInserter::Load(Playlist *destination, const int row, const
|
||||
QObject::connect(generator.get(), &PlaylistGenerator::Error, this, &PlaylistGeneratorInserter::Error);
|
||||
|
||||
QFuture<PlaylistItemList> future = QtConcurrent::run(PlaylistGeneratorInserter::Generate, generator, dynamic_count);
|
||||
NewClosure(future, this, SLOT(Finished(QFuture<PlaylistItemList>)), future);
|
||||
QFutureWatcher<PlaylistItemList> *watcher = new QFutureWatcher<PlaylistItemList>();
|
||||
watcher->setFuture(future);
|
||||
QObject::connect(watcher, &QFutureWatcher<PlaylistItemList>::finished, this, &PlaylistGeneratorInserter::Finished);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistGeneratorInserter::Finished(QFuture<PlaylistItemList> future) {
|
||||
void PlaylistGeneratorInserter::Finished() {
|
||||
|
||||
PlaylistItemList items = future.result();
|
||||
QFutureWatcher<PlaylistItemList> *watcher = static_cast<QFutureWatcher<PlaylistItemList>*>(sender());
|
||||
PlaylistItemList items = watcher->result();
|
||||
watcher->deleteLater();
|
||||
|
||||
if (items.isEmpty()) {
|
||||
if (is_dynamic_) {
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QFuture>
|
||||
#include <QString>
|
||||
|
||||
#include "playlist/playlist.h"
|
||||
@@ -52,7 +51,7 @@ class PlaylistGeneratorInserter : public QObject {
|
||||
void PlayRequested(QModelIndex idx, Playlist::AutoScroll autoscroll);
|
||||
|
||||
private slots:
|
||||
void Finished(QFuture<PlaylistItemList> future);
|
||||
void Finished();
|
||||
|
||||
private:
|
||||
TaskManager *task_manager_;
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
#include <QAbstractItemView>
|
||||
#include <QString>
|
||||
#include <QtConcurrentRun>
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
|
||||
#include "smartplaylistsearchpreview.h"
|
||||
#include "ui_smartplaylistsearchpreview.h"
|
||||
|
||||
#include "core/closure.h"
|
||||
#include "playlist/playlist.h"
|
||||
#include "playlistquerygenerator.h"
|
||||
|
||||
@@ -115,11 +116,17 @@ void SmartPlaylistSearchPreview::RunSearch(const SmartPlaylistSearch &search) {
|
||||
ui_->busy_container->show();
|
||||
ui_->count_label->hide();
|
||||
QFuture<PlaylistItemList> future = QtConcurrent::run(DoRunSearch, generator_);
|
||||
NewClosure(future, this, SLOT(SearchFinished(QFuture<PlaylistItemList>)), future);
|
||||
QFutureWatcher<PlaylistItemList> *watcher = new QFutureWatcher<PlaylistItemList>();
|
||||
watcher->setFuture(future);
|
||||
QObject::connect(watcher, &QFutureWatcher<PlaylistItemList>::finished, this, &SmartPlaylistSearchPreview::SearchFinished);
|
||||
|
||||
}
|
||||
|
||||
void SmartPlaylistSearchPreview::SearchFinished(QFuture<PlaylistItemList> future) {
|
||||
void SmartPlaylistSearchPreview::SearchFinished() {
|
||||
|
||||
QFutureWatcher<PlaylistItemList> *watcher = static_cast<QFutureWatcher<PlaylistItemList>*>(sender());
|
||||
PlaylistItemList all_items = watcher->result();
|
||||
watcher->deleteLater();
|
||||
|
||||
last_search_ = std::dynamic_pointer_cast<PlaylistQueryGenerator>(generator_)->search();
|
||||
generator_.reset();
|
||||
@@ -132,7 +139,6 @@ void SmartPlaylistSearchPreview::SearchFinished(QFuture<PlaylistItemList> future
|
||||
return;
|
||||
}
|
||||
|
||||
PlaylistItemList all_items = future.result();
|
||||
PlaylistItemList displayed_items = all_items.mid(0, PlaylistGenerator::kDefaultLimit);
|
||||
|
||||
model_->Clear();
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFuture>
|
||||
#include <QList>
|
||||
|
||||
#include "smartplaylistsearch.h"
|
||||
@@ -56,7 +55,7 @@ class SmartPlaylistSearchPreview : public QWidget {
|
||||
void RunSearch(const SmartPlaylistSearch &search);
|
||||
|
||||
private slots:
|
||||
void SearchFinished(QFuture<PlaylistItemList> future);
|
||||
void SearchFinished();
|
||||
|
||||
private:
|
||||
Ui_SmartPlaylistSearchPreview *ui_;
|
||||
|
||||
Reference in New Issue
Block a user