author | harlekin <harlekin> | 2003-03-07 22:55:36 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-07 22:55:36 (UTC) |
commit | ee1d48a9a5f3672f329301a844e69f2e184afcac (patch) (side-by-side diff) | |
tree | a549cd37f837e2704527b7b40a0f9f8ef9372a7b /noncore/net/opietooth/manager | |
parent | eeb28ead6d3050d662783696661d9360a049104f (diff) | |
download | opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.zip opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.gz opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.bz2 |
show signal strength for connections
Diffstat (limited to 'noncore/net/opietooth/manager') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 40 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 5 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluetoothbase.ui | 14 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btconnectionitem.cpp | 18 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btconnectionitem.h | 8 |
5 files changed, 80 insertions, 5 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 8b15c4f..9663b52 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -63,24 +63,26 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); connect( ListView2, SIGNAL( clicked( QListViewItem* )), this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), this, SLOT( deviceActive( const QString& , bool ) ) ); connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); + connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), + this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); // let hold be rightButtonClicked() QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); //Load all icons needed m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); m_onPix = Resource::loadPixmap( "opietooth/connected" ); m_findPix = Resource::loadPixmap( "opietooth/find" ); QPalette pal = this->palette(); @@ -89,27 +91,29 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); pal.setColor( QPalette::Normal, QColorGroup::Button, col ); pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); this->setPalette( pal ); setCaption( tr( "Bluetooth Manager" ) ); readConfig(); initGui(); ListView2->setRootIsDecorated(true); + writeToHciConfig(); // search conncetions addConnectedDevices(); + addSignalStrength(); m_iconLoader = new BTIconLoader(); readSavedDevices(); } /** * Reads all options from the config file */ void BlueBase::readConfig() { Config cfg( "bluetoothmanager" ); cfg.setGroup( "bluezsettings" ); @@ -361,25 +365,26 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin */ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { qDebug("addServicesToDevice"); // row of mac adress text(3) RemoteDevice device = item->remoteDevice(); m_deviceList.insert( item->mac() , item ); // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back m_localDevice->searchServices( device ); } /** - * Overloaded. This one it the one that is connected to the foundServices signal + * Overloaded. This one it the one that is + ted to the foundServices signal * @param device the mac address of the remote device * @param servicesList the list with the service the device has. */ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { qDebug("fill services list"); QMap<QString,BTDeviceItem*>::Iterator it; BTDeviceItem* deviceItem = 0; // get the right devices which requested the search it = m_deviceList.find( device ); if( it == m_deviceList.end() ) @@ -416,50 +421,77 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s 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) { - connectionItem = new BTConnectionItem( ListView4 , (*it) ); - } + connectionItem = new BTConnectionItem( ListView4, (*it) ); + + if( m_deviceList.find((*it).mac()).data() ) { + + connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); + } + } } else { 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() ) ); } /** diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 0326daf..743062c 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h @@ -4,39 +4,41 @@ #include <qvariant.h> #include <qwidget.h> #include <qscrollview.h> #include <qsplitter.h> #include <qlist.h> #include <qpixmap.h> #include "bluetoothbase.h" #include "btserviceitem.h" #include "btdeviceitem.h" + #include "popuphelper.h" #include "bticonloader.h" #include <remotedevice.h> #include <manager.h> class QVBox; class QHBoxLayout; class QGridLayout; class QFrame; class QLabel; class QPushButton; class QTabWidget; class QCheckBox; +class BTConnectionItem; namespace OpieTooth { class BlueBase : public BluetoothBase { Q_OBJECT public: BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~BlueBase(); protected: @@ -46,24 +48,25 @@ namespace OpieTooth { void startScan(); private: bool find( const RemoteDevice& device ); void readConfig(); void writeConfig(); void readSavedDevices(); void writeSavedDevices(); void writeToHciConfig(); QString status()const; void initGui(); void setInfo(); + PopupHelper m_popHelper; Manager *m_localDevice; QMap<QString,BTDeviceItem*> m_deviceList; void deviceActive( const RemoteDevice &device ); QString m_deviceName; QString m_defaultPasskey; bool m_useEncryption; bool m_enableAuthentification; bool m_enablePagescan; bool m_enableInquiryscan; @@ -75,18 +78,20 @@ namespace OpieTooth { BTIconLoader *m_iconLoader; private slots: void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); void addServicesToDevice( BTDeviceItem *item ); void addServicesToDevice( const QString& device, Services::ValueList ); void addConnectedDevices(); void addConnectedDevices( ConnectionState::ValueList ); void startServiceActionClicked( QListViewItem *item ); void startServiceActionHold( QListViewItem *, const QPoint &, int ); void deviceActive( const QString& mac, bool connected ); void applyConfigChanges(); + void addSignalStrength(); + void addSignalStrength( const QString& mac, const QString& strengh ); }; } #endif diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index 869a9cb..b51c8c6 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -189,24 +189,38 @@ <name>text</name> <string>Connection type</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> + <column> + <property> + <name>text</name> + <string>Signal</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> <property stdset="1"> <name>name</name> <cstring>ListView4</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> <width>240</width> <height>240</height> </rect> diff --git a/noncore/net/opietooth/manager/btconnectionitem.cpp b/noncore/net/opietooth/manager/btconnectionitem.cpp index b57d1b3..c565c47 100644 --- a/noncore/net/opietooth/manager/btconnectionitem.cpp +++ b/noncore/net/opietooth/manager/btconnectionitem.cpp @@ -13,12 +13,30 @@ BTConnectionItem::~BTConnectionItem() { } QString BTConnectionItem::type() const { return QString::fromLatin1("connection"); } int BTConnectionItem::typeId() const { return Connection; } ConnectionState BTConnectionItem::connection() const { return m_con; } +void BTConnectionItem::setName( QString name ) { + m_name = name; + setText( 0, m_name ); +} + +QString BTConnectionItem::name() { + return m_name; +} + + +void BTConnectionItem::setSignalStrength( QString strength ) { + m_signalStrength = strength; + setText( 2, m_signalStrength ); +} + +QString BTConnectionItem::signalStrength() { + return m_signalStrength; +} diff --git a/noncore/net/opietooth/manager/btconnectionitem.h b/noncore/net/opietooth/manager/btconnectionitem.h index 3c0cd79..9ab745e 100644 --- a/noncore/net/opietooth/manager/btconnectionitem.h +++ b/noncore/net/opietooth/manager/btconnectionitem.h @@ -4,23 +4,29 @@ #include "btlistitem.h" namespace OpieTooth { class ConnectionState; class BTConnectionItem : public BTListItem { public: BTConnectionItem( QListView* parent, const ConnectionState& state ); ~BTConnectionItem(); QString type()const; + QString name(); + QString signalStrength(); int typeId() const; ConnectionState connection()const; + void setSignalStrength( QString ); + void setName( QString ); + private: ConnectionState m_con; - + QString m_name; + QString m_signalStrength; }; }; #endif |