Move project in sub
This commit is contained in:
parent
f868166756
commit
ec1af1b8e5
43 changed files with 358 additions and 2 deletions
73
sea_transport/.gitignore
vendored
Normal file
73
sea_transport/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
17
sea_transport/README.md
Normal file
17
sea_transport/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Информационная система «Морской транспорт».
|
||||
|
||||
### Состав сущностей
|
||||
суда – номер судна, порт приписки, список грузов, размер свободного места в грузовых отсеках
|
||||
груз – идентификатор, количество, пункт доставки
|
||||
пункт доставки – название, список складов
|
||||
склад – номер склада, количество свободного места
|
||||
|
||||
### Операции, исполняемые системой
|
||||
просмотр списка судов
|
||||
перемещение грузов из судов в различных пунктах в склады
|
||||
просмотр списка грузов для каждого склада и загрузку судов
|
||||
|
||||
### Группы пользователей
|
||||
администратор
|
||||
диспетчер
|
||||
капитан
|
||||
14
sea_transport/authwindow.cpp
Normal file
14
sea_transport/authwindow.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "authwindow.h"
|
||||
#include "ui_authwindow.h"
|
||||
|
||||
AuthWindow::AuthWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::AuthWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
AuthWindow::~AuthWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
sea_transport/authwindow.h
Normal file
22
sea_transport/authwindow.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef AUTHWINDOW_H
|
||||
#define AUTHWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class AuthWindow;
|
||||
}
|
||||
|
||||
class AuthWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AuthWindow(QWidget *parent = nullptr);
|
||||
~AuthWindow();
|
||||
|
||||
private:
|
||||
Ui::AuthWindow *ui;
|
||||
};
|
||||
|
||||
#endif // AUTHWINDOW_H
|
||||
120
sea_transport/authwindow.ui
Normal file
120
sea_transport/authwindow.ui
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AuthWindow</class>
|
||||
<widget class="QMainWindow" name="AuthWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="et_login"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Login:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="et_password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btn_login">
|
||||
<property name="text">
|
||||
<string>Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
14
sea_transport/cargoeditdialog.cpp
Normal file
14
sea_transport/cargoeditdialog.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "cargoeditdialog.h"
|
||||
#include "ui_cargoeditdialog.h"
|
||||
|
||||
CargoEditDialog::CargoEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CargoEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CargoEditDialog::~CargoEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
sea_transport/cargoeditdialog.h
Normal file
22
sea_transport/cargoeditdialog.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CARGOEDITDIALOG_H
|
||||
#define CARGOEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class CargoEditDialog;
|
||||
}
|
||||
|
||||
class CargoEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CargoEditDialog(QWidget *parent = nullptr);
|
||||
~CargoEditDialog();
|
||||
|
||||
private:
|
||||
Ui::CargoEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // CARGOEDITDIALOG_H
|
||||
98
sea_transport/cargoeditdialog.ui
Normal file
98
sea_transport/cargoeditdialog.ui
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CargoEditDialog</class>
|
||||
<widget class="QDialog" name="CargoEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>318</width>
|
||||
<height>279</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Cargo ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="et_cargo_id">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Quantity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="et_quantity">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Destination:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btn_choose_destination">
|
||||
<property name="text">
|
||||
<string>Choose...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>148</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_discard">
|
||||
<property name="text">
|
||||
<string>Discard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
14
sea_transport/deliverypointeditdialog.cpp
Normal file
14
sea_transport/deliverypointeditdialog.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "deliverypointeditdialog.h"
|
||||
#include "ui_deliverypointeditdialog.h"
|
||||
|
||||
DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DeliveryPointEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
DeliveryPointEditDialog::~DeliveryPointEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
sea_transport/deliverypointeditdialog.h
Normal file
22
sea_transport/deliverypointeditdialog.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef DELIVERYPOINTEDITDIALOG_H
|
||||
#define DELIVERYPOINTEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class DeliveryPointEditDialog;
|
||||
}
|
||||
|
||||
class DeliveryPointEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeliveryPointEditDialog(QWidget *parent = nullptr);
|
||||
~DeliveryPointEditDialog();
|
||||
|
||||
private:
|
||||
Ui::DeliveryPointEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // DELIVERYPOINTEDITDIALOG_H
|
||||
105
sea_transport/deliverypointeditdialog.ui
Normal file
105
sea_transport/deliverypointeditdialog.ui
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DeliveryPointEditDialog</class>
|
||||
<widget class="QDialog" name="DeliveryPointEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>394</width>
|
||||
<height>386</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Delivery point title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="et_title"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="lv_storages"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_storage_add">
|
||||
<property name="text">
|
||||
<string>Add storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_storage_remove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_discard">
|
||||
<property name="text">
|
||||
<string>Discard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
14
sea_transport/entities/IEntity.h
Normal file
14
sea_transport/entities/IEntity.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef IENTITY_H
|
||||
#define IENTITY_H
|
||||
|
||||
#include "ISerializable.h"
|
||||
|
||||
|
||||
typedef unsigned long long entity_id;
|
||||
|
||||
class IEntity : public ISerializable {
|
||||
public:
|
||||
virtual entity_id id() = 0;
|
||||
};
|
||||
|
||||
#endif // IENTITY_H
|
||||
13
sea_transport/entities/ISerializable.h
Normal file
13
sea_transport/entities/ISerializable.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef ISERIALIZABLE_H
|
||||
#define ISERIALIZABLE_H
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
|
||||
class ISerializable {
|
||||
public:
|
||||
virtual void serialize(QDataStream &output) = 0;
|
||||
virtual void deserialize(QDataStream &input) = 0;
|
||||
};
|
||||
|
||||
#endif // ISERIALIZABLE_H
|
||||
29
sea_transport/entities/cargo_entity.cpp
Normal file
29
sea_transport/entities/cargo_entity.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "cargo_entity.h"
|
||||
|
||||
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) {
|
||||
this->_id += bit;
|
||||
}
|
||||
}
|
||||
|
||||
entity_id cargo_entity::id() {
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
QString cargo_entity::title() {
|
||||
return this->_title;
|
||||
}
|
||||
|
||||
unsigned int cargo_entity::volume() {
|
||||
return this->_volume;
|
||||
}
|
||||
|
||||
void cargo_entity::serialize(QDataStream &output) {
|
||||
output << this->_id << this->_title << this->_volume;
|
||||
}
|
||||
|
||||
void cargo_entity::deserialize(QDataStream &input) {
|
||||
input >> this->_id >> this->_title >> this->_volume;
|
||||
}
|
||||
28
sea_transport/entities/cargo_entity.h
Normal file
28
sea_transport/entities/cargo_entity.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef CARGO_ENTITY_H
|
||||
#define CARGO_ENTITY_H
|
||||
|
||||
#include "IEntity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
class cargo_entity : public IEntity {
|
||||
private:
|
||||
entity_id _id;
|
||||
QString _title;
|
||||
unsigned int _volume;
|
||||
|
||||
public:
|
||||
cargo_entity() = default;
|
||||
cargo_entity(const QString &title, unsigned int volume);
|
||||
|
||||
entity_id id();
|
||||
QString title();
|
||||
unsigned int volume();
|
||||
|
||||
void serialize(QDataStream &output);
|
||||
void deserialize(QDataStream &input);
|
||||
};
|
||||
|
||||
#endif // CARGO_ENTITY_H
|
||||
37
sea_transport/entities/dpoint_entity.cpp
Normal file
37
sea_transport/entities/dpoint_entity.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "dpoint_entity.h"
|
||||
|
||||
dpoint_entity::dpoint_entity(const QString &title) : _title(title) {
|
||||
this->_id = 0;
|
||||
auto hash = QCryptographicHash::hash(title.toLocal8Bit(), QCryptographicHash::Md5);
|
||||
for (auto bit : hash) {
|
||||
this->_id += bit;
|
||||
}
|
||||
}
|
||||
|
||||
entity_id dpoint_entity::id() {
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
QString dpoint_entity::title() {
|
||||
return this->_title;
|
||||
}
|
||||
|
||||
const QVector<storage_entity> dpoint_entity::storages() {
|
||||
return this->_storages;
|
||||
}
|
||||
|
||||
void dpoint_entity::serialize(QDataStream &output) {
|
||||
output << this->_id << this->_title << this->_storages.size();
|
||||
for (auto &item : this->_storages) {
|
||||
item.serialize(output);
|
||||
}
|
||||
}
|
||||
|
||||
void dpoint_entity::deserialize(QDataStream &input) {
|
||||
int icnt;
|
||||
input >> this->_id >> this->_title >> icnt;
|
||||
this->_storages.resize(icnt);
|
||||
for (int i = 0; i < icnt; i++) {
|
||||
this->_storages[i].deserialize(input);
|
||||
}
|
||||
}
|
||||
30
sea_transport/entities/dpoint_entity.h
Normal file
30
sea_transport/entities/dpoint_entity.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef DPOINT_ENTITY_H
|
||||
#define DPOINT_ENTITY_H
|
||||
|
||||
#include "IEntity.h"
|
||||
#include "storage_entity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
class dpoint_entity : public IEntity {
|
||||
private:
|
||||
entity_id _id;
|
||||
QString _title;
|
||||
QVector<storage_entity> _storages;
|
||||
|
||||
public:
|
||||
dpoint_entity() = default;
|
||||
dpoint_entity(const QString &title);
|
||||
|
||||
entity_id id();
|
||||
QString title();
|
||||
const QVector<storage_entity> storages();
|
||||
|
||||
void serialize(QDataStream &output);
|
||||
void deserialize(QDataStream &input);
|
||||
};
|
||||
|
||||
#endif // DPOINT_ENTITY_H
|
||||
81
sea_transport/entities/storage_entity.cpp
Normal file
81
sea_transport/entities/storage_entity.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#include "storage_entity.h"
|
||||
|
||||
|
||||
entity_id storage_entity::__global_id = 0;
|
||||
|
||||
storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) {
|
||||
this->_id = ++storage_entity::__global_id;
|
||||
}
|
||||
|
||||
|
||||
entity_id storage_entity::id() {
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
unsigned int storage_entity::capacity() {
|
||||
return this->_capacity;
|
||||
}
|
||||
|
||||
const QVector<cargo_entity> storage_entity::cargo() {
|
||||
return this->_cargo;
|
||||
}
|
||||
|
||||
void storage_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();
|
||||
}
|
||||
}
|
||||
|
||||
cargo_entity storage_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 storage_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 storage_entity::serialize(QDataStream &output) {
|
||||
output << this->_id << this->_capacity << this->_cargo.size();
|
||||
for (auto item : this->_cargo) {
|
||||
item.serialize(output);
|
||||
}
|
||||
}
|
||||
|
||||
void storage_entity::deserialize(QDataStream &input) {
|
||||
int icnt;
|
||||
input >> this->_id >> this->_capacity >> icnt;
|
||||
this->_cargo.resize(icnt);
|
||||
for (int i = 0; i < icnt; i++) {
|
||||
this->_cargo[i].deserialize(input);
|
||||
}
|
||||
}
|
||||
|
||||
void storage_entity::preloadGlobalId(entity_id gid) {
|
||||
storage_entity::__global_id = gid;
|
||||
}
|
||||
|
||||
entity_id storage_entity::GID() {
|
||||
return storage_entity::__global_id;
|
||||
}
|
||||
37
sea_transport/entities/storage_entity.h
Normal file
37
sea_transport/entities/storage_entity.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef STORAGE_ENTITY_H
|
||||
#define STORAGE_ENTITY_H
|
||||
|
||||
#include "IEntity.h"
|
||||
#include "cargo_entity.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
class storage_entity : public IEntity {
|
||||
private:
|
||||
static entity_id __global_id;
|
||||
|
||||
entity_id _id;
|
||||
unsigned int _capacity;
|
||||
QVector<cargo_entity> _cargo;
|
||||
|
||||
public:
|
||||
storage_entity() = default;
|
||||
storage_entity(unsigned int capacity);
|
||||
|
||||
entity_id id();
|
||||
unsigned int capacity();
|
||||
const QVector<cargo_entity> 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);
|
||||
void deserialize(QDataStream &input);
|
||||
static void preloadGlobalId(entity_id gid);
|
||||
static entity_id GID();
|
||||
};
|
||||
|
||||
#endif // STORAGE_ENTITY_H
|
||||
29
sea_transport/entities/user_entity.cpp
Normal file
29
sea_transport/entities/user_entity.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "user_entity.h"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
entity_id user_entity::id() {
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
const QString user_entity::login() {
|
||||
return this->_login;
|
||||
}
|
||||
|
||||
UserRole user_entity::role() {
|
||||
return this->_role;
|
||||
}
|
||||
|
||||
bool user_entity::verify_password(const QString &password) const {
|
||||
return (this->_pwd_hash == QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256));
|
||||
}
|
||||
|
||||
void user_entity::serialize(QDataStream &output) {
|
||||
output << this->_id << this->_login << this->_role << this->_pwd_hash;
|
||||
}
|
||||
|
||||
void user_entity::deserialize(QDataStream &input) {
|
||||
input >> this->_id >> this->_login >> this->_role >> this->_pwd_hash;
|
||||
}
|
||||
35
sea_transport/entities/user_entity.h
Normal file
35
sea_transport/entities/user_entity.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef USER_ENTITY_H
|
||||
#define USER_ENTITY_H
|
||||
|
||||
#include "IEntity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
enum class UserRole {
|
||||
ADMINISTRATOR, DISPATCHER, SKIPPER
|
||||
};
|
||||
|
||||
|
||||
class user_entity : public IEntity {
|
||||
private:
|
||||
entity_id _id;
|
||||
QString _login;
|
||||
UserRole _role;
|
||||
QByteArray _pwd_hash;
|
||||
|
||||
public:
|
||||
user_entity() = default;
|
||||
user_entity(const QString &login, const QString &password, UserRole role);
|
||||
|
||||
entity_id id();
|
||||
const QString login();
|
||||
UserRole role();
|
||||
bool verify_password(const QString &password) const;
|
||||
|
||||
void serialize(QDataStream &output);
|
||||
void deserialize(QDataStream &input);
|
||||
};
|
||||
|
||||
#endif // USER_ENTITY_H
|
||||
52
sea_transport/entities/vessel_entity.cpp
Normal file
52
sea_transport/entities/vessel_entity.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#include "vessel_entity.h"
|
||||
|
||||
|
||||
entity_id vessel_entity::__global_id = 0;
|
||||
|
||||
vessel_entity::vessel_entity(const dpoint_entity &harbor, unsigned int capacity) : _harbor(harbor), _capacity(capacity) {
|
||||
this->_id = ++vessel_entity::__global_id;
|
||||
}
|
||||
|
||||
entity_id vessel_entity::id() {
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
const dpoint_entity vessel_entity::harbor() {
|
||||
return this->_harbor;
|
||||
}
|
||||
|
||||
unsigned int vessel_entity::capacity() {
|
||||
return this->_capacity;
|
||||
}
|
||||
|
||||
const QVector<cargo_entity> vessel_entity::cargo() {
|
||||
return this->_cargo;
|
||||
}
|
||||
|
||||
void vessel_entity::serialize(QDataStream &output) {
|
||||
output << this->_id;
|
||||
this->_harbor.serialize(output);
|
||||
output << this->_capacity << this->_cargo.size();
|
||||
for (auto item : this->_cargo) {
|
||||
item.serialize(output);
|
||||
}
|
||||
}
|
||||
|
||||
void vessel_entity::deserialize(QDataStream &input) {
|
||||
input >> this->_id;
|
||||
this->_harbor.deserialize(input);
|
||||
int icnt;
|
||||
input >> this->_capacity >> icnt;
|
||||
this->_cargo.resize(icnt);
|
||||
for (int i = 0; i < icnt; i++) {
|
||||
this->_cargo[i].deserialize(input);
|
||||
}
|
||||
}
|
||||
|
||||
void vessel_entity::preloadGlobalId(entity_id gid) {
|
||||
vessel_entity::__global_id = gid;
|
||||
}
|
||||
|
||||
entity_id vessel_entity::GID() {
|
||||
return vessel_entity::__global_id;
|
||||
}
|
||||
33
sea_transport/entities/vessel_entity.h
Normal file
33
sea_transport/entities/vessel_entity.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef VESSEL_ENTITY_H
|
||||
#define VESSEL_ENTITY_H
|
||||
|
||||
#include "IEntity.h"
|
||||
#include "cargo_entity.h"
|
||||
#include "dpoint_entity.h"
|
||||
|
||||
|
||||
class vessel_entity : public IEntity {
|
||||
private:
|
||||
static entity_id __global_id;
|
||||
|
||||
entity_id _id;
|
||||
dpoint_entity _harbor;
|
||||
unsigned int _capacity;
|
||||
QVector<cargo_entity> _cargo;
|
||||
|
||||
public:
|
||||
vessel_entity() = default;
|
||||
vessel_entity(const dpoint_entity &harbor, unsigned int capacity);
|
||||
|
||||
entity_id id();
|
||||
const dpoint_entity harbor();
|
||||
unsigned int capacity();
|
||||
const QVector<cargo_entity> cargo();
|
||||
|
||||
void serialize(QDataStream &output);
|
||||
void deserialize(QDataStream &input);
|
||||
static void preloadGlobalId(entity_id gid);
|
||||
static entity_id GID();
|
||||
};
|
||||
|
||||
#endif // VESSEL_ENTITY_H
|
||||
16
sea_transport/generate_puml.ps1
Normal file
16
sea_transport/generate_puml.ps1
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
$pumlFile = "output.puml"
|
||||
if (Test-Path $pumlFile) {
|
||||
Write-Host Found old file. Resolution: delete
|
||||
Remove-Item $pumlFile
|
||||
}
|
||||
|
||||
$cmd = "hpp2plantuml -i *.h"
|
||||
# hpp2plantuml -i *.h -i entities\*.h -o output.puml
|
||||
foreach ($dir in $(Get-ChildItem -Path $Source -Directory -Recurse)) {
|
||||
$cmd += " -i '$($dir.FullName)\*.h'"
|
||||
}
|
||||
|
||||
$cmd += " -o $pumlFile"
|
||||
Invoke-Expression $cmd
|
||||
|
||||
Exit(0)
|
||||
11
sea_transport/main.cpp
Normal file
11
sea_transport/main.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "authwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
AuthWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
57
sea_transport/sea_transport.pro
Normal file
57
sea_transport/sea_transport.pro
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
authwindow.cpp \
|
||||
cargoeditdialog.cpp \
|
||||
deliverypointeditdialog.cpp \
|
||||
entities/cargo_entity.cpp \
|
||||
entities/dpoint_entity.cpp \
|
||||
entities/storage_entity.cpp \
|
||||
entities/user_entity.cpp \
|
||||
entities/vessel_entity.cpp \
|
||||
main.cpp \
|
||||
storageeditdialog.cpp \
|
||||
system/apparatus.cpp \
|
||||
system/auth_system.cpp \
|
||||
system/object_system.cpp \
|
||||
usereditdialog.cpp \
|
||||
vesseleditdialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
authwindow.h \
|
||||
cargoeditdialog.h \
|
||||
deliverypointeditdialog.h \
|
||||
entities/IEntity.h \
|
||||
entities/ISerializable.h \
|
||||
entities/cargo_entity.h \
|
||||
entities/dpoint_entity.h \
|
||||
entities/storage_entity.h \
|
||||
entities/user_entity.h \
|
||||
entities/vessel_entity.h \
|
||||
storageeditdialog.h \
|
||||
system/apparatus.h \
|
||||
system/auth_system.h \
|
||||
system/object_system.h \
|
||||
usereditdialog.h \
|
||||
vesseleditdialog.h
|
||||
|
||||
FORMS += \
|
||||
authwindow.ui \
|
||||
cargoeditdialog.ui \
|
||||
deliverypointeditdialog.ui \
|
||||
storageeditdialog.ui \
|
||||
usereditdialog.ui \
|
||||
vesseleditdialog.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
14
sea_transport/storageeditdialog.cpp
Normal file
14
sea_transport/storageeditdialog.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "storageeditdialog.h"
|
||||
#include "ui_storageeditdialog.h"
|
||||
|
||||
StorageEditDialog::StorageEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::StorageEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
StorageEditDialog::~StorageEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
sea_transport/storageeditdialog.h
Normal file
22
sea_transport/storageeditdialog.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef STORAGEEDITDIALOG_H
|
||||
#define STORAGEEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class StorageEditDialog;
|
||||
}
|
||||
|
||||
class StorageEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StorageEditDialog(QWidget *parent = nullptr);
|
||||
~StorageEditDialog();
|
||||
|
||||
private:
|
||||
Ui::StorageEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // STORAGEEDITDIALOG_H
|
||||
76
sea_transport/storageeditdialog.ui
Normal file
76
sea_transport/storageeditdialog.ui
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>StorageEditDialog</class>
|
||||
<widget class="QDialog" name="StorageEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>190</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Storage num.:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="et_storage_num"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Capacity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="et_capacity"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>72</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_discard">
|
||||
<property name="text">
|
||||
<string>Discard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
106
sea_transport/system/apparatus.cpp
Normal file
106
sea_transport/system/apparatus.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#include "apparatus.h"
|
||||
|
||||
|
||||
apparatus *apparatus::_instance = nullptr;
|
||||
const QString apparatus::filename = "data.bin";
|
||||
|
||||
void apparatus::open_reading_stream() {
|
||||
this->_bin_file = new QFile(apparatus::filename);
|
||||
this->_bin_file->open(QIODevice::ReadOnly);
|
||||
|
||||
stream.setDevice(_bin_file);
|
||||
}
|
||||
|
||||
void apparatus::open_writing_stream() {
|
||||
this->_bin_file = new QFile(apparatus::filename);
|
||||
this->_bin_file->open(QIODevice::WriteOnly);
|
||||
|
||||
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->open_reading_stream();
|
||||
this->loadGIDS();
|
||||
this->deserialize_data();
|
||||
this->close_stream();
|
||||
}
|
||||
|
||||
apparatus::~apparatus() {
|
||||
if (this->_bin_file) {
|
||||
this->_bin_file->flush();
|
||||
this->_bin_file->close();
|
||||
delete this->_bin_file;
|
||||
this->_bin_file = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
apparatus& apparatus::instance() {
|
||||
if (apparatus::_instance == nullptr) {
|
||||
apparatus::init();
|
||||
}
|
||||
|
||||
return *apparatus::_instance;
|
||||
}
|
||||
|
||||
bool apparatus::isFirstRun() {
|
||||
return QFile(apparatus::filename).exists();
|
||||
}
|
||||
|
||||
void apparatus::generate_empty_data() {
|
||||
this->open_writing_stream();
|
||||
this->writeGIDS();
|
||||
this->serialize_data();
|
||||
this->close_stream();
|
||||
}
|
||||
|
||||
const auth_system& apparatus::get_auth_subsystem() {
|
||||
return this->_auth_system;
|
||||
}
|
||||
|
||||
const object_system& apparatus::get_object_subsystem() {
|
||||
return this->_object_system;
|
||||
}
|
||||
|
||||
void apparatus::init() {
|
||||
apparatus::_instance = new apparatus();
|
||||
}
|
||||
|
||||
void apparatus::shutdown() {
|
||||
if (apparatus::_instance != nullptr) {
|
||||
apparatus::_instance->open_writing_stream();
|
||||
apparatus::_instance->writeGIDS();
|
||||
apparatus::_instance->serialize_data();
|
||||
apparatus::_instance->close_stream();
|
||||
}
|
||||
}
|
||||
|
||||
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.init(this->stream);
|
||||
this->_object_system.init(this->stream);
|
||||
}
|
||||
|
||||
void apparatus::deserialize_data() {
|
||||
this->_auth_system.shutdown(this->stream);
|
||||
this->_object_system.shutdown(this->stream);
|
||||
}
|
||||
51
sea_transport/system/apparatus.h
Normal file
51
sea_transport/system/apparatus.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef APPARATUS_H
|
||||
#define APPARATUS_H
|
||||
|
||||
#include "auth_system.h"
|
||||
#include "object_system.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
|
||||
#include <entities/vessel_entity.h>
|
||||
#include <entities/storage_entity.h>
|
||||
|
||||
|
||||
class apparatus
|
||||
{
|
||||
private:
|
||||
static apparatus *_instance;
|
||||
static const QString filename;
|
||||
|
||||
QFile *_bin_file;
|
||||
QDataStream stream;
|
||||
|
||||
auth_system _auth_system;
|
||||
object_system _object_system;
|
||||
|
||||
void open_reading_stream();
|
||||
void open_writing_stream();
|
||||
void close_stream();
|
||||
|
||||
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();
|
||||
|
||||
static apparatus& instance();
|
||||
static void init();
|
||||
static void shutdown();
|
||||
};
|
||||
|
||||
#endif // APPARATUS_H
|
||||
56
sea_transport/system/auth_system.cpp
Normal file
56
sea_transport/system/auth_system.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "auth_system.h"
|
||||
|
||||
|
||||
const user_entity* auth_system::get_user(const QString &login, bool &success) {
|
||||
user_entity *out = nullptr;
|
||||
|
||||
success = false;
|
||||
for (user_entity &item : this->_users) {
|
||||
if (item.login() == login) {
|
||||
success = true;
|
||||
out = &item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool auth_system::remove_user(const QString &login) {
|
||||
auto vit = this->_users.begin();
|
||||
for (; vit != this->_users.end(); vit++) {
|
||||
if ((*vit).login() == login) {
|
||||
this->_users.erase(vit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool auth_system::register_user(const QString &login, const QString &password, UserRole role) {
|
||||
bool exists = false;
|
||||
this->get_user(login, exists);
|
||||
if (!exists) {
|
||||
this->_users.push_back(user_entity(login, password, role));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void auth_system::init(QDataStream &stream) {
|
||||
int icnt;
|
||||
stream >> icnt;
|
||||
this->_users.resize(icnt);
|
||||
for (int i = 0; i < icnt; i++) {
|
||||
this->_users[i].deserialize(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void auth_system::shutdown(QDataStream &stream) {
|
||||
stream << this->_users.size();
|
||||
for (auto &item : this->_users) {
|
||||
item.serialize(stream);
|
||||
}
|
||||
}
|
||||
24
sea_transport/system/auth_system.h
Normal file
24
sea_transport/system/auth_system.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef AUTH_SYSTEM_H
|
||||
#define AUTH_SYSTEM_H
|
||||
|
||||
#include<QVector>
|
||||
|
||||
#include <entities/user_entity.h>
|
||||
|
||||
|
||||
class auth_system
|
||||
{
|
||||
private:
|
||||
QVector<user_entity> _users;
|
||||
public:
|
||||
auth_system() = default;
|
||||
|
||||
const 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);
|
||||
|
||||
void init(QDataStream &stream);
|
||||
void shutdown(QDataStream &stream);
|
||||
};
|
||||
|
||||
#endif // AUTH_SYSTEM_H
|
||||
106
sea_transport/system/object_system.cpp
Normal file
106
sea_transport/system/object_system.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#include "object_system.h"
|
||||
|
||||
|
||||
const dpoint_entity* object_system::get_dpoint(entity_id oid, bool &success) {
|
||||
dpoint_entity *out = nullptr;
|
||||
|
||||
success = false;
|
||||
for (dpoint_entity &item : this->_dpoints) {
|
||||
if (item.id() == oid) {
|
||||
success = true;
|
||||
out = &item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool object_system::remove_dpoint(entity_id oid) {
|
||||
auto vit = this->_dpoints.begin();
|
||||
for (; vit != this->_dpoints.end(); vit++) {
|
||||
if ((*vit).id() == oid) {
|
||||
this->_dpoints.erase(vit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool object_system::add_dpoint(dpoint_entity dpoint) {
|
||||
bool exists = false;
|
||||
this->get_dpoint(dpoint.id(), exists);
|
||||
if (!exists) {
|
||||
this->_dpoints.push_back(dpoint);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const vessel_entity* object_system::get_vessel(entity_id oid, bool &success) {
|
||||
vessel_entity *out = nullptr;
|
||||
|
||||
success = false;
|
||||
for (vessel_entity &item : this->_vessels) {
|
||||
if (item.id() == oid) {
|
||||
success = true;
|
||||
out = &item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool object_system::remove_vessel(entity_id oid) {
|
||||
auto vit = this->_vessels.begin();
|
||||
for (; vit != this->_vessels.end(); vit++) {
|
||||
if ((*vit).id() == oid) {
|
||||
this->_vessels.erase(vit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool object_system::add_vessel(vessel_entity dpoint) {
|
||||
bool exists = false;
|
||||
this->get_dpoint(dpoint.id(), exists);
|
||||
if (!exists) {
|
||||
this->_vessels.push_back(dpoint);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void object_system::init(QDataStream &stream) {
|
||||
int dicnt;
|
||||
stream >> dicnt;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void object_system::shutdown(QDataStream &stream) {
|
||||
stream << this->_dpoints.size();
|
||||
for (auto &item : this->_dpoints) {
|
||||
item.serialize(stream);
|
||||
}
|
||||
|
||||
stream << this->_vessels.size();
|
||||
for (auto &item : this->_vessels) {
|
||||
item.serialize(stream);
|
||||
}
|
||||
}
|
||||
32
sea_transport/system/object_system.h
Normal file
32
sea_transport/system/object_system.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef OBJECT_SYSTEM_H
|
||||
#define OBJECT_SYSTEM_H
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include <entities/dpoint_entity.h>
|
||||
#include <entities/vessel_entity.h>
|
||||
|
||||
|
||||
class object_system
|
||||
{
|
||||
private:
|
||||
QVector<dpoint_entity> _dpoints;
|
||||
QVector<vessel_entity> _vessels;
|
||||
|
||||
public:
|
||||
object_system() = default;
|
||||
|
||||
const 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);
|
||||
bool remove_vessel(entity_id oid);
|
||||
bool add_vessel(vessel_entity dpoint);
|
||||
|
||||
|
||||
void init(QDataStream &stream);
|
||||
void shutdown(QDataStream &stream);
|
||||
};
|
||||
|
||||
#endif // OBJECT_SYSTEM_H
|
||||
14
sea_transport/usereditdialog.cpp
Normal file
14
sea_transport/usereditdialog.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "usereditdialog.h"
|
||||
#include "ui_usereditdialog.h"
|
||||
|
||||
UserEditDialog::UserEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::UserEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
UserEditDialog::~UserEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
sea_transport/usereditdialog.h
Normal file
22
sea_transport/usereditdialog.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef USEREDITDIALOG_H
|
||||
#define USEREDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class UserEditDialog;
|
||||
}
|
||||
|
||||
class UserEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UserEditDialog(QWidget *parent = nullptr);
|
||||
~UserEditDialog();
|
||||
|
||||
private:
|
||||
Ui::UserEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // USEREDITDIALOG_H
|
||||
113
sea_transport/usereditdialog.ui
Normal file
113
sea_transport/usereditdialog.ui
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UserEditDialog</class>
|
||||
<widget class="QDialog" name="UserEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>304</width>
|
||||
<height>270</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Login:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="et_login">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="et_password">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Role:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cb_role">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Administrator</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dispatcher</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Captain</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>138</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_discard">
|
||||
<property name="text">
|
||||
<string>Discard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
14
sea_transport/vesseleditdialog.cpp
Normal file
14
sea_transport/vesseleditdialog.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "vesseleditdialog.h"
|
||||
#include "ui_vesseleditdialog.h"
|
||||
|
||||
VesselEditDialog::VesselEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::VesselEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
VesselEditDialog::~VesselEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
sea_transport/vesseleditdialog.h
Normal file
22
sea_transport/vesseleditdialog.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef VESSELEDITDIALOG_H
|
||||
#define VESSELEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class VesselEditDialog;
|
||||
}
|
||||
|
||||
class VesselEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VesselEditDialog(QWidget *parent = nullptr);
|
||||
~VesselEditDialog();
|
||||
|
||||
private:
|
||||
Ui::VesselEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // VESSELEDITDIALOG_H
|
||||
118
sea_transport/vesseleditdialog.ui
Normal file
118
sea_transport/vesseleditdialog.ui
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>VesselEditDialog</class>
|
||||
<widget class="QDialog" name="VesselEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>361</width>
|
||||
<height>425</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Vessel num.:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="et_vessel_num"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Home port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="btn_choose_home_port">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Max. capacity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="et_max_capacity"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_add_cargo">
|
||||
<property name="text">
|
||||
<string>Add cargo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_discard">
|
||||
<property name="text">
|
||||
<string>Discard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue