Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterNet.cpp
1#include "ParameterNet.h"
2#include "RabbitCommonTools.h"
3
5CParameterNet::CParameterNet(CParameterConnecter* parent, const QString &szPrefix)
6 : CParameterConnecter(parent, szPrefix)
7 , m_nPort(0)
8 , m_User(this)
9 , m_szPrompt(tr("The host is empty. please set it"))
10{}
12
13int CParameterNet::OnLoad(QSettings &set)
14{
15 set.beginGroup("Net");
16 SetHost(set.value("Host", GetHost()).toString());
17 SetPort(set.value("Port", GetPort()).toUInt());
18 set.endGroup();
19 return 0;
20}
21
22int CParameterNet::OnSave(QSettings &set)
23{
24 set.beginGroup("Net");
25 set.setValue("Host", GetHost());
26 set.setValue("Port", GetPort());
27 set.endGroup();
28 return 0;
29}
30
31const QString CParameterNet::GetHost() const
32{
33 return m_szHost;
34}
35
36void CParameterNet::SetHost(const QString& host)
37{
38 if (m_szHost == host)
39 return;
40 m_szHost = host;
41 SetModified(true);
42 emit sigHostChanged(m_szHost);
43}
44
45const quint16 CParameterNet::GetPort() const
46{
47 return m_nPort;
48}
49
50void CParameterNet::SetPort(quint16 port)
51{
52 if(m_nPort == port)
53 return;
54 m_nPort = port;
55 SetModified(true);
56}
57
58int CParameterNet::SetPrompt(const QString szPrompt)
59{
60 m_szPrompt = szPrompt;
61 return 0;
62}
63
64QString CParameterNet::GetPrompt()
65{
66 return m_szPrompt;
67}
the parameters of connecter interface.
virtual int OnLoad(QSettings &set) override
[Instance user]
CParameterNet(CParameterConnecter *parent, const QString &szPrefix=QString())
[Constructor]
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.