summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/scandialog.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opietooth/manager/scandialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp35
1 files changed, 22 insertions, 13 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 {
progress = new QProgressBar(privateLayoutWidget, "progbar");
progress->setTotalSteps(20);
QFrame *buttonFrame = new QFrame(Frame7, "");
- StartButton = new QPushButton( buttonFrame, "StartButton" );
- StartButton->setText( tr( "Start scan" ) );
+ StartStopButton = new QPushButton( buttonFrame, "StartButton" );
+ StartStopButton->setText( tr( "Start scan" ) );
- StopButton = new QPushButton( buttonFrame, "StopButton" );
- StopButton->setText( tr( "Cancel scan" ) );
QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame);
- buttonLayout->addWidget(StartButton);
- buttonLayout->addWidget(StopButton);
+ buttonLayout->addWidget(StartStopButton);
+// buttonLayout->addWidget(StopButton);
ListView1 = new QListView( privateLayoutWidget, "ListView1" );
//ListView1->addColumn( tr( "Add" ) );
ListView1->addColumn( tr( "Add Device" ) );
//ListView1->addColumn( tr( "Type" ) );
@@ -85,69 +83,79 @@ namespace OpieTooth {
Layout11->addWidget( ListView1);
Layout11->addWidget(progress);
Layout11->addWidget( buttonFrame);
localDevice = new Manager( "hci0" );
- connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
- connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
+ connect( StartStopButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ),
this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ;
// connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() ));
progressStat = 0;
+ m_search = false;
}
// hack, make cleaner later
void ScanDialog::progressTimer() {
progressStat++;
- if (progressStat++ < 20) {
+ if (progressStat++ < 20 && m_search ) {
QTimer::singleShot( 2000, this, SLOT(progressTimer() ) );
- }
progress->setProgress(progressStat++);
+ }
}
void ScanDialog::accept() {
emitToManager();
QDialog::accept();
}
void ScanDialog::startSearch() {
+ if ( m_search ) {
+ stopSearch();
+ return;
+ }
+ m_search = true;
progress->setProgress(0);
progressStat = 0;
// empty list before a new scan
ListView1->clear();
QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
deviceItem2->setText(1, "BLAH" );
progressTimer();
// when finished, it emmite foundDevices()
// checken ob initialisiert , qcop ans applet.
+ StartStopButton->setText( tr("Stop scan"));
+
localDevice->searchDevices();
}
void ScanDialog::stopSearch() {
-
+ m_search = true;
}
- void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
-
+ void ScanDialog::fillList(const QString&, RemoteDevice::ValueList deviceList) {
+ progress->setProgress(0);
+ progressStat = 0;
qDebug("fill List");
QCheckListItem * deviceItem;
RemoteDevice::ValueList::Iterator it;
for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox );
deviceItem->setText(1, (*it).mac() );
}
+ m_search = false;
+ StartStopButton->setText(tr ("Start scan") );
}
/*
* Iterates trough the items, and collects the checked items.
* Then it emits it, so the manager can connect to the signal to fill the listing.
*/
@@ -172,10 +180,11 @@ namespace OpieTooth {
}
/*
* Cleanup
*/
ScanDialog::~ScanDialog() {
+ qWarning("delete scan dialog");
delete localDevice;
}
}