-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index e81b2ee..b0ffbb3 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -18,124 +18,124 @@ | |||
18 | 18 | ||
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 | 31 | ||
32 | #include <manager.h> | 32 | #include <manager.h> |
33 | #include <device.h> | 33 | #include <device.h> |
34 | #include <remotedevice.h> | 34 | #include <remotedevice.h> |
35 | 35 | ||
36 | 36 | ||
37 | namespace OpieTooth { | 37 | namespace OpieTooth { |
38 | 38 | ||
39 | /* | 39 | /* |
40 | */ | 40 | */ |
41 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 41 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
42 | : QDialog( parent, name, modal, fl ) { | 42 | : QDialog( parent, name, modal, fl ) { |
43 | 43 | ||
44 | if ( !name ) | 44 | if ( !name ) |
45 | setName( "ScanDialog" ); | 45 | setName( "ScanDialog" ); |
46 | resize( 240, 320 ); | 46 | resize( 240, 320 ); |
47 | setCaption( tr( "Scan for devices" ) ); | 47 | setCaption( tr( "Scan for devices" ) ); |
48 | 48 | ||
49 | Frame7 = new QFrame( this, "Frame7" ); | 49 | Frame7 = new QFrame( this, "Frame7" ); |
50 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); | 50 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); |
51 | Frame7->setFrameShape( QFrame::StyledPanel ); | 51 | Frame7->setFrameShape( QFrame::StyledPanel ); |
52 | Frame7->setFrameShadow( QFrame::Raised ); | 52 | Frame7->setFrameShadow( QFrame::Raised ); |
53 | 53 | ||
54 | 54 | ||
55 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | 55 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); |
56 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); | 56 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); |
57 | Layout11 = new QVBoxLayout( privateLayoutWidget ); | 57 | Layout11 = new QVBoxLayout( privateLayoutWidget ); |
58 | Layout11->setSpacing( 6 ); | 58 | Layout11->setSpacing( 6 ); |
59 | Layout11->setMargin( 0 ); | 59 | Layout11->setMargin( 0 ); |
60 | 60 | ||
61 | 61 | ||
62 | progress = new QProgressBar(privateLayoutWidget, "progbar"); | 62 | progress = new QProgressBar(privateLayoutWidget, "progbar"); |
63 | progress->setTotalSteps(20); | 63 | progress->setTotalSteps(20); |
64 | 64 | ||
65 | 65 | ||
66 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
67 | 67 | ||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start" ) ); | 69 | StartButton->setText( tr( "Start" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | 71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); |
72 | StopButton->setText( tr( "Cancel" ) ); | 72 | StopButton->setText( tr( "Cancel" ) ); |
73 | 73 | ||
74 | 74 | ||
75 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 75 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
76 | buttonLayout->addWidget(StartButton); | 76 | buttonLayout->addWidget(StartButton); |
77 | buttonLayout->addWidget(StopButton); | 77 | buttonLayout->addWidget(StopButton); |
78 | 78 | ||
79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
80 | 80 | ||
81 | ListView1->addColumn( tr( "Add" ) ); | 81 | ListView1->addColumn( tr( "Add" ) ); |
82 | ListView1->addColumn( tr( "Device Name" ) ); | 82 | ListView1->addColumn( tr( "Device Name" ) ); |
83 | //ListView1->addColumn( tr( "Type" ) ); | 83 | //ListView1->addColumn( tr( "Type" ) ); |
84 | 84 | ||
85 | Layout11->addWidget( ListView1); | 85 | Layout11->addWidget( ListView1); |
86 | Layout11->addWidget(progress); | 86 | Layout11->addWidget(progress); |
87 | Layout11->addWidget( buttonFrame); | 87 | Layout11->addWidget( buttonFrame); |
88 | 88 | ||
89 | localDevice = new Manager( "hci0" ); | 89 | localDevice = new Manager( "hci0" ); |
90 | 90 | ||
91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | 92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); |
93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), | 93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), |
94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; | 94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; |
95 | progressStat = 0; | 95 | progressStat = 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | // hack, make cleaner later | 98 | // hack, make cleaner later |
99 | void ScanDialog::progressTimer(int maxSeconds) { | 99 | void ScanDialog::progressTimer() { |
100 | 100 | ||
101 | progressStat++; | 101 | progressStat++; |
102 | if (progressStat++ < maxSeconds) { | 102 | if (progressStat++ < 20) { |
103 | QTimer::singleShot( 1000, this, SLOT(progressTimer ) ); | 103 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); |
104 | } | 104 | } |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | void ScanDialog::startSearch() { | 108 | void ScanDialog::startSearch() { |
109 | progress->setProgress(0); | 109 | progress->setProgress(0); |
110 | progressStat = 0; | 110 | progressStat = 0; |
111 | 111 | ||
112 | progressTimer(20); | 112 | progressTimer(); |
113 | // when finished, it emmite foundDevices() | 113 | // when finished, it emmite foundDevices() |
114 | // checken ob initialisiert , qcop ans applet. | 114 | // checken ob initialisiert , qcop ans applet. |
115 | localDevice->searchDevices(); | 115 | localDevice->searchDevices(); |
116 | progress->setProgress(20); | 116 | |
117 | } | 117 | } |
118 | 118 | ||
119 | void ScanDialog::stopSearch() { | 119 | void ScanDialog::stopSearch() { |
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { | 123 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { |
124 | 124 | ||
125 | QListViewItem * deviceItem; | 125 | QListViewItem * deviceItem; |
126 | 126 | ||
127 | RemoteDevices::ValueList::Iterator it; | 127 | RemoteDevices::ValueList::Iterator it; |
128 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 128 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
129 | 129 | ||
130 | deviceItem = new QListViewItem( ListView1, (*it).name() ); | 130 | deviceItem = new QListViewItem( ListView1, (*it).name() ); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | /* | 134 | /* |
135 | * Cleanup | 135 | * Cleanup |
136 | */ | 136 | */ |
137 | ScanDialog::~ScanDialog() { | 137 | ScanDialog::~ScanDialog() { |
138 | delete localDevice; | 138 | delete localDevice; |
139 | } | 139 | } |
140 | 140 | ||
141 | } | 141 | } |