Some fixes

This commit is contained in:
Andrew nuark G 2020-12-27 20:31:05 +07:00
parent 05ac14f748
commit 4aeb0d5722
3 changed files with 9 additions and 3 deletions

View file

@ -61,8 +61,11 @@ void AuthWindow::on_auth_requested() {
((AdminPanel*) w)->set_user(*user);
}
else if (user->role() == UserRole::SKIPPER) {
// SkipperPanel(nullptr, user).set_user(user).show();
return;
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.");
w = new SkipperPanel(nullptr);
((SkipperPanel*) w)->set_user(*user);
}
else {
QMessageBox::critical(this, "Error", "Deserialized user have wrong type. "

View file

@ -4,6 +4,7 @@
#include "system/apparatus.h"
#include "adminpanel.h"
#include "skipperpanel.h"
#include <QMainWindow>
#include <QMessageBox>

View file

@ -10,6 +10,8 @@ SkipperPanel::SkipperPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::Sk
cvm = new CargoViewModel(this);
ui->tv_cargo->setModel(this->cvm);
connect(this, &SkipperPanel::user_set, this, &SkipperPanel::on_user_set);
}
SkipperPanel::~SkipperPanel() {
@ -66,7 +68,7 @@ void SkipperPanel::on_user_set() {
foreach (auto c, vessel.cargo()) {
cap_used += c.volume();
}
ui->lab_capacity->setText(tr("%1/%2/%3").arg(cap_used, vessel.capacity(), vessel.capacity() + cap_used));
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());
}