summaryrefslogtreecommitdiff
path: root/libopie2/qt3/opieui/olineedit.cpp
Unidiff
Diffstat (limited to 'libopie2/qt3/opieui/olineedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/qt3/opieui/olineedit.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/qt3/opieui/olineedit.cpp b/libopie2/qt3/opieui/olineedit.cpp
index 6f66fc7..b150987 100644
--- a/libopie2/qt3/opieui/olineedit.cpp
+++ b/libopie2/qt3/opieui/olineedit.cpp
@@ -124,49 +124,49 @@ void OLineEdit::setCompletedText( const QString& t, bool marked )
124 validateAndSet( t, curpos, curpos, t.length() ); 124 validateAndSet( t, curpos, curpos, t.length() );
125 } 125 }
126} 126}
127 127
128void OLineEdit::setCompletedText( const QString& text ) 128void OLineEdit::setCompletedText( const QString& text )
129{ 129{
130 OGlobalSettings::Completion mode = completionMode(); 130 OGlobalSettings::Completion mode = completionMode();
131 bool marked = ( mode == OGlobalSettings::CompletionAuto || 131 bool marked = ( mode == OGlobalSettings::CompletionAuto ||
132 mode == OGlobalSettings::CompletionMan || 132 mode == OGlobalSettings::CompletionMan ||
133 mode == OGlobalSettings::CompletionPopup ); 133 mode == OGlobalSettings::CompletionPopup );
134 setCompletedText( text, marked ); 134 setCompletedText( text, marked );
135} 135}
136 136
137void OLineEdit::rotateText( OCompletionBase::KeyBindingType type ) 137void OLineEdit::rotateText( OCompletionBase::KeyBindingType type )
138{ 138{
139 OCompletion* comp = compObj(); 139 OCompletion* comp = compObj();
140 if ( comp && 140 if ( comp &&
141 (type == OCompletionBase::PrevCompletionMatch || 141 (type == OCompletionBase::PrevCompletionMatch ||
142 type == OCompletionBase::NextCompletionMatch ) ) 142 type == OCompletionBase::NextCompletionMatch ) )
143 { 143 {
144 QString input = (type == OCompletionBase::PrevCompletionMatch) ? comp->previousMatch() : comp->nextMatch(); 144 QString input = (type == OCompletionBase::PrevCompletionMatch) ? comp->previousMatch() : comp->nextMatch();
145 // Skip rotation if previous/next match is null or the same text 145 // Skip rotation if previous/next match is null or the same text
146 if ( input.isNull() || input == displayText() ) 146 if ( input.isNull() || input == displayText() )
147 return; 147 return;
148 #if QT_VERSION > 290 148 #if QT_VERSION >= 0x030000
149 setCompletedText( input, hasSelectedText() ); 149 setCompletedText( input, hasSelectedText() );
150 #else 150 #else
151 setCompletedText( input, hasMarkedText() ); 151 setCompletedText( input, hasMarkedText() );
152 #endif 152 #endif
153 } 153 }
154} 154}
155 155
156void OLineEdit::makeCompletion( const QString& text ) 156void OLineEdit::makeCompletion( const QString& text )
157{ 157{
158 OCompletion *comp = compObj(); 158 OCompletion *comp = compObj();
159 if ( !comp ) 159 if ( !comp )
160 return; // No completion object... 160 return; // No completion object...
161 161
162 QString match = comp->makeCompletion( text ); 162 QString match = comp->makeCompletion( text );
163 OGlobalSettings::Completion mode = completionMode(); 163 OGlobalSettings::Completion mode = completionMode();
164 if ( mode == OGlobalSettings::CompletionPopup ) 164 if ( mode == OGlobalSettings::CompletionPopup )
165 { 165 {
166 if ( match.isNull() ) 166 if ( match.isNull() )
167 { 167 {
168 if ( d->completionBox ) { 168 if ( d->completionBox ) {
169 d->completionBox->hide(); 169 d->completionBox->hide();
170 d->completionBox->clear(); 170 d->completionBox->clear();
171 } 171 }
172 } 172 }
@@ -250,49 +250,49 @@ void OLineEdit::keyPressEvent( QKeyEvent *e )
250 250
251 e->accept(); 251 e->accept();
252 return; 252 return;
253 } 253 }
254 */ 254 */
255 255
256 // Filter key-events if EchoMode is normal & 256 // Filter key-events if EchoMode is normal &
257 // completion mode is not set to CompletionNone 257 // completion mode is not set to CompletionNone
258 if ( echoMode() == QLineEdit::Normal && 258 if ( echoMode() == QLineEdit::Normal &&
259 completionMode() != OGlobalSettings::CompletionNone ) 259 completionMode() != OGlobalSettings::CompletionNone )
260 { 260 {
261 KeyBindingMap keys = getKeyBindings(); 261 KeyBindingMap keys = getKeyBindings();
262 OGlobalSettings::Completion mode = completionMode(); 262 OGlobalSettings::Completion mode = completionMode();
263 bool noModifier = (e->state() == NoButton || e->state()== ShiftButton); 263 bool noModifier = (e->state() == NoButton || e->state()== ShiftButton);
264 264
265 if ( (mode == OGlobalSettings::CompletionAuto || 265 if ( (mode == OGlobalSettings::CompletionAuto ||
266 mode == OGlobalSettings::CompletionMan) && noModifier ) 266 mode == OGlobalSettings::CompletionMan) && noModifier )
267 { 267 {
268 QString keycode = e->text(); 268 QString keycode = e->text();
269 if ( !keycode.isNull() && keycode.unicode()->isPrint() ) 269 if ( !keycode.isNull() && keycode.unicode()->isPrint() )
270 { 270 {
271 QLineEdit::keyPressEvent ( e ); 271 QLineEdit::keyPressEvent ( e );
272 QString txt = text(); 272 QString txt = text();
273 int len = txt.length(); 273 int len = txt.length();
274 #if QT_VERSION > 290 274 #if QT_VERSION >= 0x030000
275 if ( !hasSelectedText() && len && cursorPosition() == len ) 275 if ( !hasSelectedText() && len && cursorPosition() == len )
276 #else 276 #else
277 if ( !hasMarkedText() && len && cursorPosition() == len ) 277 if ( !hasMarkedText() && len && cursorPosition() == len )
278 #endif 278 #endif
279 { 279 {
280 if ( emitSignals() ) 280 if ( emitSignals() )
281 emit completion( txt ); 281 emit completion( txt );
282 if ( handleSignals() ) 282 if ( handleSignals() )
283 makeCompletion( txt ); 283 makeCompletion( txt );
284 e->accept(); 284 e->accept();
285 } 285 }
286 return; 286 return;
287 } 287 }
288 } 288 }
289 289
290 else if ( mode == OGlobalSettings::CompletionPopup && noModifier ) 290 else if ( mode == OGlobalSettings::CompletionPopup && noModifier )
291 { 291 {
292 qDebug( "OLineEdit::keyPressEvent() - global settings = CompletionPopup & noModifier" ); 292 qDebug( "OLineEdit::keyPressEvent() - global settings = CompletionPopup & noModifier" );
293 293
294 QString old_txt = text(); 294 QString old_txt = text();
295 QLineEdit::keyPressEvent ( e ); 295 QLineEdit::keyPressEvent ( e );
296 QString txt = text(); 296 QString txt = text();
297 int len = txt.length(); 297 int len = txt.length();
298 QString keycode = e->text(); 298 QString keycode = e->text();
@@ -415,49 +415,49 @@ void OLineEdit::mouseDoubleClickEvent( QMouseEvent* e )
415 QLineEdit::mouseDoubleClickEvent( e ); 415 QLineEdit::mouseDoubleClickEvent( e );
416} 416}
417 417
418void OLineEdit::mousePressEvent( QMouseEvent* e ) 418void OLineEdit::mousePressEvent( QMouseEvent* e )
419{ 419{
420 if ( possibleTripleClick && e->button() == Qt::LeftButton ) 420 if ( possibleTripleClick && e->button() == Qt::LeftButton )
421 { 421 {
422 selectAll(); 422 selectAll();
423 return; 423 return;
424 } 424 }
425 QLineEdit::mousePressEvent( e ); 425 QLineEdit::mousePressEvent( e );
426} 426}
427 427
428void OLineEdit::tripleClickTimeout() 428void OLineEdit::tripleClickTimeout()
429{ 429{
430 possibleTripleClick=false; 430 possibleTripleClick=false;
431} 431}
432 432
433QPopupMenu *OLineEdit::createPopupMenu() 433QPopupMenu *OLineEdit::createPopupMenu()
434{ 434{
435 // Return if popup menu is not enabled !! 435 // Return if popup menu is not enabled !!
436 if ( !m_bEnableMenu ) 436 if ( !m_bEnableMenu )
437 return 0; 437 return 0;
438 438
439 #if QT_VERSION > 290 439 #if QT_VERSION >= 0x030000
440 QPopupMenu *popup = QLineEdit::createPopupMenu(); 440 QPopupMenu *popup = QLineEdit::createPopupMenu();
441 #else 441 #else
442 QPopupMenu *popup = new QPopupMenu(); 442 QPopupMenu *popup = new QPopupMenu();
443 #warning OLineEdit is not fully functional on Qt2 443 #warning OLineEdit is not fully functional on Qt2
444 #endif 444 #endif
445 445
446 // completion object is present. 446 // completion object is present.
447 if ( compObj() ) 447 if ( compObj() )
448 { 448 {
449 QPopupMenu *subMenu = new QPopupMenu( popup ); 449 QPopupMenu *subMenu = new QPopupMenu( popup );
450 connect( subMenu, SIGNAL( activated(int) ), 450 connect( subMenu, SIGNAL( activated(int) ),
451 this, SLOT( completionMenuActivated(int) ) ); 451 this, SLOT( completionMenuActivated(int) ) );
452 452
453 popup->insertSeparator(); 453 popup->insertSeparator();
454 //popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"), 454 //popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"),
455 // subMenu ); 455 // subMenu );
456 456
457 popup->insertItem( tr("Text Completion"), subMenu ); 457 popup->insertItem( tr("Text Completion"), subMenu );
458 458
459 subMenu->insertItem( tr("None"), NoCompletion ); 459 subMenu->insertItem( tr("None"), NoCompletion );
460 subMenu->insertItem( tr("Manual"), ShellCompletion ); 460 subMenu->insertItem( tr("Manual"), ShellCompletion );
461 subMenu->insertItem( tr("Automatic"), AutoCompletion ); 461 subMenu->insertItem( tr("Automatic"), AutoCompletion );
462 subMenu->insertItem( tr("Dropdown List"), PopupCompletion ); 462 subMenu->insertItem( tr("Dropdown List"), PopupCompletion );
463 subMenu->insertItem( tr("Short Automatic"), SemiAutoCompletion ); 463 subMenu->insertItem( tr("Short Automatic"), SemiAutoCompletion );