Diffstat (limited to 'noncore/settings/networksettings2/network/networkedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/network/networkedit.cpp | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp index 182213b..05110d9 100644 --- a/noncore/settings/networksettings2/network/networkedit.cpp +++ b/noncore/settings/networksettings2/network/networkedit.cpp | |||
@@ -1,14 +1,15 @@ | |||
1 | #include <qtoolbutton.h> | 1 | #include <qtoolbutton.h> |
2 | #include <qcheckbox.h> | 2 | #include <qcheckbox.h> |
3 | #include <qtabwidget.h> | ||
3 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
4 | #include <qlistbox.h> | 5 | #include <qlistbox.h> |
5 | #include <GUIUtils.h> | 6 | #include <GUIUtils.h> |
6 | #include <resources.h> | 7 | #include <resources.h> |
7 | #include "networkedit.h" | 8 | #include "networkedit.h" |
8 | 9 | ||
9 | NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){ | 10 | NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){ |
10 | 11 | ||
11 | AddPreDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 12 | AddPreDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
12 | AddPreUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 13 | AddPreUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
13 | AddPostDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 14 | AddPostDown_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
14 | AddPostUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); | 15 | AddPostUp_TB->setPixmap( NSResources->getPixmap( "add" ) ); |
@@ -101,25 +102,31 @@ void NetworkEdit::showData( NetworkData_t & Data ) { | |||
101 | populateList( Data.PostDown_SL, PostDown_LB ); | 102 | populateList( Data.PostDown_SL, PostDown_LB ); |
102 | } | 103 | } |
103 | 104 | ||
104 | bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) { | 105 | bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) { |
105 | bool Changed; | 106 | bool Changed; |
106 | QStringList NewSL; | 107 | QStringList NewSL; |
107 | 108 | ||
108 | // collect new list | 109 | // collect new list |
109 | for( unsigned int i = 0; i < LB->count() ; i ++ ) { | 110 | for( unsigned int i = 0; i < LB->count() ; i ++ ) { |
110 | NewSL.append( LB->text(i) ); | 111 | NewSL.append( LB->text(i) ); |
111 | } | 112 | } |
112 | 113 | ||
113 | // check if at least ONE item in new list is NEW | 114 | if( NewSL.count() != SL.count() ) { |
115 | // less or more items | ||
116 | SL= NewSL; | ||
117 | return 1; | ||
118 | } | ||
119 | |||
120 | // Same size -> same content ? | ||
114 | Changed = 0; | 121 | Changed = 0; |
115 | for ( QStringList::Iterator it = NewSL.begin(); | 122 | for ( QStringList::Iterator it = NewSL.begin(); |
116 | it != NewSL.end(); | 123 | it != NewSL.end(); |
117 | ++it ) { | 124 | ++it ) { |
118 | if( SL.findIndex( (*it) ) < 0 ) { | 125 | if( SL.findIndex( (*it) ) < 0 ) { |
119 | // new or modified item | 126 | // new or modified item |
120 | Changed = 1; | 127 | Changed = 1; |
121 | SL = NewSL; | 128 | SL = NewSL; |
122 | break; | 129 | break; |
123 | } | 130 | } |
124 | } | 131 | } |
125 | return Changed; | 132 | return Changed; |
@@ -149,12 +156,69 @@ void NetworkEdit::SLOT_NetmaskModified( const QString & ) { | |||
149 | { QString NW; | 156 | { QString NW; |
150 | QStringList ipal = QStringList::split( '.', IP ); | 157 | QStringList ipal = QStringList::split( '.', IP ); |
151 | QStringList nmal = QStringList::split( '.', SN ); | 158 | QStringList nmal = QStringList::split( '.', SN ); |
152 | 159 | ||
153 | NW = QString( "%1.%2.%3.%4" ). | 160 | NW = QString( "%1.%2.%3.%4" ). |
154 | arg( ipal[0].toShort() | ( ~ nmal[0].toShort() & 0x00ff) ). | 161 | arg( ipal[0].toShort() | ( ~ nmal[0].toShort() & 0x00ff) ). |
155 | arg( ipal[1].toShort() | ( ~ nmal[1].toShort() & 0x00ff) ). | 162 | arg( ipal[1].toShort() | ( ~ nmal[1].toShort() & 0x00ff) ). |
156 | arg( ipal[2].toShort() | ( ~ nmal[2].toShort() & 0x00ff) ). | 163 | arg( ipal[2].toShort() | ( ~ nmal[2].toShort() & 0x00ff) ). |
157 | arg( ipal[3].toShort() | ( ~ nmal[3].toShort() & 0x00ff) ); | 164 | arg( ipal[3].toShort() | ( ~ nmal[3].toShort() & 0x00ff) ); |
158 | Broadcast_LE->setText( NW ); | 165 | Broadcast_LE->setText( NW ); |
159 | } | 166 | } |
160 | } | 167 | } |
168 | |||
169 | QListBox * NetworkEdit::getActiveLB( void ) { | ||
170 | switch( Tab_TAB->currentPageIndex() ) { | ||
171 | case 0 : | ||
172 | return PreUp_LB; | ||
173 | case 1 : | ||
174 | return PostUp_LB; | ||
175 | case 2 : | ||
176 | return PreDown_LB; | ||
177 | } | ||
178 | return PostDown_LB; | ||
179 | } | ||
180 | |||
181 | void NetworkEdit::SLOT_Add( void ) { | ||
182 | if( Command_LE->text().isEmpty() ) | ||
183 | return; | ||
184 | QListBox * LB = getActiveLB(); | ||
185 | |||
186 | LB->insertItem( Command_LE->text() ); | ||
187 | } | ||
188 | |||
189 | void NetworkEdit::SLOT_Remove( void ) { | ||
190 | QListBox * LB = getActiveLB(); | ||
191 | int i; | ||
192 | |||
193 | if( ( i = LB->currentItem() ) >= 0 ) { | ||
194 | LB->removeItem( i ); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void NetworkEdit::SLOT_Up( void ) { | ||
199 | QListBox * LB = getActiveLB(); | ||
200 | int i; | ||
201 | |||
202 | if( ( i = LB->currentItem() ) > 0 ) { | ||
203 | QListBoxItem * LBI = LB->item(i); | ||
204 | LB->takeItem( LBI ); | ||
205 | LB->insertItem( LBI, --i ); | ||
206 | LB->setCurrentItem( i ); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | void NetworkEdit::SLOT_Down( void ) { | ||
211 | QListBox * LB = getActiveLB(); | ||
212 | int i; | ||
213 | |||
214 | if( ( i = LB->currentItem() ) >= 0 && (unsigned)(i+1) != LB->count() ) { | ||
215 | QListBoxItem * LBI = LB->item(i); | ||
216 | LB->takeItem( LBI ); | ||
217 | LB->insertItem( LBI, ++i ); | ||
218 | LB->setCurrentItem( i ); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | void NetworkEdit::SLOT_ShowCommand( QListBoxItem * It ) { | ||
223 | Command_LE->setText( It->text() ); | ||
224 | } | ||