本文整理汇总了C++中QChar::cell方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::cell方法的具体用法?C++ QChar::cell怎么用?C++ QChar::cell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::cell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertFromUnicode
QByteArray QEucJpCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const
{
char replacement = '?';
if (state) {
if (state->flags & ConvertInvalidToNull)
replacement = 0;
}
int invalid = 0;
int rlen = 3*len + 1;
QByteArray rstr;
rstr.resize(rlen);
uchar* cursor = (uchar*)rstr.data();
for (int i = 0; i < len; i++) {
QChar ch = uc[i];
uint j;
if (ch.unicode() < 0x80) {
// ASCII
*cursor++ = ch.cell();
} else if ((j = conv->unicodeToJisx0201(ch.row(), ch.cell())) != 0) {
if (j < 0x80) {
// JIS X 0201 Latin ?
*cursor++ = j;
} else {
// JIS X 0201 Kana
*cursor++ = Ss2;
*cursor++ = j;
}
} else if ((j = conv->unicodeToJisx0208(ch.row(), ch.cell())) != 0) {
// JIS X 0208
*cursor++ = (j >> 8) | 0x80;
*cursor++ = (j & 0xff) | 0x80;
} else if ((j = conv->unicodeToJisx0212(ch.row(), ch.cell())) != 0) {
示例2: fromUnicode
/*! \reimp */
QCString QTsciiCodec::fromUnicode(const QString& uc, int& lenInOut) const
{
int l = QMIN((int)uc.length(), lenInOut);
int rlen = l+1;
QCString rstr(rlen);
uchar* cursor = (uchar*)rstr.data();
for (int i = 0; i < l; i++) {
QChar ch = uc[i];
uchar j;
if ( ch.row() == 0x00 && ch.cell() < 0x80 ) {
// ASCII
j = ch.cell();
} else if ((j = qt_UnicodeToTSCII(uc[i].unicode(),
uc[i + 1].unicode(),
uc[i + 2].unicode()))) {
// We have to check the combined chars first!
i += 2;
} else if ((j = qt_UnicodeToTSCII(uc[i].unicode(),
uc[i + 1].unicode(), 0))) {
i++;
} else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), 0, 0))) {
} else {
// Error
j = '?'; // unknown char
}
*cursor++ = j;
}
lenInOut = cursor - (uchar*)rstr.data();
*cursor = 0;
return rstr;
}
示例3: wt_findPairChar
/*
charPos is positive position
*/
int Wt_TextEdit::wt_findPairChar(int charPos, QChar pairChar, bool findBefore) {
QTextCursor textCursor = this->textCursor();
textCursor.setPosition(charPos, QTextCursor::KeepAnchor);
int charBlockPos = textCursor.positionInBlock();
QString line = textCursor.block().text();
QChar curChar = line[charBlockPos];
printf("wt_findPairChar char:%c | toChar:%c \n" , curChar.cell(), pairChar.cell());
int pair = 0;
//int findBlockPos = -1;
int findPositivePos = -1;
int curPos = -1;
QString curString = "";
QTextCursor::MoveOperation direction = findBefore == true ? QTextCursor::PreviousCharacter : QTextCursor::NextCharacter;
for (int i = 0 ; textCursor.movePosition(direction, QTextCursor::KeepAnchor) ; i++) {
curPos = textCursor.positionInBlock();
curString = textCursor.block().text();
if(curString[curPos] == curChar) {
pair += 1;
}
if(curString[curPos] == pairChar) {
pair -= 1;
}
if(pair < 0) {
//findBlockPos = curPos;
findPositivePos = textCursor.position();
return findPositivePos;
}
}
return -1;
}
示例4: fromUnicode
/*!
\reimp
*/
QCString QEucJpCodec::fromUnicode(const QString& uc, int& lenInOut) const
{
int l = QMIN((int)uc.length(),lenInOut);
int rlen = l*3+1;
QCString rstr(rlen);
uchar* cursor = (uchar*)rstr.data();
for (int i=0; i<l; i++) {
QChar ch = uc[i];
uint j;
if ( ch.row() == 0x00 && ch.cell() < 0x80 ) {
// ASCII
*cursor++ = ch.cell();
} else if ((j = conv->unicodeToJisx0201(ch.row(), ch.cell())) != 0) {
if (j < 0x80) {
// JIS X 0201 Latin ?
*cursor++ = j;
} else {
// JIS X 0201 Kana
*cursor++ = Ss2;
*cursor++ = j;
}
} else if ((j = conv->unicodeToJisx0208(ch.row(), ch.cell())) != 0) {
// JIS X 0208
*cursor++ = (j >> 8) | 0x80;
*cursor++ = (j & 0xff) | 0x80;
} else if ((j = conv->unicodeToJisx0212(ch.row(), ch.cell())) != 0) {
示例5: convertFromUnicode
QByteArray QSjisCodec::convertFromUnicode(const ushort* uc, int len, ConverterState *state)
{
char replacement = '?';
if (state) {
if (state->flags & ConvertInvalidToNull)
replacement = 0;
}
int invalid = 0;
int rlen = 2*len + 1;
QByteArray rstr;
rstr.resize(rlen);
uchar* cursor = (uchar*)rstr.data();
for (int i = 0; i < len; i++) {
QChar ch = uc[i];
uint j;
if (ch.row() == 0x00 && ch.cell() < 0x80) {
// ASCII
*cursor++ = ch.cell();
} else if ((j = conv->unicodeToJisx0201(ch.row(), ch.cell())) != 0) {
// JIS X 0201 Latin or JIS X 0201 Kana
*cursor++ = j;
} else if ((j = conv->unicodeToSjis(ch.row(), ch.cell())) != 0) {
// JIS X 0208
*cursor++ = (j >> 8);
*cursor++ = (j & 0xff);
} else if ((j = conv->unicodeToSjisibmvdc(ch.row(), ch.cell())) != 0) {
示例6: fromUnicode
/*! \internal */
QCString QJisCodec::fromUnicode(const QString& uc, int& len_in_out) const
{
int l = QMIN((int)uc.length(),len_in_out);
QCString result;
Iso2022State state = Ascii;
Iso2022State prev = Ascii;
for (int i=0; i<l; i++) {
QChar ch = uc[i];
uint j;
if ( ch.row() == 0x00 && ch.cell() < 0x80 ) {
// Ascii
if (state != JISX0201_Latin ||
ch.cell() == ReverseSolidus || ch.cell() == Tilde) {
state = Ascii;
}
j = ch.cell();
} else if ((j = conv->UnicodeToJisx0201(ch.row(), ch.cell())) != 0) {
if (j < 0x80) {
// JIS X 0201 Latin
if (state != Ascii ||
ch.cell() == YenSign || ch.cell() == Overline) {
state = JISX0201_Latin;
}
} else {
// JIS X 0201 Kana
state = JISX0201_Kana;
j &= 0x7f;
}
} else if ((j = conv->UnicodeToJisx0208(ch.row(), ch.cell())) != 0) {
// JIS X 0208
state = JISX0208_1983;
} else if ((j = conv->UnicodeToJisx0212(ch.row(), ch.cell())) != 0) {
// JIS X 0212
state = JISX0212;
} else {
// Invalid
state = Unknown;
j = '?';
}
if (state != prev) {
if (state == Unknown) {
result += Esc_Ascii;
} else {
result += Esc_SEQ[state - MinState];
}
prev = state;
}
if (j < 0x0100) {
result += j & 0xff;
} else {
result += (j >> 8) & 0xff;
result += j & 0xff;
}
}
if (prev != Ascii) {
result += Esc_Ascii;
}
len_in_out = result.length();
return result;
}
示例7: if
static int hex2int( QChar hexchar )
{
int v;
if ( hexchar.isDigit() )
v = hexchar.digitValue();
else if ( hexchar >= 'A' && hexchar <= 'F' )
v = hexchar.cell() - 'A' + 10;
else if ( hexchar >= 'a' && hexchar <= 'f' )
v = hexchar.cell() - 'a' + 10;
else
v = -1;
return v;
}
示例8: matchcharclass
static bool matchcharclass( uint *rxd, QChar c )
{
uint *d = rxd;
uint clcode = *d & MCD;
bool neg = clcode == CCN;
if ( clcode != CCL && clcode != CCN)
qWarning("QRegExp: Internal error, please report to [email protected]");
uint numFields = *d & MVL;
uint cval = (((uint)(c.row())) << 8) | ((uint)c.cell());
bool found = FALSE;
for ( int i = 0; i < (int)numFields; i++ ) {
d++;
if ( *d == PWS && c.isSpace() ) {
found = TRUE;
break;
}
if ( *d == PDG && c.isDigit() ) {
found = TRUE;
break;
}
else {
uint from = ( *d & MCD ) >> 16;
uint to = *d & MVL;
if ( (cval >= from) && (cval <= to) ) {
found = TRUE;
break;
}
}
}
return neg ? !found : found;
}
示例9: wt_indentChar
/*
indent when there has nothing before the char in the block
charPos is positive position
*/
void Wt_TextEdit::wt_indentChar(int charPos, int toCharPos)
{
printf("wt_indentChar \n");
QTextCursor textCursor = this->textCursor();
textCursor.setPosition(toCharPos, QTextCursor::MoveAnchor);
QString toLine = textCursor.block().text();
textCursor.setPosition(charPos, QTextCursor::MoveAnchor);
int charBlockPos = textCursor.positionInBlock();
QString line = textCursor.block().text();
QChar mchar = line[charBlockPos];
// printf("mchar : %c | line : %s | charBlockPos: %d\n", mchar.cell(), line.toStdString().c_str(), charBlockPos);
if(line.trimmed()[0] != mchar) {
printf("mchar return : %c\n", mchar.cell());
return;
}
/*
textCursor.setPosition(charPos, QTextCursor::KeepAnchor);
pos between Anchor will be selected , delete will clear all selection
*/
for(int i = 0; i < charBlockPos ; i++) {
printf("deleteChar\n");
textCursor.deletePreviousChar();
}
for(int i = 0 ; i < toLine.length() ; i++) {
if(toLine[i] == ' ' || toLine[i] == '\t') {
textCursor.insertText(QString(toLine[i]));
} else {
break;
}
}
}
示例10: if
static bool to8bit(const QChar ch, QCString *rstr)
{
bool converted = FALSE;
if( ch.isMark() ) return TRUE; // ignore marks for conversion
if ( ch.row() ) {
if ( ch.row() == 0x05 ) {
if ( ch.cell() > 0x91 )
converted = TRUE;
// 0x0591 - 0x05cf: Hebrew punctuation... dropped
if ( ch.cell() >= 0xD0 )
*rstr += (char)unicode_to_heb_05[ch.cell()- 0xD0];
} else if ( ch.row() == 0x20 ) {
if ( ch.cell() == 0x3E ) {
*rstr += (char)0xAF;
converted = TRUE;
} else if ( ch.cell() == 0x17 ) {
*rstr += (char)0xCF;
converted = TRUE;
}
} else {
converted = FALSE;
}
} else {
if ( ch.cell() < 0x80 ) {
*rstr += (char)ch.cell();
converted = TRUE;
} else if( ch.cell() < 0xA0 ) {
*rstr += (char)unicode_to_heb_00[ch.cell() - 0x80];
converted = TRUE;
}
}
if(converted) return TRUE;
// couldn't convert the char... lets try its decomposition
QString d = ch.decomposition();
if(d.isNull())
return FALSE;
int l = d.length();
for (int i=0; i<l; i++) {
const QChar ch = d[i];
if(to8bit(ch, rstr))
converted = TRUE;
}
return converted;
}
示例11: fromUnicode
/*!
\reimp
*/
QCString QSjisCodec::fromUnicode(const QString& uc, int& len_in_out) const
{
int l = QMIN((int)uc.length(),len_in_out);
int rlen = l*2+1;
QCString rstr(rlen);
uchar* cursor = (uchar*)rstr.data();
for (int i=0; i<l; i++) {
QChar ch = uc[i];
uint j;
if ( ch.row() == 0x00 && ch.cell() < 0x80 ) {
// ASCII
*cursor++ = ch.cell();
} else if ((j = conv->UnicodeToJisx0201(ch.row(), ch.cell())) != 0) {
// JIS X 0201 Latin or JIS X 0201 Kana
*cursor++ = j;
} else if ((j = conv->UnicodeToSjis(ch.row(), ch.cell())) != 0) {
// JIS X 0208
*cursor++ = (j >> 8);
*cursor++ = (j & 0xff);
} else if ((j = conv->UnicodeToJisx0212(ch.row(), ch.cell())) != 0) {
示例12: convertFromUnicode
/*!
Converts the first \a len characters in \a uc from Unicode to this
encoding, and returns the result in a byte array. The \a state contains
some conversion flags, and is used by the codec to maintain state
information.
*/
QByteArray QTsciiCodec::convertFromUnicode(const ushort *uc, int len, ConverterState *state)
{
char replacement = '?';
if (state) {
if (state->flags & ConvertInvalidToNull)
replacement = 0;
}
int invalid = 0;
QByteArray rstr;
rstr.resize(len);
uchar* cursor = (uchar*)rstr.data();
for (int i = 0; i < len; i++) {
QChar ch = uc[i];
uchar j;
if (ch.row() == 0x00 && ch.cell() < 0x80) {
// ASCII
j = ch.cell();
} else if ((j = qt_UnicodeToTSCII(uc[i],
uc[i + 1],
uc[i + 2]))) {
// We have to check the combined chars first!
i += 2;
} else if ((j = qt_UnicodeToTSCII(uc[i],
uc[i + 1], 0))) {
i++;
} else if ((j = qt_UnicodeToTSCII(uc[i], 0, 0))) {
} else {
// Error
j = replacement;
++invalid;
}
*cursor++ = j;
}
rstr.resize(cursor - (const uchar*)rstr.constData());
if (state) {
state->invalidChars += invalid;
}
return rstr;
}
示例13: encodeFileName
void encodeFileName(QString & szPath)
{
QString szSrc(szPath);
szPath = "";
for(int i = 0; i < szSrc.length(); i++)
{
QChar cur = szSrc[i];
if( ! (cur.isLetter() || cur.isDigit() || cur==' ' || cur=='_' || cur=='.' || cur=='#' || cur=='%') )
{
if(cur.row()!=0)
{
szPath += '%';
szPath += cHexChars[cur.row() >> 4];
szPath += cHexChars[cur.row() & 15];
}
szPath += '%';
szPath += cHexChars[cur.cell() >> 4];
szPath += cHexChars[cur.cell() & 15];
} else if (cur=='%')
示例14: if
static uint *dump( uint *p )
{
while ( *p != END ) {
if ( *p & CHR ) {
QChar uc = (QChar)*p;
char c = (char)uc;
uint u = (((uint)(uc.row())) << 8) | ((uint)uc.cell());
qDebug( "\tCHR\tU%04x (%c)", u, (c ? c : ' '));
p++;
}
else if ( *p & MCC ) {
uint clcode = *p & MCD;
uint numFields = *p & MVL;
if ( clcode == CCL )
qDebug( "\tCCL\t%i", numFields );
else if ( clcode == CCN )
qDebug( "\tCCN\t%i", numFields );
else
qDebug("coding error!");
for ( int i = 0; i < (int)numFields; i++ ) {
p++;
if ( *p == PWS )
qDebug( "\t\tPWS" );
else if ( *p == PDG )
qDebug( "\t\tPDG" );
else {
uint from = ( *p & MCD ) >> 16;
uint to = *p & MVL;
char fc = (char)QChar(from);
char tc = (char)QChar(to);
qDebug( "\t\tU%04x (%c) - U%04x (%c)", from,
(fc ? fc : ' '), to, (tc ? tc : ' ') );
}
}
p++;
}
else switch ( *p++ ) {
示例15: character
QPixmap PixmapCache::character(const QChar &character)
{
auto p = pixmap(QStringLiteral(":/asset/font.png"));
return p.copy(character.cell() % 16 * 64, character.cell() / 16 * 64, 64,
64);
}