checkpoint

This commit is contained in:
aljazbrodar. 2025-12-07 11:55:34 +01:00
parent 3c876211c2
commit bfa4a8cd72
60 changed files with 239 additions and 87 deletions

View file

@ -7,7 +7,7 @@
{
"build" : ".",
"hasInstallRule" : true,
"jsonFile" : "directory-.-Debug-37186cc2dcdc365a64e7.json",
"jsonFile" : "directory-.-Debug-b087ac99b4952b24d922.json",
"minimumCMakeVersion" :
{
"string" : "3.16"
@ -44,7 +44,7 @@
{
"directoryIndex" : 0,
"id" : "simulator::@6890427a1f51a3e7e1df",
"jsonFile" : "target-simulator-Debug-2b3217783aa5062c29e1.json",
"jsonFile" : "target-simulator-Debug-edef6bab040a42101471.json",
"name" : "simulator",
"projectIndex" : 0
},

View file

@ -17,13 +17,13 @@
{
"command" : 0,
"file" : 0,
"line" : 31,
"line" : 32,
"parent" : 0
},
{
"command" : 0,
"file" : 0,
"line" : 42,
"line" : 43,
"parent" : 0
}
]

View file

@ -71,13 +71,13 @@
{
"command" : 4,
"file" : 1,
"line" : 31,
"line" : 32,
"parent" : 0
},
{
"command" : 5,
"file" : 1,
"line" : 23,
"line" : 24,
"parent" : 0
},
{
@ -293,7 +293,8 @@
6,
8,
10,
12
12,
14
]
}
],
@ -384,8 +385,8 @@
"sourceIndexes" :
[
0,
13,
14
15,
16
]
},
{
@ -397,7 +398,8 @@
6,
8,
10,
12
12,
14
]
},
{
@ -408,7 +410,8 @@
5,
7,
9,
11
11,
13
]
},
{
@ -422,7 +425,7 @@
"name" : "CMake Rules",
"sourceIndexes" :
[
15
17
]
}
],
@ -501,6 +504,17 @@
"path" : "executor.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 4,
"path" : "loader.h",
"sourceGroupIndex" : 2
},
{
"backtrace" : 4,
"compileGroupIndex" : 0,
"path" : "loader.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 0,
"isGenerated" : true,

View file

@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-bf109316b2adb0d27109.json",
"jsonFile" : "codemodel-v2-9908d093f7d320a6f887.json",
"kind" : "codemodel",
"version" :
{
@ -77,7 +77,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-bf109316b2adb0d27109.json",
"jsonFile" : "codemodel-v2-9908d093f7d320a6f887.json",
"kind" : "codemodel",
"version" :
{

View file

@ -1,12 +1,42 @@
# ninja log v6
201 521 1765010356080064621 CMakeFiles/simulator.dir/device.cpp.o 36fc5c8cf014f45b
14 1383 1765010511012053000 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
3 12 1765104358285354663 simulator_autogen/timestamp c193a23cfe79571d
12 211 1765102701378556517 CMakeFiles/simulator.dir/executor.cpp.o 8cd2a28f3c211eaa
196 1272 1765103738453735097 CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o 5301f473905a545f
13 190 1765104358295354758 CMakeFiles/simulator.dir/loader.cpp.o 8371bb969cd708a5
13 1495 1765104358295354758 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
3 12 1765104358285354663 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
279 601 1765102522843450557 CMakeFiles/simulator.dir/machine.cpp.o 7030a03f8cbf1ad0
3 12 1765104358285354663 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
3 12 1765104358285354663 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
12 22 1765010490368890036 CMakeFiles/simulator.dir/opcode.cpp.o da65f589ec5e1f76
201 1347 1765010356080064621 CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o 5301f473905a545f
2 14 1765010511000055645 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
14 192 1765010511012053000 CMakeFiles/simulator.dir/machine.cpp.o 7030a03f8cbf1ad0
201 1336 1765010356080064621 CMakeFiles/simulator.dir/main.cpp.o 9ebba9b7abc4cbf1
2 14 1765010511000055645 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
1383 1623 1765010512380751634 simulator 9e4eca252dc331ef
2 14 1765010511000055645 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 14 1765010511000055645 simulator_autogen/timestamp c193a23cfe79571d
196 1727 1765103738453735097 CMakeFiles/simulator.dir/main.cpp.o 9ebba9b7abc4cbf1
201 521 1765010356080064621 CMakeFiles/simulator.dir/device.cpp.o 36fc5c8cf014f45b
1495 1755 1765104359777368855 simulator 53725ab159343a13
2 12 1765104478951331762 simulator_autogen/timestamp c193a23cfe79571d
2 12 1765104478951331762 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 12 1765104478951331762 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
2 12 1765104478951331762 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
13 189 1765104478962331836 CMakeFiles/simulator.dir/loader.cpp.o 8371bb969cd708a5
12 1581 1765104478961331830 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
1581 1820 1765104480530342428 simulator 53725ab159343a13
2 15 1765104546817746682 simulator_autogen/timestamp c193a23cfe79571d
2 15 1765104546817746682 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 15 1765104546817746682 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
2 15 1765104546817746682 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
15 195 1765104546830746753 CMakeFiles/simulator.dir/loader.cpp.o 8371bb969cd708a5
15 1567 1765104546830746753 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
1567 1813 1765104548382755242 simulator 53725ab159343a13
2 11 1765104771629589940 simulator_autogen/timestamp c193a23cfe79571d
2 11 1765104771629589940 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 11 1765104771629589940 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
2 11 1765104771629589940 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
12 182 1765104771639589962 CMakeFiles/simulator.dir/loader.cpp.o 8371bb969cd708a5
11 1545 1765104771638589960 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
1545 1789 1765104773172593404 simulator 53725ab159343a13
2 11 1765104802251653702 simulator_autogen/timestamp c193a23cfe79571d
2 11 1765104802251653702 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 11 1765104802251653702 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
2 11 1765104802251653702 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
12 181 1765104802261653722 CMakeFiles/simulator.dir/loader.cpp.o 8371bb969cd708a5
12 1544 1765104802261653722 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
1544 1779 1765104803793656641 simulator 53725ab159343a13

View file

@ -1,8 +1,20 @@
# Generated by CMake. Changes will be overwritten.
/home/aljaz/Desktop/spo/ass2/simulator/executor.cpp
/home/aljaz/Desktop/spo/ass2/simulator/loader.h
/home/aljaz/Desktop/spo/ass2/simulator/executor.h
/home/aljaz/Desktop/spo/ass2/simulator/mainwindow.cpp
uic:ui_mainwindow.h
/home/aljaz/Desktop/spo/ass2/simulator/device.cpp
/home/aljaz/Desktop/spo/ass2/simulator/opcode.cpp
/home/aljaz/Desktop/spo/ass2/simulator/main.cpp
/home/aljaz/Desktop/spo/ass2/simulator/device.h
/home/aljaz/Desktop/spo/ass2/simulator/loader.cpp
/home/aljaz/Desktop/spo/ass2/simulator/machine.h
/home/aljaz/Desktop/spo/ass2/simulator/mainwindow.h
mmc:Q_OBJECT
mdp:/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/moc_predefs.h
mdp:/home/aljaz/Desktop/spo/ass2/simulator/device.h
mdp:/home/aljaz/Desktop/spo/ass2/simulator/loader.h
mdp:/home/aljaz/Desktop/spo/ass2/simulator/machine.h
mdp:/home/aljaz/Desktop/spo/ass2/simulator/mainwindow.h
mdp:/home/aljaz/Qt/6.10.1/gcc_64/include/QtCore/q17memory.h
@ -454,12 +466,5 @@
mdp:/usr/lib/gcc/x86_64-linux-gnu/13/include/stdarg.h
mdp:/usr/lib/gcc/x86_64-linux-gnu/13/include/stdbool.h
mdp:/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h
/home/aljaz/Desktop/spo/ass2/simulator/machine.h
/home/aljaz/Desktop/spo/ass2/simulator/device.h
/home/aljaz/Desktop/spo/ass2/simulator/machine.cpp
/home/aljaz/Desktop/spo/ass2/simulator/opcode.h
/home/aljaz/Desktop/spo/ass2/simulator/main.cpp
/home/aljaz/Desktop/spo/ass2/simulator/opcode.cpp
/home/aljaz/Desktop/spo/ass2/simulator/mainwindow.cpp
uic:ui_mainwindow.h
/home/aljaz/Desktop/spo/ass2/simulator/device.cpp
/home/aljaz/Desktop/spo/ass2/simulator/machine.cpp

View file

@ -1,3 +1,3 @@
Start testing: Dec 07 09:37 CET
Start testing: Dec 07 11:47 CET
----------------------------------------------------------
End testing: Dec 07 09:37 CET
End testing: Dec 07 11:47 CET

View file

@ -40,12 +40,15 @@ template <> constexpr inline auto MainWindow::qt_create_metaobjectdata<qt_meta_t
QtMocHelpers::StringRefStorage qt_stringData {
"MainWindow",
"on_readButton_clicked",
""
"",
"onLoadTriggered"
};
QtMocHelpers::UintData qt_methods {
// Slot 'on_readButton_clicked'
QtMocHelpers::SlotData<void()>(1, 2, QMC::AccessPrivate, QMetaType::Void),
// Slot 'onLoadTriggered'
QtMocHelpers::SlotData<void()>(3, 2, QMC::AccessPrivate, QMetaType::Void),
};
QtMocHelpers::UintData qt_properties {
};
@ -70,6 +73,7 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: _t->on_readButton_clicked(); break;
case 1: _t->onLoadTriggered(); break;
default: ;
}
}
@ -95,14 +99,14 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
_id -= 2;
}
if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 1)
if (_id < 2)
*reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();
_id -= 1;
_id -= 2;
}
return _id;
}

View file

@ -1,6 +1,7 @@
/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/EWIEGA46WW/moc_mainwindow.cpp: /home/aljaz/Desktop/spo/ass2/simulator/mainwindow.h \
/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/moc_predefs.h \
/home/aljaz/Desktop/spo/ass2/simulator/device.h \
/home/aljaz/Desktop/spo/ass2/simulator/loader.h \
/home/aljaz/Desktop/spo/ass2/simulator/machine.h \
/home/aljaz/Qt/6.10.1/gcc_64/include/QtCore/q17memory.h \
/home/aljaz/Qt/6.10.1/gcc_64/include/QtCore/q20functional.h \

View file

@ -7,6 +7,10 @@ simulator_autogen/timestamp: \
/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/moc_predefs.h \
/home/aljaz/Desktop/spo/ass2/simulator/device.cpp \
/home/aljaz/Desktop/spo/ass2/simulator/device.h \
/home/aljaz/Desktop/spo/ass2/simulator/executor.cpp \
/home/aljaz/Desktop/spo/ass2/simulator/executor.h \
/home/aljaz/Desktop/spo/ass2/simulator/loader.cpp \
/home/aljaz/Desktop/spo/ass2/simulator/loader.h \
/home/aljaz/Desktop/spo/ass2/simulator/machine.cpp \
/home/aljaz/Desktop/spo/ass2/simulator/machine.h \
/home/aljaz/Desktop/spo/ass2/simulator/main.cpp \

View file

@ -46,11 +46,11 @@ public:
QGroupBox *groupBox_3;
QWidget *gridLayoutWidget_3;
QGridLayout *gridLayout_3;
QWidget *widget;
QWidget *layoutWidget;
QVBoxLayout *verticalLayout;
QLabel *label;
QTableWidget *tableWidget;
QWidget *widget1;
QWidget *layoutWidget1;
QHBoxLayout *horizontalLayout_2;
QHBoxLayout *horizontalLayout;
QLineEdit *addressLineEdit;
@ -60,7 +60,7 @@ public:
QPushButton *pushButton_2;
QPushButton *pushButton;
QMenuBar *menubar;
QMenu *menuMenu;
QMenu *menuLoad;
QMenu *menuVizitka;
QStatusBar *statusbar;
@ -68,7 +68,7 @@ public:
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName("MainWindow");
MainWindow->resize(1657, 915);
MainWindow->resize(844, 757);
actionExit = new QAction(MainWindow);
actionExit->setObjectName("actionExit");
centralwidget = new QWidget(MainWindow);
@ -110,18 +110,18 @@ public:
gridLayout_3 = new QGridLayout(gridLayoutWidget_3);
gridLayout_3->setObjectName("gridLayout_3");
gridLayout_3->setContentsMargins(0, 0, 0, 0);
widget = new QWidget(centralwidget);
widget->setObjectName("widget");
widget->setGeometry(QRect(1070, 190, 581, 641));
verticalLayout = new QVBoxLayout(widget);
layoutWidget = new QWidget(centralwidget);
layoutWidget->setObjectName("layoutWidget");
layoutWidget->setGeometry(QRect(240, 20, 581, 641));
verticalLayout = new QVBoxLayout(layoutWidget);
verticalLayout->setObjectName("verticalLayout");
verticalLayout->setContentsMargins(0, 0, 0, 0);
label = new QLabel(widget);
label = new QLabel(layoutWidget);
label->setObjectName("label");
verticalLayout->addWidget(label);
tableWidget = new QTableWidget(widget);
tableWidget = new QTableWidget(layoutWidget);
if (tableWidget->columnCount() < 16)
tableWidget->setColumnCount(16);
if (tableWidget->rowCount() < 40)
@ -134,30 +134,30 @@ public:
tableWidget->horizontalHeader()->setDefaultSectionSize(34);
tableWidget->horizontalHeader()->setProperty("showSortIndicator", QVariant(false));
tableWidget->verticalHeader()->setMinimumSectionSize(14);
tableWidget->verticalHeader()->setDefaultSectionSize(3);
tableWidget->verticalHeader()->setDefaultSectionSize(14);
tableWidget->verticalHeader()->setHighlightSections(true);
verticalLayout->addWidget(tableWidget);
widget1 = new QWidget(centralwidget);
widget1->setObjectName("widget1");
widget1->setGeometry(QRect(1070, 850, 571, 27));
horizontalLayout_2 = new QHBoxLayout(widget1);
layoutWidget1 = new QWidget(centralwidget);
layoutWidget1->setObjectName("layoutWidget1");
layoutWidget1->setGeometry(QRect(240, 680, 571, 27));
horizontalLayout_2 = new QHBoxLayout(layoutWidget1);
horizontalLayout_2->setObjectName("horizontalLayout_2");
horizontalLayout_2->setContentsMargins(0, 0, 0, 0);
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName("horizontalLayout");
addressLineEdit = new QLineEdit(widget1);
addressLineEdit = new QLineEdit(layoutWidget1);
addressLineEdit->setObjectName("addressLineEdit");
horizontalLayout->addWidget(addressLineEdit);
valueLabel = new QLabel(widget1);
valueLabel = new QLabel(layoutWidget1);
valueLabel->setObjectName("valueLabel");
horizontalLayout->addWidget(valueLabel);
readButton = new QPushButton(widget1);
readButton = new QPushButton(layoutWidget1);
readButton->setObjectName("readButton");
horizontalLayout->addWidget(readButton);
@ -169,12 +169,12 @@ public:
horizontalLayout_2->addLayout(horizontalLayout);
pushButton_2 = new QPushButton(widget1);
pushButton_2 = new QPushButton(layoutWidget1);
pushButton_2->setObjectName("pushButton_2");
horizontalLayout_2->addWidget(pushButton_2);
pushButton = new QPushButton(widget1);
pushButton = new QPushButton(layoutWidget1);
pushButton->setObjectName("pushButton");
horizontalLayout_2->addWidget(pushButton);
@ -182,9 +182,9 @@ public:
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName("menubar");
menubar->setGeometry(QRect(0, 0, 1657, 20));
menuMenu = new QMenu(menubar);
menuMenu->setObjectName("menuMenu");
menubar->setGeometry(QRect(0, 0, 844, 20));
menuLoad = new QMenu(menubar);
menuLoad->setObjectName("menuLoad");
menuVizitka = new QMenu(menubar);
menuVizitka->setObjectName("menuVizitka");
MainWindow->setMenuBar(menubar);
@ -192,9 +192,8 @@ public:
statusbar->setObjectName("statusbar");
MainWindow->setStatusBar(statusbar);
menubar->addAction(menuMenu->menuAction());
menubar->addAction(menuLoad->menuAction());
menubar->addAction(menuVizitka->menuAction());
menuMenu->addAction(actionExit);
retranslateUi(MainWindow);
@ -217,7 +216,7 @@ public:
readButton->setText(QCoreApplication::translate("MainWindow", "Preberi", nullptr));
pushButton_2->setText(QCoreApplication::translate("MainWindow", "Levo", nullptr));
pushButton->setText(QCoreApplication::translate("MainWindow", "Desno", nullptr));
menuMenu->setTitle(QCoreApplication::translate("MainWindow", "Menu", nullptr));
menuLoad->setTitle(QCoreApplication::translate("MainWindow", "Menu", nullptr));
menuVizitka->setTitle(QCoreApplication::translate("MainWindow", "Vizitka", nullptr));
} // retranslateUi

View file

@ -1,5 +1,5 @@
#include "executor.h"
#include "machine.cpp"
#include "machine.h"
#include<chrono>
#include<thread>

View file

@ -1,3 +1,73 @@
#include "loader.h"
#include "machine.h"
Loader::Loader() {}
int Loader::readByte(std::istream &in) {
char c1, c2;
if (!in.get(c1) || !in.get(c2)) {
return -1;
}
std::string byte;
byte += c1;
byte += c2;
cout << "test: " << byte << " c1: " << c1 << " c2: " << c2 << endl;
return std::stoi(byte, nullptr, 16);
}
int Loader::readWord(std::istream &in) {
int result = 0;
for (int i = 0; i < 6; i++) {
int byte = readByte(in);
if (byte < 0) return -1;
result = (result << 8) | byte;
}
return result;
}
std::string Loader::readString(std::istream &in, int len) {
std::string result;
for (int i = 0; i < len; i++) {
char c;
if (!in.get(c)) break;
result += c;
}
return result;
}
bool Loader::loadSection(Machine& machine, std::istream& stream) {
if (stream.get() != 'H') return false;
cout << readString(stream, 6)<< endl; // ime programa ignoriramo
int start = readWord(stream);
int length = readWord(stream);
if (stream.peek() == '\r' || stream.peek() == '\n') stream.get();
// Preberi text zapise
int ch = stream.get();
while (ch == 'T') {
int loc = readWord(stream);
int len = readByte(stream);
while (len-- > 0) {
if (loc < start || loc >= start + length) return false;
int val = readByte(stream);
machine.writeByte(loc++, static_cast<unsigned char>(val));
}
if (stream.peek() == '\r' ||stream.peek() == '\n') stream.get();
ch = stream.get();
}
// End zapis
if (ch != 'E') return false;
machine.setPC(readWord(stream));
return true;
}
bool Loader::loadObj(Machine& machine, const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open()) {
std::cerr << "Napaka pri odpiranju datoteke: " << filename << "\n";
return false;
}
return loadSection(machine, file);
}

View file

@ -1,19 +1,28 @@
#ifndef LOADER_H
#define LOADER_H
#include <string>
#include <iostream>
class Machine;
class Loader
{
private:
Machine* machine;
public:
Loader();
// Prebere niz dolžine len
std::string readString(string &r, int len);
std::string readString(std::istream &in, int len);
// Prebere en bajt (2 heksadecimalni znaka)
int readByte(std::string &r);
int readByte(std::istream &in);
// Prebere eno "besedo" (3 bajte = 6 heksadecimalnih znakov)
int readWord(std::string &r);
int readWord(std::istream &in);
bool loadSection(Machine& machine, std::istream& stream);
bool loadObj(Machine& machine, const std::string& filename);
};
#endif // LOADER_H

View file

@ -68,8 +68,6 @@ public:
bool execF2(int opcode, int operand);
bool execSICF3F4(int opcode, int ni, int operand);
bool loadSection(Reader r);
};
#endif

View file

@ -1,12 +1,17 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QFileDialog>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
QAction *actionLoad = new QAction(tr("Load"), this);
ui->menuLoad->addAction(actionLoad);
connect(actionLoad, &QAction::triggered, this, &MainWindow::onLoadTriggered);
}
MainWindow::~MainWindow()
@ -24,9 +29,19 @@ void MainWindow::on_readButton_clicked()
}
try {
unsigned char val = m.readByte(addr);
unsigned char val = machine.readByte(addr);
ui->valueLabel->setText(QString::number(val));
} catch (const std::out_of_range &e) {
QMessageBox::warning(this, "Napaka", "Naslov je izven meje pomnilnika!");
}
}
void MainWindow::onLoadTriggered() {
QString filename = QFileDialog::getOpenFileName(this, tr("Open Object File"), "", tr("Object Files (*.obj)"));
if (!filename.isEmpty()) {
bool ok = loader.loadObj(machine, filename.toStdString());
if (!ok) {
QMessageBox::warning(this, tr("Error"), tr("Failed to load file"));
}
}
}

View file

@ -3,6 +3,8 @@
#include <QMainWindow>
#include "machine.h"
#include "loader.h"
QT_BEGIN_NAMESPACE
namespace Ui {
@ -20,9 +22,11 @@ public:
private slots:
void on_readButton_clicked();
void onLoadTriggered();
private:
Ui::MainWindow *ui;
Machine m;
Machine machine;
Loader loader;
};
#endif // MAINWINDOW_H

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1657</width>
<height>915</height>
<width>844</width>
<height>757</height>
</rect>
</property>
<property name="windowTitle">
@ -101,11 +101,11 @@
<layout class="QGridLayout" name="gridLayout_3"/>
</widget>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>1070</x>
<y>190</y>
<x>240</x>
<y>20</y>
<width>581</width>
<height>641</height>
</rect>
@ -142,7 +142,7 @@
<number>14</number>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>3</number>
<number>14</number>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>true</bool>
@ -207,11 +207,11 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>1070</x>
<y>850</y>
<x>240</x>
<y>680</y>
<width>571</width>
<height>27</height>
</rect>
@ -280,22 +280,21 @@
<rect>
<x>0</x>
<y>0</y>
<width>1657</width>
<width>844</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<widget class="QMenu" name="menuLoad">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuVizitka">
<property name="title">
<string>Vizitka</string>
</property>
</widget>
<addaction name="menuMenu"/>
<addaction name="menuLoad"/>
<addaction name="menuVizitka"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>