author | wimpie <wimpie> | 2004-04-02 18:29:49 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-02 18:29:49 (UTC) |
commit | 5334b639c9f97793bcae4f50f7b47c7a2ada4e2f (patch) (unidiff) | |
tree | f55aebd4314ab878bc39b6b08b8323a8ef78d803 /noncore/settings/networksettings2/ppp/PPPDNSedit.cpp | |
parent | 7c8922b37b5bb7696c0ff2cbc999e2936b9b509f (diff) | |
download | opie-5334b639c9f97793bcae4f50f7b47c7a2ada4e2f.zip opie-5334b639c9f97793bcae4f50f7b47c7a2ada4e2f.tar.gz opie-5334b639c9f97793bcae4f50f7b47c7a2ada4e2f.tar.bz2 |
First import of NS2 app
Diffstat (limited to 'noncore/settings/networksettings2/ppp/PPPDNSedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/ppp/PPPDNSedit.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp new file mode 100644 index 0000000..22f8e59 --- a/dev/null +++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp | |||
@@ -0,0 +1,108 @@ | |||
1 | #include <qtoolbutton.h> | ||
2 | #include <qmessagebox.h> | ||
3 | #include <qlistbox.h> | ||
4 | #include <qlineedit.h> | ||
5 | #include <qradiobutton.h> | ||
6 | #include <resources.h> | ||
7 | #include <GUIUtils.h> | ||
8 | #include "PPPDNSedit.h" | ||
9 | |||
10 | PPPDNSEdit::PPPDNSEdit( QWidget * Parent ) : PPPDNSGUI( Parent ){ | ||
11 | |||
12 | Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); | ||
13 | Remove_TB->setPixmap( NSResources->getPixmap( "remove" ) ); | ||
14 | } | ||
15 | |||
16 | QString PPPDNSEdit::acceptable( void ) { | ||
17 | if( DNSFixed_RB->isChecked() ) { | ||
18 | if( DomainName_LE->text().isEmpty() ) | ||
19 | tr("Domainname needed"); | ||
20 | if( Servers_LB->count() == 0 ) | ||
21 | tr("DNS Servers needed"); | ||
22 | } | ||
23 | return QString(); | ||
24 | } | ||
25 | |||
26 | bool PPPDNSEdit::commit( PPPData_t & D ) { | ||
27 | bool SM = 0; | ||
28 | |||
29 | CBM( D.DNS.ServerAssigned, DNSServerAssigned_RB, SM ); | ||
30 | TXTM( D.DNS.DomainName, DomainName_LE, SM ); | ||
31 | |||
32 | // new items in old ? | ||
33 | for ( unsigned i = 0; i < Servers_LB->count(); i++ ) { | ||
34 | QString S; | ||
35 | bool Found; | ||
36 | Found = 0; | ||
37 | S = Servers_LB->text(i); | ||
38 | for ( unsigned j = 0; j < D.DNS.Servers.size(); j++ ) { | ||
39 | if( *(D.DNS.Servers[i]) == S ) { | ||
40 | // still in list | ||
41 | Found = 1; | ||
42 | break; | ||
43 | } | ||
44 | } | ||
45 | if( ! Found ) { | ||
46 | SM = 1; | ||
47 | D.DNS.Servers.resize( D.DNS.Servers.size()+1 ); | ||
48 | D.DNS.Servers[D.DNS.Servers.size()] = new QString( S ); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | // old in new ? | ||
53 | for ( unsigned j = 0; j < D.DNS.Servers.size(); j++ ) { | ||
54 | bool Found; | ||
55 | Found = 0; | ||
56 | for ( unsigned i = 0; i < Servers_LB->count(); i++ ) { | ||
57 | if( *(D.DNS.Servers[j]) == Servers_LB->text(i) ) { | ||
58 | // still in list | ||
59 | Found = 1; | ||
60 | break; | ||
61 | } | ||
62 | } | ||
63 | if( ! Found ) { | ||
64 | // old obsolete | ||
65 | SM = 1; | ||
66 | delete D.DNS.Servers[j]; | ||
67 | for( unsigned i = j+1; i < D.DNS.Servers.size(); i ++ ) { | ||
68 | // compress array | ||
69 | D.DNS.Servers[i-1] = D.DNS.Servers[i]; | ||
70 | } | ||
71 | // shrink | ||
72 | D.DNS.Servers.resize( D.DNS.Servers.size()-1 ); | ||
73 | } | ||
74 | } | ||
75 | return SM; | ||
76 | } | ||
77 | |||
78 | void PPPDNSEdit::showData( PPPData_t & D) { | ||
79 | |||
80 | DNSServerAssigned_RB->setChecked( D.DNS.ServerAssigned ); | ||
81 | |||
82 | DomainName_LE->setText( D.DNS.DomainName ); | ||
83 | for( unsigned i = 0; i < D.DNS.Servers.size(); i ++ ) { | ||
84 | Servers_LB->insertItem( *(D.DNS.Servers[i]) ); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void PPPDNSEdit::SLOT_AddServer( void ) { | ||
89 | if( ServerAddress_LE->text().isEmpty() ) | ||
90 | return; | ||
91 | |||
92 | Servers_LB->insertItem( ServerAddress_LE->text() ); | ||
93 | ServerAddress_LE->setText( "" ); | ||
94 | } | ||
95 | |||
96 | void PPPDNSEdit::SLOT_RemoveServer( void ) { | ||
97 | long i = Servers_LB->currentItem(); | ||
98 | if( i < 0 ) | ||
99 | return; | ||
100 | Servers_LB->removeItem( i ); | ||
101 | if( (unsigned) i >= Servers_LB->count() ) { | ||
102 | i --; | ||
103 | } | ||
104 | if( i >= 0 ) { | ||
105 | Servers_LB->setCurrentItem( i ); | ||
106 | } | ||
107 | |||
108 | } | ||