author | harlekin <harlekin> | 2002-06-15 20:41:08 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-15 20:41:08 (UTC) |
commit | e23774336087439cfed07899c8446eab674a3de8 (patch) (unidiff) | |
tree | 136957b6dcef1e3b66e2a4a52a0bdb77bb0b09c7 | |
parent | e782feb7418fbf956547b9abb59afdde00745442 (diff) | |
download | opie-e23774336087439cfed07899c8446eab674a3de8.zip opie-e23774336087439cfed07899c8446eab674a3de8.tar.gz opie-e23774336087439cfed07899c8446eab674a3de8.tar.bz2 |
more
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 46 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 14 |
2 files changed, 43 insertions, 17 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 3ddba3e..842466a 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -22,89 +22,113 @@ | |||
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 | 31 | ||
31 | #include <manager.h> | 32 | #include <manager.h> |
32 | #include <device.h> | 33 | #include <device.h> |
33 | #include <remotedevice.h> | 34 | #include <remotedevice.h> |
34 | 35 | ||
35 | 36 | ||
36 | namespace OpieTooth { | 37 | namespace OpieTooth { |
37 | 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( 360, 392 ); | 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 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | 55 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); |
55 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 310 ) ); | 56 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 310 ) ); |
56 | Layout11 = new QGridLayout( privateLayoutWidget ); | 57 | Layout11 = new QGridLayout( privateLayoutWidget ); |
57 | Layout11->setSpacing( 6 ); | 58 | Layout11->setSpacing( 6 ); |
58 | Layout11->setMargin( 0 ); | 59 | Layout11->setMargin( 0 ); |
59 | 60 | ||
60 | 61 | ||
61 | TextLabel10 = new QLabel( privateLayoutWidget, "TextLabel10" ); | 62 | progress = new QProgressBar(privateLayoutWidget, "progbar"); |
62 | TextLabel10->setText( tr( "ersetzen durch qprogressbar" ) ); | 63 | progress->setTotalSteps(20); |
63 | 64 | ||
64 | Layout11->addMultiCellWidget( TextLabel10, 1, 1, 0, 1 ); | 65 | //Layout11->addMultiCellWidget( progress, 1, 1, 0, 1 ); |
66 | Layout11->addWidget(progress, 2, 2); | ||
65 | 67 | ||
66 | StartButton = new QPushButton( privateLayoutWidget, "PushButton13" ); | 68 | StartButton = new QPushButton( privateLayoutWidget, "StartButton" ); |
67 | StartButton->setText( tr( "Start" ) ); | 69 | StartButton->setText( tr( "Start" ) ); |
68 | 70 | ||
69 | Layout11->addWidget( StartButton, 2, 0 ); | 71 | Layout11->addWidget( StartButton, 2, 0 ); |
70 | 72 | ||
71 | PushButton6 = new QPushButton( privateLayoutWidget, "PushButton6" ); | 73 | StopButton = new QPushButton( privateLayoutWidget, "StopButton" ); |
72 | PushButton6->setText( tr( "Stop" ) ); | 74 | StopButton->setText( tr( "Cancel" ) ); |
73 | 75 | ||
74 | Layout11->addWidget( PushButton6, 2, 1 ); | 76 | Layout11->addWidget( StopButton, 2, 1 ); |
75 | 77 | ||
76 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 78 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
77 | 79 | ||
78 | // ListView1->addColumn( tr( "In List" ) ); | 80 | ListView1->addColumn( tr( "Add" ) ); |
79 | ListView1->addColumn( tr( "Device Name" ) ); | 81 | ListView1->addColumn( tr( "Device Name" ) ); |
80 | //ListView1->addColumn( tr( "Type" ) ); | 82 | //ListView1->addColumn( tr( "Type" ) ); |
81 | 83 | ||
82 | Layout11->addMultiCellWidget( ListView1, 0, 0, 0, 1 ); | 84 | Layout11->addMultiCellWidget( ListView1, 0, 0, 0, 1 ); |
83 | 85 | ||
84 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 86 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
87 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | ||
85 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), | 88 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), |
86 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; | 89 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; |
90 | progressStat = 0; | ||
91 | } | ||
92 | |||
93 | // hack, make cleaner later | ||
94 | void ScanDialog::progressTimer(int maxSeconds) { | ||
95 | |||
96 | progressStat++; | ||
97 | if (progressStat++ < maxSeconds) { | ||
98 | QTimer::singleShot( 1000, this, SLOT(progressTimer ) ); | ||
99 | } | ||
100 | |||
87 | } | 101 | } |
88 | 102 | ||
89 | void ScanDialog::startSearch() { | 103 | void ScanDialog::startSearch() { |
104 | progress->setProgress(0); | ||
105 | progressStat = 0; | ||
90 | // read it from config later | 106 | // read it from config later |
91 | localDevice = new Manager( "hci0" ); | 107 | localDevice = new Manager( "hci0" ); |
108 | progressTimer(20); | ||
109 | // when finished, it emmite foundDevices() | ||
110 | // checken ob initialisiert , qcop ans applet. | ||
92 | localDevice->searchDevices(); | 111 | localDevice->searchDevices(); |
112 | progress->setProgress(20); | ||
93 | } | 113 | } |
94 | 114 | ||
115 | void ScanDialog::stopSearch() { | ||
116 | |||
117 | } | ||
95 | 118 | ||
96 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { | 119 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { |
97 | 120 | ||
121 | QListViewItem * deviceItem; | ||
98 | 122 | ||
99 | RemoteDevices::ValueList::Iterator it; | 123 | RemoteDevices::ValueList::Iterator it; |
100 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 124 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
101 | 125 | ||
102 | 126 | deviceItem = new QListViewItem( ListView1, (*it).name() ); | |
103 | } | 127 | } |
104 | } | 128 | } |
105 | 129 | ||
106 | /* | 130 | /* |
107 | * Cleanup | 131 | * Cleanup |
108 | */ | 132 | */ |
109 | ScanDialog::~ScanDialog() { | 133 | ScanDialog::~ScanDialog() { |
110 | delete localDevice; | 134 | delete localDevice; |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index 5cebb11..6d9b877 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -26,46 +26,48 @@ | |||
26 | class QVBoxLayout; | 26 | class QVBoxLayout; |
27 | class QHBoxLayout; | 27 | class QHBoxLayout; |
28 | class QGridLayout; | 28 | class QGridLayout; |
29 | class QFrame; | 29 | class QFrame; |
30 | class QLabel; | 30 | class QLabel; |
31 | class QListView; | 31 | class QListView; |
32 | class QListViewItem; | 32 | class QListViewItem; |
33 | class QPushButton; | 33 | class QPushButton; |
34 | 34 | class QProgressBar; | |
35 | class Manager; | ||
36 | class Device; | ||
37 | 35 | ||
38 | 36 | ||
39 | namespace OpieTooth { | 37 | namespace OpieTooth { |
40 | 38 | ||
41 | 39 | ||
40 | class Manager; | ||
41 | class Device; | ||
42 | 42 | ||
43 | class ScanDialog : public QDialog { | 43 | class ScanDialog : public QDialog { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 47 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
48 | ~ScanDialog(); | 48 | ~ScanDialog(); |
49 | 49 | ||
50 | QFrame* Frame7; | 50 | QFrame* Frame7; |
51 | QLabel* TextLabel10; | 51 | QProgressBar* progress; |
52 | QPushButton* StartButton; | 52 | QPushButton* StartButton; |
53 | QPushButton* PushButton6; | 53 | QPushButton* StopButton; |
54 | QListView* ListView1; | 54 | QListView* ListView1; |
55 | 55 | ||
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | QGridLayout* Layout11; | 58 | QGridLayout* Layout11; |
59 | 59 | ||
60 | private slots: | 60 | private slots: |
61 | void stopSearch(); | ||
61 | void startSearch(); | 62 | void startSearch(); |
62 | void fillList(const QString& device, RemoteDevices::ValueList list); | 63 | void fillList(const QString& device, RemoteDevices::ValueList list); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | 66 | void progressTimer(int maxSeconds); | |
66 | Manager *localDevice; | 67 | Manager *localDevice; |
68 | int progressStat; | ||
67 | }; | 69 | }; |
68 | 70 | ||
69 | } | 71 | } |
70 | 72 | ||
71 | #endif // SCANDIALOG_H | 73 | #endif // SCANDIALOG_H |