author | alwin <alwin> | 2004-03-02 13:25:49 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 13:25:49 (UTC) |
commit | ac3e7c0a1ccbb984f06917ebe6156b1681b7de7f (patch) (side-by-side diff) | |
tree | dbfc670acbb2bee8032c1fa34b45948cf3b9631b /libopie2/qt3/opieui/olineedit.cpp | |
parent | b6b1c97559c0ed9f2e33632272426bf98f289232 (diff) | |
download | opie-ac3e7c0a1ccbb984f06917ebe6156b1681b7de7f.zip opie-ac3e7c0a1ccbb984f06917ebe6156b1681b7de7f.tar.gz opie-ac3e7c0a1ccbb984f06917ebe6156b1681b7de7f.tar.bz2 |
applied changes from optimize_connect script
Diffstat (limited to 'libopie2/qt3/opieui/olineedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/qt3/opieui/olineedit.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libopie2/qt3/opieui/olineedit.cpp b/libopie2/qt3/opieui/olineedit.cpp index 9cb0cff..6f66fc7 100644 --- a/libopie2/qt3/opieui/olineedit.cpp +++ b/libopie2/qt3/opieui/olineedit.cpp @@ -322,408 +322,408 @@ void OLineEdit::keyPressEvent( QKeyEvent *e ) cut = KStdAccel::shortcut(KStdAccel::TextCompletion); else cut = keys[TextCompletion]; if ( cut.contains( key ) ) { // Emit completion if the completion mode is CompletionShell // and the cursor is at the end of the string. QString txt = text(); int len = txt.length(); if ( cursorPosition() == len && len != 0 ) { if ( emitSignals() ) emit completion( txt ); if ( handleSignals() ) makeCompletion( txt ); return; } } else if ( d->completionBox ) d->completionBox->hide(); } // handle rotation if ( mode != OGlobalSettings::CompletionNone ) { // Handles previous match KShortcut cut; if ( keys[PrevCompletionMatch].isNull() ) cut = KStdAccel::shortcut(KStdAccel::PrevCompletion); else cut = keys[PrevCompletionMatch]; if ( cut.contains( key ) ) { if ( emitSignals() ) emit textRotation( OCompletionBase::PrevCompletionMatch ); if ( handleSignals() ) rotateText( OCompletionBase::PrevCompletionMatch ); return; } // Handles next match if ( keys[NextCompletionMatch].isNull() ) cut = KStdAccel::key(KStdAccel::NextCompletion); else cut = keys[NextCompletionMatch]; if ( cut.contains( key ) ) { if ( emitSignals() ) emit textRotation( OCompletionBase::NextCompletionMatch ); if ( handleSignals() ) rotateText( OCompletionBase::NextCompletionMatch ); return; } } // substring completion if ( compObj() ) { KShortcut cut; if ( keys[SubstringCompletion].isNull() ) cut = KStdAccel::shortcut(KStdAccel::SubstringCompletion); else cut = keys[SubstringCompletion]; if ( cut.contains( key ) ) { if ( emitSignals() ) emit substringCompletion( text() ); if ( handleSignals() ) { setCompletedItems( compObj()->substringCompletion(text())); e->accept(); } return; } } */ } // Let QLineEdit handle any other keys events. QLineEdit::keyPressEvent ( e ); } void OLineEdit::mouseDoubleClickEvent( QMouseEvent* e ) { if ( e->button() == Qt::LeftButton ) { possibleTripleClick=true; QTimer::singleShot( QApplication::doubleClickInterval(),this, SLOT(tripleClickTimeout()) ); } QLineEdit::mouseDoubleClickEvent( e ); } void OLineEdit::mousePressEvent( QMouseEvent* e ) { if ( possibleTripleClick && e->button() == Qt::LeftButton ) { selectAll(); return; } QLineEdit::mousePressEvent( e ); } void OLineEdit::tripleClickTimeout() { possibleTripleClick=false; } QPopupMenu *OLineEdit::createPopupMenu() { // Return if popup menu is not enabled !! if ( !m_bEnableMenu ) return 0; #if QT_VERSION > 290 QPopupMenu *popup = QLineEdit::createPopupMenu(); #else QPopupMenu *popup = new QPopupMenu(); #warning OLineEdit is not fully functional on Qt2 #endif // completion object is present. if ( compObj() ) { QPopupMenu *subMenu = new QPopupMenu( popup ); - connect( subMenu, SIGNAL( activated( int ) ), - this, SLOT( completionMenuActivated( int ) ) ); + connect( subMenu, SIGNAL( activated(int) ), + this, SLOT( completionMenuActivated(int) ) ); popup->insertSeparator(); //popup->insertItem( SmallIconSet("completion"), i18n("Text Completion"), // subMenu ); popup->insertItem( tr("Text Completion"), subMenu ); subMenu->insertItem( tr("None"), NoCompletion ); subMenu->insertItem( tr("Manual"), ShellCompletion ); subMenu->insertItem( tr("Automatic"), AutoCompletion ); subMenu->insertItem( tr("Dropdown List"), PopupCompletion ); subMenu->insertItem( tr("Short Automatic"), SemiAutoCompletion ); //subMenu->setAccel( KStdAccel::completion(), ShellCompletion ); subMenu->setAccel( Key_Tab, ShellCompletion ); OGlobalSettings::Completion mode = completionMode(); subMenu->setItemChecked( NoCompletion, mode == OGlobalSettings::CompletionNone ); subMenu->setItemChecked( ShellCompletion, mode == OGlobalSettings::CompletionShell ); subMenu->setItemChecked( PopupCompletion, mode == OGlobalSettings::CompletionPopup ); subMenu->setItemChecked( AutoCompletion, mode == OGlobalSettings::CompletionAuto ); subMenu->setItemChecked( SemiAutoCompletion, mode == OGlobalSettings::CompletionMan ); if ( mode != OGlobalSettings::completionMode() ) { subMenu->insertSeparator(); subMenu->insertItem( tr("Default"), Default ); } } // ### do we really need this? Yes, Please do not remove! This // allows applications to extend the popup menu without having to // inherit from this class! (DA) emit aboutToShowContextMenu( popup ); return popup; } void OLineEdit::completionMenuActivated( int id ) { OGlobalSettings::Completion oldMode = completionMode(); switch ( id ) { case Default: setCompletionMode( OGlobalSettings::completionMode() ); break; case NoCompletion: setCompletionMode( OGlobalSettings::CompletionNone ); break; case AutoCompletion: setCompletionMode( OGlobalSettings::CompletionAuto ); break; case SemiAutoCompletion: setCompletionMode( OGlobalSettings::CompletionMan ); break; case ShellCompletion: setCompletionMode( OGlobalSettings::CompletionShell ); break; case PopupCompletion: setCompletionMode( OGlobalSettings::CompletionPopup ); break; default: return; } if ( oldMode != completionMode() ) { if ( oldMode == OGlobalSettings::CompletionPopup && d->completionBox && d->completionBox->isVisible() ) d->completionBox->hide(); emit completionModeChanged( completionMode() ); } } /*void OLineEdit::dropEvent(QDropEvent *e) { KURL::List urlList; if( d->handleURLDrops && KURLDrag::decode( e, urlList ) ) { QString dropText = text(); KURL::List::ConstIterator it; for( it = urlList.begin() ; it != urlList.end() ; ++it ) { if(!dropText.isEmpty()) dropText+=' '; dropText += (*it).prettyURL(); } validateAndSet( dropText, dropText.length(), 0, 0); e->accept(); } else QLineEdit::dropEvent(e); }*/ bool OLineEdit::eventFilter( QObject* o, QEvent* ev ) { if( o == this ) { //OCursor::autoHideEventFilter( this, ev ); if ( ev->type() == QEvent::AccelOverride ) { QKeyEvent *e = static_cast<QKeyEvent *>( ev ); // if (overrideAccel (e)) // { // e->accept(); // return true; // } } else if( ev->type() == QEvent::KeyPress ) { QKeyEvent *e = static_cast<QKeyEvent *>( ev ); if( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { bool trap = d->completionBox && d->completionBox->isVisible(); // Qt will emit returnPressed() itself if we return false if ( d->grabReturnKeyEvents || trap ) emit QLineEdit::returnPressed(); emit returnPressed( displayText() ); if ( trap ) d->completionBox->hide(); // Eat the event if the user asked for it, or if a completionbox was visible return d->grabReturnKeyEvents || trap; } } } return QLineEdit::eventFilter( o, ev ); } void OLineEdit::setURLDropsEnabled(bool enable) { d->handleURLDrops=enable; } bool OLineEdit::isURLDropsEnabled() const { return d->handleURLDrops; } void OLineEdit::setTrapReturnKey( bool grab ) { d->grabReturnKeyEvents = grab; } bool OLineEdit::trapReturnKey() const { return d->grabReturnKeyEvents; } /*void OLineEdit::setURL( const KURL& url ) { QLineEdit::setText( url.prettyURL() ); }*/ void OLineEdit::makeCompletionBox() { if ( d->completionBox ) return; d->completionBox = new OCompletionBox( this, "completion box" ); if ( handleSignals() ) { - connect( d->completionBox, SIGNAL(highlighted( const QString& )), - SLOT(setText( const QString& )) ); - connect( d->completionBox, SIGNAL(userCancelled( const QString& )), - SLOT(setText( const QString& )) ); + connect( d->completionBox, SIGNAL(highlighted(const QString&)), + SLOT(setText(const QString&)) ); + connect( d->completionBox, SIGNAL(userCancelled(const QString&)), + SLOT(setText(const QString&)) ); // Nice lil' hacklet ;) KComboBox doesn't know when the completionbox // is created (childEvent() is even more hacky, IMHO), so we simply // forward the completionbox' activated signal from here. if ( parentWidget() && parentWidget()->inherits("KComboBox") ) - connect( d->completionBox, SIGNAL( activated( const QString& )), - parentWidget(), SIGNAL( activated( const QString & ))); + connect( d->completionBox, SIGNAL( activated(const QString&)), + parentWidget(), SIGNAL( activated(const QString&))); } } /*bool OLineEdit::overrideAccel (const QKeyEvent* e) { KShortcut scKey; KKey key( e ); KeyBindingMap keys = getKeyBindings(); if (keys[TextCompletion].isNull()) scKey = KStdAccel::shortcut(KStdAccel::TextCompletion); else scKey = keys[TextCompletion]; if (scKey.contains( key )) return true; if (keys[NextCompletionMatch].isNull()) scKey = KStdAccel::shortcut(KStdAccel::NextCompletion); else scKey = keys[NextCompletionMatch]; if (scKey.contains( key )) return true; if (keys[PrevCompletionMatch].isNull()) scKey = KStdAccel::shortcut(KStdAccel::PrevCompletion); else scKey = keys[PrevCompletionMatch]; if (scKey.contains( key )) return true; if (KStdAccel::deleteWordBack().contains( key )) return true; if (KStdAccel::deleteWordForward().contains( key )) return true; if (d->completionBox && d->completionBox->isVisible ()) if (e->key () == Key_Backtab) return true; return false; }*/ void OLineEdit::setCompletedItems( const QStringList& items ) { QString txt = text(); if ( !items.isEmpty() && !(items.count() == 1 && txt == items.first()) ) { if ( !d->completionBox ) makeCompletionBox(); if ( !txt.isEmpty() ) d->completionBox->setCancelledText( txt ); d->completionBox->setItems( items ); d->completionBox->popup(); } else { if ( d->completionBox && d->completionBox->isVisible() ) d->completionBox->hide(); } } OCompletionBox * OLineEdit::completionBox( bool create ) { if ( create ) makeCompletionBox(); return d->completionBox; } void OLineEdit::setCompletionObject( OCompletion* comp, bool hsig ) { OCompletion *oldComp = compObj(); if ( oldComp && handleSignals() ) - disconnect( oldComp, SIGNAL( matches( const QStringList& )), - this, SLOT( setCompletedItems( const QStringList& ))); + disconnect( oldComp, SIGNAL( matches(const QStringList&)), + this, SLOT( setCompletedItems(const QStringList&))); if ( comp && hsig ) - connect( comp, SIGNAL( matches( const QStringList& )), - this, SLOT( setCompletedItems( const QStringList& ))); + connect( comp, SIGNAL( matches(const QStringList&)), + this, SLOT( setCompletedItems(const QStringList&))); OCompletionBase::setCompletionObject( comp, hsig ); } // QWidget::create() turns off mouse-Tracking which would break auto-hiding void OLineEdit::create( WId id, bool initializeWindow, bool destroyOldWindow ) { QLineEdit::create( id, initializeWindow, destroyOldWindow ); //OCursor::setAutoHideCursor( this, true, true ); } void OLineEdit::clear() { setText( QString::null ); } |