author | wimpie <wimpie> | 2004-04-02 18:30:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-02 18:30:55 (UTC) |
commit | 4ea2f227d3fb0d9591bb4f18555420ac47f3397d (patch) (unidiff) | |
tree | 4fdd216cf7af4a747e2ca71e35d15f3d9e646333 /noncore/settings/networksettings2/lancard/lancardedit.cpp | |
parent | 5334b639c9f97793bcae4f50f7b47c7a2ada4e2f (diff) | |
download | opie-4ea2f227d3fb0d9591bb4f18555420ac47f3397d.zip opie-4ea2f227d3fb0d9591bb4f18555420ac47f3397d.tar.gz opie-4ea2f227d3fb0d9591bb4f18555420ac47f3397d.tar.bz2 |
first import of NS2 app
Diffstat (limited to 'noncore/settings/networksettings2/lancard/lancardedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/lancard/lancardedit.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancardedit.cpp b/noncore/settings/networksettings2/lancard/lancardedit.cpp new file mode 100644 index 0000000..fa7f6dc --- a/dev/null +++ b/noncore/settings/networksettings2/lancard/lancardedit.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | #include <GUIUtils.h> | ||
2 | #include <resources.h> | ||
3 | #include <qlistview.h> | ||
4 | #include <qcheckbox.h> | ||
5 | #include <qheader.h> | ||
6 | #include <qregexp.h> | ||
7 | #include "lancardedit.h" | ||
8 | |||
9 | LanCardEdit::LanCardEdit( QWidget * Parent ) : LanCardGUI( Parent ){ | ||
10 | System & S = NSResources->system(); | ||
11 | QRegExp R( "eth[0-9]" ); | ||
12 | QCheckListItem * CLI; | ||
13 | |||
14 | LanCards_LV->header()->hide(); | ||
15 | |||
16 | // populate with all lancards in system | ||
17 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | ||
18 | It.current(); | ||
19 | ++It ) { | ||
20 | if( R.match( It.current()->Name ) >= 0 && | ||
21 | It.current()->CardType == ARPHRD_ETHER | ||
22 | ) { | ||
23 | CLI = new QCheckListItem( LanCards_LV, It.current()->Name, | ||
24 | QCheckListItem::CheckBox ); | ||
25 | CLI->setText( 1, It.current()->MACAddress ); | ||
26 | } | ||
27 | } | ||
28 | } | ||
29 | |||
30 | QString LanCardEdit::acceptable( void ) { | ||
31 | return QString(); | ||
32 | } | ||
33 | |||
34 | |||
35 | bool LanCardEdit::commit( LanCardData & Data ) { | ||
36 | bool SM = 0; | ||
37 | CBM( Data.AnyLanCard, AnyCard_CB, SM ); | ||
38 | |||
39 | if( ! Data.AnyLanCard ) { | ||
40 | // collect set of lancards that match | ||
41 | int idx; | ||
42 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); | ||
43 | while( CLI ) { | ||
44 | idx = Data.HWAddresses.findIndex(CLI->text(1)); | ||
45 | if( CLI->isOn() ) { | ||
46 | if( idx < 0 ) { | ||
47 | // should be in list | ||
48 | Data.HWAddresses.append( CLI->text(1) ); | ||
49 | SM = 1; | ||
50 | } | ||
51 | } else { | ||
52 | // should not be in list | ||
53 | if( idx >= 0 ) { | ||
54 | Data.HWAddresses.remove( Data.HWAddresses.at(idx) ); | ||
55 | SM = 1; | ||
56 | } | ||
57 | } | ||
58 | CLI = (QCheckListItem *)CLI->nextSibling(); | ||
59 | } | ||
60 | } | ||
61 | return SM || ContainedObsoleteMAC ; | ||
62 | } | ||
63 | |||
64 | void LanCardEdit::showData( LanCardData & Data ) { | ||
65 | AnyCard_CB->setChecked( Data.AnyLanCard ); | ||
66 | |||
67 | QCheckListItem * CLI = (QCheckListItem *)LanCards_LV->firstChild(); | ||
68 | |||
69 | ContainedObsoleteMAC = 0; | ||
70 | // remove obsolete address | ||
71 | for( QStringList::Iterator it=Data.HWAddresses.begin(); | ||
72 | it != Data.HWAddresses.end(); | ||
73 | ) { | ||
74 | CLI = (QCheckListItem *)LanCards_LV->firstChild(); | ||
75 | while( CLI ) { | ||
76 | if( CLI->text(1) == (*it) ) | ||
77 | // still valid | ||
78 | break; | ||
79 | CLI = (QCheckListItem *)CLI->nextSibling(); | ||
80 | } | ||
81 | if( CLI == 0 ) { | ||
82 | // address not found -> remove | ||
83 | ContainedObsoleteMAC = 1; | ||
84 | Data.HWAddresses.remove( it ); | ||
85 | } else { | ||
86 | ++ it; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | // set checks | ||
91 | while( CLI ) { | ||
92 | CLI->setOn( Data.HWAddresses.findIndex(CLI->text(1)) >= 0 ); | ||
93 | CLI = (QCheckListItem *)CLI->nextSibling(); | ||
94 | } | ||
95 | } | ||