summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/scandialog.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/scandialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp46
1 files changed, 39 insertions, 7 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index 63c5472..70ea77a 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -19,32 +19,35 @@
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 32
32#include <manager.h> 33#include <manager.h>
33#include <device.h> 34#include <device.h>
34#include <remotedevice.h> 35
35 36
36 37
37namespace OpieTooth { 38namespace OpieTooth {
38 39
40#include <remotedevice.h>
41
39/* 42/*
40 */ 43 */
41 ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 44 ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
42 : QDialog( parent, name, modal, fl ) { 45 : QDialog( parent, name, modal, fl ) {
43 46
44 if ( !name ) 47 if ( !name )
45 setName( "ScanDialog" ); 48 setName( "ScanDialog" );
46 resize( 240, 320 ); 49 resize( 240, 320 );
47 setCaption( tr( "Scan for devices" ) ); 50 setCaption( tr( "Scan for devices" ) );
48 51
49 Frame7 = new QFrame( this, "Frame7" ); 52 Frame7 = new QFrame( this, "Frame7" );
50 Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); 53 Frame7->setGeometry( QRect( 0, 0, 240, 331 ) );
@@ -54,37 +57,38 @@ namespace OpieTooth {
54 QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); 57 QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" );
55 privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); 58 privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) );
56 Layout11 = new QVBoxLayout( privateLayoutWidget ); 59 Layout11 = new QVBoxLayout( privateLayoutWidget );
57 Layout11->setSpacing( 6 ); 60 Layout11->setSpacing( 6 );
58 Layout11->setMargin( 0 ); 61 Layout11->setMargin( 0 );
59 62
60 progress = new QProgressBar(privateLayoutWidget, "progbar"); 63 progress = new QProgressBar(privateLayoutWidget, "progbar");
61 progress->setTotalSteps(20); 64 progress->setTotalSteps(20);
62 65
63 QFrame *buttonFrame = new QFrame(Frame7, ""); 66 QFrame *buttonFrame = new QFrame(Frame7, "");
64 67
65 StartButton = new QPushButton( buttonFrame, "StartButton" ); 68 StartButton = new QPushButton( buttonFrame, "StartButton" );
66 StartButton->setText( tr( "Start" ) ); 69 StartButton->setText( tr( "Start scan" ) );
67 70
68 StopButton = new QPushButton( buttonFrame, "StopButton" ); 71 StopButton = new QPushButton( buttonFrame, "StopButton" );
69 StopButton->setText( tr( "Cancel" ) ); 72 StopButton->setText( tr( "Cancel scan" ) );
70 73
71 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); 74 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame);
75
72 buttonLayout->addWidget(StartButton); 76 buttonLayout->addWidget(StartButton);
73 buttonLayout->addWidget(StopButton); 77 buttonLayout->addWidget(StopButton);
74 78
75 ListView1 = new QListView( privateLayoutWidget, "ListView1" ); 79 ListView1 = new QListView( privateLayoutWidget, "ListView1" );
76 80
77 ListView1->addColumn( tr( "Add" ) ); 81 //ListView1->addColumn( tr( "Add" ) );
78 ListView1->addColumn( tr( "Device Name" ) ); 82 ListView1->addColumn( tr( "Add Device" ) );
79 //ListView1->addColumn( tr( "Type" ) ); 83 //ListView1->addColumn( tr( "Type" ) );
80 84
81 Layout11->addWidget( ListView1); 85 Layout11->addWidget( ListView1);
82 Layout11->addWidget(progress); 86 Layout11->addWidget(progress);
83 Layout11->addWidget( buttonFrame); 87 Layout11->addWidget( buttonFrame);
84 88
85 localDevice = new Manager( "hci0" ); 89 localDevice = new Manager( "hci0" );
86 90
87 connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); 91 connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
88 connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); 92 connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
89 connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), 93 connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ),
90 this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; 94 this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ;
@@ -97,42 +101,70 @@ namespace OpieTooth {
97 progressStat++; 101 progressStat++;
98 if (progressStat++ < 20) { 102 if (progressStat++ < 20) {
99 QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); 103 QTimer::singleShot( 1000, this, SLOT(progressTimer() ) );
100 } 104 }
101 progress->setProgress(progressStat++); 105 progress->setProgress(progressStat++);
102 106
103 } 107 }
104 108
105 void ScanDialog::startSearch() { 109 void ScanDialog::startSearch() {
106 progress->setProgress(0); 110 progress->setProgress(0);
107 progressStat = 0; 111 progressStat = 0;
108 112
113 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
114 deviceItem2->setText(1, "BLAH" );
115
109 progressTimer(); 116 progressTimer();
110 // when finished, it emmite foundDevices() 117 // when finished, it emmite foundDevices()
111 // checken ob initialisiert , qcop ans applet. 118 // checken ob initialisiert , qcop ans applet.
112 localDevice->searchDevices(); 119 localDevice->searchDevices();
113 120
114 } 121 }
115 122
116 void ScanDialog::stopSearch() { 123 void ScanDialog::stopSearch() {
117 124
118 } 125 }
119 126
120 void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { 127 void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) {
121 128
122 QListViewItem * deviceItem; 129 QCheckListItem * deviceItem;
123 130
124 RemoteDevices::ValueList::Iterator it; 131 RemoteDevices::ValueList::Iterator it;
125 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 132 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
126 133
127 deviceItem = new QListViewItem( ListView1, (*it).name() ); 134 deviceItem = new QCheckListItem( ListView1, (*it).name() );
135 deviceItem->setText(1, (*it).mac() );
136 }
137
138 }
139
140/*
141 * Iterates trough the items, and collects the checked items.
142 * Then it emits it, so the manager can connect to the signal to fill the listing.
143 */
144 void ScanDialog::emitToManager() {
145
146 if (!ListView1) {
147 return;
148 }
149
150 QList<RemoteDevices> *deviceList = new QList<RemoteDevices>;
151
152 QListViewItemIterator it( ListView1 );
153 for ( ; it.current(); ++it ) {
154 if ( it.current()->isSelected() ) {
155 RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0));
156 deviceList->append( device );
157 }
128 } 158 }
159 emit selectedDevices( *deviceList );
129 } 160 }
130 161
131/* 162/*
132 * Cleanup 163 * Cleanup
133 */ 164 */
134 ScanDialog::~ScanDialog() { 165 ScanDialog::~ScanDialog() {
166 emitToManager();
135 delete localDevice; 167 delete localDevice;
136 } 168 }
137 169
138} 170}