author | harlekin <harlekin> | 2003-02-16 10:04:28 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-02-16 10:04:28 (UTC) |
commit | fb16f3317916704eca14d35271d48130bfa78c6c (patch) (unidiff) | |
tree | 2a68df6a2938466c6d8e7e446730c5794bd61a8d | |
parent | f1737ebd1afc35528c2452f6a281039c39a28f1f (diff) | |
download | opie-fb16f3317916704eca14d35271d48130bfa78c6c.zip opie-fb16f3317916704eca14d35271d48130bfa78c6c.tar.gz opie-fb16f3317916704eca14d35271d48130bfa78c6c.tar.bz2 |
cleaned the scandialog
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 69 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 13 |
2 files changed, 24 insertions, 58 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 9ce1b6a..de4f742 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -15,15 +15,13 @@ | |||
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | 20 | ||
21 | #include <qframe.h> | ||
22 | #include <qheader.h> | 21 | #include <qheader.h> |
23 | #include <qlabel.h> | ||
24 | #include <qlistview.h> | 22 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
26 | #include <qlayout.h> | 24 | #include <qlayout.h> |
27 | #include <qvariant.h> | 25 | #include <qvariant.h> |
28 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
29 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
@@ -31,81 +29,61 @@ | |||
31 | #include <qlist.h> | 29 | #include <qlist.h> |
32 | 30 | ||
33 | #include <manager.h> | 31 | #include <manager.h> |
34 | #include <device.h> | 32 | #include <device.h> |
35 | 33 | ||
36 | 34 | ||
37 | |||
38 | namespace OpieTooth { | 35 | namespace OpieTooth { |
39 | 36 | ||
40 | #include <remotedevice.h> | 37 | #include <remotedevice.h> |
41 | 38 | ||
42 | /* | 39 | /** |
43 | */ | 40 | */ |
44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 41 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
45 | : QDialog( parent, name, modal, fl ) { | 42 | : QDialog( parent, name, modal, fl ) { |
46 | 43 | ||
47 | if ( !name ) | ||
48 | setName( "ScanDialog" ); | ||
49 | resize( 240, 320 ); | ||
50 | setCaption( tr( "Scan for devices" ) ); | 44 | setCaption( tr( "Scan for devices" ) ); |
51 | 45 | ||
52 | Frame7 = new QFrame( this, "Frame7" ); | 46 | Layout11 = new QVBoxLayout( this ); |
53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); | ||
54 | Frame7->setFrameShape( QFrame::StyledPanel ); | ||
55 | Frame7->setFrameShadow( QFrame::Raised ); | ||
56 | |||
57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | ||
58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); | ||
59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); | ||
60 | Layout11->setSpacing( 6 ); | 47 | Layout11->setSpacing( 6 ); |
61 | Layout11->setMargin( 0 ); | 48 | Layout11->setMargin( 0 ); |
62 | 49 | ||
63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); | 50 | progress = new QProgressBar( this, "progbar"); |
64 | progress->setTotalSteps(20); | 51 | progress->setTotalSteps(20); |
65 | 52 | ||
66 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 53 | StartStopButton = new QPushButton( this, "StartButton" ); |
67 | |||
68 | StartStopButton = new QPushButton( buttonFrame, "StartButton" ); | ||
69 | StartStopButton->setText( tr( "Start scan" ) ); | 54 | StartStopButton->setText( tr( "Start scan" ) ); |
70 | 55 | ||
71 | 56 | ListView1 = new QListView( this, "ListView1" ); | |
72 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | ||
73 | |||
74 | buttonLayout->addWidget(StartStopButton); | ||
75 | //buttonLayout->addWidget(StopButton); | ||
76 | |||
77 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | ||
78 | 57 | ||
79 | //ListView1->addColumn( tr( "Add" ) ); | 58 | //ListView1->addColumn( tr( "Add" ) ); |
80 | ListView1->addColumn( tr( "Add Device" ) ); | 59 | ListView1->addColumn( tr( "Add Device" ) ); |
81 | //ListView1->addColumn( tr( "Type" ) ); | 60 | //ListView1->addColumn( tr( "Type" ) ); |
82 | 61 | ||
83 | Layout11->addWidget( ListView1); | 62 | Layout11->addWidget( ListView1 ); |
84 | Layout11->addWidget(progress); | 63 | Layout11->addWidget( progress ); |
85 | Layout11->addWidget( buttonFrame); | 64 | Layout11->addWidget( StartStopButton ); |
86 | 65 | ||
87 | localDevice = new Manager( "hci0" ); | 66 | localDevice = new Manager( "hci0" ); |
88 | 67 | ||
89 | connect( StartStopButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 68 | connect( StartStopButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
90 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), | 69 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), |
91 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; | 70 | this, SLOT( fillList( const QString& , RemoteDevice::ValueList ) ) ) ; |
92 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); | 71 | |
93 | progressStat = 0; | 72 | progressStat = 0; |
94 | m_search = false; | 73 | m_search = false; |
95 | } | 74 | } |
96 | 75 | ||
97 | // hack, make cleaner later | 76 | // hack, make cleaner later |
98 | void ScanDialog::progressTimer() { | 77 | void ScanDialog::progressTimer() { |
99 | 78 | ||
100 | progressStat++; | 79 | progressStat++; |
101 | if (progressStat++ < 20 && m_search ) { | 80 | if ( progressStat++ < 20 && m_search ) { |
102 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); | 81 | QTimer::singleShot( 2000, this, SLOT( progressTimer() ) ); |
103 | progress->setProgress(progressStat++); | 82 | progress->setProgress( progressStat++ ); |
104 | } | 83 | } |
105 | |||
106 | } | 84 | } |
107 | 85 | ||
108 | void ScanDialog::accept() { | 86 | void ScanDialog::accept() { |
109 | emitToManager(); | 87 | emitToManager(); |
110 | QDialog::accept(); | 88 | QDialog::accept(); |
111 | } | 89 | } |
@@ -120,71 +98,64 @@ namespace OpieTooth { | |||
120 | progress->setProgress(0); | 98 | progress->setProgress(0); |
121 | progressStat = 0; | 99 | progressStat = 0; |
122 | 100 | ||
123 | // empty list before a new scan | 101 | // empty list before a new scan |
124 | ListView1->clear(); | 102 | ListView1->clear(); |
125 | 103 | ||
126 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); | ||
127 | deviceItem2->setText(1, "BLAH" ); | ||
128 | |||
129 | progressTimer(); | 104 | progressTimer(); |
130 | // when finished, it emmite foundDevices() | 105 | // when finished, it emmite foundDevices() |
131 | // checken ob initialisiert , qcop ans applet. | 106 | // checken ob initialisiert , qcop ans applet. |
132 | StartStopButton->setText( tr("Stop scan")); | 107 | StartStopButton->setText( tr( "Stop scan" ) ); |
133 | 108 | ||
134 | localDevice->searchDevices(); | 109 | localDevice->searchDevices(); |
135 | 110 | ||
136 | } | 111 | } |
137 | 112 | ||
138 | void ScanDialog::stopSearch() { | 113 | void ScanDialog::stopSearch() { |
139 | m_search = true; | 114 | m_search = true; |
140 | } | 115 | } |
141 | 116 | ||
142 | void ScanDialog::fillList(const QString&, RemoteDevice::ValueList deviceList) { | 117 | void ScanDialog::fillList(const QString&, RemoteDevice::ValueList deviceList) { |
143 | progress->setProgress(0); | 118 | progress->setProgress(0); |
144 | progressStat = 0; | 119 | progressStat = 0; |
145 | qDebug("fill List"); | ||
146 | QCheckListItem * deviceItem; | 120 | QCheckListItem * deviceItem; |
147 | 121 | ||
148 | RemoteDevice::ValueList::Iterator it; | 122 | RemoteDevice::ValueList::Iterator it; |
149 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 123 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
150 | 124 | ||
151 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); | 125 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); |
152 | deviceItem->setText(1, (*it).mac() ); | 126 | deviceItem->setText( 1, (*it).mac() ); |
153 | } | 127 | } |
154 | m_search = false; | 128 | m_search = false; |
155 | StartStopButton->setText(tr ("Start scan") ); | 129 | StartStopButton->setText( tr( "Start scan" ) ); |
156 | } | 130 | } |
157 | 131 | ||
158 | /* | 132 | /** |
159 | * Iterates trough the items, and collects the checked items. | 133 | * Iterates trough the items, and collects the checked items. |
160 | * Then it emits it, so the manager can connect to the signal to fill the listing. | 134 | * Then it emits it, so the manager can connect to the signal to fill the listing. |
161 | */ | 135 | */ |
162 | void ScanDialog::emitToManager() { | 136 | void ScanDialog::emitToManager() { |
163 | qDebug("vor liste durchsuchen"); | ||
164 | 137 | ||
165 | if (!ListView1) { | 138 | if (!ListView1) { |
166 | return; | 139 | return; |
167 | } | 140 | } |
168 | 141 | ||
169 | QValueList<RemoteDevice> deviceList; | 142 | QValueList<RemoteDevice> deviceList; |
170 | 143 | ||
171 | QListViewItemIterator it( ListView1 ); | 144 | QListViewItemIterator it( ListView1 ); |
172 | for ( ; it.current(); ++it ) { | 145 | for ( ; it.current(); ++it ) { |
173 | if ( ((QCheckListItem*)it.current())->isOn() ) { | 146 | if ( ( (QCheckListItem*)it.current() )->isOn() ) { |
174 | RemoteDevice device( it.current()->text(1), it.current()->text(0)); | 147 | RemoteDevice device( it.current()->text(1), it.current()->text(0) ); |
175 | deviceList.append( device ); | 148 | deviceList.append( device ); |
176 | } | 149 | } |
177 | } | 150 | } |
178 | qDebug("vor emit"); | ||
179 | emit selectedDevices( deviceList ); | 151 | emit selectedDevices( deviceList ); |
180 | } | 152 | } |
181 | 153 | ||
182 | /* | 154 | /** |
183 | * Cleanup | 155 | * Cleanup |
184 | */ | 156 | */ |
185 | ScanDialog::~ScanDialog() { | 157 | ScanDialog::~ScanDialog() { |
186 | qWarning("delete scan dialog"); | 158 | qWarning("delete scan dialog"); |
187 | delete localDevice; | 159 | delete localDevice; |
188 | } | 160 | } |
189 | |||
190 | } | 161 | } |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index 8f8d39a..a644e96 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -20,62 +20,57 @@ | |||
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; | ||
27 | class QGridLayout; | 26 | class QGridLayout; |
28 | class QFrame; | ||
29 | class QLabel; | 27 | class QLabel; |
30 | class QListView; | 28 | class QListView; |
31 | class QListViewItem; | 29 | class QListViewItem; |
32 | class QPushButton; | 30 | class QPushButton; |
33 | class QProgressBar; | 31 | class QProgressBar; |
34 | 32 | ||
35 | 33 | ||
36 | namespace OpieTooth { | 34 | namespace OpieTooth { |
37 | 35 | ||
38 | |||
39 | class Manager; | 36 | class Manager; |
40 | class Device; | 37 | class Device; |
41 | 38 | ||
42 | class ScanDialog : public QDialog { | 39 | class ScanDialog : public QDialog { |
43 | Q_OBJECT | 40 | Q_OBJECT |
44 | 41 | ||
45 | public: | 42 | public: |
46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 43 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
47 | ~ScanDialog(); | 44 | ~ScanDialog(); |
48 | 45 | ||
49 | private: // make them private -zecke | 46 | private: |
50 | QFrame* Frame7; | 47 | QProgressBar* progress; |
51 | QProgressBar* progress; | ||
52 | QPushButton* StartStopButton; | 48 | QPushButton* StartStopButton; |
53 | // QPushButton* StopButton; | ||
54 | QListView* ListView1; | 49 | QListView* ListView1; |
55 | 50 | ||
56 | public slots: | 51 | public slots: |
57 | void accept(); | 52 | void accept(); |
58 | 53 | ||
59 | protected: | 54 | protected: |
60 | QVBoxLayout* Layout11; | 55 | QVBoxLayout* Layout11; |
61 | 56 | ||
62 | private slots: | 57 | private slots: |
63 | void stopSearch(); | 58 | void stopSearch(); |
64 | void startSearch(); | 59 | void startSearch(); |
65 | void progressTimer(); | 60 | void progressTimer(); |
66 | void fillList(const QString& device, RemoteDevice::ValueList list); | 61 | void fillList( const QString& device, RemoteDevice::ValueList list ); |
67 | 62 | ||
68 | private: | 63 | private: |
69 | bool m_search:1; | 64 | bool m_search:1; |
70 | void emitToManager(); | 65 | void emitToManager(); |
71 | Manager *localDevice; | 66 | Manager *localDevice; |
72 | int progressStat; | 67 | int progressStat; |
73 | 68 | ||
74 | signals: | 69 | signals: |
75 | void selectedDevices(const QValueList<RemoteDevice>&); | 70 | void selectedDevices( const QValueList<RemoteDevice>& ); |
76 | }; | 71 | }; |
77 | 72 | ||
78 | 73 | ||
79 | } | 74 | } |
80 | 75 | ||
81 | #endif // SCANDIALOG_H | 76 | #endif // SCANDIALOG_H |