author | zecke <zecke> | 2002-07-14 18:04:14 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-14 18:04:14 (UTC) |
commit | 26c7e63572e729b4846e4f7551bb041aa6d4bd83 (patch) (unidiff) | |
tree | 5c3bc09142bd19e84fbebb88f2e37b02e6d603cd /noncore/net/opietooth/manager/scandialog.cpp | |
parent | 31e233a6cf72bc853137ea05285f4d0f41665365 (diff) | |
download | opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.zip opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.tar.gz opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.tar.bz2 |
- able to configure HCID
- able to save and restore known devices
- able to scan servivces and shows the right pixmap too
- able to do some more
- scan dialog clean up ( tiny )
Diffstat (limited to 'noncore/net/opietooth/manager/scandialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 3d6c928..9ce1b6a 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -62,22 +62,20 @@ namespace OpieTooth { | |||
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 | StartStopButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start scan" ) ); | 69 | StartStopButton->setText( tr( "Start scan" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | ||
72 | StopButton->setText( tr( "Cancel scan" ) ); | ||
73 | 71 | ||
74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 72 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
75 | 73 | ||
76 | buttonLayout->addWidget(StartButton); | 74 | buttonLayout->addWidget(StartStopButton); |
77 | buttonLayout->addWidget(StopButton); | 75 | //buttonLayout->addWidget(StopButton); |
78 | 76 | ||
79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 77 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
80 | 78 | ||
81 | //ListView1->addColumn( tr( "Add" ) ); | 79 | //ListView1->addColumn( tr( "Add" ) ); |
82 | ListView1->addColumn( tr( "Add Device" ) ); | 80 | ListView1->addColumn( tr( "Add Device" ) ); |
83 | //ListView1->addColumn( tr( "Type" ) ); | 81 | //ListView1->addColumn( tr( "Type" ) ); |
@@ -85,69 +83,79 @@ namespace OpieTooth { | |||
85 | Layout11->addWidget( ListView1); | 83 | Layout11->addWidget( ListView1); |
86 | Layout11->addWidget(progress); | 84 | Layout11->addWidget(progress); |
87 | Layout11->addWidget( buttonFrame); | 85 | Layout11->addWidget( buttonFrame); |
88 | 86 | ||
89 | localDevice = new Manager( "hci0" ); | 87 | localDevice = new Manager( "hci0" ); |
90 | 88 | ||
91 | connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 89 | connect( StartStopButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | ||
93 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), | 90 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), |
94 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; | 91 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; |
95 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); | 92 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); |
96 | progressStat = 0; | 93 | progressStat = 0; |
94 | m_search = false; | ||
97 | } | 95 | } |
98 | 96 | ||
99 | // hack, make cleaner later | 97 | // hack, make cleaner later |
100 | void ScanDialog::progressTimer() { | 98 | void ScanDialog::progressTimer() { |
101 | 99 | ||
102 | progressStat++; | 100 | progressStat++; |
103 | if (progressStat++ < 20) { | 101 | if (progressStat++ < 20 && m_search ) { |
104 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); | 102 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); |
105 | } | ||
106 | progress->setProgress(progressStat++); | 103 | progress->setProgress(progressStat++); |
104 | } | ||
107 | 105 | ||
108 | } | 106 | } |
109 | 107 | ||
110 | void ScanDialog::accept() { | 108 | void ScanDialog::accept() { |
111 | emitToManager(); | 109 | emitToManager(); |
112 | QDialog::accept(); | 110 | QDialog::accept(); |
113 | } | 111 | } |
114 | 112 | ||
115 | 113 | ||
116 | void ScanDialog::startSearch() { | 114 | void ScanDialog::startSearch() { |
115 | if ( m_search ) { | ||
116 | stopSearch(); | ||
117 | return; | ||
118 | } | ||
119 | m_search = true; | ||
117 | progress->setProgress(0); | 120 | progress->setProgress(0); |
118 | progressStat = 0; | 121 | progressStat = 0; |
119 | 122 | ||
120 | // empty list before a new scan | 123 | // empty list before a new scan |
121 | ListView1->clear(); | 124 | ListView1->clear(); |
122 | 125 | ||
123 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); | 126 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); |
124 | deviceItem2->setText(1, "BLAH" ); | 127 | deviceItem2->setText(1, "BLAH" ); |
125 | 128 | ||
126 | progressTimer(); | 129 | progressTimer(); |
127 | // when finished, it emmite foundDevices() | 130 | // when finished, it emmite foundDevices() |
128 | // checken ob initialisiert , qcop ans applet. | 131 | // checken ob initialisiert , qcop ans applet. |
132 | StartStopButton->setText( tr("Stop scan")); | ||
133 | |||
129 | localDevice->searchDevices(); | 134 | localDevice->searchDevices(); |
130 | 135 | ||
131 | } | 136 | } |
132 | 137 | ||
133 | void ScanDialog::stopSearch() { | 138 | void ScanDialog::stopSearch() { |
134 | 139 | m_search = true; | |
135 | } | 140 | } |
136 | 141 | ||
137 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { | 142 | void ScanDialog::fillList(const QString&, RemoteDevice::ValueList deviceList) { |
138 | 143 | progress->setProgress(0); | |
144 | progressStat = 0; | ||
139 | qDebug("fill List"); | 145 | qDebug("fill List"); |
140 | QCheckListItem * deviceItem; | 146 | QCheckListItem * deviceItem; |
141 | 147 | ||
142 | RemoteDevice::ValueList::Iterator it; | 148 | RemoteDevice::ValueList::Iterator it; |
143 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 149 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
144 | 150 | ||
145 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); | 151 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); |
146 | deviceItem->setText(1, (*it).mac() ); | 152 | deviceItem->setText(1, (*it).mac() ); |
147 | } | 153 | } |
154 | m_search = false; | ||
155 | StartStopButton->setText(tr ("Start scan") ); | ||
148 | } | 156 | } |
149 | 157 | ||
150 | /* | 158 | /* |
151 | * Iterates trough the items, and collects the checked items. | 159 | * Iterates trough the items, and collects the checked items. |
152 | * Then it emits it, so the manager can connect to the signal to fill the listing. | 160 | * Then it emits it, so the manager can connect to the signal to fill the listing. |
153 | */ | 161 | */ |
@@ -172,10 +180,11 @@ namespace OpieTooth { | |||
172 | } | 180 | } |
173 | 181 | ||
174 | /* | 182 | /* |
175 | * Cleanup | 183 | * Cleanup |
176 | */ | 184 | */ |
177 | ScanDialog::~ScanDialog() { | 185 | ScanDialog::~ScanDialog() { |
186 | qWarning("delete scan dialog"); | ||
178 | delete localDevice; | 187 | delete localDevice; |
179 | } | 188 | } |
180 | 189 | ||
181 | } | 190 | } |