Diffstat (limited to 'noncore/net/opietooth/manager/scandialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 842466a..e81b2ee 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -1,137 +1,141 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
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, 310 ) ); | 56 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); |
57 | Layout11 = new QGridLayout( 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 | //Layout11->addMultiCellWidget( progress, 1, 1, 0, 1 ); | ||
66 | Layout11->addWidget(progress, 2, 2); | ||
67 | 65 | ||
68 | StartButton = new QPushButton( privateLayoutWidget, "StartButton" ); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
67 | |||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | ||
69 | StartButton->setText( tr( "Start" ) ); | 69 | StartButton->setText( tr( "Start" ) ); |
70 | 70 | ||
71 | Layout11->addWidget( StartButton, 2, 0 ); | 71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); |
72 | |||
73 | StopButton = new QPushButton( privateLayoutWidget, "StopButton" ); | ||
74 | StopButton->setText( tr( "Cancel" ) ); | 72 | StopButton->setText( tr( "Cancel" ) ); |
75 | 73 | ||
76 | Layout11->addWidget( StopButton, 2, 1 ); | 74 | |
75 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | ||
76 | buttonLayout->addWidget(StartButton); | ||
77 | buttonLayout->addWidget(StopButton); | ||
77 | 78 | ||
78 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
79 | 80 | ||
80 | ListView1->addColumn( tr( "Add" ) ); | 81 | ListView1->addColumn( tr( "Add" ) ); |
81 | ListView1->addColumn( tr( "Device Name" ) ); | 82 | ListView1->addColumn( tr( "Device Name" ) ); |
82 | //ListView1->addColumn( tr( "Type" ) ); | 83 | //ListView1->addColumn( tr( "Type" ) ); |
83 | 84 | ||
84 | Layout11->addMultiCellWidget( ListView1, 0, 0, 0, 1 ); | 85 | Layout11->addWidget( ListView1); |
86 | Layout11->addWidget(progress); | ||
87 | Layout11->addWidget( buttonFrame); | ||
88 | |||
89 | localDevice = new Manager( "hci0" ); | ||
85 | 90 | ||
86 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
87 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | 92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); |
88 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), | 93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), |
89 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; | 94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; |
90 | progressStat = 0; | 95 | progressStat = 0; |
91 | } | 96 | } |
92 | 97 | ||
93 | // hack, make cleaner later | 98 | // hack, make cleaner later |
94 | void ScanDialog::progressTimer(int maxSeconds) { | 99 | void ScanDialog::progressTimer(int maxSeconds) { |
95 | 100 | ||
96 | progressStat++; | 101 | progressStat++; |
97 | if (progressStat++ < maxSeconds) { | 102 | if (progressStat++ < maxSeconds) { |
98 | QTimer::singleShot( 1000, this, SLOT(progressTimer ) ); | 103 | QTimer::singleShot( 1000, this, SLOT(progressTimer ) ); |
99 | } | 104 | } |
100 | 105 | ||
101 | } | 106 | } |
102 | 107 | ||
103 | void ScanDialog::startSearch() { | 108 | void ScanDialog::startSearch() { |
104 | progress->setProgress(0); | 109 | progress->setProgress(0); |
105 | progressStat = 0; | 110 | progressStat = 0; |
106 | // read it from config later | 111 | |
107 | localDevice = new Manager( "hci0" ); | ||
108 | progressTimer(20); | 112 | progressTimer(20); |
109 | // when finished, it emmite foundDevices() | 113 | // when finished, it emmite foundDevices() |
110 | // checken ob initialisiert , qcop ans applet. | 114 | // checken ob initialisiert , qcop ans applet. |
111 | localDevice->searchDevices(); | 115 | localDevice->searchDevices(); |
112 | progress->setProgress(20); | 116 | progress->setProgress(20); |
113 | } | 117 | } |
114 | 118 | ||
115 | void ScanDialog::stopSearch() { | 119 | void ScanDialog::stopSearch() { |
116 | 120 | ||
117 | } | 121 | } |
118 | 122 | ||
119 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { | 123 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { |
120 | 124 | ||
121 | QListViewItem * deviceItem; | 125 | QListViewItem * deviceItem; |
122 | 126 | ||
123 | RemoteDevices::ValueList::Iterator it; | 127 | RemoteDevices::ValueList::Iterator it; |
124 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 128 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
125 | 129 | ||
126 | deviceItem = new QListViewItem( ListView1, (*it).name() ); | 130 | deviceItem = new QListViewItem( ListView1, (*it).name() ); |
127 | } | 131 | } |
128 | } | 132 | } |
129 | 133 | ||
130 | /* | 134 | /* |
131 | * Cleanup | 135 | * Cleanup |
132 | */ | 136 | */ |
133 | ScanDialog::~ScanDialog() { | 137 | ScanDialog::~ScanDialog() { |
134 | delete localDevice; | 138 | delete localDevice; |
135 | } | 139 | } |
136 | 140 | ||
137 | } | 141 | } |