-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathIOViewDlgImpl.cpp
144 lines (124 loc) · 4.75 KB
/
IOViewDlgImpl.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
Copyright (C) 2000,2001 Stefan Duffner
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <QCloseEvent>
#include "IOViewDlgImpl.h"
#include "MainWindow.h"
/**
* Constructs a IOViewDlgImpl which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
IOViewDlgImpl::IOViewDlgImpl(QWidget *parent, const char *name, bool modal,
Qt::WFlags fl)
: QDialog(parent, name, modal, fl) {
ioViewDlg.setupUi(this);
main = (MainWindow *)parent;
}
/**
* Destroys the object and frees any allocated resources
*/
IOViewDlgImpl::~IOViewDlgImpl() {}
/**
* Updates the list.
* Emits the closing signal and hides the dialog.
*/
void IOViewDlgImpl::updateIOList(Machine *m) {
QStringList list;
QString joinedList;
QRect dialogGeometry;
int vertSize = 0, horzSize = 180;
QFontMetrics fontSize(QFont("DejaVu Sans", 9, 400, false));
content = tr("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style "
"type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:'DejaVu Sans'; "
"font-size:9pt; font-weight:400; font-style:normal;\">\n");
if (m->getNumInputs() > 0) {
list = m->getInputNameList();
joinedList = list.join(",");
content +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span "
"style=\" font-weight:600;\">Inputs:</span></p>\n";
content +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px; "
"font-weight:600;\"><span style=\" font-weight:400;\">";
content += joinedList;
content += "</span></p>\n";
vertSize += 40;
if (horzSize < fontSize.width(joinedList))
horzSize = fontSize.width(joinedList);
}
if (m->getNumOutputs() > 0) {
list = m->getOutputNameList();
joinedList = list.join(",");
content +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span "
"style=\" font-weight:600;\">Mealy Outputs:</span></p>\n";
content +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px; "
"font-weight:600;\"><span style=\" font-weight:400;\">";
content += joinedList;
content += "</span></p>\n";
vertSize += 40;
if (horzSize < fontSize.width(joinedList))
horzSize = fontSize.width(joinedList);
}
if (m->getNumMooreOutputs() > 0) {
list = m->getMooreOutputList();
joinedList = list.join(",");
content +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span "
"style=\" font-weight:600;\">Moore Outputs:</span></p>\n";
content +=
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
"margin-right:0px; -qt-block-indent:0; text-indent:0px; "
"font-weight:600;\"><span style=\" font-weight:400;\">";
content += joinedList;
content += "</span></p>\n";
vertSize += 40;
if (horzSize < fontSize.width(joinedList))
horzSize = fontSize.width(joinedList);
}
content += "</body></html>";
ioViewDlg.textBrowser->setHtml(content);
dialogGeometry = geometry();
dialogGeometry.setWidth(horzSize + 40);
dialogGeometry.setHeight(vertSize + 40);
setGeometry(dialogGeometry);
}
/**
* Is invoked when the window is shown.
* Updates the text of the text browser.
*/
void IOViewDlgImpl::showEvent(QShowEvent *) {
ioViewDlg.textBrowser->setHtml(content);
}
/**
* Is invoked when the user closes the window.
* Emits the closing signal and hides the dialog.
*/
void IOViewDlgImpl::closeEvent(QCloseEvent *e) {
emit closing();
e->accept();
}