Code style refactoring done

This commit is contained in:
Andrew nuark G 2021-01-10 19:49:24 +07:00
parent 02766bd5d2
commit c5f1572efa
36 changed files with 202 additions and 130 deletions

View file

@ -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) {
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) {
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) {
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");
}

View file

@ -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);

View file

@ -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);
}

View file

@ -9,20 +9,20 @@
#include <QMainWindow>
#include <QMessageBox>
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();
};

View file

@ -1,6 +1,7 @@
#include "cargoeditdialog.h"
#include "ui_cargoeditdialog.h"
CargoEditDialog::CargoEditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CargoEditDialog) {
ui->setupUi(this);

View file

@ -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;

View file

@ -2,18 +2,22 @@
#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) {
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]() {
connect(ui->pb_storage_remove, &QPushButton::clicked,
[this]() {
auto sel = ui->lv_storages->selectionModel()->selectedRows();
if (sel.length() == 0) {
return;
@ -24,7 +28,8 @@ DeliveryPointEditDialog::DeliveryPointEditDialog(QWidget *parent) : QDialog(pare
this->_dp->remove_storage(cuid);
}
this->update_list();
});
}
);
connect(ui->pb_storage_edit, &QPushButton::clicked, [this]() {
this->on_storage_edit_add(true);

View file

@ -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

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -12,7 +12,6 @@ enum class UserRole {
ADMINISTRATOR, DISPATCHER, SKIPPER
};
class user_entity : public IEntity {
private:
static entity_id __global_id;

View file

@ -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 {

View file

@ -1,9 +1,9 @@
#include "authwindow.h"
#include "system/apparatus.h"
#include <QApplication>
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();
}
});

View file

@ -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());
}

View file

@ -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();
};

View file

@ -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) {
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();

View file

@ -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;

View file

@ -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;
}

View file

@ -12,8 +12,7 @@
#include <QDataStream>
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();

View file

@ -6,8 +6,7 @@
#include "../entities/user_entity.h"
class auth_system
{
class auth_system {
private:
QVector<user_entity> _users;
public:

View file

@ -7,8 +7,7 @@
#include "../entities/vessel_entity.h"
class object_system
{
class object_system {
private:
QVector<dpoint_entity> _dpoints;
QVector<vessel_entity> _vessels;

View file

@ -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);
}

View file

@ -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;

View file

@ -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) {
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;

View file

@ -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

View file

@ -1,5 +1,6 @@
#include "cargoviewmodel.h"
CargoViewModel::CargoViewModel(QObject *parent) : QAbstractTableModel(parent) {
}

View file

@ -6,7 +6,9 @@
#include "entities/cargo_entity.h"
class CargoViewModel : public QAbstractTableModel {
private:
Q_OBJECT
QVector<cargo_entity> _data;

View file

@ -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:

View file

@ -5,7 +5,9 @@
#include <QAbstractTableModel>
class DeliveryPointsViewModel : public QAbstractTableModel {
private:
Q_OBJECT
public:

View file

@ -1,5 +1,6 @@
#include "usersviewmodel.h"
UsersViewModel::UsersViewModel(QObject *parent) : QAbstractTableModel(parent) {
}

View file

@ -5,7 +5,9 @@
#include <QAbstractTableModel>
class UsersViewModel : public QAbstractTableModel {
private:
Q_OBJECT
public:

View file

@ -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:

View file

@ -5,7 +5,9 @@
#include <QAbstractTableModel>
class VesselsViewModel : public QAbstractTableModel {
private:
Q_OBJECT
public:

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.13.3, 2020-12-30T12:27:51. -->
<!-- Written by QtCreator 4.13.3, 2021-01-10T19:49:10. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -64,7 +64,26 @@
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuemap type="QVariantMap" key="AutoTest.CheckStates">
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:apparatus_check_first_registered_user">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:apparatus_check_first_registration">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:apparatus_check_first_run">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:apparatus_check_not_first_run">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:apparatus_check_null_throws_error">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:apparatus_check_remove_user">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:cargo_entity_serialization_test">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:cleanupTestCase">Unchecked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:dpoint_entity_serialization_test">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:initTestCase">Unchecked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:object_subsystem_check_add_dpoint">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:object_subsystem_check_find_dpoint">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:object_subsystem_check_remove_dpoint">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:st_test">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:storage_entity_serialization_test">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:user_entity_password_verification_test">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:user_entity_serialization_test">Checked</value>
<value type="Qt::CheckState" key="C:/Users/Admin/Documents/repos/sea_transport_project/st_test/tst_st_test.cpp:vessel_entity_serialization_test">Checked</value>
</valuemap>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">

View file

@ -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();
}