big-change:添加两种类型结构读写支持
This commit is contained in:
44
src/uhistory.cpp
Normal file
44
src/uhistory.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user