game_list: Use QT5's new event connection syntax

Makes for more compact code in most places.
This commit is contained in:
Lioncash 2016-12-10 21:20:34 -05:00 committed by linkmauve
parent fd3d56740e
commit dd4582f85d
1 changed files with 6 additions and 6 deletions

View File

@ -34,8 +34,7 @@ GameList::GameList(QWidget* parent) : QWidget{parent} {
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type"); item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type");
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size"); item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size");
connect(tree_view, SIGNAL(activated(const QModelIndex&)), this, connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry);
SLOT(ValidateEntry(const QModelIndex&)));
// We must register all custom types with the Qt Automoc system so that we are able to use it // We must register all custom types with the Qt Automoc system so that we are able to use it
// with // with
@ -86,12 +85,13 @@ void GameList::PopulateAsync(const QString& dir_path, bool deep_scan) {
emit ShouldCancelWorker(); emit ShouldCancelWorker();
GameListWorker* worker = new GameListWorker(dir_path, deep_scan); GameListWorker* worker = new GameListWorker(dir_path, deep_scan);
connect(worker, SIGNAL(EntryReady(QList<QStandardItem*>)), this, connect(worker, &GameListWorker::EntryReady, this, &GameList::AddEntry, Qt::QueuedConnection);
SLOT(AddEntry(QList<QStandardItem*>)), Qt::QueuedConnection); connect(worker, &GameListWorker::Finished, this, &GameList::DonePopulating,
connect(worker, SIGNAL(Finished()), this, SLOT(DonePopulating()), Qt::QueuedConnection); Qt::QueuedConnection);
// Use DirectConnection here because worker->Cancel() is thread-safe and we want it to cancel // Use DirectConnection here because worker->Cancel() is thread-safe and we want it to cancel
// without delay. // without delay.
connect(this, SIGNAL(ShouldCancelWorker()), worker, SLOT(Cancel()), Qt::DirectConnection); connect(this, &GameList::ShouldCancelWorker, worker, &GameListWorker::Cancel,
Qt::DirectConnection);
QThreadPool::globalInstance()->start(worker); QThreadPool::globalInstance()->start(worker);
current_worker = std::move(worker); current_worker = std::move(worker);