This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemberDetailsDialog.cpp
58 lines (46 loc) · 2.13 KB
/
MemberDetailsDialog.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "MemberDetailsDialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "Utils.h"
MemberDetailsDialog::MemberDetailsDialog(const ClassMember &member, QWidget *parent)
: QDialog(parent), _member(member) {
// 移除问号
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
_memberDetailsLabel = new QLabel(this);
_deleteButton = new QPushButton(tr("Delete"), this);
_returnButton = new QPushButton(tr("Return"), this);
// 设定详细信息
QString details = QString(tr("ID: %1\nName: %2\nType: %3\nMemory: %4 bytes\nDataType: %5\nAccessibility: %6"))
.arg(member.memberId())
.arg(member.memberName())
.arg(member.memberType() == MemberType::Data ? "Data" : "Function")
.arg(member.memorySize())
.arg(member.dataType() == DataType::Int ? "Int" :
member.dataType() == DataType::Float ? "Float" :
member.dataType() == DataType::Double ? "Double" :
member.dataType() == DataType::Char ? "Char" :
member.dataType() == DataType::String ? "String" : "Custom")
.arg(member.accessibility() == Accessibility::Public ? "Public" :
member.accessibility() == Accessibility::Private ? "Private" : "Protected");
_memberDetailsLabel->setText(details);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(_memberDetailsLabel);
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addStretch();
buttonLayout->addWidget(_deleteButton);
buttonLayout->addWidget(_returnButton);
mainLayout->addLayout(buttonLayout);
connect(_deleteButton, &QPushButton::clicked, this, &MemberDetailsDialog::onDeleteButtonClicked);
connect(_returnButton, &QPushButton::clicked, this, &MemberDetailsDialog::onReturnButtonClicked);
setLayout(mainLayout);
resize(400, 300);
setWindowTitle(tr("Member Details"));
setWindowIcon(QIcon(ICON_PATH));
}
void MemberDetailsDialog::onDeleteButtonClicked() {
emit memberDeleted();
accept();
}
void MemberDetailsDialog::onReturnButtonClicked() {
reject();
}