From 97d561ce57e195e5a58710b45aa90e8a5636d05d Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sat, 19 Dec 2020 00:40:36 +0700 Subject: [PATCH 01/43] Moved files --- sea_transport/.gitignore => .gitignore | 0 sea_transport/README.md => README.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sea_transport/.gitignore => .gitignore (100%) rename sea_transport/README.md => README.md (100%) diff --git a/sea_transport/.gitignore b/.gitignore similarity index 100% rename from sea_transport/.gitignore rename to .gitignore diff --git a/sea_transport/README.md b/README.md similarity index 100% rename from sea_transport/README.md rename to README.md From 2c72beab6ab9822fe7c7ee84446bfe8bf3d45b96 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 20:04:31 +0700 Subject: [PATCH 02/43] Main cycle init --- sea_transport/main.cpp | 16 ++++++++++++---- sea_transport/system/apparatus.h | 9 +++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sea_transport/main.cpp b/sea_transport/main.cpp index d26e059..bb4345c 100644 --- a/sea_transport/main.cpp +++ b/sea_transport/main.cpp @@ -1,11 +1,19 @@ #include "authwindow.h" +#include "system/apparatus.h" + #include -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { QApplication a(argc, argv); - AuthWindow w; + + bool fr = apparatus::isFirstRun(); + + apparatus::init(); + AuthWindow w(nullptr, fr); w.show(); - return a.exec(); + int ecode = a.exec(); + apparatus::shutdown(); + + return ecode; } diff --git a/sea_transport/system/apparatus.h b/sea_transport/system/apparatus.h index 3493115..4761a0a 100644 --- a/sea_transport/system/apparatus.h +++ b/sea_transport/system/apparatus.h @@ -30,18 +30,19 @@ private: void writeGIDS(); void loadGIDS(); - void serialize_data(); - void deserialize_data(); - public: apparatus(); ~apparatus(); - bool isFirstRun(); void generate_empty_data(); const auth_system& get_auth_subsystem(); const object_system& get_object_subsystem(); + + void serialize_data(); + void deserialize_data(); + + static bool isFirstRun(); static apparatus* instance(); static void init(); static void shutdown(); From 9f2eb3c573756360a79c4db23c9ae901d9dadd0f Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 21:24:15 +0700 Subject: [PATCH 03/43] Add admin panel --- sea_transport/adminpanel.cpp | 16 ++++ sea_transport/adminpanel.h | 28 ++++++ sea_transport/adminpanel.ui | 162 ++++++++++++++++++++++++++++++++ sea_transport/authwindow.cpp | 62 ++++++++++-- sea_transport/authwindow.h | 12 ++- sea_transport/sea_transport.pro | 3 + 6 files changed, 276 insertions(+), 7 deletions(-) create mode 100644 sea_transport/adminpanel.cpp create mode 100644 sea_transport/adminpanel.h create mode 100644 sea_transport/adminpanel.ui diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp new file mode 100644 index 0000000..f368ea0 --- /dev/null +++ b/sea_transport/adminpanel.cpp @@ -0,0 +1,16 @@ +#include "adminpanel.h" +#include "ui_adminpanel.h" + +AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) +{ + ui->setupUi(this); +} + +AdminPanel::~AdminPanel() { + delete ui; +} + +AdminPanel& AdminPanel::set_user(const user_entity &user) { + this->user = user; + return *this; +} diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h new file mode 100644 index 0000000..1444919 --- /dev/null +++ b/sea_transport/adminpanel.h @@ -0,0 +1,28 @@ +#ifndef ADMINPANEL_H +#define ADMINPANEL_H + +#include + +#include "entities/user_entity.h" + +namespace Ui { + class AdminPanel; +} + +class AdminPanel : public QMainWindow +{ + Q_OBJECT + + user_entity user; + +public: + explicit AdminPanel(QWidget *parent = nullptr); + ~AdminPanel(); + + AdminPanel& set_user(const user_entity &user); + +private: + Ui::AdminPanel *ui; +}; + +#endif // ADMINPANEL_H diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui new file mode 100644 index 0000000..196027d --- /dev/null +++ b/sea_transport/adminpanel.ui @@ -0,0 +1,162 @@ + + + AdminPanel + + + + 0 + 0 + 1200 + 600 + + + + MainWindow + + + + + + + + + Storages + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + + + Delivery points + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + + + Vessels + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + + + Users + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + + + 0 + 0 + 1200 + 21 + + + + + + + + diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index f895a75..5f8712c 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -1,14 +1,64 @@ #include "authwindow.h" #include "ui_authwindow.h" -AuthWindow::AuthWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::AuthWindow) -{ + +AuthWindow::AuthWindow(QWidget *parent, bool fr) : QMainWindow(parent), ui(new Ui::AuthWindow) { ui->setupUi(this); + this->firstRun = fr; + + connect(ui->btn_login, &QPushButton::clicked, this, &AuthWindow::on_auth_requested); } -AuthWindow::~AuthWindow() -{ +AuthWindow::~AuthWindow() { delete ui; } + +void AuthWindow::on_auth_requested() { + auto login = ui->et_login->text().trimmed(); + auto passw = ui->et_password->text().trimmed(); + + if (login.isEmpty() || passw.isEmpty()) { + QMessageBox::critical(this, "Error", "Login nor password cannot be empty!"); + return; + } + + bool success = false; + auto a = apparatus::instance()->get_auth_subsystem(); + if (this->firstRun) { + success = a.register_user(login, passw, UserRole::ADMINISTRATOR); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot register you. Check filesystem permission"); + return; + } + else { + apparatus::instance()->serialize_data(); + } + } + + auto user = *a.get_user(login, success); + if (!success) { + QMessageBox::critical(this, "Error", "User not found"); + return; + } + + success = user.verify_password(passw); + if (!success) { + QMessageBox::critical(this, "Error", "Wrong password"); + return; + } + + + if (user.role() == UserRole::ADMINISTRATOR) { + AdminPanel(nullptr).set_user(user).show(); + } + else if (user.role() == UserRole::DISPATCHER) { + // DispatcherPanel(nullptr, user).set_user(user).show(); + } + else if (user.role() == UserRole::SKIPPER) { + // SkipperPanel(nullptr, user).set_user(user).show(); + } + else { + QMessageBox::critical(this, "Error", "Deserialized user have wrong type. " + "It may mean corruption of data."); + } +} diff --git a/sea_transport/authwindow.h b/sea_transport/authwindow.h index 5f5a356..c3fbe2a 100644 --- a/sea_transport/authwindow.h +++ b/sea_transport/authwindow.h @@ -1,7 +1,12 @@ #ifndef AUTHWINDOW_H #define AUTHWINDOW_H +#include + +#include "adminpanel.h" + #include +#include namespace Ui { class AuthWindow; @@ -10,11 +15,16 @@ class AuthWindow; class AuthWindow : public QMainWindow { Q_OBJECT + bool firstRun; public: - explicit AuthWindow(QWidget *parent = nullptr); + explicit AuthWindow(QWidget *parent = nullptr, bool fr = false); ~AuthWindow(); + +private slots: + void on_auth_requested(); + private: Ui::AuthWindow *ui; }; diff --git a/sea_transport/sea_transport.pro b/sea_transport/sea_transport.pro index d5e4f66..23e96ba 100644 --- a/sea_transport/sea_transport.pro +++ b/sea_transport/sea_transport.pro @@ -9,6 +9,7 @@ CONFIG += c++11 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + adminpanel.cpp \ authwindow.cpp \ cargoeditdialog.cpp \ deliverypointeditdialog.cpp \ @@ -26,6 +27,7 @@ SOURCES += \ vesseleditdialog.cpp HEADERS += \ + adminpanel.h \ authwindow.h \ cargoeditdialog.h \ deliverypointeditdialog.h \ @@ -44,6 +46,7 @@ HEADERS += \ vesseleditdialog.h FORMS += \ + adminpanel.ui \ authwindow.ui \ cargoeditdialog.ui \ deliverypointeditdialog.ui \ From 840990950d51b380f817dcdb16b19cacb93f98e2 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 21:33:36 +0700 Subject: [PATCH 04/43] Updated ids in ui --- sea_transport/adminpanel.ui | 24 ++++++++++++------------ sea_transport/authwindow.cpp | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index 196027d..e006923 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -25,19 +25,19 @@ - + - + Add - + Remove @@ -57,19 +57,19 @@ - + - + Add - + Remove @@ -89,19 +89,19 @@ - + - + Add - + Remove @@ -121,19 +121,19 @@ - + - + Add - + Remove diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index 5f8712c..9af9f9d 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -60,5 +60,7 @@ void AuthWindow::on_auth_requested() { else { QMessageBox::critical(this, "Error", "Deserialized user have wrong type. " "It may mean corruption of data."); + return; } + close(); } From f6dbacabee37b4e5092c52a9ba04e46c923484bb Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 21:34:53 +0700 Subject: [PATCH 05/43] Add users notification --- sea_transport/adminpanel.ui | 104 ++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 47 deletions(-) diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index e006923..a085404 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -15,29 +15,29 @@ - - + + - + - Storages + Vessels - + - + - + Add - + Remove @@ -47,7 +47,39 @@ - + + + + + + Users + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + @@ -80,28 +112,28 @@ - + - + - Vessels + Storages - + - + - + Add - + Remove @@ -111,37 +143,15 @@ - - - - - - Users - - - - - - - - - - - - Add - - - - - - - Remove - - - - - - + + + + Hello, user %1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + From 44963dbad7859a98a116bd4b1a4b5a598599d0d1 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 21:36:20 +0700 Subject: [PATCH 06/43] ADd logout button --- sea_transport/adminpanel.ui | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index a085404..1542c03 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -153,6 +153,19 @@ + + + + + 0 + 0 + + + + Logout + + + From 50aa95e65953b04ccf1edcec86f2641f143ec4c0 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 21:49:40 +0700 Subject: [PATCH 07/43] Admin panel slots --- sea_transport/adminpanel.cpp | 23 +++++++++++++++++++++-- sea_transport/adminpanel.h | 15 +++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index f368ea0..0cd3210 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -1,9 +1,27 @@ #include "adminpanel.h" #include "ui_adminpanel.h" -AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) -{ +AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) { ui->setupUi(this); + + connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); + + connect(ui->pb_vessels_add, &QPushButton::clicked, this, &AdminPanel::on_vessel_add); + connect(ui->pb_vessels_remove, &QPushButton::clicked, this, &AdminPanel::on_vessel_remove); + + connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_user_add); + connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_user_remove); + + connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_storage_add); + connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_storage_remove); + + connect(ui->pb_dp_add, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_add); + connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); + +// ui->tv_vessels->setModel(); +// ui->tv_users->setModel(); +// ui->tv_dp->setModel(); +// ui->tv_storages->setModel(); } AdminPanel::~AdminPanel() { @@ -12,5 +30,6 @@ AdminPanel::~AdminPanel() { AdminPanel& AdminPanel::set_user(const user_entity &user) { this->user = user; + ui->lab_user->setText(tr("Hello user %1").arg(user.login())); return *this; } diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index 1444919..5dfc5dd 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -21,6 +21,21 @@ public: AdminPanel& set_user(const user_entity &user); +private slots: + void on_logout_requested(); + + void on_vessel_add(); + void on_vessel_remove(); + + void on_user_add(); + void on_user_remove(); + + void on_storage_add(); + void on_storage_remove(); + + void on_delivery_point_add(); + void on_delivery_point_remove(); + private: Ui::AdminPanel *ui; }; From d69b18f083106150ad2231013c834d99ac1c1dae Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 21 Dec 2020 23:39:04 +0700 Subject: [PATCH 08/43] base viewmodel and interactions --- sea_transport/adminpanel.cpp | 63 ++++++++++++++++---- sea_transport/adminpanel.h | 11 +++- sea_transport/authwindow.cpp | 21 ++++--- sea_transport/authwindow.h | 14 ++--- sea_transport/main.cpp | 17 +++--- sea_transport/sea_transport.pro | 6 +- sea_transport/system/apparatus.cpp | 46 +++++++-------- sea_transport/system/apparatus.h | 5 +- sea_transport/system/auth_system.cpp | 8 ++- sea_transport/system/auth_system.h | 8 ++- sea_transport/system/object_system.cpp | 12 +++- sea_transport/system/object_system.h | 7 ++- sea_transport/viewmodels/usersviewmodel.cpp | 65 +++++++++++++++++++++ sea_transport/viewmodels/usersviewmodel.h | 22 +++++++ 14 files changed, 228 insertions(+), 77 deletions(-) create mode 100644 sea_transport/viewmodels/usersviewmodel.cpp create mode 100644 sea_transport/viewmodels/usersviewmodel.h diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 0cd3210..c596f91 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -4,28 +4,35 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) { ui->setupUi(this); - connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); + uvm = new UsersViewModel(this); - connect(ui->pb_vessels_add, &QPushButton::clicked, this, &AdminPanel::on_vessel_add); - connect(ui->pb_vessels_remove, &QPushButton::clicked, this, &AdminPanel::on_vessel_remove); +// connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); - connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_user_add); - connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_user_remove); +// connect(ui->pb_vessels_add, &QPushButton::clicked, this, &AdminPanel::on_vessel_add); +// connect(ui->pb_vessels_remove, &QPushButton::clicked, this, &AdminPanel::on_vessel_remove); - connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_storage_add); - connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_storage_remove); +// connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_user_add); +// connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_user_remove); - connect(ui->pb_dp_add, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_add); - connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); +// connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_storage_add); +// connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_storage_remove); + +// connect(ui->pb_dp_add, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_add); +// connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); // ui->tv_vessels->setModel(); -// ui->tv_users->setModel(); + ui->tv_users->setModel(uvm); // ui->tv_dp->setModel(); // ui->tv_storages->setModel(); + + + uvm->update(); } AdminPanel::~AdminPanel() { delete ui; + + delete uvm; } AdminPanel& AdminPanel::set_user(const user_entity &user) { @@ -33,3 +40,39 @@ AdminPanel& AdminPanel::set_user(const user_entity &user) { ui->lab_user->setText(tr("Hello user %1").arg(user.login())); return *this; } + +void AdminPanel::on_logout_requested() { + +} + +void AdminPanel::on_vessel_add() { + +} + +void AdminPanel::on_vessel_remove() { + +} + +void AdminPanel::on_user_add() { + +} + +void AdminPanel::on_user_remove() { + +} + +void AdminPanel::on_storage_add() { + +} + +void AdminPanel::on_storage_remove() { + +} + +void AdminPanel::on_delivery_point_add() { + +} + +void AdminPanel::on_delivery_point_remove() { + +} diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index 5dfc5dd..a65ce20 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -3,6 +3,8 @@ #include +#include "viewmodels/usersviewmodel.h" + #include "entities/user_entity.h" namespace Ui { @@ -15,6 +17,8 @@ class AdminPanel : public QMainWindow user_entity user; + UsersViewModel *uvm; + public: explicit AdminPanel(QWidget *parent = nullptr); ~AdminPanel(); @@ -22,6 +26,10 @@ public: AdminPanel& set_user(const user_entity &user); private slots: + +private: + Ui::AdminPanel *ui; + void on_logout_requested(); void on_vessel_add(); @@ -35,9 +43,6 @@ private slots: void on_delivery_point_add(); void on_delivery_point_remove(); - -private: - Ui::AdminPanel *ui; }; #endif // ADMINPANEL_H diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index 9af9f9d..76b4bbf 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -2,9 +2,8 @@ #include "ui_authwindow.h" -AuthWindow::AuthWindow(QWidget *parent, bool fr) : QMainWindow(parent), ui(new Ui::AuthWindow) { +AuthWindow::AuthWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::AuthWindow) { ui->setupUi(this); - this->firstRun = fr; connect(ui->btn_login, &QPushButton::clicked, this, &AuthWindow::on_auth_requested); } @@ -24,37 +23,38 @@ void AuthWindow::on_auth_requested() { bool success = false; auto a = apparatus::instance()->get_auth_subsystem(); - if (this->firstRun) { + if (apparatus::isFirstRun()) { success = a.register_user(login, passw, UserRole::ADMINISTRATOR); if (!success) { QMessageBox::critical(this, "Error", "Cannot register you. Check filesystem permission"); return; } else { - apparatus::instance()->serialize_data(); + QMessageBox::information(this, "Info", "You are the first user of system. " + "Your account type is administrator"); } } - auto user = *a.get_user(login, success); + auto user = a.get_user(login, success); if (!success) { QMessageBox::critical(this, "Error", "User not found"); return; } - success = user.verify_password(passw); + success = user->verify_password(passw); if (!success) { QMessageBox::critical(this, "Error", "Wrong password"); return; } - if (user.role() == UserRole::ADMINISTRATOR) { - AdminPanel(nullptr).set_user(user).show(); + if (user->role() == UserRole::ADMINISTRATOR) { + AdminPanel(nullptr).set_user(*user).showNormal(); } - else if (user.role() == UserRole::DISPATCHER) { + else if (user->role() == UserRole::DISPATCHER) { // DispatcherPanel(nullptr, user).set_user(user).show(); } - else if (user.role() == UserRole::SKIPPER) { + else if (user->role() == UserRole::SKIPPER) { // SkipperPanel(nullptr, user).set_user(user).show(); } else { @@ -62,5 +62,4 @@ void AuthWindow::on_auth_requested() { "It may mean corruption of data."); return; } - close(); } diff --git a/sea_transport/authwindow.h b/sea_transport/authwindow.h index c3fbe2a..e0f174e 100644 --- a/sea_transport/authwindow.h +++ b/sea_transport/authwindow.h @@ -1,7 +1,7 @@ #ifndef AUTHWINDOW_H #define AUTHWINDOW_H -#include +#include "system/apparatus.h" #include "adminpanel.h" @@ -12,21 +12,17 @@ namespace Ui { class AuthWindow; } -class AuthWindow : public QMainWindow -{ +class AuthWindow : public QMainWindow { Q_OBJECT - bool firstRun; public: - explicit AuthWindow(QWidget *parent = nullptr, bool fr = false); + explicit AuthWindow(QWidget *parent = nullptr); ~AuthWindow(); - -private slots: - void on_auth_requested(); - private: Ui::AuthWindow *ui; + + void on_auth_requested(); }; #endif // AUTHWINDOW_H diff --git a/sea_transport/main.cpp b/sea_transport/main.cpp index bb4345c..a37cf30 100644 --- a/sea_transport/main.cpp +++ b/sea_transport/main.cpp @@ -7,13 +7,16 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - bool fr = apparatus::isFirstRun(); - apparatus::init(); - AuthWindow w(nullptr, fr); - w.show(); - int ecode = a.exec(); - apparatus::shutdown(); - return ecode; + AuthWindow w(nullptr); + w.show(); + + QObject::connect(&a, &QApplication::aboutToQuit, []() { + apparatus::shutdown(); + if (apparatus::isFirstRun()) { + apparatus::generate_lock_file(); + } + }); + return a.exec(); } diff --git a/sea_transport/sea_transport.pro b/sea_transport/sea_transport.pro index 23e96ba..e5ceb58 100644 --- a/sea_transport/sea_transport.pro +++ b/sea_transport/sea_transport.pro @@ -24,7 +24,8 @@ SOURCES += \ system/auth_system.cpp \ system/object_system.cpp \ usereditdialog.cpp \ - vesseleditdialog.cpp + vesseleditdialog.cpp \ + viewmodels/usersviewmodel.cpp HEADERS += \ adminpanel.h \ @@ -43,7 +44,8 @@ HEADERS += \ system/auth_system.h \ system/object_system.h \ usereditdialog.h \ - vesseleditdialog.h + vesseleditdialog.h \ + viewmodels/usersviewmodel.h FORMS += \ adminpanel.ui \ diff --git a/sea_transport/system/apparatus.cpp b/sea_transport/system/apparatus.cpp index 43747f5..4e4e89f 100644 --- a/sea_transport/system/apparatus.cpp +++ b/sea_transport/system/apparatus.cpp @@ -24,7 +24,14 @@ apparatus::apparatus() { } apparatus::~apparatus() { - this->shutdown(); + +} + +void apparatus::generate_lock_file() { + QFile init("lock"); + init.open(QIODevice::ReadWrite); + init.write("lock"); + init.close(); } apparatus* apparatus::instance() { @@ -36,38 +43,30 @@ apparatus* apparatus::instance() { } bool apparatus::isFirstRun() { - return QFile().exists("init"); + return !QFile().exists("lock"); } -void apparatus::generate_empty_data() { - this->open_stream(); - this->writeGIDS(); - this->serialize_data(); - this->close_stream(); -} - -const auth_system& apparatus::get_auth_subsystem() { +auth_system& apparatus::get_auth_subsystem() { return this->_auth_system; } -const object_system& apparatus::get_object_subsystem() { +object_system& apparatus::get_object_subsystem() { return this->_object_system; } void apparatus::init() { apparatus::_instance = new apparatus(); - apparatus::instance()->open_stream(); - apparatus::instance()->loadGIDS(); - apparatus::instance()->deserialize_data(); - apparatus::instance()->close_stream(); + apparatus::_instance->open_stream(); + apparatus::_instance->loadGIDS(); + apparatus::_instance->deserialize_data(); } void apparatus::shutdown() { - apparatus::instance()->open_stream(); - apparatus::instance()->writeGIDS(); - apparatus::instance()->serialize_data(); - apparatus::instance()->close_stream(); + apparatus::_instance->writeGIDS(); + apparatus::_instance->serialize_data(); + apparatus::_instance->close_stream(); + delete apparatus::_instance; } void apparatus::writeGIDS() { @@ -84,12 +83,11 @@ void apparatus::loadGIDS() { } void apparatus::serialize_data() { - this->_auth_system.init(this->stream); - this->_object_system.init(this->stream); + this->_auth_system.serialize_data(this->stream); + this->_object_system.serialize_data(this->stream); } void apparatus::deserialize_data() { - QFile("init").open(QIODevice::ReadWrite); - this->_auth_system.shutdown(this->stream); - this->_object_system.shutdown(this->stream); + this->_auth_system.deserialize_data(this->stream); + this->_object_system.deserialize_data(this->stream); } diff --git a/sea_transport/system/apparatus.h b/sea_transport/system/apparatus.h index 4761a0a..eb62840 100644 --- a/sea_transport/system/apparatus.h +++ b/sea_transport/system/apparatus.h @@ -35,14 +35,15 @@ public: ~apparatus(); void generate_empty_data(); - const auth_system& get_auth_subsystem(); - const object_system& get_object_subsystem(); + auth_system& get_auth_subsystem(); + object_system& get_object_subsystem(); void serialize_data(); void deserialize_data(); static bool isFirstRun(); + static void generate_lock_file(); static apparatus* instance(); static void init(); static void shutdown(); diff --git a/sea_transport/system/auth_system.cpp b/sea_transport/system/auth_system.cpp index 6b2a0fb..5d70ea1 100644 --- a/sea_transport/system/auth_system.cpp +++ b/sea_transport/system/auth_system.cpp @@ -39,7 +39,11 @@ bool auth_system::register_user(const QString &login, const QString &password, U return false; } -void auth_system::init(QDataStream &stream) { +const QVector auth_system::users() const { + return this->_users; +} + +void auth_system::deserialize_data(QDataStream &stream) { int icnt; stream >> icnt; this->_users.resize(icnt); @@ -48,7 +52,7 @@ void auth_system::init(QDataStream &stream) { } } -void auth_system::shutdown(QDataStream &stream) { +void auth_system::serialize_data(QDataStream &stream) { stream << this->_users.size(); for (auto &item : this->_users) { item.serialize(stream); diff --git a/sea_transport/system/auth_system.h b/sea_transport/system/auth_system.h index 52849e1..c87439f 100644 --- a/sea_transport/system/auth_system.h +++ b/sea_transport/system/auth_system.h @@ -1,7 +1,7 @@ #ifndef AUTH_SYSTEM_H #define AUTH_SYSTEM_H -#include +#include #include "../entities/user_entity.h" @@ -17,8 +17,10 @@ public: bool remove_user(const QString &login); bool register_user(const QString &login, const QString &password, UserRole role); - void init(QDataStream &stream); - void shutdown(QDataStream &stream); + const QVector users() const; + + void deserialize_data(QDataStream &stream); + void serialize_data(QDataStream &stream); }; #endif // AUTH_SYSTEM_H diff --git a/sea_transport/system/object_system.cpp b/sea_transport/system/object_system.cpp index df59433..1aa46b6 100644 --- a/sea_transport/system/object_system.cpp +++ b/sea_transport/system/object_system.cpp @@ -77,7 +77,15 @@ bool object_system::add_vessel(vessel_entity dpoint) { return false; } -void object_system::init(QDataStream &stream) { +const QVector object_system::dpoints() const { + return this->_dpoints; +} + +const QVector object_system::vessels() const { + return this->_vessels; +} + +void object_system::deserialize_data(QDataStream &stream) { int dicnt; stream >> dicnt; this->_dpoints.resize(dicnt); @@ -93,7 +101,7 @@ void object_system::init(QDataStream &stream) { } } -void object_system::shutdown(QDataStream &stream) { +void object_system::serialize_data(QDataStream &stream) { stream << this->_dpoints.size(); for (auto &item : this->_dpoints) { item.serialize(stream); diff --git a/sea_transport/system/object_system.h b/sea_transport/system/object_system.h index 18285bb..095e2e5 100644 --- a/sea_transport/system/object_system.h +++ b/sea_transport/system/object_system.h @@ -25,8 +25,11 @@ public: bool add_vessel(vessel_entity dpoint); - void init(QDataStream &stream); - void shutdown(QDataStream &stream); + const QVector dpoints() const; + const QVector vessels() const; + + void deserialize_data(QDataStream &stream); + void serialize_data(QDataStream &stream); }; #endif // OBJECT_SYSTEM_H diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp new file mode 100644 index 0000000..6ad267c --- /dev/null +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -0,0 +1,65 @@ +#include "usersviewmodel.h" + +UsersViewModel::UsersViewModel(QObject *parent) : QAbstractTableModel(parent) { + +} + +int UsersViewModel::rowCount(const QModelIndex & /*parent*/) const { + return apparatus::instance()->get_object_subsystem().vessels().size(); +} + +int UsersViewModel::columnCount(const QModelIndex & /*parent*/) const { + return 3; +} + +QVariant UsersViewModel::headerData(int section, Qt::Orientation orientation, int role) const { + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { + switch (section) { + case 0: + return QString("UID"); + case 1: + return QString("Login"); + case 2: + return QString("Role"); + } + } + return QVariant(); +} + +QVariant UsersViewModel::data(const QModelIndex &index, int role) const { + if (role == Qt::DisplayRole) { + auto item = apparatus::instance()->get_auth_subsystem().users()[index.row()]; + int col = index.column(); + + switch (col) { + case 0: + return QString::number(item.id()); + case 1: + return item.login(); + case 2: + QString role = "unknown"; + + switch(item.role()) { + case UserRole::ADMINISTRATOR: + role = "Administrator"; + break; + case UserRole::DISPATCHER: + role = "Dispatcher"; + break; + case UserRole::SKIPPER: + role = "Skipper"; + break; + } + + return role; + } + + return "UNKNOWN FIELD"; + } + + return QVariant(); +} + +void UsersViewModel::update() { + this->resetInternalData(); +} diff --git a/sea_transport/viewmodels/usersviewmodel.h b/sea_transport/viewmodels/usersviewmodel.h new file mode 100644 index 0000000..411981b --- /dev/null +++ b/sea_transport/viewmodels/usersviewmodel.h @@ -0,0 +1,22 @@ +#ifndef USERSVIEWMODEL_H +#define USERSVIEWMODEL_H + +#include "system/apparatus.h" + +#include + +class UsersViewModel : public QAbstractTableModel +{ + Q_OBJECT +public: + UsersViewModel(QObject *parent = nullptr); + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +public slots: + void update(); +}; + +#endif // USERSVIEWMODEL_H From f99974d8ae23d090f89476377942eb6b030255d6 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 19:17:28 +0700 Subject: [PATCH 09/43] Fixed referencing and dereferencing errors in apparatus --- sea_transport/adminpanel.cpp | 7 +- sea_transport/authwindow.cpp | 14 ++- sea_transport/main.cpp | 4 +- sea_transport/system/apparatus.cpp | 111 +++++++++++--------- sea_transport/system/apparatus.h | 25 ++--- sea_transport/system/auth_system.cpp | 26 +++-- sea_transport/system/auth_system.h | 6 +- sea_transport/system/object_system.cpp | 32 +++--- sea_transport/system/object_system.h | 4 +- sea_transport/viewmodels/usersviewmodel.cpp | 4 +- sea_transport_project.pro.user | 11 +- st_test/tst_st_test.cpp | 16 +-- 12 files changed, 148 insertions(+), 112 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index c596f91..d424284 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -1,10 +1,10 @@ #include "adminpanel.h" #include "ui_adminpanel.h" + AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) { ui->setupUi(this); - uvm = new UsersViewModel(this); // connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); @@ -20,9 +20,14 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP // connect(ui->pb_dp_add, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_add); // connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); + // ui->tv_vessels->setModel(); + + uvm = new UsersViewModel(this); ui->tv_users->setModel(uvm); + // ui->tv_dp->setModel(); + // ui->tv_storages->setModel(); diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index 76b4bbf..f8a13ff 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -23,8 +23,9 @@ void AuthWindow::on_auth_requested() { bool success = false; auto a = apparatus::instance()->get_auth_subsystem(); + if (apparatus::isFirstRun()) { - success = a.register_user(login, passw, UserRole::ADMINISTRATOR); + success = a->register_user(login, passw, UserRole::ADMINISTRATOR); if (!success) { QMessageBox::critical(this, "Error", "Cannot register you. Check filesystem permission"); return; @@ -35,7 +36,7 @@ void AuthWindow::on_auth_requested() { } } - auto user = a.get_user(login, success); + auto user = a->get_user(login, success); if (!success) { QMessageBox::critical(this, "Error", "User not found"); return; @@ -48,18 +49,25 @@ void AuthWindow::on_auth_requested() { } + QWidget *w; if (user->role() == UserRole::ADMINISTRATOR) { - AdminPanel(nullptr).set_user(*user).showNormal(); + w = new AdminPanel(nullptr); + ((AdminPanel*) w)->set_user(*user); } else if (user->role() == UserRole::DISPATCHER) { // DispatcherPanel(nullptr, user).set_user(user).show(); + return; } else if (user->role() == UserRole::SKIPPER) { // SkipperPanel(nullptr, user).set_user(user).show(); + return; } else { QMessageBox::critical(this, "Error", "Deserialized user have wrong type. " "It may mean corruption of data."); return; } + + w->show(); + close(); } diff --git a/sea_transport/main.cpp b/sea_transport/main.cpp index a37cf30..5a92eef 100644 --- a/sea_transport/main.cpp +++ b/sea_transport/main.cpp @@ -13,8 +13,8 @@ int main(int argc, char *argv[]) { w.show(); QObject::connect(&a, &QApplication::aboutToQuit, []() { - apparatus::shutdown(); - if (apparatus::isFirstRun()) { + apparatus::instance()->save(); + if (apparatus::isFirstRun() && apparatus::instance()->get_auth_subsystem()->users().length() > 0) { apparatus::generate_lock_file(); } }); diff --git a/sea_transport/system/apparatus.cpp b/sea_transport/system/apparatus.cpp index 4e4e89f..91c2ec3 100644 --- a/sea_transport/system/apparatus.cpp +++ b/sea_transport/system/apparatus.cpp @@ -4,27 +4,15 @@ apparatus *apparatus::_instance = nullptr; const QString apparatus::filename = "data.bin"; -void apparatus::open_stream() { - this->_bin_file = new QFile(apparatus::filename); - this->_bin_file->open(QIODevice::ReadWrite); - - stream.setDevice(_bin_file); -} - -void apparatus::close_stream() { - stream.setDevice(nullptr); - - this->_bin_file->close(); - delete this->_bin_file; - this->_bin_file = nullptr; -} - apparatus::apparatus() { - + this->_auth_system = new auth_system(); + this->_object_system = new object_system(); } apparatus::~apparatus() { - + this->save(); + delete this->_auth_system; + delete this->_object_system; } void apparatus::generate_lock_file() { @@ -42,52 +30,79 @@ apparatus* apparatus::instance() { return apparatus::_instance; } +void apparatus::save() { + if (_instance == nullptr) { + return; + } + QFile f(apparatus::filename); + f.open(QIODevice::WriteOnly); + QDataStream stream(&f); + + // saving GIDs + entity_id vgid = vessel_entity::GID(); + entity_id sgid = storage_entity::GID(); + stream << vgid << sgid; + + // serializing data + this->_auth_system->serialize_data(&stream); + this->_object_system->serialize_data(&stream); + + f.close(); +} + +void apparatus::load() { + if (_instance == nullptr) { + throw std::runtime_error("HOW DU FUCK INSTANCE IS NULL????"); + } + QFile f(apparatus::filename); + f.open(QIODevice::ReadOnly); + QDataStream stream(&f); + + // loading GIDs + entity_id vgid, sgid; + stream >> vgid >> sgid; + vessel_entity::preloadGlobalId(vgid); + storage_entity::preloadGlobalId(sgid); + + // deserializing data + this->_auth_system->deserialize_data(&stream); + this->_object_system->deserialize_data(&stream); + + f.close(); +} + bool apparatus::isFirstRun() { return !QFile().exists("lock"); } -auth_system& apparatus::get_auth_subsystem() { +auth_system* apparatus::get_auth_subsystem() { return this->_auth_system; } -object_system& apparatus::get_object_subsystem() { +object_system* apparatus::get_object_subsystem() { return this->_object_system; } void apparatus::init() { + if (apparatus::_instance != nullptr) { + throw std::runtime_error("System already initialized!"); + } + + bool fr = apparatus::isFirstRun(); apparatus::_instance = new apparatus(); - apparatus::_instance->open_stream(); - apparatus::_instance->loadGIDS(); - apparatus::_instance->deserialize_data(); + if (fr) { + if (!QFile().exists(apparatus::filename)) { + QFile init(apparatus::filename); + init.open(QIODevice::ReadWrite); + init.close(); + } + apparatus::_instance->save(); + } + + apparatus::_instance->load(); } void apparatus::shutdown() { - apparatus::_instance->writeGIDS(); - apparatus::_instance->serialize_data(); - apparatus::_instance->close_stream(); delete apparatus::_instance; } - -void apparatus::writeGIDS() { - entity_id vgid = vessel_entity::GID(); - entity_id sgid = storage_entity::GID(); - this->stream << vgid << sgid; -} - -void apparatus::loadGIDS() { - entity_id vgid, sgid; - this->stream >> vgid >> sgid; - vessel_entity::preloadGlobalId(vgid); - storage_entity::preloadGlobalId(sgid); -} - -void apparatus::serialize_data() { - this->_auth_system.serialize_data(this->stream); - this->_object_system.serialize_data(this->stream); -} - -void apparatus::deserialize_data() { - this->_auth_system.deserialize_data(this->stream); - this->_object_system.deserialize_data(this->stream); -} diff --git a/sea_transport/system/apparatus.h b/sea_transport/system/apparatus.h index eb62840..43ddeee 100644 --- a/sea_transport/system/apparatus.h +++ b/sea_transport/system/apparatus.h @@ -18,29 +18,18 @@ private: static apparatus *_instance; static const QString filename; - QFile *_bin_file; - QDataStream stream; - - auth_system _auth_system; - object_system _object_system; - - void open_stream(); - void close_stream(); - - void writeGIDS(); - void loadGIDS(); + auth_system* _auth_system; + object_system* _object_system; public: - apparatus(); + explicit apparatus(); ~apparatus(); - void generate_empty_data(); - auth_system& get_auth_subsystem(); - object_system& get_object_subsystem(); + auth_system* get_auth_subsystem(); + object_system* get_object_subsystem(); - - void serialize_data(); - void deserialize_data(); + void save(); + void load(); static bool isFirstRun(); static void generate_lock_file(); diff --git a/sea_transport/system/auth_system.cpp b/sea_transport/system/auth_system.cpp index 5d70ea1..a6c53aa 100644 --- a/sea_transport/system/auth_system.cpp +++ b/sea_transport/system/auth_system.cpp @@ -1,4 +1,6 @@ +#include "apparatus.h" #include "auth_system.h" +#include const user_entity* auth_system::get_user(const QString &login, bool &success) { @@ -32,29 +34,35 @@ bool auth_system::register_user(const QString &login, const QString &password, U bool exists = false; this->get_user(login, exists); if (!exists) { + std::cout << apparatus::instance()->get_auth_subsystem()->users().length() << std::endl; this->_users.push_back(user_entity(login, password, role)); + std::cout << apparatus::instance()->get_auth_subsystem()->users().length() << std::endl; + apparatus::instance()->save(); + std::cout << apparatus::instance()->get_auth_subsystem()->users().length() << std::endl; return true; } return false; } -const QVector auth_system::users() const { +const QVector& auth_system::users() const { return this->_users; } -void auth_system::deserialize_data(QDataStream &stream) { +void auth_system::deserialize_data(QDataStream *stream) { int icnt; - stream >> icnt; - this->_users.resize(icnt); - for (int i = 0; i < icnt; i++) { - this->_users[i].deserialize(stream); + *stream >> icnt; + if (icnt > 0) { + this->_users.resize(icnt); + for (int i = 0; i < icnt; i++) { + this->_users[i].deserialize(*stream); + } } } -void auth_system::serialize_data(QDataStream &stream) { - stream << this->_users.size(); +void auth_system::serialize_data(QDataStream *stream) { + *stream << this->_users.size(); for (auto &item : this->_users) { - item.serialize(stream); + item.serialize(*stream); } } diff --git a/sea_transport/system/auth_system.h b/sea_transport/system/auth_system.h index c87439f..ecc42ae 100644 --- a/sea_transport/system/auth_system.h +++ b/sea_transport/system/auth_system.h @@ -17,10 +17,10 @@ public: bool remove_user(const QString &login); bool register_user(const QString &login, const QString &password, UserRole role); - const QVector users() const; + const QVector& users() const; - void deserialize_data(QDataStream &stream); - void serialize_data(QDataStream &stream); + void deserialize_data(QDataStream *stream); + void serialize_data(QDataStream *stream); }; #endif // AUTH_SYSTEM_H diff --git a/sea_transport/system/object_system.cpp b/sea_transport/system/object_system.cpp index 1aa46b6..6b6456c 100644 --- a/sea_transport/system/object_system.cpp +++ b/sea_transport/system/object_system.cpp @@ -85,30 +85,34 @@ const QVector object_system::vessels() const { return this->_vessels; } -void object_system::deserialize_data(QDataStream &stream) { +void object_system::deserialize_data(QDataStream *stream) { int dicnt; - stream >> dicnt; - this->_dpoints.resize(dicnt); - for (int i = 0; i < dicnt; i++) { - this->_dpoints[i].deserialize(stream); + *stream >> dicnt; + if (dicnt > 0) { + this->_dpoints.resize(dicnt); + for (int i = 0; i < dicnt; i++) { + this->_dpoints[i].deserialize(*stream); + } } int vicnt; - stream >> vicnt; - this->_vessels.resize(vicnt); - for (int i = 0; i < vicnt; i++) { - this->_vessels[i].deserialize(stream); + *stream >> vicnt; + if (vicnt > 0) { + this->_vessels.resize(vicnt); + for (int i = 0; i < vicnt; i++) { + this->_vessels[i].deserialize(*stream); + } } } -void object_system::serialize_data(QDataStream &stream) { - stream << this->_dpoints.size(); +void object_system::serialize_data(QDataStream *stream) { + *stream << this->_dpoints.size(); for (auto &item : this->_dpoints) { - item.serialize(stream); + item.serialize(*stream); } - stream << this->_vessels.size(); + *stream << this->_vessels.size(); for (auto &item : this->_vessels) { - item.serialize(stream); + item.serialize(*stream); } } diff --git a/sea_transport/system/object_system.h b/sea_transport/system/object_system.h index 095e2e5..2239a42 100644 --- a/sea_transport/system/object_system.h +++ b/sea_transport/system/object_system.h @@ -28,8 +28,8 @@ public: const QVector dpoints() const; const QVector vessels() const; - void deserialize_data(QDataStream &stream); - void serialize_data(QDataStream &stream); + void deserialize_data(QDataStream *stream); + void serialize_data(QDataStream *stream); }; #endif // OBJECT_SYSTEM_H diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp index 6ad267c..93785f2 100644 --- a/sea_transport/viewmodels/usersviewmodel.cpp +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -5,7 +5,7 @@ UsersViewModel::UsersViewModel(QObject *parent) : QAbstractTableModel(parent) { } int UsersViewModel::rowCount(const QModelIndex & /*parent*/) const { - return apparatus::instance()->get_object_subsystem().vessels().size(); + return apparatus::instance()->get_object_subsystem()->vessels().size(); } int UsersViewModel::columnCount(const QModelIndex & /*parent*/) const { @@ -28,7 +28,7 @@ QVariant UsersViewModel::headerData(int section, Qt::Orientation orientation, in QVariant UsersViewModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { - auto item = apparatus::instance()->get_auth_subsystem().users()[index.row()]; + auto item = apparatus::instance()->get_auth_subsystem()->users()[index.row()]; int col = index.column(); switch (col) { diff --git a/sea_transport_project.pro.user b/sea_transport_project.pro.user index 62fefe9..be69ce2 100644 --- a/sea_transport_project.pro.user +++ b/sea_transport_project.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -65,10 +65,17 @@ true + Checked + Checked + Checked + Checked Checked + Unchecked Checked + Unchecked Checked Checked + Checked Checked Checked @@ -99,7 +106,7 @@ qt.qt5.5150.win64_mingw81_kit 0 0 - 1 + 0 true 0 diff --git a/st_test/tst_st_test.cpp b/st_test/tst_st_test.cpp index 8a21a9f..0e015bb 100644 --- a/st_test/tst_st_test.cpp +++ b/st_test/tst_st_test.cpp @@ -245,18 +245,18 @@ void st_test::apparatus_check_first_run() { void st_test::apparatus_check_auth_subsystem() { apparatus::init(); - auth_system as = apparatus::instance()->get_auth_subsystem(); + auto as = apparatus::instance()->get_auth_subsystem(); { - bool test = as.register_user("testor", "passwd", UserRole::ADMINISTRATOR); + bool test = as->register_user("testor", "passwd", UserRole::ADMINISTRATOR); QVERIFY(test); } { bool test; - as.get_user("testor", test); + as->get_user("testor", test); QVERIFY(test); } { - bool test = as.remove_user("testor"); + bool test = as->remove_user("testor"); QVERIFY(test); } apparatus::shutdown(); @@ -264,19 +264,19 @@ void st_test::apparatus_check_auth_subsystem() { void st_test::apparatus_check_object_subsystem() { apparatus::init(); - object_system os = apparatus::instance()->get_object_subsystem(); + auto os = apparatus::instance()->get_object_subsystem(); dpoint_entity p("test"); { - bool test = os.add_dpoint(p); + bool test = os->add_dpoint(p); QVERIFY(test); } { bool test; - os.get_dpoint(p.id(), test); + os->get_dpoint(p.id(), test); QVERIFY(test); } { - bool test = os.remove_dpoint(p.id()); + bool test = os->remove_dpoint(p.id()); QVERIFY(test); } apparatus::shutdown(); From 88e36a1c3078213a158028e240985d2c30b99d95 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:15:57 +0700 Subject: [PATCH 10/43] Admin panel edits --- sea_transport/adminpanel.cpp | 4 ++-- sea_transport/adminpanel.ui | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index d424284..868ed4e 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -1,6 +1,6 @@ #include "adminpanel.h" #include "ui_adminpanel.h" - +#include AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) { ui->setupUi(this); @@ -24,7 +24,7 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP // ui->tv_vessels->setModel(); uvm = new UsersViewModel(this); - ui->tv_users->setModel(uvm); + ui->tv_users->setModel(this->uvm); // ui->tv_dp->setModel(); diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index 1542c03..3eaa710 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -25,7 +25,11 @@ - + + + true + + @@ -57,7 +61,11 @@ - + + + true + + @@ -89,7 +97,11 @@ - + + + true + + @@ -121,7 +133,11 @@ - + + + true + + From f58c53cadbd717b958108562a99677ef48e5ea7e Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:16:34 +0700 Subject: [PATCH 11/43] Vessel entity updates --- sea_transport/entities/vessel_entity.cpp | 12 +++++------- sea_transport/entities/vessel_entity.h | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index b4ccdc7..34f1b2b 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -3,7 +3,7 @@ entity_id vessel_entity::__global_id = 0; -vessel_entity::vessel_entity(const dpoint_entity &harbor, unsigned int capacity) : _harbor(harbor), _capacity(capacity) { +vessel_entity::vessel_entity(entity_id harbor_id, unsigned int capacity) : _harbor_id(harbor_id), _capacity(capacity) { this->_id = ++vessel_entity::__global_id; } @@ -11,8 +11,8 @@ entity_id vessel_entity::id() const { return this->_id; } -const dpoint_entity vessel_entity::harbor() const { - return this->_harbor; +entity_id vessel_entity::harbor() const { + return this->_harbor_id; } unsigned int vessel_entity::capacity() const { @@ -24,8 +24,7 @@ const QVector vessel_entity::cargo() { } void vessel_entity::serialize(QDataStream &output) { - output << this->_id; - this->_harbor.serialize(output); + output << this->_id << this->_harbor_id; output << this->_capacity << this->_cargo.size(); for (auto item : this->_cargo) { item.serialize(output); @@ -33,8 +32,7 @@ void vessel_entity::serialize(QDataStream &output) { } void vessel_entity::deserialize(QDataStream &input) { - input >> this->_id; - this->_harbor.deserialize(input); + input >> this->_id >> this->_harbor_id; int icnt; input >> this->_capacity >> icnt; this->_cargo.resize(icnt); diff --git a/sea_transport/entities/vessel_entity.h b/sea_transport/entities/vessel_entity.h index f381f37..e96ecfe 100644 --- a/sea_transport/entities/vessel_entity.h +++ b/sea_transport/entities/vessel_entity.h @@ -11,16 +11,16 @@ private: static entity_id __global_id; entity_id _id; - dpoint_entity _harbor; + entity_id _harbor_id; unsigned int _capacity; QVector _cargo; public: vessel_entity() = default; - vessel_entity(const dpoint_entity &harbor, unsigned int capacity); + vessel_entity(entity_id harbor_id, unsigned int capacity); entity_id id() const; - const dpoint_entity harbor() const; + entity_id harbor() const; unsigned int capacity() const; const QVector cargo(); From 09e67d4031f14406b6952bdfe581bd4ddf1ab801 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:17:04 +0700 Subject: [PATCH 12/43] Auth window update --- sea_transport/authwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index f8a13ff..271365f 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -34,6 +34,8 @@ void AuthWindow::on_auth_requested() { QMessageBox::information(this, "Info", "You are the first user of system. " "Your account type is administrator"); } + + apparatus::instance()->save(); } auto user = a->get_user(login, success); From 72a48428007f8188c2911ecd29b0f04a31fb6b4a Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:17:29 +0700 Subject: [PATCH 13/43] Systems update --- sea_transport/system/apparatus.cpp | 2 +- sea_transport/system/auth_system.cpp | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sea_transport/system/apparatus.cpp b/sea_transport/system/apparatus.cpp index 91c2ec3..9aa878d 100644 --- a/sea_transport/system/apparatus.cpp +++ b/sea_transport/system/apparatus.cpp @@ -59,7 +59,7 @@ void apparatus::load() { QDataStream stream(&f); // loading GIDs - entity_id vgid, sgid; + entity_id vgid, sgid = vgid = 0; stream >> vgid >> sgid; vessel_entity::preloadGlobalId(vgid); storage_entity::preloadGlobalId(sgid); diff --git a/sea_transport/system/auth_system.cpp b/sea_transport/system/auth_system.cpp index a6c53aa..6ac11b7 100644 --- a/sea_transport/system/auth_system.cpp +++ b/sea_transport/system/auth_system.cpp @@ -1,6 +1,5 @@ #include "apparatus.h" #include "auth_system.h" -#include const user_entity* auth_system::get_user(const QString &login, bool &success) { @@ -34,11 +33,7 @@ bool auth_system::register_user(const QString &login, const QString &password, U bool exists = false; this->get_user(login, exists); if (!exists) { - std::cout << apparatus::instance()->get_auth_subsystem()->users().length() << std::endl; this->_users.push_back(user_entity(login, password, role)); - std::cout << apparatus::instance()->get_auth_subsystem()->users().length() << std::endl; - apparatus::instance()->save(); - std::cout << apparatus::instance()->get_auth_subsystem()->users().length() << std::endl; return true; } From 9a4b71de36b9965883dbb9938aa7c07228db61e5 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:18:05 +0700 Subject: [PATCH 14/43] Updates and Vessels viewmodel --- sea_transport/sea_transport.pro | 6 ++++-- sea_transport/viewmodels/usersviewmodel.cpp | 9 +++++---- sea_transport/viewmodels/usersviewmodel.h | 8 ++++---- sea_transport/viewmodels/vesselsviewmodel.cpp | 6 ++++++ sea_transport/viewmodels/vesselsviewmodel.h | 13 +++++++++++++ st_test/tst_st_test.cpp | 4 ++-- 6 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 sea_transport/viewmodels/vesselsviewmodel.cpp create mode 100644 sea_transport/viewmodels/vesselsviewmodel.h diff --git a/sea_transport/sea_transport.pro b/sea_transport/sea_transport.pro index e5ceb58..be07897 100644 --- a/sea_transport/sea_transport.pro +++ b/sea_transport/sea_transport.pro @@ -25,7 +25,8 @@ SOURCES += \ system/object_system.cpp \ usereditdialog.cpp \ vesseleditdialog.cpp \ - viewmodels/usersviewmodel.cpp + viewmodels/usersviewmodel.cpp \ + viewmodels/vesselsviewmodel.cpp HEADERS += \ adminpanel.h \ @@ -45,7 +46,8 @@ HEADERS += \ system/object_system.h \ usereditdialog.h \ vesseleditdialog.h \ - viewmodels/usersviewmodel.h + viewmodels/usersviewmodel.h \ + viewmodels/vesselsviewmodel.h FORMS += \ adminpanel.ui \ diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp index 93785f2..ae938c2 100644 --- a/sea_transport/viewmodels/usersviewmodel.cpp +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -4,11 +4,11 @@ UsersViewModel::UsersViewModel(QObject *parent) : QAbstractTableModel(parent) { } -int UsersViewModel::rowCount(const QModelIndex & /*parent*/) const { - return apparatus::instance()->get_object_subsystem()->vessels().size(); +int UsersViewModel::rowCount(const QModelIndex &/*parent*/) const { + return apparatus::instance()->get_auth_subsystem()->users().length(); } -int UsersViewModel::columnCount(const QModelIndex & /*parent*/) const { +int UsersViewModel::columnCount(const QModelIndex &/*parent*/) const { return 3; } @@ -61,5 +61,6 @@ QVariant UsersViewModel::data(const QModelIndex &index, int role) const { } void UsersViewModel::update() { - this->resetInternalData(); + this->beginResetModel(); + this->endResetModel(); } diff --git a/sea_transport/viewmodels/usersviewmodel.h b/sea_transport/viewmodels/usersviewmodel.h index 411981b..2eda407 100644 --- a/sea_transport/viewmodels/usersviewmodel.h +++ b/sea_transport/viewmodels/usersviewmodel.h @@ -10,10 +10,10 @@ class UsersViewModel : public QAbstractTableModel Q_OBJECT public: UsersViewModel(QObject *parent = nullptr); - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; public slots: void update(); diff --git a/sea_transport/viewmodels/vesselsviewmodel.cpp b/sea_transport/viewmodels/vesselsviewmodel.cpp new file mode 100644 index 0000000..63d7454 --- /dev/null +++ b/sea_transport/viewmodels/vesselsviewmodel.cpp @@ -0,0 +1,6 @@ +#include "vesselsviewmodel.h" + +VesselsViewModel::VesselsViewModel() +{ + +} diff --git a/sea_transport/viewmodels/vesselsviewmodel.h b/sea_transport/viewmodels/vesselsviewmodel.h new file mode 100644 index 0000000..06cfd75 --- /dev/null +++ b/sea_transport/viewmodels/vesselsviewmodel.h @@ -0,0 +1,13 @@ +#ifndef VESSELSVIEWMODEL_H +#define VESSELSVIEWMODEL_H + +#include + +class VesselsViewModel : public QAbstractTableModel +{ + Q_OBJECT +public: + VesselsViewModel(); +}; + +#endif // VESSELSVIEWMODEL_H diff --git a/st_test/tst_st_test.cpp b/st_test/tst_st_test.cpp index 0e015bb..6cfc350 100644 --- a/st_test/tst_st_test.cpp +++ b/st_test/tst_st_test.cpp @@ -165,7 +165,7 @@ void st_test::vessel_entity_serialization_test() { stream.setDevice(&f); dpoint_entity test_harbor("test_harbor_for_vessel"); - ent1 = vessel_entity(test_harbor, 256); + ent1 = vessel_entity(test_harbor.id(), 256); ent1.serialize(stream); stream.setDevice(nullptr); @@ -181,7 +181,7 @@ void st_test::vessel_entity_serialization_test() { } QVERIFY2( - ent1.id() == ent2.id() && ent1.harbor().id() == ent2.harbor().id() && ent1.capacity() == ent2.capacity(), + ent1.id() == ent2.id() && ent1.harbor() == ent2.harbor() && ent1.capacity() == ent2.capacity(), "Delivery Point entity not serialized properly" ); } From fc9b61467c1e16b5a76f16659454083531cdd1b5 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:31:25 +0700 Subject: [PATCH 15/43] UsersVM small code style update --- sea_transport/viewmodels/usersviewmodel.cpp | 15 +++++++-------- sea_transport/viewmodels/usersviewmodel.h | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp index ae938c2..72290fb 100644 --- a/sea_transport/viewmodels/usersviewmodel.cpp +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -29,29 +29,29 @@ QVariant UsersViewModel::headerData(int section, Qt::Orientation orientation, in QVariant UsersViewModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { auto item = apparatus::instance()->get_auth_subsystem()->users()[index.row()]; - int col = index.column(); + int col = index.column(); switch (col) { case 0: return QString::number(item.id()); case 1: return item.login(); case 2: - QString role = "unknown"; + QString _role = "unknown"; switch(item.role()) { case UserRole::ADMINISTRATOR: - role = "Administrator"; + _role = "Administrator"; break; case UserRole::DISPATCHER: - role = "Dispatcher"; + _role = "Dispatcher"; break; case UserRole::SKIPPER: - role = "Skipper"; + _role = "Skipper"; break; } - return role; + return _role; } return "UNKNOWN FIELD"; @@ -61,6 +61,5 @@ QVariant UsersViewModel::data(const QModelIndex &index, int role) const { } void UsersViewModel::update() { - this->beginResetModel(); - this->endResetModel(); + dataChanged(QModelIndex(), QModelIndex()); } diff --git a/sea_transport/viewmodels/usersviewmodel.h b/sea_transport/viewmodels/usersviewmodel.h index 2eda407..40e3813 100644 --- a/sea_transport/viewmodels/usersviewmodel.h +++ b/sea_transport/viewmodels/usersviewmodel.h @@ -5,9 +5,9 @@ #include -class UsersViewModel : public QAbstractTableModel -{ +class UsersViewModel : public QAbstractTableModel { Q_OBJECT + public: UsersViewModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const; From 2f67449c72f6fd05302ad1c72013485b25ea4f1e Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:31:38 +0700 Subject: [PATCH 16/43] Implemented Vessels VM --- sea_transport/viewmodels/vesselsviewmodel.cpp | 63 ++++++++++++++++++- sea_transport/viewmodels/vesselsviewmodel.h | 15 ++++- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/sea_transport/viewmodels/vesselsviewmodel.cpp b/sea_transport/viewmodels/vesselsviewmodel.cpp index 63d7454..accfe2b 100644 --- a/sea_transport/viewmodels/vesselsviewmodel.cpp +++ b/sea_transport/viewmodels/vesselsviewmodel.cpp @@ -1,6 +1,65 @@ #include "vesselsviewmodel.h" -VesselsViewModel::VesselsViewModel() -{ +VesselsViewModel::VesselsViewModel(QObject *parent) : QAbstractTableModel(parent) { } + +int VesselsViewModel::rowCount(const QModelIndex &/*parent*/) const { + return apparatus::instance()->get_object_subsystem()->vessels().length(); +} + +int VesselsViewModel::columnCount(const QModelIndex &/*parent*/) const { + return 5; +} + +QVariant VesselsViewModel::headerData(int section, Qt::Orientation orientation, int role) const { + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { + switch (section) { + case 0: + return QString("VID"); + case 1: + return QString("Harbor"); + case 2: + return QString("Capacity"); + case 3: + return QString("Cargo count"); + case 4: + return QString("Cargo volume"); + } + } + return QVariant(); +} + +QVariant VesselsViewModel::data(const QModelIndex &index, int role) const { + if (role == Qt::DisplayRole) { + auto item = apparatus::instance()->get_object_subsystem()->vessels()[index.row()]; + bool s = false; + auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(item.harbor(), s); + + int col = index.column(); + switch (col) { + case 0: + return QString::number(item.id()); + case 1: + return (s? harbor->title() : "##ERROR##"); + case 2: + return item.capacity(); + case 3: + return item.cargo().length(); + case 4: + int cvol = 0; + foreach (auto cargo, item.cargo()) { + cvol += cargo.volume(); + } + return cvol; + } + + return "UNKNOWN FIELD"; + } + + return QVariant(); +} + +void VesselsViewModel::update() { + dataChanged(QModelIndex(), QModelIndex()); +} diff --git a/sea_transport/viewmodels/vesselsviewmodel.h b/sea_transport/viewmodels/vesselsviewmodel.h index 06cfd75..b861fb9 100644 --- a/sea_transport/viewmodels/vesselsviewmodel.h +++ b/sea_transport/viewmodels/vesselsviewmodel.h @@ -1,13 +1,22 @@ #ifndef VESSELSVIEWMODEL_H #define VESSELSVIEWMODEL_H +#include "system/apparatus.h" + #include -class VesselsViewModel : public QAbstractTableModel -{ +class VesselsViewModel : public QAbstractTableModel { Q_OBJECT + public: - VesselsViewModel(); + VesselsViewModel(QObject *parent = nullptr); + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + +public slots: + void update(); }; #endif // VESSELSVIEWMODEL_H From 6231e7efb00c660e0a1ce93c1a45643f08b95b97 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:40:40 +0700 Subject: [PATCH 17/43] Add and implemented Delivery Point VM --- sea_transport/sea_transport.pro | 2 + .../viewmodels/deliverypointsviewmodel.cpp | 59 +++++++++++++++++++ .../viewmodels/deliverypointsviewmodel.h | 22 +++++++ 3 files changed, 83 insertions(+) create mode 100644 sea_transport/viewmodels/deliverypointsviewmodel.cpp create mode 100644 sea_transport/viewmodels/deliverypointsviewmodel.h diff --git a/sea_transport/sea_transport.pro b/sea_transport/sea_transport.pro index be07897..bf9d0a6 100644 --- a/sea_transport/sea_transport.pro +++ b/sea_transport/sea_transport.pro @@ -25,6 +25,7 @@ SOURCES += \ system/object_system.cpp \ usereditdialog.cpp \ vesseleditdialog.cpp \ + viewmodels/deliverypointsviewmodel.cpp \ viewmodels/usersviewmodel.cpp \ viewmodels/vesselsviewmodel.cpp @@ -46,6 +47,7 @@ HEADERS += \ system/object_system.h \ usereditdialog.h \ vesseleditdialog.h \ + viewmodels/deliverypointsviewmodel.h \ viewmodels/usersviewmodel.h \ viewmodels/vesselsviewmodel.h diff --git a/sea_transport/viewmodels/deliverypointsviewmodel.cpp b/sea_transport/viewmodels/deliverypointsviewmodel.cpp new file mode 100644 index 0000000..5823d9c --- /dev/null +++ b/sea_transport/viewmodels/deliverypointsviewmodel.cpp @@ -0,0 +1,59 @@ +#include "deliverypointsviewmodel.h" + +DeliveryPointsViewModel::DeliveryPointsViewModel(QObject *parent) : QAbstractTableModel(parent) { + +} + +int DeliveryPointsViewModel::rowCount(const QModelIndex &/*parent*/) const { + return apparatus::instance()->get_object_subsystem()->dpoints().length(); +} + +int DeliveryPointsViewModel::columnCount(const QModelIndex &/*parent*/) const { + return 4; +} + +QVariant DeliveryPointsViewModel::headerData(int section, Qt::Orientation orientation, int role) const { + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { + switch (section) { + case 0: + return QString("DPID"); + case 1: + return QString("Title"); + case 2: + return QString("Storages count"); + case 3: + return QString("Storages total volume"); + } + } + return QVariant(); +} + +QVariant DeliveryPointsViewModel::data(const QModelIndex &index, int role) const { + if (role == Qt::DisplayRole) { + auto item = apparatus::instance()->get_object_subsystem()->dpoints()[index.row()]; + + int col = index.column(); + switch (col) { + case 0: + return QString::number(item.id()); + case 1: + return item.title(); + case 2: + return item.storages().length(); + case 3: + int tvol = 0; + foreach (auto storage, item.storages()) { + tvol += storage.capacity(); + } + return tvol; + } + + return "UNKNOWN FIELD"; + } + + return QVariant(); +} + +void DeliveryPointsViewModel::update() { + dataChanged(QModelIndex(), QModelIndex()); +} diff --git a/sea_transport/viewmodels/deliverypointsviewmodel.h b/sea_transport/viewmodels/deliverypointsviewmodel.h new file mode 100644 index 0000000..bfbfb40 --- /dev/null +++ b/sea_transport/viewmodels/deliverypointsviewmodel.h @@ -0,0 +1,22 @@ +#ifndef DELIVERYPOINTSVIEWMODEL_H +#define DELIVERYPOINTSVIEWMODEL_H + +#include "system/apparatus.h" + +#include + +class DeliveryPointsViewModel : public QAbstractTableModel { + Q_OBJECT + +public: + DeliveryPointsViewModel(QObject *parent = nullptr); + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + +public slots: + void update(); +}; + +#endif // DELIVERYPOINTSVIEWMODEL_H From 3adbef8c08b8996d405b99f12a4fcc1fa47327eb Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 23:05:38 +0700 Subject: [PATCH 18/43] Redone Admin panel UI --- sea_transport/adminpanel.cpp | 21 +-- sea_transport/adminpanel.h | 7 +- sea_transport/adminpanel.ui | 338 +++++++++++++++++++---------------- 3 files changed, 190 insertions(+), 176 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 868ed4e..2418e16 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -14,24 +14,23 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP // connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_user_add); // connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_user_remove); -// connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_storage_add); -// connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_storage_remove); - // connect(ui->pb_dp_add, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_add); // connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); -// ui->tv_vessels->setModel(); - uvm = new UsersViewModel(this); ui->tv_users->setModel(this->uvm); -// ui->tv_dp->setModel(); + vvm = new VesselsViewModel(this); + ui->tv_vessels->setModel(vvm); -// ui->tv_storages->setModel(); + dpvm = new DeliveryPointsViewModel(this); + ui->tv_dp->setModel(dpvm); uvm->update(); + vvm->update(); + dpvm->update(); } AdminPanel::~AdminPanel() { @@ -66,14 +65,6 @@ void AdminPanel::on_user_remove() { } -void AdminPanel::on_storage_add() { - -} - -void AdminPanel::on_storage_remove() { - -} - void AdminPanel::on_delivery_point_add() { } diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index a65ce20..8152158 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -4,6 +4,8 @@ #include #include "viewmodels/usersviewmodel.h" +#include "viewmodels/vesselsviewmodel.h" +#include "viewmodels/deliverypointsviewmodel.h" #include "entities/user_entity.h" @@ -18,6 +20,8 @@ class AdminPanel : public QMainWindow user_entity user; UsersViewModel *uvm; + VesselsViewModel *vvm; + DeliveryPointsViewModel *dpvm; public: explicit AdminPanel(QWidget *parent = nullptr); @@ -38,9 +42,6 @@ private: void on_user_add(); void on_user_remove(); - void on_storage_add(); - void on_storage_remove(); - void on_delivery_point_add(); void on_delivery_point_remove(); }; diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index 3eaa710..98e15da 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -6,169 +6,21 @@ 0 0 - 1200 - 600 + 1162 + 567 + + + 0 + 0 + + MainWindow - - - - - - - Vessels - - - - - - - true - - - - - - - - - Add - - - - - - - Remove - - - - - - - - - - - - - Users - - - - - - - true - - - - - - - - - Add - - - - - - - Remove - - - - - - - - - - - - - Delivery points - - - - - - - true - - - - - - - - - Add - - - - - - - Remove - - - - - - - - - - - - - Storages - - - - - - - true - - - - - - - - - Add - - - - - - - Remove - - - - - - - - - - - Hello, user %1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - + @@ -182,6 +34,176 @@ + + + + Hello, user %1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QTabWidget::Rounded + + + 2 + + + false + + + false + + + + Users + + + + + + true + + + + + + + Qt::Horizontal + + + + 953 + 20 + + + + + + + + + + Add + + + + + + + false + + + Remove + + + + + + + + + + Vessels + + + + + + + + Add + + + + + + + false + + + Remove + + + + + + + + + Qt::Horizontal + + + + 953 + 20 + + + + + + + + true + + + + + + + + Delivery points + + + + + + Qt::Horizontal + + + + 953 + 20 + + + + + + + + + + Add + + + + + + + false + + + Remove + + + + + + + + + true + + + + + + + @@ -189,7 +211,7 @@ 0 0 - 1200 + 1162 21 From e24554a0a0d8058bf0c6cbef84cd96ab32145653 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 01:03:13 +0700 Subject: [PATCH 19/43] User edit dialog completed --- sea_transport/adminpanel.cpp | 174 ++++++++++++++++++-- sea_transport/adminpanel.h | 12 +- sea_transport/adminpanel.ui | 59 +++++-- sea_transport/entities/user_entity.cpp | 8 + sea_transport/entities/user_entity.h | 2 + sea_transport/system/auth_system.cpp | 2 +- sea_transport/system/auth_system.h | 2 +- sea_transport/usereditdialog.cpp | 75 ++++++++- sea_transport/usereditdialog.h | 23 ++- sea_transport/usereditdialog.ui | 2 +- sea_transport/viewmodels/usersviewmodel.cpp | 3 +- 11 files changed, 315 insertions(+), 47 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 2418e16..1bda76f 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -1,21 +1,36 @@ #include "adminpanel.h" #include "ui_adminpanel.h" -#include + AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) { ui->setupUi(this); -// connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); + connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); -// connect(ui->pb_vessels_add, &QPushButton::clicked, this, &AdminPanel::on_vessel_add); -// connect(ui->pb_vessels_remove, &QPushButton::clicked, this, &AdminPanel::on_vessel_remove); + connect(ui->pb_vessels_add, &QPushButton::clicked, this, [this](){ + this->on_vessel_add_edit(false); + }); + connect(ui->pb_vessels_edit, &QPushButton::clicked, this, [this](){ + this->on_vessel_add_edit(true); + }); + connect(ui->pb_vessels_remove, &QPushButton::clicked, this, &AdminPanel::on_vessel_remove); -// connect(ui->pb_users_add, &QPushButton::clicked, this, &AdminPanel::on_user_add); -// connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_user_remove); + connect(ui->pb_users_add, &QPushButton::clicked, this, [this](){ + this->on_user_add_edit(false); + }); + connect(ui->pb_users_edit, &QPushButton::clicked, this, [this](){ + this->on_user_add_edit(true); + }); + connect(ui->pb_users_remove, &QPushButton::clicked, this, &AdminPanel::on_user_remove); -// connect(ui->pb_dp_add, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_add); -// connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); + connect(ui->pb_dp_add, &QPushButton::clicked, this, [this](){ + this->on_delivery_point_add_edit(false); + }); + connect(ui->pb_dp_edit, &QPushButton::clicked, this, [this](){ + this->on_delivery_point_add_edit(true); + }); + connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); uvm = new UsersViewModel(this); @@ -27,48 +42,175 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP dpvm = new DeliveryPointsViewModel(this); ui->tv_dp->setModel(dpvm); + connect(ui->tv_users->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + ui->pb_users_remove->setEnabled(selected.length() > 0); + ui->pb_users_edit->setEnabled(selected.length() == 1); + }); - uvm->update(); - vvm->update(); - dpvm->update(); + connect(ui->tv_vessels->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + ui->pb_vessels_remove->setEnabled(selected.length() > 0); + ui->pb_vessels_edit->setEnabled(selected.length() == 1); + }); + + connect(ui->tv_dp->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + ui->pb_dp_remove->setEnabled(selected.length() > 0); + ui->pb_dp_edit->setEnabled(selected.length() == 1); + }); + + ui->tw_tabs->setCurrentIndex(0); } AdminPanel::~AdminPanel() { delete ui; delete uvm; + delete vvm; + delete dpvm; } AdminPanel& AdminPanel::set_user(const user_entity &user) { this->user = user; - ui->lab_user->setText(tr("Hello user %1").arg(user.login())); + ui->lab_user->setText(tr("Hello, **%1**").arg(user.login())); return *this; } void AdminPanel::on_logout_requested() { - + this->close(); } -void AdminPanel::on_vessel_add() { +void AdminPanel::on_vessel_add_edit(bool edit) { } void AdminPanel::on_vessel_remove() { + auto selected = ui->tv_vessels->selectionModel()->selectedRows(); + if (selected.length() == 0) { + return; + } + QMessageBox delConf(this); + delConf.setIcon(QMessageBox::Question); + delConf.setWindowTitle(tr("Deletion confirmation")); + delConf.setText(tr("Are you sure you want to delete these vessels?")); + delConf.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + delConf.setDefaultButton(QMessageBox::No); + if (delConf.exec() == QMessageBox::No) { + return; + } + + foreach (auto mIdx, selected) { + int idx = mIdx.row(); + qDebug() << idx << ' ' << mIdx.data() << '\n'; + } + + vvm->update(); } -void AdminPanel::on_user_add() { +void AdminPanel::on_user_add_edit(bool edit) { + auto selected = ui->tv_users->selectionModel()->selectedRows(); + if (edit && selected.length() != 1) { + return; + } + user_entity usr; + if (edit) { + int idx = selected[0].row(); + usr = apparatus::instance()->get_auth_subsystem()->users()[idx]; + if (usr.id() == this->user.id()) { + QMessageBox::critical(this, "Error", "You cannot edit yourself"); + return; + } + } + + UserEditDialog ued(this); + ued.setWindowTitle(edit? "Edit user" : "New user"); + ued.set_user(&usr, edit); + if (ued.exec() != UserEditDialog::Accepted) { + return; + } + + auto data = ued.user(); + if (edit) { + bool success; + auto user = apparatus::instance()->get_auth_subsystem()->get_user(usr.login(), success); + if (success) { + user->set_password(data->password); + user->set_role(data->role); + QMessageBox::information(this, "Info", "User edited successfully (note: you cannot change login)"); + } + else { + QMessageBox::critical(this, "Error", "Error while editing user"); + return; + } + } + else { + bool success = apparatus::instance()->get_auth_subsystem()->register_user(data->login, data->password, data->role); + if (success) { + QMessageBox::information(this, "Info", "User created successfully"); + } + else { + QMessageBox::critical(this, "Error", "Error while creating user"); + return; + } + } + + uvm->update(); } void AdminPanel::on_user_remove() { + auto selected = ui->tv_users->selectionModel()->selectedRows(); + if (selected.length() == 0) { + return; + } + QMessageBox delConf(this); + delConf.setIcon(QMessageBox::Question); + delConf.setWindowTitle(tr("Deletion confirmation")); + delConf.setText(tr("Are you sure you want to delete these users?")); + delConf.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + delConf.setDefaultButton(QMessageBox::No); + if (delConf.exec() == QMessageBox::No) { + return; + } + + auto _u = apparatus::instance()->get_auth_subsystem()->users(); + foreach (auto mIdx, selected) { + int idx = mIdx.row(); + auto ent = _u[idx]; + if (ent.id() == user.id()) { + QMessageBox::critical(this, "Error", "You cannot delete yourself!"); + break; + } + apparatus::instance()->get_auth_subsystem()->remove_user(ent.login()); + } + + uvm->update(); } -void AdminPanel::on_delivery_point_add() { +void AdminPanel::on_delivery_point_add_edit(bool edit) { } void AdminPanel::on_delivery_point_remove() { + auto selected = ui->tv_dp->selectionModel()->selectedRows(); + if (selected.length() == 0) { + return; + } + QMessageBox delConf(this); + delConf.setIcon(QMessageBox::Question); + delConf.setWindowTitle(tr("Deletion confirmation")); + delConf.setText(tr("Are you sure you want to delete these delivery points?")); + delConf.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + delConf.setDefaultButton(QMessageBox::No); + if (delConf.exec() == QMessageBox::No) { + return; + } + + foreach (auto mIdx, selected) { + int idx = mIdx.row(); + qDebug() << idx << ' ' << mIdx.data() << '\n'; + } + + dpvm->update(); } diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index 8152158..3489f39 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -2,6 +2,12 @@ #define ADMINPANEL_H #include +#include +#include + +#include "usereditdialog.h" +#include "vesseleditdialog.h" +#include "deliverypointeditdialog.h" #include "viewmodels/usersviewmodel.h" #include "viewmodels/vesselsviewmodel.h" @@ -36,13 +42,13 @@ private: void on_logout_requested(); - void on_vessel_add(); + void on_vessel_add_edit(bool edit); void on_vessel_remove(); - void on_user_add(); + void on_user_add_edit(bool edit); void on_user_remove(); - void on_delivery_point_add(); + void on_delivery_point_add_edit(bool edit); void on_delivery_point_remove(); }; diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index 98e15da..cc86acc 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -7,7 +7,7 @@ 0 0 1162 - 567 + 532 @@ -37,7 +37,10 @@ - Hello, user %1 + Hello, %1 + + + Qt::MarkdownText Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -65,6 +68,9 @@ + + QAbstractItemView::SelectRows + true @@ -92,6 +98,16 @@ + + + + false + + + Edit + + + @@ -120,6 +136,16 @@ + + + + false + + + Edit + + + @@ -147,6 +173,9 @@ + + QAbstractItemView::SelectRows + true @@ -154,7 +183,7 @@ - + Delivery points @@ -181,6 +210,16 @@ + + + + false + + + Edit + + + @@ -195,6 +234,9 @@ + + QAbstractItemView::SelectRows + true @@ -206,17 +248,6 @@ - - - - 0 - 0 - 1162 - 21 - - - - diff --git a/sea_transport/entities/user_entity.cpp b/sea_transport/entities/user_entity.cpp index 5cd56a7..a54471f 100644 --- a/sea_transport/entities/user_entity.cpp +++ b/sea_transport/entities/user_entity.cpp @@ -20,6 +20,14 @@ bool user_entity::verify_password(const QString &password) const { return (this->_pwd_hash == QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256)); } +void user_entity::set_password(const QString &new_password) { + this->_pwd_hash = QCryptographicHash::hash(new_password.toLocal8Bit(), QCryptographicHash::Sha3_256); +} + +void user_entity::set_role(UserRole new_role) { + this->_role = new_role; +} + void user_entity::serialize(QDataStream &output) { output << this->_id << this->_login << this->_role << this->_pwd_hash; } diff --git a/sea_transport/entities/user_entity.h b/sea_transport/entities/user_entity.h index 890279c..1bf4203 100644 --- a/sea_transport/entities/user_entity.h +++ b/sea_transport/entities/user_entity.h @@ -27,6 +27,8 @@ public: const QString login() const; UserRole role() const; bool verify_password(const QString &password) const; + void set_password(const QString &new_password); + void set_role(UserRole new_role); void serialize(QDataStream &output); void deserialize(QDataStream &input); diff --git a/sea_transport/system/auth_system.cpp b/sea_transport/system/auth_system.cpp index 6ac11b7..f10adc4 100644 --- a/sea_transport/system/auth_system.cpp +++ b/sea_transport/system/auth_system.cpp @@ -2,7 +2,7 @@ #include "auth_system.h" -const user_entity* auth_system::get_user(const QString &login, bool &success) { +user_entity* auth_system::get_user(const QString &login, bool &success) { user_entity *out = nullptr; success = false; diff --git a/sea_transport/system/auth_system.h b/sea_transport/system/auth_system.h index ecc42ae..21dd056 100644 --- a/sea_transport/system/auth_system.h +++ b/sea_transport/system/auth_system.h @@ -13,7 +13,7 @@ private: public: auth_system() = default; - const user_entity* get_user(const QString &login, bool &success); + user_entity* get_user(const QString &login, bool &success); bool remove_user(const QString &login); bool register_user(const QString &login, const QString &password, UserRole role); diff --git a/sea_transport/usereditdialog.cpp b/sea_transport/usereditdialog.cpp index a052c47..c0c2650 100644 --- a/sea_transport/usereditdialog.cpp +++ b/sea_transport/usereditdialog.cpp @@ -1,14 +1,77 @@ #include "usereditdialog.h" #include "ui_usereditdialog.h" -UserEditDialog::UserEditDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::UserEditDialog) -{ +UserEditDialog::UserEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::UserEditDialog) { ui->setupUi(this); + + connect(ui->btn_save, &QPushButton::clicked, this, &UserEditDialog::accept); + connect(ui->btn_discard, &QPushButton::clicked, this, &UserEditDialog::reject); } -UserEditDialog::~UserEditDialog() -{ +UserEditDialog::~UserEditDialog() { delete ui; } + +UserEditDialog::user_data* UserEditDialog::user() const { + return this->_user; +} + +void UserEditDialog::set_user(user_entity* user, bool edit) { + if (edit) { + this->_user = new UserEditDialog::user_data { + user->login(), "", user->role(), true + }; + + ui->et_login->setText(user->login()); + ui->et_password->setText("##########UNEDITED##########"); + ui->cb_role->setCurrentIndex((int)user->role()); + } + else { + this->_user = new UserEditDialog::user_data{}; + } + this->_user->edit = edit; +} + +void UserEditDialog::accept() { + UserRole role; + switch (ui->cb_role->currentIndex()) { + case 0: + role = UserRole::ADMINISTRATOR; + break; + case 1: + role = UserRole::DISPATCHER; + break; + case 2: + role = UserRole::SKIPPER; + break; + } + bool emptyTitle = ui->et_login->text().trimmed().isEmpty(); + bool emptyPassword = ui->et_password->text().trimmed().isEmpty(); + bool lowerank = this->_user->edit && this->_user->role < role; + if (emptyTitle || emptyPassword || lowerank) { + QMessageBox errDlg(this); + errDlg.setTextFormat(Qt::RichText); + errDlg.setWindowTitle(tr("Error")); + errDlg.setIcon(QMessageBox::Critical); + QString message = tr("Some errors happend, while saving your note:"); + if (emptyTitle) { + message.append("
- Title cannot be empty (all spaces - empty too)"); + } + if (emptyPassword) { + message.append("
- Password cannot be empty (all spaces - empty too)"); + } + if (lowerank) { + message.append("
- You cannot lower users rank"); + } + errDlg.setText(message); + errDlg.exec(); + return; + } + ; + + this->_user->login = ui->et_login->text().trimmed(); + this->_user->password = ui->et_password->text().trimmed(); + this->_user->role = role; + + QDialog::accept(); +} diff --git a/sea_transport/usereditdialog.h b/sea_transport/usereditdialog.h index 26a93e7..7fb13ca 100644 --- a/sea_transport/usereditdialog.h +++ b/sea_transport/usereditdialog.h @@ -2,21 +2,36 @@ #define USEREDITDIALOG_H #include +#include + +#include "entities/user_entity.h" + namespace Ui { class UserEditDialog; } -class UserEditDialog : public QDialog -{ +class UserEditDialog : public QDialog { Q_OBJECT + Ui::UserEditDialog *ui; + + struct user_data { + QString login; + QString password; + UserRole role; + bool edit; + } *_user; public: explicit UserEditDialog(QWidget *parent = nullptr); ~UserEditDialog(); -private: - Ui::UserEditDialog *ui; + UserEditDialog::user_data* user() const; + void set_user(user_entity* user, bool edit); + + +public slots: + void accept() Q_DECL_OVERRIDE; }; #endif // USEREDITDIALOG_H diff --git a/sea_transport/usereditdialog.ui b/sea_transport/usereditdialog.ui index 674bbb2..8ec17a4 100644 --- a/sea_transport/usereditdialog.ui +++ b/sea_transport/usereditdialog.ui @@ -68,7 +68,7 @@
- Captain + Skipper diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp index 72290fb..9269d34 100644 --- a/sea_transport/viewmodels/usersviewmodel.cpp +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -61,5 +61,6 @@ QVariant UsersViewModel::data(const QModelIndex &index, int role) const { } void UsersViewModel::update() { - dataChanged(QModelIndex(), QModelIndex()); + this->beginResetModel(); + this->endResetModel(); } From 4a3951938aeed3b6a5bc2e33f0e6bd546c0b42b3 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 01:23:36 +0700 Subject: [PATCH 20/43] Vessel interaction update --- sea_transport/entities/vessel_entity.cpp | 23 ++++++++++++++++++++++- sea_transport/entities/vessel_entity.h | 6 +++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index 34f1b2b..e3bd829 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -3,7 +3,7 @@ entity_id vessel_entity::__global_id = 0; -vessel_entity::vessel_entity(entity_id harbor_id, unsigned int capacity) : _harbor_id(harbor_id), _capacity(capacity) { +vessel_entity::vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity) : _skipper_id(skipper_id), _harbor_id(harbor_id), _capacity(capacity) { this->_id = ++vessel_entity::__global_id; } @@ -23,6 +23,27 @@ const QVector vessel_entity::cargo() { return this->_cargo; } +void vessel_entity::add_cargo(cargo_entity object, bool &success) { + success = ((int)this->_capacity - (int)object.volume()) > 0; + if (success) { + this->_cargo.push_back(object); + this->_capacity -= object.volume(); + } +} + +void vessel_entity::withdraw_cargo(entity_id oid, bool &success) { + success = false; + auto vit = this->_cargo.begin(); + for (; vit != this->_cargo.end(); vit++) { + if ((*vit).id() == oid) { + this->_capacity += (*vit).volume(); + this->_cargo.erase(vit); + success = true; + break; + } + } +} + void vessel_entity::serialize(QDataStream &output) { output << this->_id << this->_harbor_id; output << this->_capacity << this->_cargo.size(); diff --git a/sea_transport/entities/vessel_entity.h b/sea_transport/entities/vessel_entity.h index e96ecfe..22a1c7c 100644 --- a/sea_transport/entities/vessel_entity.h +++ b/sea_transport/entities/vessel_entity.h @@ -11,19 +11,23 @@ private: static entity_id __global_id; entity_id _id; + entity_id _skipper_id; entity_id _harbor_id; unsigned int _capacity; QVector _cargo; public: vessel_entity() = default; - vessel_entity(entity_id harbor_id, unsigned int capacity); + vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity); entity_id id() const; entity_id harbor() const; unsigned int capacity() const; const QVector cargo(); + void add_cargo(cargo_entity object, bool &success); + void withdraw_cargo(entity_id oid, bool &success); + void serialize(QDataStream &output); void deserialize(QDataStream &input); static void preloadGlobalId(entity_id gid); From 05776f19f38f5a716550f92b633147af09a5467e Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 01:30:11 +0700 Subject: [PATCH 21/43] Entities update --- sea_transport/adminpanel.ui | 2 +- sea_transport/entities/dpoint_entity.cpp | 8 ++++++-- sea_transport/entities/dpoint_entity.h | 4 +++- sea_transport/entities/vessel_entity.cpp | 4 ++++ sea_transport/entities/vessel_entity.h | 1 + st_test/tst_st_test.cpp | 6 +++--- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index cc86acc..ac236f6 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -53,7 +53,7 @@ QTabWidget::Rounded - 2 + 0 false diff --git a/sea_transport/entities/dpoint_entity.cpp b/sea_transport/entities/dpoint_entity.cpp index abc256a..ed5b926 100644 --- a/sea_transport/entities/dpoint_entity.cpp +++ b/sea_transport/entities/dpoint_entity.cpp @@ -1,7 +1,7 @@ #include "dpoint_entity.h" -dpoint_entity::dpoint_entity(const QString &title) : _title(title) { - this->_id = 0; +dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _dispatcher_id(dispatcher_id), _title(title) { + this->_id = dispatcher_id; auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5); for (auto bit : hash) { this->_id += bit; @@ -12,6 +12,10 @@ entity_id dpoint_entity::id() const { return this->_id; } +entity_id dpoint_entity::dispatcher() const { + return this->_dispatcher_id; +} + QString dpoint_entity::title() const { return this->_title; } diff --git a/sea_transport/entities/dpoint_entity.h b/sea_transport/entities/dpoint_entity.h index 037f8ff..90fb4a4 100644 --- a/sea_transport/entities/dpoint_entity.h +++ b/sea_transport/entities/dpoint_entity.h @@ -12,14 +12,16 @@ class dpoint_entity : public IEntity { private: entity_id _id; + entity_id _dispatcher_id; QString _title; QVector _storages; public: dpoint_entity() = default; - dpoint_entity(const QString &title); + dpoint_entity(entity_id dispatcher_id, const QString &title); entity_id id() const; + entity_id dispatcher() const; QString title() const; const QVector storages(); diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index e3bd829..45ce0a0 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -11,6 +11,10 @@ entity_id vessel_entity::id() const { return this->_id; } +entity_id vessel_entity::skipper() const { + return this->_skipper_id; +} + entity_id vessel_entity::harbor() const { return this->_harbor_id; } diff --git a/sea_transport/entities/vessel_entity.h b/sea_transport/entities/vessel_entity.h index 22a1c7c..9b72c90 100644 --- a/sea_transport/entities/vessel_entity.h +++ b/sea_transport/entities/vessel_entity.h @@ -21,6 +21,7 @@ public: vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity); entity_id id() const; + entity_id skipper() const; entity_id harbor() const; unsigned int capacity() const; const QVector cargo(); diff --git a/st_test/tst_st_test.cpp b/st_test/tst_st_test.cpp index 6cfc350..3c8ca78 100644 --- a/st_test/tst_st_test.cpp +++ b/st_test/tst_st_test.cpp @@ -164,8 +164,8 @@ void st_test::vessel_entity_serialization_test() { f.open(QIODevice::WriteOnly); stream.setDevice(&f); - dpoint_entity test_harbor("test_harbor_for_vessel"); - ent1 = vessel_entity(test_harbor.id(), 256); + dpoint_entity test_harbor(0, "test_harbor_for_vessel"); + ent1 = vessel_entity(0, test_harbor.id(), 256); ent1.serialize(stream); stream.setDevice(nullptr); @@ -265,7 +265,7 @@ void st_test::apparatus_check_auth_subsystem() { void st_test::apparatus_check_object_subsystem() { apparatus::init(); auto os = apparatus::instance()->get_object_subsystem(); - dpoint_entity p("test"); + dpoint_entity p(0, "test"); { bool test = os->add_dpoint(p); QVERIFY(test); From a6c080d36bcccc7e03b42c6067e8cd6b499fa467 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 03:17:06 +0700 Subject: [PATCH 22/43] Cargo edit dialog and VM --- sea_transport/cargoeditdialog.cpp | 24 ++++++--- sea_transport/cargoeditdialog.h | 15 ++++-- sea_transport/cargoeditdialog.ui | 33 +++++-------- sea_transport/viewmodels/cargoviewmodel.cpp | 54 +++++++++++++++++++++ sea_transport/viewmodels/cargoviewmodel.h | 24 +++++++++ 5 files changed, 118 insertions(+), 32 deletions(-) create mode 100644 sea_transport/viewmodels/cargoviewmodel.cpp create mode 100644 sea_transport/viewmodels/cargoviewmodel.h diff --git a/sea_transport/cargoeditdialog.cpp b/sea_transport/cargoeditdialog.cpp index b481bbf..67c9a1e 100644 --- a/sea_transport/cargoeditdialog.cpp +++ b/sea_transport/cargoeditdialog.cpp @@ -1,14 +1,26 @@ #include "cargoeditdialog.h" #include "ui_cargoeditdialog.h" -CargoEditDialog::CargoEditDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::CargoEditDialog) -{ +CargoEditDialog::CargoEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CargoEditDialog) { ui->setupUi(this); } -CargoEditDialog::~CargoEditDialog() -{ +CargoEditDialog::~CargoEditDialog() { delete ui; } + +cargo_entity* CargoEditDialog::cargo() { + return this->_cargo; +} + +void CargoEditDialog::accept() { + bool emptyTitle = ui->et_title->text().trimmed().isEmpty(); + if (emptyTitle) { + QMessageBox::critical(this, "Error", "Title cannot be empty"); + return; + } + + this->_cargo = new cargo_entity(ui->et_title->text().trimmed(), ui->sb_volume->value()); + + QDialog::accept(); +} diff --git a/sea_transport/cargoeditdialog.h b/sea_transport/cargoeditdialog.h index 2da4b33..fcab6ea 100644 --- a/sea_transport/cargoeditdialog.h +++ b/sea_transport/cargoeditdialog.h @@ -2,21 +2,28 @@ #define CARGOEDITDIALOG_H #include +#include + +#include "entities/cargo_entity.h" namespace Ui { class CargoEditDialog; } -class CargoEditDialog : public QDialog -{ +class CargoEditDialog : public QDialog { Q_OBJECT + Ui::CargoEditDialog *ui; + + cargo_entity *_cargo; public: explicit CargoEditDialog(QWidget *parent = nullptr); ~CargoEditDialog(); -private: - Ui::CargoEditDialog *ui; + cargo_entity* cargo(); + +public slots: + void accept() Q_DECL_OVERRIDE; }; #endif // CARGOEDITDIALOG_H diff --git a/sea_transport/cargoeditdialog.ui b/sea_transport/cargoeditdialog.ui index a6b62e3..da14928 100644 --- a/sea_transport/cargoeditdialog.ui +++ b/sea_transport/cargoeditdialog.ui @@ -7,7 +7,7 @@ 0 0 318 - 279 + 127 @@ -19,12 +19,12 @@ - Cargo ID: + Title - + @@ -33,28 +33,17 @@ - Quantity: + Volume: - - - + + + 1 - - - - - - Destination: - - - - - - - Choose... + + 500 @@ -76,14 +65,14 @@ - + Discard - + Save diff --git a/sea_transport/viewmodels/cargoviewmodel.cpp b/sea_transport/viewmodels/cargoviewmodel.cpp new file mode 100644 index 0000000..ef6621a --- /dev/null +++ b/sea_transport/viewmodels/cargoviewmodel.cpp @@ -0,0 +1,54 @@ +#include "cargoviewmodel.h" + +CargoViewModel::CargoViewModel(QObject *parent) : QAbstractTableModel(parent) { + +} + +int CargoViewModel::rowCount(const QModelIndex &/*parent*/) const { + return this->_data.length(); +} + +int CargoViewModel::columnCount(const QModelIndex &/*parent*/) const { + return 3; +} + +QVariant CargoViewModel::headerData(int section, Qt::Orientation orientation, int role) const { + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { + switch (section) { + case 0: + return QString("SID"); + case 1: + return QString("Title"); + case 2: + return QString("Volume"); + } + } + return QVariant(); +} + +QVariant CargoViewModel::data(const QModelIndex &index, int role) const { + if (role == Qt::DisplayRole) { + auto item = this->_data[index.row()]; + + int col = index.column(); + switch (col) { + case 0: + return QString::number(item.id()); + case 1: + return item.title(); + case 2: + return item.volume(); + } + + return "UNKNOWN FIELD"; + } + + return QVariant(); +} + +void CargoViewModel::set_data(const QVector &new_data) { + this->beginResetModel(); + this->_data.clear(); + this->_data += new_data; + this->endResetModel(); +} diff --git a/sea_transport/viewmodels/cargoviewmodel.h b/sea_transport/viewmodels/cargoviewmodel.h new file mode 100644 index 0000000..26db7b1 --- /dev/null +++ b/sea_transport/viewmodels/cargoviewmodel.h @@ -0,0 +1,24 @@ +#ifndef CARGOVIEWMODEL_H +#define CARGOVIEWMODEL_H + +#include +#include + +#include "entities/cargo_entity.h" + +class CargoViewModel : public QAbstractTableModel { + Q_OBJECT + + QVector _data; + +public: + CargoViewModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + void set_data(const QVector &new_data); +}; + +#endif // CARGOVIEWMODEL_H From 3e196f35746d55dbf6948749c061d7fd3629d766 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 04:26:18 +0700 Subject: [PATCH 23/43] Delivery point editor done --- sea_transport/adminpanel.cpp | 42 ++++++- sea_transport/adminpanel.h | 1 + sea_transport/cargoeditdialog.cpp | 3 + sea_transport/deliverypointeditdialog.cpp | 114 +++++++++++++++++- sea_transport/deliverypointeditdialog.h | 28 ++++- sea_transport/deliverypointeditdialog.ui | 24 +++- sea_transport/entities/dpoint_entity.cpp | 18 +++ sea_transport/entities/dpoint_entity.h | 4 + sea_transport/entities/storage_entity.cpp | 4 + sea_transport/entities/storage_entity.h | 1 + sea_transport/sea_transport.pro | 2 + sea_transport/storageeditdialog.cpp | 78 +++++++++++- sea_transport/storageeditdialog.h | 22 +++- sea_transport/storageeditdialog.ui | 51 +++++--- sea_transport/system/object_system.cpp | 4 +- sea_transport/system/object_system.h | 4 +- sea_transport/usereditdialog.cpp | 22 ++-- sea_transport/usereditdialog.h | 17 +-- .../viewmodels/deliverypointsviewmodel.cpp | 3 +- sea_transport/viewmodels/vesselsviewmodel.cpp | 3 +- sea_transport_project.pro.user | 6 +- st_test/tst_st_test.cpp | 2 +- 22 files changed, 379 insertions(+), 74 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 1bda76f..74a4e4a 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -78,7 +78,7 @@ void AdminPanel::on_logout_requested() { this->close(); } -void AdminPanel::on_vessel_add_edit(bool edit) { +void AdminPanel::on_vessel_add_edit(bool /*edit*/) { } @@ -129,7 +129,7 @@ void AdminPanel::on_user_add_edit(bool edit) { return; } - auto data = ued.user(); + auto data = ued.user_data(); if (edit) { bool success; auto user = apparatus::instance()->get_auth_subsystem()->get_user(usr.login(), success); @@ -188,7 +188,41 @@ void AdminPanel::on_user_remove() { } void AdminPanel::on_delivery_point_add_edit(bool edit) { + auto selected = ui->tv_dp->selectionModel()->selectedRows(); + if (edit && selected.length() != 1) { + return; + } + dpoint_entity dpoint; + if (edit) { + int idx = selected[0].row(); + dpoint = apparatus::instance()->get_object_subsystem()->dpoints()[idx]; + } + + DeliveryPointEditDialog dped(this); + dped.setWindowTitle(edit? "Edit delivery point" : "New delivery point"); + dped.set_dpoint(&dpoint, edit); + if (dped.exec() != UserEditDialog::Accepted) { + return; + } + + auto data = dped.dpoint(); + if (edit) { + bool success; + auto dp = apparatus::instance()->get_object_subsystem()->get_dpoint(dpoint.id(), success); + if (!success) { + QMessageBox::critical(this, "Error", "Error editing delivery point"); + return; + } + + dp->set_title(data->title()); + dp->set_storages(data->storages()); + } + else { + apparatus::instance()->get_object_subsystem()->add_dpoint(*data); + } + + dpvm->update(); } void AdminPanel::on_delivery_point_remove() { @@ -208,8 +242,8 @@ void AdminPanel::on_delivery_point_remove() { } foreach (auto mIdx, selected) { - int idx = mIdx.row(); - qDebug() << idx << ' ' << mIdx.data() << '\n'; + entity_id oid = mIdx.data().toULongLong(); + apparatus::instance()->get_object_subsystem()->remove_dpoint(oid); } dpvm->update(); diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index 3489f39..827c4b1 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -14,6 +14,7 @@ #include "viewmodels/deliverypointsviewmodel.h" #include "entities/user_entity.h" +#include "entities/dpoint_entity.h" namespace Ui { class AdminPanel; diff --git a/sea_transport/cargoeditdialog.cpp b/sea_transport/cargoeditdialog.cpp index 67c9a1e..a55ba79 100644 --- a/sea_transport/cargoeditdialog.cpp +++ b/sea_transport/cargoeditdialog.cpp @@ -3,6 +3,9 @@ CargoEditDialog::CargoEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CargoEditDialog) { ui->setupUi(this); + + connect(ui->pb_save, &QPushButton::clicked, this, &CargoEditDialog::accept); + connect(ui->pb_discard, &QPushButton::clicked, this, &CargoEditDialog::reject); } CargoEditDialog::~CargoEditDialog() { diff --git a/sea_transport/deliverypointeditdialog.cpp b/sea_transport/deliverypointeditdialog.cpp index a010715..922a549 100644 --- a/sea_transport/deliverypointeditdialog.cpp +++ b/sea_transport/deliverypointeditdialog.cpp @@ -1,14 +1,116 @@ #include "deliverypointeditdialog.h" #include "ui_deliverypointeditdialog.h" -DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::DeliveryPointEditDialog) -{ + +DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::DeliveryPointEditDialog) { ui->setupUi(this); + + this->svm = new QStringListModel(this); + ui->lv_storages->setModel(this->svm); + + connect(ui->lv_storages->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + ui->pb_storage_remove->setEnabled(selected.length() > 0); + ui->pb_storage_edit->setEnabled(selected.length() == 1); + }); + + connect(ui->pb_storage_remove, &QPushButton::clicked, [this]() { + auto sel = ui->lv_storages->selectionModel()->selectedRows(); + if (sel.length() == 0) { + return; + } + + foreach (auto mIdx, sel) { + auto cuid = mIdx.data().toString().toULongLong(); + auto st = this->_dp->storages(); + + for (int i = 0; i < st.length(); i++) { + if (st[i].id() == cuid) { + st.removeAt(i); + break; + } + } + + this->_dp->set_storages(st); + } + this->update_list(); + }); + + connect(ui->pb_storage_edit, &QPushButton::clicked, [this]() { + this->on_storage_edit_add(true); + }); + + connect(ui->pb_storage_add, &QPushButton::clicked, [this]() { + this->on_storage_edit_add(false); + }); + + connect(ui->pb_save, &QPushButton::clicked, this, &DeliveryPointEditDialog::accept); + connect(ui->pb_discard, &QPushButton::clicked, this, &DeliveryPointEditDialog::reject); } -DeliveryPointEditDialog::~DeliveryPointEditDialog() -{ +DeliveryPointEditDialog::~DeliveryPointEditDialog() { delete ui; } + +void DeliveryPointEditDialog::update_list() { + QStringList slist; + foreach (auto storage, this->_dp->storages()) { + slist << QString::number(storage.id()); + } + this->svm->setStringList(slist); +} + +dpoint_entity* DeliveryPointEditDialog::dpoint() const { + return this->_dp; +} + +void DeliveryPointEditDialog::on_storage_edit_add(bool edit) { + auto selected = ui->lv_storages->selectionModel()->selectedRows(); + if (edit && selected.length() != 1) { + return; + } + + storage_entity stor; + if (edit) { + int idx = selected[0].row(); + stor = this->_dp->storages()[idx]; + this->_dp->remove_storage(stor.id()); + } + + StorageEditDialog sed(this); + sed.setWindowTitle(edit? "Edit storage" : "New storage"); + sed.set_storage(&stor, edit); + if (sed.exec() != StorageEditDialog::Accepted) { + return; + } + + auto n_storage = sed.storage(); + if (edit) { + this->_dp->remove_storage(stor.id()); + } + this->_dp->add_storage(*n_storage); + + this->update_list(); +} + +void DeliveryPointEditDialog::set_dpoint(dpoint_entity* dpoint, bool edit) { + this->_dp = new dpoint_entity(*dpoint); + + if (edit) { + ui->et_title->setText(dpoint->title()); + this->update_list(); + } +} + +void DeliveryPointEditDialog::accept() { + bool emptyTitle = ui->et_title->text().trimmed().isEmpty(); + if (emptyTitle) {; + QString message = "Some errors happend, while saving your note:" + "
- Title cannot be empty (all spaces - empty too)"; + QMessageBox::critical(this, "Error", message); + return; + } + + this->_dp->set_title(ui->et_title->text().trimmed()); + + QDialog::accept(); +} diff --git a/sea_transport/deliverypointeditdialog.h b/sea_transport/deliverypointeditdialog.h index 6b044e2..3eeb00b 100644 --- a/sea_transport/deliverypointeditdialog.h +++ b/sea_transport/deliverypointeditdialog.h @@ -1,22 +1,42 @@ #ifndef DELIVERYPOINTEDITDIALOG_H #define DELIVERYPOINTEDITDIALOG_H +#include #include +#include +#include +#include +#include + +#include "entities/dpoint_entity.h" +#include "system/apparatus.h" +#include "storageeditdialog.h" + namespace Ui { class DeliveryPointEditDialog; } -class DeliveryPointEditDialog : public QDialog -{ +class DeliveryPointEditDialog : public QDialog { Q_OBJECT + Ui::DeliveryPointEditDialog *ui; + + QStringListModel *svm; + dpoint_entity *_dp; + + void update_list(); public: explicit DeliveryPointEditDialog(QWidget *parent = nullptr); ~DeliveryPointEditDialog(); -private: - Ui::DeliveryPointEditDialog *ui; + dpoint_entity* dpoint() const; + void set_dpoint(dpoint_entity* dpoint, bool edit); + +public slots: + void on_storage_edit_add(bool edit); + + void accept() Q_DECL_OVERRIDE; }; #endif // DELIVERYPOINTEDITDIALOG_H diff --git a/sea_transport/deliverypointeditdialog.ui b/sea_transport/deliverypointeditdialog.ui index 4a0ab3d..4797b21 100644 --- a/sea_transport/deliverypointeditdialog.ui +++ b/sea_transport/deliverypointeditdialog.ui @@ -44,19 +44,33 @@
- + + + QAbstractItemView::NoEditTriggers + + - + Add storage - + + + false + + + Edit storage + + + + + false @@ -83,14 +97,14 @@ - + Discard - + Save diff --git a/sea_transport/entities/dpoint_entity.cpp b/sea_transport/entities/dpoint_entity.cpp index ed5b926..01b164b 100644 --- a/sea_transport/entities/dpoint_entity.cpp +++ b/sea_transport/entities/dpoint_entity.cpp @@ -20,10 +20,28 @@ QString dpoint_entity::title() const { return this->_title; } +void dpoint_entity::set_title(const QString &new_title) { + this->_title = new_title; +} + const QVector dpoint_entity::storages() { return this->_storages; } +void dpoint_entity::set_storages(QVector storages) { + this->_storages = storages; +} + +void dpoint_entity::remove_storage(entity_id sid) { + std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) { + return ent.id() == sid; + }); +} + +void dpoint_entity::add_storage(storage_entity ent) { + this->_storages.push_back(ent); +} + void dpoint_entity::serialize(QDataStream &output) { output << this->_id << this->_title << this->_storages.size(); for (auto &item : this->_storages) { diff --git a/sea_transport/entities/dpoint_entity.h b/sea_transport/entities/dpoint_entity.h index 90fb4a4..8c17537 100644 --- a/sea_transport/entities/dpoint_entity.h +++ b/sea_transport/entities/dpoint_entity.h @@ -23,7 +23,11 @@ public: entity_id id() const; entity_id dispatcher() const; QString title() const; + void set_title(const QString &new_title); const QVector storages(); + void set_storages(QVector storages); + void remove_storage(entity_id sid); + void add_storage(storage_entity ent); void serialize(QDataStream &output); void deserialize(QDataStream &input); diff --git a/sea_transport/entities/storage_entity.cpp b/sea_transport/entities/storage_entity.cpp index 5e55f4c..49a381d 100644 --- a/sea_transport/entities/storage_entity.cpp +++ b/sea_transport/entities/storage_entity.cpp @@ -16,6 +16,10 @@ unsigned int storage_entity::capacity() const { return this->_capacity; } +void storage_entity::set_capacity(unsigned int new_capacity) { + this->_capacity = new_capacity; +} + const QVector storage_entity::cargo() { return this->_cargo; } diff --git a/sea_transport/entities/storage_entity.h b/sea_transport/entities/storage_entity.h index 3b8abf5..68030a2 100644 --- a/sea_transport/entities/storage_entity.h +++ b/sea_transport/entities/storage_entity.h @@ -22,6 +22,7 @@ public: entity_id id() const; unsigned int capacity() const; + void set_capacity(unsigned int new_capacity); const QVector cargo(); void add_cargo(cargo_entity object, bool &success); diff --git a/sea_transport/sea_transport.pro b/sea_transport/sea_transport.pro index bf9d0a6..99e2c50 100644 --- a/sea_transport/sea_transport.pro +++ b/sea_transport/sea_transport.pro @@ -25,6 +25,7 @@ SOURCES += \ system/object_system.cpp \ usereditdialog.cpp \ vesseleditdialog.cpp \ + viewmodels/cargoviewmodel.cpp \ viewmodels/deliverypointsviewmodel.cpp \ viewmodels/usersviewmodel.cpp \ viewmodels/vesselsviewmodel.cpp @@ -47,6 +48,7 @@ HEADERS += \ system/object_system.h \ usereditdialog.h \ vesseleditdialog.h \ + viewmodels/cargoviewmodel.h \ viewmodels/deliverypointsviewmodel.h \ viewmodels/usersviewmodel.h \ viewmodels/vesselsviewmodel.h diff --git a/sea_transport/storageeditdialog.cpp b/sea_transport/storageeditdialog.cpp index bfb4dc4..8395ae9 100644 --- a/sea_transport/storageeditdialog.cpp +++ b/sea_transport/storageeditdialog.cpp @@ -1,14 +1,80 @@ #include "storageeditdialog.h" #include "ui_storageeditdialog.h" -StorageEditDialog::StorageEditDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::StorageEditDialog) -{ +StorageEditDialog::StorageEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::StorageEditDialog) { ui->setupUi(this); + + this->cvm = new CargoViewModel(this); + ui->lv_cargo->setModel(this->cvm); + + connect(ui->lv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + ui->pb_cargo_remove->setEnabled(selected.length() > 0); + }); + + connect(ui->pb_cargo_remove, &QPushButton::clicked, [this]() { + auto sel = ui->lv_cargo->selectionModel()->selectedRows(); + if (sel.length() == 0) { + return; + } + + foreach (auto mIdx, sel) { + auto cdata = mIdx.data().toInt(); + qDebug() << cdata << '\n'; + } + }); + + connect(ui->pb_cargo_add, &QPushButton::clicked, this, &StorageEditDialog::on_cargo_add); + + connect(ui->pb_save, &QPushButton::clicked, this, &StorageEditDialog::accept); + connect(ui->pb_discard, &QPushButton::clicked, this, &StorageEditDialog::reject); } -StorageEditDialog::~StorageEditDialog() -{ +StorageEditDialog::~StorageEditDialog() { delete ui; } + +storage_entity* StorageEditDialog::storage() { + return this->_storage; +} + +void StorageEditDialog::set_storage(storage_entity *ent, bool edit) { + this->_storage = new storage_entity(*ent); + + if (edit) { + ui->sb_capacity->setValue(ent->capacity()); + this->cvm->set_data(this->_storage->cargo()); + } +} + +void StorageEditDialog::on_cargo_add() { + CargoEditDialog ced(this); + ced.setWindowTitle("New cargo"); + if (ced.exec() != CargoEditDialog::Accepted) { + return; + } + + bool success; + this->_storage->add_cargo(*ced.cargo(), success); + if (success) { + this->cvm->set_data(this->_storage->cargo()); + QMessageBox::information(this, "Success", "Cargo successfully put into storage"); + } + else { + QMessageBox::critical(this, "Error", "Not enough space to put cargo"); + } +} + +void StorageEditDialog::accept() { + int cvs = 0; + foreach (auto c, this->_storage->cargo()) { + cvs += c.volume(); + } + if (cvs > ui->sb_capacity->value()) { + QMessageBox::critical(this, "Error", "Cargo volume bigger than capacity"); + return; + } + + this->_storage->set_capacity(ui->sb_capacity->value()); + + QDialog::accept(); +} diff --git a/sea_transport/storageeditdialog.h b/sea_transport/storageeditdialog.h index bf70a54..372833a 100644 --- a/sea_transport/storageeditdialog.h +++ b/sea_transport/storageeditdialog.h @@ -1,22 +1,36 @@ #ifndef STORAGEEDITDIALOG_H #define STORAGEEDITDIALOG_H +#include #include +#include + +#include "entities/storage_entity.h" +#include "viewmodels/cargoviewmodel.h" +#include "cargoeditdialog.h" + namespace Ui { class StorageEditDialog; } -class StorageEditDialog : public QDialog -{ +class StorageEditDialog : public QDialog { Q_OBJECT + Ui::StorageEditDialog *ui; + + CargoViewModel *cvm; + storage_entity *_storage; public: explicit StorageEditDialog(QWidget *parent = nullptr); ~StorageEditDialog(); -private: - Ui::StorageEditDialog *ui; + storage_entity* storage(); + void set_storage(storage_entity *ent, bool edit); + +public slots: + void on_cargo_add(); + void accept() Q_DECL_OVERRIDE; }; #endif // STORAGEEDITDIALOG_H diff --git a/sea_transport/storageeditdialog.ui b/sea_transport/storageeditdialog.ui index 95b17c4..ac1e467 100644 --- a/sea_transport/storageeditdialog.ui +++ b/sea_transport/storageeditdialog.ui @@ -7,7 +7,7 @@ 0 0 400 - 190 + 336
@@ -17,24 +17,45 @@ - - - Storage num.: - - - - - - - Capacity: - - + + + + 1 + + + 500 + + + + + + + + + + + + + + Add cargo + + + + + + + false + + + Remove cargo + + @@ -54,14 +75,14 @@ - + Discard - + Save diff --git a/sea_transport/system/object_system.cpp b/sea_transport/system/object_system.cpp index 6b6456c..5915b78 100644 --- a/sea_transport/system/object_system.cpp +++ b/sea_transport/system/object_system.cpp @@ -1,7 +1,7 @@ #include "object_system.h" -const dpoint_entity* object_system::get_dpoint(entity_id oid, bool &success) { +dpoint_entity* object_system::get_dpoint(entity_id oid, bool &success) { dpoint_entity *out = nullptr; success = false; @@ -39,7 +39,7 @@ bool object_system::add_dpoint(dpoint_entity dpoint) { return false; } -const vessel_entity* object_system::get_vessel(entity_id oid, bool &success) { +vessel_entity* object_system::get_vessel(entity_id oid, bool &success) { vessel_entity *out = nullptr; success = false; diff --git a/sea_transport/system/object_system.h b/sea_transport/system/object_system.h index 2239a42..7551201 100644 --- a/sea_transport/system/object_system.h +++ b/sea_transport/system/object_system.h @@ -16,11 +16,11 @@ private: public: object_system() = default; - const dpoint_entity* get_dpoint(entity_id oid, bool &success); + dpoint_entity* get_dpoint(entity_id oid, bool &success); bool remove_dpoint(entity_id oid); bool add_dpoint(dpoint_entity dpoint); - const vessel_entity* get_vessel(entity_id oid, bool &success); + vessel_entity* get_vessel(entity_id oid, bool &success); bool remove_vessel(entity_id oid); bool add_vessel(vessel_entity dpoint); diff --git a/sea_transport/usereditdialog.cpp b/sea_transport/usereditdialog.cpp index c0c2650..a84ba1b 100644 --- a/sea_transport/usereditdialog.cpp +++ b/sea_transport/usereditdialog.cpp @@ -1,6 +1,7 @@ #include "usereditdialog.h" #include "ui_usereditdialog.h" + UserEditDialog::UserEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::UserEditDialog) { ui->setupUi(this); @@ -12,24 +13,22 @@ UserEditDialog::~UserEditDialog() { delete ui; } -UserEditDialog::user_data* UserEditDialog::user() const { - return this->_user; +user_data_struct* UserEditDialog::user_data() const { + return this->_user_data; } void UserEditDialog::set_user(user_entity* user, bool edit) { if (edit) { - this->_user = new UserEditDialog::user_data { - user->login(), "", user->role(), true - }; + this->_user_data = new user_data_struct(); ui->et_login->setText(user->login()); ui->et_password->setText("##########UNEDITED##########"); ui->cb_role->setCurrentIndex((int)user->role()); } else { - this->_user = new UserEditDialog::user_data{}; + this->_user_data = new user_data_struct{}; } - this->_user->edit = edit; + this->_user_data->edit = edit; } void UserEditDialog::accept() { @@ -47,7 +46,7 @@ void UserEditDialog::accept() { } bool emptyTitle = ui->et_login->text().trimmed().isEmpty(); bool emptyPassword = ui->et_password->text().trimmed().isEmpty(); - bool lowerank = this->_user->edit && this->_user->role < role; + bool lowerank = this->_user_data->edit && this->_user_data->role < role; if (emptyTitle || emptyPassword || lowerank) { QMessageBox errDlg(this); errDlg.setTextFormat(Qt::RichText); @@ -67,11 +66,10 @@ void UserEditDialog::accept() { errDlg.exec(); return; } - ; - this->_user->login = ui->et_login->text().trimmed(); - this->_user->password = ui->et_password->text().trimmed(); - this->_user->role = role; + this->_user_data->login = ui->et_login->text().trimmed(); + this->_user_data->password = ui->et_password->text().trimmed(); + this->_user_data->role = role; QDialog::accept(); } diff --git a/sea_transport/usereditdialog.h b/sea_transport/usereditdialog.h index 7fb13ca..ada392e 100644 --- a/sea_transport/usereditdialog.h +++ b/sea_transport/usereditdialog.h @@ -11,25 +11,26 @@ namespace Ui { class UserEditDialog; } +struct user_data_struct { + QString login; + QString password; + UserRole role; + bool edit; +}; + class UserEditDialog : public QDialog { Q_OBJECT Ui::UserEditDialog *ui; - struct user_data { - QString login; - QString password; - UserRole role; - bool edit; - } *_user; + user_data_struct *_user_data; public: explicit UserEditDialog(QWidget *parent = nullptr); ~UserEditDialog(); - UserEditDialog::user_data* user() const; + user_data_struct* user_data() const; void set_user(user_entity* user, bool edit); - public slots: void accept() Q_DECL_OVERRIDE; }; diff --git a/sea_transport/viewmodels/deliverypointsviewmodel.cpp b/sea_transport/viewmodels/deliverypointsviewmodel.cpp index 5823d9c..487e768 100644 --- a/sea_transport/viewmodels/deliverypointsviewmodel.cpp +++ b/sea_transport/viewmodels/deliverypointsviewmodel.cpp @@ -55,5 +55,6 @@ QVariant DeliveryPointsViewModel::data(const QModelIndex &index, int role) const } void DeliveryPointsViewModel::update() { - dataChanged(QModelIndex(), QModelIndex()); + this->beginResetModel(); + this->endResetModel(); } diff --git a/sea_transport/viewmodels/vesselsviewmodel.cpp b/sea_transport/viewmodels/vesselsviewmodel.cpp index accfe2b..7d4f2ba 100644 --- a/sea_transport/viewmodels/vesselsviewmodel.cpp +++ b/sea_transport/viewmodels/vesselsviewmodel.cpp @@ -61,5 +61,6 @@ QVariant VesselsViewModel::data(const QModelIndex &index, int role) const { } void VesselsViewModel::update() { - dataChanged(QModelIndex(), QModelIndex()); + this->beginResetModel(); + this->endResetModel(); } diff --git a/sea_transport_project.pro.user b/sea_transport_project.pro.user index be69ce2..c77d533 100644 --- a/sea_transport_project.pro.user +++ b/sea_transport_project.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -169,7 +169,7 @@ true QtProjectManager.QMakeBuildStep - false + true @@ -221,7 +221,7 @@ true QtProjectManager.QMakeBuildStep - false + true diff --git a/st_test/tst_st_test.cpp b/st_test/tst_st_test.cpp index 3c8ca78..fca6bde 100644 --- a/st_test/tst_st_test.cpp +++ b/st_test/tst_st_test.cpp @@ -133,7 +133,7 @@ void st_test::dpoint_entity_serialization_test() { f.open(QIODevice::WriteOnly); stream.setDevice(&f); - ent1 = dpoint_entity("some_test_point"); + ent1 = dpoint_entity(0, "some_test_point"); ent1.serialize(stream); stream.setDevice(nullptr); From 9686b96d8a1a2a0daf470d39b5acc7f4b6bd6a5f Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 15:00:02 +0700 Subject: [PATCH 24/43] Minor system improvements --- sea_transport/adminpanel.cpp | 20 ++++-- sea_transport/cargoeditdialog.ui | 2 +- sea_transport/deliverypointeditdialog.cpp | 12 +--- sea_transport/deliverypointeditdialog.ui | 79 +++++++++++++---------- sea_transport/entities/cargo_entity.cpp | 1 + sea_transport/entities/cargo_entity.h | 1 + sea_transport/entities/dpoint_entity.cpp | 18 +++++- sea_transport/entities/dpoint_entity.h | 1 + sea_transport/entities/storage_entity.cpp | 2 +- sea_transport/entities/storage_entity.h | 4 +- sea_transport/entities/user_entity.cpp | 4 ++ sea_transport/entities/user_entity.h | 1 + sea_transport/entities/vessel_entity.cpp | 2 +- sea_transport/entities/vessel_entity.h | 2 + sea_transport/storageeditdialog.cpp | 8 ++- sea_transport/storageeditdialog.ui | 73 ++++++++++++++------- 16 files changed, 144 insertions(+), 86 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 74a4e4a..4ea9230 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -80,6 +80,8 @@ void AdminPanel::on_logout_requested() { void AdminPanel::on_vessel_add_edit(bool /*edit*/) { + + vvm->update(); } void AdminPanel::on_vessel_remove() { @@ -99,8 +101,8 @@ void AdminPanel::on_vessel_remove() { } foreach (auto mIdx, selected) { - int idx = mIdx.row(); - qDebug() << idx << ' ' << mIdx.data() << '\n'; + entity_id oid = mIdx.data().toULongLong(); + apparatus::instance()->get_object_subsystem()->remove_vessel(oid); } vvm->update(); @@ -210,7 +212,10 @@ void AdminPanel::on_delivery_point_add_edit(bool edit) { if (edit) { bool success; auto dp = apparatus::instance()->get_object_subsystem()->get_dpoint(dpoint.id(), success); - if (!success) { + if (success) { + QMessageBox::information(this, "Info", "Successfully edited delivery point"); + } + else { QMessageBox::critical(this, "Error", "Error editing delivery point"); return; } @@ -219,7 +224,14 @@ void AdminPanel::on_delivery_point_add_edit(bool edit) { dp->set_storages(data->storages()); } else { - apparatus::instance()->get_object_subsystem()->add_dpoint(*data); + bool success = apparatus::instance()->get_object_subsystem()->add_dpoint(*data); + if (success) { + QMessageBox::information(this, "Info", "Successfully created delivery point"); + } + else { + QMessageBox::critical(this, "Error", "Error creating delivery point"); + return; + } } dpvm->update(); diff --git a/sea_transport/cargoeditdialog.ui b/sea_transport/cargoeditdialog.ui index da14928..4b2f8bf 100644 --- a/sea_transport/cargoeditdialog.ui +++ b/sea_transport/cargoeditdialog.ui @@ -43,7 +43,7 @@ 1 - 500 + 500000
diff --git a/sea_transport/deliverypointeditdialog.cpp b/sea_transport/deliverypointeditdialog.cpp index 922a549..187d1c5 100644 --- a/sea_transport/deliverypointeditdialog.cpp +++ b/sea_transport/deliverypointeditdialog.cpp @@ -21,16 +21,7 @@ DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) : QDialog(pare foreach (auto mIdx, sel) { auto cuid = mIdx.data().toString().toULongLong(); - auto st = this->_dp->storages(); - - for (int i = 0; i < st.length(); i++) { - if (st[i].id() == cuid) { - st.removeAt(i); - break; - } - } - - this->_dp->set_storages(st); + this->_dp->remove_storage(cuid); } this->update_list(); }); @@ -73,7 +64,6 @@ void DeliveryPointEditDialog::on_storage_edit_add(bool edit) { if (edit) { int idx = selected[0].row(); stor = this->_dp->storages()[idx]; - this->_dp->remove_storage(stor.id()); } StorageEditDialog sed(this); diff --git a/sea_transport/deliverypointeditdialog.ui b/sea_transport/deliverypointeditdialog.ui index 4797b21..c330679 100644 --- a/sea_transport/deliverypointeditdialog.ui +++ b/sea_transport/deliverypointeditdialog.ui @@ -13,7 +13,7 @@ Dialog - + @@ -44,43 +44,52 @@ - - - QAbstractItemView::NoEditTriggers + + + Storages IDs + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + Add storage + + + + + + + false + + + Edit storage + + + + + + + false + + + Remove storage + + + + + + - - - - - - Add storage - - - - - - - false - - - Edit storage - - - - - - - false - - - Remove storage - - - - - diff --git a/sea_transport/entities/cargo_entity.cpp b/sea_transport/entities/cargo_entity.cpp index 4104050..9835444 100644 --- a/sea_transport/entities/cargo_entity.cpp +++ b/sea_transport/entities/cargo_entity.cpp @@ -6,6 +6,7 @@ cargo_entity::cargo_entity(const QString &title, unsigned int volume) : _title(t for (auto bit : hash) { this->_id += bit; } + this->_id += QRandomGenerator().generate64(); } entity_id cargo_entity::id() const { diff --git a/sea_transport/entities/cargo_entity.h b/sea_transport/entities/cargo_entity.h index 8d84b3a..9b69169 100644 --- a/sea_transport/entities/cargo_entity.h +++ b/sea_transport/entities/cargo_entity.h @@ -4,6 +4,7 @@ #include "IEntity.h" #include +#include #include diff --git a/sea_transport/entities/dpoint_entity.cpp b/sea_transport/entities/dpoint_entity.cpp index 01b164b..04d2f32 100644 --- a/sea_transport/entities/dpoint_entity.cpp +++ b/sea_transport/entities/dpoint_entity.cpp @@ -6,6 +6,7 @@ dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _d for (auto bit : hash) { this->_id += bit; } + this->_id += QRandomGenerator().generate64(); } entity_id dpoint_entity::id() const { @@ -33,9 +34,20 @@ void dpoint_entity::set_storages(QVector storages) { } void dpoint_entity::remove_storage(entity_id sid) { - std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) { - return ent.id() == sid; - }); +// std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) { +// return ent.id() == sid; +// }); + + QVector st(this->_storages); + + for (int i = 0; i < st.length(); i++) { + if (st[i].id() == sid) { + st.removeAt(i); + break; + } + } + + this->set_storages(st); } void dpoint_entity::add_storage(storage_entity ent) { diff --git a/sea_transport/entities/dpoint_entity.h b/sea_transport/entities/dpoint_entity.h index 8c17537..202e002 100644 --- a/sea_transport/entities/dpoint_entity.h +++ b/sea_transport/entities/dpoint_entity.h @@ -6,6 +6,7 @@ #include #include +#include #include diff --git a/sea_transport/entities/storage_entity.cpp b/sea_transport/entities/storage_entity.cpp index 49a381d..96909e6 100644 --- a/sea_transport/entities/storage_entity.cpp +++ b/sea_transport/entities/storage_entity.cpp @@ -4,7 +4,7 @@ entity_id storage_entity::__global_id = 0; storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) { - this->_id = ++storage_entity::__global_id; + this->_id = ++storage_entity::__global_id + QRandomGenerator().generate64(); } diff --git a/sea_transport/entities/storage_entity.h b/sea_transport/entities/storage_entity.h index 68030a2..4d502f2 100644 --- a/sea_transport/entities/storage_entity.h +++ b/sea_transport/entities/storage_entity.h @@ -5,7 +5,7 @@ #include "cargo_entity.h" #include -#include +#include class storage_entity : public IEntity { @@ -13,7 +13,7 @@ private: static entity_id __global_id; entity_id _id; - unsigned int _capacity; + unsigned int _capacity = 500000; QVector _cargo; public: diff --git a/sea_transport/entities/user_entity.cpp b/sea_transport/entities/user_entity.cpp index a54471f..a213906 100644 --- a/sea_transport/entities/user_entity.cpp +++ b/sea_transport/entities/user_entity.cpp @@ -2,6 +2,10 @@ user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) { this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256); + foreach (auto bit, this->_pwd_hash) { + this->_id += bit; + } + this->_id += QRandomGenerator().generate64(); } entity_id user_entity::id() const { diff --git a/sea_transport/entities/user_entity.h b/sea_transport/entities/user_entity.h index 1bf4203..7f875a7 100644 --- a/sea_transport/entities/user_entity.h +++ b/sea_transport/entities/user_entity.h @@ -4,6 +4,7 @@ #include "IEntity.h" #include +#include #include diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index 45ce0a0..4739ee4 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -4,7 +4,7 @@ entity_id vessel_entity::__global_id = 0; vessel_entity::vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity) : _skipper_id(skipper_id), _harbor_id(harbor_id), _capacity(capacity) { - this->_id = ++vessel_entity::__global_id; + this->_id = ++vessel_entity::__global_id + QRandomGenerator().generate64(); } entity_id vessel_entity::id() const { diff --git a/sea_transport/entities/vessel_entity.h b/sea_transport/entities/vessel_entity.h index 9b72c90..48c2bbc 100644 --- a/sea_transport/entities/vessel_entity.h +++ b/sea_transport/entities/vessel_entity.h @@ -5,6 +5,8 @@ #include "cargo_entity.h" #include "dpoint_entity.h" +#include + class vessel_entity : public IEntity { private: diff --git a/sea_transport/storageeditdialog.cpp b/sea_transport/storageeditdialog.cpp index 8395ae9..b8eaefb 100644 --- a/sea_transport/storageeditdialog.cpp +++ b/sea_transport/storageeditdialog.cpp @@ -5,14 +5,14 @@ StorageEditDialog::StorageEditDialog(QWidget *parent) : QDialog(parent), ui(new ui->setupUi(this); this->cvm = new CargoViewModel(this); - ui->lv_cargo->setModel(this->cvm); + ui->tv_cargo->setModel(this->cvm); - connect(ui->lv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + connect(ui->tv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { ui->pb_cargo_remove->setEnabled(selected.length() > 0); }); connect(ui->pb_cargo_remove, &QPushButton::clicked, [this]() { - auto sel = ui->lv_cargo->selectionModel()->selectedRows(); + auto sel = ui->tv_cargo->selectionModel()->selectedRows(); if (sel.length() == 0) { return; } @@ -44,6 +44,8 @@ void StorageEditDialog::set_storage(storage_entity *ent, bool edit) { ui->sb_capacity->setValue(ent->capacity()); this->cvm->set_data(this->_storage->cargo()); } + + ui->lab_capacity_current->setText(QString::number(this->_storage->capacity())); } void StorageEditDialog::on_cargo_add() { diff --git a/sea_transport/storageeditdialog.ui b/sea_transport/storageeditdialog.ui index ac1e467..89c6b29 100644 --- a/sea_transport/storageeditdialog.ui +++ b/sea_transport/storageeditdialog.ui @@ -13,13 +13,13 @@ Dialog - + - Capacity: + Capacity (new): @@ -29,35 +29,58 @@ 1 - 500 + 500000 + + + + + + + Capacity (current): + + + + + + + 0
- - - - - - - - Add cargo - - - - - - - false - - - Remove cargo - - - - + + + Storage cargo + + + + + + + + + + + Add cargo + + + + + + + false + + + Remove cargo + + + + + + + From eb097588ba6c6fe1db59186afa4ce43ee373c952 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 18:43:41 +0700 Subject: [PATCH 25/43] Vessel edit dialog --- sea_transport/adminpanel.cpp | 43 ++- sea_transport/adminpanel.ui | 11 +- sea_transport/cargoeditdialog.ui | 12 + sea_transport/deliverypointeditdialog.ui | 12 + sea_transport/entities/cargo_entity.cpp | 5 + sea_transport/entities/cargo_entity.h | 6 +- sea_transport/entities/dpoint_entity.cpp | 22 +- sea_transport/entities/dpoint_entity.h | 5 +- sea_transport/entities/storage_entity.cpp | 7 +- sea_transport/entities/storage_entity.h | 4 +- sea_transport/entities/user_entity.cpp | 8 + sea_transport/entities/user_entity.h | 4 +- sea_transport/entities/vessel_entity.cpp | 43 ++- sea_transport/entities/vessel_entity.h | 16 +- sea_transport/storageeditdialog.cpp | 8 +- sea_transport/storageeditdialog.ui | 12 + sea_transport/usereditdialog.ui | 12 + sea_transport/vesseleditdialog.cpp | 267 +++++++++++++++++- sea_transport/vesseleditdialog.h | 27 +- sea_transport/vesseleditdialog.ui | 140 ++++++--- sea_transport/viewmodels/vesselsviewmodel.cpp | 22 +- 21 files changed, 589 insertions(+), 97 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 4ea9230..6095b12 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -78,10 +78,51 @@ void AdminPanel::on_logout_requested() { this->close(); } -void AdminPanel::on_vessel_add_edit(bool /*edit*/) { +void AdminPanel::on_vessel_add_edit(bool edit) { + auto selected = ui->tv_vessels->selectionModel()->selectedRows(); + if (edit && selected.length() != 1) { + return; + } + if (apparatus::instance()->get_object_subsystem()->dpoints().isEmpty()) { + QMessageBox::critical(this, "Error", "No harbors to assign. At least one required."); + return; + } + + int skippers = 0; + foreach (auto user, apparatus::instance()->get_auth_subsystem()->users()) { + skippers += user.role() == UserRole::SKIPPER; + } + if (skippers == 0) { + QMessageBox::critical(this, "Error", "No skippers to assign. At least one required."); + return; + } + + vessel_entity ves; + if (edit) { + int idx = selected[0].row(); + ves = apparatus::instance()->get_object_subsystem()->vessels()[idx]; + } + + VesselEditDialog ved(this); + ved.setWindowTitle(edit? "Edit vessel" : "New vessel"); + ved.set_vessel(&ves, edit); + if (ved.exec() != UserEditDialog::Accepted) { + return; + } + + auto data = ved.vessel(); + if (edit) { + apparatus::instance()->get_object_subsystem()->remove_vessel(ves.id()); + QMessageBox::information(this, "Info", "Vessel edited successfully"); + } + else { + QMessageBox::information(this, "Info", "Vessel created successfully"); + } + apparatus::instance()->get_object_subsystem()->add_vessel(*data); vvm->update(); + dpvm->update(); } void AdminPanel::on_vessel_remove() { diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index ac236f6..e472f2f 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -53,7 +53,7 @@ QTabWidget::Rounded - 0 + 2 false @@ -68,6 +68,9 @@ + + QAbstractItemView::SingleSelection + QAbstractItemView::SelectRows @@ -173,6 +176,9 @@ + + QAbstractItemView::SingleSelection + QAbstractItemView::SelectRows @@ -234,6 +240,9 @@ + + QAbstractItemView::SingleSelection + QAbstractItemView::SelectRows diff --git a/sea_transport/cargoeditdialog.ui b/sea_transport/cargoeditdialog.ui index 4b2f8bf..fd1b1f7 100644 --- a/sea_transport/cargoeditdialog.ui +++ b/sea_transport/cargoeditdialog.ui @@ -10,6 +10,18 @@ 127 + + + 318 + 127 + + + + + 318 + 127 + + Dialog diff --git a/sea_transport/deliverypointeditdialog.ui b/sea_transport/deliverypointeditdialog.ui index c330679..0d7c4ae 100644 --- a/sea_transport/deliverypointeditdialog.ui +++ b/sea_transport/deliverypointeditdialog.ui @@ -10,6 +10,18 @@ 386 + + + 394 + 386 + + + + + 394 + 386 + + Dialog diff --git a/sea_transport/entities/cargo_entity.cpp b/sea_transport/entities/cargo_entity.cpp index 9835444..a5d136c 100644 --- a/sea_transport/entities/cargo_entity.cpp +++ b/sea_transport/entities/cargo_entity.cpp @@ -1,5 +1,10 @@ #include "cargo_entity.h" + +cargo_entity::cargo_entity() { + this->_id += QRandomGenerator().generate64(); +} + cargo_entity::cargo_entity(const QString &title, unsigned int volume) : _title(title), _volume(volume) { this->_id = volume; auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5); diff --git a/sea_transport/entities/cargo_entity.h b/sea_transport/entities/cargo_entity.h index 9b69169..60d8c69 100644 --- a/sea_transport/entities/cargo_entity.h +++ b/sea_transport/entities/cargo_entity.h @@ -10,12 +10,12 @@ class cargo_entity : public IEntity { private: - entity_id _id; + entity_id _id = 0; QString _title; - unsigned int _volume; + unsigned int _volume = 50000; public: - cargo_entity() = default; + cargo_entity(); cargo_entity(const QString &title, unsigned int volume); entity_id id() const; diff --git a/sea_transport/entities/dpoint_entity.cpp b/sea_transport/entities/dpoint_entity.cpp index 04d2f32..55a682d 100644 --- a/sea_transport/entities/dpoint_entity.cpp +++ b/sea_transport/entities/dpoint_entity.cpp @@ -1,5 +1,10 @@ #include "dpoint_entity.h" + +dpoint_entity::dpoint_entity() { + this->_id += QRandomGenerator().generate64(); +} + dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _dispatcher_id(dispatcher_id), _title(title) { this->_id = dispatcher_id; auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5); @@ -29,15 +34,24 @@ const QVector dpoint_entity::storages() { return this->_storages; } +storage_entity* dpoint_entity::get_storage(entity_id sid, bool &success) { + success = false; + for (int i = 0; i < this->_storages.length(); i++) { + if (this->_storages[i].id() != sid) { + continue; + } + success = true; + return &this->_storages[i]; + } + + return nullptr; +} + void dpoint_entity::set_storages(QVector storages) { this->_storages = storages; } void dpoint_entity::remove_storage(entity_id sid) { -// std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) { -// return ent.id() == sid; -// }); - QVector st(this->_storages); for (int i = 0; i < st.length(); i++) { diff --git a/sea_transport/entities/dpoint_entity.h b/sea_transport/entities/dpoint_entity.h index 202e002..0a536ba 100644 --- a/sea_transport/entities/dpoint_entity.h +++ b/sea_transport/entities/dpoint_entity.h @@ -12,13 +12,13 @@ class dpoint_entity : public IEntity { private: - entity_id _id; + entity_id _id = 0; entity_id _dispatcher_id; QString _title; QVector _storages; public: - dpoint_entity() = default; + dpoint_entity(); dpoint_entity(entity_id dispatcher_id, const QString &title); entity_id id() const; @@ -26,6 +26,7 @@ public: QString title() const; void set_title(const QString &new_title); const QVector storages(); + storage_entity* get_storage(entity_id sid, bool &success); void set_storages(QVector storages); void remove_storage(entity_id sid); void add_storage(storage_entity ent); diff --git a/sea_transport/entities/storage_entity.cpp b/sea_transport/entities/storage_entity.cpp index 96909e6..49f5920 100644 --- a/sea_transport/entities/storage_entity.cpp +++ b/sea_transport/entities/storage_entity.cpp @@ -3,10 +3,13 @@ entity_id storage_entity::__global_id = 0; -storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) { +storage_entity::storage_entity() { this->_id = ++storage_entity::__global_id + QRandomGenerator().generate64(); } +storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) { + this->_id = ++storage_entity::__global_id + QRandomGenerator().generate64(); +} entity_id storage_entity::id() const { return this->_id; @@ -25,7 +28,7 @@ const QVector storage_entity::cargo() { } void storage_entity::add_cargo(cargo_entity object, bool &success) { - success = ((int)this->_capacity - (int)object.volume()) > 0; + success = ((int)this->_capacity - (int)object.volume()) >= 0; if (success) { this->_cargo.push_back(object); this->_capacity -= object.volume(); diff --git a/sea_transport/entities/storage_entity.h b/sea_transport/entities/storage_entity.h index 4d502f2..c09e2b5 100644 --- a/sea_transport/entities/storage_entity.h +++ b/sea_transport/entities/storage_entity.h @@ -12,12 +12,12 @@ class storage_entity : public IEntity { private: static entity_id __global_id; - entity_id _id; + entity_id _id = 0; unsigned int _capacity = 500000; QVector _cargo; public: - storage_entity() = default; + storage_entity(); storage_entity(unsigned int capacity); entity_id id() const; diff --git a/sea_transport/entities/user_entity.cpp b/sea_transport/entities/user_entity.cpp index a213906..9c628e6 100644 --- a/sea_transport/entities/user_entity.cpp +++ b/sea_transport/entities/user_entity.cpp @@ -1,10 +1,18 @@ #include "user_entity.h" + +user_entity::user_entity() { + this->_id += QRandomGenerator().generate64(); +} + user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) { this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256); foreach (auto bit, this->_pwd_hash) { this->_id += bit; } + foreach (auto bit, QCryptographicHash::hash(login.toLocal8Bit(), QCryptographicHash::Sha3_256)) { + this->_id += bit; + } this->_id += QRandomGenerator().generate64(); } diff --git a/sea_transport/entities/user_entity.h b/sea_transport/entities/user_entity.h index 7f875a7..6ab2de9 100644 --- a/sea_transport/entities/user_entity.h +++ b/sea_transport/entities/user_entity.h @@ -15,13 +15,13 @@ enum class UserRole { class user_entity : public IEntity { private: - entity_id _id; + entity_id _id = 0; QString _login; UserRole _role; QByteArray _pwd_hash; public: - user_entity() = default; + user_entity(); user_entity(const QString &login, const QString &password, UserRole role); entity_id id() const; diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index 4739ee4..383d116 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -3,38 +3,69 @@ entity_id vessel_entity::__global_id = 0; -vessel_entity::vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity) : _skipper_id(skipper_id), _harbor_id(harbor_id), _capacity(capacity) { +vessel_entity::vessel_entity() { this->_id = ++vessel_entity::__global_id + QRandomGenerator().generate64(); } +vessel_entity::vessel_entity(QString skipper, entity_id harbor_id, unsigned int capacity) : _skipper(skipper), _harbor_id(harbor_id), _capacity(capacity) { + this->_id = ++vessel_entity::__global_id + harbor_id + capacity + QRandomGenerator().generate64(); +} + entity_id vessel_entity::id() const { return this->_id; } -entity_id vessel_entity::skipper() const { - return this->_skipper_id; +QString vessel_entity::skipper() const { + return this->_skipper; +} + +void vessel_entity::set_skipper(const QString &new_skipper) { + this->_skipper = new_skipper; } entity_id vessel_entity::harbor() const { return this->_harbor_id; } +void vessel_entity::set_harbor(entity_id new_harbor) { + this->_harbor_id = new_harbor; +} + unsigned int vessel_entity::capacity() const { return this->_capacity; } +void vessel_entity::set_capacity(unsigned int new_capacity) { + this->_capacity = new_capacity; +} + const QVector vessel_entity::cargo() { return this->_cargo; } void vessel_entity::add_cargo(cargo_entity object, bool &success) { - success = ((int)this->_capacity - (int)object.volume()) > 0; + success = ((int)this->_capacity - (int)object.volume()) >= 0; if (success) { this->_cargo.push_back(object); this->_capacity -= object.volume(); } } +cargo_entity vessel_entity::get_cargo(entity_id oid, bool &found) { + cargo_entity ent; + found = false; + + auto vit = this->_cargo.begin(); + for (; vit != this->_cargo.end(); vit++) { + if ((*vit).id() == oid) { + ent = *vit; + found = true; + break; + } + } + return ent; +} + void vessel_entity::withdraw_cargo(entity_id oid, bool &success) { success = false; auto vit = this->_cargo.begin(); @@ -49,7 +80,7 @@ void vessel_entity::withdraw_cargo(entity_id oid, bool &success) { } void vessel_entity::serialize(QDataStream &output) { - output << this->_id << this->_harbor_id; + output << this->_id << this->_skipper << this->_harbor_id; output << this->_capacity << this->_cargo.size(); for (auto item : this->_cargo) { item.serialize(output); @@ -57,7 +88,7 @@ void vessel_entity::serialize(QDataStream &output) { } void vessel_entity::deserialize(QDataStream &input) { - input >> this->_id >> this->_harbor_id; + input >> this->_id >> this->_skipper >> this->_harbor_id; int icnt; input >> this->_capacity >> icnt; this->_cargo.resize(icnt); diff --git a/sea_transport/entities/vessel_entity.h b/sea_transport/entities/vessel_entity.h index 48c2bbc..a554a2b 100644 --- a/sea_transport/entities/vessel_entity.h +++ b/sea_transport/entities/vessel_entity.h @@ -12,23 +12,27 @@ class vessel_entity : public IEntity { private: static entity_id __global_id; - entity_id _id; - entity_id _skipper_id; + entity_id _id = 0; + QString _skipper; entity_id _harbor_id; - unsigned int _capacity; + unsigned int _capacity = 50000; QVector _cargo; public: - vessel_entity() = default; - vessel_entity(entity_id skipper_id, entity_id harbor_id, unsigned int capacity); + vessel_entity(); + vessel_entity(QString skipper, entity_id harbor_id, unsigned int capacity); entity_id id() const; - entity_id skipper() const; + QString skipper() const; + void set_skipper(const QString &new_skipper); entity_id harbor() const; + void set_harbor(entity_id new_harbor); unsigned int capacity() const; + void set_capacity(unsigned int new_capacity); const QVector cargo(); void add_cargo(cargo_entity object, bool &success); + cargo_entity get_cargo(entity_id oid, bool &found); void withdraw_cargo(entity_id oid, bool &success); void serialize(QDataStream &output); diff --git a/sea_transport/storageeditdialog.cpp b/sea_transport/storageeditdialog.cpp index b8eaefb..e7426c0 100644 --- a/sea_transport/storageeditdialog.cpp +++ b/sea_transport/storageeditdialog.cpp @@ -18,8 +18,12 @@ StorageEditDialog::StorageEditDialog(QWidget *parent) : QDialog(parent), ui(new } foreach (auto mIdx, sel) { - auto cdata = mIdx.data().toInt(); - qDebug() << cdata << '\n'; + auto oid = mIdx.data().toULongLong(); + bool success; + this->_storage->withdraw_cargo(oid, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot remove some of this cargo!"); + } } }); diff --git a/sea_transport/storageeditdialog.ui b/sea_transport/storageeditdialog.ui index 89c6b29..08e60c2 100644 --- a/sea_transport/storageeditdialog.ui +++ b/sea_transport/storageeditdialog.ui @@ -10,6 +10,18 @@ 336 + + + 400 + 336 + + + + + 400 + 336 + + Dialog diff --git a/sea_transport/usereditdialog.ui b/sea_transport/usereditdialog.ui index 8ec17a4..e924ca5 100644 --- a/sea_transport/usereditdialog.ui +++ b/sea_transport/usereditdialog.ui @@ -10,6 +10,18 @@ 270 + + + 304 + 270 + + + + + 304 + 270 + + Dialog diff --git a/sea_transport/vesseleditdialog.cpp b/sea_transport/vesseleditdialog.cpp index dcc2e3b..a49384a 100644 --- a/sea_transport/vesseleditdialog.cpp +++ b/sea_transport/vesseleditdialog.cpp @@ -1,14 +1,269 @@ #include "vesseleditdialog.h" #include "ui_vesseleditdialog.h" -VesselEditDialog::VesselEditDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::VesselEditDialog) -{ +VesselEditDialog::VesselEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::VesselEditDialog) { ui->setupUi(this); + + this->cvm = new CargoViewModel(this); + ui->tv_cargo->setModel(this->cvm); + + connect(ui->tv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { + ui->pb_cargo_remove->setEnabled(selected.length() > 0); + }); + + connect(ui->pb_cargo_remove, &QPushButton::clicked, [this]() { + auto sel = ui->tv_cargo->selectionModel()->selectedRows(); + if (sel.length() == 0) { + return; + } + + foreach (auto mIdx, sel) { + auto oid = mIdx.data().toULongLong(); + bool success; + this->_vessel->withdraw_cargo(oid, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot remove some of this cargo!"); + } + } + }); + + foreach (auto port, apparatus::instance()->get_object_subsystem()->dpoints()) { + ui->cb_port->addItem(tr("%1 :%2").arg(port.title()).arg(port.id())); + } + + foreach (auto user, apparatus::instance()->get_auth_subsystem()->users()) { + if (user.role() != UserRole::SKIPPER) { + continue; + } + ui->cb_skippers->addItem(tr("%1 :%2").arg(user.login()).arg(user.id())); + } + + connect(ui->pb_cargo_add, &QPushButton::clicked, this, &VesselEditDialog::on_cargo_add); + + connect(ui->pb_withdraw_from_harbor, &QPushButton::clicked, this, &VesselEditDialog::on_withdraw_from_harbor); + connect(ui->pb_withdraw_from_vessel, &QPushButton::clicked, this, &VesselEditDialog::on_withdraw_from_vessel); + + connect(ui->pb_save, &QPushButton::clicked, this, &VesselEditDialog::accept); + connect(ui->pb_discard, &QPushButton::clicked, this, &VesselEditDialog::reject); } -VesselEditDialog::~VesselEditDialog() -{ +VesselEditDialog::~VesselEditDialog() { delete ui; } + +void VesselEditDialog::select_proper_skipper() { + int i = 0; + foreach (auto user, apparatus::instance()->get_auth_subsystem()->users()) { + if (user.role() != UserRole::SKIPPER || user.login() != this->_vessel->skipper()) { + i += 1; + continue; + } + ui->cb_port->setCurrentIndex(i); + return; + } + + QMessageBox::critical(this, "Error", "Cannot find this vessel's skipper."); +} + +void VesselEditDialog::select_proper_port() { + int i = 0; + foreach (auto port, apparatus::instance()->get_object_subsystem()->dpoints()) { + if (port.id() != this->_vessel->harbor()) { + i += 1; + continue; + } + ui->cb_port->setCurrentIndex(i); + return; + } + + QMessageBox::critical(this, "Error", "Cannot find this vessel's harbor."); +} + +vessel_entity* VesselEditDialog::vessel() { + return this->_vessel; +} + +void VesselEditDialog::set_vessel(vessel_entity *ves, bool edit) { + this->_vessel = new vessel_entity(*ves); + + if (edit) { + this->select_proper_skipper(); + this->select_proper_port(); + ui->sb_capacity->setValue(this->_vessel->capacity()); + this->cvm->set_data(this->_vessel->cargo()); + ui->pb_withdraw_from_harbor->setEnabled(true); + ui->pb_withdraw_from_vessel->setEnabled(true); + } + ui->lab_capacity_current->setText(QString::number(this->_vessel->capacity())); +} + +void VesselEditDialog::on_cargo_add() { + CargoEditDialog ced(this); + ced.setWindowTitle("New cargo"); + if (ced.exec() != CargoEditDialog::Accepted) { + return; + } + + bool success; + this->_vessel->add_cargo(*ced.cargo(), success); + if (success) { + this->cvm->set_data(this->_vessel->cargo()); + QMessageBox::information(this, "Success", "Cargo successfully put into storage"); + } + else { + QMessageBox::critical(this, "Error", "Not enough space to put cargo"); + } +} + +void VesselEditDialog::on_withdraw_from_harbor() { + QMessageBox::information(this, "Note", "Please note, old storage will be used.\n" + "Also, movement cannot be undone by discarding vessel edit dialog"); + + bool success; + auto dpoint = apparatus::instance()->get_object_subsystem()->get_dpoint(this->_vessel->harbor(), success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot find associated harbor in DB"); + return; + } + if (dpoint->storages().isEmpty()) { + QMessageBox::information(this, "Note", "Vessel has no storages"); + return; + } + + QStringList harbor_storage; + foreach (auto storage, dpoint->storages()) { + harbor_storage << QString::number(storage.id()); + } + bool ok; + QString storage_id_str = QInputDialog::getItem(this, "Select storage", "Storages in harbor:", harbor_storage, 0, false, &ok); + if (!ok || storage_id_str.isEmpty()) { + QMessageBox::information(this, "Aborted", "Operation aborted by user."); + return; + } + + entity_id sid = storage_id_str.toULongLong(); + auto storage = dpoint->get_storage(sid, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot find associated storage in harbor"); + return; + } + if (storage->cargo().isEmpty()) { + QMessageBox::information(this, "Note", "Storage has no cargo"); + return; + } + + QStringList storage_cargo; + foreach (auto storage, storage->cargo()) { + storage_cargo << tr("%1 :%2").arg(storage.title()).arg(storage.id()); + } + QString cargo_id_str = QInputDialog::getItem(this, "Select cargo", "Cargo in storage:", storage_cargo, 0, false, &ok); + if (!ok || cargo_id_str.isEmpty()) { + QMessageBox::information(this, "Aborted", "Operation aborted by user."); + return; + } + + entity_id cid = cargo_id_str.split(":")[1].toULongLong(); + auto cargo = storage->get_cargo(cid, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot find cargo in storage"); + return; + } + + this->_vessel->add_cargo(cargo, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot add cargo to vessel"); + return; + } + storage->withdraw_cargo(cid, success); + if (!success) { + throw std::runtime_error("Cannot withdraw from storage"); + } + + QMessageBox::information(this, "Info", "Successfully withdrawed cargo from harbor"); + cvm->set_data(this->_vessel->cargo()); +} + +void VesselEditDialog::on_withdraw_from_vessel() { + if (this->_vessel->cargo().isEmpty()) { + QMessageBox::information(this, "Note", "Vessel has no cargo"); + return; + } + + QMessageBox::information(this, "Note", "Please note, old storage will be used.\n" + "Also, movement cannot be undone by discarding vessel edit dialog"); + + bool success; + auto dpoint = apparatus::instance()->get_object_subsystem()->get_dpoint(this->_vessel->harbor(), success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot find associated harbor in DB"); + return; + } + + QStringList vessel_cargo; + foreach (auto storage, this->_vessel->cargo()) { + vessel_cargo << tr("%1 :%2").arg(storage.title()).arg(storage.id()); + } + bool ok; + QString cargo_id_str = QInputDialog::getItem(this, "Select cargo", "Cargo in storage:", vessel_cargo, 0, false, &ok); + if (!ok || cargo_id_str.isEmpty()) { + QMessageBox::information(this, "Aborted", "Operation aborted by user."); + return; + } + + entity_id cid = cargo_id_str.split(":")[1].toULongLong(); + auto cargo = this->_vessel->get_cargo(cid, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot find cargo in vessel"); + return; + } + + QStringList harbor_storage; + foreach (auto storage, dpoint->storages()) { + harbor_storage << QString::number(storage.id()); + } + QString storage_id_str = QInputDialog::getItem(this, "Select storage", "Storages in harbor:", harbor_storage, 0, false, &ok); + if (!ok || storage_id_str.isEmpty()) { + QMessageBox::information(this, "Aborted", "Operation aborted by user."); + return; + } + entity_id sid = storage_id_str.toULongLong(); + auto storage = dpoint->get_storage(sid, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot find associated storage in harbor"); + return; + } + + storage->add_cargo(cargo, success); + if (!success) { + QMessageBox::critical(this, "Error", "Cannot add cargo to storage"); + return; + } + this->_vessel->withdraw_cargo(cid, success); + if (!success) { + throw std::runtime_error("Cannot withdraw from vessel"); + } + + QMessageBox::information(this, "Info", "Successfully withdrawed cargo from vessel"); + cvm->set_data(this->_vessel->cargo()); +} + +void VesselEditDialog::accept() { + int cvs = 0; + foreach (auto c, this->_vessel->cargo()) { + cvs += c.volume(); + } + if (cvs > ui->sb_capacity->value()) { + QMessageBox::critical(this, "Error", "Cargo volume bigger than capacity"); + return; + } + + auto slog = ui->cb_skippers->currentText().split(":")[0].trimmed(); + auto hid = ui->cb_port->currentText().split(":")[1].trimmed().toULongLong(); + auto cap = ui->sb_capacity->value(); + + this->_vessel->set_skipper(slog); + this->_vessel->set_harbor(hid); + this->_vessel->set_capacity(cap); + + QDialog::accept(); +} diff --git a/sea_transport/vesseleditdialog.h b/sea_transport/vesseleditdialog.h index 8aa08af..f616972 100644 --- a/sea_transport/vesseleditdialog.h +++ b/sea_transport/vesseleditdialog.h @@ -2,21 +2,40 @@ #define VESSELEDITDIALOG_H #include +#include +#include + +#include "entities/vessel_entity.h" +#include "system/apparatus.h" +#include "viewmodels/cargoviewmodel.h" +#include "cargoeditdialog.h" namespace Ui { class VesselEditDialog; } -class VesselEditDialog : public QDialog -{ +class VesselEditDialog : public QDialog { Q_OBJECT + Ui::VesselEditDialog *ui; + + CargoViewModel *cvm; + vessel_entity *_vessel; + + void select_proper_skipper(); + void select_proper_port(); public: explicit VesselEditDialog(QWidget *parent = nullptr); ~VesselEditDialog(); -private: - Ui::VesselEditDialog *ui; + vessel_entity* vessel(); + void set_vessel(vessel_entity *ves, bool edit); + +public slots: + void on_cargo_add(); + void on_withdraw_from_harbor(); + void on_withdraw_from_vessel(); + void accept() Q_DECL_OVERRIDE; }; #endif // VESSELEDITDIALOG_H diff --git a/sea_transport/vesseleditdialog.ui b/sea_transport/vesseleditdialog.ui index f802ae8..f70bdc3 100644 --- a/sea_transport/vesseleditdialog.ui +++ b/sea_transport/vesseleditdialog.ui @@ -10,100 +10,146 @@ 425 + + + 361 + 425 + + + + + 361 + 425 + + Dialog - + - - QFormLayout::ExpandingFieldsGrow - - - 24 - - - 8 - - - 4 - - - 4 - - - 4 - - - 4 - - Vessel num.: + Skipper: - - - - Home port: + Harbor: - - - - 0 - 0 - - - - Choose... - - + - Max. capacity: + Capacity (new): + + + - + + + 1 + + + 50000 + + + + + + + Capacity (current): + + + + + + + 50000 + + - - - + + + QAbstractItemView::SelectRows + + + + + + + + + Remove cargo + + - - + + Add cargo + + + + false + + + Get from harbor + + + + + + + false + + + Move to harbor + + + + + + + Qt::Vertical + + + + 20 + 64 + + + + - + Discard - + Save diff --git a/sea_transport/viewmodels/vesselsviewmodel.cpp b/sea_transport/viewmodels/vesselsviewmodel.cpp index 7d4f2ba..bbfeef5 100644 --- a/sea_transport/viewmodels/vesselsviewmodel.cpp +++ b/sea_transport/viewmodels/vesselsviewmodel.cpp @@ -9,7 +9,7 @@ int VesselsViewModel::rowCount(const QModelIndex &/*parent*/) const { } int VesselsViewModel::columnCount(const QModelIndex &/*parent*/) const { - return 5; + return 6; } QVariant VesselsViewModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -18,12 +18,14 @@ QVariant VesselsViewModel::headerData(int section, Qt::Orientation orientation, case 0: return QString("VID"); case 1: - return QString("Harbor"); + return QString("Skipper"); case 2: - return QString("Capacity"); + return QString("Harbor"); case 3: - return QString("Cargo count"); + return QString("Capacity"); case 4: + return QString("Cargo count"); + case 5: return QString("Cargo volume"); } } @@ -33,20 +35,22 @@ QVariant VesselsViewModel::headerData(int section, Qt::Orientation orientation, QVariant VesselsViewModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { auto item = apparatus::instance()->get_object_subsystem()->vessels()[index.row()]; - bool s = false; - auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(item.harbor(), s); + bool hs = false; + auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(item.harbor(), hs); int col = index.column(); switch (col) { case 0: return QString::number(item.id()); case 1: - return (s? harbor->title() : "##ERROR##"); + return item.skipper(); case 2: - return item.capacity(); + return (hs? harbor->title() : tr("##ERROR[%1]##").arg(item.harbor())); case 3: - return item.cargo().length(); + return item.capacity(); case 4: + return item.cargo().length(); + case 5: int cvol = 0; foreach (auto cargo, item.cargo()) { cvol += cargo.volume(); From 2be2e9f5e31d4fb6d41f59c6aa593122bc9468bb Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 19:00:57 +0700 Subject: [PATCH 26/43] All entities now have GID --- sea_transport/deliverypointeditdialog.cpp | 2 +- sea_transport/entities/cargo_entity.cpp | 12 +++++++++++- sea_transport/entities/cargo_entity.h | 4 ++++ sea_transport/entities/dpoint_entity.cpp | 12 +++++++++++- sea_transport/entities/dpoint_entity.h | 4 ++++ sea_transport/entities/user_entity.cpp | 12 +++++++++++- sea_transport/entities/user_entity.h | 4 ++++ sea_transport/system/apparatus.cpp | 18 ++++++++++++------ sea_transport/usereditdialog.cpp | 2 +- 9 files changed, 59 insertions(+), 11 deletions(-) diff --git a/sea_transport/deliverypointeditdialog.cpp b/sea_transport/deliverypointeditdialog.cpp index 187d1c5..c57d7e4 100644 --- a/sea_transport/deliverypointeditdialog.cpp +++ b/sea_transport/deliverypointeditdialog.cpp @@ -94,7 +94,7 @@ void DeliveryPointEditDialog::set_dpoint(dpoint_entity* dpoint, bool edit) { void DeliveryPointEditDialog::accept() { bool emptyTitle = ui->et_title->text().trimmed().isEmpty(); if (emptyTitle) {; - QString message = "Some errors happend, while saving your note:" + QString message = "Some errors happend, while saving:" "
- Title cannot be empty (all spaces - empty too)"; QMessageBox::critical(this, "Error", message); return; diff --git a/sea_transport/entities/cargo_entity.cpp b/sea_transport/entities/cargo_entity.cpp index a5d136c..1fee72e 100644 --- a/sea_transport/entities/cargo_entity.cpp +++ b/sea_transport/entities/cargo_entity.cpp @@ -1,8 +1,10 @@ #include "cargo_entity.h" +entity_id cargo_entity::__global_id = 0; + cargo_entity::cargo_entity() { - this->_id += QRandomGenerator().generate64(); + this->_id = ++cargo_entity::__global_id + QRandomGenerator().generate64(); } cargo_entity::cargo_entity(const QString &title, unsigned int volume) : _title(title), _volume(volume) { @@ -33,3 +35,11 @@ void cargo_entity::serialize(QDataStream &output) { void cargo_entity::deserialize(QDataStream &input) { input >> this->_id >> this->_title >> this->_volume; } + +void cargo_entity::preloadGlobalId(entity_id gid) { + cargo_entity::__global_id = gid; +} + +entity_id cargo_entity::GID() { + return cargo_entity::__global_id; +} diff --git a/sea_transport/entities/cargo_entity.h b/sea_transport/entities/cargo_entity.h index 60d8c69..79f928d 100644 --- a/sea_transport/entities/cargo_entity.h +++ b/sea_transport/entities/cargo_entity.h @@ -10,6 +10,8 @@ class cargo_entity : public IEntity { private: + static entity_id __global_id; + entity_id _id = 0; QString _title; unsigned int _volume = 50000; @@ -24,6 +26,8 @@ public: void serialize(QDataStream &output); void deserialize(QDataStream &input); + static void preloadGlobalId(entity_id gid); + static entity_id GID(); }; #endif // CARGO_ENTITY_H diff --git a/sea_transport/entities/dpoint_entity.cpp b/sea_transport/entities/dpoint_entity.cpp index 55a682d..13b7873 100644 --- a/sea_transport/entities/dpoint_entity.cpp +++ b/sea_transport/entities/dpoint_entity.cpp @@ -1,8 +1,10 @@ #include "dpoint_entity.h" +entity_id dpoint_entity::__global_id = 0; + dpoint_entity::dpoint_entity() { - this->_id += QRandomGenerator().generate64(); + this->_id = ++dpoint_entity::__global_id + QRandomGenerator().generate64(); } dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _dispatcher_id(dispatcher_id), _title(title) { @@ -83,3 +85,11 @@ void dpoint_entity::deserialize(QDataStream &input) { this->_storages[i].deserialize(input); } } + +void dpoint_entity::preloadGlobalId(entity_id gid) { + dpoint_entity::__global_id = gid; +} + +entity_id dpoint_entity::GID() { + return dpoint_entity::__global_id; +} diff --git a/sea_transport/entities/dpoint_entity.h b/sea_transport/entities/dpoint_entity.h index 0a536ba..75e3774 100644 --- a/sea_transport/entities/dpoint_entity.h +++ b/sea_transport/entities/dpoint_entity.h @@ -12,6 +12,8 @@ class dpoint_entity : public IEntity { private: + static entity_id __global_id; + entity_id _id = 0; entity_id _dispatcher_id; QString _title; @@ -33,6 +35,8 @@ public: void serialize(QDataStream &output); void deserialize(QDataStream &input); + static void preloadGlobalId(entity_id gid); + static entity_id GID(); }; #endif // DPOINT_ENTITY_H diff --git a/sea_transport/entities/user_entity.cpp b/sea_transport/entities/user_entity.cpp index 9c628e6..9d0e641 100644 --- a/sea_transport/entities/user_entity.cpp +++ b/sea_transport/entities/user_entity.cpp @@ -1,8 +1,10 @@ #include "user_entity.h" +entity_id user_entity::__global_id = 0; + user_entity::user_entity() { - this->_id += QRandomGenerator().generate64(); + this->_id = ++user_entity::__global_id + QRandomGenerator().generate64(); } user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) { @@ -47,3 +49,11 @@ void user_entity::serialize(QDataStream &output) { void user_entity::deserialize(QDataStream &input) { input >> this->_id >> this->_login >> this->_role >> this->_pwd_hash; } + +void user_entity::preloadGlobalId(entity_id gid) { + user_entity::__global_id = gid; +} + +entity_id user_entity::GID() { + return user_entity::__global_id; +} diff --git a/sea_transport/entities/user_entity.h b/sea_transport/entities/user_entity.h index 6ab2de9..f3387a1 100644 --- a/sea_transport/entities/user_entity.h +++ b/sea_transport/entities/user_entity.h @@ -15,6 +15,8 @@ enum class UserRole { class user_entity : public IEntity { private: + static entity_id __global_id; + entity_id _id = 0; QString _login; UserRole _role; @@ -33,6 +35,8 @@ public: void serialize(QDataStream &output); void deserialize(QDataStream &input); + static void preloadGlobalId(entity_id gid); + static entity_id GID(); }; #endif // USER_ENTITY_H diff --git a/sea_transport/system/apparatus.cpp b/sea_transport/system/apparatus.cpp index 9aa878d..3e8e2c7 100644 --- a/sea_transport/system/apparatus.cpp +++ b/sea_transport/system/apparatus.cpp @@ -39,9 +39,12 @@ void apparatus::save() { QDataStream stream(&f); // saving GIDs - entity_id vgid = vessel_entity::GID(); + entity_id cgid = cargo_entity::GID(); + entity_id dgid = dpoint_entity::GID(); entity_id sgid = storage_entity::GID(); - stream << vgid << sgid; + entity_id ugid = user_entity::GID(); + entity_id vgid = vessel_entity::GID(); + stream << cgid << dgid << sgid << ugid << vgid; // serializing data this->_auth_system->serialize_data(&stream); @@ -52,17 +55,20 @@ void apparatus::save() { void apparatus::load() { if (_instance == nullptr) { - throw std::runtime_error("HOW DU FUCK INSTANCE IS NULL????"); + throw std::runtime_error("NO WAY INSTANCE IS NULL!"); } QFile f(apparatus::filename); f.open(QIODevice::ReadOnly); QDataStream stream(&f); // loading GIDs - entity_id vgid, sgid = vgid = 0; - stream >> vgid >> sgid; - vessel_entity::preloadGlobalId(vgid); + entity_id cgid, dgid, sgid, ugid, vgid = ugid = sgid = dgid = cgid = 0; + stream >> cgid >> dgid >> sgid >> ugid >> vgid; + cargo_entity::preloadGlobalId(cgid); + dpoint_entity::preloadGlobalId(dgid); storage_entity::preloadGlobalId(sgid); + user_entity::preloadGlobalId(ugid); + vessel_entity::preloadGlobalId(vgid); // deserializing data this->_auth_system->deserialize_data(&stream); diff --git a/sea_transport/usereditdialog.cpp b/sea_transport/usereditdialog.cpp index a84ba1b..3954ff9 100644 --- a/sea_transport/usereditdialog.cpp +++ b/sea_transport/usereditdialog.cpp @@ -52,7 +52,7 @@ void UserEditDialog::accept() { errDlg.setTextFormat(Qt::RichText); errDlg.setWindowTitle(tr("Error")); errDlg.setIcon(QMessageBox::Critical); - QString message = tr("Some errors happend, while saving your note:"); + QString message = tr("Some errors happend, while saving:"); if (emptyTitle) { message.append("
- Title cannot be empty (all spaces - empty too)"); } From 0dab9e1eb2a99d9ef8366bf653f6fd5436aa8161 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Wed, 23 Dec 2020 19:21:23 +0700 Subject: [PATCH 27/43] Post done fixes --- sea_transport/system/object_system.cpp | 6 +++--- sea_transport/usereditdialog.cpp | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/sea_transport/system/object_system.cpp b/sea_transport/system/object_system.cpp index 5915b78..1a94dcb 100644 --- a/sea_transport/system/object_system.cpp +++ b/sea_transport/system/object_system.cpp @@ -66,11 +66,11 @@ bool object_system::remove_vessel(entity_id oid) { return false; } -bool object_system::add_vessel(vessel_entity dpoint) { +bool object_system::add_vessel(vessel_entity vessel) { bool exists = false; - this->get_dpoint(dpoint.id(), exists); + this->get_vessel(vessel.id(), exists); if (!exists) { - this->_vessels.push_back(dpoint); + this->_vessels.push_back(vessel); return true; } diff --git a/sea_transport/usereditdialog.cpp b/sea_transport/usereditdialog.cpp index 3954ff9..3239ffe 100644 --- a/sea_transport/usereditdialog.cpp +++ b/sea_transport/usereditdialog.cpp @@ -24,6 +24,7 @@ void UserEditDialog::set_user(user_entity* user, bool edit) { ui->et_login->setText(user->login()); ui->et_password->setText("##########UNEDITED##########"); ui->cb_role->setCurrentIndex((int)user->role()); + ui->cb_role->setEnabled(false); } else { this->_user_data = new user_data_struct{}; @@ -46,8 +47,7 @@ void UserEditDialog::accept() { } bool emptyTitle = ui->et_login->text().trimmed().isEmpty(); bool emptyPassword = ui->et_password->text().trimmed().isEmpty(); - bool lowerank = this->_user_data->edit && this->_user_data->role < role; - if (emptyTitle || emptyPassword || lowerank) { + if (emptyTitle || emptyPassword) { QMessageBox errDlg(this); errDlg.setTextFormat(Qt::RichText); errDlg.setWindowTitle(tr("Error")); @@ -59,9 +59,6 @@ void UserEditDialog::accept() { if (emptyPassword) { message.append("
- Password cannot be empty (all spaces - empty too)"); } - if (lowerank) { - message.append("
- You cannot lower users rank"); - } errDlg.setText(message); errDlg.exec(); return; From b6fb78bb7549450be7320df8cbc5a8239efdc6d3 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 27 Dec 2020 19:44:12 +0700 Subject: [PATCH 28/43] Implemented tab switch for diff. user types --- sea_transport/adminpanel.cpp | 22 +++++++++++++++++++++- sea_transport/adminpanel.h | 7 +++++-- sea_transport/adminpanel.ui | 2 +- sea_transport/authwindow.cpp | 4 ++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index 6095b12..c845cfd 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -57,7 +57,7 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP ui->pb_dp_edit->setEnabled(selected.length() == 1); }); - ui->tw_tabs->setCurrentIndex(0); + connect(this, &AdminPanel::user_set, this, &AdminPanel::on_user_set); } AdminPanel::~AdminPanel() { @@ -71,9 +71,29 @@ AdminPanel::~AdminPanel() { AdminPanel& AdminPanel::set_user(const user_entity &user) { this->user = user; ui->lab_user->setText(tr("Hello, **%1**").arg(user.login())); + + emit user_set(); + return *this; } +void AdminPanel::on_user_set() { + UserRole urole = this->user.role(); + switch (urole) { + case UserRole::ADMINISTRATOR: + ui->tw_tabs->setCurrentIndex(0); + break; + case UserRole::DISPATCHER: + ui->tw_tabs->setTabVisible(0, false); + ui->tw_tabs->setCurrentIndex(1); + break; + case UserRole::SKIPPER: + QMessageBox::critical(this, "Error", "You shouldn't be here!"); + close(); + break; + } +} + void AdminPanel::on_logout_requested() { this->close(); } diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index 827c4b1..d3db004 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -20,8 +20,7 @@ namespace Ui { class AdminPanel; } -class AdminPanel : public QMainWindow -{ +class AdminPanel : public QMainWindow { Q_OBJECT user_entity user; @@ -36,7 +35,11 @@ public: AdminPanel& set_user(const user_entity &user); +signals: + void user_set(); + private slots: + void on_user_set(); private: Ui::AdminPanel *ui; diff --git a/sea_transport/adminpanel.ui b/sea_transport/adminpanel.ui index e472f2f..1430a81 100644 --- a/sea_transport/adminpanel.ui +++ b/sea_transport/adminpanel.ui @@ -53,7 +53,7 @@ QTabWidget::Rounded - 2 + 0 false diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index 271365f..1002bdb 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -57,8 +57,8 @@ void AuthWindow::on_auth_requested() { ((AdminPanel*) w)->set_user(*user); } else if (user->role() == UserRole::DISPATCHER) { - // DispatcherPanel(nullptr, user).set_user(user).show(); - return; + w = new AdminPanel(nullptr); + ((AdminPanel*) w)->set_user(*user); } else if (user->role() == UserRole::SKIPPER) { // SkipperPanel(nullptr, user).set_user(user).show(); From e0efbacd097b2dd3dd216d6af6b0240f17e15f31 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 27 Dec 2020 19:47:23 +0700 Subject: [PATCH 29/43] Add skeleton for panel --- sea_transport/sea_transport.pro | 3 +++ sea_transport/skipperpanel.cpp | 14 ++++++++++++++ sea_transport/skipperpanel.h | 22 ++++++++++++++++++++++ sea_transport/skipperpanel.ui | 24 ++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 sea_transport/skipperpanel.cpp create mode 100644 sea_transport/skipperpanel.h create mode 100644 sea_transport/skipperpanel.ui diff --git a/sea_transport/sea_transport.pro b/sea_transport/sea_transport.pro index 99e2c50..93ae602 100644 --- a/sea_transport/sea_transport.pro +++ b/sea_transport/sea_transport.pro @@ -19,6 +19,7 @@ SOURCES += \ entities/user_entity.cpp \ entities/vessel_entity.cpp \ main.cpp \ + skipperpanel.cpp \ storageeditdialog.cpp \ system/apparatus.cpp \ system/auth_system.cpp \ @@ -42,6 +43,7 @@ HEADERS += \ entities/storage_entity.h \ entities/user_entity.h \ entities/vessel_entity.h \ + skipperpanel.h \ storageeditdialog.h \ system/apparatus.h \ system/auth_system.h \ @@ -58,6 +60,7 @@ FORMS += \ authwindow.ui \ cargoeditdialog.ui \ deliverypointeditdialog.ui \ + skipperpanel.ui \ storageeditdialog.ui \ usereditdialog.ui \ vesseleditdialog.ui diff --git a/sea_transport/skipperpanel.cpp b/sea_transport/skipperpanel.cpp new file mode 100644 index 0000000..dcb5d5e --- /dev/null +++ b/sea_transport/skipperpanel.cpp @@ -0,0 +1,14 @@ +#include "skipperpanel.h" +#include "ui_skipperpanel.h" + +SkipperPanel::SkipperPanel(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::SkipperPanel) +{ + ui->setupUi(this); +} + +SkipperPanel::~SkipperPanel() +{ + delete ui; +} diff --git a/sea_transport/skipperpanel.h b/sea_transport/skipperpanel.h new file mode 100644 index 0000000..65a7b51 --- /dev/null +++ b/sea_transport/skipperpanel.h @@ -0,0 +1,22 @@ +#ifndef SKIPPERPANEL_H +#define SKIPPERPANEL_H + +#include + +namespace Ui { + class SkipperPanel; +} + +class SkipperPanel : public QMainWindow +{ + Q_OBJECT + +public: + explicit SkipperPanel(QWidget *parent = nullptr); + ~SkipperPanel(); + +private: + Ui::SkipperPanel *ui; +}; + +#endif // SKIPPERPANEL_H diff --git a/sea_transport/skipperpanel.ui b/sea_transport/skipperpanel.ui new file mode 100644 index 0000000..20e9ec7 --- /dev/null +++ b/sea_transport/skipperpanel.ui @@ -0,0 +1,24 @@ + + + + + SkipperPanel + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + From a8e4b10d077762a2a741d2bbcf3bdb27e59024bc Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 27 Dec 2020 19:56:56 +0700 Subject: [PATCH 30/43] Created UI for skipper panel --- sea_transport/skipperpanel.ui | 145 +++++++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 9 deletions(-) diff --git a/sea_transport/skipperpanel.ui b/sea_transport/skipperpanel.ui index 20e9ec7..315e473 100644 --- a/sea_transport/skipperpanel.ui +++ b/sea_transport/skipperpanel.ui @@ -1,24 +1,151 @@ + - - - SkipperPanel 0 0 - 800 - 600 + 560 + 337 MainWindow - - - + + + + + + + 0 + 0 + + + + Logout + + + + + + + Hello, %1 + + + Qt::MarkdownText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Vessel info + + + + + + VID: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + #### + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + + + + Capacity (left/max): + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + #### + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + + + + Harbor: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + #### + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Vessel cargo + + + + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectRows + + + + + + + + - + From 05ac14f748fbd008946da66cc14b32c4e96a550d Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 27 Dec 2020 20:22:58 +0700 Subject: [PATCH 31/43] Add skipper view render code --- sea_transport/skipperpanel.cpp | 74 +++++++++++++++++++++++++++++++--- sea_transport/skipperpanel.h | 24 ++++++++++- sea_transport/skipperpanel.ui | 8 ++-- 3 files changed, 94 insertions(+), 12 deletions(-) diff --git a/sea_transport/skipperpanel.cpp b/sea_transport/skipperpanel.cpp index dcb5d5e..dccf3c9 100644 --- a/sea_transport/skipperpanel.cpp +++ b/sea_transport/skipperpanel.cpp @@ -1,14 +1,76 @@ #include "skipperpanel.h" #include "ui_skipperpanel.h" -SkipperPanel::SkipperPanel(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::SkipperPanel) -{ + +SkipperPanel::SkipperPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::SkipperPanel) { ui->setupUi(this); + + + connect(ui->pb_logout, &QPushButton::clicked, this, &SkipperPanel::on_logout_requested); + + cvm = new CargoViewModel(this); + ui->tv_cargo->setModel(this->cvm); } -SkipperPanel::~SkipperPanel() -{ +SkipperPanel::~SkipperPanel() { delete ui; + + delete cvm; +} + +SkipperPanel& SkipperPanel::set_user(const user_entity &user) { + this->user = user; + ui->lab_user->setText(tr("Hello, **%1**").arg(user.login())); + + emit user_set(); + + return *this; +} + +void SkipperPanel::on_user_set() { + UserRole urole = this->user.role(); + switch (urole) { + case UserRole::ADMINISTRATOR: + case UserRole::DISPATCHER: + QMessageBox::critical(this, "Error", "You shouldn't be here!"); + close(); + return; + case UserRole::SKIPPER: + break; + } + + bool success = false; + vessel_entity vessel; + foreach(auto _vessel, apparatus::instance()->get_object_subsystem()->vessels()) { + if (_vessel.skipper() == this->user.login()) { + success = true; + vessel = _vessel; + break; + } + } + + if (!success) { + QMessageBox::critical(this, "Error", "You are not assigned to vessel. \n" + "Ask you local dispatcher/administrator to do it. \n" + "System will now close."); + this->close(); + } + + ui->lab_vid->setText(QString::number(vessel.id())); + + bool h_success; + auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(vessel.harbor(), h_success); + ui->lab_harbor->setText(h_success? harbor->title() : "#UNKNOWN#"); + + int cap_used = 0; + foreach (auto c, vessel.cargo()) { + cap_used += c.volume(); + } + ui->lab_capacity->setText(tr("%1/%2/%3").arg(cap_used, vessel.capacity(), vessel.capacity() + cap_used)); + + this->cvm->set_data(vessel.cargo()); +} + +void SkipperPanel::on_logout_requested() { + this->close(); } diff --git a/sea_transport/skipperpanel.h b/sea_transport/skipperpanel.h index 65a7b51..d82aa18 100644 --- a/sea_transport/skipperpanel.h +++ b/sea_transport/skipperpanel.h @@ -2,21 +2,41 @@ #define SKIPPERPANEL_H #include +#include +#include + +#include "system/apparatus.h" +#include "viewmodels/cargoviewmodel.h" +#include "entities/user_entity.h" +#include "entities/vessel_entity.h" namespace Ui { class SkipperPanel; } -class SkipperPanel : public QMainWindow -{ +class SkipperPanel : public QMainWindow { Q_OBJECT + user_entity user; + + CargoViewModel *cvm; + public: explicit SkipperPanel(QWidget *parent = nullptr); ~SkipperPanel(); + SkipperPanel& set_user(const user_entity &user); + +signals: + void user_set(); + +private slots: + void on_user_set(); + private: Ui::SkipperPanel *ui; + + void on_logout_requested(); }; #endif // SKIPPERPANEL_H diff --git a/sea_transport/skipperpanel.ui b/sea_transport/skipperpanel.ui index 315e473..30aad65 100644 --- a/sea_transport/skipperpanel.ui +++ b/sea_transport/skipperpanel.ui @@ -60,7 +60,7 @@ - #### + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -77,7 +77,7 @@ - Capacity (left/max): + Capacity (used/left/max): Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -87,7 +87,7 @@ - #### + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -114,7 +114,7 @@ - #### + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter From 4aeb0d572200178bd622206553eefe6996d2281c Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 27 Dec 2020 20:31:05 +0700 Subject: [PATCH 32/43] Some fixes --- sea_transport/authwindow.cpp | 7 +++++-- sea_transport/authwindow.h | 1 + sea_transport/skipperpanel.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index 1002bdb..ecfe549 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -61,8 +61,11 @@ void AuthWindow::on_auth_requested() { ((AdminPanel*) w)->set_user(*user); } else if (user->role() == UserRole::SKIPPER) { - // SkipperPanel(nullptr, user).set_user(user).show(); - return; + QMessageBox::information(this, "Info", "Please note: if you have more than one vessel assigned to you " + "only first will be shown (it is intended by design, you cannot physically control two ships). \n" + "Please, ask your local dispatcher/administrator to unassign you from other vessels."); + w = new SkipperPanel(nullptr); + ((SkipperPanel*) w)->set_user(*user); } else { QMessageBox::critical(this, "Error", "Deserialized user have wrong type. " diff --git a/sea_transport/authwindow.h b/sea_transport/authwindow.h index e0f174e..f438c65 100644 --- a/sea_transport/authwindow.h +++ b/sea_transport/authwindow.h @@ -4,6 +4,7 @@ #include "system/apparatus.h" #include "adminpanel.h" +#include "skipperpanel.h" #include #include diff --git a/sea_transport/skipperpanel.cpp b/sea_transport/skipperpanel.cpp index dccf3c9..8618d7f 100644 --- a/sea_transport/skipperpanel.cpp +++ b/sea_transport/skipperpanel.cpp @@ -10,6 +10,8 @@ SkipperPanel::SkipperPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::Sk cvm = new CargoViewModel(this); ui->tv_cargo->setModel(this->cvm); + + connect(this, &SkipperPanel::user_set, this, &SkipperPanel::on_user_set); } SkipperPanel::~SkipperPanel() { @@ -66,7 +68,7 @@ void SkipperPanel::on_user_set() { foreach (auto c, vessel.cargo()) { cap_used += c.volume(); } - ui->lab_capacity->setText(tr("%1/%2/%3").arg(cap_used, vessel.capacity(), vessel.capacity() + cap_used)); + ui->lab_capacity->setText(tr("%1/%2/%3").arg(cap_used).arg(vessel.capacity() - cap_used).arg(vessel.capacity())); this->cvm->set_data(vessel.cargo()); } From b7ceb7087aa9e62b28c00b1c06a7d8d18ff2fe8d Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 28 Dec 2020 22:22:45 +0700 Subject: [PATCH 33/43] New and fixed tests --- sea_transport/system/apparatus.cpp | 7 +- sea_transport_project.pro.user | 14 +++- st_test/tst_st_test.cpp | 119 +++++++++++++++++++---------- 3 files changed, 95 insertions(+), 45 deletions(-) diff --git a/sea_transport/system/apparatus.cpp b/sea_transport/system/apparatus.cpp index 3e8e2c7..d89d55a 100644 --- a/sea_transport/system/apparatus.cpp +++ b/sea_transport/system/apparatus.cpp @@ -110,5 +110,10 @@ void apparatus::init() { } void apparatus::shutdown() { - delete apparatus::_instance; + apparatus::instance()->save(); + if (apparatus::isFirstRun() && apparatus::instance()->get_auth_subsystem()->users().length() > 0) { + apparatus::generate_lock_file(); + } +// delete apparatus::_instance; + apparatus::_instance = nullptr; } diff --git a/sea_transport_project.pro.user b/sea_transport_project.pro.user index c77d533..ba3931a 100644 --- a/sea_transport_project.pro.user +++ b/sea_transport_project.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -65,14 +65,20 @@ true - Checked + Checked + Checked Checked + Checked + Checked Checked - Checked + Checked Checked Unchecked Checked Unchecked + Checked + Checked + Checked Checked Checked Checked @@ -106,7 +112,7 @@ qt.qt5.5150.win64_mingw81_kit 0 0 - 0 + 1 true 0 diff --git a/st_test/tst_st_test.cpp b/st_test/tst_st_test.cpp index fca6bde..cec13f8 100644 --- a/st_test/tst_st_test.cpp +++ b/st_test/tst_st_test.cpp @@ -7,6 +7,8 @@ #include "../sea_transport/entities/user_entity.h" #include "../sea_transport/system/apparatus.h" +#include "../sea_transport/system/auth_system.h" +#include "../sea_transport/system/object_system.h" #include #include @@ -14,6 +16,7 @@ class st_test : public QObject { Q_OBJECT + dpoint_entity *p; public: st_test(); @@ -30,14 +33,22 @@ private slots: void user_entity_serialization_test(); void user_entity_password_verification_test(); + void apparatus_check_null_throws_error(); + void apparatus_check_first_run(); - void apparatus_check_auth_subsystem(); - void apparatus_check_object_subsystem(); + void apparatus_check_first_registration(); + void apparatus_check_not_first_run(); + void apparatus_check_first_registered_user(); + void apparatus_check_remove_user(); + + void object_subsystem_check_add_dpoint(); + void object_subsystem_check_find_dpoint(); + void object_subsystem_check_remove_dpoint(); }; st_test::st_test() { - + this->p = new dpoint_entity(0, "test"); } st_test::~st_test() { @@ -47,17 +58,19 @@ st_test::~st_test() { //================================================= void st_test::initTestCase() { QVERIFY2( - !QFile("data.bin").exists(), - "There should be no data file!" + !QFile("data.bin").exists() && !QFile("lock").exists(), + "There should be no data and lock file!" ); + } void st_test::cleanupTestCase() { QVERIFY2( - QFile("data.bin").exists(), - "There should be a data file!" + QFile("data.bin").exists() && QFile("lock").exists(), + "There should be data and lock file!" ); QFile().remove("data.bin"); + QFile().remove("lock"); } //================================================= @@ -236,49 +249,75 @@ void st_test::apparatus_check_null_throws_error() { void st_test::apparatus_check_first_run() { apparatus::init(); - QVERIFY2( - apparatus::instance()->isFirstRun(), - "Not a first run!" - ); + QVERIFY(apparatus::instance()->isFirstRun()); apparatus::shutdown(); } -void st_test::apparatus_check_auth_subsystem() { +void st_test::apparatus_check_first_registration() { apparatus::init(); auto as = apparatus::instance()->get_auth_subsystem(); - { - bool test = as->register_user("testor", "passwd", UserRole::ADMINISTRATOR); - QVERIFY(test); - } - { - bool test; - as->get_user("testor", test); - QVERIFY(test); - } - { - bool test = as->remove_user("testor"); - QVERIFY(test); - } + + bool test = as->register_user("testor", "passwd", UserRole::ADMINISTRATOR); + QVERIFY(test); + apparatus::shutdown(); } -void st_test::apparatus_check_object_subsystem() { +void st_test::apparatus_check_not_first_run() { apparatus::init(); + QVERIFY(!apparatus::instance()->isFirstRun()); + apparatus::shutdown(); +} + +void st_test::apparatus_check_first_registered_user() { + apparatus::init(); + auto as = apparatus::instance()->get_auth_subsystem(); + + bool test; + auto user = as->get_user("testor", test); + QVERIFY(test && user->role() == UserRole::ADMINISTRATOR); + + apparatus::shutdown(); +} + +void st_test::apparatus_check_remove_user() { + apparatus::init(); + auto as = apparatus::instance()->get_auth_subsystem(); + + bool test = as->remove_user("testor"); + QVERIFY(test); + + apparatus::shutdown(); +} + +void st_test::object_subsystem_check_add_dpoint() { + apparatus::init(); + auto os = apparatus::instance()->get_object_subsystem(); - dpoint_entity p(0, "test"); - { - bool test = os->add_dpoint(p); - QVERIFY(test); - } - { - bool test; - os->get_dpoint(p.id(), test); - QVERIFY(test); - } - { - bool test = os->remove_dpoint(p.id()); - QVERIFY(test); - } + bool test = os->add_dpoint(*this->p); + QVERIFY(test); + + apparatus::shutdown(); +} + +void st_test::object_subsystem_check_find_dpoint() { + apparatus::init(); + + auto os = apparatus::instance()->get_object_subsystem(); + bool test; + os->get_dpoint(this->p->id(), test); + QVERIFY(test); + + apparatus::shutdown(); +} + +void st_test::object_subsystem_check_remove_dpoint() { + apparatus::init(); + + auto os = apparatus::instance()->get_object_subsystem(); + bool test = os->remove_dpoint(this->p->id()); + QVERIFY(test); + apparatus::shutdown(); } From 02766bd5d2ccc8ff667ded8d1d13990b9569489f Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 10 Jan 2021 18:59:53 +0700 Subject: [PATCH 34/43] Initial --- sea_transport/usereditdialog.cpp | 3 +++ sea_transport_project.pro.user | 34 +++++++------------------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/sea_transport/usereditdialog.cpp b/sea_transport/usereditdialog.cpp index 3239ffe..bec2fa0 100644 --- a/sea_transport/usereditdialog.cpp +++ b/sea_transport/usereditdialog.cpp @@ -44,6 +44,9 @@ void UserEditDialog::accept() { case 2: role = UserRole::SKIPPER; break; + default: + QMessageBox::critical(this, "Error", "Role not selected"); + return; } bool emptyTitle = ui->et_login->text().trimmed().isEmpty(); bool emptyPassword = ui->et_password->text().trimmed().isEmpty(); diff --git a/sea_transport_project.pro.user b/sea_transport_project.pro.user index ba3931a..18d2d69 100644 --- a/sea_transport_project.pro.user +++ b/sea_transport_project.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -64,27 +64,7 @@ true true - - Checked - Checked - Checked - Checked - Checked - Checked - Checked - Checked - Unchecked - Checked - Unchecked - Checked - Checked - Checked - Checked - Checked - Checked - Checked - Checked - + 0 true @@ -110,9 +90,9 @@ Desktop Qt 5.15.0 MinGW 64-bit Desktop Qt 5.15.0 MinGW 64-bit qt.qt5.5150.win64_mingw81_kit - 0 + 1 0 - 1 + 0 true 0 @@ -175,7 +155,7 @@ true QtProjectManager.QMakeBuildStep - true + false @@ -357,7 +337,7 @@ false true - C:/Users/Admin/Documents/repos/build-sea_transport_project-Desktop_Qt_5_15_0_MinGW_64_bit-Debug/sea_transport + C:/Users/Admin/Documents/repos/build-sea_transport_project-Desktop_Qt_5_15_0_MinGW_64_bit-Release/sea_transport dwarf @@ -432,7 +412,7 @@ false true - C:/Users/Admin/Documents/repos/build-sea_transport_project-Desktop_Qt_5_15_0_MinGW_64_bit-Debug/st_test + C:/Users/Admin/Documents/repos/build-sea_transport_project-Desktop_Qt_5_15_0_MinGW_64_bit-Release/st_test 2 From c5f1572efaea9bcc5a2d873c55d732cd149d9500 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 10 Jan 2021 19:49:24 +0700 Subject: [PATCH 35/43] Code style refactoring done --- sea_transport/adminpanel.cpp | 38 ++++++++------- sea_transport/adminpanel.h | 10 ++-- sea_transport/authwindow.cpp | 10 ++-- sea_transport/authwindow.h | 10 ++-- sea_transport/cargoeditdialog.cpp | 1 + sea_transport/cargoeditdialog.h | 6 +-- sea_transport/deliverypointeditdialog.cpp | 37 ++++++++------- sea_transport/deliverypointeditdialog.h | 10 ++-- sea_transport/entities/cargo_entity.cpp | 3 +- sea_transport/entities/dpoint_entity.cpp | 3 +- sea_transport/entities/user_entity.cpp | 15 ++++-- sea_transport/entities/user_entity.h | 1 - sea_transport/entities/vessel_entity.cpp | 6 ++- sea_transport/main.cpp | 5 +- sea_transport/skipperpanel.cpp | 15 +++--- sea_transport/skipperpanel.h | 11 ++--- sea_transport/storageeditdialog.cpp | 12 +++-- sea_transport/storageeditdialog.h | 5 +- sea_transport/system/apparatus.cpp | 9 ++-- sea_transport/system/apparatus.h | 5 +- sea_transport/system/auth_system.h | 3 +- sea_transport/system/object_system.h | 3 +- sea_transport/usereditdialog.cpp | 2 +- sea_transport/usereditdialog.h | 5 +- sea_transport/vesseleditdialog.cpp | 46 ++++++++++++------- sea_transport/vesseleditdialog.h | 13 +++--- sea_transport/viewmodels/cargoviewmodel.cpp | 1 + sea_transport/viewmodels/cargoviewmodel.h | 2 + .../viewmodels/deliverypointsviewmodel.cpp | 4 +- .../viewmodels/deliverypointsviewmodel.h | 2 + sea_transport/viewmodels/usersviewmodel.cpp | 1 + sea_transport/viewmodels/usersviewmodel.h | 2 + sea_transport/viewmodels/vesselsviewmodel.cpp | 7 +-- sea_transport/viewmodels/vesselsviewmodel.h | 2 + sea_transport_project.pro.user | 23 +++++++++- st_test/tst_st_test.cpp | 4 +- 36 files changed, 202 insertions(+), 130 deletions(-) diff --git a/sea_transport/adminpanel.cpp b/sea_transport/adminpanel.cpp index c845cfd..d160861 100644 --- a/sea_transport/adminpanel.cpp +++ b/sea_transport/adminpanel.cpp @@ -5,7 +5,6 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminPanel) { ui->setupUi(this); - connect(ui->pb_logout, &QPushButton::clicked, this, &AdminPanel::on_logout_requested); connect(ui->pb_vessels_add, &QPushButton::clicked, this, [this](){ @@ -32,7 +31,6 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP }); connect(ui->pb_dp_remove, &QPushButton::clicked, this, &AdminPanel::on_delivery_point_remove); - uvm = new UsersViewModel(this); ui->tv_users->setModel(this->uvm); @@ -42,20 +40,26 @@ AdminPanel::AdminPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::AdminP dpvm = new DeliveryPointsViewModel(this); ui->tv_dp->setModel(dpvm); - connect(ui->tv_users->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { - ui->pb_users_remove->setEnabled(selected.length() > 0); - ui->pb_users_edit->setEnabled(selected.length() == 1); - }); + connect(ui->tv_users->selectionModel(), &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &selected) { + ui->pb_users_remove->setEnabled(selected.length() > 0); + ui->pb_users_edit->setEnabled(selected.length() == 1); + } + ); - connect(ui->tv_vessels->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { - ui->pb_vessels_remove->setEnabled(selected.length() > 0); - ui->pb_vessels_edit->setEnabled(selected.length() == 1); - }); + connect(ui->tv_vessels->selectionModel(), &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &selected) { + ui->pb_vessels_remove->setEnabled(selected.length() > 0); + ui->pb_vessels_edit->setEnabled(selected.length() == 1); + } + ); - connect(ui->tv_dp->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { - ui->pb_dp_remove->setEnabled(selected.length() > 0); - ui->pb_dp_edit->setEnabled(selected.length() == 1); - }); + connect(ui->tv_dp->selectionModel(), &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &selected) { + ui->pb_dp_remove->setEnabled(selected.length() > 0); + ui->pb_dp_edit->setEnabled(selected.length() == 1); + } + ); connect(this, &AdminPanel::user_set, this, &AdminPanel::on_user_set); } @@ -199,7 +203,8 @@ void AdminPanel::on_user_add_edit(bool edit) { if (success) { user->set_password(data->password); user->set_role(data->role); - QMessageBox::information(this, "Info", "User edited successfully (note: you cannot change login)"); + QMessageBox::information(this, "Info", "User edited successfully " + "(note: you cannot change login)"); } else { QMessageBox::critical(this, "Error", "Error while editing user"); @@ -207,7 +212,8 @@ void AdminPanel::on_user_add_edit(bool edit) { } } else { - bool success = apparatus::instance()->get_auth_subsystem()->register_user(data->login, data->password, data->role); + bool success = apparatus::instance()->get_auth_subsystem() + ->register_user(data->login, data->password, data->role); if (success) { QMessageBox::information(this, "Info", "User created successfully"); } diff --git a/sea_transport/adminpanel.h b/sea_transport/adminpanel.h index d3db004..8a729ce 100644 --- a/sea_transport/adminpanel.h +++ b/sea_transport/adminpanel.h @@ -16,13 +16,15 @@ #include "entities/user_entity.h" #include "entities/dpoint_entity.h" -namespace Ui { - class AdminPanel; -} + +namespace Ui { class AdminPanel; } class AdminPanel : public QMainWindow { +private: Q_OBJECT + Ui::AdminPanel *ui; + user_entity user; UsersViewModel *uvm; @@ -42,8 +44,6 @@ private slots: void on_user_set(); private: - Ui::AdminPanel *ui; - void on_logout_requested(); void on_vessel_add_edit(bool edit); diff --git a/sea_transport/authwindow.cpp b/sea_transport/authwindow.cpp index ecfe549..b7598d9 100644 --- a/sea_transport/authwindow.cpp +++ b/sea_transport/authwindow.cpp @@ -24,7 +24,7 @@ void AuthWindow::on_auth_requested() { bool success = false; auto a = apparatus::instance()->get_auth_subsystem(); - if (apparatus::isFirstRun()) { + if (apparatus::is_first_run()) { success = a->register_user(login, passw, UserRole::ADMINISTRATOR); if (!success) { QMessageBox::critical(this, "Error", "Cannot register you. Check filesystem permission"); @@ -61,9 +61,11 @@ void AuthWindow::on_auth_requested() { ((AdminPanel*) w)->set_user(*user); } else if (user->role() == UserRole::SKIPPER) { - QMessageBox::information(this, "Info", "Please note: if you have more than one vessel assigned to you " - "only first will be shown (it is intended by design, you cannot physically control two ships). \n" - "Please, ask your local dispatcher/administrator to unassign you from other vessels."); + QMessageBox::information(this, "Info", + "Please note: if you have more than one vessel assigned to you " + "only first will be shown (it is intended by design, you cannot " + "physically control two ships). \nPlease, ask your local " + "dispatcher/administrator to unassign you from other vessels."); w = new SkipperPanel(nullptr); ((SkipperPanel*) w)->set_user(*user); } diff --git a/sea_transport/authwindow.h b/sea_transport/authwindow.h index f438c65..bf7efb8 100644 --- a/sea_transport/authwindow.h +++ b/sea_transport/authwindow.h @@ -9,20 +9,20 @@ #include #include -namespace Ui { -class AuthWindow; -} + +namespace Ui { class AuthWindow; } class AuthWindow : public QMainWindow { +private: Q_OBJECT + Ui::AuthWindow *ui; + public: explicit AuthWindow(QWidget *parent = nullptr); ~AuthWindow(); private: - Ui::AuthWindow *ui; - void on_auth_requested(); }; diff --git a/sea_transport/cargoeditdialog.cpp b/sea_transport/cargoeditdialog.cpp index a55ba79..9730900 100644 --- a/sea_transport/cargoeditdialog.cpp +++ b/sea_transport/cargoeditdialog.cpp @@ -1,6 +1,7 @@ #include "cargoeditdialog.h" #include "ui_cargoeditdialog.h" + CargoEditDialog::CargoEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CargoEditDialog) { ui->setupUi(this); diff --git a/sea_transport/cargoeditdialog.h b/sea_transport/cargoeditdialog.h index fcab6ea..29822b1 100644 --- a/sea_transport/cargoeditdialog.h +++ b/sea_transport/cargoeditdialog.h @@ -6,11 +6,11 @@ #include "entities/cargo_entity.h" -namespace Ui { -class CargoEditDialog; -} + +namespace Ui { class CargoEditDialog; } class CargoEditDialog : public QDialog { +private: Q_OBJECT Ui::CargoEditDialog *ui; diff --git a/sea_transport/deliverypointeditdialog.cpp b/sea_transport/deliverypointeditdialog.cpp index c57d7e4..2954077 100644 --- a/sea_transport/deliverypointeditdialog.cpp +++ b/sea_transport/deliverypointeditdialog.cpp @@ -2,29 +2,34 @@ #include "ui_deliverypointeditdialog.h" -DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::DeliveryPointEditDialog) { +DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::DeliveryPointEditDialog) { ui->setupUi(this); this->svm = new QStringListModel(this); ui->lv_storages->setModel(this->svm); - connect(ui->lv_storages->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { - ui->pb_storage_remove->setEnabled(selected.length() > 0); - ui->pb_storage_edit->setEnabled(selected.length() == 1); - }); + connect(ui->lv_storages->selectionModel(), &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &selected) { + ui->pb_storage_remove->setEnabled(selected.length() > 0); + ui->pb_storage_edit->setEnabled(selected.length() == 1); + } + ); - connect(ui->pb_storage_remove, &QPushButton::clicked, [this]() { - auto sel = ui->lv_storages->selectionModel()->selectedRows(); - if (sel.length() == 0) { - return; - } + connect(ui->pb_storage_remove, &QPushButton::clicked, + [this]() { + auto sel = ui->lv_storages->selectionModel()->selectedRows(); + if (sel.length() == 0) { + return; + } - foreach (auto mIdx, sel) { - auto cuid = mIdx.data().toString().toULongLong(); - this->_dp->remove_storage(cuid); - } - this->update_list(); - }); + foreach (auto mIdx, sel) { + auto cuid = mIdx.data().toString().toULongLong(); + this->_dp->remove_storage(cuid); + } + this->update_list(); + } + ); connect(ui->pb_storage_edit, &QPushButton::clicked, [this]() { this->on_storage_edit_add(true); diff --git a/sea_transport/deliverypointeditdialog.h b/sea_transport/deliverypointeditdialog.h index 3eeb00b..8d1b9a7 100644 --- a/sea_transport/deliverypointeditdialog.h +++ b/sea_transport/deliverypointeditdialog.h @@ -13,19 +13,16 @@ #include "storageeditdialog.h" -namespace Ui { -class DeliveryPointEditDialog; -} +namespace Ui { class DeliveryPointEditDialog; } class DeliveryPointEditDialog : public QDialog { +private: Q_OBJECT Ui::DeliveryPointEditDialog *ui; QStringListModel *svm; dpoint_entity *_dp; - void update_list(); - public: explicit DeliveryPointEditDialog(QWidget *parent = nullptr); ~DeliveryPointEditDialog(); @@ -37,6 +34,9 @@ public slots: void on_storage_edit_add(bool edit); void accept() Q_DECL_OVERRIDE; + +private: + void update_list(); }; #endif // DELIVERYPOINTEDITDIALOG_H diff --git a/sea_transport/entities/cargo_entity.cpp b/sea_transport/entities/cargo_entity.cpp index 1fee72e..cd15fd0 100644 --- a/sea_transport/entities/cargo_entity.cpp +++ b/sea_transport/entities/cargo_entity.cpp @@ -7,7 +7,8 @@ cargo_entity::cargo_entity() { this->_id = ++cargo_entity::__global_id + QRandomGenerator().generate64(); } -cargo_entity::cargo_entity(const QString &title, unsigned int volume) : _title(title), _volume(volume) { +cargo_entity::cargo_entity(const QString &title, unsigned int volume) + : _title(title), _volume(volume) { this->_id = volume; auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5); for (auto bit : hash) { diff --git a/sea_transport/entities/dpoint_entity.cpp b/sea_transport/entities/dpoint_entity.cpp index 13b7873..7b7a8eb 100644 --- a/sea_transport/entities/dpoint_entity.cpp +++ b/sea_transport/entities/dpoint_entity.cpp @@ -7,7 +7,8 @@ dpoint_entity::dpoint_entity() { this->_id = ++dpoint_entity::__global_id + QRandomGenerator().generate64(); } -dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _dispatcher_id(dispatcher_id), _title(title) { +dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) + : _dispatcher_id(dispatcher_id), _title(title) { this->_id = dispatcher_id; auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5); for (auto bit : hash) { diff --git a/sea_transport/entities/user_entity.cpp b/sea_transport/entities/user_entity.cpp index 9d0e641..4089496 100644 --- a/sea_transport/entities/user_entity.cpp +++ b/sea_transport/entities/user_entity.cpp @@ -7,12 +7,15 @@ user_entity::user_entity() { this->_id = ++user_entity::__global_id + QRandomGenerator().generate64(); } -user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) { - this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256); +user_entity::user_entity(const QString &login, const QString &password, UserRole role) + : _login(login), _role(role) { + this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), + QCryptographicHash::Sha3_256); foreach (auto bit, this->_pwd_hash) { this->_id += bit; } - foreach (auto bit, QCryptographicHash::hash(login.toLocal8Bit(), QCryptographicHash::Sha3_256)) { + foreach (auto bit, + QCryptographicHash::hash(login.toLocal8Bit(), QCryptographicHash::Sha3_256)) { this->_id += bit; } this->_id += QRandomGenerator().generate64(); @@ -31,11 +34,13 @@ UserRole user_entity::role() const { } bool user_entity::verify_password(const QString &password) const { - return (this->_pwd_hash == QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256)); + return (this->_pwd_hash == QCryptographicHash::hash(password.toLocal8Bit(), + QCryptographicHash::Sha3_256)); } void user_entity::set_password(const QString &new_password) { - this->_pwd_hash = QCryptographicHash::hash(new_password.toLocal8Bit(), QCryptographicHash::Sha3_256); + this->_pwd_hash = QCryptographicHash::hash(new_password.toLocal8Bit(), + QCryptographicHash::Sha3_256); } void user_entity::set_role(UserRole new_role) { diff --git a/sea_transport/entities/user_entity.h b/sea_transport/entities/user_entity.h index f3387a1..e382afc 100644 --- a/sea_transport/entities/user_entity.h +++ b/sea_transport/entities/user_entity.h @@ -12,7 +12,6 @@ enum class UserRole { ADMINISTRATOR, DISPATCHER, SKIPPER }; - class user_entity : public IEntity { private: static entity_id __global_id; diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index 383d116..8762b42 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -7,8 +7,10 @@ vessel_entity::vessel_entity() { this->_id = ++vessel_entity::__global_id + QRandomGenerator().generate64(); } -vessel_entity::vessel_entity(QString skipper, entity_id harbor_id, unsigned int capacity) : _skipper(skipper), _harbor_id(harbor_id), _capacity(capacity) { - this->_id = ++vessel_entity::__global_id + harbor_id + capacity + QRandomGenerator().generate64(); +vessel_entity::vessel_entity(QString skipper, entity_id harbor_id, unsigned int capacity) + : _skipper(skipper), _harbor_id(harbor_id), _capacity(capacity) { + this->_id = ++vessel_entity::__global_id + harbor_id + capacity + + QRandomGenerator().generate64(); } entity_id vessel_entity::id() const { diff --git a/sea_transport/main.cpp b/sea_transport/main.cpp index 5a92eef..89c4247 100644 --- a/sea_transport/main.cpp +++ b/sea_transport/main.cpp @@ -1,9 +1,9 @@ #include "authwindow.h" - #include "system/apparatus.h" #include + int main(int argc, char *argv[]) { QApplication a(argc, argv); @@ -14,7 +14,8 @@ int main(int argc, char *argv[]) { QObject::connect(&a, &QApplication::aboutToQuit, []() { apparatus::instance()->save(); - if (apparatus::isFirstRun() && apparatus::instance()->get_auth_subsystem()->users().length() > 0) { + if (apparatus::is_first_run() + && apparatus::instance()->get_auth_subsystem()->users().length() > 0) { apparatus::generate_lock_file(); } }); diff --git a/sea_transport/skipperpanel.cpp b/sea_transport/skipperpanel.cpp index 8618d7f..a86ef48 100644 --- a/sea_transport/skipperpanel.cpp +++ b/sea_transport/skipperpanel.cpp @@ -5,7 +5,6 @@ SkipperPanel::SkipperPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::SkipperPanel) { ui->setupUi(this); - connect(ui->pb_logout, &QPushButton::clicked, this, &SkipperPanel::on_logout_requested); cvm = new CargoViewModel(this); @@ -52,23 +51,27 @@ void SkipperPanel::on_user_set() { } if (!success) { - QMessageBox::critical(this, "Error", "You are not assigned to vessel. \n" - "Ask you local dispatcher/administrator to do it. \n" - "System will now close."); + QMessageBox::critical(this, "Error", + "You are not assigned to vessel. \nAsk you local " + "dispatcher/administrator to do it. \nSystem will now close."); this->close(); } ui->lab_vid->setText(QString::number(vessel.id())); bool h_success; - auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(vessel.harbor(), h_success); + auto harbor = apparatus::instance()->get_object_subsystem() + ->get_dpoint(vessel.harbor(), h_success); ui->lab_harbor->setText(h_success? harbor->title() : "#UNKNOWN#"); int cap_used = 0; foreach (auto c, vessel.cargo()) { cap_used += c.volume(); } - ui->lab_capacity->setText(tr("%1/%2/%3").arg(cap_used).arg(vessel.capacity() - cap_used).arg(vessel.capacity())); + ui->lab_capacity->setText(tr("%1/%2/%3") + .arg(cap_used) + .arg(vessel.capacity() - cap_used) + .arg(vessel.capacity())); this->cvm->set_data(vessel.cargo()); } diff --git a/sea_transport/skipperpanel.h b/sea_transport/skipperpanel.h index d82aa18..edce0fd 100644 --- a/sea_transport/skipperpanel.h +++ b/sea_transport/skipperpanel.h @@ -10,15 +10,16 @@ #include "entities/user_entity.h" #include "entities/vessel_entity.h" -namespace Ui { - class SkipperPanel; -} + +namespace Ui { class SkipperPanel; } class SkipperPanel : public QMainWindow { +private: Q_OBJECT - user_entity user; + Ui::SkipperPanel *ui; + user_entity user; CargoViewModel *cvm; public: @@ -34,8 +35,6 @@ private slots: void on_user_set(); private: - Ui::SkipperPanel *ui; - void on_logout_requested(); }; diff --git a/sea_transport/storageeditdialog.cpp b/sea_transport/storageeditdialog.cpp index e7426c0..8adeb6f 100644 --- a/sea_transport/storageeditdialog.cpp +++ b/sea_transport/storageeditdialog.cpp @@ -1,15 +1,19 @@ #include "storageeditdialog.h" #include "ui_storageeditdialog.h" -StorageEditDialog::StorageEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::StorageEditDialog) { + +StorageEditDialog::StorageEditDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::StorageEditDialog) { ui->setupUi(this); this->cvm = new CargoViewModel(this); ui->tv_cargo->setModel(this->cvm); - connect(ui->tv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { - ui->pb_cargo_remove->setEnabled(selected.length() > 0); - }); + connect(ui->tv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &selected) { + ui->pb_cargo_remove->setEnabled(selected.length() > 0); + } + ); connect(ui->pb_cargo_remove, &QPushButton::clicked, [this]() { auto sel = ui->tv_cargo->selectionModel()->selectedRows(); diff --git a/sea_transport/storageeditdialog.h b/sea_transport/storageeditdialog.h index 372833a..95ae41d 100644 --- a/sea_transport/storageeditdialog.h +++ b/sea_transport/storageeditdialog.h @@ -10,11 +10,10 @@ #include "cargoeditdialog.h" -namespace Ui { -class StorageEditDialog; -} +namespace Ui { class StorageEditDialog; } class StorageEditDialog : public QDialog { +private: Q_OBJECT Ui::StorageEditDialog *ui; diff --git a/sea_transport/system/apparatus.cpp b/sea_transport/system/apparatus.cpp index d89d55a..75de92f 100644 --- a/sea_transport/system/apparatus.cpp +++ b/sea_transport/system/apparatus.cpp @@ -77,7 +77,7 @@ void apparatus::load() { f.close(); } -bool apparatus::isFirstRun() { +bool apparatus::is_first_run() { return !QFile().exists("lock"); } @@ -94,7 +94,7 @@ void apparatus::init() { throw std::runtime_error("System already initialized!"); } - bool fr = apparatus::isFirstRun(); + bool fr = apparatus::is_first_run(); apparatus::_instance = new apparatus(); if (fr) { @@ -111,9 +111,10 @@ void apparatus::init() { void apparatus::shutdown() { apparatus::instance()->save(); - if (apparatus::isFirstRun() && apparatus::instance()->get_auth_subsystem()->users().length() > 0) { + if (apparatus::is_first_run() + && apparatus::instance()->get_auth_subsystem()->users().length() > 0) { apparatus::generate_lock_file(); } -// delete apparatus::_instance; + apparatus::_instance = nullptr; } diff --git a/sea_transport/system/apparatus.h b/sea_transport/system/apparatus.h index 43ddeee..ff628e8 100644 --- a/sea_transport/system/apparatus.h +++ b/sea_transport/system/apparatus.h @@ -12,8 +12,7 @@ #include -class apparatus -{ +class apparatus { private: static apparatus *_instance; static const QString filename; @@ -31,7 +30,7 @@ public: void save(); void load(); - static bool isFirstRun(); + static bool is_first_run(); static void generate_lock_file(); static apparatus* instance(); static void init(); diff --git a/sea_transport/system/auth_system.h b/sea_transport/system/auth_system.h index 21dd056..8d0d3bf 100644 --- a/sea_transport/system/auth_system.h +++ b/sea_transport/system/auth_system.h @@ -6,8 +6,7 @@ #include "../entities/user_entity.h" -class auth_system -{ +class auth_system { private: QVector _users; public: diff --git a/sea_transport/system/object_system.h b/sea_transport/system/object_system.h index 7551201..40d09f1 100644 --- a/sea_transport/system/object_system.h +++ b/sea_transport/system/object_system.h @@ -7,8 +7,7 @@ #include "../entities/vessel_entity.h" -class object_system -{ +class object_system { private: QVector _dpoints; QVector _vessels; diff --git a/sea_transport/usereditdialog.cpp b/sea_transport/usereditdialog.cpp index bec2fa0..4308fd1 100644 --- a/sea_transport/usereditdialog.cpp +++ b/sea_transport/usereditdialog.cpp @@ -22,7 +22,7 @@ void UserEditDialog::set_user(user_entity* user, bool edit) { this->_user_data = new user_data_struct(); ui->et_login->setText(user->login()); - ui->et_password->setText("##########UNEDITED##########"); + ui->et_password->setText("#UNEDITED#"); ui->cb_role->setCurrentIndex((int)user->role()); ui->cb_role->setEnabled(false); } diff --git a/sea_transport/usereditdialog.h b/sea_transport/usereditdialog.h index ada392e..c352b50 100644 --- a/sea_transport/usereditdialog.h +++ b/sea_transport/usereditdialog.h @@ -7,9 +7,7 @@ #include "entities/user_entity.h" -namespace Ui { -class UserEditDialog; -} +namespace Ui { class UserEditDialog; } struct user_data_struct { QString login; @@ -19,6 +17,7 @@ struct user_data_struct { }; class UserEditDialog : public QDialog { +private: Q_OBJECT Ui::UserEditDialog *ui; diff --git a/sea_transport/vesseleditdialog.cpp b/sea_transport/vesseleditdialog.cpp index a49384a..925f16e 100644 --- a/sea_transport/vesseleditdialog.cpp +++ b/sea_transport/vesseleditdialog.cpp @@ -1,15 +1,19 @@ #include "vesseleditdialog.h" #include "ui_vesseleditdialog.h" -VesselEditDialog::VesselEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::VesselEditDialog) { + +VesselEditDialog::VesselEditDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::VesselEditDialog) { ui->setupUi(this); this->cvm = new CargoViewModel(this); ui->tv_cargo->setModel(this->cvm); - connect(ui->tv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection &selected) { - ui->pb_cargo_remove->setEnabled(selected.length() > 0); - }); + connect(ui->tv_cargo->selectionModel(), &QItemSelectionModel::selectionChanged, + [this](const QItemSelection &selected) { + ui->pb_cargo_remove->setEnabled(selected.length() > 0); + } + ); connect(ui->pb_cargo_remove, &QPushButton::clicked, [this]() { auto sel = ui->tv_cargo->selectionModel()->selectedRows(); @@ -40,8 +44,10 @@ VesselEditDialog::VesselEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui connect(ui->pb_cargo_add, &QPushButton::clicked, this, &VesselEditDialog::on_cargo_add); - connect(ui->pb_withdraw_from_harbor, &QPushButton::clicked, this, &VesselEditDialog::on_withdraw_from_harbor); - connect(ui->pb_withdraw_from_vessel, &QPushButton::clicked, this, &VesselEditDialog::on_withdraw_from_vessel); + connect(ui->pb_withdraw_from_harbor, &QPushButton::clicked, + this, &VesselEditDialog::on_withdraw_from_harbor); + connect(ui->pb_withdraw_from_vessel, &QPushButton::clicked, + this, &VesselEditDialog::on_withdraw_from_vessel); connect(ui->pb_save, &QPushButton::clicked, this, &VesselEditDialog::accept); connect(ui->pb_discard, &QPushButton::clicked, this, &VesselEditDialog::reject); @@ -116,11 +122,13 @@ void VesselEditDialog::on_cargo_add() { } void VesselEditDialog::on_withdraw_from_harbor() { - QMessageBox::information(this, "Note", "Please note, old storage will be used.\n" - "Also, movement cannot be undone by discarding vessel edit dialog"); + QMessageBox::information(this, "Note", + "Please note, old storage will be used.\nAlso, movement cannot be " + "undone by discarding vessel edit dialog"); bool success; - auto dpoint = apparatus::instance()->get_object_subsystem()->get_dpoint(this->_vessel->harbor(), success); + auto dpoint = apparatus::instance()->get_object_subsystem() + ->get_dpoint(this->_vessel->harbor(), success); if (!success) { QMessageBox::critical(this, "Error", "Cannot find associated harbor in DB"); return; @@ -135,7 +143,8 @@ void VesselEditDialog::on_withdraw_from_harbor() { harbor_storage << QString::number(storage.id()); } bool ok; - QString storage_id_str = QInputDialog::getItem(this, "Select storage", "Storages in harbor:", harbor_storage, 0, false, &ok); + QString storage_id_str = QInputDialog::getItem(this, "Select storage", "Storages in harbor:", + harbor_storage, 0, false, &ok); if (!ok || storage_id_str.isEmpty()) { QMessageBox::information(this, "Aborted", "Operation aborted by user."); return; @@ -156,7 +165,8 @@ void VesselEditDialog::on_withdraw_from_harbor() { foreach (auto storage, storage->cargo()) { storage_cargo << tr("%1 :%2").arg(storage.title()).arg(storage.id()); } - QString cargo_id_str = QInputDialog::getItem(this, "Select cargo", "Cargo in storage:", storage_cargo, 0, false, &ok); + QString cargo_id_str = QInputDialog::getItem(this, "Select cargo", "Cargo in storage:", + storage_cargo, 0, false, &ok); if (!ok || cargo_id_str.isEmpty()) { QMessageBox::information(this, "Aborted", "Operation aborted by user."); return; @@ -189,11 +199,13 @@ void VesselEditDialog::on_withdraw_from_vessel() { return; } - QMessageBox::information(this, "Note", "Please note, old storage will be used.\n" - "Also, movement cannot be undone by discarding vessel edit dialog"); + QMessageBox::information(this, "Note", + "Please note, old storage will be used.\nAlso, movement cannot be " + "undone by discarding vessel edit dialog"); bool success; - auto dpoint = apparatus::instance()->get_object_subsystem()->get_dpoint(this->_vessel->harbor(), success); + auto dpoint = apparatus::instance()->get_object_subsystem() + ->get_dpoint(this->_vessel->harbor(), success); if (!success) { QMessageBox::critical(this, "Error", "Cannot find associated harbor in DB"); return; @@ -204,7 +216,8 @@ void VesselEditDialog::on_withdraw_from_vessel() { vessel_cargo << tr("%1 :%2").arg(storage.title()).arg(storage.id()); } bool ok; - QString cargo_id_str = QInputDialog::getItem(this, "Select cargo", "Cargo in storage:", vessel_cargo, 0, false, &ok); + QString cargo_id_str = QInputDialog::getItem(this, "Select cargo", "Cargo in storage:", + vessel_cargo, 0, false, &ok); if (!ok || cargo_id_str.isEmpty()) { QMessageBox::information(this, "Aborted", "Operation aborted by user."); return; @@ -221,7 +234,8 @@ void VesselEditDialog::on_withdraw_from_vessel() { foreach (auto storage, dpoint->storages()) { harbor_storage << QString::number(storage.id()); } - QString storage_id_str = QInputDialog::getItem(this, "Select storage", "Storages in harbor:", harbor_storage, 0, false, &ok); + QString storage_id_str = QInputDialog::getItem(this, "Select storage", "Storages in harbor:", + harbor_storage, 0, false, &ok); if (!ok || storage_id_str.isEmpty()) { QMessageBox::information(this, "Aborted", "Operation aborted by user."); return; diff --git a/sea_transport/vesseleditdialog.h b/sea_transport/vesseleditdialog.h index f616972..75f87dc 100644 --- a/sea_transport/vesseleditdialog.h +++ b/sea_transport/vesseleditdialog.h @@ -10,20 +10,17 @@ #include "viewmodels/cargoviewmodel.h" #include "cargoeditdialog.h" -namespace Ui { -class VesselEditDialog; -} + +namespace Ui { class VesselEditDialog; } class VesselEditDialog : public QDialog { +private: Q_OBJECT Ui::VesselEditDialog *ui; CargoViewModel *cvm; vessel_entity *_vessel; - void select_proper_skipper(); - void select_proper_port(); - public: explicit VesselEditDialog(QWidget *parent = nullptr); ~VesselEditDialog(); @@ -36,6 +33,10 @@ public slots: void on_withdraw_from_harbor(); void on_withdraw_from_vessel(); void accept() Q_DECL_OVERRIDE; + +private: + void select_proper_skipper(); + void select_proper_port(); }; #endif // VESSELEDITDIALOG_H diff --git a/sea_transport/viewmodels/cargoviewmodel.cpp b/sea_transport/viewmodels/cargoviewmodel.cpp index ef6621a..ee60b4d 100644 --- a/sea_transport/viewmodels/cargoviewmodel.cpp +++ b/sea_transport/viewmodels/cargoviewmodel.cpp @@ -1,5 +1,6 @@ #include "cargoviewmodel.h" + CargoViewModel::CargoViewModel(QObject *parent) : QAbstractTableModel(parent) { } diff --git a/sea_transport/viewmodels/cargoviewmodel.h b/sea_transport/viewmodels/cargoviewmodel.h index 26db7b1..4190382 100644 --- a/sea_transport/viewmodels/cargoviewmodel.h +++ b/sea_transport/viewmodels/cargoviewmodel.h @@ -6,7 +6,9 @@ #include "entities/cargo_entity.h" + class CargoViewModel : public QAbstractTableModel { +private: Q_OBJECT QVector _data; diff --git a/sea_transport/viewmodels/deliverypointsviewmodel.cpp b/sea_transport/viewmodels/deliverypointsviewmodel.cpp index 487e768..621e6dc 100644 --- a/sea_transport/viewmodels/deliverypointsviewmodel.cpp +++ b/sea_transport/viewmodels/deliverypointsviewmodel.cpp @@ -1,5 +1,6 @@ #include "deliverypointsviewmodel.h" + DeliveryPointsViewModel::DeliveryPointsViewModel(QObject *parent) : QAbstractTableModel(parent) { } @@ -12,7 +13,8 @@ int DeliveryPointsViewModel::columnCount(const QModelIndex &/*parent*/) const { return 4; } -QVariant DeliveryPointsViewModel::headerData(int section, Qt::Orientation orientation, int role) const { +QVariant DeliveryPointsViewModel::headerData(int section, Qt::Orientation orientation, + int role) const { if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { switch (section) { case 0: diff --git a/sea_transport/viewmodels/deliverypointsviewmodel.h b/sea_transport/viewmodels/deliverypointsviewmodel.h index bfbfb40..d7c836d 100644 --- a/sea_transport/viewmodels/deliverypointsviewmodel.h +++ b/sea_transport/viewmodels/deliverypointsviewmodel.h @@ -5,7 +5,9 @@ #include + class DeliveryPointsViewModel : public QAbstractTableModel { +private: Q_OBJECT public: diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp index 9269d34..dbde3ad 100644 --- a/sea_transport/viewmodels/usersviewmodel.cpp +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -1,5 +1,6 @@ #include "usersviewmodel.h" + UsersViewModel::UsersViewModel(QObject *parent) : QAbstractTableModel(parent) { } diff --git a/sea_transport/viewmodels/usersviewmodel.h b/sea_transport/viewmodels/usersviewmodel.h index 40e3813..e0693e6 100644 --- a/sea_transport/viewmodels/usersviewmodel.h +++ b/sea_transport/viewmodels/usersviewmodel.h @@ -5,7 +5,9 @@ #include + class UsersViewModel : public QAbstractTableModel { +private: Q_OBJECT public: diff --git a/sea_transport/viewmodels/vesselsviewmodel.cpp b/sea_transport/viewmodels/vesselsviewmodel.cpp index bbfeef5..a34d33b 100644 --- a/sea_transport/viewmodels/vesselsviewmodel.cpp +++ b/sea_transport/viewmodels/vesselsviewmodel.cpp @@ -1,5 +1,6 @@ #include "vesselsviewmodel.h" + VesselsViewModel::VesselsViewModel(QObject *parent) : QAbstractTableModel(parent) { } @@ -35,8 +36,8 @@ QVariant VesselsViewModel::headerData(int section, Qt::Orientation orientation, QVariant VesselsViewModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { auto item = apparatus::instance()->get_object_subsystem()->vessels()[index.row()]; - bool hs = false; - auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(item.harbor(), hs); + bool s = false; + auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(item.harbor(), s); int col = index.column(); switch (col) { @@ -45,7 +46,7 @@ QVariant VesselsViewModel::data(const QModelIndex &index, int role) const { case 1: return item.skipper(); case 2: - return (hs? harbor->title() : tr("##ERROR[%1]##").arg(item.harbor())); + return (s? harbor->title() : tr("##ERROR[%1]##").arg(item.harbor())); case 3: return item.capacity(); case 4: diff --git a/sea_transport/viewmodels/vesselsviewmodel.h b/sea_transport/viewmodels/vesselsviewmodel.h index b861fb9..b50aba0 100644 --- a/sea_transport/viewmodels/vesselsviewmodel.h +++ b/sea_transport/viewmodels/vesselsviewmodel.h @@ -5,7 +5,9 @@ #include + class VesselsViewModel : public QAbstractTableModel { +private: Q_OBJECT public: diff --git a/sea_transport_project.pro.user b/sea_transport_project.pro.user index 18d2d69..f11e8c6 100644 --- a/sea_transport_project.pro.user +++ b/sea_transport_project.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -64,7 +64,26 @@ true true - + + Checked + Checked + Checked + Checked + Checked + Checked + Checked + Unchecked + Checked + Unchecked + Checked + Checked + Checked + Checked + Checked + Checked + Checked + Checked + 0 true diff --git a/st_test/tst_st_test.cpp b/st_test/tst_st_test.cpp index cec13f8..9667421 100644 --- a/st_test/tst_st_test.cpp +++ b/st_test/tst_st_test.cpp @@ -249,7 +249,7 @@ void st_test::apparatus_check_null_throws_error() { void st_test::apparatus_check_first_run() { apparatus::init(); - QVERIFY(apparatus::instance()->isFirstRun()); + QVERIFY(apparatus::instance()->is_first_run()); apparatus::shutdown(); } @@ -265,7 +265,7 @@ void st_test::apparatus_check_first_registration() { void st_test::apparatus_check_not_first_run() { apparatus::init(); - QVERIFY(!apparatus::instance()->isFirstRun()); + QVERIFY(!apparatus::instance()->is_first_run()); apparatus::shutdown(); } From addab707d64c6aaa1be3b6fcd8c37cdc0ff17f48 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 10 Jan 2021 19:58:42 +0700 Subject: [PATCH 36/43] Add Doxyfile --- sea_transport/Doxyfile | 2654 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2654 insertions(+) create mode 100644 sea_transport/Doxyfile diff --git a/sea_transport/Doxyfile b/sea_transport/Doxyfile new file mode 100644 index 0000000..ced3ea3 --- /dev/null +++ b/sea_transport/Doxyfile @@ -0,0 +1,2654 @@ +# Doxyfile 1.9.0 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = seaTransport + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = 1.0.0 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Реализация Информационной системы \"Морской транспорт\"" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /