#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_readButton_clicked()
{
    bool ok;
    unsigned int addr = ui->addressLineEdit->text().toUInt(&ok);
    if (!ok) {
        QMessageBox::warning(this, "Napaka", "Neveljaven naslov!");
        return;
    }

    try {
        unsigned char val = m.readByte(addr);
        ui->valueLabel->setText(QString::number(val));
    } catch (const std::out_of_range &e) {
        QMessageBox::warning(this, "Napaka", "Naslov je izven meje pomnilnika!");
    }
}
