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*/) {
|
||||
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>500</number>
|
||||
<number>500000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="horizontalSpacing">
|
||||
|
|
@ -44,43 +44,52 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="lv_storages">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Storages IDs</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="lv_storages">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_storage_add">
|
||||
<property name="text">
|
||||
<string>Add storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_storage_edit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_storage_remove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_storage_add">
|
||||
<property name="text">
|
||||
<string>Add storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_storage_edit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit storage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_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">
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "IEntity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QRandomGenerator>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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<storage_entity> 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<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) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QRandomGenerator>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "cargo_entity.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QCryptographicHash>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
|
||||
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_entity> _cargo;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "IEntity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QRandomGenerator>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include "cargo_entity.h"
|
||||
#include "dpoint_entity.h"
|
||||
|
||||
#include <QRandomGenerator>
|
||||
|
||||
|
||||
class vessel_entity : public IEntity {
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@
|
|||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Capacity:</string>
|
||||
<string>Capacity (new):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -29,35 +29,58 @@
|
|||
<number>1</number>
|
||||
</property>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="lv_cargo"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_cargo_add">
|
||||
<property name="text">
|
||||
<string>Add cargo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_cargo_remove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove cargo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_cargo_add">
|
||||
<property name="text">
|
||||
<string>Add cargo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_cargo_remove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove cargo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue