From 3e92beca986b9fecd8193f55513ea1ecd2cd0866 Mon Sep 17 00:00:00 2001 From: harlekin Date: Fri, 07 Mar 2003 23:58:45 +0000 Subject: nicer refresh handling for connections --- (limited to 'noncore/net') diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 9663b52..b5a09e5 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -467,23 +467,49 @@ void BlueBase::addConnectedDevices() { */ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { - // clear the ListView first - ListView4->clear(); - QValueList::Iterator it; BTConnectionItem * connectionItem; if ( !connectionList.isEmpty() ) { for (it = connectionList.begin(); it != connectionList.end(); ++it) { - connectionItem = new BTConnectionItem( ListView4, (*it) ); - if( m_deviceList.find((*it).mac()).data() ) { + QListViewItemIterator it2( ListView4 ); + bool found = false; + for ( ; it2.current(); ++it2 ) { + if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { + found = true; + } + } + + if ( found == false ) { + connectionItem = new BTConnectionItem( ListView4, (*it) ); + + if( m_deviceList.find((*it).mac()).data() ) { + connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); + } + } - connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); - } } + + QListViewItemIterator it2( ListView4 ); + for ( ; it2.current(); ++it2 ) { + bool found = false; + for (it = connectionList.begin(); it != connectionList.end(); ++it) { + if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { + found = true; + } + } + + if ( !found ) { + delete it2.current(); + } + + } + + } else { + ListView4->clear(); ConnectionState con; con.setMac( tr("No connections found") ); connectionItem = new BTConnectionItem( ListView4 , con ); -- cgit v0.9.0.2