feat: generate word list
This commit is contained in:
parent
42b8c8d7e7
commit
e2f9b630c5
3 changed files with 33 additions and 1 deletions
|
@ -33,7 +33,8 @@ else()
|
||||||
endif()
|
endif()
|
||||||
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
|
# 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,
|
# you are developing for iOS or macOS you should consider setting an explicit,
|
||||||
|
|
|
@ -1,9 +1,32 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
|
|
||||||
|
#include "timer.h"
|
||||||
|
#include "word_list_generator.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->resultView->setModel(&result_model_);
|
||||||
|
|
||||||
|
generate_word_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() { delete ui; }
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QStringListModel>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -12,10 +13,17 @@ QT_END_NAMESPACE
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::string> word_list_;
|
||||||
|
QStringListModel result_model_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void generate_word_list();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue