Diffstat (limited to 'noncore/settings/networksettings2/network/networkedit.cpp') (more/less context) (show 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,10 +1,11 @@ #include <qtoolbutton.h> #include <qcheckbox.h> +#include <qtabwidget.h> #include <qlineedit.h> #include <qlistbox.h> #include <GUIUtils.h> #include <resources.h> #include "networkedit.h" NetworkEdit::NetworkEdit( QWidget * Parent ) : NetworkGUI( Parent ){ @@ -105,17 +106,23 @@ bool NetworkEdit::updateList( QStringList & SL, QListBox * LB ) { bool Changed; QStringList NewSL; // collect new list for( unsigned int i = 0; i < LB->count() ; i ++ ) { NewSL.append( LB->text(i) ); } - // check if at least ONE item in new list is NEW + if( NewSL.count() != SL.count() ) { + // less or more items + SL= NewSL; + return 1; + } + + // Same size -> same content ? Changed = 0; for ( QStringList::Iterator it = NewSL.begin(); it != NewSL.end(); ++it ) { if( SL.findIndex( (*it) ) < 0 ) { // new or modified item Changed = 1; SL = NewSL; @@ -153,8 +160,65 @@ void NetworkEdit::SLOT_NetmaskModified( const QString & ) { NW = QString( "%1.%2.%3.%4" ). arg( ipal[0].toShort() | ( ~ nmal[0].toShort() & 0x00ff) ). arg( ipal[1].toShort() | ( ~ nmal[1].toShort() & 0x00ff) ). arg( ipal[2].toShort() | ( ~ nmal[2].toShort() & 0x00ff) ). arg( ipal[3].toShort() | ( ~ nmal[3].toShort() & 0x00ff) ); Broadcast_LE->setText( NW ); } } + +QListBox * NetworkEdit::getActiveLB( void ) { + switch( Tab_TAB->currentPageIndex() ) { + case 0 : + return PreUp_LB; + case 1 : + return PostUp_LB; + case 2 : + return PreDown_LB; + } + return PostDown_LB; +} + +void NetworkEdit::SLOT_Add( void ) { + if( Command_LE->text().isEmpty() ) + return; + QListBox * LB = getActiveLB(); + + LB->insertItem( Command_LE->text() ); +} + +void NetworkEdit::SLOT_Remove( void ) { + QListBox * LB = getActiveLB(); + int i; + + if( ( i = LB->currentItem() ) >= 0 ) { + LB->removeItem( i ); + } +} + +void NetworkEdit::SLOT_Up( void ) { + QListBox * LB = getActiveLB(); + int i; + + if( ( i = LB->currentItem() ) > 0 ) { + QListBoxItem * LBI = LB->item(i); + LB->takeItem( LBI ); + LB->insertItem( LBI, --i ); + LB->setCurrentItem( i ); + } +} + +void NetworkEdit::SLOT_Down( void ) { + QListBox * LB = getActiveLB(); + int i; + + if( ( i = LB->currentItem() ) >= 0 && (unsigned)(i+1) != LB->count() ) { + QListBoxItem * LBI = LB->item(i); + LB->takeItem( LBI ); + LB->insertItem( LBI, ++i ); + LB->setCurrentItem( i ); + } +} + +void NetworkEdit::SLOT_ShowCommand( QListBoxItem * It ) { + Command_LE->setText( It->text() ); +} |