summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp34
1 files changed, 30 insertions, 4 deletions
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
@@ -406,145 +406,171 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
if (!servicesList.isEmpty() ) {
// add services
QMap<int, QString> list;
QMap<int, QString>::Iterator classIt;
for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
serviceItem = new BTServiceItem( deviceItem, (*it2) );
list = (*it2).classIdList();
classIt = list.begin();
int classId=0;
if ( classIt != list.end() ) {
classId = classIt.key();
}
serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
}
} else {
Services s1;
s1.setServiceName( tr("no services found") );
serviceItem = new BTServiceItem( deviceItem, s1 );
}
// now remove them from the list
m_deviceList.remove( it );
}
void BlueBase::addSignalStrength() {
QListViewItemIterator it( ListView4 );
for ( ; it.current(); ++it ) {
m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
}
QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
}
void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) {
QListViewItemIterator it( ListView4 );
for ( ; it.current(); ++it ) {
if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) {
((BTConnectionItem*)it.current() )->setSignalStrength( strength );
}
}
}
/**
* Add the existing connections (pairs) to the connections tab.
* This one triggers the search
*/
void BlueBase::addConnectedDevices() {
m_localDevice->searchConnections();
}
/**
* This adds the found connections to the connection tab.
* @param connectionList the ValueList with all current connections
*/
void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
- // clear the ListView first
- ListView4->clear();
-
QValueList<OpieTooth::ConnectionState>::Iterator it;
BTConnectionItem * connectionItem;
if ( !connectionList.isEmpty() ) {
for (it = connectionList.begin(); it != connectionList.end(); ++it) {
+
+ 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() );
}
}
+
+ }
+
+ 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 );
}
// recall connection search after some time
QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) );
}
/**
* Find out if a device can currently be reached
* @param device
*/
void BlueBase::deviceActive( const RemoteDevice &device ) {
// search by mac, async, gets a signal back
// We should have a BTDeviceItem there or where does it get added to the map -zecke
m_localDevice->isAvailable( device.mac() );
}
/**
* The signal catcher. Set the avail. status on device.
* @param device - the mac address
* @param connected - if it is avail. or not
*/
void BlueBase::deviceActive( const QString& device, bool connected ) {
qDebug("deviceActive slot");
QMap<QString,BTDeviceItem*>::Iterator it;
it = m_deviceList.find( device );
if( it == m_deviceList.end() )
return;
BTDeviceItem* deviceItem = it.data();
if ( connected ) {
deviceItem->setPixmap( 1, m_onPix );
} else {
deviceItem->setPixmap( 1, m_offPix );
}
m_deviceList.remove( it );
}
/**
* Open the "scan for devices" dialog
*/
void BlueBase::startScan() {
ScanDialog *scan = new ScanDialog( this, "ScanDialog",
true, WDestructiveClose );
QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ),
this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) );
scan->showMaximized();
}
/**
* Set the informations about the local device in information Tab
*/
void BlueBase::setInfo() {