-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 19 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 4 |
4 files changed, 23 insertions, 12 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 71da82e..c993c7c 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,181 +1,192 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * begin : Sun 10 17:20:00 CEST 2002 | 5 | * begin : Sun 10 17:20:00 CEST 2002 |
6 | * copyright : (c) 2002 by Maximilian Reiß | 6 | * copyright : (c) 2002 by Maximilian Reiß |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "bluebase.h" | 19 | #include "bluebase.h" |
20 | #include "scandialog.h" | 20 | #include "scandialog.h" |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qvariant.h> | 26 | #include <qvariant.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qimage.h> | 28 | #include <qimage.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qscrollview.h> | 31 | #include <qscrollview.h> |
32 | #include <qvbox.h> | 32 | #include <qvbox.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qlistview.h> | ||
37 | 38 | ||
38 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | 41 | ||
41 | 42 | ||
42 | namespace OpieTooth { | 43 | namespace OpieTooth { |
43 | 44 | ||
44 | class RemoteDevices; | 45 | |
46 | #include <remotedevice.h> | ||
45 | 47 | ||
46 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 48 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
47 | : BluetoothBase( parent, name, fl ) { | 49 | : BluetoothBase( parent, name, fl ) { |
48 | 50 | ||
49 | 51 | ||
50 | QObject::connect( (QObject*) PushButton2, SIGNAL( clicked() ), this, SLOT(startScan())); | 52 | QObject::connect( (QObject*) PushButton2, SIGNAL( clicked() ), this, SLOT(startScan())); |
51 | QObject::connect((QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges())); | 53 | QObject::connect((QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges())); |
52 | 54 | ||
53 | 55 | ||
54 | 56 | ||
55 | 57 | ||
56 | QPalette pal = this->palette(); | 58 | QPalette pal = this->palette(); |
57 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); | 59 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); |
58 | pal.setColor(QPalette::Active, QColorGroup::Button, col); | 60 | pal.setColor(QPalette::Active, QColorGroup::Button, col); |
59 | pal.setColor(QPalette::Inactive, QColorGroup::Button, col); | 61 | pal.setColor(QPalette::Inactive, QColorGroup::Button, col); |
60 | pal.setColor(QPalette::Normal, QColorGroup::Button, col); | 62 | pal.setColor(QPalette::Normal, QColorGroup::Button, col); |
61 | pal.setColor(QPalette::Disabled, QColorGroup::Button, col); | 63 | pal.setColor(QPalette::Disabled, QColorGroup::Button, col); |
62 | this->setPalette(pal); | 64 | this->setPalette(pal); |
63 | 65 | ||
64 | setCaption( tr( "Bluetooth Manager" ) ); | 66 | setCaption( tr( "Bluetooth Manager" ) ); |
65 | 67 | ||
66 | readConfig(); | 68 | readConfig(); |
67 | initGui(); | 69 | initGui(); |
68 | } | 70 | } |
69 | 71 | ||
70 | /** | 72 | /** |
71 | * Reads all options from the config file | 73 | * Reads all options from the config file |
72 | */ | 74 | */ |
73 | void BlueBase::readConfig() { | 75 | void BlueBase::readConfig() { |
74 | 76 | ||
75 | Config cfg("bluetoothmanager"); | 77 | Config cfg("bluetoothmanager"); |
76 | cfg.setGroup("bluezsettings"); | 78 | cfg.setGroup("bluezsettings"); |
77 | 79 | ||
78 | 80 | ||
79 | deviceName = cfg.readEntry("name", "No name"); // name the device should identify with | 81 | deviceName = cfg.readEntry("name", "No name"); // name the device should identify with |
80 | defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak | 82 | defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak |
81 | useEncryption = cfg.readNumEntry("useEncryption", 1); | 83 | useEncryption = cfg.readNumEntry("useEncryption", 1); |
82 | enableAuthentification = cfg.readNumEntry("enableAuthentification", 1); | 84 | enableAuthentification = cfg.readNumEntry("enableAuthentification", 1); |
83 | enablePagescan = cfg.readNumEntry("enablePagescan",1); | 85 | enablePagescan = cfg.readNumEntry("enablePagescan",1); |
84 | enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1); | 86 | enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1); |
85 | 87 | ||
86 | } | 88 | } |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * Writes all options to the config file | 91 | * Writes all options to the config file |
90 | */ | 92 | */ |
91 | void BlueBase::writeConfig() { | 93 | void BlueBase::writeConfig() { |
92 | 94 | ||
93 | 95 | ||
94 | Config cfg("bluetoothmanager"); | 96 | Config cfg("bluetoothmanager"); |
95 | cfg.setGroup("bluezsettings"); | 97 | cfg.setGroup("bluezsettings"); |
96 | 98 | ||
97 | 99 | ||
98 | cfg.writeEntry("name", deviceName); | 100 | cfg.writeEntry("name", deviceName); |
99 | cfg.writeEntryCrypt("passkey", defaultPasskey); | 101 | cfg.writeEntryCrypt("passkey", defaultPasskey); |
100 | cfg.writeEntry("useEncryption", useEncryption); | 102 | cfg.writeEntry("useEncryption", useEncryption); |
101 | cfg.writeEntry("enableAuthentification", enableAuthentification); | 103 | cfg.writeEntry("enableAuthentification", enableAuthentification); |
102 | cfg.writeEntry("enablePagescan",enablePagescan); | 104 | cfg.writeEntry("enablePagescan",enablePagescan); |
103 | cfg.writeEntry("enableInquiryscan", enableInquiryscan); | 105 | cfg.writeEntry("enableInquiryscan", enableInquiryscan); |
104 | } | 106 | } |
105 | 107 | ||
106 | 108 | ||
107 | /** | 109 | /** |
108 | * Set up the gui | 110 | * Set up the gui |
109 | */ | 111 | */ |
110 | void BlueBase::initGui() { | 112 | void BlueBase::initGui() { |
111 | 113 | ||
112 | StatusLabel->setText(getStatus()); // maybe move it to getStatus() | 114 | StatusLabel->setText(getStatus()); // maybe move it to getStatus() |
113 | 115 | ||
114 | cryptCheckBox->setChecked(useEncryption); | 116 | cryptCheckBox->setChecked(useEncryption); |
115 | authCheckBox->setChecked(enableAuthentification); | 117 | authCheckBox->setChecked(enableAuthentification); |
116 | pagescanCheckBox->setChecked(enablePagescan); | 118 | pagescanCheckBox->setChecked(enablePagescan); |
117 | inquiryscanCheckBox->setChecked(enableInquiryscan); | 119 | inquiryscanCheckBox->setChecked(enableInquiryscan); |
118 | deviceNameLine->setText(deviceName); | 120 | deviceNameLine->setText(deviceName); |
119 | passkeyLine->setText(defaultPasskey); | 121 | passkeyLine->setText(defaultPasskey); |
120 | } | 122 | } |
121 | 123 | ||
122 | 124 | ||
123 | /** | 125 | /** |
124 | * Get the status informations and returns it | 126 | * Get the status informations and returns it |
125 | * @return QString the status informations gathered | 127 | * @return QString the status informations gathered |
126 | */ | 128 | */ |
127 | QString BlueBase::getStatus(){ | 129 | QString BlueBase::getStatus(){ |
128 | 130 | ||
129 | return ("manger.h need also a status method"); | 131 | return ("manger.h need also a status method"); |
130 | 132 | ||
131 | } | 133 | } |
132 | 134 | ||
133 | 135 | ||
134 | /** | 136 | /** |
135 | * Read the current values from the gui and invoke writeConfig() | 137 | * Read the current values from the gui and invoke writeConfig() |
136 | */ | 138 | */ |
137 | void BlueBase::applyConfigChanges() { | 139 | void BlueBase::applyConfigChanges() { |
138 | 140 | ||
139 | deviceName = deviceNameLine->text(); | 141 | deviceName = deviceNameLine->text(); |
140 | defaultPasskey = passkeyLine->text(); | 142 | defaultPasskey = passkeyLine->text(); |
141 | useEncryption = cryptCheckBox->isChecked(); | 143 | useEncryption = cryptCheckBox->isChecked(); |
142 | enableAuthentification = authCheckBox->isChecked(); | 144 | enableAuthentification = authCheckBox->isChecked(); |
143 | enablePagescan = pagescanCheckBox->isChecked(); | 145 | enablePagescan = pagescanCheckBox->isChecked(); |
144 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 146 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
145 | 147 | ||
146 | writeConfig(); | 148 | writeConfig(); |
147 | 149 | ||
148 | QMessageBox* box = new QMessageBox(this, "Test"); | 150 | QMessageBox* box = new QMessageBox(this, "Test"); |
149 | box->setText(tr("Changes applied")); | 151 | box->setText(tr("Changes applied")); |
150 | box->show(); | 152 | box->show(); |
151 | 153 | ||
152 | // falls nötig hcid killhupen - die funktionalität adden | 154 | // falls nötig hcid killhupen - die funktionalität adden |
153 | } | 155 | } |
154 | 156 | ||
155 | 157 | ||
156 | void BlueBase::addSearchedDevices( QList<RemoteDevices> &newDevices ) { | 158 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { |
159 | |||
160 | QListViewItem * deviceItem; | ||
161 | |||
162 | QListIterator<RemoteDevice> it(newDevices); | ||
157 | 163 | ||
164 | for( ; it.current(); ++it ) { | ||
158 | 165 | ||
159 | 166 | ||
167 | RemoteDevice *dev = it.current(); | ||
168 | deviceItem = new QListViewItem( ListView4, dev->name() ); | ||
169 | deviceItem->setText(1, dev->mac() ); | ||
170 | } | ||
160 | } | 171 | } |
161 | 172 | ||
162 | 173 | ||
163 | /** | 174 | /** |
164 | * Open the "scan for devices" dialog | 175 | * Open the "scan for devices" dialog |
165 | */ | 176 | */ |
166 | void BlueBase::startScan() { | 177 | void BlueBase::startScan() { |
167 | ScanDialog *scan = new ScanDialog( this, "", true); | 178 | ScanDialog *scan = new ScanDialog( this, "", true); |
168 | QObject::connect((QObject*)scan, SIGNAL( selectedDevices(QList<RemoteDevices>&) ), | 179 | QObject::connect((QObject*)scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ), |
169 | this, SLOT( addSearchedDevices(QList<RemoteDevices>& ) )); | 180 | this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) )); |
170 | 181 | ||
171 | scan->showMaximized(); | 182 | scan->showMaximized(); |
172 | } | 183 | } |
173 | 184 | ||
174 | /** | 185 | /** |
175 | * Decontructor | 186 | * Decontructor |
176 | */ | 187 | */ |
177 | BlueBase::~BlueBase(){ | 188 | BlueBase::~BlueBase(){ |
178 | } | 189 | } |
179 | 190 | ||
180 | } | 191 | } |
181 | 192 | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 5364e51..c8ceed2 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,63 +1,63 @@ | |||
1 | 1 | ||
2 | #ifndef BLUEBASE_H | 2 | #ifndef BLUEBASE_H |
3 | #define BLUEBASE_H | 3 | #define BLUEBASE_H |
4 | 4 | ||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | 10 | ||
11 | #include "bluetoothbase.h" | 11 | #include "bluetoothbase.h" |
12 | 12 | ||
13 | #include <remotedevice.h> | 13 | #include <remotedevice.h> |
14 | 14 | ||
15 | class QVBox; | 15 | class QVBox; |
16 | class QHBoxLayout; | 16 | class QHBoxLayout; |
17 | class QGridLayout; | 17 | class QGridLayout; |
18 | class QFrame; | 18 | class QFrame; |
19 | class QLabel; | 19 | class QLabel; |
20 | class QPushButton; | 20 | class QPushButton; |
21 | class QTabWidget; | 21 | class QTabWidget; |
22 | class QCheckBox; | 22 | class QCheckBox; |
23 | 23 | ||
24 | namespace OpieTooth { | 24 | namespace OpieTooth { |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | class BlueBase : public BluetoothBase { | 28 | class BlueBase : public BluetoothBase { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | 30 | ||
31 | public: | 31 | public: |
32 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 32 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
33 | ~BlueBase(); | 33 | ~BlueBase(); |
34 | 34 | ||
35 | protected: | 35 | protected: |
36 | 36 | ||
37 | 37 | ||
38 | private slots: | 38 | private slots: |
39 | void startScan(); | 39 | void startScan(); |
40 | 40 | ||
41 | private: | 41 | private: |
42 | void readConfig(); | 42 | void readConfig(); |
43 | void writeConfig(); | 43 | void writeConfig(); |
44 | QString getStatus(); | 44 | QString getStatus(); |
45 | void initGui(); | 45 | void initGui(); |
46 | 46 | ||
47 | 47 | ||
48 | QString deviceName; | 48 | QString deviceName; |
49 | QString defaultPasskey; | 49 | QString defaultPasskey; |
50 | int useEncryption; | 50 | int useEncryption; |
51 | int enableAuthentification; | 51 | int enableAuthentification; |
52 | int enablePagescan; | 52 | int enablePagescan; |
53 | int enableInquiryscan; | 53 | int enableInquiryscan; |
54 | 54 | ||
55 | private slots: | 55 | private slots: |
56 | void addSearchedDevices( QList<RemoteDevices> &newDevices ); | 56 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); |
57 | void applyConfigChanges(); | 57 | void applyConfigChanges(); |
58 | 58 | ||
59 | }; | 59 | }; |
60 | 60 | ||
61 | } | 61 | } |
62 | 62 | ||
63 | #endif | 63 | #endif |
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 8a7ea01..bd7d23c 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -1,169 +1,169 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | 20 | ||
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qheader.h> | 22 | #include <qheader.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvariant.h> | 27 | #include <qvariant.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #include <qprogressbar.h> | 30 | #include <qprogressbar.h> |
31 | #include <qlist.h> | 31 | #include <qlist.h> |
32 | 32 | ||
33 | #include <manager.h> | 33 | #include <manager.h> |
34 | #include <device.h> | 34 | #include <device.h> |
35 | 35 | ||
36 | 36 | ||
37 | 37 | ||
38 | namespace OpieTooth { | 38 | namespace OpieTooth { |
39 | 39 | ||
40 | #include <remotedevice.h> | 40 | #include <remotedevice.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | */ | 43 | */ |
44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
45 | : QDialog( parent, name, modal, fl ) { | 45 | : QDialog( parent, name, modal, fl ) { |
46 | 46 | ||
47 | if ( !name ) | 47 | if ( !name ) |
48 | setName( "ScanDialog" ); | 48 | setName( "ScanDialog" ); |
49 | resize( 240, 320 ); | 49 | resize( 240, 320 ); |
50 | setCaption( tr( "Scan for devices" ) ); | 50 | setCaption( tr( "Scan for devices" ) ); |
51 | 51 | ||
52 | Frame7 = new QFrame( this, "Frame7" ); | 52 | Frame7 = new QFrame( this, "Frame7" ); |
53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); | 53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); |
54 | Frame7->setFrameShape( QFrame::StyledPanel ); | 54 | Frame7->setFrameShape( QFrame::StyledPanel ); |
55 | Frame7->setFrameShadow( QFrame::Raised ); | 55 | Frame7->setFrameShadow( QFrame::Raised ); |
56 | 56 | ||
57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | 57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); |
58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); | 58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); |
59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); | 59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); |
60 | Layout11->setSpacing( 6 ); | 60 | Layout11->setSpacing( 6 ); |
61 | Layout11->setMargin( 0 ); | 61 | Layout11->setMargin( 0 ); |
62 | 62 | ||
63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); | 63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); |
64 | progress->setTotalSteps(20); | 64 | progress->setTotalSteps(20); |
65 | 65 | ||
66 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
67 | 67 | ||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start scan" ) ); | 69 | StartButton->setText( tr( "Start scan" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | 71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); |
72 | StopButton->setText( tr( "Cancel scan" ) ); | 72 | StopButton->setText( tr( "Cancel scan" ) ); |
73 | 73 | ||
74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
75 | 75 | ||
76 | buttonLayout->addWidget(StartButton); | 76 | buttonLayout->addWidget(StartButton); |
77 | buttonLayout->addWidget(StopButton); | 77 | buttonLayout->addWidget(StopButton); |
78 | 78 | ||
79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
80 | 80 | ||
81 | //ListView1->addColumn( tr( "Add" ) ); | 81 | //ListView1->addColumn( tr( "Add" ) ); |
82 | ListView1->addColumn( tr( "Add Device" ) ); | 82 | ListView1->addColumn( tr( "Add Device" ) ); |
83 | //ListView1->addColumn( tr( "Type" ) ); | 83 | //ListView1->addColumn( tr( "Type" ) ); |
84 | 84 | ||
85 | Layout11->addWidget( ListView1); | 85 | Layout11->addWidget( ListView1); |
86 | Layout11->addWidget(progress); | 86 | Layout11->addWidget(progress); |
87 | Layout11->addWidget( buttonFrame); | 87 | Layout11->addWidget( buttonFrame); |
88 | 88 | ||
89 | localDevice = new Manager( "hci0" ); | 89 | localDevice = new Manager( "hci0" ); |
90 | 90 | ||
91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | 92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); |
93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), | 93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), |
94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; | 94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; |
95 | progressStat = 0; | 95 | progressStat = 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | // hack, make cleaner later | 98 | // hack, make cleaner later |
99 | void ScanDialog::progressTimer() { | 99 | void ScanDialog::progressTimer() { |
100 | 100 | ||
101 | progressStat++; | 101 | progressStat++; |
102 | if (progressStat++ < 20) { | 102 | if (progressStat++ < 20) { |
103 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); | 103 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); |
104 | } | 104 | } |
105 | progress->setProgress(progressStat++); | 105 | progress->setProgress(progressStat++); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | void ScanDialog::startSearch() { | 109 | void ScanDialog::startSearch() { |
110 | progress->setProgress(0); | 110 | progress->setProgress(0); |
111 | progressStat = 0; | 111 | progressStat = 0; |
112 | 112 | ||
113 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); | 113 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); |
114 | deviceItem2->setText(1, "BLAH" ); | 114 | deviceItem2->setText(1, "BLAH" ); |
115 | 115 | ||
116 | progressTimer(); | 116 | progressTimer(); |
117 | // when finished, it emmite foundDevices() | 117 | // when finished, it emmite foundDevices() |
118 | // checken ob initialisiert , qcop ans applet. | 118 | // checken ob initialisiert , qcop ans applet. |
119 | localDevice->searchDevices(); | 119 | localDevice->searchDevices(); |
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | void ScanDialog::stopSearch() { | 123 | void ScanDialog::stopSearch() { |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { | 127 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { |
128 | 128 | ||
129 | QCheckListItem * deviceItem; | 129 | QCheckListItem * deviceItem; |
130 | 130 | ||
131 | RemoteDevices::ValueList::Iterator it; | 131 | RemoteDevice::ValueList::Iterator it; |
132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
133 | 133 | ||
134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); | 134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); |
135 | deviceItem->setText(1, (*it).mac() ); | 135 | deviceItem->setText(1, (*it).mac() ); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * Iterates trough the items, and collects the checked items. | 140 | * Iterates trough the items, and collects the checked items. |
141 | * Then it emits it, so the manager can connect to the signal to fill the listing. | 141 | * Then it emits it, so the manager can connect to the signal to fill the listing. |
142 | */ | 142 | */ |
143 | void ScanDialog::emitToManager() { | 143 | void ScanDialog::emitToManager() { |
144 | 144 | ||
145 | if (!ListView1) { | 145 | if (!ListView1) { |
146 | return; | 146 | return; |
147 | } | 147 | } |
148 | 148 | ||
149 | QList<RemoteDevices> *deviceList = new QList<RemoteDevices>; | 149 | QList<RemoteDevice> *deviceList = new QList<RemoteDevice>; |
150 | 150 | ||
151 | QListViewItemIterator it( ListView1 ); | 151 | QListViewItemIterator it( ListView1 ); |
152 | for ( ; it.current(); ++it ) { | 152 | for ( ; it.current(); ++it ) { |
153 | if ( ((QCheckListItem*)it.current())->isOn() ) { | 153 | if ( ((QCheckListItem*)it.current())->isOn() ) { |
154 | RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0)); | 154 | RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0)); |
155 | deviceList->append( device ); | 155 | deviceList->append( device ); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | emit selectedDevices( *deviceList ); | 158 | emit selectedDevices( *deviceList ); |
159 | } | 159 | } |
160 | 160 | ||
161 | /* | 161 | /* |
162 | * Cleanup | 162 | * Cleanup |
163 | */ | 163 | */ |
164 | ScanDialog::~ScanDialog() { | 164 | ScanDialog::~ScanDialog() { |
165 | emitToManager(); | 165 | emitToManager(); |
166 | delete localDevice; | 166 | delete localDevice; |
167 | } | 167 | } |
168 | 168 | ||
169 | } | 169 | } |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index 0ca302a..adc960c 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -1,77 +1,77 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
3 | * copyright : (c) 2002 by Maximilian Reiß | 3 | * copyright : (c) 2002 by Maximilian Reiß |
4 | * email : max.reiss@gmx.de | 4 | * email : max.reiss@gmx.de |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | /*************************************************************************** | 7 | /*************************************************************************** |
8 | * * | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License as published by * | 10 | * it under the terms of the GNU General Public License as published by * |
11 | * the Free Software Foundation; either version 2 of the License, or * | 11 | * the Free Software Foundation; either version 2 of the License, or * |
12 | * (at your option) any later version. * | 12 | * (at your option) any later version. * |
13 | * * | 13 | * * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | 15 | ||
16 | 16 | ||
17 | #ifndef SCANDIALOG_H | 17 | #ifndef SCANDIALOG_H |
18 | #define SCANDIALOG_H | 18 | #define SCANDIALOG_H |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qlist.h> | 22 | #include <qlist.h> |
23 | 23 | ||
24 | #include <remotedevice.h> | 24 | #include <remotedevice.h> |
25 | class QVBoxLayout; | 25 | class QVBoxLayout; |
26 | class QHBoxLayout; | 26 | class QHBoxLayout; |
27 | class QGridLayout; | 27 | class QGridLayout; |
28 | class QFrame; | 28 | class QFrame; |
29 | class QLabel; | 29 | class QLabel; |
30 | class QListView; | 30 | class QListView; |
31 | class QListViewItem; | 31 | class QListViewItem; |
32 | class QPushButton; | 32 | class QPushButton; |
33 | class QProgressBar; | 33 | class QProgressBar; |
34 | 34 | ||
35 | 35 | ||
36 | namespace OpieTooth { | 36 | namespace OpieTooth { |
37 | 37 | ||
38 | 38 | ||
39 | class Manager; | 39 | class Manager; |
40 | class Device; | 40 | class Device; |
41 | 41 | ||
42 | class ScanDialog : public QDialog { | 42 | class ScanDialog : public QDialog { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
47 | ~ScanDialog(); | 47 | ~ScanDialog(); |
48 | 48 | ||
49 | QFrame* Frame7; | 49 | QFrame* Frame7; |
50 | QProgressBar* progress; | 50 | QProgressBar* progress; |
51 | QPushButton* StartButton; | 51 | QPushButton* StartButton; |
52 | QPushButton* StopButton; | 52 | QPushButton* StopButton; |
53 | QListView* ListView1; | 53 | QListView* ListView1; |
54 | 54 | ||
55 | 55 | ||
56 | protected: | 56 | protected: |
57 | QVBoxLayout* Layout11; | 57 | QVBoxLayout* Layout11; |
58 | 58 | ||
59 | private slots: | 59 | private slots: |
60 | void stopSearch(); | 60 | void stopSearch(); |
61 | void startSearch(); | 61 | void startSearch(); |
62 | void progressTimer(); | 62 | void progressTimer(); |
63 | void fillList(const QString& device, RemoteDevices::ValueList list); | 63 | void fillList(const QString& device, RemoteDevice::ValueList list); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | void emitToManager(); | 66 | void emitToManager(); |
67 | Manager *localDevice; | 67 | Manager *localDevice; |
68 | int progressStat; | 68 | int progressStat; |
69 | 69 | ||
70 | signals: | 70 | signals: |
71 | void selectedDevices(QList<RemoteDevices>&); | 71 | void selectedDevices(QList<RemoteDevice>&); |
72 | }; | 72 | }; |
73 | 73 | ||
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | #endif // SCANDIALOG_H | 77 | #endif // SCANDIALOG_H |