feat: generate word list

main
mandlm 2024-03-20 10:16:46 +01:00
parent 42b8c8d7e7
commit e2f9b630c5
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
3 changed files with 33 additions and 1 deletions

View File

@ -33,7 +33,8 @@ else()
endif()
endif()
target_link_libraries(QVectorSearch PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(QVectorSearch PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
vector_search)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. If
# you are developing for iOS or macOS you should consider setting an explicit,

View File

@ -1,9 +1,32 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "timer.h"
#include "word_list_generator.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
ui->resultView->setModel(&result_model_);
generate_word_list();
}
MainWindow::~MainWindow() { delete ui; }
void MainWindow::generate_word_list() {
Timer timer;
word_list_ = WordListGenerator().generate();
timer.stop();
std::stringstream status_message;
status_message << "generated " << word_list_.size() << " words in " << timer;
ui->mainStatusBar->showMessage(QString::fromStdString(status_message.str()));
QStringList words;
for (auto word : word_list_) {
words.append(QString::fromStdString(word));
}
result_model_.setStringList(words);
}

View File

@ -2,6 +2,7 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include <QStringListModel>
QT_BEGIN_NAMESPACE
namespace Ui {
@ -12,10 +13,17 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow {
Q_OBJECT
private:
std::vector<std::string> word_list_;
QStringListModel result_model_;
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
void generate_word_list();
private:
Ui::MainWindow *ui;
};