Parameter compone.
More...
Parameter compone.
- Write a parameter compone
- Defined the parameter compone class. eg: CParameterUser
- Add the parameter compone UI is derived from CParameterUI . eg: CParameterUserUI . and add the follow functions:
- int SetParameter(CParameter* pParameter);
- int Accept(bool validity = false);
- Use a parameter compone
- Instance the parameter compone class. eg: CParameterNet
It contains user and password It only valid in plugin.
, m_nPort(0)
, m_User(this)
, m_szPrompt(tr("The host is empty. please set it"))
{}
the parameters of connecter interface.
CParameterNet(CParameterConnecter *parent, const QString &szPrefix=QString())
[Constructor]
- Call SetParameter and slotAccept
- CParameterNetUI::SetParameter call CParameterUserUI::SetParameter
{
if(!pParameter) return -1;
m_pNet = qobject_cast<CParameterNet*>(pParameter);
ui->leHost->setText(m_pNet->GetHost());
ui->spPort->setValue(m_pNet->GetPort());
ui->wUser->SetParameter(&m_pNet->
m_User);
return 0;
}
int SetParameter(CParameter *pParameter)
[Parameter commone functions]
CParameterUser m_User
[Instance user]
- Check parameter validity: CParameterNetUI::CheckValidity
{
if(validity && ui->leHost->text().isEmpty()) {
QMessageBox::critical(this, tr("Error"),
m_pNet->GetPrompt());
qCritical(log) << "The host is empty" << m_pNet->GetPrompt();
ui->leHost->setFocus();
return false;
}
return true;
}
bool CheckValidity(bool validity=false)
[Set Parameter]
- CParameterNetUI::Accept call CParameterUserUI::Accept
{
int nRet = 0;
m_pNet->SetHost(ui->leHost->text());
m_pNet->SetPort(ui->spPort->value());
ui->wUser->Accept();
return nRet;
}
int Accept()
Accept parameters.