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) {
ui->pb_users_remove->setEnabled(selected.length() > 0);
ui->pb_users_edit->setEnabled(selected.length() == 1);
});
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) {
ui->pb_vessels_remove->setEnabled(selected.length() > 0);
ui->pb_vessels_edit->setEnabled(selected.length() == 1);
});
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) {
ui->pb_dp_remove->setEnabled(selected.length() > 0);
ui->pb_dp_edit->setEnabled(selected.length() == 1);
});
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");
}