Example #1
0
/*
    \internal
    Matches the current intermediate key sequence + the latest
    keyevent, with and AccelItem. Returns Identical,
    PartialMatch or NoMatch, and fills \a temp with the
    resulting key sequence.
*/
Qt::SequenceMatch QAccelManager::match( QKeyEvent *e, QAccelItem* item, QKeySequence& temp )
{
    SequenceMatch result = Qt::NoMatch;
    int index = intermediate.count();
    temp = intermediate;

    int modifier = translateModifiers( e->state() );

    if ( e->key() && e->key() != Key_unknown) {
	int key = e->key()  | modifier;
	if ( e->key() == Key_BackTab ) {
	    /*
	    In QApplication, we map shift+tab to shift+backtab.
	    This code here reverts the mapping in a way that keeps
	    backtab and shift+tab accelerators working, in that
	    order, meaning backtab has priority.*/
	    key &= ~SHIFT;

	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	    if ( e->state() & ShiftButton )
		key |= SHIFT;
	    key = Key_Tab | ( key & MODIFIER_MASK );
	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	} else {
	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	}

	if ( key == Key_BackTab ) {
	    if ( e->state() & ShiftButton )
		key |= SHIFT;
	    temp.setKey( key, index );
	    if ( Qt::NoMatch != (result = temp.matches( item->key )) )
		return result;
	}
    }
    if ( !e->text().isEmpty() ) {
        QChar c = e->text()[0];
        // be in accordance with accoQAccel::shortcutKey()
        if ( modifier != 0 && c.isPrint() )
            c = c.upper();
	temp.setKey( (int)c.unicode() | UNICODE_ACCEL | modifier, index );
	result = temp.matches( item->key );
    }
    return result;
}
Example #2
0
int QAccel::shortcutKey( const QString &str )
{
    int p = 0;
    while ( p >= 0 ) {
        p = str.find( '&', p ) + 1;
        if ( p <= 0 || p >= (int)str.length() )
            return 0;
        if ( str[p] != '&' ) {
            QChar c = str[p];
            if ( c.isPrint() ) {
                c = c.upper();
                return c.unicode() + ALT + UNICODE_ACCEL;
            }
        }
        p++;
    }
    return 0;
}
Example #3
0
QString
wDBTable::journalFieldName(long columnId)
{
	aCfgItem item;
	item= md->find(md->find(columnId),md_fieldid);
	item = md->find(md->text(item).toLong());
	if(!item.isNull())
	{
		QString s = md->attr(item,mda_type);
		QChar ch = s[0];
		if(ch.upper()=='O')
		{
			return QString("text_uf%1").arg(md->attr(item,mda_id));
		}
		else
		{
			return QString("uf%1").arg(md->attr(item,mda_id));
		}
	}
	return "uf0";

}
Example #4
0
void KeyGrabDialog::setKeyStr()
{
    QString keystr = QString::null;
    int keyval = pressed_keyval;
    ButtonState mod = pressed_keystate;

    /*
     * Ignore Shift modifier for printable char keys for
     * easy-to-recognize key configuration.  uim-custom performs
     * implicit shift key encoding/decoding appropriately.
     */
    if( ((keyval >= 256) || !isgraph(keyval)) &&
        (mod & Qt::ShiftButton) )
        keystr += "<Shift>";
    if( mod & Qt::ControlButton )
        keystr += "<Control>";
    if( mod & Qt::AltButton )
        keystr += "<Alt>";
    if( mod & Qt::MetaButton )
        keystr += "<Meta>";

    switch( keyval ) {
    case Qt::Key_Space:
        keystr += "space";
        break;
    case Qt::Key_BackSpace:
        keystr += "backspace";
        break;
    case Qt::Key_Delete:
        keystr += "delete";
        break;
    case Qt::Key_Insert:
        keystr += "insert";
        break;
    case Qt::Key_Escape:
        keystr += "escape";
        break;
    case Qt::Key_Tab:
        keystr += "tab";
        break;
    case Qt::Key_Return:
        keystr += "return";
        break;
    case Qt::Key_Left:
        keystr += "left";
        break;
    case Qt::Key_Up:
        keystr += "up";
        break;
    case Qt::Key_Right:
        keystr += "right";
        break;
    case Qt::Key_Down:
        keystr += "down";
        break;
    case Qt::Key_Prior:
        keystr += "prior";
        break;
    case Qt::Key_Next:
        keystr += "next";
        break;
    case Qt::Key_Home:
        keystr += "home";
        break;
    case Qt::Key_End:
        keystr += "end";
        break;
#ifdef QT_IMMODULE
    case Qt::Key_Multi_key:
        keystr += "Multi_key";
        break;
    case Qt::Key_Codeinput:
        keystr += "codeinput";
        break;
    case Qt::Key_SingleCandidate:
        keystr += "single-candidate";
        break;
    case Qt::Key_MultipleCandidate:
        keystr += "multiple-candidate";
        break;
    case Qt::Key_PreviousCandidate:
        keystr += "previous-candidate";
        break;
    case Qt::Key_Mode_switch:
        keystr += "Mode_switch";
        break;
    case Qt::Key_Kanji:
        keystr += "Kanji";
        break;
    case Qt::Key_Muhenkan:
        keystr += "Muhenkan";
        break;
    case Qt::Key_Henkan:
        keystr += "Henkan_Mode";
        break;
    case Qt::Key_Romaji:
        keystr += "romaji";
        break;
    case Qt::Key_Hiragana:
        keystr += "hiragana";
        break;
    case Qt::Key_Katakana:
        keystr += "katakana";
        break;
    case Qt::Key_Hiragana_Katakana:
        keystr += "hiragana-katakana";
        break;
    case Qt::Key_Zenkaku:
        keystr += "zenkaku";
        break;
    case Qt::Key_Hankaku:
        keystr += "hankaku";
        break;
    case Qt::Key_Zenkaku_Hankaku:
        keystr += "zenkaku-hankaku";
        break;
    case Qt::Key_Touroku:
        keystr += "touroku";
        break;
    case Qt::Key_Massyo:
        keystr += "massyo";
        break;
    case Qt::Key_Kana_Lock:
        keystr += "kana-lock";
        break;
    case Qt::Key_Kana_Shift:
        keystr += "kana-shift";
        break;
    case Qt::Key_Eisu_Shift:
        keystr += "eisu-shift";
        break;
    case Qt::Key_Eisu_toggle:
        keystr += "eisu-toggle";
        break;
    case Qt::Key_Hangul:
        keystr += "hangul";
        break;
    case Qt::Key_Hangul_Start:
        keystr += "hangul-start";
        break;
    case Qt::Key_Hangul_End:
        keystr += "hangul-end";
        break;
    case Qt::Key_Hangul_Hanja:
        keystr += "hangul-hanja";
        break;
    case Qt::Key_Hangul_Jamo:
        keystr += "hangul-jamo";
        break;
    case Qt::Key_Hangul_Romaja:
        keystr += "hangul-romaja";
        break;
    case Qt::Key_Hangul_Jeonja:
        keystr += "hangul-jeonja";
        break;
    case Qt::Key_Hangul_Banja:
        keystr += "hangul-banja";
        break;
    case Qt::Key_Hangul_PreHanja:
        keystr += "hangul-prehanja";
        break;
    case Qt::Key_Hangul_PostHanja:
        keystr += "hangul-prosthanja";
        break;
    case Qt::Key_Hangul_Special:
        keystr += "hangul-special";
        break;
    case Qt::Key_Dead_Grave:
        keystr += "dead-grave";
        break;
    case Qt::Key_Dead_Acute:
        keystr += "dead-acute";
        break;
    case Qt::Key_Dead_Circumflex:
        keystr += "dead-circumflex";
        break;
    case Qt::Key_Dead_Tilde:
        keystr += "dead-tilde";
        break;
    case Qt::Key_Dead_Macron:
        keystr += "dead-macron";
        break;
    case Qt::Key_Dead_Breve:
        keystr += "dead-breve";
        break;
    case Qt::Key_Dead_Abovedot:
        keystr += "dead-abovedot";
        break;
    case Qt::Key_Dead_Diaeresis:
        keystr += "dead-diaeresis";
        break;
    case Qt::Key_Dead_Abovering:
        keystr += "dead-abovering";
        break;
    case Qt::Key_Dead_Doubleacute:
        keystr += "dead-doubleacute";
        break;
    case Qt::Key_Dead_Caron:
        keystr += "dead-caron";
        break;
    case Qt::Key_Dead_Cedilla:
        keystr += "dead-cedilla";
        break;
    case Qt::Key_Dead_Ogonek:
        keystr += "dead-ogonek";
        break;
    case Qt::Key_Dead_Iota:
        keystr += "dead-iota";
        break;
    case Qt::Key_Dead_Voiced_Sound:
        keystr += "dead-voiced-sound";
        break;
    case Qt::Key_Dead_Semivoiced_Sound:
        keystr += "dead-semivoiced-sound";
        break;
    case Qt::Key_Dead_Belowdot:
        keystr += "dead-belowdot";
        break;
    case Qt::Key_Dead_Hook:
        keystr += "dead-hook";
        break;
    case Qt::Key_Dead_Horn:
        keystr += "dead-horn";
        break;
#endif /* Def: QT_IMMODULE */
    case Qt::Key_Shift:
        keystr += "Shift_key";
        break;
    case Qt::Key_Control:
        keystr += "Control_key";
        break;
    case Qt::Key_Alt:
        keystr += "Alt_key";
        break;
    case Qt::Key_Meta:
        keystr += "Meta_key";
        break;
    case Qt::Key_Super_L:
    case Qt::Key_Super_R:
        keystr += "Super_key";
        break;
    case Qt::Key_Hyper_L:
    case Qt::Key_Hyper_R:
        keystr += "Hyper_key";
        break;
    case Qt::Key_CapsLock:
        keystr += "caps-lock";
        break;
    case Qt::Key_NumLock:
        keystr += "num-lock";
        break;
    case Qt::Key_ScrollLock:
        keystr += "scroll-lock";
        break;
    case Qt::Key_unknown:
        keystr += unicodeKeyToSymStr ( pressed_unichar );
        break;
    default:
        if( keyval >= Qt::Key_F1 && keyval <= Qt::Key_F35 )
        {
            keystr += "F" + QString::number( keyval - Qt::Key_F1 + 1 );
            break;
        }
        else if( keyval < 256 )
        {
            QChar ch = QChar( keyval );
            
            if( mod & Qt::ShiftButton ) 
                ch = ch.upper();
            else
                ch = ch.lower();

            keystr += ch;
        }
    }

    m_keystr = keystr;
        
}
bool CppEditorCompletion::doObjectCompletion( const QString &objName )
{
    if ( !ths )
	return FALSE;
    QString object( objName );
    int i = -1;
    if ( ( i = object.findRev( "->" ) ) != -1 )
	object = object.mid( i + 2 );
    if ( ( i = object.findRev( "." ) ) != -1 )
	object = object.mid( i + 1 );
    object = object.simplifyWhiteSpace();
    QObject *obj = 0;
    if ( ths->name() == object || object == "this" ) {
	obj = ths;
    } else {
	obj = ths->child( object );
    }

    if ( !obj )
	return FALSE;

    QValueList<CompletionEntry> lst;

    if ( obj->children() ) {
	for ( QObjectListIt cit( *obj->children() ); cit.current(); ++cit ) {
	    QString s( cit.current()->name() );
	    if ( s.find( " " ) == -1 && s.find( "qt_" ) == -1 && s.find( "unnamed" ) == -1 ) {
		CompletionEntry c;
		c.type = "variable";
		c.text = s;
		c.prefix = "";
		lst << c;
	    }
	}
    }

    QStrList props = obj->metaObject()->propertyNames( TRUE );
    for ( QPtrListIterator<char> pit( props ); pit.current(); ++pit ) {
	QString f( pit.current() );
	QChar c = f[ 0 ];
	f.remove( (uint)0, 1 );
	f.prepend( c.upper() );
	f.prepend( "set" );

	CompletionEntry ce;
	ce.type = "property";
	ce.text = f;
	ce.postfix = "()";

	if ( lst.find( ce ) == lst.end() )
	    lst << ce;
    }

    QStrList slts = obj->metaObject()->slotNames( TRUE );
    for ( QPtrListIterator<char> sit( slts ); sit.current(); ++sit ) {
	QString f( sit.current() );
	f = f.left( f.find( "(" ) );
	CompletionEntry c;
	c.type = "slot";
	c.text = f;
	c.postfix = "()";
	if ( lst.find( c ) == lst.end() )
	    lst << c;
    }

    if ( lst.isEmpty() )
	return FALSE;

    showCompletion( lst );
    return TRUE;
}