int QuazaaCssScanner_Generated::lex() { lexemStart = pos; lexemLength = 0; int lastAcceptingPos = -1; int token = -1; QChar ch; // initial state ch = next(); if(ch.unicode() >= 9 && ch.unicode() <= 10) { goto state_1; } if(ch.unicode() >= 12 && ch.unicode() <= 13) { goto state_1; } if(ch.unicode() == 32) { goto state_1; } if(ch.unicode() == 33) { token = QuazaaCss::EXCLAMATION_SYM; goto found; } if(ch.unicode() == 34) { goto state_3; } if(ch.unicode() == 35) { goto state_4; } if(ch.unicode() == 39) { goto state_5; } if(ch.unicode() == 40) { token = QuazaaCss::LPAREN; goto found; } if(ch.unicode() == 41) { token = QuazaaCss::RPAREN; goto found; } if(ch.unicode() == 42) { token = QuazaaCss::STAR; goto found; } if(ch.unicode() == 43) { goto state_9; } if(ch.unicode() == 44) { goto state_10; } if(ch.unicode() == 45) { goto state_11; } if(ch.unicode() == 46) { goto state_12; } if(ch.unicode() == 47) { goto state_13; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_14; } if(ch.unicode() == 58) { token = QuazaaCss::COLON; goto found; } if(ch.unicode() == 59) { token = QuazaaCss::SEMICOLON; goto found; } if(ch.unicode() == 60) { goto state_17; } if(ch.unicode() == 61) { token = QuazaaCss::EQUAL; goto found; } if(ch.unicode() == 62) { goto state_19; } if(ch.unicode() == 64) { goto state_20; } if(ch.unicode() == 91) { token = QuazaaCss::LBRACKET; goto found; } if(ch.unicode() == 92) { goto state_22; } if(ch.unicode() == 93) { token = QuazaaCss::RBRACKET; goto found; } if(ch.unicode() == 95) { goto state_24; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_24; } if(ch.unicode() == 123) { goto state_25; } if(ch.unicode() == 124) { goto state_26; } if(ch.unicode() == 125) { token = QuazaaCss::RBRACE; goto found; } if(ch.unicode() == 126) { goto state_28; } goto out; state_1: lastAcceptingPos = pos; token = QuazaaCss::S; ch = next(); if(ch.unicode() >= 9 && ch.unicode() <= 10) { goto state_29; } if(ch.unicode() >= 12 && ch.unicode() <= 13) { goto state_29; } if(ch.unicode() == 32) { goto state_29; } if(ch.unicode() == 43) { goto state_9; } if(ch.unicode() == 44) { goto state_10; } if(ch.unicode() == 62) { goto state_19; } if(ch.unicode() == 123) { goto state_25; } goto out; state_3: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_4: ch = next(); if(ch.unicode() == 45) { goto state_33; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_33; } if(ch.unicode() == 92) { goto state_34; } if(ch.unicode() == 95) { goto state_33; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_33; } goto out; state_5: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_9: lastAcceptingPos = pos; token = QuazaaCss::PLUS; goto out; state_10: lastAcceptingPos = pos; token = QuazaaCss::COMMA; goto out; state_11: lastAcceptingPos = pos; token = QuazaaCss::MINUS; ch = next(); if(ch.unicode() == 45) { goto state_38; } if(ch.unicode() == 92) { goto state_22; } if(ch.unicode() == 95) { goto state_24; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_24; } goto out; state_12: lastAcceptingPos = pos; token = QuazaaCss::DOT; ch = next(); if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_39; } goto out; state_13: lastAcceptingPos = pos; token = QuazaaCss::SLASH; ch = next(); if(ch.unicode() == 42) { token = handleCommentStart(); goto found; } goto out; state_14: lastAcceptingPos = pos; token = QuazaaCss::NUMBER; ch = next(); if(ch.unicode() == 37) { goto state_41; } if(ch.unicode() == 45) { goto state_42; } if(ch.unicode() == 46) { goto state_43; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_44; } if(ch.unicode() == 92) { goto state_45; } if(ch.unicode() == 95) { goto state_46; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_46; } goto out; state_17: ch = next(); if(ch.unicode() == 33) { goto state_47; } goto out; state_19: lastAcceptingPos = pos; token = QuazaaCss::GREATER; goto out; state_20: ch = next(); if(ch.unicode() == 45) { goto state_48; } if(ch.unicode() == 92) { goto state_49; } if(ch.unicode() == 95) { goto state_50; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_50; } goto out; state_22: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_51; } if(ch.unicode() == 11) { goto state_51; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_51; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_51; } if(ch.unicode() >= 103) { goto state_51; } goto out; state_24: lastAcceptingPos = pos; token = QuazaaCss::IDENT; ch = next(); if(ch.unicode() == 40) { goto state_52; } if(ch.unicode() == 45) { goto state_53; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_53; } if(ch.unicode() == 92) { goto state_54; } if(ch.unicode() == 95) { goto state_53; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_53; } goto out; state_25: lastAcceptingPos = pos; token = QuazaaCss::LBRACE; goto out; state_26: lastAcceptingPos = pos; token = QuazaaCss::OR; ch = next(); if(ch.unicode() == 61) { token = QuazaaCss::DASHMATCH; goto found; } goto out; state_28: ch = next(); if(ch.unicode() == 61) { token = QuazaaCss::INCLUDES; goto found; } goto out; state_29: lastAcceptingPos = pos; token = QuazaaCss::S; ch = next(); if(ch.unicode() >= 9 && ch.unicode() <= 10) { goto state_29; } if(ch.unicode() >= 12 && ch.unicode() <= 13) { goto state_29; } if(ch.unicode() == 32) { goto state_29; } if(ch.unicode() == 43) { goto state_9; } if(ch.unicode() == 44) { goto state_10; } if(ch.unicode() == 62) { goto state_19; } if(ch.unicode() == 123) { goto state_25; } goto out; state_30: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_31: lastAcceptingPos = pos; token = QuazaaCss::STRING; goto out; state_32: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_57; } if(ch.unicode() == 10) { goto state_58; } if(ch.unicode() == 11) { goto state_57; } if(ch.unicode() == 12) { goto state_59; } if(ch.unicode() == 13) { goto state_60; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_57; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_57; } if(ch.unicode() >= 103) { goto state_57; } goto out; state_33: lastAcceptingPos = pos; token = QuazaaCss::HASH; ch = next(); if(ch.unicode() == 45) { goto state_61; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_61; } if(ch.unicode() == 92) { goto state_62; } if(ch.unicode() == 95) { goto state_61; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_61; } goto out; state_34: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_63; } if(ch.unicode() == 11) { goto state_63; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_63; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_63; } if(ch.unicode() >= 103) { goto state_63; } goto out; state_35: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_36: lastAcceptingPos = pos; token = QuazaaCss::STRING; goto out; state_37: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_64; } if(ch.unicode() == 10) { goto state_65; } if(ch.unicode() == 11) { goto state_64; } if(ch.unicode() == 12) { goto state_66; } if(ch.unicode() == 13) { goto state_67; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_64; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_64; } if(ch.unicode() >= 103) { goto state_64; } goto out; state_38: ch = next(); if(ch.unicode() == 62) { token = QuazaaCss::CDC; goto found; } goto out; state_39: lastAcceptingPos = pos; token = QuazaaCss::NUMBER; ch = next(); if(ch.unicode() == 37) { goto state_41; } if(ch.unicode() == 45) { goto state_42; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_69; } if(ch.unicode() == 92) { goto state_45; } if(ch.unicode() == 95) { goto state_46; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_46; } goto out; state_41: lastAcceptingPos = pos; token = QuazaaCss::PERCENTAGE; goto out; state_42: ch = next(); if(ch.unicode() == 92) { goto state_45; } if(ch.unicode() == 95) { goto state_46; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_46; } goto out; state_43: ch = next(); if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_39; } goto out; state_44: lastAcceptingPos = pos; token = QuazaaCss::NUMBER; ch = next(); if(ch.unicode() == 37) { goto state_41; } if(ch.unicode() == 45) { goto state_42; } if(ch.unicode() == 46) { goto state_43; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_44; } if(ch.unicode() == 92) { goto state_45; } if(ch.unicode() == 95) { goto state_46; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_46; } goto out; state_45: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_70; } if(ch.unicode() == 11) { goto state_70; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_70; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_70; } if(ch.unicode() >= 103) { goto state_70; } goto out; state_46: lastAcceptingPos = pos; token = QuazaaCss::LENGTH; ch = next(); if(ch.unicode() == 45) { goto state_71; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_71; } if(ch.unicode() == 92) { goto state_72; } if(ch.unicode() == 95) { goto state_71; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_71; } goto out; state_47: ch = next(); if(ch.unicode() == 45) { goto state_73; } goto out; state_48: ch = next(); if(ch.unicode() == 92) { goto state_49; } if(ch.unicode() == 95) { goto state_50; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_50; } goto out; state_49: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_74; } if(ch.unicode() == 11) { goto state_74; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_74; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_74; } if(ch.unicode() >= 103) { goto state_74; } goto out; state_50: lastAcceptingPos = pos; token = QuazaaCss::ATKEYWORD_SYM; ch = next(); if(ch.unicode() == 45) { goto state_75; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_75; } if(ch.unicode() == 92) { goto state_76; } if(ch.unicode() == 95) { goto state_75; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_75; } goto out; state_51: lastAcceptingPos = pos; token = QuazaaCss::IDENT; ch = next(); if(ch.unicode() == 40) { goto state_52; } if(ch.unicode() == 45) { goto state_53; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_53; } if(ch.unicode() == 92) { goto state_54; } if(ch.unicode() == 95) { goto state_53; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_53; } goto out; state_52: lastAcceptingPos = pos; token = QuazaaCss::FUNCTION; goto out; state_53: lastAcceptingPos = pos; token = QuazaaCss::IDENT; ch = next(); if(ch.unicode() == 40) { goto state_52; } if(ch.unicode() == 45) { goto state_53; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_53; } if(ch.unicode() == 92) { goto state_54; } if(ch.unicode() == 95) { goto state_53; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_53; } goto out; state_54: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_77; } if(ch.unicode() == 11) { goto state_77; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_77; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_77; } if(ch.unicode() >= 103) { goto state_77; } goto out; state_57: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_58: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_59: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_60: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 10) { goto state_78; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_61: lastAcceptingPos = pos; token = QuazaaCss::HASH; ch = next(); if(ch.unicode() == 45) { goto state_61; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_61; } if(ch.unicode() == 92) { goto state_62; } if(ch.unicode() == 95) { goto state_61; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_61; } goto out; state_62: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_79; } if(ch.unicode() == 11) { goto state_79; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_79; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_79; } if(ch.unicode() >= 103) { goto state_79; } goto out; state_63: lastAcceptingPos = pos; token = QuazaaCss::HASH; ch = next(); if(ch.unicode() == 45) { goto state_61; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_61; } if(ch.unicode() == 92) { goto state_62; } if(ch.unicode() == 95) { goto state_61; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_61; } goto out; state_64: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_65: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_66: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_67: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 10) { goto state_80; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_69: lastAcceptingPos = pos; token = QuazaaCss::NUMBER; ch = next(); if(ch.unicode() == 37) { goto state_41; } if(ch.unicode() == 45) { goto state_42; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_69; } if(ch.unicode() == 92) { goto state_45; } if(ch.unicode() == 95) { goto state_46; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_46; } goto out; state_70: lastAcceptingPos = pos; token = QuazaaCss::LENGTH; ch = next(); if(ch.unicode() == 45) { goto state_71; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_71; } if(ch.unicode() == 92) { goto state_72; } if(ch.unicode() == 95) { goto state_71; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_71; } goto out; state_71: lastAcceptingPos = pos; token = QuazaaCss::LENGTH; ch = next(); if(ch.unicode() == 45) { goto state_71; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_71; } if(ch.unicode() == 92) { goto state_72; } if(ch.unicode() == 95) { goto state_71; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_71; } goto out; state_72: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_81; } if(ch.unicode() == 11) { goto state_81; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_81; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_81; } if(ch.unicode() >= 103) { goto state_81; } goto out; state_73: ch = next(); if(ch.unicode() == 45) { token = QuazaaCss::CDO; goto found; } goto out; state_74: lastAcceptingPos = pos; token = QuazaaCss::ATKEYWORD_SYM; ch = next(); if(ch.unicode() == 45) { goto state_75; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_75; } if(ch.unicode() == 92) { goto state_76; } if(ch.unicode() == 95) { goto state_75; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_75; } goto out; state_75: lastAcceptingPos = pos; token = QuazaaCss::ATKEYWORD_SYM; ch = next(); if(ch.unicode() == 45) { goto state_75; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_75; } if(ch.unicode() == 92) { goto state_76; } if(ch.unicode() == 95) { goto state_75; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_75; } goto out; state_76: ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_83; } if(ch.unicode() == 11) { goto state_83; } if(ch.unicode() >= 14 && ch.unicode() <= 47) { goto state_83; } if(ch.unicode() >= 58 && ch.unicode() <= 96) { goto state_83; } if(ch.unicode() >= 103) { goto state_83; } goto out; state_77: lastAcceptingPos = pos; token = QuazaaCss::IDENT; ch = next(); if(ch.unicode() == 40) { goto state_52; } if(ch.unicode() == 45) { goto state_53; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_53; } if(ch.unicode() == 92) { goto state_54; } if(ch.unicode() == 95) { goto state_53; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_53; } goto out; state_78: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_30; } if(ch.unicode() == 11) { goto state_30; } if(ch.unicode() >= 14 && ch.unicode() <= 33) { goto state_30; } if(ch.unicode() == 34) { goto state_31; } if(ch.unicode() >= 35 && ch.unicode() <= 91) { goto state_30; } if(ch.unicode() == 92) { goto state_32; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_30; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_30; } if(ch.unicode() >= 123) { goto state_30; } goto out; state_79: lastAcceptingPos = pos; token = QuazaaCss::HASH; ch = next(); if(ch.unicode() == 45) { goto state_61; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_61; } if(ch.unicode() == 92) { goto state_62; } if(ch.unicode() == 95) { goto state_61; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_61; } goto out; state_80: lastAcceptingPos = pos; token = QuazaaCss::INVALID; ch = next(); if(ch.unicode() >= 1 && ch.unicode() <= 9) { goto state_35; } if(ch.unicode() == 11) { goto state_35; } if(ch.unicode() >= 14 && ch.unicode() <= 38) { goto state_35; } if(ch.unicode() == 39) { goto state_36; } if(ch.unicode() >= 40 && ch.unicode() <= 91) { goto state_35; } if(ch.unicode() == 92) { goto state_37; } if(ch.unicode() >= 93 && ch.unicode() <= 96) { goto state_35; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_35; } if(ch.unicode() >= 123) { goto state_35; } goto out; state_81: lastAcceptingPos = pos; token = QuazaaCss::LENGTH; ch = next(); if(ch.unicode() == 45) { goto state_71; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_71; } if(ch.unicode() == 92) { goto state_72; } if(ch.unicode() == 95) { goto state_71; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_71; } goto out; state_83: lastAcceptingPos = pos; token = QuazaaCss::ATKEYWORD_SYM; ch = next(); if(ch.unicode() == 45) { goto state_75; } if(ch.unicode() >= 48 && ch.unicode() <= 57) { goto state_75; } if(ch.unicode() == 92) { goto state_76; } if(ch.unicode() == 95) { goto state_75; } if((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) { goto state_75; } goto out; found: lastAcceptingPos = pos; out: if(lastAcceptingPos != -1) { lexemLength = lastAcceptingPos - lexemStart; pos = lastAcceptingPos; } return token; }
QString Page::replaceTextMacros(const QString& s) const { QString d; for (int i = 0, n = s.size(); i < n; ++i) { QChar c = s[i]; if (c == '$' && (i < (n-1))) { QChar c = s[i+1]; switch(c.toLatin1()) { case 'p': // not on first page 1 if (_no) // FALLTHROUGH case 'N': // on page 1 only if there are multiple pages if ( (score()->npages() + score()->pageNumberOffset()) > 1 ) // FALLTHROUGH case 'P': // on all pages { int no = _no + 1 + score()->pageNumberOffset(); if (no > 0 ) d += QString("%1").arg(no); } break; case 'n': d += QString("%1").arg(score()->npages() + score()->pageNumberOffset()); break; case 'f': d += masterScore()->fileInfo()->completeBaseName().toHtmlEscaped(); break; case 'F': d += masterScore()->fileInfo()->absoluteFilePath().toHtmlEscaped(); break; case 'd': d += QDate::currentDate().toString(Qt::DefaultLocaleShortDate); break; case 'D': { QString creationDate = score()->metaTag("creationDate"); if (creationDate.isNull()) d += masterScore()->fileInfo()->created().date().toString(Qt::DefaultLocaleShortDate); else d += QDate::fromString(creationDate, Qt::ISODate).toString(Qt::DefaultLocaleShortDate); } break; case 'm': if ( score()->dirty() ) d += QTime::currentTime().toString(Qt::DefaultLocaleShortDate); else d += masterScore()->fileInfo()->lastModified().time().toString(Qt::DefaultLocaleShortDate); break; case 'M': if ( score()->dirty() ) d += QDate::currentDate().toString(Qt::DefaultLocaleShortDate); else d += masterScore()->fileInfo()->lastModified().date().toString(Qt::DefaultLocaleShortDate); break; case 'C': // only on first page if (!_no) // FALLTHROUGH case 'c': d += score()->metaTag("copyright").toHtmlEscaped(); break; case '$': d += '$'; break; case ':': { QString tag; int k = i+2; for (; k < n; ++k) { if (s[k].toLatin1() == ':') break; tag += s[k]; } if (k != n) { // found ':' ? d += score()->metaTag(tag).toHtmlEscaped(); i = k-1; } } break; default: d += '$'; d += c; break; } ++i; } else d += c; } return d; }
static bool qIsAlnum(QChar ch) { uint u = uint(ch.unicode()); // matches [a-zA-Z0-9_] return u - 'a' < 26 || u - 'A' < 26 || u - '0' < 10 || u == '_'; }
bool ProFileCompletionAssistProvider::isContinuationChar(const QChar &c) const { return c.isLetterOrNumber() || c == QLatin1Char('_'); }
bool QDeclarativeDirParser::parse() { if (_isParsed) return true; _isParsed = true; _errors.clear(); _plugins.clear(); _components.clear(); QTextStream stream(&_source); int lineNumber = 0; forever { ++lineNumber; const QString line = stream.readLine(); if (line.isNull()) break; QString sections[3]; int sectionCount = 0; int index = 0; const int length = line.length(); while (index != length) { const QChar ch = line.at(index); if (ch.isSpace()) { do { ++index; } while (index != length && line.at(index).isSpace()); } else if (ch == QLatin1Char('#')) { // recognized a comment break; } else { const int start = index; do { ++index; } while (index != length && !line.at(index).isSpace()); const QString lexeme = line.mid(start, index - start); if (sectionCount >= 3) { reportError(lineNumber, start, QLatin1String("unexpected token")); } else { sections[sectionCount++] = lexeme; } } } if (sectionCount == 0) { continue; // no sections, no party. } else if (sections[0] == QLatin1String("plugin")) { if (sectionCount < 2) { reportError(lineNumber, -1, QString::fromUtf8("plugin directive requires 2 arguments, but %1 were provided").arg(sectionCount + 1)); continue; } const Plugin entry(sections[1], sections[2]); _plugins.append(entry); } else if (sections[0] == QLatin1String("internal")) { if (sectionCount != 3) { reportError(lineNumber, -1, QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount + 1)); continue; } Component entry(sections[1], sections[2], -1, -1); entry.internal = true; _components.append(entry); } else if (sectionCount == 2) { // No version specified (should only be used for relative qmldir files) const Component entry(sections[0], sections[1], -1, -1); _components.append(entry); } else if (sectionCount == 3) { const QString &version = sections[1]; const int dotIndex = version.indexOf(QLatin1Char('.')); if (dotIndex == -1) { reportError(lineNumber, -1, QLatin1String("expected '.'")); } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) { reportError(lineNumber, -1, QLatin1String("unexpected '.'")); } else { bool validVersionNumber = false; const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber); if (validVersionNumber) { const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber); if (validVersionNumber) { const Component entry(sections[0], sections[2], majorVersion, minorVersion); _components.append(entry); } } } } else { reportError(lineNumber, -1, QString::fromUtf8("a component declaration requires 3 arguments, but %1 were provided").arg(sectionCount + 1)); } } return hasError(); }
int RegExpTokenizer::lex() { lexemStart = pos; lexemLength = 0; int lastAcceptingPos = -1; int token = -1; QChar ch; // initial state ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 33) goto state_1; if (ch.unicode() == 34) goto state_2; if (ch.unicode() >= 35 && ch.unicode() <= 39) goto state_1; if (ch.unicode() == 40) { token = RE2NFA::TOK_LPAREN; goto found; } if (ch.unicode() == 41) { token = RE2NFA::TOK_RPAREN; goto found; } if (ch.unicode() == 42) { token = RE2NFA::TOK_STAR; goto found; } if (ch.unicode() == 43) { token = RE2NFA::TOK_PLUS; goto found; } if (ch.unicode() == 44) { token = RE2NFA::TOK_COMMA; goto found; } if (ch.unicode() == 45) goto state_1; if (ch.unicode() == 46) { token = RE2NFA::TOK_DOT; goto found; } if (ch.unicode() >= 47 && ch.unicode() <= 62) goto state_1; if (ch.unicode() == 63) { token = RE2NFA::TOK_QUESTION; goto found; } if (ch.unicode() >= 64 && ch.unicode() <= 90) goto state_1; if (ch.unicode() == 91) goto state_10; if (ch.unicode() == 92) goto state_11; if (ch.unicode() >= 93 && ch.unicode() <= 122) goto state_1; if (ch.unicode() == 123) { token = RE2NFA::TOK_LBRACE; goto found; } if (ch.unicode() == 124) { token = RE2NFA::TOK_OR; goto found; } if (ch.unicode() == 125) { token = RE2NFA::TOK_RBRACE; goto found; } if (ch.unicode() >= 126) goto state_1; goto out; state_1: lastAcceptingPos = pos; token = RE2NFA::TOK_STRING; goto out; state_2: lastAcceptingPos = pos; token = RE2NFA::TOK_STRING; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 33) goto state_15; if (ch.unicode() == 34) goto state_16; if (ch.unicode() >= 35) goto state_15; goto out; state_10: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 91) goto state_17; if (ch.unicode() == 92) goto state_18; if (ch.unicode() == 93) goto state_19; if (ch.unicode() >= 94) goto state_17; goto out; state_11: lastAcceptingPos = pos; token = RE2NFA::TOK_STRING; ch = next(); if (ch.unicode() >= 1) goto state_20; goto out; state_15: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 33) goto state_15; if (ch.unicode() == 34) goto state_16; if (ch.unicode() >= 35) goto state_15; goto out; state_16: lastAcceptingPos = pos; token = RE2NFA::TOK_QUOTED_STRING; goto out; state_17: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 91) goto state_17; if (ch.unicode() == 92) goto state_18; if (ch.unicode() == 93) goto state_19; if (ch.unicode() >= 94) goto state_17; goto out; state_18: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 91) goto state_17; if (ch.unicode() == 92) goto state_18; if (ch.unicode() == 93) goto state_21; if (ch.unicode() >= 94) goto state_17; goto out; state_19: lastAcceptingPos = pos; token = RE2NFA::TOK_SEQUENCE; goto out; state_20: lastAcceptingPos = pos; token = RE2NFA::TOK_STRING; goto out; state_21: lastAcceptingPos = pos; token = RE2NFA::TOK_SEQUENCE; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 91) goto state_17; if (ch.unicode() == 92) goto state_18; if (ch.unicode() == 93) goto state_19; if (ch.unicode() >= 94) goto state_17; goto out; found: lastAcceptingPos = pos; out: if (lastAcceptingPos != -1) { lexemLength = lastAcceptingPos - lexemStart; pos = lastAcceptingPos; } return token; }
/* Returns the recommended indent for the bottom line of yyProgram, assuming it's a continuation line. We're trying to align the continuation line against some parenthesis or other bracked left opened on a previous line, or some interesting operator such as '='. */ int QmlJSIndenter::indentForContinuationLine() { int braceDepth = 0; int delimDepth = 0; bool leftBraceFollowed = *yyLeftBraceFollows; for (int i = 0; i < SmallRoof; i++) { int hook = -1; int j = yyLine->length(); while (j > 0 && hook < 0) { j--; QChar ch = yyLine->at(j); switch (ch.unicode()) { case ')': delimDepth++; break; case ']': braceDepth++; break; case '}': braceDepth++; break; case '(': delimDepth--; /* An unclosed delimiter is a good place to align at, at least for some styles (including Qt's). */ if (delimDepth == -1) hook = j; break; case '[': braceDepth--; /* An unclosed delimiter is a good place to align at, at least for some styles (including Qt's). */ if (braceDepth == -1) hook = j; break; case '{': braceDepth--; /* A left brace followed by other stuff on the same line is typically for an enum or an initializer. Such a brace must be treated just like the other delimiters. */ if (braceDepth == -1) { if (j < yyLine->length() - 1) { hook = j; } else { return 0; // shouldn't happen } } break; case '=': /* An equal sign is a very natural alignment hook because it's usually the operator with the lowest precedence in statements it appears in. Case in point: int x = 1 + 2; However, we have to beware of constructs such as default arguments and explicit enum constant values: void foo(int x = 0, int y = 0); And not void foo(int x = 0, int y = 0); These constructs are caracterized by a ',' at the end of the unfinished lines or by unbalanced parentheses. */ Q_ASSERT(j - 1 >= 0); if (QString::fromLatin1("!=<>").indexOf(yyLine->at(j - 1)) == -1 && j + 1 < yyLine->length() && yyLine->at(j + 1) != '=') { if (braceDepth == 0 && delimDepth == 0 && j < yyLine->length() - 1 && !yyLine->endsWith(QLatin1Char(',')) && (yyLine->contains(QLatin1Char('(')) == yyLine->contains(QLatin1Char(')')))) hook = j; } } } if (hook >= 0) { /* Yes, we have a delimiter or an operator to align against! We don't really align against it, but rather against the following token, if any. In this example, the following token is "11": int x = (11 + 2); If there is no such token, we use a continuation indent: static QRegExp foo(QString( "foo foo foo foo foo foo foo foo foo")); */ hook++; while (hook < yyLine->length()) { if (!yyLine->at(hook).isSpace()) return columnForIndex(*yyLine, hook); hook++; } return indentOfLine(*yyLine) + ppContinuationIndentSize; } if (braceDepth != 0) break; /* The line's delimiters are balanced. It looks like a continuation line or something. */ if (delimDepth == 0) { if (leftBraceFollowed) { /* We have int main() { or Bar::Bar() : Foo(x) { The "{" should be flush left. */ if (!isContinuationLine()) return indentOfLine(*yyLine); } else if (isContinuationLine() || yyLine->endsWith(QLatin1String(","))) { /* We have x = a + b + c; or int t[] = { 1, 2, 3, 4, 5, 6 The "c;" should fall right under the "b +", and the "4, 5, 6" right under the "1, 2, 3,". */ return indentOfLine(*yyLine); } else { /* We have stream << 1 + 2; We could, but we don't, try to analyze which operator has precedence over which and so on, to obtain the excellent result stream << 1 + 2; We do have a special trick above for the assignment operator above, though. */ return indentOfLine(*yyLine) + ppContinuationIndentSize; } } if (!readLine()) break; } return 0; }
// Apply a simple variant type to a DOM property static bool applySimpleProperty(const QVariant &v, bool translateString, DomProperty *dom_prop) { switch (v.type()) { case QVariant::String: { DomString *str = new DomString(); str->setText(v.toString()); if (!translateString) str->setAttributeNotr(QLatin1String("true")); dom_prop->setElementString(str); } return true; case QVariant::ByteArray: dom_prop->setElementCstring(QString::fromUtf8(v.toByteArray())); return true; case QVariant::Int: dom_prop->setElementNumber(v.toInt()); return true; case QVariant::UInt: dom_prop->setElementUInt(v.toUInt()); return true; case QVariant::LongLong: dom_prop->setElementLongLong(v.toLongLong()); return true; case QVariant::ULongLong: dom_prop->setElementULongLong(v.toULongLong()); return true; case QVariant::Double: dom_prop->setElementDouble(v.toDouble()); return true; case QVariant::Bool: dom_prop->setElementBool(v.toBool() ? QFormBuilderStrings::instance().trueValue : QFormBuilderStrings::instance().falseValue); return true; case QVariant::Char: { DomChar *ch = new DomChar(); const QChar character = v.toChar(); ch->setElementUnicode(character.unicode()); dom_prop->setElementChar(ch); } return true; case QVariant::Point: { DomPoint *pt = new DomPoint(); const QPoint point = v.toPoint(); pt->setElementX(point.x()); pt->setElementY(point.y()); dom_prop->setElementPoint(pt); } return true; case QVariant::PointF: { DomPointF *ptf = new DomPointF(); const QPointF pointf = v.toPointF(); ptf->setElementX(pointf.x()); ptf->setElementY(pointf.y()); dom_prop->setElementPointF(ptf); } return true; case QVariant::Color: { DomColor *clr = new DomColor(); const QColor color = qvariant_cast<QColor>(v); clr->setElementRed(color.red()); clr->setElementGreen(color.green()); clr->setElementBlue(color.blue()); const int alphaChannel = color.alpha(); if (alphaChannel != 255) clr->setAttributeAlpha(alphaChannel); dom_prop->setElementColor(clr); } return true; case QVariant::Size: { DomSize *sz = new DomSize(); const QSize size = v.toSize(); sz->setElementWidth(size.width()); sz->setElementHeight(size.height()); dom_prop->setElementSize(sz); } return true; case QVariant::SizeF: { DomSizeF *szf = new DomSizeF(); const QSizeF sizef = v.toSizeF(); szf->setElementWidth(sizef.width()); szf->setElementHeight(sizef.height()); dom_prop->setElementSizeF(szf); } return true; case QVariant::Rect: { DomRect *rc = new DomRect(); const QRect rect = v.toRect(); rc->setElementX(rect.x()); rc->setElementY(rect.y()); rc->setElementWidth(rect.width()); rc->setElementHeight(rect.height()); dom_prop->setElementRect(rc); } return true; case QVariant::RectF: { DomRectF *rcf = new DomRectF(); const QRectF rectf = v.toRectF(); rcf->setElementX(rectf.x()); rcf->setElementY(rectf.y()); rcf->setElementWidth(rectf.width()); rcf->setElementHeight(rectf.height()); dom_prop->setElementRectF(rcf); } return true; case QVariant::Font: { DomFont *fnt = new DomFont(); const QFont font = qvariant_cast<QFont>(v); const uint mask = font.resolve(); if (mask & QFont::WeightResolved) { fnt->setElementBold(font.bold()); fnt->setElementWeight(font.weight()); } if (mask & QFont::FamilyResolved) fnt->setElementFamily(font.family()); if (mask & QFont::StyleResolved) fnt->setElementItalic(font.italic()); if (mask & QFont::SizeResolved) fnt->setElementPointSize(font.pointSize()); if (mask & QFont::StrikeOutResolved) fnt->setElementStrikeOut(font.strikeOut()); if (mask & QFont::UnderlineResolved) fnt->setElementUnderline(font.underline()); if (mask & QFont::KerningResolved) fnt->setElementKerning(font.kerning()); if (mask & QFont::StyleStrategyResolved) { const QMetaEnum styleStrategy_enum = metaEnum<QAbstractFormBuilderGadget>("styleStrategy"); fnt->setElementStyleStrategy(QLatin1String(styleStrategy_enum.valueToKey(font.styleStrategy()))); } dom_prop->setElementFont(fnt); } return true; #ifndef QT_NO_CURSOR case QVariant::Cursor: { const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape"); dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape()))); } return true; #endif case QVariant::KeySequence: { DomString *s = new DomString(); s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText)); dom_prop->setElementString(s); } return true; case QVariant::Locale: { DomLocale *dom = new DomLocale(); const QLocale locale = qvariant_cast<QLocale>(v); const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language"); const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country"); dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language()))); dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country()))); dom_prop->setElementLocale(dom); } return true; case QVariant::SizePolicy: { DomSizePolicy *dom = new DomSizePolicy(); const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v); dom->setElementHorStretch(sizePolicy.horizontalStretch()); dom->setElementVerStretch(sizePolicy.verticalStretch()); const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType"); dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy()))); dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy()))); dom_prop->setElementSizePolicy(dom); } return true; case QVariant::Date: { DomDate *dom = new DomDate(); const QDate date = qvariant_cast<QDate>(v); dom->setElementYear(date.year()); dom->setElementMonth(date.month()); dom->setElementDay(date.day()); dom_prop->setElementDate(dom); } return true; case QVariant::Time: { DomTime *dom = new DomTime(); const QTime time = qvariant_cast<QTime>(v); dom->setElementHour(time.hour()); dom->setElementMinute(time.minute()); dom->setElementSecond(time.second()); dom_prop->setElementTime(dom); } return true; case QVariant::DateTime: { DomDateTime *dom = new DomDateTime(); const QDateTime dateTime = qvariant_cast<QDateTime>(v); dom->setElementHour(dateTime.time().hour()); dom->setElementMinute(dateTime.time().minute()); dom->setElementSecond(dateTime.time().second()); dom->setElementYear(dateTime.date().year()); dom->setElementMonth(dateTime.date().month()); dom->setElementDay(dateTime.date().day()); dom_prop->setElementDateTime(dom); } return true; case QVariant::Url: { DomUrl *dom = new DomUrl(); const QUrl url = v.toUrl(); DomString *str = new DomString(); str->setText(url.toString()); dom->setElementString(str); dom_prop->setElementUrl(dom); } return true; case QVariant::StringList: { DomStringList *sl = new DomStringList; sl->setElementString(qvariant_cast<QStringList>(v)); dom_prop->setElementStringList(sl); } return true; default: break; } return false; }
void Highlighter::highlightBlock(const QString &text) { int state = previousBlockState(); int len = text.length(); int start = 0; int pos = 0; while (pos < len) { switch (state) { case State_Text: default: while (pos < len) { QChar ch = text.at(pos); if (ch == '<') { if (text.mid(pos, 4) == "<!--") { state = State_Comment; } else { if (text.mid(pos, 9).toUpper() == "<!DOCTYPE") state = State_DocType; else state = State_TagStart; } break; } else if (ch == '&') { start = pos; while (pos < len && text.at(pos++) != ';') ; setFormat(start, pos - start, m_colors[Entity]); } else { ++pos; } } break; case State_Comment: start = pos; while (pos < len) { if (text.mid(pos, 3) == "-->") { pos += 3; state = State_Text; break; } else { ++pos; } } setFormat(start, pos - start, m_colors[Comment]); break; case State_DocType: start = pos; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch == '>') { state = State_Text; break; } } setFormat(start, pos - start, m_colors[DocType]); break; // at '<' in e.g. "<span>foo</span>" case State_TagStart: start = pos + 1; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch == '>') { state = State_Text; break; } if (!ch.isSpace()) { --pos; state = State_TagName; break; } } break; // at 'b' in e.g "<blockquote>foo</blockquote>" case State_TagName: start = pos; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch.isSpace()) { --pos; state = State_InsideTag; break; } if (ch == '>') { state = State_Text; break; } } setFormat(start, pos - start, m_colors[Tag]); break; // anywhere after tag name and before tag closing ('>') case State_InsideTag: start = pos; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch == '/') continue; if (ch == '>') { state = State_Text; break; } if (!ch.isSpace()) { --pos; state = State_AttributeName; break; } } break; // at 's' in e.g. <img src=bla.png/> case State_AttributeName: start = pos; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch == '=') { state = State_AttributeValue; break; } if (ch == '>' || ch == '/') { state = State_InsideTag; break; } } setFormat(start, pos - start, m_colors[AttributeName]); break; // after '=' in e.g. <img src=bla.png/> case State_AttributeValue: start = pos; // find first non-space character while (pos < len) { QChar ch = text.at(pos); ++pos; // handle opening single quote if (ch == '\'') { state = State_SingleQuote; break; } // handle opening double quote if (ch == '"') { state = State_DoubleQuote; break; } if (!ch.isSpace()) break; } if (state == State_AttributeValue) { // attribute value without quote // just stop at non-space or tag delimiter start = pos; while (pos < len) { QChar ch = text.at(pos); if (ch.isSpace()) break; if (ch == '>' || ch == '/') break; ++pos; } state = State_InsideTag; setFormat(start, pos - start, m_colors[AttributeValue]); } break; // after the opening single quote in an attribute value case State_SingleQuote: start = pos; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch == '\'') break; } state = State_InsideTag; setFormat(start, pos - start, m_colors[AttributeValue]); break; // after the opening double quote in an attribute value case State_DoubleQuote: start = pos; while (pos < len) { QChar ch = text.at(pos); ++pos; if (ch == '"') break; } state = State_InsideTag; setFormat(start, pos - start, m_colors[AttributeValue]); break; } } setCurrentBlockState(state); }
void MessageHighlighter::highlightBlock(const QString &text) { static const QLatin1Char tab = QLatin1Char('\t'); static const QLatin1Char space = QLatin1Char(' '); static const QLatin1Char amp = QLatin1Char('&'); static const QLatin1Char endTag = QLatin1Char('>'); static const QLatin1Char quot = QLatin1Char('"'); static const QLatin1Char apos = QLatin1Char('\''); static const QLatin1Char semicolon = QLatin1Char(';'); static const QLatin1Char equals = QLatin1Char('='); static const QLatin1Char percent = QLatin1Char('%'); static const QLatin1String startComment = QLatin1String("<!--"); static const QLatin1String endComment = QLatin1String("-->"); static const QLatin1String endElement = QLatin1String("/>"); int state = previousBlockState(); int len = text.length(); int start = 0; int pos = 0; while (pos < len) { switch (state) { case NormalState: default: while (pos < len) { QChar ch = text.at(pos); if (ch == QLatin1Char('<')) { if (text.mid(pos, 4) == startComment) { state = InComment; } else { state = InTag; start = pos; while (pos < len && text.at(pos) != space && text.at(pos) != endTag && text.at(pos) != tab && text.mid(pos, 2) != endElement) ++pos; if (text.mid(pos, 2) == endElement) ++pos; setFormat(start, pos - start, m_formats[Tag]); break; } break; } else if (ch == amp && pos + 1 < len) { // Default is Accelerator if (text.at(pos + 1).isLetterOrNumber()) setFormat(pos + 1, 1, m_formats[Accelerator]); // When a semicolon follows assume an Entity start = pos; ch = text.at(++pos); while (pos + 1 < len && ch != semicolon && ch.isLetterOrNumber()) ch = text.at(++pos); if (ch == semicolon) setFormat(start, pos - start + 1, m_formats[Entity]); } else if (ch == percent) { start = pos; // %[1-9]* for (++pos; pos < len && text.at(pos).isDigit(); ++pos) {} // %n if (pos < len && pos == start + 1 && text.at(pos) == QLatin1Char('n')) ++pos; setFormat(start, pos - start, m_formats[Variable]); } else { // No tag, comment or entity started, continue... ++pos; } } break; case InComment: start = pos; while (pos < len) { if (text.mid(pos, 3) == endComment) { pos += 3; state = NormalState; break; } else { ++pos; } } setFormat(start, pos - start, m_formats[Comment]); break; case InTag: QChar quote = QChar::Null; while (pos < len) { QChar ch = text.at(pos); if (quote.isNull()) { start = pos; if (ch == apos || ch == quot) { quote = ch; } else if (ch == endTag) { ++pos; setFormat(start, pos - start, m_formats[Tag]); state = NormalState; break; } else if (text.mid(pos, 2) == endElement) { pos += 2; setFormat(start, pos - start, m_formats[Tag]); state = NormalState; break; } else if (ch != space && text.at(pos) != tab) { // Tag not ending, not a quote and no whitespace, so // we must be dealing with an attribute. ++pos; while (pos < len && text.at(pos) != space && text.at(pos) != tab && text.at(pos) != equals) ++pos; setFormat(start, pos - start, m_formats[Attribute]); start = pos; } } else if (ch == quote) { quote = QChar::Null; // Anything quoted is a value setFormat(start, pos - start, m_formats[Value]); } ++pos; } break; } } setCurrentBlockState(state); }
// Function tries to split given datatype (type) into a number of // ui widgets (type, scale and precision). If it is unable to do // that - custom style (pure edit text widget) is used void toDatatype::setType(const QString &type) { try { // Intentionally not using the SQL parser for this enum { Initial, AtType, AtSize, AtPrecision, AtEnd } state = Initial; int startType = -1; int endType = -1; int size = -1; int precision = -1; bool valid = !PreferCustom; bool endoftoken = false; if (valid) { for (int pos = 0; pos < type.length(); pos++) { QChar c = type.at(pos); if (c.isSpace()) { endoftoken = true; continue; } switch (state) { case Initial: state = AtType; startType = pos; endoftoken = false; break; case AtType: if (c == '(') { state = AtSize; endoftoken = false; } else if (endoftoken) { valid = false; } else endType = pos; break; case AtSize: if (c.isDigit() && (!endoftoken || size == -1)) { if (size == -1) size = (c.toAscii()) - '0'; else size = size * 10 + (c.toAscii()) - '0'; endoftoken = false; } else if (size == -1) valid = false; else if (c == ')') { endoftoken = false; state = AtEnd; } else if (c == ',') { endoftoken = false; state = AtPrecision; } else valid = false; break; case AtPrecision: if (c.isDigit() && (!endoftoken || precision == -1)) { if (precision == -1) precision = (c.toAscii()) - '0'; else precision = precision * 10 + (c.toAscii()) - '0'; endoftoken = false; } else if (precision == -1) valid = false; else if (c == ')') { endoftoken = false; state = AtEnd; } else valid = false; break; case AtEnd: valid = false; break; } if (!valid) break; } } if (valid) { if (endType == -1) endType = type.length(); if (startType >= 0) { QString actualtype = type.mid(startType, endType - startType + 1).toUpper(); valid = false; for (int i = 0; i < Type->count(); i++) { if (actualtype == Type->itemText(i)) { Type->show(); bCustomVisible = false; Type->setCurrentIndex(i); valid = true; break; } } if (valid) { valid = false; for (std::list<toExtract::datatype>::iterator i = Datatypes.begin(); i != Datatypes.end(); i++) { if ((*i).name() == actualtype) { valid = true; if ((*i).hasLength()) { if (size > (*i).maxLength()) valid = false; else { Size->show(); bSizeVisible = true; Size->setMaximum((*i).maxLength()); if (size != -1) Size->setValue(size); else //Size->setValue((*i).maxLength()); Size->setValue(0); // set value "not specified" } } else if (size != -1) valid = false; else { Size->hide(); bSizeVisible = false; } if ((*i).hasPrecision()) { if (precision > (*i).maxPrecision()) valid = false; else { Precision->show(); bPrecVisible = true; Precision->setMaximum((*i).maxPrecision()); if (precision != -1) Precision->setValue(precision); else // Set precision to 0 (meaning "precision not specified"). // If precision 0 can actually be used -1 should be used // here and minimum value on precision spinner should be // changed to -1 so that spinner would allow choosing 0 Precision->setValue(0); } } else if (precision != -1) valid = false; else { Precision->hide(); bPrecVisible = false; } break; } } } } } if (!valid) { Custom->setText(type); Custom->show(); bCustomVisible = true; Precision->hide(); bPrecVisible = false; Size->hide(); bSizeVisible = false; Type->hide(); } else { Custom->hide(); bCustomVisible = false; // probably set already above but just for clarity... } setupLabels(); } TOCATCH }
QString TextUtil::rich2plain(const QString &in, bool collapseSpaces) { QString out; for(int i = 0; i < (int)in.length(); ++i) { // tag? if(in[i] == '<') { // find end of tag ++i; int n = in.indexOf('>', i); if(n == -1) break; QString str = in.mid(i, (n-i)); i = n; QString tagName; n = str.indexOf(' '); if(n != -1) tagName = str.mid(0, n); else tagName = str; if(tagName == "br") out += '\n'; // handle output of Qt::convertFromPlainText() correctly if((tagName == "p" || tagName == "/p" || tagName == "div") && out.length() > 0) out += '\n'; } // entity? else if(in[i] == '&') { // find a semicolon ++i; int n = in.indexOf(';', i); if(n == -1) break; QString type = in.mid(i, (n-i)); i = n; // should be n+1, but we'll let the loop increment do it if(type == "amp") out += '&'; else if(type == "lt") out += '<'; else if(type == "gt") out += '>'; else if(type == "quot") out += '\"'; else if(type == "apos") out += '\''; } else if(in[i].isSpace()) { if(in[i] == QChar::Nbsp) out += ' '; else if(in[i] != '\n') { if(!collapseSpaces || i == 0 || out.length() == 0) out += ' '; else { QChar last = out.at(out.length()-1); bool ok = true; if(last.isSpace() && last != '\n') ok = false; if(ok) out += ' '; } } } else { out += in[i]; } } return out; }
bool QTextHtmlImporter::appendNodeText() { const int initialCursorPosition = cursor.position(); QTextCharFormat format = currentNode->charFormat; if(wsm == QTextHtmlParserNode::WhiteSpacePre || wsm == QTextHtmlParserNode::WhiteSpacePreWrap) compressNextWhitespace = PreserveWhiteSpace; QString text = currentNode->text; QString textToInsert; textToInsert.reserve(text.size()); for (int i = 0; i < text.length(); ++i) { QChar ch = text.at(i); if (ch.isSpace() && ch != QChar::Nbsp && ch != QChar::ParagraphSeparator) { if (compressNextWhitespace == CollapseWhiteSpace) compressNextWhitespace = RemoveWhiteSpace; // allow this one, and remove the ones coming next. else if(compressNextWhitespace == RemoveWhiteSpace) continue; if (wsm == QTextHtmlParserNode::WhiteSpacePre || textEditMode ) { if (ch == QLatin1Char('\n')) { if (textEditMode) continue; } else if (ch == QLatin1Char('\r')) { continue; } } else if (wsm != QTextHtmlParserNode::WhiteSpacePreWrap) { compressNextWhitespace = RemoveWhiteSpace; if (wsm == QTextHtmlParserNode::WhiteSpaceNoWrap) ch = QChar::Nbsp; else ch = QLatin1Char(' '); } } else { compressNextWhitespace = PreserveWhiteSpace; } if (ch == QLatin1Char('\n') || ch == QChar::ParagraphSeparator) { if (!textToInsert.isEmpty()) { cursor.insertText(textToInsert, format); textToInsert.clear(); } QTextBlockFormat fmt = cursor.blockFormat(); if (fmt.hasProperty(QTextFormat::BlockBottomMargin)) { QTextBlockFormat tmp = fmt; tmp.clearProperty(QTextFormat::BlockBottomMargin); cursor.setBlockFormat(tmp); } fmt.clearProperty(QTextFormat::BlockTopMargin); appendBlock(fmt, cursor.charFormat()); } else { if (!namedAnchors.isEmpty()) { if (!textToInsert.isEmpty()) { cursor.insertText(textToInsert, format); textToInsert.clear(); } format.setAnchor(true); format.setAnchorNames(namedAnchors); cursor.insertText(ch, format); namedAnchors.clear(); format.clearProperty(QTextFormat::IsAnchor); format.clearProperty(QTextFormat::AnchorName); } else { textToInsert += ch; } } } if (!textToInsert.isEmpty()) { cursor.insertText(textToInsert, format); } return cursor.position() != initialCursorPosition; }
void RTFGenParser::text(const QString &text) { for (int i = 0; i < (int)(text.length()); i++){ QChar c = text[i]; // In Qt, unless you force the paragraph direction with (Left/Right) // Ctrl-Shift (also known as Key_Direction_L and Key_Direction_R), // the P tag won't have a DIR attribute at all. In such cases, unlike // HTML, Qt will render the paragraph LTR or RTL according to the // first strong character (as Unicode TR#9 defines). Thus, if the // direction isn't known yet, we check each character till we find // a strong one. if ((m_lastParagraphPos != 0) && (m_paragraphDir == DirUnknown)) { switch(c.direction()) { case QChar::DirL: res.insert(m_lastParagraphPos, "\\ltrpar"); m_paragraphDir = DirLTR; break; case QChar::DirR: res.insert(m_lastParagraphPos, "\\rtlpar"); m_paragraphDir = DirRTL; break; default: // to avoid warnings break; } } unsigned short u = c.unicode(); if (c == '\r' || c == '\n') continue; if ((c == '{') || (c == '}') || (c == '\\')){ char b[5]; snprintf(b, sizeof(b), "\\\'%02x", u & 0xFF); res += b; m_bSpace = false; continue; } if (u < 0x80){ if (m_bSpace) res += ' '; res += (char)u; m_bSpace = false; continue; } QString s; s += c; if (m_codec){ string plain; plain = m_codec->fromUnicode(s); if ((plain.length() == 1) && (m_codec->toUnicode(plain.c_str()) == s)){ char b[5]; snprintf(b, sizeof(b), "\\\'%02x", plain[0] & 0xFF); res += b; m_bSpace = false; continue; } } res += "\\u"; res += number(s[0].unicode()); res += "?"; m_bSpace = false; } }
void KeyEvent::fromScriptValue(const QScriptValue& object, KeyEvent& event) { event.isValid = false; // assume the worst event.isMeta = object.property("isMeta").toVariant().toBool(); event.isControl = object.property("isControl").toVariant().toBool(); event.isAlt = object.property("isAlt").toVariant().toBool(); event.isKeypad = object.property("isKeypad").toVariant().toBool(); event.isAutoRepeat = object.property("isAutoRepeat").toVariant().toBool(); QScriptValue key = object.property("key"); if (key.isValid()) { event.key = key.toVariant().toInt(); event.text = QString(QChar(event.key)); event.isValid = true; } else { QScriptValue text = object.property("text"); if (text.isValid()) { event.text = object.property("text").toVariant().toString(); // if the text is a special command, then map it here... // TODO: come up with more elegant solution here, a map? is there a Qt function that gives nice names for keys? if (event.text.toUpper() == "F1") { event.key = Qt::Key_F1; } else if (event.text.toUpper() == "F2") { event.key = Qt::Key_F2; } else if (event.text.toUpper() == "F3") { event.key = Qt::Key_F3; } else if (event.text.toUpper() == "F4") { event.key = Qt::Key_F4; } else if (event.text.toUpper() == "F5") { event.key = Qt::Key_F5; } else if (event.text.toUpper() == "F6") { event.key = Qt::Key_F6; } else if (event.text.toUpper() == "F7") { event.key = Qt::Key_F7; } else if (event.text.toUpper() == "F8") { event.key = Qt::Key_F8; } else if (event.text.toUpper() == "F9") { event.key = Qt::Key_F9; } else if (event.text.toUpper() == "F10") { event.key = Qt::Key_F10; } else if (event.text.toUpper() == "F11") { event.key = Qt::Key_F11; } else if (event.text.toUpper() == "F12") { event.key = Qt::Key_F12; } else if (event.text.toUpper() == "UP") { event.key = Qt::Key_Up; event.isKeypad = true; } else if (event.text.toUpper() == "DOWN") { event.key = Qt::Key_Down; event.isKeypad = true; } else if (event.text.toUpper() == "LEFT") { event.key = Qt::Key_Left; event.isKeypad = true; } else if (event.text.toUpper() == "RIGHT") { event.key = Qt::Key_Right; event.isKeypad = true; } else if (event.text.toUpper() == "SPACE") { event.key = Qt::Key_Space; } else if (event.text.toUpper() == "ESC") { event.key = Qt::Key_Escape; } else if (event.text.toUpper() == "TAB") { event.key = Qt::Key_Tab; } else if (event.text.toUpper() == "DELETE") { event.key = Qt::Key_Delete; } else if (event.text.toUpper() == "BACKSPACE") { event.key = Qt::Key_Backspace; } else if (event.text.toUpper() == "SHIFT") { event.key = Qt::Key_Shift; } else if (event.text.toUpper() == "ALT") { event.key = Qt::Key_Alt; } else if (event.text.toUpper() == "CONTROL") { event.key = Qt::Key_Control; } else if (event.text.toUpper() == "META") { event.key = Qt::Key_Meta; } else if (event.text.toUpper() == "PAGE DOWN") { event.key = Qt::Key_PageDown; } else if (event.text.toUpper() == "PAGE UP") { event.key = Qt::Key_PageUp; } else if (event.text.toUpper() == "HOME") { event.key = Qt::Key_Home; } else if (event.text.toUpper() == "END") { event.key = Qt::Key_End; } else if (event.text.toUpper() == "HELP") { event.key = Qt::Key_Help; } else if (event.text.toUpper() == "CAPS LOCK") { event.key = Qt::Key_CapsLock; } else { // Key values do not distinguish between uppercase and lowercase // and use the uppercase key value. event.key = event.text.toUpper().at(0).unicode(); } event.isValid = true; } } QScriptValue isShifted = object.property("isShifted"); if (isShifted.isValid()) { event.isShifted = isShifted.toVariant().toBool(); } else { // if no isShifted was included, get it from the text QChar character = event.text.at(0); if (character.isLetter() && character.isUpper()) { event.isShifted = true; } else { // if it's a symbol, then attempt to detect shifted-ness if (QString("~!@#$%^&*()_+{}|:\"<>?").contains(character)) { event.isShifted = true; } } } const bool wantDebug = false; if (wantDebug) { qCDebug(scriptengine) << "event.key=" << event.key << " event.text=" << event.text << " event.isShifted=" << event.isShifted << " event.isControl=" << event.isControl << " event.isMeta=" << event.isMeta << " event.isAlt=" << event.isAlt << " event.isKeypad=" << event.isKeypad << " event.isAutoRepeat=" << event.isAutoRepeat; } }
// Comes from koffice/filters/libexport/KWEFUtils.cc static QString EscapeSgmlText(const QTextCodec* codec, const QString& strIn, const bool quot = false , const bool apos = false ) { QString strReturn; QChar ch; for (uint i=0; i<strIn.length(); i++) { ch=strIn[i]; switch (ch.unicode()) { case 38: // & { strReturn+="&"; break; } case 60: // < { strReturn+="<"; break; } case 62: // > { strReturn+=">"; break; } case 34: // " { if (quot) strReturn+="""; else strReturn+=ch; break; } case 39: // ' { // NOTE: HTML does not define ' by default (only XML/XHTML does) if (apos) strReturn+="'"; else strReturn+=ch; break; } default: { // verify that the character ch can be expressed in the // encoding in which we will write the HTML file. if (codec) { if (!codec->canEncode(ch)) { strReturn+=QString("&#%1;").arg(ch.unicode()); break; } } strReturn+=ch; break; } } } return strReturn; }
void KDataToolPluginView::aboutToShow() { kdDebug()<<"KTextEditor::KDataToolPluginView::aboutToShow"<<endl; QString word; m_singleWord = false; m_wordUnderCursor = QString::null; // unplug old actions, if any: KAction *ac; for ( ac = m_actionList.first(); ac; ac = m_actionList.next() ) { m_menu->remove(ac); } if (m_notAvailable) { m_menu->remove(m_notAvailable); delete m_notAvailable; m_notAvailable=0; } if ( selectionInterface(m_view->document())->hasSelection() ) { word = selectionInterface(m_view->document())->selection(); if ( word.find(' ') == -1 && word.find('\t') == -1 && word.find('\n') == -1 ) m_singleWord = true; else m_singleWord = false; } else { // No selection -> use word under cursor KTextEditor::EditInterface *ei; KTextEditor::ViewCursorInterface *ci; KTextEditor::View *v = (KTextEditor::View*)m_view; ei = KTextEditor::editInterface(v->document()); ci = KTextEditor::viewCursorInterface(v); uint line, col; ci->cursorPositionReal(&line, &col); QString tmp_line = ei->textLine(line); m_wordUnderCursor = ""; // find begin of word: m_singleWord_start = 0; for(int i = col; i >= 0; i--) { QChar ch = tmp_line.at(i); if( ! (ch.isLetter() || ch == '-' || ch == '\'') ) { m_singleWord_start = i+1; break; } m_wordUnderCursor = ch + m_wordUnderCursor; } // find end of word: m_singleWord_end = tmp_line.length(); for(uint i = col+1; i < tmp_line.length(); i++) { QChar ch = tmp_line.at(i); if( ! (ch.isLetter() || ch == '-' || ch == '\'') ) { m_singleWord_end = i; break; } m_wordUnderCursor += ch; } if( ! m_wordUnderCursor.isEmpty() ) { m_singleWord = true; m_singleWord_line = line; } else { m_notAvailable = new KAction(i18n("(not available)"), QString::null, 0, this, SLOT(slotNotAvailable()), actionCollection(),"dt_n_av"); m_menu->insert(m_notAvailable); return; } } KInstance *inst=instance(); QValueList<KDataToolInfo> tools; tools += KDataToolInfo::query( "QString", "text/plain", inst ); if( m_singleWord ) tools += KDataToolInfo::query( "QString", "application/x-singleword", inst ); m_actionList = KDataToolAction::dataToolActionList( tools, this, SLOT( slotToolActivated( const KDataToolInfo &, const QString & ) ) ); for ( ac = m_actionList.first(); ac; ac = m_actionList.next() ) { m_menu->insert(ac); } if( m_actionList.isEmpty() ) { m_notAvailable = new KAction(i18n("(not available)"), QString::null, 0, this, SLOT(slotNotAvailable()), actionCollection(),"dt_n_av"); m_menu->insert(m_notAvailable); } }
/*! Load, parse, and process a qdoc configuration file. This function is only called by the other load() function, but this one is recursive, i.e., it calls itself when it sees an \c{include} statement in the qdog configuration file. */ void Config::load(Location location, const QString& fileName) { QRegExp keySyntax("\\w+(?:\\.\\w+)*"); #define SKIP_CHAR() \ do { \ location.advance(c); \ ++i; \ c = text.at(i); \ cc = c.unicode(); \ } while (0) #define SKIP_SPACES() \ while (c.isSpace() && cc != '\n') \ SKIP_CHAR() #define PUT_CHAR() \ word += c; \ SKIP_CHAR(); if (location.depth() > 16) location.fatal(tr("Too many nested includes")); QFile fin(fileName); if (!fin.open(QFile::ReadOnly | QFile::Text)) { fin.setFileName(fileName + ".qdoc"); if (!fin.open(QFile::ReadOnly | QFile::Text)) location.fatal(tr("Cannot open file '%1': %2").arg(fileName).arg(fin.errorString())); } QTextStream stream(&fin); stream.setCodec("UTF-8"); QString text = stream.readAll(); text += QLatin1String("\n\n"); text += QChar('\0'); fin.close(); location.push(fileName); location.start(); int i = 0; QChar c = text.at(0); uint cc = c.unicode(); while (i < (int) text.length()) { if (cc == 0) ++i; else if (c.isSpace()) { SKIP_CHAR(); } else if (cc == '#') { do { SKIP_CHAR(); } while (cc != '\n'); } else if (isMetaKeyChar(c)) { Location keyLoc = location; bool plus = false; QString stringValue; QStringList stringListValue; QString word; bool inQuote = false; bool prevWordQuoted = true; bool metWord = false; MetaStack stack; do { stack.process(c, location); SKIP_CHAR(); } while (isMetaKeyChar(c)); QStringList keys = stack.getExpanded(location); SKIP_SPACES(); if (keys.count() == 1 && keys.first() == "include") { QString includeFile; if (cc != '(') location.fatal(tr("Bad include syntax")); SKIP_CHAR(); SKIP_SPACES(); while (!c.isSpace() && cc != '#' && cc != ')') { includeFile += c; SKIP_CHAR(); } SKIP_SPACES(); if (cc != ')') location.fatal(tr("Bad include syntax")); SKIP_CHAR(); SKIP_SPACES(); if (cc != '#' && cc != '\n') location.fatal(tr("Trailing garbage")); /* Here is the recursive call. */ load(location, QFileInfo(QFileInfo(fileName).dir(), includeFile) .filePath()); } else { /* It wasn't an include statement, so it;s something else. */ if (cc == '+') { plus = true; SKIP_CHAR(); } if (cc != '=') location.fatal(tr("Expected '=' or '+=' after key")); SKIP_CHAR(); SKIP_SPACES(); for (;;) { if (cc == '\\') { int metaCharPos; SKIP_CHAR(); if (cc == '\n') { SKIP_CHAR(); } else if (cc > '0' && cc < '8') { word += QChar(c.digitValue()); SKIP_CHAR(); } else if ((metaCharPos = QString::fromLatin1("abfnrtv").indexOf(c)) != -1) { word += "\a\b\f\n\r\t\v"[metaCharPos]; SKIP_CHAR(); } else { PUT_CHAR(); } } else if (c.isSpace() || cc == '#') { if (inQuote) { if (cc == '\n') location.fatal(tr("Unterminated string")); PUT_CHAR(); } else { if (!word.isEmpty()) { if (metWord) stringValue += QLatin1Char(' '); stringValue += word; stringListValue << word; metWord = true; word.clear(); prevWordQuoted = false; } if (cc == '\n' || cc == '#') break; SKIP_SPACES(); } } else if (cc == '"') { if (inQuote) { if (!prevWordQuoted) stringValue += QLatin1Char(' '); stringValue += word; if (!word.isEmpty()) stringListValue << word; metWord = true; word.clear(); prevWordQuoted = true; } inQuote = !inQuote; SKIP_CHAR(); } else if (cc == '$') { QString var; SKIP_CHAR(); while (c.isLetterOrNumber() || cc == '_') { var += c; SKIP_CHAR(); } if (!var.isEmpty()) { char *val = getenv(var.toLatin1().data()); if (val == 0) { location.fatal(tr("Environment variable '%1' undefined").arg(var)); } else { word += QString(val); } } } else { if (!inQuote && cc == '=') location.fatal(tr("Unexpected '='")); PUT_CHAR(); } } QStringList::ConstIterator key = keys.begin(); while (key != keys.end()) { if (!keySyntax.exactMatch(*key)) keyLoc.fatal(tr("Invalid key '%1'").arg(*key)); if (plus) { if (locMap[*key].isEmpty()) { locMap[*key] = keyLoc; } else { locMap[*key].setEtc(true); } if (stringValueMap[*key].isEmpty()) { stringValueMap[*key] = stringValue; } else { stringValueMap[*key] += QLatin1Char(' ') + stringValue; } stringListValueMap[*key] += stringListValue; } else { locMap[*key] = keyLoc; stringValueMap[*key] = stringValue; stringListValueMap[*key] = stringListValue; } ++key; } } } else { location.fatal(tr("Unexpected character '%1' at beginning of line") .arg(c)); } } }
/*! Sets the characters used for delimiting between keys and values, and between key-value pairs in the URL's query string. The default value delimiter is '=' and the default pair delimiter is '&'. \image qurl-querystring.png \a valueDelimiter will be used for separating keys from values, and \a pairDelimiter will be used to separate key-value pairs. Any occurrences of these delimiting characters in the encoded representation of the keys and values of the query string are percent encoded when returned in query(). If \a valueDelimiter is set to '(' and \a pairDelimiter is ')', the above query string would instead be represented like this: \snippet code/src_corelib_io_qurl.cpp 4 \note Non-standard delimiters should be chosen from among what RFC 3986 calls "sub-delimiters". They are: \code sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" \endcode Use of other characters is not supported and may result in unexpected behaviour. This method does not verify that you passed a valid delimiter. \sa queryValueDelimiter(), queryPairDelimiter() */ void QUrlQuery::setQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter) { d->valueDelimiter = valueDelimiter.unicode(); d->pairDelimiter = pairDelimiter.unicode(); }
void CKSocketClient::playMessage(const QString &message) { ostringstream os; os << message.toStdString() << endl; ColorKeeperModel::logMessage(os.str()); if (message.compare(QString("GET_SCREEN_INFO")) == 0) { try { const DisplayDevice & currScreen = ColorKeeperModel::Instance().getDeviceInfo().getCalibrableDisplayDevice( _currentScreen); ColorKeeperModel::Instance().addCalibModelForScreen(_currentScreen); QString sendMessage("SCREEN_INFO_ [index]"); sendMessage.append(currScreen.getOSIndex()); sendMessage.append(";[uid]"); sendMessage.append(currScreen.getFullSerialNumber().c_str()); sendMessage.append(";[manufacturer]"); sendMessage.append(currScreen.getManufacturerName().c_str()); sendMessage.append(";[model]"); sendMessage.append(currScreen.getModelName().c_str()); sendMessage.append(";[type]"); sendMessage.append(currScreen.getStringType().c_str()); sendMessage.append(";[profil]"); sendMessage.append( ColorKeeperModel::Instance().getScreenProfilName( currScreen.getOSIndex()).c_str()); sendMessage.append("\n"); writeSocket(sendMessage); } catch (std::string e) { //TODO exception QString sendMessage = "Error"; writeSocket(sendMessage); } } else if (message.contains(QString("DISPLAY_LUM_PATT")) == true) { QString m = message; m.remove(QString("DISPLAY_LUM_PATT ")); QChar sc = m[0]; m.remove(sc); int screen = sc.digitValue(); float gamma = m.toFloat(); emit displayLumContPatt(gamma, screen, false); } else if (message.contains(QString("SET_LUT_ON")) == true) { QChar sc = message[11]; int screen = sc.digitValue(); ColorKeeperModel::Instance().setScreenShouldApplyCorrection(screen, true); } else if (message.contains(QString("SET_LUT_OFF")) == true) { QChar sc = message[12]; int screen = sc.digitValue(); ColorKeeperModel::Instance().setScreenShouldApplyCorrection(screen, false); } else if (message.contains(QString("UNSET_MOSAIC")) == true) { QChar sc = message[13]; int screen = sc.digitValue(); emit displayLumContPatt(-1, screen, false); } else if (message.contains(QString("SET_MOSAIC")) == true) { QChar sc = message[11]; int screen = sc.digitValue(); emit displayLumContPatt(-1, screen, true); } else if (message.contains(QString("SET_PATCH_COLOR")) == true) { QChar sc = message[16]; int screen = sc.digitValue(); QStringList list = message.split(QChar('-')); QStringList::Iterator it = list.begin() + 1; QString tmp = (*it); float r = tmp.toFloat() / 255.f; ++it; tmp = (*it); float g = tmp.toFloat() / 255.f; ++it; tmp = (*it); float b = tmp.toFloat() / 255.f; ++it; tmp = (*it); QChar halo = tmp[0]; bool drawHalo = false; if (halo == QChar('t')) { drawHalo = true; } emit displayPatch(screen, r, g, b, drawHalo); QString sendMessage("PATCH_OK\n"); writeSocket(sendMessage); } else if (message.contains(QString("SET_REC_COLOR")) == true) { QChar sc = message[14]; int screen = sc.digitValue(); QStringList list = message.split(QChar('-')); QStringList::Iterator it = list.begin() + 1; QString tmp = (*it); float r = tmp.toFloat() / 255.f; ++it; tmp = (*it); float g = tmp.toFloat() / 255.f; ++it; tmp = (*it); float b = tmp.toFloat() / 255.f; ++it; tmp = (*it); emit displayFullScreenRec(screen, r, g, b); QString sendMessage("REC_OK\n"); writeSocket(sendMessage); } else if (message.contains(QString("SET_LUT_SIZE")) == true) { QChar sc = message[13]; int screen = sc.digitValue(); QStringList list = message.split(QChar('-')); QStringList::Iterator it = list.begin() + 1; QString tmp = (*it); unsigned int size = tmp.toInt(); ColorKeeperModel::Instance().setCalibSizeForScreen(screen, size); QString sendMessage("SET_LUT_SIZE_OK\n"); writeSocket(sendMessage); } else if (message.contains(QString("VALUE")) == true) { QChar sc = message[6]; int screen = sc.digitValue(); QStringList list = message.split(QChar('-')); QStringList::Iterator it = list.begin() + 1; QString tmp = (*it); unsigned short red = tmp.toInt(); ++it; tmp = (*it); unsigned short green = tmp.toInt(); ++it; tmp = (*it); unsigned short blue = tmp.toInt(); ostringstream os; os << (int) red << (int) green << (int) blue << endl; ColorKeeperModel::logMessage(os.str()); ColorKeeperModel::Instance().addCalibValueForScreen(screen, red, green, blue); } else if (message.contains(QString("SET_LUT_DONE")) == true) { // QString sendMessage("SET_LUT_OK\n"); // writeSocket(sendMessage); QChar sc = message[13]; int screen = sc.digitValue(); ColorKeeperModel::Instance().setCalibDoneForScreen(screen); } else if (message.contains(QString("SHOULD_DISPLAY")) == true) { QChar sc = message[15]; int screen = sc.digitValue(); QChar va = message[17]; bool tog = false; if (va == QChar('t')) { tog = true; } ColorKeeperModel::Instance().shoudDisplayCalibForScreen(screen, tog); } else if (message.contains(QString("UPDATE_CALIB_FILE")) == true) { QChar sc = message[18]; int screen = sc.digitValue(); QString infos = message; infos.remove(0, 19); infos.replace(QChar('#'), QChar('\n')); ColorKeeperModel::Instance().updateCorrection(screen, infos); QString sendMessage("UPDATE_OK\n"); writeSocket(sendMessage); } else if (message.contains(QString("BUH_BYE")) == true) { QChar sc = message[8]; int screen = sc.digitValue(); ColorKeeperModel::Instance().endCalib(screen); } }
void S60DeployConfigurationWidget::updateTargetInformation() { QString package; for (int i = 0; i < m_deployConfiguration->signedPackages().count(); ++i) package += m_deployConfiguration->signedPackages()[i] + QLatin1String("\n"); if (!package.isEmpty()) package.remove(package.length()-1, 1); m_sisFileLabel->setText(QDir::toNativeSeparators(package)); } void S60DeployConfigurationWidget::setInstallationDrive(int index) { QTC_ASSERT(index >= 0, return); QTC_ASSERT(index < m_installationDriveCombo->count(), return); QChar driveLetter(m_installationDriveCombo->itemData(index).toChar()); m_deployConfiguration->setInstallationDrive(driveLetter.toAscii()); } void S60DeployConfigurationWidget::setSerialPort(int index) { const SymbianUtils::SymbianDevice d = device(index); m_deployConfiguration->setSerialPortName(d.portName()); m_deviceInfoButton->setEnabled(index >= 0); clearDeviceInfo(); } void S60DeployConfigurationWidget::updateCommunicationChannelUi() { S60DeployConfiguration::CommunicationChannel channel = m_deployConfiguration->communicationChannel(); if (channel == S60DeployConfiguration::CommunicationCodaTcpConnection) {
void TextBase::paste(EditData& ed) { QString txt = QApplication::clipboard()->text(QClipboard::Clipboard); if (MScore::debugMode) qDebug("<%s>", qPrintable(txt)); int state = 0; QString token; QString sym; bool symState = false; score()->startCmd(); for (int i = 0; i < txt.length(); i++ ) { QChar c = txt[i]; if (state == 0) { if (c == '<') { state = 1; token.clear(); } else if (c == '&') { state = 2; token.clear(); } else { if (symState) sym += c; else { deleteSelectedText(ed); if (c.isHighSurrogate()) { QChar highSurrogate = c; Q_ASSERT(i + 1 < txt.length()); i++; QChar lowSurrogate = txt[i]; insertText(ed, QString(QChar::surrogateToUcs4(highSurrogate, lowSurrogate))); } else { insertText(ed, QString(QChar(c.unicode()))); } } } } else if (state == 1) { if (c == '>') { state = 0; if (token == "sym") { symState = true; sym.clear(); } else if (token == "/sym") { symState = false; insertSym(ed, Sym::name2id(sym)); } } else token += c; } else if (state == 2) { if (c == ';') { state = 0; if (token == "lt") insertText(ed, "<"); else if (token == "gt") insertText(ed, ">"); else if (token == "amp") insertText(ed, "&"); else if (token == "quot") insertText(ed, "\""); else insertSym(ed, Sym::name2id(token)); } else if (!c.isLetter()) { state = 0; insertText(ed, "&"); insertText(ed, token); insertText(ed, c); } else token += c; } } if (state == 2) { insertText(ed, "&"); insertText(ed, token); } score()->endCmd(); }
void SM_Dropbox_Json::parseString(QString strJson) { #ifdef SM_QTDROPBOX_DEBUG qDebug() << "parse string = " << strJson << endl; #endif // clear all existing data emptyList(); // basically a json is valid until it is invalidated valid = true; if(!strJson.startsWith("{") || !strJson.endsWith("}")) { #ifdef SM_QTDROPBOX_DEBUG qDebug() << "string does not start with { " << endl; #endif if(strJson.startsWith("[") && strJson.endsWith("]")) { #ifdef SM_QTDROPBOX_DEBUG qDebug() << "JSON is anonymous array" << endl; #endif _anonymousArray = true; // fix json to be parseable by the algorithm below strJson = "{\"_anonArray\":"+strJson+"}"; } else { valid = false; return; } } QString buffer = ""; QString key = ""; QString value = ""; bool isKey = true; bool insertValue = false; bool isJson = false; bool isArray = false; bool openQuotes = false; for(int i=0; i<strJson.size(); ++i) { switch(strJson.at(i).toLatin1()) { case '"': if(!isKey) { buffer += "\""; openQuotes = !openQuotes; } continue; break; case ' ': if(!isKey) buffer += " "; continue; break; case '}': if(openQuotes) buffer += "}"; continue; break; case ':': if(!isKey) { buffer += ":"; continue; } #ifdef SM_QTDROPBOX_DEBUG qDebug() << "key = " << buffer << endl; #endif key = buffer.trimmed(); buffer = ""; isKey = false; break; case ',': if(openQuotes) { buffer += ','; continue; } #ifdef SM_QTDROPBOX_DEBUG qDebug() << "value = " << buffer << endl; #endif value = buffer.trimmed(); buffer = ""; isKey = true; insertValue = true; break; case '{': if(i == 0) continue; if(!openQuotes) isJson = true; buffer += '{'; break; case '[': if(!openQuotes) isArray = true; buffer += '['; break; default: buffer += strJson.at(i); break; } if(isJson) { // create new json object with data until } sm_dropbox_json_entry e; int offset = parseSubJson(strJson, i, &e); valueMap[key] = e; key = ""; // ignore next , i = offset+1; buffer = ""; isJson = false; insertValue = false; isKey = true; //continue; } if(isArray) { // value is an array value -> parse array bool inString = false; bool arrayEnd = false; int arrayDepth = 0; int j = i+1; buffer = "["; for(;!arrayEnd && j<strJson.size();++j) { QChar arrC = strJson.at(j); switch(arrC.toLatin1()) { case '"': inString = !inString; buffer += arrC; break; case '[': buffer += "["; arrayDepth += 1; break; case ']': buffer += "]"; if(!inString) { if(arrayDepth == 0) { arrayEnd = true; } else { arrayDepth -= 1; } } break; case '\\': if(strJson.at(j+1) == '"') // escaped double quote { buffer += "\""; j++; } else buffer += "\\"; break; default: buffer += arrC; break; } } // save array value string (buffer) value = buffer; buffer = ""; i = j; insertValue = true; isArray = false; isKey = true; // next element is started } if(insertValue) { #ifdef SM_QTDROPBOX_DEBUG qDebug() << "insert value " << key << " with content = " << value.trimmed() << " and type = " << interpretType(value.trimmed()) << endl; #endif sm_dropbox_json_entry e; QString *valuePointer = new QString(value.trimmed()); e.value.value = valuePointer; e.type = interpretType(value.trimmed()); valueMap[key] = e; key = ""; value = ""; insertValue = false; } } // there's some key left if(key.compare("")) { #ifdef SM_QTDROPBOX_DEBUG qDebug() << "rest value = " << buffer << endl; #endif // but no value in the buffer -> json is invalid because a value is missing if(!buffer.compare("")) { valid = false; } else { // if there's a value left we store it sm_dropbox_json_entry e; e.value.value = new QString(buffer.trimmed()); e.type = interpretType(buffer.trimmed()); valueMap[key] = e; } } return; }
static inline bool isValidNumber(const QChar &c) { register ushort u = c.unicode(); return (u >= '0' && u <= '9'); }