author | korovkin <korovkin> | 2006-03-25 18:10:13 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-03-25 18:10:13 (UTC) |
commit | c4f82599db775f52c7e04cce09c7c45ecc89ccfd (patch) (side-by-side diff) | |
tree | 81d48e5363a2135bb6820510ae7f5dee9999e8f2 /noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | |
parent | da3c4a6231882bc56266162415a8d1a2a1bf0293 (diff) | |
download | opie-c4f82599db775f52c7e04cce09c7c45ecc89ccfd.zip opie-c4f82599db775f52c7e04cce09c7c45ecc89ccfd.tar.gz opie-c4f82599db775f52c7e04cce09c7c45ecc89ccfd.tar.bz2 |
Added RFCOMM binding table functionality.
Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | 115 |
1 files changed, 65 insertions, 50 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,6 +34,5 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool { - m_range = 5; - m_scrollView = new QScrollView( this ); + m_scrollView = new QScrollView(this); m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); @@ -31,6 +40,6 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool - RfcommAssignDialogBaseLayout->addWidget( m_scrollView ); + RfcommAssignDialogBaseLayout->addWidget(m_scrollView); - m_box = new QVBox( m_scrollView->viewport() ); - m_scrollView->addChild( m_box ); + m_box = new QVBox(m_scrollView->viewport()); + m_scrollView->addChild(m_box); @@ -50,3 +59,3 @@ RfcommAssignDialog::~RfcommAssignDialog() -void RfcommAssignDialog::newDevice( const QString & mac ) +void RfcommAssignDialog::newDevice(const QString & mac, int channel) { @@ -55,7 +64,6 @@ 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 - if ( it == confHandler->foundEntries().end() ) + if ( it == confHandler->foundEntries().end() ) { @@ -64,6 +72,11 @@ void RfcommAssignDialog::newDevice( const QString & mac ) (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); - - RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); - newDev->setIdent( i ); - newDev->setMac( mac ); + QVBoxLayout layout(&dialog); + layout.setSpacing( 0 ); + layout.setMargin( 0 ); + + 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,27 +99,21 @@ 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 ); - m_itemList.insert( i , rfcomm ); - rfcomm->setIdent( i ); + m_itemList.insert(i, rfcomm); + rfcomm->setIdent(i); QMap<QString, RfCommConfObject*>::Iterator it; - it = confHandler->foundEntries().find( QString("%1").arg( i ) ); - if ( it != confHandler->foundEntries().end() ) + it = confHandler->foundEntries().find(QString::number(i)); + if (it != confHandler->foundEntries().end()) { - odebug << "Found key in foundEntries() " << oendl; - rfcomm->setMac( it.data()->mac() ); - rfcomm->setChannel( it.data()->channel() ); - rfcomm->setComment( it.data()->comment() ); + rfcomm->setMac(it.data()->mac()); + rfcomm->setChannel(it.data()->channel()); + 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); +} - confHandler->save( outMap ); - +/* + * Reaction on the OK button + */ +void RfcommAssignDialog::accept() +{ + odebug << "save configuration" << oendl; + saveConfig(); + RfcommAssignDialogBase::accept(); } + +//eof |