本文整理汇总了C++中KShortcut::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ KShortcut::contains方法的具体用法?C++ KShortcut::contains怎么用?C++ KShortcut::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KShortcut
的用法示例。
在下文中一共展示了KShortcut::contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressEvent
void KLineEdit::keyPressEvent( QKeyEvent *e )
{
KKey key( e );
if ( KStdAccel::copy().contains( key ) )
{
copy();
return;
}
else if ( KStdAccel::paste().contains( key ) )
{
paste();
return;
}
else if ( KStdAccel::pasteSelection().contains( key ) )
{
QString text = QApplication::clipboard()->text( QClipboard::Selection);
insert( text );
deselect();
return;
}
else if ( KStdAccel::cut().contains( key ) )
{
cut();
return;
}
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;
}
else if ( KStdAccel::backwardWord().contains( key ) )
{
cursorWordBackward(false);
e->accept();
return;
}
else if ( KStdAccel::forwardWord().contains( key ) )
{
cursorWordForward(false);
e->accept();
return;
}
else if ( KStdAccel::beginningOfLine().contains( key ) )
{
home(false);
e->accept();
return;
}
else if ( KStdAccel::endOfLine().contains( key ) )
{
end(false);
e->accept();
return;
}
// Filter key-events if EchoMode is normal and
// completion mode is not set to CompletionNone
if ( echoMode() == QLineEdit::Normal &&
completionMode() != KGlobalSettings::CompletionNone )
{
KeyBindingMap keys = getKeyBindings();
KGlobalSettings::Completion mode = completionMode();
bool noModifier = (e->state() == NoButton ||
e->state() == ShiftButton ||
e->state() == Keypad);
if ( (mode == KGlobalSettings::CompletionAuto ||
mode == KGlobalSettings::CompletionPopupAuto ||
mode == KGlobalSettings::CompletionMan) && noModifier )
{
if ( !d->userSelection && hasSelectedText() &&
( e->key() == Key_Right || e->key() == Key_Left ) &&
e->state()==NoButton )
//.........这里部分代码省略.........
示例2: keyPressEvent
void KreTextEdit::keyPressEvent( QKeyEvent *e )
{
// Filter key-events if completion mode is not set to CompletionNone
KeyBindingMap keys = getKeyBindings();
KShortcut cut;
bool noModifier = ( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::ShiftModifier );
if ( noModifier ) {
QString keycode = e->text();
if ( !keycode.isEmpty() && keycode.unicode() ->isPrint() ) {
KTextEdit::keyPressEvent ( e );
tryCompletion();
e->accept();
return ;
}
}
// Handles completion
if ( keys[ TextCompletion ].isEmpty() )
cut = KStandardShortcut::shortcut( KStandardShortcut::TextCompletion );
else
cut = keys[ TextCompletion ];
//using just the standard Ctrl+E isn't user-friendly enough for Grandma...
if ( completing && ( cut.contains( e->key() ) || e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) ) {
#if 0
int paraFrom, indexFrom, paraTo, indexTo;
getSelection ( ¶From, &indexFrom, ¶To, &indexTo );
removeSelection();
setCursorPosition( paraTo, indexTo );
completing = false;
return ;
#endif
}
// handle rotation
// Handles previous match
if ( keys[ PrevCompletionMatch ].isEmpty() )
cut = KStandardShortcut::shortcut( KStandardShortcut::PrevCompletion );
else
cut = keys[ PrevCompletionMatch ];
if ( cut.contains( e->key() ) ) {
rotateText( KCompletionBase::PrevCompletionMatch );
return ;
}
// Handles next match
if ( keys[ NextCompletionMatch ].isEmpty() )
cut = KStandardShortcut::shortcut( KStandardShortcut::NextCompletion );
else
cut = keys[ NextCompletionMatch ];
if ( cut.contains( e->key() ) ) {
rotateText( KCompletionBase::NextCompletionMatch );
return ;
}
//any other key events will end any text completion execpt for modifiers
switch ( e->key() ) {
case Qt::Key_Shift:
case Qt::Key_Control:
case Qt::Key_Alt:
case Qt::Key_Meta:
break;
default:
completing = false;
break;
}
// Let KTextEdit handle any other keys events.
KTextEdit::keyPressEvent ( e );
}