Another fix

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2022-11-02 09:31:39 +00:00
parent 6c45a990ef
commit a1ed8154f7

View File

@ -282,27 +282,31 @@ void ModPage::openUrl(const QUrl& url)
dialog->selectPage(page); dialog->selectPage(page);
ModPage* newPage = dialog->getSelectedPage(); ModPage* newPage = dialog->getSelectedPage();
newPage->ui->searchEdit->setText(slug); QLineEdit* searchEdit = newPage->ui->searchEdit;
newPage->triggerSearch();
ModPlatform::ListModel* model = newPage->listModel; if (searchEdit->text() != slug) {
QListView* view = newPage->ui->packView; searchEdit->setText(slug);
newPage->triggerSearch();
connect(model->activeJob(), &Task::finished, [url, slug, model, view] { ModPlatform::ListModel* model = newPage->listModel;
for (int row = 0; row < model->rowCount({}); row++) { QListView* view = newPage->ui->packView;
QModelIndex index = model->index(row);
auto pack = model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack>(); connect(model->activeJob(), &Task::finished, [url, slug, model, view] {
if (pack.slug == slug) { for (int row = 0; row < model->rowCount({}); row++) {
view->setCurrentIndex(index); QModelIndex index = model->index(row);
return; auto pack = model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack>();
if (pack.slug == slug) {
view->setCurrentIndex(index);
return;
}
} }
}
// The final fallback. // The final fallback.
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
}); });
return; return;
}
} }
} }