-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowwidget.cpp
More file actions
38 lines (28 loc) · 889 Bytes
/
showwidget.cpp
File metadata and controls
38 lines (28 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "showwidget.h"
#include "ui_showwidget.h"
#include "showdialog.h"
ShowWidget::ShowWidget(const std::vector<Expr>& v,QWidget *parent)
: QWidget(parent)
, ui(new Ui::ShowWidget)
{
ui->setupUi(this);
for(size_t i = 0; i < v.size(); ++i)
{
ui->listWidget->addItem(v[i].prefix);
}
expressions = v;
connect(ui->listWidget, &QListWidget::itemDoubleClicked,
this, [=](QListWidgetItem *item){
int row = ui->listWidget->row(item);
if(row >= 0 && row < static_cast<int>(expressions.size())) {
Expr& targetExpr = expressions[row];
ShowDialog *dlg = new ShowDialog(targetExpr, this);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->exec();
}
});
}
ShowWidget::~ShowWidget()
{
delete ui;
}