| 1 | // File: byteconverterhex.cppcxx . . $ `<file>/byteconverterhex.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 "byteconverterhex.h"cxx . . $ `<file>/byteconverterhex.h`/ |
| 22 | #include "ui_byteconverterhex.h"cxx . . $ `<file>/ui_byteconverterhex.h`/ |
| 23 | #include <QTextCursor> |
| 24 | |
| 25 | ByteConverterHexcxx . . $ ByteConverterHex#::ByteConverterHexcxx . . $ ByteConverterHex#ByteConverterHex(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget# *parent) : |
| 26 | QWidgetcxx . . $ QWidget#QWidget(872e7b0c281abd8d).(parent), |
| 27 | uicxx . . $ ByteConverterHex#ui.(new Uicxx . . $ Ui/::ByteConverterHexcxx . . $ Ui/ByteConverterHex#) |
| 28 | { |
| 29 | uicxx . . $ ByteConverterHex#ui.->setupUicxx . . $ Ui_ByteConverterHex#setupUi(108f35f7aa7f3cf9).(this); |
| 30 | // Regular expression to validate 0x00 - 0xff |
| 31 | QRegExpcxx . . $ QRegExp# hexRxcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("0x([0-9]|[a-f]|[A-F])([0-9]|[a-f]|[A-F])"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 32 | hexValidatorcxx . . $ ByteConverterHex#hexValidator. = new QRegExpValidatorcxx . . $ QRegExpValidator#(hexRx, this); |
| 33 | uicxx . . $ ByteConverterHex#ui.->lineEditcxx . . $ Ui_ByteConverterHex#lineEdit.->setValidatorcxx . . $ QLineEdit#setValidator(65a0e52d19f97f21).(hexValidatorcxx . . $ ByteConverterHex#hexValidator.); |
| 34 | // Forward the textEdited() signal from ui->lineEdit up to the main window |
| 35 | connectcxx . . $ QObject#connect(158df1d9a01a3410).(uicxx . . $ ByteConverterHex#ui.->lineEditcxx . . $ Ui_ByteConverterHex#lineEdit., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(textEdited(const QString &)), this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(textEdited(const QString &))); |
| 36 | connectcxx . . $ QObject#connect(158df1d9a01a3410).(uicxx . . $ ByteConverterHex#ui.->lineEditcxx . . $ Ui_ByteConverterHex#lineEdit., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(cursorPositionChanged(int,int)), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(moveCursorAwayFromPrefix(int, int))); |
| 37 | |
| 38 | } |
| 39 | |
| 40 | ByteConverterHexcxx . . $ ByteConverterHex#::~cxx . . $ ByteConverterHex#`~ByteConverterHex`(ced63f7c635d850d).ByteConverterHexcxx . . $ ByteConverterHex#() |
| 41 | { |
| 42 | delete uicxx . . $ ByteConverterHex#ui.; |
| 43 | } |
| 44 | |
| 45 | void ByteConverterHexcxx . . $ ByteConverterHex#::setValuecxx . . $ ByteConverterHex#setValue(d4f767463ce0a6b3).(int value) |
| 46 | { |
| 47 | if (value == -1) { |
| 48 | uicxx . . $ ByteConverterHex#ui.->lineEditcxx . . $ Ui_ByteConverterHex#lineEdit.->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).("0x"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 49 | } |
| 50 | else { |
| 51 | uicxx . . $ ByteConverterHex#ui.->lineEditcxx . . $ Ui_ByteConverterHex#lineEdit.->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("0x%1").argcxx . . $ QString#arg(64ab2ed17cc11715).(value, 2, 16, QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('0'))); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void ByteConverterHexcxx . . $ ByteConverterHex#::moveCursorAwayFromPrefixcxx . . $ ByteConverterHex#moveCursorAwayFromPrefix(3e454b8ccf442868).(int old, int current) |
| 56 | { |
| 57 | if (current < 2) { |
| 58 | uicxx . . $ ByteConverterHex#ui.->lineEditcxx . . $ Ui_ByteConverterHex#lineEdit.->setCursorPositioncxx . . $ QLineEdit#setCursorPosition(d4f767463ce0a6b3).(old); |
| 59 | } |
| 60 | } |