diff --git a/AppleSAWS.pro b/AppleSAWS.pro
index b74977d..038e4b5 100644
--- a/AppleSAWS.pro
+++ b/AppleSAWS.pro
@@ -53,7 +53,8 @@ SOURCES += \
src/binaryfile/binaryfilemetadata.cpp \
src/util/charset.cpp \
src/ui/widgets/characterwidget.cpp \
- src/ui/viewers/applesoftfiledetailviewer.cpp
+ src/ui/viewers/applesoftfiledetailviewer.cpp \
+ src/ui/widgets/hexconverter.cpp
HEADERS += \
@@ -87,7 +88,8 @@ HEADERS += \
src/ui/widgets/characterwidget.h \
src/util/charset.h \
src/ui/viewers/charsetviewer.h \
- src/ui/viewers/applesoftfiledetailviewer.h
+ src/ui/viewers/applesoftfiledetailviewer.h \
+ src/ui/widgets/hexconverter.h
FORMS += \
src/ui/catalogwidget.ui \
@@ -96,4 +98,5 @@ FORMS += \
src/ui/viewers/disassemblerviewer.ui \
src/ui/viewers/hexdumpviewer.ui \
src/ui/viewers/texthexdumpviewer.ui \
- src/ui/viewers/applesoftfiledetailviewer.ui
+ src/ui/viewers/applesoftfiledetailviewer.ui \
+ src/ui/widgets/hexconverter.ui
diff --git a/src/ui/mainwindow.cxx b/src/ui/mainwindow.cxx
index 147830b..21f6070 100644
--- a/src/ui/mainwindow.cxx
+++ b/src/ui/mainwindow.cxx
@@ -44,6 +44,10 @@ MainWindow::MainWindow(QWidget *parent) :
ui->catalogWidget, SLOT(processNewlyLoadedDisk(QString,DiskFile*)));
connect(this, SIGNAL(diskFileUnloading(DiskFile*)),
ui->catalogWidget, SLOT(unloadDisk(DiskFile*)));
+
+
+ m_hexConverter = new HexConverter(this);
+ connect(ui->action_Hex_Converter, SIGNAL(triggered()), m_hexConverter, SLOT(show()));
}
MainWindow::~MainWindow()
diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h
index d64f218..8aafd80 100644
--- a/src/ui/mainwindow.h
+++ b/src/ui/mainwindow.h
@@ -7,6 +7,7 @@
#include "binaryfile.h"
#include "applesoftfile.h"
//#include "relocatablefile.h"
+#include "hexconverter.h"
namespace Ui {
@@ -46,6 +47,7 @@ protected:
void openInCharSetViewer(BinaryFile *file);
private:
Ui::MainWindow *ui;
+ HexConverter *m_hexConverter;
DiskFile *m_disk;
};
diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui
index e7a5165..b1be53f 100644
--- a/src/ui/mainwindow.ui
+++ b/src/ui/mainwindow.ui
@@ -45,7 +45,7 @@
0
0
273
- 20
+ 21
+
+
@@ -86,6 +93,11 @@
&Unload Disk Image
+
+
+ &Hex Converter...
+
+
diff --git a/src/ui/viewers/applesoftfiledetailviewer.cpp b/src/ui/viewers/applesoftfiledetailviewer.cpp
index bfdeb7d..95c00d1 100644
--- a/src/ui/viewers/applesoftfiledetailviewer.cpp
+++ b/src/ui/viewers/applesoftfiledetailviewer.cpp
@@ -4,6 +4,7 @@
#include
#include
#include
+#include
ApplesoftFileDetailViewer::ApplesoftFileDetailViewer(QWidget *parent) :
@@ -66,9 +67,17 @@ void ApplesoftFileDetailViewer::process()
default: vtname = "Unknown";
}
- ui->m_varView->setItem(idx,0,new QTableWidgetItem(vtname));
- ui->m_varView->setItem(idx,1,new QTableWidgetItem(key));
- ui->m_varView->setItem(idx,2,new QTableWidgetItem(linenums));
+ QTableWidgetItem *twi = new QTableWidgetItem(vtname);
+ twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ ui->m_varView->setItem(idx,0,twi);
+
+ twi = new QTableWidgetItem(key);
+ twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ ui->m_varView->setItem(idx,1,twi);
+
+ twi = new QTableWidgetItem(linenums);
+ twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ ui->m_varView->setItem(idx,2,twi);
idx++;
}
diff --git a/src/ui/widgets/hexconverter.cpp b/src/ui/widgets/hexconverter.cpp
new file mode 100644
index 0000000..1df1283
--- /dev/null
+++ b/src/ui/widgets/hexconverter.cpp
@@ -0,0 +1,100 @@
+#include "hexconverter.h"
+#include "ui_hexconverter.h"
+#include
+
+HexConverter::HexConverter(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::HexConverter)
+{
+ ui->setupUi(this);
+
+ ui->uint8LineEdit->setValidator(new QIntValidator(0,255));
+ ui->int8LineEdit->setValidator(new QIntValidator(-128,127));
+ ui->uint16LineEdit->setValidator(new QIntValidator(0,65535));
+ ui->int16LineEdit->setValidator(new QIntValidator(-32768,32767));
+
+ connect(ui->hexLineEdit, SIGNAL(textEdited(QString)), SLOT(calcFromNewHex(QString)));
+ connect(ui->uint8LineEdit, SIGNAL(textEdited(QString)), SLOT(calcFromNewUint8(QString)));
+ connect(ui->int8LineEdit, SIGNAL(textEdited(QString)), SLOT(calcFromNewInt8(QString)));
+ connect(ui->uint16LineEdit, SIGNAL(textEdited(QString)), SLOT(calcFromNewUint16(QString)));
+ connect(ui->int16LineEdit, SIGNAL(textEdited(QString)), SLOT(calcFromNewInt16(QString)));
+}
+
+HexConverter::~HexConverter()
+{
+ delete ui;
+}
+
+void HexConverter::calcFromNewHex(QString value)
+{
+ bool ok = true;
+ quint16 ui16 = value.toInt(&ok,16);
+ qint16 i16 = ui16;
+ quint8 ui8 = ui16;
+ qint8 i8 = ui16;
+
+ ui->uint16LineEdit->setText(QString::number(ui16));
+ ui->int16LineEdit->setText(QString::number(i16));
+ ui->uint8LineEdit->setText(QString::number(ui8));
+ ui->int8LineEdit->setText(QString::number(i8));
+}
+
+void HexConverter::calcFromNewUint16(QString value)
+{
+ bool ok = true;
+ quint16 ui16 = value.toInt(&ok);
+ qint16 i16 = ui16;
+ quint8 ui8 = ui16;
+ qint8 i8 = ui16;
+ QString hex = QString::number(ui16,16);
+
+ ui->int16LineEdit->setText(QString::number(i16));
+ ui->uint8LineEdit->setText(QString::number(ui8));
+ ui->int8LineEdit->setText(QString::number(i8));
+ ui->hexLineEdit->setText(hex);
+}
+
+void HexConverter::calcFromNewInt16(QString value)
+{
+ bool ok = true;
+ qint16 i16 = value.toInt(&ok);
+ quint16 ui16 = i16;
+ quint8 ui8 = i16;
+ qint8 i8 = i16;
+ QString hex = QString::number(ui16,16);
+
+ ui->uint16LineEdit->setText(QString::number(ui16));
+ ui->uint8LineEdit->setText(QString::number(ui8));
+ ui->int8LineEdit->setText(QString::number(i8));
+ ui->hexLineEdit->setText(hex);
+}
+
+void HexConverter::calcFromNewUint8(QString value)
+{
+ bool ok = true;
+ quint8 ui8 = value.toInt(&ok);
+ quint16 ui16 = ui8;
+ qint16 i16 = ui16;
+ qint8 i8 = ui16;
+ QString hex = QString::number(ui16,16);
+
+ ui->uint16LineEdit->setText(QString::number(ui16));
+ ui->int16LineEdit->setText(QString::number(i16));
+ ui->int8LineEdit->setText(QString::number(i8));
+ ui->hexLineEdit->setText(hex);
+}
+
+void HexConverter::calcFromNewInt8(QString value)
+{
+ bool ok = true;
+ qint8 i8 = value.toInt(&ok);
+ quint8 ui8 = i8;
+ quint16 ui16 = ui8;
+ qint16 i16 = ui16;
+ QString hex = QString::number(ui16,16);
+
+ ui->uint16LineEdit->setText(QString::number(ui16));
+ ui->int16LineEdit->setText(QString::number(i16));
+ ui->uint8LineEdit->setText(QString::number(ui8));
+ ui->hexLineEdit->setText(hex);
+}
diff --git a/src/ui/widgets/hexconverter.h b/src/ui/widgets/hexconverter.h
new file mode 100644
index 0000000..fd4f354
--- /dev/null
+++ b/src/ui/widgets/hexconverter.h
@@ -0,0 +1,29 @@
+#ifndef HEXCONVERTER_H
+#define HEXCONVERTER_H
+
+#include
+
+namespace Ui {
+class HexConverter;
+}
+
+class HexConverter : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit HexConverter(QWidget *parent = 0);
+ ~HexConverter();
+
+public slots:
+ void calcFromNewUint16(QString value);
+ void calcFromNewInt16(QString value);
+ void calcFromNewHex(QString value);
+ void calcFromNewUint8(QString value);
+ void calcFromNewInt8(QString value);
+protected slots:
+private:
+ Ui::HexConverter *ui;
+};
+
+#endif // HEXCONVERTER_H
diff --git a/src/ui/widgets/hexconverter.ui b/src/ui/widgets/hexconverter.ui
new file mode 100644
index 0000000..7db65e2
--- /dev/null
+++ b/src/ui/widgets/hexconverter.ui
@@ -0,0 +1,79 @@
+
+
+ HexConverter
+
+
+
+ 0
+ 0
+ 247
+ 113
+
+
+
+ HexConverter
+
+
+ -
+
+
-
+
+
+ Hex
+
+
+
+ -
+
+
+ UInt16
+
+
+
+ -
+
+
+ Int16
+
+
+
+ -
+
+
+ HHHH
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ Uint8
+
+
+
+ -
+
+
+ Int8
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+
+