Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | 89 |
1 files changed, 52 insertions, 37 deletions
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp index be720b8..7943deb 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp @@ -1 +1,11 @@ +/* $Id$ */ +/* RFCOMM binding table edit dialog */ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ @@ -24,3 +34,2 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool { - m_range = 5; @@ -50,3 +59,3 @@ RfcommAssignDialog::~RfcommAssignDialog() -void RfcommAssignDialog::newDevice( const QString & mac ) +void RfcommAssignDialog::newDevice(const QString & mac, int channel) { @@ -55,5 +64,4 @@ void RfcommAssignDialog::newDevice( const QString & mac ) { - QMap<QString, RfCommConfObject*>::Iterator it; - it = confHandler->foundEntries().find( QString("%1").arg( i ) ); + it = confHandler->foundEntries().find(QString::number(i)); // make sure that rfcommX is not assigned yet @@ -64,6 +72,11 @@ void RfcommAssignDialog::newDevice( const QString & mac ) (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); + QVBoxLayout layout(&dialog); + layout.setSpacing( 0 ); + layout.setMargin( 0 ); - RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); - newDev->setIdent( i ); - newDev->setMac( mac ); + RfcommDialogItem newDev(&dialog); + newDev.setIdent( i ); + newDev.setMac( mac ); + newDev.setChannel( channel ); + layout.addWidget(&newDev); @@ -71,10 +84,13 @@ void RfcommAssignDialog::newDevice( const QString & mac ) { - RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); - m_itemList.insert( i , rfcomm ); + QMap<int, RfcommDialogItem*>::Iterator it; + it = m_itemList.find( i ); + RfcommDialogItem *rfcomm = it.data(); rfcomm->setIdent( i ); rfcomm->setMac( mac ); - rfcomm->setChannel( newDev->channel() ); - rfcomm->setComment( newDev->comment() ); + rfcomm->setChannel( newDev.channel() ); + rfcomm->setComment( newDev.comment() ); + rfcomm->setBind( newDev.isBind() ); odebug << "New device set up" << oendl; } + break; } @@ -83,10 +99,9 @@ void RfcommAssignDialog::newDevice( const QString & mac ) +/* + * Load rfcomm bind configuration + */ void RfcommAssignDialog::loadConfig() { - - //Config cfg( "bluetoothmanager-rfcommbind" ); - for ( int i = 0 ; i < m_range; i++ ) { - // cfg.setGroup( QString("%1").arg( i ) ); RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); @@ -95,6 +110,5 @@ void RfcommAssignDialog::loadConfig() QMap<QString, RfCommConfObject*>::Iterator it; - it = confHandler->foundEntries().find( QString("%1").arg( i ) ); + it = confHandler->foundEntries().find(QString::number(i)); if ( it != confHandler->foundEntries().end() ) { - odebug << "Found key in foundEntries() " << oendl; rfcomm->setMac( it.data()->mac() ); @@ -102,8 +116,4 @@ void RfcommAssignDialog::loadConfig() rfcomm->setComment( it.data()->comment() ); + rfcomm->setBind(it.data()->isBind()); } - /* Use rfcomm.conf directly for now - * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); - * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); - * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); - */ } @@ -112,9 +122,8 @@ void RfcommAssignDialog::loadConfig() +/* + * Save rfcomm bind configuration + */ void RfcommAssignDialog::saveConfig() { - - //Config cfg( "bluetoothmanager-rfcommbind" ); - QMap< int, RfcommDialogItem*>::Iterator it; - QMap< QString, RfCommConfObject*> outMap; @@ -123,17 +132,23 @@ void RfcommAssignDialog::saveConfig() { - - //cfg.setGroup( QString("%1").arg( it.key() ) ); RfcommDialogItem *rfcomm = it.data(); - - - outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); - - - //cfg.writeEntry( "mac", rfcomm->mac() ); - //cfg.writeEntry( "channel", rfcomm->channel() ); - //cfg.writeEntry( "comment", rfcomm->comment() ); + if (rfcomm->mac().isEmpty()) + continue; + outMap.insert(QString::number(it.key()), + new RfCommConfObject(it.key(), + rfcomm->mac(), rfcomm->channel(), rfcomm->comment(), + rfcomm->isBind())); } - confHandler->save( outMap ); +} +/* + * Reaction on the OK button + */ +void RfcommAssignDialog::accept() +{ + odebug << "save configuration" << oendl; + saveConfig(); + RfcommAssignDialogBase::accept(); } + +//eof |