summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp21
-rw-r--r--noncore/net/opietooth/manager/scandialog.h4
2 files changed, 18 insertions, 7 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index f8f7b15..ec8df82 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -67,105 +67,114 @@ namespace OpieTooth {
StartButton = new QPushButton( buttonFrame, "StartButton" );
StartButton->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);
ListView1 = new QListView( privateLayoutWidget, "ListView1" );
//ListView1->addColumn( tr( "Add" ) );
ListView1->addColumn( tr( "Add Device" ) );
//ListView1->addColumn( tr( "Type" ) );
Layout11->addWidget( ListView1);
Layout11->addWidget(progress);
Layout11->addWidget( buttonFrame);
localDevice = new Manager( "hci0" );
- connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
- connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
- connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ),
- this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ;
+ connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
+ connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
+ connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ),
+ this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ;
+ // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() ));
progressStat = 0;
}
// hack, make cleaner later
void ScanDialog::progressTimer() {
progressStat++;
if (progressStat++ < 20) {
QTimer::singleShot( 1000, this, SLOT(progressTimer() ) );
}
progress->setProgress(progressStat++);
}
+ void ScanDialog::accept() {
+ emitToManager();
+ QDialog::accept();
+ }
+
+
void ScanDialog::startSearch() {
progress->setProgress(0);
progressStat = 0;
QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
deviceItem2->setText(1, "BLAH" );
progressTimer();
// when finished, it emmite foundDevices()
// checken ob initialisiert , qcop ans applet.
localDevice->searchDevices();
}
void ScanDialog::stopSearch() {
}
void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
+ qDebug("fill List");
QCheckListItem * deviceItem;
RemoteDevice::ValueList::Iterator it;
for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
- deviceItem = new QCheckListItem( ListView1, (*it).name() );
+ deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox );
deviceItem->setText(1, (*it).mac() );
}
}
/*
* 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.
*/
void ScanDialog::emitToManager() {
+ qDebug("vor liste durchsuchen");
if (!ListView1) {
return;
}
QList<RemoteDevice> *deviceList = new QList<RemoteDevice>;
deviceList->setAutoDelete(true);
QListViewItemIterator it( ListView1 );
for ( ; it.current(); ++it ) {
if ( ((QCheckListItem*)it.current())->isOn() ) {
RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0));
deviceList->append( device );
}
}
+ qDebug("vor emit");
emit selectedDevices( *deviceList );
delete deviceList;
}
/*
* Cleanup
*/
ScanDialog::~ScanDialog() {
- emitToManager();
delete localDevice;
}
}
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h
index adc960c..7c84ce2 100644
--- a/noncore/net/opietooth/manager/scandialog.h
+++ b/noncore/net/opietooth/manager/scandialog.h
@@ -31,47 +31,49 @@ 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 progressTimer();
void fillList(const QString& device, RemoteDevice::ValueList list);
private:
void emitToManager();
Manager *localDevice;
int progressStat;
signals:
void selectedDevices(QList<RemoteDevice>&);
};
}
#endif // SCANDIALOG_H