commit
aa838bf826
6 changed files with 280 additions and 2 deletions
|
|
@ -61,8 +61,11 @@ void AuthWindow::on_auth_requested() {
|
||||||
((AdminPanel*) w)->set_user(*user);
|
((AdminPanel*) w)->set_user(*user);
|
||||||
}
|
}
|
||||||
else if (user->role() == UserRole::SKIPPER) {
|
else if (user->role() == UserRole::SKIPPER) {
|
||||||
// SkipperPanel(nullptr, user).set_user(user).show();
|
QMessageBox::information(this, "Info", "Please note: if you have more than one vessel assigned to you "
|
||||||
return;
|
"only first will be shown (it is intended by design, you cannot physically control two ships). \n"
|
||||||
|
"Please, ask your local dispatcher/administrator to unassign you from other vessels.");
|
||||||
|
w = new SkipperPanel(nullptr);
|
||||||
|
((SkipperPanel*) w)->set_user(*user);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::critical(this, "Error", "Deserialized user have wrong type. "
|
QMessageBox::critical(this, "Error", "Deserialized user have wrong type. "
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "system/apparatus.h"
|
#include "system/apparatus.h"
|
||||||
|
|
||||||
#include "adminpanel.h"
|
#include "adminpanel.h"
|
||||||
|
#include "skipperpanel.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ SOURCES += \
|
||||||
entities/user_entity.cpp \
|
entities/user_entity.cpp \
|
||||||
entities/vessel_entity.cpp \
|
entities/vessel_entity.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
|
skipperpanel.cpp \
|
||||||
storageeditdialog.cpp \
|
storageeditdialog.cpp \
|
||||||
system/apparatus.cpp \
|
system/apparatus.cpp \
|
||||||
system/auth_system.cpp \
|
system/auth_system.cpp \
|
||||||
|
|
@ -42,6 +43,7 @@ HEADERS += \
|
||||||
entities/storage_entity.h \
|
entities/storage_entity.h \
|
||||||
entities/user_entity.h \
|
entities/user_entity.h \
|
||||||
entities/vessel_entity.h \
|
entities/vessel_entity.h \
|
||||||
|
skipperpanel.h \
|
||||||
storageeditdialog.h \
|
storageeditdialog.h \
|
||||||
system/apparatus.h \
|
system/apparatus.h \
|
||||||
system/auth_system.h \
|
system/auth_system.h \
|
||||||
|
|
@ -58,6 +60,7 @@ FORMS += \
|
||||||
authwindow.ui \
|
authwindow.ui \
|
||||||
cargoeditdialog.ui \
|
cargoeditdialog.ui \
|
||||||
deliverypointeditdialog.ui \
|
deliverypointeditdialog.ui \
|
||||||
|
skipperpanel.ui \
|
||||||
storageeditdialog.ui \
|
storageeditdialog.ui \
|
||||||
usereditdialog.ui \
|
usereditdialog.ui \
|
||||||
vesseleditdialog.ui
|
vesseleditdialog.ui
|
||||||
|
|
|
||||||
78
sea_transport/skipperpanel.cpp
Normal file
78
sea_transport/skipperpanel.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include "skipperpanel.h"
|
||||||
|
#include "ui_skipperpanel.h"
|
||||||
|
|
||||||
|
|
||||||
|
SkipperPanel::SkipperPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::SkipperPanel) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
|
connect(ui->pb_logout, &QPushButton::clicked, this, &SkipperPanel::on_logout_requested);
|
||||||
|
|
||||||
|
cvm = new CargoViewModel(this);
|
||||||
|
ui->tv_cargo->setModel(this->cvm);
|
||||||
|
|
||||||
|
connect(this, &SkipperPanel::user_set, this, &SkipperPanel::on_user_set);
|
||||||
|
}
|
||||||
|
|
||||||
|
SkipperPanel::~SkipperPanel() {
|
||||||
|
delete ui;
|
||||||
|
|
||||||
|
delete cvm;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkipperPanel& SkipperPanel::set_user(const user_entity &user) {
|
||||||
|
this->user = user;
|
||||||
|
ui->lab_user->setText(tr("Hello, **%1**").arg(user.login()));
|
||||||
|
|
||||||
|
emit user_set();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkipperPanel::on_user_set() {
|
||||||
|
UserRole urole = this->user.role();
|
||||||
|
switch (urole) {
|
||||||
|
case UserRole::ADMINISTRATOR:
|
||||||
|
case UserRole::DISPATCHER:
|
||||||
|
QMessageBox::critical(this, "Error", "You shouldn't be here!");
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
case UserRole::SKIPPER:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
vessel_entity vessel;
|
||||||
|
foreach(auto _vessel, apparatus::instance()->get_object_subsystem()->vessels()) {
|
||||||
|
if (_vessel.skipper() == this->user.login()) {
|
||||||
|
success = true;
|
||||||
|
vessel = _vessel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
QMessageBox::critical(this, "Error", "You are not assigned to vessel. \n"
|
||||||
|
"Ask you local dispatcher/administrator to do it. \n"
|
||||||
|
"System will now close.");
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lab_vid->setText(QString::number(vessel.id()));
|
||||||
|
|
||||||
|
bool h_success;
|
||||||
|
auto harbor = apparatus::instance()->get_object_subsystem()->get_dpoint(vessel.harbor(), h_success);
|
||||||
|
ui->lab_harbor->setText(h_success? harbor->title() : "#UNKNOWN#");
|
||||||
|
|
||||||
|
int cap_used = 0;
|
||||||
|
foreach (auto c, vessel.cargo()) {
|
||||||
|
cap_used += c.volume();
|
||||||
|
}
|
||||||
|
ui->lab_capacity->setText(tr("%1/%2/%3").arg(cap_used).arg(vessel.capacity() - cap_used).arg(vessel.capacity()));
|
||||||
|
|
||||||
|
this->cvm->set_data(vessel.cargo());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkipperPanel::on_logout_requested() {
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
42
sea_transport/skipperpanel.h
Normal file
42
sea_transport/skipperpanel.h
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef SKIPPERPANEL_H
|
||||||
|
#define SKIPPERPANEL_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "system/apparatus.h"
|
||||||
|
#include "viewmodels/cargoviewmodel.h"
|
||||||
|
#include "entities/user_entity.h"
|
||||||
|
#include "entities/vessel_entity.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class SkipperPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SkipperPanel : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
user_entity user;
|
||||||
|
|
||||||
|
CargoViewModel *cvm;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SkipperPanel(QWidget *parent = nullptr);
|
||||||
|
~SkipperPanel();
|
||||||
|
|
||||||
|
SkipperPanel& set_user(const user_entity &user);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void user_set();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_user_set();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SkipperPanel *ui;
|
||||||
|
|
||||||
|
void on_logout_requested();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SKIPPERPANEL_H
|
||||||
151
sea_transport/skipperpanel.ui
Normal file
151
sea_transport/skipperpanel.ui
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SkipperPanel</class>
|
||||||
|
<widget class="QMainWindow" name="SkipperPanel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>560</width>
|
||||||
|
<height>337</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="pb_logout">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Logout</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="lab_user">
|
||||||
|
<property name="text">
|
||||||
|
<string>Hello, %1</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::MarkdownText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Vessel info</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>VID:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="lab_vid">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="3">
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Capacity (used/left/max):</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLabel" name="lab_capacity">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="3">
|
||||||
|
<widget class="Line" name="line_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Harbor:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="lab_harbor">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Vessel cargo</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tv_cargo">
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue