author | zecke <zecke> | 2002-07-09 18:28:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-09 18:28:19 (UTC) |
commit | 411ac6f9199b1aae2b6a40e7a8cf6bfea260acba (patch) (side-by-side diff) | |
tree | 218836d6509d2dcaba3c6306f9f488b759169b1a | |
parent | 5f549398401acc5591ffcb67459dbf55ea323b91 (diff) | |
download | opie-411ac6f9199b1aae2b6a40e7a8cf6bfea260acba.zip opie-411ac6f9199b1aae2b6a40e7a8cf6bfea260acba.tar.gz opie-411ac6f9199b1aae2b6a40e7a8cf6bfea260acba.tar.bz2 |
Add a generic class for the sensitive QPopupMenu
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.cpp | 25 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.h | 25 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 2 |
6 files changed, 57 insertions, 7 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index c29eb1a..85c6717 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -199,97 +199,97 @@ using namespace OpieTooth; * Set up the gui */ void BlueBase::initGui() { StatusLabel->setText( status() ); // maybe move it to getStatus() cryptCheckBox->setChecked( m_useEncryption ); authCheckBox->setChecked( m_enableAuthentification ); pagescanCheckBox->setChecked( m_enablePagescan ); inquiryscanCheckBox->setChecked( m_enableInquiryscan ); deviceNameLine->setText( m_deviceName ); passkeyLine->setText( m_defaultPasskey ); // set info tab setInfo(); } /** * Get the status informations and returns it * @return QString the status informations gathered */ QString BlueBase::status()const{ QString infoString = tr( "<b>Device name : </b> Ipaq" ); infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); return (infoString); } /** * Read the current values from the gui and invoke writeConfig() */ void BlueBase::applyConfigChanges() { m_deviceName = deviceNameLine->text(); m_defaultPasskey = passkeyLine->text(); m_useEncryption = cryptCheckBox->isChecked(); m_enableAuthentification = authCheckBox->isChecked(); m_enablePagescan = pagescanCheckBox->isChecked(); m_enableInquiryscan = inquiryscanCheckBox->isChecked(); writeConfig(); QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); } /** * Add fresh found devices from scan dialog to the listing * */ - void BlueBase::addSearchedDevices( QValueList<RemoteDevice> &newDevices ) { + void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { BTListItem * deviceItem; QValueList<RemoteDevice>::ConstIterator it; for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { deviceItem = new BTListItem( ListView2 , (*it).name(), (*it).mac(), "device" ); deviceItem->setExpandable ( true ); // look if device is avail. atm, async deviceActive( (*it) ); // ggf auch hier? addServicesToDevice( deviceItem ); } } /** * Action that is toggled on entrys on click */ void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { } /** * Action that are toggled on hold (mostly QPopups i guess) */ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { QPopupMenu *menu = new QPopupMenu(); int ret=0; if ( ((BTListItem*)item)->type() == "device") { QPopupMenu *groups = new QPopupMenu(); menu->insertItem( tr("rescan sevices:"), 0); menu->insertItem( tr("to group"), groups , 1); menu->insertItem( tr("bound device"), 2); menu->insertItem( tr("delete"), 3); ret = menu->exec( point , 0); switch(ret) { case 0: break; case 1: break; case 2: // make connection @@ -389,70 +389,70 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin } } else { connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" ); } // recall connection search after some time QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); } /** * Find out if a device can currently be reached */ void BlueBase::deviceActive( const RemoteDevice &device ) { // search by mac, async, gets a signal back 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,BTListItem*>::Iterator it; BTListItem* deviceItem = 0; // get the right devices which requested the search for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { if ( it.key() == device ) { deviceItem = it.data(); } } if ( connected ) { deviceItem->setPixmap( 1, m_onPix ); } else { deviceItem->setPixmap( 1, m_offPix ); } } /** * Open the "scan for devices" dialog */ void BlueBase::startScan() { ScanDialog *scan = new ScanDialog( this, "ScanDialog", true, WDestructiveClose ); - QObject::connect( scan, SIGNAL( selectedDevices( QValueList<RemoteDevice>& ) ), - this, SLOT( addSearchedDevices( QValueList<RemoteDevice>& ) ) ); + 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() { StatusLabel->setText( status() ); } /** * Decontructor */ BlueBase::~BlueBase() { writeSavedDevices(); delete m_iconLoader; } diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 97ce8c3..73fac97 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h @@ -23,63 +23,63 @@ class QFrame; class QLabel; class QPushButton; class QTabWidget; class QCheckBox; namespace OpieTooth { class BlueBase : public BluetoothBase { Q_OBJECT public: BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~BlueBase(); protected: private slots: void startScan(); private: void readConfig(); void writeConfig(); void readSavedDevices(); void writeSavedDevices(); void writeToHciConfig(); QString status()const; void initGui(); void setInfo(); Manager *m_localDevice; QMap<QString,BTListItem*> 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; QPixmap m_offPix; QPixmap m_onPix; BTIconLoader *m_iconLoader; private slots: - void addSearchedDevices( QValueList<RemoteDevice> &newDevices ); + void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); void addServicesToDevice( BTListItem *item ); void addServicesToDevice( const QString& device, Services::ValueList ); void addConnectedDevices(); void addConnectedDevices( Connection::ValueList ); void startServiceActionClicked( QListViewItem *item ); void startServiceActionHold( QListViewItem *, const QPoint &, int ); void deviceActive( const QString& mac, bool connected ); void applyConfigChanges(); }; } #endif diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 55f2fd2..4f0ea60 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro @@ -1,27 +1,27 @@ TEMPLATE = app CONFIG = qt warn_on debug #CONFIG = qt warn_on release -HEADERS = bluebase.h scandialog.h btlistitem.h hciconfwrapper.h bticonloader.h -SOURCES = main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp bticonloader.cpp +HEADERS = popuphelper.h bluebase.h scandialog.h btlistitem.h hciconfwrapper.h bticonloader.h +SOURCES = popuphelper.cpp main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp bticonloader.cpp INCLUDEPATH += $(OPIEDIR)/include INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopietooth -lopie INTERFACES = bluetoothbase.ui devicedialog.ui DESTDIR = $(OPIEDIR)/bin TARGET = bluetooth-manager TRANSLATIONS = ../../../../i18n/de/bluetooth-manager.ts \ ../../../../i18n/en/bluetooth-manager.ts \ ../../../../i18n/es/bluetooth-manager.ts \ ../../../../i18n/fr/bluetooth-manager.ts \ ../../../../i18n/hu/bluetooth-manager.ts \ ../../../../i18n/ja/bluetooth-manager.ts \ ../../../../i18n/ko/bluetooth-manager.ts \ ../../../../i18n/no/bluetooth-manager.ts \ ../../../../i18n/pl/bluetooth-manager.ts \ ../../../../i18n/pt/bluetooth-manager.ts \ ../../../../i18n/pt_BR/bluetooth-manager.ts \ ../../../../i18n/sl/bluetooth-manager.ts \ ../../../../i18n/zh_CN/bluetooth-manager.ts \ ../../../../i18n/zh_TW/bluetooth-manager.ts diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp new file mode 100644 index 0000000..2a6dad0 --- a/dev/null +++ b/noncore/net/opietooth/manager/popuphelper.cpp @@ -0,0 +1,25 @@ + +#include "popuphelper.h" + +using namespace OpieTooth; + +PopupHelper::PopupHelper() { + init(); +} +PopupHelper::~PopupHelper() { + +} +void PopupHelper::insert( int id, popupFactory fact ) { + m_map.insert(id, fact ); +} +QPopupMenu* PopupHelper::find( int id ) { + FactoryMap::Iterator it = m_map.find(id ); + if ( it != m_map.end() ) { + popupFactory fact = it.data(); + return (*fact)(); + } + return 0l; +} +void PopupHelper::init() { + +} diff --git a/noncore/net/opietooth/manager/popuphelper.h b/noncore/net/opietooth/manager/popuphelper.h new file mode 100644 index 0000000..7485f71 --- a/dev/null +++ b/noncore/net/opietooth/manager/popuphelper.h @@ -0,0 +1,25 @@ + +#ifndef OPIE_TOOTH_POPUP_HELPER +#define OPIE_TOOTH_POPUP_HELPER + +#include <qpopupmenu.h> +#include <qmap.h> + + +namespace OpieTooth { + typedef QPopupMenu* (*popupFactory)(void); + typedef QMap<int, popupFactory> FactoryMap; + class PopupHelper { + public: + PopupHelper(); + ~PopupHelper(); + void insert( int id, popupFactory fact ); + QPopupMenu* find( int id ); + private: + void init(); + FactoryMap m_map; + + }; +}; + +#endif diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index cc890f3..f18784d 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h @@ -25,55 +25,55 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QFrame; class QLabel; class QListView; class QListViewItem; class QPushButton; class QProgressBar; namespace OpieTooth { class Manager; class Device; class ScanDialog : public QDialog { Q_OBJECT public: ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~ScanDialog(); QFrame* Frame7; QProgressBar* progress; QPushButton* StartButton; QPushButton* StopButton; QListView* ListView1; public slots: void accept(); protected: QVBoxLayout* Layout11; private slots: void stopSearch(); void startSearch(); void progressTimer(); void fillList(const QString& device, RemoteDevice::ValueList list); private: void emitToManager(); Manager *localDevice; int progressStat; signals: - void selectedDevices(QValueList<RemoteDevice>&); + void selectedDevices(const QValueList<RemoteDevice>&); }; } #endif // SCANDIALOG_H |