author | ar <ar> | 2005-01-21 20:19:00 (UTC) |
---|---|---|
committer | ar <ar> | 2005-01-21 20:19:00 (UTC) |
commit | 55eccecc08f839878e5743d6e6be25af386b5a3f (patch) (side-by-side diff) | |
tree | fd663ded2a2c097ce53bac6c021ca652ef5b5508 /libopie2/qt3/opieui/olineedit.cpp | |
parent | cd51d382be50bc021739395309e23760f1619759 (diff) | |
download | opie-55eccecc08f839878e5743d6e6be25af386b5a3f.zip opie-55eccecc08f839878e5743d6e6be25af386b5a3f.tar.gz opie-55eccecc08f839878e5743d6e6be25af386b5a3f.tar.bz2 |
- make opie compilable against qte 2.3.10 snapshot
change QT_VERSION > 290 into QT_VERSION <= 0x030000
Diffstat (limited to 'libopie2/qt3/opieui/olineedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/qt3/opieui/olineedit.cpp | 6 |
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 @@ -100,97 +100,97 @@ void OLineEdit::init() installEventFilter( this ); } void OLineEdit::setCompletionMode( OGlobalSettings::Completion mode ) { OGlobalSettings::Completion oldMode = completionMode(); if ( oldMode != mode && oldMode == OGlobalSettings::CompletionPopup && d->completionBox && d->completionBox->isVisible() ) d->completionBox->hide(); // If the widgets echo mode is not Normal, no completion // feature will be enabled even if one is requested. if ( echoMode() != QLineEdit::Normal ) mode = OGlobalSettings::CompletionNone; // Override the request. OCompletionBase::setCompletionMode( mode ); } void OLineEdit::setCompletedText( const QString& t, bool marked ) { QString txt = text(); if ( t != txt ) { int curpos = marked ? txt.length() : t.length(); validateAndSet( t, curpos, curpos, t.length() ); } } void OLineEdit::setCompletedText( const QString& text ) { OGlobalSettings::Completion mode = completionMode(); bool marked = ( mode == OGlobalSettings::CompletionAuto || mode == OGlobalSettings::CompletionMan || mode == OGlobalSettings::CompletionPopup ); setCompletedText( text, marked ); } void OLineEdit::rotateText( OCompletionBase::KeyBindingType type ) { OCompletion* comp = compObj(); if ( comp && (type == OCompletionBase::PrevCompletionMatch || type == OCompletionBase::NextCompletionMatch ) ) { QString input = (type == OCompletionBase::PrevCompletionMatch) ? comp->previousMatch() : comp->nextMatch(); // Skip rotation if previous/next match is null or the same text if ( input.isNull() || input == displayText() ) return; - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 setCompletedText( input, hasSelectedText() ); #else setCompletedText( input, hasMarkedText() ); #endif } } void OLineEdit::makeCompletion( const QString& text ) { OCompletion *comp = compObj(); if ( !comp ) return; // No completion object... QString match = comp->makeCompletion( text ); OGlobalSettings::Completion mode = completionMode(); if ( mode == OGlobalSettings::CompletionPopup ) { if ( match.isNull() ) { if ( d->completionBox ) { d->completionBox->hide(); d->completionBox->clear(); } } else setCompletedItems( comp->allMatches() ); } else { // all other completion modes // If no match or the same match, simply return without completing. if ( match.isNull() || match == text ) return; setCompletedText( match ); } } void OLineEdit::setReadOnly(bool readOnly) { QPalette p = palette(); if (readOnly) { QColor color = p.color(QPalette::Disabled, QColorGroup::Background); p.setColor(QColorGroup::Base, color); p.setColor(QColorGroup::Background, color); } else @@ -226,97 +226,97 @@ void OLineEdit::keyPressEvent( QKeyEvent *e ) } else if ( KStdAccel::undo().contains( key ) ) { undo(); return; } else if ( KStdAccel::redo().contains( key ) ) { redo(); return; } else if ( KStdAccel::deleteWordBack().contains( key ) ) { cursorWordBackward(TRUE); if ( hasSelectedText() ) del(); e->accept(); return; } else if ( KStdAccel::deleteWordForward().contains( key ) ) { // Workaround for QT bug where cursorWordForward(TRUE); if ( hasSelectedText() ) del(); e->accept(); return; } */ // Filter key-events if EchoMode is normal & // completion mode is not set to CompletionNone if ( echoMode() == QLineEdit::Normal && completionMode() != OGlobalSettings::CompletionNone ) { KeyBindingMap keys = getKeyBindings(); OGlobalSettings::Completion mode = completionMode(); bool noModifier = (e->state() == NoButton || e->state()== ShiftButton); if ( (mode == OGlobalSettings::CompletionAuto || mode == OGlobalSettings::CompletionMan) && noModifier ) { QString keycode = e->text(); if ( !keycode.isNull() && keycode.unicode()->isPrint() ) { QLineEdit::keyPressEvent ( e ); QString txt = text(); int len = txt.length(); - #if QT_VERSION > 290 + #if QT_VERSION >= 0x030000 if ( !hasSelectedText() && len && cursorPosition() == len ) #else if ( !hasMarkedText() && len && cursorPosition() == len ) #endif { if ( emitSignals() ) emit completion( txt ); if ( handleSignals() ) makeCompletion( txt ); e->accept(); } return; } } else if ( mode == OGlobalSettings::CompletionPopup && noModifier ) { qDebug( "OLineEdit::keyPressEvent() - global settings = CompletionPopup & noModifier" ); QString old_txt = text(); QLineEdit::keyPressEvent ( e ); QString txt = text(); int len = txt.length(); QString keycode = e->text(); if ( txt != old_txt && len && cursorPosition() == len && ( (!keycode.isNull() && keycode.unicode()->isPrint()) || e->key() == Key_Backspace ) ) { if ( emitSignals() ) emit completion( txt ); // emit when requested... if ( handleSignals() ) makeCompletion( txt ); // handle when requested... e->accept(); } else if (!len && d->completionBox && d->completionBox->isVisible()) d->completionBox->hide(); return; } /*else if ( mode == OGlobalSettings::CompletionShell ) { // Handles completion. KShortcut cut; if ( keys[TextCompletion].isNull() ) cut = KStdAccel::shortcut(KStdAccel::TextCompletion); @@ -391,97 +391,97 @@ void OLineEdit::keyPressEvent( QKeyEvent *e ) 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 + #if QT_VERSION >= 0x030000 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) ) ); 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) |