Debian Codegraph @

byteconverterbin.cpp

raw symbols SCIP
1 // File: byteconverterbin.cpp
2 /*
3 Pep8-1 is a virtual machine for writing machine language and assembly
4 language programs.
5
6 Copyright (C) 2009 J. Stanley Warford, Pepperdine University
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "byteconverterbin.h"
22 #include "ui_byteconverterbin.h"
23
24 ByteConverterBin::ByteConverterBin(QWidget *parent) :
25 QWidget(parent),
26 ui(new Ui::ByteConverterBin)
27 {
28 ui->setupUi(this);
29 // Regular expression to validate a binary byte
30 QRegExp binRx("([0-1]{0,8})");
31 binValidator = new QRegExpValidator(binRx, this);
32 ui->lineEdit->setValidator(binValidator);
33 // Forward the textEdited() signal from ui->lineEdit up to the main window
34 QObject::connect(ui->lineEdit, SIGNAL(textEdited(const QString &)), this,
35 SIGNAL(textEdited(const QString &)));
36 }
37
38 ByteConverterBin::~ByteConverterBin()
39 {
40 delete ui;
41 }
42
43 void ByteConverterBin::setValue(int value)
44 {
45 ui->lineEdit->setText(QString("%1").arg(value, 8, 2, QLatin1Char('0')));
46 }