Diffstat (limited to 'noncore/net/opietooth/manager/scandialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 3d6c928..9ce1b6a 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -65,16 +65,14 @@ namespace OpieTooth { | |||
65 | 65 | ||
66 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
67 | 67 | ||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartStopButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start scan" ) ); | 69 | StartStopButton->setText( tr( "Start scan" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | ||
72 | StopButton->setText( tr( "Cancel scan" ) ); | ||
73 | 71 | ||
74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 72 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
75 | 73 | ||
76 | buttonLayout->addWidget(StartButton); | 74 | buttonLayout->addWidget(StartStopButton); |
77 | buttonLayout->addWidget(StopButton); | 75 | //buttonLayout->addWidget(StopButton); |
78 | 76 | ||
79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 77 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
80 | 78 | ||
@@ -88,22 +86,22 @@ namespace OpieTooth { | |||
88 | 86 | ||
89 | localDevice = new Manager( "hci0" ); | 87 | localDevice = new Manager( "hci0" ); |
90 | 88 | ||
91 | connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 89 | connect( StartStopButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | ||
93 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), | 90 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), |
94 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; | 91 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; |
95 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); | 92 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); |
96 | progressStat = 0; | 93 | progressStat = 0; |
94 | m_search = false; | ||
97 | } | 95 | } |
98 | 96 | ||
99 | // hack, make cleaner later | 97 | // hack, make cleaner later |
100 | void ScanDialog::progressTimer() { | 98 | void ScanDialog::progressTimer() { |
101 | 99 | ||
102 | progressStat++; | 100 | progressStat++; |
103 | if (progressStat++ < 20) { | 101 | if (progressStat++ < 20 && m_search ) { |
104 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); | 102 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); |
105 | } | ||
106 | progress->setProgress(progressStat++); | 103 | progress->setProgress(progressStat++); |
104 | } | ||
107 | 105 | ||
108 | } | 106 | } |
109 | 107 | ||
@@ -114,6 +112,11 @@ namespace OpieTooth { | |||
114 | 112 | ||
115 | 113 | ||
116 | void ScanDialog::startSearch() { | 114 | void ScanDialog::startSearch() { |
115 | if ( m_search ) { | ||
116 | stopSearch(); | ||
117 | return; | ||
118 | } | ||
119 | m_search = true; | ||
117 | progress->setProgress(0); | 120 | progress->setProgress(0); |
118 | progressStat = 0; | 121 | progressStat = 0; |
119 | 122 | ||
@@ -126,16 +129,19 @@ namespace OpieTooth { | |||
126 | progressTimer(); | 129 | progressTimer(); |
127 | // when finished, it emmite foundDevices() | 130 | // when finished, it emmite foundDevices() |
128 | // checken ob initialisiert , qcop ans applet. | 131 | // checken ob initialisiert , qcop ans applet. |
132 | StartStopButton->setText( tr("Stop scan")); | ||
133 | |||
129 | localDevice->searchDevices(); | 134 | localDevice->searchDevices(); |
130 | 135 | ||
131 | } | 136 | } |
132 | 137 | ||
133 | void ScanDialog::stopSearch() { | 138 | void ScanDialog::stopSearch() { |
134 | 139 | m_search = true; | |
135 | } | 140 | } |
136 | 141 | ||
137 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { | 142 | void ScanDialog::fillList(const QString&, RemoteDevice::ValueList deviceList) { |
138 | 143 | progress->setProgress(0); | |
144 | progressStat = 0; | ||
139 | qDebug("fill List"); | 145 | qDebug("fill List"); |
140 | QCheckListItem * deviceItem; | 146 | QCheckListItem * deviceItem; |
141 | 147 | ||
@@ -145,6 +151,8 @@ namespace OpieTooth { | |||
145 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); | 151 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); |
146 | deviceItem->setText(1, (*it).mac() ); | 152 | deviceItem->setText(1, (*it).mac() ); |
147 | } | 153 | } |
154 | m_search = false; | ||
155 | StartStopButton->setText(tr ("Start scan") ); | ||
148 | } | 156 | } |
149 | 157 | ||
150 | /* | 158 | /* |
@@ -175,6 +183,7 @@ namespace OpieTooth { | |||
175 | * Cleanup | 183 | * Cleanup |
176 | */ | 184 | */ |
177 | ScanDialog::~ScanDialog() { | 185 | ScanDialog::~ScanDialog() { |
186 | qWarning("delete scan dialog"); | ||
178 | delete localDevice; | 187 | delete localDevice; |
179 | } | 188 | } |
180 | 189 | ||