summaryrefslogtreecommitdiff
path: root/libopie2/qt3/opieui/oeditlistbox.cpp
Unidiff
Diffstat (limited to 'libopie2/qt3/opieui/oeditlistbox.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/qt3/opieui/oeditlistbox.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/qt3/opieui/oeditlistbox.cpp b/libopie2/qt3/opieui/oeditlistbox.cpp
index 0e95274..dcc697d 100644
--- a/libopie2/qt3/opieui/oeditlistbox.cpp
+++ b/libopie2/qt3/opieui/oeditlistbox.cpp
@@ -171,49 +171,49 @@ void OEditListBox::typedSomething(const QString& text)
171 // IMHO changeItem() shouldn't do anything with the value 171 // IMHO changeItem() shouldn't do anything with the value
172 // of currentItem() ... like changing it or emitting signals ... 172 // of currentItem() ... like changing it or emitting signals ...
173 // but TT disagree with me on this one (it's been that way since ages ... grrr) 173 // but TT disagree with me on this one (it's been that way since ages ... grrr)
174 bool block = m_listBox->signalsBlocked(); 174 bool block = m_listBox->signalsBlocked();
175 m_listBox->blockSignals( true ); 175 m_listBox->blockSignals( true );
176 m_listBox->changeItem(text, currentItem()); 176 m_listBox->changeItem(text, currentItem());
177 m_listBox->blockSignals( block ); 177 m_listBox->blockSignals( block );
178 emit changed(); 178 emit changed();
179 } 179 }
180 } 180 }
181 181
182 if ( !servNewButton ) 182 if ( !servNewButton )
183 return; 183 return;
184 184
185 if (!d->m_checkAtEntering) 185 if (!d->m_checkAtEntering)
186 servNewButton->setEnabled(!text.isEmpty()); 186 servNewButton->setEnabled(!text.isEmpty());
187 else 187 else
188 { 188 {
189 if (text.isEmpty()) 189 if (text.isEmpty())
190 { 190 {
191 servNewButton->setEnabled(false); 191 servNewButton->setEnabled(false);
192 } 192 }
193 else 193 else
194 { 194 {
195 #if QT_VERSION > 290 195 #if QT_VERSION >= 0x030000
196 StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); 196 StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive );
197 bool enable = (m_listBox->findItem( text, mode ) == 0L); 197 bool enable = (m_listBox->findItem( text, mode ) == 0L);
198 #else 198 #else
199 bool enable = (m_listBox->findItem( text ) == 0L); 199 bool enable = (m_listBox->findItem( text ) == 0L);
200 #endif 200 #endif
201 servNewButton->setEnabled( enable ); 201 servNewButton->setEnabled( enable );
202 } 202 }
203 } 203 }
204} 204}
205 205
206void OEditListBox::moveItemUp() 206void OEditListBox::moveItemUp()
207{ 207{
208 if (!m_listBox->isEnabled()) 208 if (!m_listBox->isEnabled())
209 { 209 {
210 //ONotifyClient::beep(); 210 //ONotifyClient::beep();
211 return; 211 return;
212 } 212 }
213 213
214 unsigned int selIndex = m_listBox->currentItem(); 214 unsigned int selIndex = m_listBox->currentItem();
215 if (selIndex == 0) 215 if (selIndex == 0)
216 { 216 {
217 //ONotifyClient::beep(); 217 //ONotifyClient::beep();
218 return; 218 return;
219 } 219 }
@@ -246,82 +246,82 @@ void OEditListBox::moveItemDown()
246 m_listBox->insertItem(selItem, selIndex+1); 246 m_listBox->insertItem(selItem, selIndex+1);
247 m_listBox->setCurrentItem(selIndex + 1); 247 m_listBox->setCurrentItem(selIndex + 1);
248 248
249 emit changed(); 249 emit changed();
250} 250}
251 251
252void OEditListBox::addItem() 252void OEditListBox::addItem()
253{ 253{
254 // when m_checkAtEntering is true, the add-button is disabled, but this 254 // when m_checkAtEntering is true, the add-button is disabled, but this
255 // slot can still be called through Key_Return/Key_Enter. So we guard 255 // slot can still be called through Key_Return/Key_Enter. So we guard
256 // against this. 256 // against this.
257 if ( !servNewButton || !servNewButton->isEnabled() ) 257 if ( !servNewButton || !servNewButton->isEnabled() )
258 return; 258 return;
259 259
260 const QString& currentTextLE=m_lineEdit->text(); 260 const QString& currentTextLE=m_lineEdit->text();
261 bool alreadyInList(false); 261 bool alreadyInList(false);
262 //if we didn't check for dupes at the inserting we have to do it now 262 //if we didn't check for dupes at the inserting we have to do it now
263 if (!d->m_checkAtEntering) 263 if (!d->m_checkAtEntering)
264 { 264 {
265 // first check current item instead of dumb iterating the entire list 265 // first check current item instead of dumb iterating the entire list
266 if ( m_listBox->currentText() == currentTextLE ) 266 if ( m_listBox->currentText() == currentTextLE )
267 alreadyInList = true; 267 alreadyInList = true;
268 else 268 else
269 { 269 {
270 #if QT_VERSION > 290 270 #if QT_VERSION >= 0x030000
271 StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive ); 271 StringComparisonMode mode = (StringComparisonMode) (ExactMatch | CaseSensitive );
272 alreadyInList =(m_listBox->findItem(currentTextLE, mode) != 0); 272 alreadyInList =(m_listBox->findItem(currentTextLE, mode) != 0);
273 #else 273 #else
274 alreadyInList =(m_listBox->findItem(currentTextLE) != 0); 274 alreadyInList =(m_listBox->findItem(currentTextLE) != 0);
275 #endif 275 #endif
276 } 276 }
277 } 277 }
278 278
279 if ( servNewButton ) 279 if ( servNewButton )
280 servNewButton->setEnabled(false); 280 servNewButton->setEnabled(false);
281 281
282 bool block = m_lineEdit->signalsBlocked(); 282 bool block = m_lineEdit->signalsBlocked();
283 m_lineEdit->blockSignals(true); 283 m_lineEdit->blockSignals(true);
284 m_lineEdit->clear(); 284 m_lineEdit->clear();
285 m_lineEdit->blockSignals(block); 285 m_lineEdit->blockSignals(block);
286 286
287 m_listBox->setSelected(currentItem(), false); 287 m_listBox->setSelected(currentItem(), false);
288 288
289 if (!alreadyInList) 289 if (!alreadyInList)
290 { 290 {
291 block = m_listBox->signalsBlocked(); 291 block = m_listBox->signalsBlocked();
292 m_listBox->blockSignals( true ); 292 m_listBox->blockSignals( true );
293 m_listBox->insertItem(currentTextLE); 293 m_listBox->insertItem(currentTextLE);
294 m_listBox->blockSignals( block ); 294 m_listBox->blockSignals( block );
295 emit changed(); 295 emit changed();
296 emit added( currentTextLE ); 296 emit added( currentTextLE );
297 } 297 }
298} 298}
299 299
300int OEditListBox::currentItem() const 300int OEditListBox::currentItem() const
301{ 301{
302 int nr = m_listBox->currentItem(); 302 int nr = m_listBox->currentItem();
303 #if QT_VERSION > 290 303 #if QT_VERSION >= 0x030000
304 if(nr >= 0 && !m_listBox->item(nr)->isSelected()) return -1; 304 if(nr >= 0 && !m_listBox->item(nr)->isSelected()) return -1;
305 #else 305 #else
306 if(nr >= 0 && !m_listBox->isSelected(m_listBox->item(nr))) return -1; 306 if(nr >= 0 && !m_listBox->isSelected(m_listBox->item(nr))) return -1;
307 #endif 307 #endif
308 return nr; 308 return nr;
309} 309}
310 310
311void OEditListBox::removeItem() 311void OEditListBox::removeItem()
312{ 312{
313 int selected = m_listBox->currentItem(); 313 int selected = m_listBox->currentItem();
314 314
315 if ( selected >= 0 ) 315 if ( selected >= 0 )
316 { 316 {
317 QString removedText = m_listBox->currentText(); 317 QString removedText = m_listBox->currentText();
318 318
319 m_listBox->removeItem( selected ); 319 m_listBox->removeItem( selected );
320 if ( count() > 0 ) 320 if ( count() > 0 )
321 m_listBox->setSelected( QMIN( selected, count() - 1 ), true ); 321 m_listBox->setSelected( QMIN( selected, count() - 1 ), true );
322 322
323 emit changed(); 323 emit changed();
324 emit removed( removedText ); 324 emit removed( removedText );
325 } 325 }
326 326
327 if ( servRemoveButton && m_listBox->currentItem() == -1 ) 327 if ( servRemoveButton && m_listBox->currentItem() == -1 )