summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/PPPIPedit.cpp
blob: ef1b7c0cb4d40e820e53e06c0f668064662d29a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <qmessagebox.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <GUIUtils.h>
#include "PPPIPedit.h"

PPPIPEdit::PPPIPEdit( QWidget * Parent ) : PPPIPGUI( Parent ){
}

QString PPPIPEdit::acceptable( void ) {
    if( GWFixed_RB->isChecked() ) {
      if( GWAddress_LE->text().isEmpty() )
        return tr("Gateway address needed" );
      if( ! validIP( GWAddress_LE->text() ) )
        return tr("Gateway address not valid" );
    };

    return QString();
}

bool PPPIPEdit::commit( PPPData & D ) {

      bool SM = 0;

      CBM( D.IP.LocalOverrule, ServerOverrulesLocal_CB, SM );
      CBM( D.IP.RemoteOverrule, ServerOverrulesRemote_CB, SM );

      TXTM( D.IP.LocalAddress, LocalAddress_LE, SM );
      TXTM( D.IP.RemoteAddress, RemoteAddress_LE, SM );

      CBM( D.IP.GWAutomatic, GWServerAssigned_RB, SM );

      if( ! D.IP.GWAutomatic ) {
        TXTM( D.IP.GWAddress, GWAddress_LE, SM );
      }

      CBM( D.IP.GWIsDefault, GWIsDefault_CB, SM );
      CBM( D.IP.GWIfNotSet, GWIfNotSet_CB, SM );

      return SM;
}

void PPPIPEdit::showData( PPPData & D ) {
      ServerOverrulesLocal_CB->setChecked( D.IP.LocalOverrule );
      ServerOverrulesRemote_CB->setChecked( D.IP.RemoteOverrule );
      LocalAddress_LE->setText( D.IP.LocalAddress );
      RemoteAddress_LE->setText( D.IP.RemoteAddress );

      GWServerAssigned_RB->setChecked( D.IP.GWAutomatic );
      GWAddress_LE->setText( D.IP.GWAddress );
      GWIsDefault_CB->setChecked( D.IP.GWIsDefault );
      GWIfNotSet_CB->setChecked( D.IP.GWIfNotSet );
}