big-change:添加两种类型结构读写支持

This commit is contained in:
2024-08-27 17:30:48 +08:00
parent ff68e756ff
commit b05783191f
20 changed files with 975 additions and 195 deletions

44
src/uhistory.cpp Normal file
View File

@@ -0,0 +1,44 @@
#include "uhistory.h"
#include "src/ui_uhistory.h"
#include "ui_uhistory.h"
CUIHistory::CUIHistory(QWidget* parent, CHistory* his) : QDialog(parent), ui(new Ui::CUIHistory)
{
ui->setupUi(this);
his_ = his;
connect(ui->btnExit, &QPushButton::clicked, this, [&]() { close(); });
connect(ui->btnOk, &QPushButton::clicked, this, [&]() { select_ok(); });
}
CUIHistory::~CUIHistory()
{
delete ui;
}
void CUIHistory::showEvent(QShowEvent* event)
{
std::vector<std::string> vec;
his_->get_history(vec);
QStringList list;
for (const auto& data : vec) {
list.append(QString::fromStdString(data));
}
if (!list.empty()) {
ui->listWidget->addItems(list);
}
cur_.clear();
QDialog::showEvent(event);
}
void CUIHistory::select_ok()
{
auto re = ui->listWidget->selectedItems();
if (re.empty()) {
return ;
}
cur_ = re[0]->text();
close();
}