Minor system improvements
This commit is contained in:
parent
3e196f3574
commit
9686b96d8a
16 changed files with 144 additions and 86 deletions
|
|
@ -80,6 +80,8 @@ void AdminPanel::on_logout_requested() {
|
||||||
|
|
||||||
void AdminPanel::on_vessel_add_edit(bool /*edit*/) {
|
void AdminPanel::on_vessel_add_edit(bool /*edit*/) {
|
||||||
|
|
||||||
|
|
||||||
|
vvm->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminPanel::on_vessel_remove() {
|
void AdminPanel::on_vessel_remove() {
|
||||||
|
|
@ -99,8 +101,8 @@ void AdminPanel::on_vessel_remove() {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (auto mIdx, selected) {
|
foreach (auto mIdx, selected) {
|
||||||
int idx = mIdx.row();
|
entity_id oid = mIdx.data().toULongLong();
|
||||||
qDebug() << idx << ' ' << mIdx.data() << '\n';
|
apparatus::instance()->get_object_subsystem()->remove_vessel(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
vvm->update();
|
vvm->update();
|
||||||
|
|
@ -210,7 +212,10 @@ void AdminPanel::on_delivery_point_add_edit(bool edit) {
|
||||||
if (edit) {
|
if (edit) {
|
||||||
bool success;
|
bool success;
|
||||||
auto dp = apparatus::instance()->get_object_subsystem()->get_dpoint(dpoint.id(), 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");
|
QMessageBox::critical(this, "Error", "Error editing delivery point");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +224,14 @@ void AdminPanel::on_delivery_point_add_edit(bool edit) {
|
||||||
dp->set_storages(data->storages());
|
dp->set_storages(data->storages());
|
||||||
}
|
}
|
||||||
else {
|
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();
|
dpvm->update();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>500</number>
|
<number>500000</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,7 @@ DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) : QDialog(pare
|
||||||
|
|
||||||
foreach (auto mIdx, sel) {
|
foreach (auto mIdx, sel) {
|
||||||
auto cuid = mIdx.data().toString().toULongLong();
|
auto cuid = mIdx.data().toString().toULongLong();
|
||||||
auto st = this->_dp->storages();
|
this->_dp->remove_storage(cuid);
|
||||||
|
|
||||||
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();
|
this->update_list();
|
||||||
});
|
});
|
||||||
|
|
@ -73,7 +64,6 @@ void DeliveryPointEditDialog::on_storage_edit_add(bool edit) {
|
||||||
if (edit) {
|
if (edit) {
|
||||||
int idx = selected[0].row();
|
int idx = selected[0].row();
|
||||||
stor = this->_dp->storages()[idx];
|
stor = this->_dp->storages()[idx];
|
||||||
this->_dp->remove_storage(stor.id());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageEditDialog sed(this);
|
StorageEditDialog sed(this);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<property name="horizontalSpacing">
|
<property name="horizontalSpacing">
|
||||||
|
|
@ -43,6 +43,12 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Storages IDs</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="lv_storages">
|
<widget class="QListView" name="lv_storages">
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
|
|
@ -81,6 +87,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ cargo_entity::cargo_entity(const QString &title, unsigned int volume) : _title(t
|
||||||
for (auto bit : hash) {
|
for (auto bit : hash) {
|
||||||
this->_id += bit;
|
this->_id += bit;
|
||||||
}
|
}
|
||||||
|
this->_id += QRandomGenerator().generate64();
|
||||||
}
|
}
|
||||||
|
|
||||||
entity_id cargo_entity::id() const {
|
entity_id cargo_entity::id() const {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "IEntity.h"
|
#include "IEntity.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ dpoint_entity::dpoint_entity(entity_id dispatcher_id, const QString &title) : _d
|
||||||
for (auto bit : hash) {
|
for (auto bit : hash) {
|
||||||
this->_id += bit;
|
this->_id += bit;
|
||||||
}
|
}
|
||||||
|
this->_id += QRandomGenerator().generate64();
|
||||||
}
|
}
|
||||||
|
|
||||||
entity_id dpoint_entity::id() const {
|
entity_id dpoint_entity::id() const {
|
||||||
|
|
@ -33,9 +34,20 @@ void dpoint_entity::set_storages(QVector<storage_entity> storages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dpoint_entity::remove_storage(entity_id sid) {
|
void dpoint_entity::remove_storage(entity_id sid) {
|
||||||
std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) {
|
// std::remove_if(this->_storages.begin(), this->_storages.end(), [sid](storage_entity ent) {
|
||||||
return ent.id() == sid;
|
// return ent.id() == sid;
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
QVector<storage_entity> 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) {
|
void dpoint_entity::add_storage(storage_entity ent) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
entity_id storage_entity::__global_id = 0;
|
entity_id storage_entity::__global_id = 0;
|
||||||
|
|
||||||
storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) {
|
storage_entity::storage_entity(unsigned int capacity) : _capacity(capacity) {
|
||||||
this->_id = ++storage_entity::__global_id;
|
this->_id = ++storage_entity::__global_id + QRandomGenerator().generate64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "cargo_entity.h"
|
#include "cargo_entity.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QCryptographicHash>
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
|
|
||||||
class storage_entity : public IEntity {
|
class storage_entity : public IEntity {
|
||||||
|
|
@ -13,7 +13,7 @@ private:
|
||||||
static entity_id __global_id;
|
static entity_id __global_id;
|
||||||
|
|
||||||
entity_id _id;
|
entity_id _id;
|
||||||
unsigned int _capacity;
|
unsigned int _capacity = 500000;
|
||||||
QVector<cargo_entity> _cargo;
|
QVector<cargo_entity> _cargo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) {
|
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);
|
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 {
|
entity_id user_entity::id() const {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "IEntity.h"
|
#include "IEntity.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
entity_id vessel_entity::__global_id = 0;
|
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(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 {
|
entity_id vessel_entity::id() const {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
#include "cargo_entity.h"
|
#include "cargo_entity.h"
|
||||||
#include "dpoint_entity.h"
|
#include "dpoint_entity.h"
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
|
|
||||||
class vessel_entity : public IEntity {
|
class vessel_entity : public IEntity {
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ StorageEditDialog::StorageEditDialog(QWidget *parent) : QDialog(parent), ui(new
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
this->cvm = new CargoViewModel(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);
|
ui->pb_cargo_remove->setEnabled(selected.length() > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->pb_cargo_remove, &QPushButton::clicked, [this]() {
|
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) {
|
if (sel.length() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +44,8 @@ void StorageEditDialog::set_storage(storage_entity *ent, bool edit) {
|
||||||
ui->sb_capacity->setValue(ent->capacity());
|
ui->sb_capacity->setValue(ent->capacity());
|
||||||
this->cvm->set_data(this->_storage->cargo());
|
this->cvm->set_data(this->_storage->cargo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->lab_capacity_current->setText(QString::number(this->_storage->capacity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageEditDialog::on_cargo_add() {
|
void StorageEditDialog::on_cargo_add() {
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Capacity:</string>
|
<string>Capacity (new):</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -29,14 +29,34 @@
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>500</number>
|
<number>500000</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Capacity (current):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="lab_capacity_current">
|
||||||
|
<property name="text">
|
||||||
|
<string>0</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="lv_cargo"/>
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Storage cargo</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tv_cargo"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
|
@ -59,6 +79,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue