refs #681, adjusted form classes

* made server form a CForm, not a component
* adjusted other forms
This commit is contained in:
Klaus Basan
2016-06-26 20:04:17 +02:00
parent 2d00ff42fe
commit 75a7ca382c
15 changed files with 279 additions and 264 deletions

View File

@@ -16,7 +16,7 @@
#include "blackcore/network.h" #include "blackcore/network.h"
#include "blackcore/simulator.h" #include "blackcore/simulator.h"
#include "blackgui/components/logincomponent.h" #include "blackgui/components/logincomponent.h"
#include "blackgui/components/serverform.h" #include "blackgui/editors/serverform.h"
#include "blackgui/components/serverlistselector.h" #include "blackgui/components/serverlistselector.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackgui/loginmodebuttons.h" #include "blackgui/loginmodebuttons.h"

View File

@@ -501,7 +501,7 @@
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
<widget class="BlackGui::Components::CServerForm" name="frp_CurrentServer"> <widget class="BlackGui::Editors::CServerForm" name="frp_CurrentServer">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
@@ -572,9 +572,9 @@
<header>blackgui/components/serverlistselector.h</header> <header>blackgui/components/serverlistselector.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>BlackGui::Components::CServerForm</class> <class>BlackGui::Editors::CServerForm</class>
<extends>QFrame</extends> <extends>QFrame</extends>
<header>blackgui/components/serverform.h</header> <header>blackgui/editors/serverform.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>

View File

@@ -1,209 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CNetworkServerForm</class>
<widget class="QFrame" name="CNetworkServerForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>347</width>
<height>126</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_NetworkServerForm">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gl_ServerForm">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Address">
<property name="text">
<string>Addr./ port:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_RealName">
<property name="text">
<string>Real name:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Description">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="le_Name">
<property name="placeholderText">
<string>server name</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="le_Description">
<property name="placeholderText">
<string>server description</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="le_RealName">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>your name if required</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_IdPassword">
<property name="text">
<string>Id/Password:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_Address">
<property name="placeholderText">
<string>e.g. &quot;server.foo.com&quot;</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QWidget" name="wi_NanePassword" native="true">
<layout class="QHBoxLayout" name="hl_NamePassword">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="le_NetworkId">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>id</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_Password">
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>32</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>password</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="le_Port">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>6809</string>
</property>
<property name="maxLength">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>le_Name</tabstop>
<tabstop>le_Description</tabstop>
<tabstop>le_Address</tabstop>
<tabstop>le_Port</tabstop>
<tabstop>le_RealName</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -126,8 +126,9 @@ namespace BlackGui
return icao; return icao;
} }
CStatusMessageList CAircraftIcaoForm::validate() const CStatusMessageList CAircraftIcaoForm::validate(bool nested) const
{ {
Q_UNUSED(nested);
CAircraftIcaoCode code(getValue()); CAircraftIcaoCode code(getValue());
CStatusMessageList msgs(code.validate()); CStatusMessageList msgs(code.validate());
this->ui->val_Indicator->setState(msgs); this->ui->val_Indicator->setState(msgs);

View File

@@ -47,20 +47,18 @@ namespace BlackGui
//! Get value //! Get value
BlackMisc::Aviation::CAircraftIcaoCode getValue() const; BlackMisc::Aviation::CAircraftIcaoCode getValue() const;
//! Validate, empty list means OK
BlackMisc::CStatusMessageList validate() const;
//! Allow to drop //! Allow to drop
void allowDrop(bool allowDrop); void allowDrop(bool allowDrop);
//! Is drop allowed? //! Is drop allowed?
bool isDropAllowed() const; bool isDropAllowed() const;
//! \copydoc CForm::setReadOnly //! \name Form class implementations
virtual void setReadOnly(bool readOnly) override; //! @{
virtual void setReadOnly(bool readonly) override;
//! \copydoc CForm::setSelectOnly
virtual void setSelectOnly() override; virtual void setSelectOnly() override;
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
//! @}
//! Clear //! Clear
void clear(); void clear();

View File

@@ -87,8 +87,9 @@ namespace BlackGui
return code; return code;
} }
CStatusMessageList CAirlineIcaoForm::validate() const CStatusMessageList CAirlineIcaoForm::validate(bool nested) const
{ {
Q_UNUSED(nested);
CAirlineIcaoCode code(getValue()); CAirlineIcaoCode code(getValue());
CStatusMessageList msgs(code.validate()); CStatusMessageList msgs(code.validate());
if (this->isReadOnly()) if (this->isReadOnly())

View File

@@ -50,20 +50,18 @@ namespace BlackGui
//! Get value //! Get value
BlackMisc::Aviation::CAirlineIcaoCode getValue() const; BlackMisc::Aviation::CAirlineIcaoCode getValue() const;
//! Validate, empty list means OK
BlackMisc::CStatusMessageList validate() const;
//! Allow to drop //! Allow to drop
void allowDrop(bool allowDrop); void allowDrop(bool allowDrop);
//! Is drop allowed? //! Is drop allowed?
bool isDropAllowed() const; bool isDropAllowed() const;
//! \copydoc CForm::setReadOnly //! \name Form class implementations
virtual void setReadOnly(bool readOnly) override; //! @{
virtual void setReadOnly(bool readonly) override;
//! \copydoc CForm::setSelectOnly
virtual void setSelectOnly() override; virtual void setSelectOnly() override;
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
//! @}
//! Clear //! Clear
void clear(); void clear();

View File

@@ -70,8 +70,9 @@ namespace BlackGui
return distributor; return distributor;
} }
CStatusMessageList CDistributorForm::validate() const CStatusMessageList CDistributorForm::validate(bool nested) const
{ {
Q_UNUSED(nested);
CDistributor distributor(getValue()); CDistributor distributor(getValue());
CStatusMessageList msgs(distributor.validate()); CStatusMessageList msgs(distributor.validate());
if (this->isReadOnly()) if (this->isReadOnly())

View File

@@ -46,20 +46,18 @@ namespace BlackGui
//! Get value //! Get value
BlackMisc::Simulation::CDistributor getValue() const; BlackMisc::Simulation::CDistributor getValue() const;
//! Validate, empty list means OK
BlackMisc::CStatusMessageList validate() const;
//! Allow to drop //! Allow to drop
void allowDrop(bool allowDrop); void allowDrop(bool allowDrop);
//! Is drop allowed? //! Is drop allowed?
bool isDropAllowed() const; bool isDropAllowed() const;
//! \copydoc CForm::setReadOnly //! \name Form class implementations
virtual void setReadOnly(bool readOnly) override; //! @{
virtual void setReadOnly(bool readonly) override;
//! \copydoc CForm::setSelectOnly
virtual void setSelectOnly() override; virtual void setSelectOnly() override;
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
//! @}
//! Clear //! Clear
void clear(); void clear();

View File

@@ -33,8 +33,7 @@ namespace BlackGui
/*! /*!
* Livery form class * Livery form class
*/ */
class BLACKGUI_EXPORT CLiveryForm : class BLACKGUI_EXPORT CLiveryForm : public CForm
public CForm
{ {
Q_OBJECT Q_OBJECT
@@ -51,9 +50,6 @@ namespace BlackGui
//! Embedded ariline //! Embedded ariline
BlackMisc::Aviation::CAirlineIcaoCode getValueAirlineIcao() const; BlackMisc::Aviation::CAirlineIcaoCode getValueAirlineIcao() const;
//! Validate, empty list means OK
BlackMisc::CStatusMessageList validate(bool withNestedForms) const;
//! Validate airline ICAO code only //! Validate airline ICAO code only
BlackMisc::CStatusMessageList validateAirlineIcao() const; BlackMisc::CStatusMessageList validateAirlineIcao() const;
@@ -63,11 +59,12 @@ namespace BlackGui
//! Is drop allowed? //! Is drop allowed?
bool isDropAllowed() const; bool isDropAllowed() const;
//! \copydoc CForm::setReadOnly //! \name Form class implementations
virtual void setReadOnly(bool readOnly) override; //! @{
virtual void setReadOnly(bool readonly) override;
//! \copydoc CForm::setSelectOnly
virtual void setSelectOnly() override; virtual void setSelectOnly() override;
virtual BlackMisc::CStatusMessageList validate(bool withNestedForms) const override;
//! @}
//! Clear data //! Clear data
void clear(); void clear();

View File

@@ -46,13 +46,13 @@ namespace BlackGui
BlackMisc::Simulation::CAircraftModel getValue() const; BlackMisc::Simulation::CAircraftModel getValue() const;
//! Validate //! Validate
BlackMisc::CStatusMessageList validate(bool withNestedObjects) const;
//! \copydoc CForm::setReadOnly //! \name Form class implementations
virtual void setReadOnly(bool readOnly) override; //! @{
virtual void setReadOnly(bool readonly) override;
//! \copydoc CForm::setSelectOnly
virtual void setSelectOnly() override; virtual void setSelectOnly() override;
virtual BlackMisc::CStatusMessageList validate(bool withNestedObjects) const override;
//! @}
public slots: public slots:
//! Set model //! Set model

View File

@@ -68,7 +68,6 @@ namespace BlackGui
//! \name Form functions, here not used //! \name Form functions, here not used
//! \@{ //! \@{
virtual void setReadOnly(bool readOnly) override { Q_UNUSED(readOnly); } virtual void setReadOnly(bool readOnly) override { Q_UNUSED(readOnly); }
virtual void setSelectOnly() override {}
//! \@} //! \@}
signals: signals:

View File

@@ -7,7 +7,7 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackgui/components/serverform.h" #include "blackgui/editors/serverform.h"
#include "blackmisc/network/user.h" #include "blackmisc/network/user.h"
#include "ui_serverform.h" #include "ui_serverform.h"
@@ -19,10 +19,10 @@ using namespace BlackMisc::Network;
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Editors
{ {
CServerForm::CServerForm(QWidget *parent) : CServerForm::CServerForm(QWidget *parent) :
QFrame(parent), CForm(parent),
ui(new Ui::CNetworkServerForm) ui(new Ui::CNetworkServerForm)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -42,6 +42,7 @@ namespace BlackGui
this->ui->le_Description->setText(server.getDescription()); this->ui->le_Description->setText(server.getDescription());
this->ui->le_Address->setText(server.getAddress()); this->ui->le_Address->setText(server.getAddress());
this->ui->le_Port->setText(QString::number(server.getPort())); this->ui->le_Port->setText(QString::number(server.getPort()));
this->ui->form_ServerFsd->setValue(server.getFsdSetup());
} }
BlackMisc::Network::CServer CServerForm::getServer() const BlackMisc::Network::CServer CServerForm::getServer() const
@@ -59,6 +60,8 @@ namespace BlackGui
this->ui->le_Port->text().trimmed().toInt(), this->ui->le_Port->text().trimmed().toInt(),
user user
); );
CFsdSetup setup(this->ui->form_ServerFsd->getValue());
server.setFsdSetup(setup);
return server; return server;
} }
@@ -71,6 +74,7 @@ namespace BlackGui
this->ui->le_Address->setReadOnly(readOnly); this->ui->le_Address->setReadOnly(readOnly);
this->ui->le_Port->setReadOnly(readOnly); this->ui->le_Port->setReadOnly(readOnly);
this->ui->le_Password->setReadOnly(readOnly); this->ui->le_Password->setReadOnly(readOnly);
this->ui->form_ServerFsd->setReadOnly(readOnly);
} }
void CServerForm::showPasswordField(bool show) void CServerForm::showPasswordField(bool show)
@@ -88,9 +92,10 @@ namespace BlackGui
this->ui->le_Password->setVisible(show); this->ui->le_Password->setVisible(show);
} }
BlackMisc::CStatusMessageList CServerForm::validate() const BlackMisc::CStatusMessageList CServerForm::validate(bool nested) const
{ {
CServer server = getServer(); Q_UNUSED(nested);
const CServer server = getServer();
return server.validate(); return server.validate();
} }
} // ns } // ns

View File

@@ -13,6 +13,7 @@
#define BLACKGUI_COMPONENTS_NETWORKSERVERFORM_H #define BLACKGUI_COMPONENTS_NETWORKSERVERFORM_H
#include "blackgui/blackguiexport.h" #include "blackgui/blackguiexport.h"
#include "blackgui/editors/form.h"
#include "blackmisc/network/server.h" #include "blackmisc/network/server.h"
#include "blackmisc/statusmessagelist.h" #include "blackmisc/statusmessagelist.h"
@@ -27,10 +28,10 @@ namespace Ui { class CNetworkServerForm; }
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Editors
{ {
//! Server form //! Server form
class BLACKGUI_EXPORT CServerForm : public QFrame class BLACKGUI_EXPORT CServerForm : public CForm
{ {
Q_OBJECT Q_OBJECT
@@ -47,15 +48,15 @@ namespace BlackGui
//! Get server //! Get server
BlackMisc::Network::CServer getServer() const; BlackMisc::Network::CServer getServer() const;
//! Set read only //! \name Form class implementations
void setReadOnly(bool readOnly); //! @{
virtual void setReadOnly(bool readonly) override;
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
//! @}
//! Show the password field //! Show the password field
void showPasswordField(bool show); void showPasswordField(bool show);
//! Validate and provide messages (empty means OK)
BlackMisc::CStatusMessageList validate() const;
private: private:
QScopedPointer<Ui::CNetworkServerForm> ui; QScopedPointer<Ui::CNetworkServerForm> ui;
QString m_passwordNameLabel; QString m_passwordNameLabel;

View File

@@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CNetworkServerForm</class>
<widget class="QFrame" name="CNetworkServerForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>171</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_NetworkServerForm">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tw_ServerForm">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_ServerGeneral">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="vl_ServerGeneral">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QFrame" name="fr_ServerGeneral">
<layout class="QGridLayout" name="gl_ServerForm">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="2" column="1">
<widget class="QLineEdit" name="le_Address">
<property name="placeholderText">
<string>e.g. &quot;server.foo.com&quot;</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="le_Description">
<property name="placeholderText">
<string>server description</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="le_RealName">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>your name if required</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="le_Port">
<property name="text">
<string>6809</string>
</property>
<property name="maxLength">
<number>5</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_RealName">
<property name="text">
<string>Real name:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Address">
<property name="text">
<string>Addr./ port:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Description">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="le_Name">
<property name="placeholderText">
<string>server name</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_IdPassword">
<property name="text">
<string>Id/Password:</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="le_Password">
<property name="maxLength">
<number>32</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>password</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="le_NetworkId">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>id</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_ServerFsd">
<attribute name="title">
<string>FSD</string>
</attribute>
<layout class="QVBoxLayout" name="vl_ServerFsd">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="BlackGui::Editors::CFsdSetupForm" name="form_ServerFsd">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Editors::CFsdSetupForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/fsdsetupform.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>