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

@@ -0,0 +1,102 @@
/* Copyright (C) 2014
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "blackgui/editors/serverform.h"
#include "blackmisc/network/user.h"
#include "ui_serverform.h"
#include <QIntValidator>
#include <QLabel>
#include <QLineEdit>
using namespace BlackMisc::Network;
namespace BlackGui
{
namespace Editors
{
CServerForm::CServerForm(QWidget *parent) :
CForm(parent),
ui(new Ui::CNetworkServerForm)
{
ui->setupUi(this);
this->ui->le_Port->setValidator(new QIntValidator(1, 65535, this));
}
CServerForm::~CServerForm()
{ }
void CServerForm::setServer(const CServer &server)
{
CUser user = server.getUser();
this->ui->le_NetworkId->setText(user.getId());
this->ui->le_RealName->setText(user.getRealName());
this->ui->le_Name->setText(server.getName());
this->ui->le_Password->setText(user.getPassword());
this->ui->le_Description->setText(server.getDescription());
this->ui->le_Address->setText(server.getAddress());
this->ui->le_Port->setText(QString::number(server.getPort()));
this->ui->form_ServerFsd->setValue(server.getFsdSetup());
}
BlackMisc::Network::CServer CServerForm::getServer() const
{
CUser user(
this->ui->le_NetworkId->text().trimmed(),
this->ui->le_RealName->text().trimmed().simplified(),
"",
this->ui->le_Password->text().trimmed()
);
CServer server(
this->ui->le_Name->text().trimmed().simplified(),
this->ui->le_Description->text().trimmed().simplified(),
this->ui->le_Address->text().trimmed(),
this->ui->le_Port->text().trimmed().toInt(),
user
);
CFsdSetup setup(this->ui->form_ServerFsd->getValue());
server.setFsdSetup(setup);
return server;
}
void CServerForm::setReadOnly(bool readOnly)
{
this->ui->le_NetworkId->setReadOnly(readOnly);
this->ui->le_RealName->setReadOnly(readOnly);
this->ui->le_Name->setReadOnly(readOnly);
this->ui->le_Description->setReadOnly(readOnly);
this->ui->le_Address->setReadOnly(readOnly);
this->ui->le_Port->setReadOnly(readOnly);
this->ui->le_Password->setReadOnly(readOnly);
this->ui->form_ServerFsd->setReadOnly(readOnly);
}
void CServerForm::showPasswordField(bool show)
{
if (this->ui->le_Password->isVisible() == show) { return; }
if (m_passwordNameLabel.isEmpty()) { m_passwordNameLabel = ui->lbl_IdPassword->text(); }
if (show)
{
ui->lbl_IdPassword->setText(m_passwordNameLabel);
}
else
{
ui->lbl_IdPassword->setText("Id");
}
this->ui->le_Password->setVisible(show);
}
BlackMisc::CStatusMessageList CServerForm::validate(bool nested) const
{
Q_UNUSED(nested);
const CServer server = getServer();
return server.validate();
}
} // ns
} // ns