feat: use std::forward_list for results
This commit is contained in:
parent
510deb2d54
commit
ba460cc00a
8 changed files with 37 additions and 23 deletions
|
@ -7,8 +7,8 @@
|
|||
#include "timer.h"
|
||||
#include "word_list_generator.h"
|
||||
|
||||
#include <thread>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
|
@ -51,8 +51,8 @@ void MainWindow::search(const QString &search_term) {
|
|||
timer.stop();
|
||||
|
||||
std::stringstream status_message;
|
||||
status_message << "search took " << timer << ", found " << results.size()
|
||||
<< " results";
|
||||
status_message << "search took " << timer << ", found "
|
||||
<< std::distance(results.begin(), results.end()) << " results";
|
||||
ui->mainStatusBar->showMessage(QString::fromStdString(status_message.str()));
|
||||
|
||||
showResults(results);
|
||||
|
@ -71,7 +71,8 @@ std::unique_ptr<Finder> MainWindow::createSelectedFinder() const {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::showResults(const std::vector<const std::string *> &results) {
|
||||
void MainWindow::showResults(
|
||||
const std::forward_list<const std::string *> &results) {
|
||||
QStringList ui_results;
|
||||
for (auto word : results) {
|
||||
ui_results.append(QString::fromStdString(*word));
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
void generateWordList();
|
||||
void search(const QString &search_term);
|
||||
std::unique_ptr<Finder> createSelectedFinder() const;
|
||||
void showResults(const std::vector<const std::string *> &results);
|
||||
void showResults(const std::forward_list<const std::string *> &results);
|
||||
|
||||
private slots:
|
||||
void on_searchInput_textChanged(const QString &search_term);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue