Changeset View
Changeset View
Standalone View
Standalone View
layers/selections/text/kpTextSelection_Cursor.cpp
Context not available. | |||||
74 | const QFontMetrics fontMetrics (d->textStyle.fontMetrics ()); | 74 | const QFontMetrics fontMetrics (d->textStyle.fontMetrics ()); | ||
---|---|---|---|---|---|
75 | 75 | | |||
76 | // (should be 0 but call just in case) | 76 | // (should be 0 but call just in case) | ||
77 | int charLocalLeft = fontMetrics.width (d->textLines [row], 0); | 77 | int charLocalLeft =fontMetrics. | ||
78 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) | ||||
79 | horizontalAdvance | ||||
80 | #else | ||||
81 | width | ||||
82 | #endif | ||||
83 | (d->textLines [row], 0); | ||||
78 | 84 | | |||
79 | // OPT: binary search or guess location then move | 85 | // OPT: binary search or guess location then move | ||
80 | for (int col = 0; col < static_cast<int> (d->textLines [row].length ()); col++) | 86 | for (int col = 0; col < static_cast<int> (d->textLines [row].length ()); col++) | ||
81 | { | 87 | { | ||
82 | // OPT: fontMetrics::charWidth() might be faster | 88 | // OPT: fontMetrics::charWidth() might be faster | ||
83 | const int nextCharLocalLeft = fontMetrics.width (d->textLines [row], col + 1); | 89 | const int nextCharLocalLeft = fontMetrics. | ||
90 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) | ||||
91 | horizontalAdvance | ||||
92 | #else | ||||
93 | fontMetrics.width | ||||
94 | #endif | ||||
95 | (d->textLines [row], col + 1); | ||||
96 | | ||||
84 | if (localX <= (charLocalLeft + nextCharLocalLeft) / 2) { | 97 | if (localX <= (charLocalLeft + nextCharLocalLeft) / 2) { | ||
85 | return col; | 98 | return col; | ||
86 | } | 99 | } | ||
Context not available. | |||||
119 | { | 132 | { | ||
120 | line.insert (preeditText.position ().x (), preeditText.preeditString ()); | 133 | line.insert (preeditText.position ().x (), preeditText.preeditString ()); | ||
121 | } | 134 | } | ||
122 | const int x = fontMetrics.width (line.left (col)); | 135 | | ||
136 | const int x =fontMetrics. | ||||
137 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) | ||||
138 | horizontalAdvance | ||||
139 | #else | ||||
140 | width | ||||
141 | #endif | ||||
142 | (line.left (col)); | ||||
143 | | ||||
123 | const int y = row * fontMetrics.height () + | 144 | const int y = row * fontMetrics.height () + | ||
124 | (row >= 1 ? row * fontMetrics.leading () : 0); | 145 | (row >= 1 ? row * fontMetrics.leading () : 0); | ||
125 | 146 | | |||
Context not available. |