From a125b0298425809c94a661342baeaba476db77f7 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 17 Jan 2016 00:34:54 +0100 Subject: [PATCH] refs #573, added exclude/include combo box in UI * access to user, only admin may edit include/exclude * updated UI --- src/blackgui/editors/form.cpp | 10 +++++++++ src/blackgui/editors/form.h | 10 +++++++++ src/blackgui/editors/modelmappingform.cpp | 20 +++++++++++++++++ src/blackgui/editors/modelmappingform.h | 4 ++++ src/blackgui/editors/modelmappingform.ui | 26 ++++++++++++++++++++++- 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/blackgui/editors/form.cpp b/src/blackgui/editors/form.cpp index bf3ebc8dd..2699b9dbd 100644 --- a/src/blackgui/editors/form.cpp +++ b/src/blackgui/editors/form.cpp @@ -19,5 +19,15 @@ namespace BlackGui CForm::~CForm() { } + const BlackMisc::Network::CAuthenticatedUser &CForm::getUser() const + { + return this->m_user.get(); + } + + void CForm::ps_userChanged() + { + // void + } + } // ns } // ns diff --git a/src/blackgui/editors/form.h b/src/blackgui/editors/form.h index c17d0907f..f76f8936e 100644 --- a/src/blackgui/editors/form.h +++ b/src/blackgui/editors/form.h @@ -12,6 +12,8 @@ #ifndef BLACKGUI_EDITORS_FORM_H #define BLACKGUI_EDITORS_FORM_H +#include "blackmisc/network/authenticateduser.h" +#include "blackcore/data/authenticateduser.h" #include namespace BlackGui @@ -42,8 +44,16 @@ namespace BlackGui //! Is read only? bool isReadOnly() const { return m_readOnly; } + //! Authenticated user + const BlackMisc::Network::CAuthenticatedUser &getUser() const; + protected: bool m_readOnly = false; //!< read only + BlackMisc::CData m_user {this, &CForm::ps_userChanged}; //!< authenticated user + + protected slots: + //! User has been changed + virtual void ps_userChanged(); }; } // ns diff --git a/src/blackgui/editors/modelmappingform.cpp b/src/blackgui/editors/modelmappingform.cpp index ac3281450..54a9180f6 100644 --- a/src/blackgui/editors/modelmappingform.cpp +++ b/src/blackgui/editors/modelmappingform.cpp @@ -11,6 +11,7 @@ #include "ui_modelmappingform.h" using namespace BlackMisc; +using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; namespace BlackGui @@ -26,6 +27,8 @@ namespace BlackGui ui->le_Id->setReadOnly(true); ui->lai_Id->set(CIcons::appMappings16(), "Id:"); connect(ui->pb_Stash, &QPushButton::clicked, this, &CModelMappingForm::requestStash); + + this->ps_userChanged(); } CModelMappingForm::~CModelMappingForm() @@ -38,6 +41,7 @@ namespace BlackGui model.setDescription(this->ui->le_Description->text()); model.setModelString(this->ui->le_ModelKey->text()); model.setName(this->ui->le_Name->text()); + model.setModelModeAsString(this->ui->cb_Include->currentText()); return model; } @@ -68,8 +72,24 @@ namespace BlackGui ui->le_Id->setText(model.getDbKeyAsString()); ui->le_Description->setText(model.getDescription()); ui->le_Name->setText(model.getName()); + ui->cb_Include->setCurrentText(model.getModelModeAsString()); ui->selector_Simulator->setValue(model.getSimulatorInfo()); m_originalModel = model; } + + void CModelMappingForm::ps_userChanged() + { + const CAuthenticatedUser user(this->getUser()); + if (user.isAdmin()) + { + ui->cb_Include->setEnabled(true); + } + else + { + ui->cb_Include->setEnabled(false); + } + + CForm::ps_userChanged(); + } } // ns } // ns diff --git a/src/blackgui/editors/modelmappingform.h b/src/blackgui/editors/modelmappingform.h index 366a0bc08..48eec4c0b 100644 --- a/src/blackgui/editors/modelmappingform.h +++ b/src/blackgui/editors/modelmappingform.h @@ -59,6 +59,10 @@ namespace BlackGui //! Request stashing for model void requestStash(); + protected slots: + //! User has been changed + virtual void ps_userChanged() override; + private: QScopedPointer ui; BlackMisc::Simulation::CAircraftModel m_originalModel; diff --git a/src/blackgui/editors/modelmappingform.ui b/src/blackgui/editors/modelmappingform.ui index c45052450..de30f2595 100644 --- a/src/blackgui/editors/modelmappingform.ui +++ b/src/blackgui/editors/modelmappingform.ui @@ -161,6 +161,28 @@ + + + + + Include + + + + :/diagona/icons/diagona/icons/paper-plane--plus.png:/diagona/icons/diagona/icons/paper-plane--plus.png + + + + + Exclude + + + + :/diagona/icons/diagona/icons/paper-plane--minus.png:/diagona/icons/diagona/icons/paper-plane--minus.png + + + + @@ -194,6 +216,8 @@ pb_Stash le_LastUpdated - + + +